0

I have a python program that should automatically change the disc volume names / labels for newly inserted usb mass storage devices - it just uses a system call like fatlabel /dev/sdc1 MyNewLabel details in https://github.com/s-light/usbstick_masscopy/blob/master/usbstick.py

currently i getting an open: Permission denied error. ok - for normal usage that is fine - if i want to change the disc-label i have to use root-privileges.

but i don't like to run my python script with sudo. so is there an other solution to this?
i think it could work in some way if i can create an udev rule that adds these newly attached usb-mass-storage devices to a special group or user that is allowed to change the labeling?! could this work?

edit: i have found how to execute a command without sudo that points to the capability system there the nearest i have found is 'CAP_SYS_ADMIN' i have tested this with this script but i did not get it to work. (iam getting the permission denied errors..)

for my mounting and un-mounting i have found the pmount and pumount option - this works fine. something similar as replacement for fatlabel would be my favorite - but till now i did not find something.

i hope you have some advice / tips for me
sunny greetings stefan

4
  • adduser <user> disk or to the group which has write permission to device. Commented Oct 19, 2017 at 0:26
  • what permission has the 'disk' group? normal file read/write permission is working fine. have you some extended information on this? Commented Oct 19, 2017 at 18:08
  • The disk group has permission to write to all block devices, so it's probably something you don't really want: it lets you break your whole system and bypass filesystem permissions. Commented Oct 20, 2017 at 20:12
  • I'd recommend a udev rule that chowns the block device (specifically the USB stick — matching on the vendor ID, product ID, serial number, or similar) to your user or to a group which you are a member of (that isn't disk!), which should allow you to change the partition label without root. Commented Oct 20, 2017 at 20:14

0

You must log in to answer this question.

Browse other questions tagged .