How to run an application with certain group permissions

devicespermissions

I have a 3D printer, with which my PC can communicate through /dev/ttyACM0:

crw-rw---- 1 root uucp 166,  0 16 nov 14:58 ttyACM0

The 3D printing application repetierHost requires read/write access to this device in order to function. If I 'naively' start the application without any preparation, the application doesn't work.

If I run the application as root, it works.

If I run the application as a normal user with (supplementary) group uucp, it still doesn't work.

If I give /dev/ttyACM0 the permission flags rw-rw-rw-, and run it with my normal user, it works.

(Why) does my permission through the uucp group not pass on to the application?

I would not be opposed to just giving the file rw-rw-rw- permissions, but these are reset when the device is disconnected and reconnected. If I can't make this work through theuucp group, how can I instead make the change to the permission flags persistent?

Best Answer

I would set the group of the repetierHost application to uucp and then set the SGID bit (as long as it is a real binary and not script):

chgrp uucp repetierHost
chmod g+s repetierHost

If the repetierHost is a script you could consider moving that to repetierHost.sh and write a small C programming wrapper repetierHost that calls repetierHost.sh

E.g.:

#include <stdlib.h>

int 
main(int argc, char *argv[])
{
    system("/path/to/repetierHost.sh");
}
Related Question