registrar: implemented auth port via launch_daemon.
* get_roster_port_name() is no longer needed. * This also removes the app_server restart code from the debug server -- this will be done by the launch_daemon in the future.
This commit is contained in:
@@ -1,5 +1,8 @@
|
|||||||
service x-vnd.Haiku-registrar {
|
service x-vnd.Haiku-registrar {
|
||||||
launch /system/servers/registrar
|
launch /system/servers/registrar
|
||||||
|
port auth {
|
||||||
|
capacity 100
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
service x-vnd.Haiku-app_server {
|
service x-vnd.Haiku-app_server {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2009, Haiku, Inc. All Rights Reserved.
|
* Copyright 2001-2015, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -18,15 +18,13 @@
|
|||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
// names
|
// names
|
||||||
extern const char* kRegistrarSignature;
|
|
||||||
extern const char* kRosterThreadName;
|
|
||||||
extern const char* kRAppLooperPortName;
|
extern const char* kRAppLooperPortName;
|
||||||
|
|
||||||
extern const char* get_roster_port_name();
|
|
||||||
|
|
||||||
|
#define B_REGISTRAR_SIGNATURE "application/x-vnd.haiku-registrar"
|
||||||
#define REGISTRAR_AUTHENTICATION_PORT_NAME "system:registrar:auth manager"
|
#define B_REGISTRAR_AUTHENTICATION_PORT_NAME "auth"
|
||||||
|
|
||||||
|
|
||||||
// message constants
|
// message constants
|
||||||
@@ -179,7 +177,9 @@ struct flat_app_info {
|
|||||||
char ref_name[B_FILE_NAME_LENGTH + 1];
|
char ref_name[B_FILE_NAME_LENGTH + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|
||||||
|
|
||||||
#endif // REGISTRAR_DEFS_H
|
#endif // REGISTRAR_DEFS_H
|
||||||
|
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ BApplication::_InitData(const char* signature, bool initGUI, status_t* _error)
|
|||||||
|
|
||||||
#ifndef RUN_WITHOUT_REGISTRAR
|
#ifndef RUN_WITHOUT_REGISTRAR
|
||||||
bool registerApp = signature == NULL
|
bool registerApp = signature == NULL
|
||||||
|| (strcasecmp(signature, kRegistrarSignature) != 0
|
|| (strcasecmp(signature, B_REGISTRAR_SIGNATURE) != 0
|
||||||
&& strcasecmp(signature, kLaunchDaemonSignature) != 0);
|
&& strcasecmp(signature, kLaunchDaemonSignature) != 0);
|
||||||
// get team and thread
|
// get team and thread
|
||||||
team_id team = Team();
|
team_id team = Team();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2009, Haiku.
|
* Copyright 2001-2015, Haiku.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -16,28 +16,13 @@
|
|||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
// names
|
// names
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
||||||
const char* kRegistrarSignature = "application/x-vnd.haiku-registrar";
|
|
||||||
const char* kRAppLooperPortName = "rAppLooperPort";
|
const char* kRAppLooperPortName = "rAppLooperPort";
|
||||||
#else
|
#else
|
||||||
const char* kRegistrarSignature = "application/x-vnd.test-registrar";
|
|
||||||
const char* kRAppLooperPortName = "haiku-test:rAppLooperPort";
|
const char* kRAppLooperPortName = "haiku-test:rAppLooperPort";
|
||||||
#endif
|
#endif
|
||||||
const char* kRosterThreadName = "_roster_thread_";
|
|
||||||
|
|
||||||
|
|
||||||
/*! \brief Returns the name of the main request port of the registrar (roster).
|
|
||||||
\return the name of the registrar request port.
|
|
||||||
*/
|
|
||||||
const char*
|
|
||||||
get_roster_port_name()
|
|
||||||
{
|
|
||||||
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
|
|
||||||
return "system:roster";
|
|
||||||
#else
|
|
||||||
return "haiku-test:roster";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace BPrivate
|
} // namespace BPrivate
|
||||||
|
|||||||
@@ -1021,8 +1021,6 @@ TeamDebugHandler::_HandlerThread()
|
|||||||
"initial message: %s", strerror(error));
|
"initial message: %s", strerror(error));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isGuiServer = _IsGUIServer();
|
|
||||||
|
|
||||||
// kill the team or hand it over to the debugger
|
// kill the team or hand it over to the debugger
|
||||||
thread_id debuggerThread = -1;
|
thread_id debuggerThread = -1;
|
||||||
if (debugAction == kActionKillTeam) {
|
if (debugAction == kActionKillTeam) {
|
||||||
@@ -1078,22 +1076,6 @@ TeamDebugHandler::_HandlerThread()
|
|||||||
// remove this handler from the roster and delete it
|
// remove this handler from the roster and delete it
|
||||||
TeamDebugHandlerRoster::Default()->RemoveHandler(fTeam);
|
TeamDebugHandlerRoster::Default()->RemoveHandler(fTeam);
|
||||||
|
|
||||||
if (isGuiServer) {
|
|
||||||
// wait till debugging is done
|
|
||||||
status_t dummy;
|
|
||||||
wait_for_thread(debuggerThread, &dummy);
|
|
||||||
|
|
||||||
// find the registrar port
|
|
||||||
port_id rosterPort = find_port(BPrivate::get_roster_port_name());
|
|
||||||
port_info info;
|
|
||||||
BMessenger messenger;
|
|
||||||
if (rosterPort >= 0 && get_port_info(rosterPort, &info) == B_OK) {
|
|
||||||
BMessenger::Private(messenger).SetTo(info.team, rosterPort,
|
|
||||||
B_PREFERRED_TOKEN);
|
|
||||||
}
|
|
||||||
messenger.SendMessage(kMsgRestartAppServer);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete this;
|
delete this;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "AuthenticationManager.h"
|
#include "AuthenticationManager.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
#include <StringList.h>
|
#include <StringList.h>
|
||||||
|
|
||||||
#include <AutoDeleter.h>
|
#include <AutoDeleter.h>
|
||||||
|
#include <LaunchRoster.h>
|
||||||
#include <RegistrarDefs.h>
|
#include <RegistrarDefs.h>
|
||||||
|
|
||||||
#include <libroot_private.h>
|
#include <libroot_private.h>
|
||||||
@@ -723,12 +725,9 @@ AuthenticationManager::AuthenticationManager()
|
|||||||
|
|
||||||
AuthenticationManager::~AuthenticationManager()
|
AuthenticationManager::~AuthenticationManager()
|
||||||
{
|
{
|
||||||
// delete port and wait for the request thread to finish
|
// Quit the request thread and wait for it to finish
|
||||||
if (fRequestPort >= 0)
|
write_port(fRequestPort, 'quit', NULL, 0);
|
||||||
delete_port(fRequestPort);
|
wait_for_thread(fRequestThread, NULL);
|
||||||
|
|
||||||
status_t dummy;
|
|
||||||
wait_for_thread(fRequestThread, &dummy);
|
|
||||||
|
|
||||||
delete fUserDB;
|
delete fUserDB;
|
||||||
delete fGroupDB;
|
delete fGroupDB;
|
||||||
@@ -752,7 +751,8 @@ AuthenticationManager::Init()
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
fRequestPort = create_port(100, REGISTRAR_AUTHENTICATION_PORT_NAME);
|
fRequestPort = BLaunchRoster().GetPort(
|
||||||
|
B_REGISTRAR_AUTHENTICATION_PORT_NAME);
|
||||||
if (fRequestPort < 0)
|
if (fRequestPort < 0)
|
||||||
return fRequestPort;
|
return fRequestPort;
|
||||||
|
|
||||||
|
|||||||
@@ -57,8 +57,7 @@ static const bigtime_t kRosterSanityEventInterval = 1000000LL;
|
|||||||
*/
|
*/
|
||||||
Registrar::Registrar(status_t* _error)
|
Registrar::Registrar(status_t* _error)
|
||||||
:
|
:
|
||||||
BServer(kRegistrarSignature, BPrivate::get_roster_port_name(), -1,
|
BServer(B_REGISTRAR_SIGNATURE, "system:roster", -1, false, _error),
|
||||||
false, _error),
|
|
||||||
fRoster(NULL),
|
fRoster(NULL),
|
||||||
fClipboardHandler(NULL),
|
fClipboardHandler(NULL),
|
||||||
fMIMEManager(NULL),
|
fMIMEManager(NULL),
|
||||||
@@ -434,7 +433,6 @@ main()
|
|||||||
// app thread.
|
// app thread.
|
||||||
be_clipboard = new BClipboard(NULL);
|
be_clipboard = new BClipboard(NULL);
|
||||||
|
|
||||||
|
|
||||||
// create and run the registrar application
|
// create and run the registrar application
|
||||||
status_t error;
|
status_t error;
|
||||||
Registrar *app = new Registrar(&error);
|
Registrar *app = new Registrar(&error);
|
||||||
@@ -445,7 +443,7 @@ main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// rename the main thread
|
// rename the main thread
|
||||||
rename_thread(find_thread(NULL), kRosterThreadName);
|
rename_thread(find_thread(NULL), "roster");
|
||||||
|
|
||||||
PRINT("app->Run()...\n");
|
PRINT("app->Run()...\n");
|
||||||
|
|
||||||
|
|||||||
@@ -1247,7 +1247,7 @@ TRoster::Init()
|
|||||||
if (error == B_OK) {
|
if (error == B_OK) {
|
||||||
info->Init(be_app->Thread(), be_app->Team(),
|
info->Init(be_app->Thread(), be_app->Team(),
|
||||||
BMessenger::Private(be_app_messenger).Port(),
|
BMessenger::Private(be_app_messenger).Port(),
|
||||||
B_EXCLUSIVE_LAUNCH | B_BACKGROUND_APP, &ref, kRegistrarSignature);
|
B_EXCLUSIVE_LAUNCH | B_BACKGROUND_APP, &ref, B_REGISTRAR_SIGNATURE);
|
||||||
info->state = APP_STATE_REGISTERED;
|
info->state = APP_STATE_REGISTERED;
|
||||||
info->registration_time = system_time();
|
info->registration_time = system_time();
|
||||||
error = AddApp(info);
|
error = AddApp(info);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include <errno_private.h>
|
#include <errno_private.h>
|
||||||
|
#include <launch.h>
|
||||||
#include <libroot_private.h>
|
#include <libroot_private.h>
|
||||||
#include <locks.h>
|
#include <locks.h>
|
||||||
#include <RegistrarDefs.h>
|
#include <RegistrarDefs.h>
|
||||||
@@ -54,9 +55,14 @@ BPrivate::user_group_unlock()
|
|||||||
port_id
|
port_id
|
||||||
BPrivate::get_registrar_authentication_port()
|
BPrivate::get_registrar_authentication_port()
|
||||||
{
|
{
|
||||||
if (sRegistrarPort < 0)
|
if (sRegistrarPort < 0) {
|
||||||
sRegistrarPort = find_port(REGISTRAR_AUTHENTICATION_PORT_NAME);
|
BPrivate::KMessage data;
|
||||||
|
if (BPrivate::get_launch_data(B_REGISTRAR_SIGNATURE, data)
|
||||||
|
== B_OK) {
|
||||||
|
sRegistrarPort = data.GetInt32(
|
||||||
|
B_REGISTRAR_AUTHENTICATION_PORT_NAME "_port", -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
return sRegistrarPort;
|
return sRegistrarPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user