Score:0

Bluetooth: Files are either not received or they are empty

ke flag

I am trying to transfer images from my phone (an older Huawei model) to a PC running Ubuntu 20.04 LTS via Bluetooth.

Keeping the Bluetooth settings dialog open (as it is described on some web sites), the phone reports that the PC denied the receiption of the file.

Trying "blueman" as suggested in another answer (or in one answer to this question), I have a strange behaviour:

  • If the phone is marked as "trusted device", I get the same error message from the phone.
  • When the phone was marked as "untrusted device", the phone reported that the file has been sent successfully and Ubuntu reported that the file has been received.
    However, the file was not stored on the disk and I was not reproduce that behaviour.

Using bt-obex, my phone reports "file successfully transferred" but the files are not stored in the Downloads directory but an empty file is created in ~/.cache/obexd:

$ mkdir destdir

$ bt-obex -y -s destdir
[OBEX Server] OBEX session opened
[OBEX Server] Transfer started
[Transfer Request]
  Name: IMG_20211009_102029.jpg
  Size: 2667331 bytes
[OBEX Server] OBEX transfer closed
[OBEX Server] OBEX session closed
^C

$ find . | grep IMG_20211009_102029
./.cache/obexd/IMG_20211009_102029.jpg

$ wc .cache/obexd/*.jpg
0 0 0 .cache/obexd/IMG_20211009_102029.jpg

It would not be a problem if the file would be stored in .cache/obexd, but as you can see, the file in that directory is empty!

Why does receiption of the file fail?

EDIT

I found out that receiving files using obexpushd works well...

David avatar
cn flag
You may want to clarify the title. The files are not empty according to the question. The directory you expected to find them in has no files.
Martin Rosenau avatar
ke flag
@David I changed the title
Score:0
ke flag

I found the answer myself:

My HOME directory is a symlink to a directory:

/home/myname is a symlink to /other_directory.

By default, obexd (which is used by both the built-in file receiver and bt-obex) checks that both the temporary file destination (in ~/.cache/obexd) and the "final" one (in ~/Downloads) really are in a sub-directory of the HOME directory.

obexd uses the "real" directory name if symlinks are involved, so it finds out that the full file name /other_directory/.cache/obexd/... does not start with /home/myname/ and refuses to continue the operation.

A solution is doing a pkill obexd and re-starting obexd passing the real home directory name using the -r argument.

I assume that this check is done to avoid that somebody overwrites a file like /usr/bin/ls by sending a file named ../../../../../usr/bin/ls.

Interestingly, this check is done after obexd has opened the file with O_CREAT|O_TRUNC flags, so in this case, /usr/bin/ls would be overwritten by an empty file!

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.