launch_daemon: We can now talk to the authentication manager.

* When creating the port of the registrar's authentication manager, we
  now set it manually, so that the user/group functions work.
* This allows LaunchDaemon::_StartSession() to set up the user, and
  groups as needed.
This commit is contained in:
Axel Dörfler
2015-07-22 20:43:26 +02:00
parent 560119c9a4
commit 7987907008
5 changed files with 20 additions and 16 deletions
+1
View File
@@ -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);
+1 -1
View File
@@ -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 ] ;
+7
View File
@@ -11,6 +11,8 @@
#include <Message.h>
#include <Roster.h>
#include <user_group.h>
#include "Target.h"
@@ -241,6 +243,11 @@ Job::Init(const Finder& finder, std::set<BString>& 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) {
+4 -15
View File
@@ -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;
@@ -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)