Merge pull request #148 from unknownloner/master

Allow MPD Password to be configured in command line options
This commit is contained in:
Andy 2018-01-22 04:23:51 +01:00 committed by GitHub
commit f7aade410d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 3 deletions

View File

@ -35,7 +35,7 @@ WEB_PORT=8080
# Load the VERBOSE setting and other rcS variables # Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS [ -f /etc/default/rcS ] && . /etc/default/rcS
DAEMON_OPT="--user $YMPD_USER --webport $WEB_PORT --host $MPD_HOST --port $MPD_PORT" DAEMON_OPT="--user $YMPD_USER --mpdpass '$MPD_PASSWORD' --webport $WEB_PORT --host $MPD_HOST --port $MPD_PORT"
do_start() do_start()
{ {

View File

@ -1,4 +1,5 @@
MPD_HOST=localhost MPD_HOST=localhost
MPD_PORT=6600 MPD_PORT=6600
MPD_PASSWORD=
WEB_PORT=8080 WEB_PORT=8080
YMPD_USER=nobody YMPD_USER=nobody

View File

@ -5,10 +5,11 @@ Requires=network.target local-fs.target
[Service] [Service]
Environment=MPD_HOST=localhost Environment=MPD_HOST=localhost
Environment=MPD_PORT=6600 Environment=MPD_PORT=6600
Environment=MPD_PASSWORD=
Environment=WEB_PORT=8080 Environment=WEB_PORT=8080
Environment=YMPD_USER=nobody Environment=YMPD_USER=nobody
EnvironmentFile=/etc/default/ympd EnvironmentFile=/etc/default/ympd
ExecStart=/usr/bin/ympd --user $YMPD_USER --webport $WEB_PORT --host $MPD_HOST --port $MPD_PORT ExecStart=/usr/bin/ympd --user $YMPD_USER --mpdpass "$MPD_PASSWORD" --webport $WEB_PORT --host $MPD_HOST --port $MPD_PORT
Type=simple Type=simple
[Install] [Install]

View File

@ -87,10 +87,11 @@ int main(int argc, char **argv)
{"user", required_argument, 0, 'u'}, {"user", required_argument, 0, 'u'},
{"version", no_argument, 0, 'v'}, {"version", no_argument, 0, 'v'},
{"help", no_argument, 0, 0 }, {"help", no_argument, 0, 0 },
{"mpdpass", required_argument, 0, 'm'},
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
while((n = getopt_long(argc, argv, "h:p:w:u:v", while((n = getopt_long(argc, argv, "h:p:w:u:vm:",
long_options, &option_index)) != -1) { long_options, &option_index)) != -1) {
switch (n) { switch (n) {
case 'h': case 'h':
@ -105,6 +106,9 @@ int main(int argc, char **argv)
case 'u': case 'u':
run_as_user = strdup(optarg); run_as_user = strdup(optarg);
break; break;
case 'm':
mpd.password = strdup(optarg);
break;
case 'v': case 'v':
fprintf(stdout, "ympd %d.%d.%d\n" fprintf(stdout, "ympd %d.%d.%d\n"
"Copyright (C) 2014 Andrew Karpow <andy@ndyk.de>\n" "Copyright (C) 2014 Andrew Karpow <andy@ndyk.de>\n"
@ -119,6 +123,7 @@ int main(int argc, char **argv)
" -w, --webport [ip:]<port>\tlisten interface/port for webserver [8080]\n" " -w, --webport [ip:]<port>\tlisten interface/port for webserver [8080]\n"
" -u, --user <username>\t\tdrop priviliges to user after socket bind\n" " -u, --user <username>\t\tdrop priviliges to user after socket bind\n"
" -V, --version\t\t\tget version\n" " -V, --version\t\t\tget version\n"
" -m, --mpdpass <password>\tspecifies the password to use when connecting to mpd\n"
" --help\t\t\t\tthis help\n" " --help\t\t\t\tthis help\n"
, argv[0]); , argv[0]);
return EXIT_FAILURE; return EXIT_FAILURE;

3
ympd.1
View File

@ -23,6 +23,9 @@ specifies the port for the webserver to listen to, defaults to 8080
\fB\-u\fR, \fB\-\-user username\fR \fB\-u\fR, \fB\-\-user username\fR
drop privileges to the provided username after socket binding drop privileges to the provided username after socket binding
.TP .TP
\fB\-m\fR, \fB\-\-mpdpass password\fR
specifies the password to use when connecting to mpd
.TP
\fB\-V\fR, \fB\-\-version\fR \fB\-V\fR, \fB\-\-version\fR
print version and exit print version and exit
.TP .TP