]> granicus.if.org Git - sudo/commitdiff
Revert 04ec05108b2b, change the default input source back to stdin.
authorTodd C. Miller <Todd.Miller@sudo.ws>
Sun, 28 Jan 2018 23:11:02 +0000 (16:11 -0700)
committerTodd C. Miller <Todd.Miller@sudo.ws>
Sun, 28 Jan 2018 23:11:02 +0000 (16:11 -0700)
doc/cvtsudoers.cat
doc/cvtsudoers.man.in
doc/cvtsudoers.mdoc.in
plugins/sudoers/cvtsudoers.c
plugins/sudoers/stubs.c
plugins/sudoers/visudo.c

index 526f56a185963a028eb671a47ac1b42af0cfcf51..2b64e0bfdfdfc27460f13fde7b73fbe7ac44314f 100644 (file)
@@ -10,9 +10,9 @@ D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
      c\bcv\bvt\bts\bsu\bud\bdo\boe\ber\brs\bs can be used to convert a policy file in _\bs_\bu_\bd_\bo_\be_\br_\bs format to
      other formats.  The default output format is JSON.
 
-     If _\bs_\bu_\bd_\bo_\be_\br_\bs_\b__\bf_\bi_\bl_\be is `-', the policy is read from the standard input.  If
-     no _\bs_\bu_\bd_\bo_\be_\br_\bs_\b__\bf_\bi_\bl_\be is specified, _\b/_\be_\bt_\bc_\b/_\bs_\bu_\bd_\bo_\be_\br_\bs will be used.  By default, the
-     result is written to the standard output.
+     If no _\bs_\bu_\bd_\bo_\be_\br_\bs_\b__\bf_\bi_\bl_\be is specified, or if it is `-', the policy is read from
+     the standard input.  By default, the result is written to the standard
+     output.
 
      The options are as follows:
 
index cfcdafbe6813f08d835eaec818b620a7fee228f7..cbb2b7ae84ea0075fce4d3e62015f01af06cf72d 100644 (file)
@@ -36,16 +36,11 @@ can be used to convert a policy file in
 format to other formats.
 The default output format is JSON.
 .PP
-If
+If no
 \fIsudoers_file\fR
