#6162 Add UID arg so service can change process user
This commit is contained in:
parent
23464a38a7
commit
b028e88fed
|
@ -33,21 +33,22 @@
|
||||||
#include "ipc/Ipc.h"
|
#include "ipc/Ipc.h"
|
||||||
#include "base/EventQueue.h"
|
#include "base/EventQueue.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#if SYSAPI_WIN32
|
#if SYSAPI_WIN32
|
||||||
#include "arch/win32/ArchMiscWindows.h"
|
#include "arch/win32/ArchMiscWindows.h"
|
||||||
#include "base/IEventQueue.h"
|
#include "base/IEventQueue.h"
|
||||||
#include "base/TMethodJob.h"
|
#include "base/TMethodJob.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#if WINAPI_CARBON
|
#if WINAPI_CARBON
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
#include "platform/OSXDragSimulator.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if WINAPI_XWINDOWS
|
||||||
#include "platform/OSXDragSimulator.h"
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
App* App::s_instance = nullptr;
|
App* App::s_instance = nullptr;
|
||||||
|
@ -172,6 +173,21 @@ App::initApp(int argc, const char** argv)
|
||||||
{
|
{
|
||||||
// parse command line
|
// parse command line
|
||||||
parseArgs(argc, argv);
|
parseArgs(argc, argv);
|
||||||
|
|
||||||
|
#if WINAPI_XWINDOWS
|
||||||
|
// for use on linux, tell the core process what user id it should run as.
|
||||||
|
// this is a simple way to allow the core process to talk to X. this avoids
|
||||||
|
// the "WARNING: primary screen unavailable: unable to open screen" error.
|
||||||
|
// a better way would be to use xauth cookie and dbus to get access to X.
|
||||||
|
if (!argsBase().m_runAsUid != -1) {
|
||||||
|
if (setuid(argsBase().m_runAsUid) == 0) {
|
||||||
|
LOG((CLOG_DEBUG "process uid was set to: %d", argsBase().m_runAsUid));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LOG((CLOG_WARN "failed to set process uid to: %d", argsBase().m_runAsUid));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ARCH->setProfileDirectory(argsBase().m_profileDirectory);
|
ARCH->setProfileDirectory(argsBase().m_profileDirectory);
|
||||||
ARCH->setPluginDirectory(argsBase().m_pluginDirectory);
|
ARCH->setPluginDirectory(argsBase().m_pluginDirectory);
|
||||||
|
|
|
@ -299,6 +299,9 @@ ArgParser::parseGenericArgs(int argc, const char* const* argv, int& i)
|
||||||
else if (isArg(i, argc, argv, NULL, "--plugin-dir", 1)) {
|
else if (isArg(i, argc, argv, NULL, "--plugin-dir", 1)) {
|
||||||
argsBase().m_pluginDirectory = argv[++i];
|
argsBase().m_pluginDirectory = argv[++i];
|
||||||
}
|
}
|
||||||
|
else if (isArg(i, argc, argv, NULL, "--run-as-uid", 1)) {
|
||||||
|
argsBase().m_runAsUid = std::stoi(argv[++i]);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
// option not supported here
|
// option not supported here
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -29,6 +29,7 @@ m_daemon(true), // backward compatibility for unix (daemon by default)
|
||||||
#endif
|
#endif
|
||||||
#if WINAPI_XWINDOWS
|
#if WINAPI_XWINDOWS
|
||||||
m_disableXInitThreads(false),
|
m_disableXInitThreads(false),
|
||||||
|
m_runAsUid(-1),
|
||||||
#endif
|
#endif
|
||||||
m_backend(false),
|
m_backend(false),
|
||||||
m_restartable(true),
|
m_restartable(true),
|
||||||
|
|
|
@ -44,6 +44,7 @@ public:
|
||||||
#endif
|
#endif
|
||||||
#if WINAPI_XWINDOWS
|
#if WINAPI_XWINDOWS
|
||||||
bool m_disableXInitThreads;
|
bool m_disableXInitThreads;
|
||||||
|
int m_runAsUid;
|
||||||
#endif
|
#endif
|
||||||
bool m_shouldExit;
|
bool m_shouldExit;
|
||||||
String m_synergyAddress;
|
String m_synergyAddress;
|
||||||
|
|
Loading…
Reference in New Issue