Cannot receive file over Bluetooth

In the absence of Wi-Fi and USB cables, all I was left with was Bluetooth. However, upon multiples attempts, I was unable to send the PDF I needed from my phone to my laptop.

It looks like it boils down to obex.service, which is responsible for sending/receiving files over Bluetooth.

journalctl -ft obexd showed some suspicious error messages, so I tried launching it manually via /usr/libexec/bluetooth/obexd --debug --nodetach --auto-accept:

…
obexd[9095]: obexd/src/obex.c:obex_session_start() 
obexd[9095]: obexd/src/obex.c:cmd_connect() 
obexd[9095]: CONNECT(0x0), <unknown>(0xff)
obexd[9095]: obexd/src/obex.c:cmd_connect() Selected driver: Object Push server
obexd[9095]: CONNECT(0x0), <unknown>(0x0)
obexd[9095]: obexd/src/obex.c:cmd_put() 
obexd[9095]: PUT(0x2), <unknown>(0xff)
obexd[9095]: obexd/src/obex.c:parse_type() TYPE: application/pdf
obexd[9095]: obexd/src/obex.c:parse_name() NAME: IB002-2019-slajdy.pdf
obexd[9095]: obexd/src/obex.c:parse_length() LENGTH: 3490576
obexd[9095]: open(/home/jurf/.cache/obexd/IB002-2019-slajdy.pdf): Operation not permitted (1)
obexd[9095]: PUT(0x2), Forbidden(0x43)
obexd[9095]: obexd/src/obex.c:cmd_disconnect() session 0x55d4d35917f0
obexd[9095]: DISCONNECT(0x1), <unknown>(0xff)
obexd[9095]: DISCONNECT(0x1), Success(0x20)
obexd[9095]: disconnected: Transport got disconnected
obexd[9095]: obexd/src/obex.c:obex_session_destroy()
…

So, it looks like for some reason it doesn’t have access to files in .cache/obexd/? It was able to create 0-byte placeholder files in it, however. It wasn’t specific to the filename in question.

I tried giving the folder in question the broadest possible permissions, without success (which I would be surprised since obexd is launched as a user service). So maybe SELinux?

I don’t have any trouble reproducing this, I’ll gladly provide more info if needed.

Hmm maybe try a sudo setenforce 0 and then see if it works, or check the journal for any SELinux denials? If that doesn’t work, maybe also try deleting the entire cache directory.

1 Like

Sorry to necro this thread, but sudo setenforce 0 did not work in my case.

I have a similar problem.
In my case the culprit is that ~/.cache is a symlink.
Obexd checks upon opening a file whether its real path is under root folder and if it isn’t, then it throws an Operation not permitted error.
The default root folder is $XDG_CACHE_HOME (which defaults to ~/.cache), while i my case the real path sat under /tmp.
Try to run:
/usr/libexec/bluetooth/obexd --debug --nodetach --auto-accept --symlinks
or select the root folder manually:
mkdir /tmp/obexd
/usr/libexec/bluetooth/obexd --debug --nodetach --auto-accept --root=/tmp/obexd
Btw, I find the error message highly unhelpful.

For reference:
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/obexd/plugins/filesystem.c#n166
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/obexd/plugins/filesystem.c#n115

2 Likes

Solution to make it work unattended:

$ cat ~/.config/systemd/user/obex.service.d/10-symlink.conf
[Service]
ExecStart=
ExecStart=/usr/libexec/bluetooth/obexd --symlinks

Then:

$ systemctl --user daemon-reload
$ systemctl --user restart obex

The problem with Silverblue is probably that /home/$USER is a symlink to /var/home/$USER.

I think on newer Silverblue installs $HOME is on /var/home/$USER, which might partially fix this issue.