When I use su(1) to change my UID and then touch(1) a file which does not yet exist, the new file has the correct owner, but the associated group is the one for my original login; it does not reflect the change of GID. I have no difficulty changing the group associated with the new file after the fact using chown(), but the original value surprises me.
This is not the fault of su(1). When I run a C program which calls setgid(2) and setuid(2) (and also changes the environment variable USER), the behavior is the same. And yes, I check the returned result from setgid(2) and setuid(2), and also print the returned result from getuid(2), geteuid(2), getgid(2), and getegid(2).
Is this a feature? If so, why would one want this feature? I suspect that this, um, wonderful behavior is specified in a configuration file somewhere, and I can turn it off. True? and how?
This is not the fault of su(1). When I run a C program which calls setgid(2) and setuid(2) (and also changes the environment variable USER), the behavior is the same. And yes, I check the returned result from setgid(2) and setuid(2), and also print the returned result from getuid(2), geteuid(2), getgid(2), and getegid(2).
Is this a feature? If so, why would one want this feature? I suspect that this, um, wonderful behavior is specified in a configuration file somewhere, and I can turn it off. True? and how?