diff --git a/headers/private/libroot/user_group.h b/headers/private/libroot/user_group.h index a6c1631032..945415e043 100644 --- a/headers/private/libroot/user_group.h +++ b/headers/private/libroot/user_group.h @@ -89,6 +89,7 @@ public: port_id get_registrar_authentication_port(); +void set_registrar_authentication_port(port_id port); status_t send_authentication_request_to_registrar(KMessage& request, KMessage& reply); diff --git a/src/servers/launch/Jamfile b/src/servers/launch/Jamfile index 93c927146a..09d2ec7901 100644 --- a/src/servers/launch/Jamfile +++ b/src/servers/launch/Jamfile @@ -1,6 +1,6 @@ SubDir HAIKU_TOP src servers launch ; -UsePrivateHeaders app package shared storage support ; +UsePrivateHeaders app libroot shared storage support ; UsePrivateSystemHeaders ; UseHeaders [ FDirName $(HAIKU_TOP) src bin multiuser ] ; diff --git a/src/servers/launch/Job.cpp b/src/servers/launch/Job.cpp index 093275746c..449ae0c34c 100644 --- a/src/servers/launch/Job.cpp +++ b/src/servers/launch/Job.cpp @@ -11,6 +11,8 @@ #include #include +#include + #include "Target.h" @@ -241,6 +243,11 @@ Job::Init(const Finder& finder, std::set& dependencies) break; } iterator->second.SetInt32("port", port); + + if (name == "x-vnd.haiku-registrar:auth") { + // Allow the launch_daemon to access the registrar authentication + BPrivate::set_registrar_authentication_port(port); + } } if (fInitStatus == B_OK && fCreateDefaultPort && !defaultPort) { diff --git a/src/servers/launch/LaunchDaemon.cpp b/src/servers/launch/LaunchDaemon.cpp index 0b3c95c9a0..1b792abf58 100644 --- a/src/servers/launch/LaunchDaemon.cpp +++ b/src/servers/launch/LaunchDaemon.cpp @@ -702,7 +702,7 @@ LaunchDaemon::_StartSession(const char* login) { // TODO: enable user/group code // The launch_daemon currently cannot talk to the registrar, though -/* + struct passwd* passwd = getpwnam(login); if (passwd == NULL) return B_NAME_NOT_FOUND; @@ -712,7 +712,6 @@ LaunchDaemon::_StartSession(const char* login) // Check if there is a user session running already uid_t user = passwd->pw_uid; gid_t group = passwd->pw_gid; -*/ Unlock(); @@ -720,22 +719,12 @@ LaunchDaemon::_StartSession(const char* login) if (setsid() < 0) exit(EXIT_FAILURE); -/* -debug_printf("session leader...\n"); - if (initgroups(login, group) == -1) { -debug_printf("1.ouch: %s\n", strerror(errno)); + if (initgroups(login, group) == -1) exit(EXIT_FAILURE); - } - //endgrent(); - if (setgid(group) != 0) { -debug_printf("2.ouch: %s\n", strerror(errno)); + if (setgid(group) != 0) exit(EXIT_FAILURE); - } - if (setuid(user) != 0) { -debug_printf("3.ouch: %s\n", strerror(errno)); + if (setuid(user) != 0) exit(EXIT_FAILURE); - } -*/ // TODO: This leaks the parent application be_app = NULL; diff --git a/src/system/libroot/posix/user_group_common.cpp b/src/system/libroot/posix/user_group_common.cpp index 5c234bf2f9..eb5911b1e1 100644 --- a/src/system/libroot/posix/user_group_common.cpp +++ b/src/system/libroot/posix/user_group_common.cpp @@ -67,6 +67,13 @@ BPrivate::get_registrar_authentication_port() } +void +BPrivate::set_registrar_authentication_port(port_id port) +{ + sRegistrarPort = port; +} + + status_t BPrivate::send_authentication_request_to_registrar(KMessage& request, KMessage& reply)