openbsd-ports/x11/slim/patches/patch-switchuser_cpp

26 lines
829 B
Plaintext
Raw Normal View History

$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
void SwitchUser::SetUserId() {
if( (Pw == 0) ||
+ (setusercontext(NULL, Pw, Pw->pw_uid, LOGIN_SETPRIORITY|LOGIN_SETRESOURCES) == -1) ||
+ (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) ) {