mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-30 09:26:15 +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
|
@ -6,11 +6,13 @@ START_SNAPCLIENT=true
|
|||
# Allowed options:
|
||||
# --help produce help message
|
||||
# -v, --version show version number
|
||||
# -l, --list list pcm devices
|
||||
# -h, --host arg server hostname or ip address
|
||||
# -p, --port arg (=1704) server port
|
||||
# -l, --list list pcm devices
|
||||
# -s, --soundcard arg (=default) index or name of the soundcard
|
||||
# -d, --daemon [=arg(=-3)] daemonize, optional process priority [-20..19]
|
||||
# --user arg the user[:group] to run snapclient as when daemonized
|
||||
# --latency arg (=0) latency of the soundcard
|
||||
# -i, --instance arg (=1) instance id
|
||||
|
||||
SNAPCLIENT_OPTS="-d"
|
||||
SNAPCLIENT_OPTS=""
|
||||
|
|
|
@ -18,7 +18,6 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin:/
|
|||
DESC="Snapcast client"
|
||||
NAME=snapclient
|
||||
DAEMON=/usr/bin/$NAME
|
||||
SNAPCLIENT_OPTS="-d"
|
||||
PIDFILE=/var/run/$NAME/pid
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
|
||||
|
@ -27,6 +26,7 @@ SCRIPTNAME=/etc/init.d/$NAME
|
|||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||
SNAPCLIENT_OPTS="-d --user snapclient:audio $SNAPCLIENT_OPTS"
|
||||
|
||||
if [ "$START_SNAPCLIENT" != "true" ] ; then
|
||||
exit 0
|
||||
|
|
|
@ -6,7 +6,7 @@ Requires=network-online.target
|
|||
[Service]
|
||||
EnvironmentFile=-/etc/default/snapclient
|
||||
Type=forking
|
||||
ExecStart=/usr/sbin/snapclient $SNAPCLIENT_OPTS
|
||||
ExecStart=/usr/sbin/snapclient -d --user snapclient:audio $SNAPCLIENT_OPTS
|
||||
PIDFile=/var/run/snapclient.pid
|
||||
Restart=always
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -9,7 +9,7 @@ SERVICE_PID_FILE=/var/run/$SERVICE_NAME/pid
|
|||
|
||||
DESC="Snapcast client"
|
||||
DAEMON=/usr/bin/$SERVICE_NAME
|
||||
SNAPCLIENT_OPTS="-d --user root"
|
||||
SNAPCLIENT_OPTS="-d"
|
||||
|
||||
|
||||
# Exit if the package is not installed
|
||||
|
|
|
@ -9,7 +9,7 @@ SERVICE_PID_FILE=/var/run/$SERVICE_NAME/pid
|
|||
|
||||
DESC="Snapcast server"
|
||||
DAEMON=/usr/bin/$SERVICE_NAME
|
||||
SNAPSERVER_OPTS="-d --user root"
|
||||
SNAPSERVER_OPTS="-d"
|
||||
|
||||
|
||||
# Exit if the package is not installed
|
||||
|
|
|
@ -4,18 +4,23 @@
|
|||
START_SNAPSERVER=true
|
||||
|
||||
# Allowed options:
|
||||
# -h, --help produce help message
|
||||
# -v, --version show version number
|
||||
# -p, --port arg (=1704) server port
|
||||
# -h, --help Produce help message
|
||||
# -v, --version Show version number
|
||||
# -p, --port arg (=1704) Server port
|
||||
# --controlPort arg (=1705) Remote control port
|
||||
# -s, --sampleformat arg (=48000:16:2)
|
||||
# sample format
|
||||
# -c, --codec arg (=flac) transport codec [flac|ogg|pcm][:options]
|
||||
# -s, --stream arg (=pipe:///tmp/snapfifo?name=default)
|
||||
# URI of the PCM input stream.
|
||||
# Format: TYPE://host/path?name=NAME
|
||||
# [&codec=CODEC]
|
||||
# [&sampleformat=SAMPLEFORMAT]
|
||||
# --sampleformat arg (=48000:16:2) Default sample format
|
||||
# -c, --codec arg (=flac) Default transport codec
|
||||
# (flac|ogg|pcm)[:options]
|
||||
# Type codec:? to get codec specific options
|
||||
# -f, --fifo arg (=/tmp/snapfifo) name of the input fifo file
|
||||
# -d, --daemon [=arg(=0)] daemonize
|
||||
# --streamBuffer arg (=20) Default stream read buffer [ms]
|
||||
# -b, --buffer arg (=1000) Buffer [ms]
|
||||
# -d, --daemon [=arg(=0)] Daemonize
|
||||
# optional process priority [-20..19]
|
||||
# -b, --buffer arg (=1000) buffer [ms]
|
||||
# --pipeReadBuffer arg (=20) pipe read buffer [ms]
|
||||
# --user arg the user[:group] to run snapserver as when daemonized
|
||||
|
||||
SNAPSERVER_OPTS="-d"
|
||||
SNAPSERVER_OPTS=""
|
||||
|
|
|
@ -18,7 +18,6 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin:/
|
|||
DESC="Snapcast server"
|
||||
NAME=snapserver
|
||||
DAEMON=/usr/bin/$NAME
|
||||
SNAPSERVER_OPTS="-d"
|
||||
PIDFILE=/var/run/$NAME/pid
|
||||
SCRIPTNAME=/etc/init.d/$NAME
|
||||
|
||||
|
@ -27,6 +26,7 @@ SCRIPTNAME=/etc/init.d/$NAME
|
|||
|
||||
# Read configuration variable file if it is present
|
||||
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
|
||||
SNAPSERVER_OPTS="-d --user snapserver:snapserver $SNAPSERVER_OPTS"
|
||||
|
||||
if [ "$START_SNAPSERVER" != "true" ] ; then
|
||||
exit 0
|
||||
|
|
|
@ -6,7 +6,7 @@ Requires=network-online.target
|
|||
[Service]
|
||||
EnvironmentFile=-/etc/default/snapserver
|
||||
Type=forking
|
||||
ExecStart=/usr/sbin/snapserver $SNAPSERVER_OPTS
|
||||
ExecStart=/usr/sbin/snapserver -d --user snapserver:snapserver $SNAPSERVER_OPTS
|
||||
PIDFile=/var/run/snapserver.pid
|
||||
Restart=always
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
Value<int> bufferValue("b", "buffer", "Buffer [ms]", settings.bufferMs, &settings.bufferMs);
|
||||
Implicit<int> daemonOption("d", "daemon", "Daemonize\noptional process priority [-20..19]", 0, &processPriority);
|
||||
Value<string> userValue("", "user", "the user[:group] to run snapserver as when daemonized", "snapserver:snapserver");
|
||||
Value<string> userValue("", "user", "the user[:group] to run snapserver as when daemonized", "");
|
||||
|
||||
OptionParser op("Allowed options");
|
||||
op.add(helpSwitch)
|
||||
|
@ -146,12 +146,19 @@ int main(int argc, char* argv[])
|
|||
if (daemonOption.isSet())
|
||||
{
|
||||
#ifdef HAS_DAEMON
|
||||
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, "/var/run/snapserver/pid");
|
||||
if (processPriority < -20)
|
||||
processPriority = -20;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue