Not all systems implement setuid(2) the way you expect.

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8362 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Björn Groenvall
2000-06-09 09:59:47 +00:00
parent 0268cb4d24
commit f3c11fde79

View File

@@ -954,14 +954,19 @@ main (int argc, char **argv)
*/
{
struct passwd *pw;
uid_t uid = getuid();
if (!(pw = k_getpwuid(0)))
errx (1, "can't get root's passwd!");
strlcpy(root_cpass, pw->pw_passwd, sizeof(root_cpass));
if (!(pw = k_getpwuid(getuid())))
if (!(pw = k_getpwuid(uid)))
errx (1, "Can't get your password entry!");
strlcpy(user_cpass, pw->pw_passwd, sizeof(user_cpass));
setuid(getuid());
setuid(uid);
if (uid != 0 && setuid(0) != -1) {
fprintf(stderr, "Failed to drop privileges!");
exit(1);
}
/* Now we're no longer running setuid root. */
strlcpy(login, pw->pw_name, sizeof(login));
}