Page 1 of 1

[Solved] newgrp creates a subshell!

Posted: 2025-01-15 18:38
by kent_dorfman766
See the attached image description and then note the behaviour when executing the command. They don't match.
LOL

I want to temporarily set my GID value to "devel" so that when I run my IDE the output files are GID=devel, but I don't want my main user GID to default to devel.

The newgrp command spawns a subshell that must be exited when done. That causes me problems. I need the GID switch to occur in the current shell.

Am I going to have to hack the bash sourcecode or is there another way?

And yes, I understand the chmod g+s mechanism, but it only applies to directory heirarchies where it has been set.

Re: [Software] newgrp creates a subshell!

Posted: 2025-01-15 18:56
by lindi
As far as I know an unprivileged process cannot change its GID. You can see the logic at https://github.com/torvalds/linux/blob/ ... sys.c#L447 . You would need to have the CAP_SETGID capability which is almost the same as root already.

Re: [Software] newgrp creates a subshell!

Posted: 2025-01-15 23:15
by kent_dorfman766
lindi wrote: 2025-01-15 18:56 As far as I know an unprivileged process cannot change its GID. You can see the logic at https://github.com/torvalds/linux/blob/ ... sys.c#L447 . You would need to have the CAP_SETGID capability which is almost the same as root already.
Yeah. after writing a short test program, that was my take-away too. grumble grumble...