version 1.24, 2003/05/29 16:58:45 |
version 1.24.12.1, 2006/09/30 04:06:51 |
|
|
|
/* $OpenBSD$ */ |
/* |
/* |
* Author: Tatu Ylonen <ylo@cs.hut.fi> |
* Author: Tatu Ylonen <ylo@cs.hut.fi> |
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
|
|
* called by a name other than "ssh" or "Secure Shell". |
* called by a name other than "ssh" or "Secure Shell". |
*/ |
*/ |
|
|
#include "includes.h" |
#include <sys/param.h> |
RCSID("$OpenBSD$"); |
#include <errno.h> |
|
#include <pwd.h> |
|
#include <string.h> |
|
#include <unistd.h> |
|
#include <stdarg.h> |
|
|
#include "log.h" |
#include "log.h" |
#include "uidswap.h" |
#include "uidswap.h" |
|
|
fatal("permanently_set_uid: temporarily_use_uid effective"); |
fatal("permanently_set_uid: temporarily_use_uid effective"); |
debug("permanently_set_uid: %u/%u", (u_int)pw->pw_uid, |
debug("permanently_set_uid: %u/%u", (u_int)pw->pw_uid, |
(u_int)pw->pw_gid); |
(u_int)pw->pw_gid); |
if (setegid(pw->pw_gid) < 0) |
if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) != 0) |
fatal("setegid %u: %.100s", (u_int)pw->pw_gid, strerror(errno)); |
fatal("setresgid %u: %s", (u_int)pw->pw_gid, strerror(errno)); |
if (setgid(pw->pw_gid) < 0) |
if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) != 0) |
fatal("setgid %u: %.100s", (u_int)pw->pw_gid, strerror(errno)); |
fatal("setresuid %u: %s", (u_int)pw->pw_uid, strerror(errno)); |
if (seteuid(pw->pw_uid) < 0) |
} |
fatal("seteuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno)); |
|
if (setuid(pw->pw_uid) < 0) |
void |
fatal("setuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno)); |
permanently_drop_suid(uid_t uid) |
|
{ |
|
debug("permanently_drop_suid: %u", (u_int)uid); |
|
if (setresuid(uid, uid, uid) != 0) |
|
fatal("setresuid %u: %s", (u_int)uid, strerror(errno)); |
} |
} |