Execute-Bit got automatically set on all files copying from USB connected Android phone

Hello everybody.

recently I discovered on a text file copied per USB from my Pixel4a the execute bit was set automatically. I tried to read it by opening it from Caja but got the question if I want to execute it. By checking other files (like photos) after that I found out, that all files I transfer from the automatically "mounted" phone get there execute bit set.

I use Ubuntu MATE 22.04 LTS with the latest updates - and it looks like

Caja automatically a kind of mounts it via mtp/mtpfs (gvfs? - the device is reachable via '/run/user/1000/gvfs' as 'mtp:host=Google_Pixel_4a_17051JEC200361' too. The "mount" command doesn't show it.)

  • while I use on the phone the options:
    MTP and the Android device handling the connection. (Changing the option to let the connected device handling the connection is not possible.)

Is there any help where I can change this default behavior so in the future nothing gets copied in a way it lands with an execute bit set on my PC. Maybe something similar to the mount option "file_mode=0644"?

Any help is greatly appreciated!

Thanks a lot,
michaelsf

1 Like

Welcome @michaelsf to the community!

1 Like

Hello,

They say, changing default permissions for auto-mounted USB drive is the answer.

Surely, the group and exact mode must be set to your liking.

Good luck!

2 Likes

Thank you very much! This was a nice idea which looked like something helpful.

Sadly it just didn't work.

After the first try exactly how suggested, I made other attempts with e.g. different names or 0644 instead of 0660 day after day.

Now I'm still searching for a solution or another hint I could try.

Thank you very much again and have a nice day!

...meanwhile I had the chance to connect my mobile via USB to a Xubuntu 22.04LTS PC and copying files to it showed the same effect. So it looks like the problem is not limited to Ubuntu MATE.

... Just an idea

1 Like

Thank you very much!

I read and tried and read and tried and read something else and they say it works only for new files not for files getting copied by cp. Maybe this is the reason the question in the stackoverflow-link isn't marked as solved. It looks like Caja and Thunar somehow use a similar method like cp and somehow assume every file on my android Google Pixel smartphone (automounted mtp/mtpfs) are having an execute bit set which they "preserve".

Thank you very much again.

I wonder if it only happens with my mobile phone...

Could maybe anyone with an Android smartphone try connecting it with the PC with an USB cable and copy some files via Caja and check the permissions of these copied files on the PC?

Thanks again and a wonderful day!

1 Like

You are welcome!

AFAIK, that happens every time when one copies files from (any) USB flash drive (FAT32, etc.) which does not support UX-styled permissions.

I am afraid that is an age long problem.

https://bugzilla.gnome.org/show_bug.cgi?id=586708

Regards!

1 Like

I'm still hoping on some feedback how this behaves with other peoples android phones connected by USB-cable. Meanwhile I found a kind of workaround for me:

I installed samba and changed in /etc/samba/smb.conf the one line to
create mask = 0640
. I can't use the cable for this way but at least it works like it should be via wifi now.

Thanks to all the suggestions so far.

1 Like