--- suX/src/sux.c 2013/04/09 12:55:51 1.3.2.4 +++ suX/src/sux.c 2013/04/09 15:51:11 1.3.2.6 @@ -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.6 2013/04/09 15:51:11 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,24 +253,14 @@ Run(char **argv, char flg) } if (flg & SUX_GET_FORCE) { - if (setgid(AIT_GET_I16(&proc.proc_gid)) == -1) { - ESYSERR(0); - if (args) - free(args); - return -1; - } - if (setuid(AIT_GET_I16(&proc.proc_uid)) == -1) { - ESYSERR(0); - if (args) - free(args); - return -1; - } - if (setpriority(PRIO_PROCESS, 0, AIT_GET_I32(&proc.proc_prio)) == -1) { - ESYSERR(0); - if (args) - free(args); - return -1; - } + /* + if (setegid(AIT_GET_I16(&proc.proc_gid)) == -1) + goto err; + if (seteuid(AIT_GET_I16(&proc.proc_uid)) == -1) + goto err; + */ + if (setpriority(PRIO_PROCESS, 0, AIT_GET_I32(&proc.proc_prio)) == -1) + goto err; } DumpProc(__func__); @@ -292,9 +274,10 @@ Run(char **argv, char flg) fflush(lf); execve(cmd, args, environ); - if (args) - free(args); +err: ESYSERR(0); + if (args) + e_free(args); return -1; }