|
Bugzilla – Full Text Bug Listing |
| Summary: | Unexpected LOGNAME and USER set when sudoing twice | ||
|---|---|---|---|
| Product: | Sudo | Reporter: | Marek Tamaskovic <mtamasko> |
| Component: | Sudo | Assignee: | Todd C. Miller <Todd.Miller> |
| Status: | RESOLVED WORKSFORME | ||
| Severity: | normal | ||
| Priority: | low | ||
| Version: | 1.8.23 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
|
Description
Marek Tamaskovic
2019-03-14 07:41:58 MDT
Isn't this the same as https://bugzilla.sudo.ws/show_bug.cgi?id=805 ? Your example won't work as you expect since the variables are being expanded by your shell before sudo even runs. You need to wrap things in a shell like this: $ sudo -u user sh -c 'echo $LOGNAME' user $ sudo sudo -u user sh -c 'echo $LOGNAME' user # sudo -u user1 sh -c 'echo $LOGNAME' user1 # sudo sudo -u user1 sh -c 'echo $LOGNAME' root Or better to describe this problem as this: [root@host ~]# sudo -u user1 sh -c 'echo $LOGNAME' user1 [root@host ~]# sudo sudo -u user1 sh -c 'echo $LOGNAME' root [user1@host ~]$ sudo -u user2 sh -c 'echo $LOGNAME' user1 [user1@host ~]$ sudo sudo -u user2 sh -c 'echo $LOGNAME' user1 As you can see there are two behaviors one for root and one for other users. I think I found answer in documentation. Please you can close this bug. |