Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

export USERNAME=root in zsh gives permission error

Tags:

shell

zsh

When I run

export USERNAME=root

in zsh it gives me the following error.

zsh: failed to change group ID: operation not permitted

Any idea why?

PS: I did not manually run this initially, but I came across this when my vim-dispatch plugin threw this error while running a command in vim. Afterwards I was able to reproduce this by just running it in any zsh shell.

like image 724
woodstok Avatar asked Nov 25 '25 11:11

woodstok


1 Answers

The parameter USERNAME corresponds to the real user ID of the shell process. Modifying it also changes the real user ID, effectively changing the permissions of the running shell process. This is of course only possible, if the original user has sufficient privileges. In most cases this probably means that only root is allowed to assign to USERNAME, while any other accounts are not permitted.

For example, consider this shell session:

root@host# echo $USERNAME $UID $EUID $GID $EGID
root 0 0 0 0
root@host# USERNAME=adaephon
adaephon@host% echo $USERNAME $UID $EUID $GID $EGID
adaephon 1000 1000 1000 1000
adaephon@host% USERNAME=root
zsh: failed to change group ID: operation not permitted
adaephon@host% echo $USERNAME $UID $EUID $GID $EGID
adaephon 1000 1000 1000 1000   

Starting out as root, I can easily drop my privileges to my normal user account. But I cannot switch back to root as adaephon lacks the necessary privileges.

like image 199
Adaephon Avatar answered Nov 27 '25 12:11

Adaephon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!