From af52ec8453e492e8a366c77cb63fba1989380c9f Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Fri, 5 Jun 2020 02:07:41 +0100 Subject: [PATCH] clients/, disobedience/: Add `-u' option to override user config file. Organization: Straylight/Edgeware From: Mark Wooding At long last. --- clients/disorder.c | 7 +++++-- clients/playrtp.c | 7 +++++-- disobedience/disobedience.c | 7 +++++-- doc/disobedience.1.in | 7 +++++++ doc/disorder-playrtp.1.in | 9 ++++++++- doc/disorder.1.in | 13 ++++++++++++- doc/disorder_config.5.in | 6 +++++- 7 files changed, 47 insertions(+), 9 deletions(-) diff --git a/clients/disorder.c b/clients/disorder.c index c7672fb..6aa12c4 100644 --- a/clients/disorder.c +++ b/clients/disorder.c @@ -75,6 +75,7 @@ static const struct option options[] = { { "config", required_argument, 0, 'c' }, { "debug", no_argument, 0, 'd' }, { "local", no_argument, 0, 'l' }, + { "user-config", required_argument, 0, 'u' }, { "no-per-user-config", no_argument, 0, 'N' }, { "help-commands", no_argument, 0, 'H' }, { "user", required_argument, 0, 'U' }, @@ -90,7 +91,8 @@ static void attribute((noreturn)) help(void) { " --help, -h Display usage message\n" " --help-commands, -H List commands\n" " --version, -V Display version number\n" - " --config PATH, -c PATH Set configuration file\n" + " --config PATH, -c PATH Set system configuration file\n" + " --user-config PATH, -u PATH Set user configuration file\n" " --local, -l Force connection to local server\n" " --debug, -d Turn on debugging\n"); xfclose(stdout); @@ -883,12 +885,13 @@ int main(int argc, char **argv) { regexp_setup(); if(!setlocale(LC_CTYPE, "")) disorder_fatal(errno, "error calling setlocale"); if(!setlocale(LC_TIME, "")) disorder_fatal(errno, "error calling setlocale"); - while((n = getopt_long(argc, argv, "+hVc:dHl", options, 0)) >= 0) { + while((n = getopt_long(argc, argv, "+hVc:dHlu:", options, 0)) >= 0) { switch(n) { case 'h': help(); case 'H': help_commands(); case 'V': version("disorder"); case 'c': configfile = optarg; break; + case 'u': userconfigfile = optarg; break; case 'd': debugging = 1; break; case 'l': local = 1; break; case 'N': config_per_user = 0; break; diff --git a/clients/playrtp.c b/clients/playrtp.c index c22998b..2f98415 100644 --- a/clients/playrtp.c +++ b/clients/playrtp.c @@ -217,6 +217,7 @@ static const struct option options[] = { { "pause-mode", required_argument, 0, 'P' }, { "socket", required_argument, 0, 's' }, { "config", required_argument, 0, 'C' }, + { "user-config", required_argument, 0, 'u' }, { "monitor", no_argument, 0, 'M' }, { 0, 0, 0, 0 } }; @@ -509,7 +510,8 @@ static void attribute((noreturn)) help(void) { " --min, -m FRAMES Buffer low water mark\n" " --max, -x FRAMES Buffer maximum size\n" " --rcvbuf, -R BYTES Socket receive buffer size\n" - " --config, -C PATH Set configuration file\n" + " --config, -C PATH Set system configuration file\n" + " --user-config, -u PATH Set user configuration file\n" " --api, -A API Select audio API. Possibilities:\n" " "); int first = 1; @@ -670,7 +672,7 @@ int main(int argc, char **argv) { logdate = 1; mem_init(); if(!setlocale(LC_CTYPE, "")) disorder_fatal(errno, "error calling setlocale"); - while((n = getopt_long(argc, argv, "hVdD:m:x:L:R:aocC:re:P:MA:", options, 0)) >= 0) { + while((n = getopt_long(argc, argv, "hVdD:m:x:L:R:aocC:u:re:P:MA:", options, 0)) >= 0) { switch(n) { case 'h': help(); case 'V': version("disorder-playrtp"); @@ -699,6 +701,7 @@ int main(int argc, char **argv) { #endif case 'A': backend = uaudio_find(optarg); break; case 'C': configfile = optarg; break; + case 'u': userconfigfile = optarg; break; case 's': control_socket = optarg; break; case 'r': dumpfile = optarg; break; case 'e': backend = &uaudio_command; uaudio_set("command", optarg); break; diff --git a/disobedience/disobedience.c b/disobedience/disobedience.c index 6706a2d..75e5b97 100644 --- a/disobedience/disobedience.c +++ b/disobedience/disobedience.c @@ -466,6 +466,7 @@ static const struct option options[] = { { "help", no_argument, 0, 'h' }, { "version", no_argument, 0, 'V' }, { "config", required_argument, 0, 'c' }, + { "user-config", required_argument, 0, 'u' }, { "tufnel", no_argument, 0, 't' }, { "debug", no_argument, 0, 'd' }, { 0, 0, 0, 0 } @@ -480,7 +481,8 @@ static void attribute((noreturn)) help(void) { "Options:\n" " --help, -h Display usage message\n" " --version, -V Display version number\n" - " --config PATH, -c PATH Set configuration file\n" + " --config PATH, -c PATH Set system configuration file\n" + " --user-config PATH, -u PATH Set user configuration file\n" " --debug, -d Turn on debugging\n" "\n" "Also GTK+ options will work.\n"); @@ -546,11 +548,12 @@ int main(int argc, char **argv) { regexp_setup(); if(!setlocale(LC_CTYPE, "")) disorder_fatal(errno, "error calling setlocale"); gtkok = gtk_init_check(&argc, &argv); - while((n = getopt_long(argc, argv, "hVc:dt", options, 0)) >= 0) { + while((n = getopt_long(argc, argv, "hVc:dtu:", options, 0)) >= 0) { switch(n) { case 'h': help(); case 'V': version("disobedience"); case 'c': configfile = optarg; break; + case 'u': userconfigfile = optarg; break; case 'd': debugging = 1; break; case 't': goesupto = 11; break; default: disorder_fatal(0, "invalid option"); diff --git a/doc/disobedience.1.in b/doc/disobedience.1.in index ea983f3..e1fdcc2 100644 --- a/doc/disobedience.1.in +++ b/doc/disobedience.1.in @@ -36,6 +36,13 @@ given by the environment variable, defaulting to .IR pkgconfdir/config . .TP +.B \-\-user-config \fIPATH\fR, \fB\-u \fIPATH +Set the user configuration file. +THe default is given by the +.B DISORDER_USERCONFIG +environment variable, defaulting to +.IR $HOME/.disorder/passwd . +.TP .B \-\-debug\fR, \fB\-d Enable debugging. .TP diff --git a/doc/disorder-playrtp.1.in b/doc/disorder-playrtp.1.in index 24ad03f..3afd742 100644 --- a/doc/disorder-playrtp.1.in +++ b/doc/disorder-playrtp.1.in @@ -105,13 +105,20 @@ writes to the subprocess are suspended, requiring it to infer a pause from flow control. .TP .B \-\-config \fIPATH\fR, \fB\-C \fIPATH -Set the configuration file. +Set the system configuration file. The default is given by the .B DISORDER_CONFIG environment variable, defaulting to .IR pkgconfdir/config . .TP +.B \-\-user-config \fIPATH\fR, \fB\-u \fIPATH +Set the user configuration file. +THe default is given by the +.B DISORDER_USERCONFIG +environment variable, defaulting to +.IR $HOME/.disorder/passwd . +.TP .B \-\-socket \fIPATH\fR, \fB\-s \fIPATH Set the control socket. Normally this would not be used manually. diff --git a/doc/disorder.1.in b/doc/disorder.1.in index 5899ab5..a5a84f9 100644 --- a/doc/disorder.1.in +++ b/doc/disorder.1.in @@ -40,13 +40,20 @@ and \fBdisorder_config\fR (5) for documentation of the configuration file. .SH OPTIONS .TP .B \-\-config \fIPATH\fR, \fB\-c \fIPATH -Set the configuration file. +Set the system configuration file. The default is given by the .B DISORDER_CONFIG environment variable, defaulting to .IR pkgconfdir/config . .TP +.B \-\-user-config \fIPATH\fR, \fB\-u \fIPATH +Set the user configuration file. +THe default is given by the +.B DISORDER_USERCONFIG +environment variable, defaulting to +.IR $HOME/.disorder/passwd . +.TP .B \-\-debug\fR, \fB\-d Enable debugging. .TP @@ -402,6 +409,10 @@ Private configuration file to use instead of .B DISORDER_USERCONFIG Per-user configuration file to use instead of .BR $DISORDER_HOME/passwd . +Overridden by the +.B \-u +.RB ( \-\-user-config ) +command-line option. .TP .B DISORDER_USERCONFIG_SYS System-provided per-user configuration file to use instead of diff --git a/doc/disorder_config.5.in b/doc/disorder_config.5.in index 4190d16..1d690b0 100644 --- a/doc/disorder_config.5.in +++ b/doc/disorder_config.5.in @@ -221,7 +221,11 @@ Not really useful any more and will be abolished in future. Or .BR $DISORDER_USERCONFIG , if that's set; else -.BR $DISORDER_HOME/passwd . +.BR $DISORDER_HOME/passwd ; +overridden by +.B \-u +.RB ( \-\-user-config ) +command-line option. Per-user client configuration. Optional but if it exists must be readable only by the relevant user. Would normally contain a \fBpassword\fR directive. -- [mdw]