--- suX/src/sux.c 2013/04/09 12:55:51 1.3.2.4 +++ suX/src/sux.c 2013/04/09 15:44:28 1.3.2.5 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ - * $Id: sux.c,v 1.3.2.4 2013/04/09 12:55:51 misho Exp $ + * $Id: sux.c,v 1.3.2.5 2013/04/09 15:44:28 misho Exp $ * *************************************************************************/ #include "global.h" @@ -131,8 +131,8 @@ setUIDGID(char flg, const char *name) static inline int SetClass() { - login_cap_t *cap; struct passwd *pass; + int ret = 0; pass = getpwuid(AIT_GET_I16(&proc.proc_uid)); if (!pass) { @@ -142,23 +142,15 @@ SetClass() } else AIT_SET_STR(&proc.proc_class, pass->pw_class); - cap = login_getclass(AIT_GET_STR(&proc.proc_class)); - if (!cap) { - Err("Error:: Cant get login class %s", AIT_GET_STR(&proc.proc_class)); - endpwent(); - return -1; - } - - if (setusercontext(cap, pass, AIT_GET_I16(&proc.proc_uid), LOGIN_SETALL)) { + if (setusercontext(NULL, pass, AIT_GET_I16(&proc.proc_uid), + LOGIN_SETRESOURCES | LOGIN_SETGROUP | LOGIN_SETLOGIN | + LOGIN_SETPRIORITY)) { Err("Error:: Cant set login class %s", AIT_GET_STR(&proc.proc_class)); - login_close(cap); - endpwent(); - return -1; + ret = -1; } - login_close(cap); endpwent(); - return 0; + return ret; } static int @@ -261,22 +253,22 @@ Run(char **argv, char flg) } if (flg & SUX_GET_FORCE) { - if (setgid(AIT_GET_I16(&proc.proc_gid)) == -1) { + if (setegid(AIT_GET_I16(&proc.proc_gid)) == -1) { ESYSERR(0); if (args) - free(args); + e_free(args); return -1; } - if (setuid(AIT_GET_I16(&proc.proc_uid)) == -1) { + if (seteuid(AIT_GET_I16(&proc.proc_uid)) == -1) { ESYSERR(0); if (args) - free(args); + e_free(args); return -1; } if (setpriority(PRIO_PROCESS, 0, AIT_GET_I32(&proc.proc_prio)) == -1) { ESYSERR(0); if (args) - free(args); + e_free(args); return -1; } } @@ -293,7 +285,7 @@ Run(char **argv, char flg) execve(cmd, args, environ); if (args) - free(args); + e_free(args); ESYSERR(0); return -1; }