[EMAIL PROTECTED] wrote on 08/09/2004 11:23:43 AM: > I'm writing a script that's run by users as sudo, and I'm trying to find > the original user's id. Does anyone know how to do this? > > eg: > > > ~$ id > > uid=1002(sonia) gid=1002(sonia) groups=1002(sonia),27(sudo) > > ~$ sudo bash > > ~# id > > uid=0(root) gid=0(root) groups=0(root) > > When I run the 'id' command it returns uid=1002. But after sudo'ing to > root, the id command returns uid=0(root). How would I find the user's > original id before they sudo'd to root? >
One way is: uid=1100(scott) gid=1100(Scott Ragen) groups=1100(Scott Ragen),541(rradmin) [EMAIL PROTECTED] scott]$ sudo bash [EMAIL PROTECTED] scott]# set |grep SUDO SUDO_COMMAND=/bin/bash SUDO_GID=1100 SUDO_UID=1100 SUDO_USER=scott Cheers, Scott -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html