mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-28 00:16:17 +02:00
don't change user/group by default
This commit is contained in:
parent
fa5aab6dd7
commit
f89bf272e2
10 changed files with 52 additions and 32 deletions
|
@ -88,7 +88,7 @@ int main (int argc, char **argv)
|
|||
Implicit<int> daemonOption("d", "daemon", "daemonize, optional process priority [-20..19]", -3, &processPriority);
|
||||
Value<int> latencyValue("", "latency", "latency of the soundcard", 0, &latency);
|
||||
Value<size_t> instanceValue("i", "instance", "instance id", 1, &instance);
|
||||
Value<string> userValue("", "user", "the user[:group] to run snapclient as when daemonized", "snapclient:audio");
|
||||
Value<string> userValue("", "user", "the user[:group] to run snapclient as when daemonized");
|
||||
|
||||
OptionParser op("Allowed options");
|
||||
op.add(helpSwitch)
|
||||
|
@ -162,13 +162,19 @@ int main (int argc, char **argv)
|
|||
string pidFile = "/var/run/snapclient/pid";
|
||||
if (instance != 1)
|
||||
pidFile += "." + cpt::to_string(instance);
|
||||
|
||||
if (userValue.getValue().empty())
|
||||
std::invalid_argument("user must not be empty");
|
||||
string user = "";
|
||||
string group = "";
|
||||
|
||||
vector<string> user_group = split(userValue.getValue(), ':');
|
||||
string user = user_group[0];
|
||||
string group = (user_group.size() == 1)?user_group[0]:user_group[1];
|
||||
if (userValue.isSet())
|
||||
{
|
||||
if (userValue.getValue().empty())
|
||||
std::invalid_argument("user must not be empty");
|
||||
|
||||
vector<string> user_group = split(userValue.getValue(), ':');
|
||||
user = user_group[0];
|
||||
if (user_group.size() > 1)
|
||||
group = user_group[1];
|
||||
}
|
||||
daemonize(user, group, pidFile);
|
||||
if (processPriority < -20)
|
||||
processPriority = -20;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue