Date: Mon, 24 Mar 1997 22:32:45 -0700 From: Warner Losh <imp@village.org> To: hackers@freebsd.org Subject: A good way to... Message-ID: <E0w9Oqk-0000O8-00@rover.village.org>
next in thread | raw e-mail | index | archive | help
OK. I'm looking for some good code that will drop privs, do some operation, and the restore privs. I'm not sure what the best way to do this. I'm thinking it is uid_t xxx, yyy; xxx = geteuid(); yyy = getegid(); seteuid(getuid()) setegid(getgid()) <do it> (eg fopen(zzz, "r");) seteuid(xxx); setegid(yyy); I think this does what I want to do, but can someone punch some holes into this before I commit code like this? Why am I asking this? It turns out that I'm starting to get reports of unintended side effects of some of the checkins that I made It would help if I was able to reproduce the problems here :-(. At least some of them should just drop and raise privs "like" this. This stuff always makes my head spin.... Also, if someone or someones would like to review anything that I do, please let me know. Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E0w9Oqk-0000O8-00>