summaryrefslogtreecommitdiffstats
path: root/vtysh
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@diac24.net>2009-10-15 13:55:47 +0200
committerDavid Lamparter <equinox@diac24.net>2010-02-04 02:53:48 +0100
commit2d3b742ab0c15303e008cd83f15bea869107fab9 (patch)
tree81612af1c8899a23ce2925f81eb7f78c6d9f28fe /vtysh
parent771d0b2c006702b739e707bc3967679bbb68389e (diff)
downloadquagga-2d3b742ab0c15303e008cd83f15bea869107fab9.tar.bz2
quagga-2d3b742ab0c15303e008cd83f15bea869107fab9.tar.xz
lib: fs namespacing 5/5: vtysh -N command-line parameter
vtysh needs some special care for namespace support in order to not open a gaping security hole. this patch allows giving namespace names without slashes or leading dots only.
Diffstat (limited to 'vtysh')
-rw-r--r--vtysh/vtysh_main.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index d8987a26..bdff22de 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -143,6 +143,7 @@ usage (int status)
"-d, --daemon Connect only to the specified daemon\n" \
"-E, --echo Echo prompt and command in -c mode\n" \
"-C, --dryrun Check configuration for validity and exit\n" \
+ "-N, --namespace Use prefixed daemon socket names\n" \
"-h, --help Display this help and exit\n\n" \
"Note that multiple commands may be executed from the command\n" \
"line by passing multiple -c args, or by embedding linefeed\n" \
@@ -162,6 +163,7 @@ struct option longopts[] =
{ "daemon", required_argument, NULL, 'd'},
{ "echo", no_argument, NULL, 'E'},
{ "dryrun", no_argument, NULL, 'C'},
+ { "namespace", required_argument, NULL, 'N'},
{ "help", no_argument, NULL, 'h'},
{ "noerror", no_argument, NULL, 'n'},
{ 0 }
@@ -237,7 +239,7 @@ main (int argc, char **argv, char **env)
/* Option handling. */
while (1)
{
- opt = getopt_long (argc, argv, "be:c:d:nEhC", longopts, 0);
+ opt = getopt_long (argc, argv, "be:c:d:nEhCN:", longopts, 0);
if (opt == EOF)
break;
@@ -278,6 +280,20 @@ main (int argc, char **argv, char **env)
case 'h':
usage (0);
break;
+ case 'N':
+ /* we're using this as a path component, so...
+ * for the daemons we can assume no malicious tampering
+ * with the cmdline, but for vtysh we have to check
+ */
+ if (strchr (optarg, '/') || optarg[0] == '.')
+ {
+ fprintf (stderr, "The namespace argument may not include "
+ "slashes or start with a dot.\n");
+ break;
+ }
+
+ path_set_namespace (optarg);
+ break;
default:
usage (1);
break;