-is
+is specified, or if it is
 \(oq-\(cq,
 the policy is read from the standard input.
-If no
-\fIsudoers_file\fR
-is specified,
-\fI@sysconfdir@/sudoers\fR
-will be used.
 By default, the result is written to the standard output.
 .PP
 The options are as follows:
index 96c2e9c2ba5141ec50b3c369dde11fc5d086ce83..ce1a9c4ef7a99d4816613d248b822448c6b39c6b 100644 (file)
@@ -33,16 +33,11 @@ can be used to convert a policy file in
 format to other formats.
 The default output format is JSON.
 .Pp
-If
+If no
 .Ar sudoers_file
-is
+is specified, or if it is
 .Ql - ,
 the policy is read from the standard input.
-If no
-.Ar sudoers_file
-is specified,
-.Pa @sysconfdir@/sudoers
-will be used.
 By default, the result is written to the standard output.
 .Pp
 The options are as follows:
index 011e3db83a5f5bd6984f0dcc424957e34f616543..6932145331c79122b74999d622841acd9fa16fbd 100644 (file)
@@ -51,7 +51,6 @@
 
 extern bool convert_sudoers_json(const char *output_file);
 extern bool convert_sudoers_ldif(const char *output_file, const char *base);
-extern void parse_sudoers_options(void);
 extern void get_hostname(void);
 
 /*
@@ -86,7 +85,7 @@ main(int argc, char *argv[])
 {
     int ch, exitcode = EXIT_FAILURE;
     enum output_formats output_format = output_json;
-    const char *input_file = NULL;
+    const char *input_file = "-";
     const char *output_file = "-";
     debug_decl(main, SUDOERS_DEBUG_MAIN)
 
@@ -117,9 +116,6 @@ main(int argc, char *argv[])
     if (!sudoers_debug_register(getprogname(), sudo_conf_debug_files(getprogname())))
        goto done;
 
-    /* Parse sudoers plugin options, if any. */
-    parse_sudoers_options();
-
     /*
      * Arg handling.
      */
@@ -155,14 +151,12 @@ main(int argc, char *argv[])
     argc -= optind;
     argv += optind;
 
-    /* Input file (defaults to /etc/sudoers). */
+    /* Input file (defaults to stdin). */
     if (argc > 0) {
        /* XXX - allow multiple input files? */
        if (argc > 1)
            usage(1);
        input_file  = argv[0];
-    } else {
-       input_file = sudoers_file;
     }
 
     if (strcmp(input_file, "-") != 0) {
index 11adcf580118bbe5a4f951308d3da3b4e2bcd5a2..bc1c6eaccb38b72706b3ee0e1e49dba278b29655 100644 (file)
@@ -108,63 +108,3 @@ get_hostname(void)
 
     debug_return;
 }
-
-/*
- * Parse sudoers plugin options.
- * May set sudoers_file, sudoers_uid, sudoers_gid or sudoers_mode globals.
- */
-void
-parse_sudoers_options(void)
-{
-    struct plugin_info_list *plugins;
-    debug_decl(parse_sudoers_options, SUDOERS_DEBUG_UTIL)
-
-    plugins = sudo_conf_plugins();
-    if (plugins) {
-       struct plugin_info *info;
-
-       TAILQ_FOREACH(info, plugins, entries) {
-           if (strcmp(info->symbol_name, "sudoers_policy") == 0)
-               break;
-       }
-       if (info != NULL && info->options != NULL) {
-           char * const *cur;
-
-#define MATCHES(s, v)  \
-    (strncmp((s), (v), sizeof(v) - 1) == 0 && (s)[sizeof(v) - 1] != '\0')
-
-           for (cur = info->options; *cur != NULL; cur++) {
-               const char *errstr, *p;
-               id_t id;
-
-               if (MATCHES(*cur, "sudoers_file=")) {
-                   sudoers_file = *cur + sizeof("sudoers_file=") - 1;
-                   continue;
-               }
-               if (MATCHES(*cur, "sudoers_uid=")) {
-                   p = *cur + sizeof("sudoers_uid=") - 1;
-                   id = sudo_strtoid(p, NULL, NULL, &errstr);
-                   if (errstr == NULL)
-                       sudoers_uid = (uid_t) id;
-                   continue;
-               }
-               if (MATCHES(*cur, "sudoers_gid=")) {
-                   p = *cur + sizeof("sudoers_gid=") - 1;
-                   id = sudo_strtoid(p, NULL, NULL, &errstr);
-                   if (errstr == NULL)
-                       sudoers_gid = (gid_t) id;
-                   continue;
-               }
-               if (MATCHES(*cur, "sudoers_mode=")) {
-                   p = *cur + sizeof("sudoers_mode=") - 1;
-                   id = (id_t) sudo_strtomode(p, &errstr);
-                   if (errstr == NULL)
-                       sudoers_mode = (mode_t) id;
-                   continue;
-               }
-           }
-#undef MATCHES
-       }
-    }
-    debug_return;
-}
index 7ce2f1ce71e90142ea26c12f725669662e80812d..000e3d76f67438b80fcdfd7965b5fac5af958fae 100644 (file)
@@ -94,6 +94,7 @@ static bool install_sudoers(struct sudoersfile *, bool);
 static int print_unused(void *, void *);
 static bool reparse_sudoers(char *, int, char **, bool, bool);
 static int run_command(char *, char **);
+static void parse_sudoers_options(void);
 static void setup_signals(void);
 static void help(void) __attribute__((__noreturn__));
 static void usage(int);
@@ -101,7 +102,6 @@ static void visudo_cleanup(void);
 
 extern void get_hostname(void);
 extern void sudoersrestart(FILE *);
-extern void parse_sudoers_options(void);
 
 /*
  * Globals
@@ -1221,6 +1221,62 @@ print_unused(void *v1, void *v2)
     return 0;
 }
 
+static void
+parse_sudoers_options(void)
+{
+    struct plugin_info_list *plugins;
+    debug_decl(parse_sudoers_options, SUDOERS_DEBUG_UTIL)
+
+    plugins = sudo_conf_plugins();
+    if (plugins) {
+       struct plugin_info *info;
+
+       TAILQ_FOREACH(info, plugins, entries) {
+           if (strcmp(info->symbol_name, "sudoers_policy") == 0)
+               break;
+       }
+       if (info != NULL && info->options != NULL) {
+           char * const *cur;
+
+#define MATCHES(s, v)  \
+    (strncmp((s), (v), sizeof(v) - 1) == 0 && (s)[sizeof(v) - 1] != '\0')
+
+           for (cur = info->options; *cur != NULL; cur++) {
+               const char *errstr, *p;
+               id_t id;
+
+               if (MATCHES(*cur, "sudoers_file=")) {
+                   sudoers_file = *cur + sizeof("sudoers_file=") - 1;
+                   continue;
+               }
+               if (MATCHES(*cur, "sudoers_uid=")) {
+                   p = *cur + sizeof("sudoers_uid=") - 1;
+                   id = sudo_strtoid(p, NULL, NULL, &errstr);
+                   if (errstr == NULL)
+                       sudoers_uid = (uid_t) id;
+                   continue;
+               }
+               if (MATCHES(*cur, "sudoers_gid=")) {
+                   p = *cur + sizeof("sudoers_gid=") - 1;
+                   id = sudo_strtoid(p, NULL, NULL, &errstr);
+                   if (errstr == NULL)
+                       sudoers_gid = (gid_t) id;
+                   continue;
+               }
+               if (MATCHES(*cur, "sudoers_mode=")) {
+                   p = *cur + sizeof("sudoers_mode=") - 1;
+                   id = (id_t) sudo_strtomode(p, &errstr);
+                   if (errstr == NULL)
+                       sudoers_mode = (mode_t) id;
+                   continue;
+               }
+           }
+#undef MATCHES
+       }
+    }
+    debug_return;
+}
+
 /*
  * Unlink any sudoers temp files that remain.
  */