Skip to content

Commit

Permalink
Added --server.uid option.
Browse files Browse the repository at this point in the history
  • Loading branch information
cathyjf committed Oct 24, 2010
1 parent 8d5d9b2 commit 6659323
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const char *getPidFileName() {

int initialise(int argc, char **argv, bool &daemon) {
string configFile;
int port, databasePort, workerThreads;
int port, databasePort, workerThreads, serverUid;
string serverName, welcomeFile, welcomeMessage;
string databaseName, databaseHost, databaseUser, databasePassword;
string authParameter, loginParameter, registerParameter;
Expand Down Expand Up @@ -84,6 +84,9 @@ int initialise(int argc, char **argv, bool &daemon) {
po::value<int>(&workerThreads)->default_value(
20),
"number of worker threads for network I/O")
("server.uid",
po::value<int>(&serverUid),
"UID to run the server process as")
("auth.vbulletin",
po::value<string>(
&authParameter)->implicit_value("vbulletin"),
Expand Down Expand Up @@ -164,6 +167,15 @@ int initialise(int argc, char **argv, bool &daemon) {
po::notify(vm);
}

if (vm.count("server.uid")) {
if (seteuid(serverUid)) {
// Failed to set the UID.
Log::out() << "Failed to set the effective UID to " << serverUid
<< ". Try\n\n sudo shoddybattle2\n\ninstead." << endl;
return EXIT_FAILURE;
}
}

if (vm.count("server.welcome")) {
ifstream file(welcomeFile.c_str());
if (!file.is_open()) {
Expand Down

0 comments on commit 6659323

Please sign in to comment.