2012-09-02 05:22:59 -04:00
|
|
|
$OpenBSD: patch-switchuser_cpp,v 1.4 2012/09/02 09:23:00 landry Exp $
|
|
|
|
add missing setusercontext/setsid/setlogin calls.
|
|
|
|
--- switchuser.cpp.orig Tue Jun 26 10:20:14 2012
|
|
|
|
+++ switchuser.cpp Sat Sep 1 20:51:44 2012
|
|
|
|
@@ -10,6 +10,10 @@
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
+#ifdef __OpenBSD__
|
|
|
|
+#include <sys/types.h>
|
|
|
|
+#include <login_cap.h>
|
|
|
|
+#endif
|
|
|
|
#include "switchuser.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
@@ -36,6 +40,9 @@ void SwitchUser::Login(const char* cmd, const char* mc
|
2010-07-10 06:46:52 -04:00
|
|
|
|
|
|
|
void SwitchUser::SetUserId() {
|
|
|
|
if( (Pw == 0) ||
|
2012-09-02 05:22:59 -04:00
|
|
|
+ (setusercontext(NULL, Pw, Pw->pw_uid, LOGIN_SETPRIORITY|LOGIN_SETRESOURCES) == -1) ||
|
2010-07-10 06:46:52 -04:00
|
|
|
+ (setsid() == -1) ||
|
|
|
|
+ (setlogin(Pw->pw_name) != 0) ||
|
|
|
|
(initgroups(Pw->pw_name, Pw->pw_gid) != 0) ||
|
|
|
|
(setgid(Pw->pw_gid) != 0) ||
|
|
|
|
(setuid(Pw->pw_uid) != 0) ) {
|