Linux program unable to access files in group

Posted on

Problem :

I’m having trouble configuring things on linux so that a program can access certain files. Let’s call it pgm A. It has uid uA and gid gA. In addition, uid uA is listed in /etc/group as a member of group gX. The problem is that pgm A cannot access files for which the uid is root and the gid is gX, but only when pgm A is called from another program, pgm B, which also runs as user uA.

If I su as user uA and run pgm A from bash, it has no problem accessing files in group gX.

But if another program, pgm B, which also runs as user uA, forks and execs pgm A, pgm A cannot access the files. I’ve verified that pgm A is indeed running as user uA, group gA, when launched from pgm B. So, if uA is a member of group gX, why can’t the program access files which are readable by group gX? It’s as if the operating system is ignoring the fact that user uA is also in group gX.

Solution :

You may need to login again after adding the user to the group, as group permissions are only read on login time.

Leave a Reply

Your email address will not be published. Required fields are marked *