瀏覽代碼

Merge pull request #148 from unknownloner/master

Allow MPD Password to be configured in command line options
Andy 6 年之前
父節點
當前提交
f7aade410d
共有 5 個文件被更改,包括 13 次插入3 次删除
  1. 1 1
      contrib/init.debian
  2. 1 0
      contrib/ympd.default
  3. 2 1
      contrib/ympd.service
  4. 6 1
      src/ympd.c
  5. 3 0
      ympd.1

+ 1 - 1
contrib/init.debian

@@ -35,7 +35,7 @@ WEB_PORT=8080
 # Load the VERBOSE setting and other rcS variables
 [ -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()
 {

+ 1 - 0
contrib/ympd.default

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

+ 2 - 1
contrib/ympd.service

@@ -5,10 +5,11 @@ Requires=network.target local-fs.target
 [Service]
 Environment=MPD_HOST=localhost
 Environment=MPD_PORT=6600
+Environment=MPD_PASSWORD=
 Environment=WEB_PORT=8080
 Environment=YMPD_USER=nobody
 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
 
 [Install]

+ 6 - 1
src/ympd.c

@@ -87,10 +87,11 @@ int main(int argc, char **argv)
         {"user",         required_argument, 0, 'u'},
         {"version",      no_argument,       0, 'v'},
         {"help",         no_argument,       0,  0 },
+        {"mpdpass",      required_argument, 0, 'm'},
         {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) {
         switch (n) {
             case 'h':
@@ -105,6 +106,9 @@ int main(int argc, char **argv)
             case 'u':
                 run_as_user = strdup(optarg);
                 break;
+            case 'm':
+                mpd.password = strdup(optarg);
+                break;
             case 'v':
                 fprintf(stdout, "ympd  %d.%d.%d\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"
                         " -u, --user <username>\t\tdrop priviliges to user after socket bind\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"
                         , argv[0]);
                 return EXIT_FAILURE;

+ 3 - 0
ympd.1

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