From b0e6977c353978479122c30bd6c98dd1f21e0b34 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 13 May 2014 15:00:43 -0600 Subject: [PATCH] Try to be clearer about which are the input and output files in export mode. --- doc/visudo.cat | 26 ++++++++++++++++---------- doc/visudo.man.in | 29 +++++++++++++++++++++++------ doc/visudo.mdoc.in | 28 ++++++++++++++++++++++------ plugins/sudoers/visudo.c | 16 ++++++++-------- 4 files changed, 69 insertions(+), 30 deletions(-) diff --git a/doc/visudo.cat b/doc/visudo.cat index 66ba0a7f4..a56698f89 100644 --- a/doc/visudo.cat +++ b/doc/visudo.cat @@ -4,7 +4,7 @@ NNAAMMEE vviissuuddoo - edit the sudoers file SSYYNNOOPPSSIISS - vviissuuddoo [--cchhqqssVV] [--ff _s_u_d_o_e_r_s] [--xx _f_i_l_e] + vviissuuddoo [--cchhqqssVV] [--ff _s_u_d_o_e_r_s] [--xx _o_u_t_p_u_t___f_i_l_e] DDEESSCCRRIIPPTTIIOONN vviissuuddoo edits the _s_u_d_o_e_r_s file in a safe fashion, analogous to vipw(1m). @@ -72,14 +72,16 @@ DDEESSCCRRIIPPTTIIOONN --VV, ----vveerrssiioonn Print the vviissuuddoo and _s_u_d_o_e_r_s grammar versions and exit. - --xx _f_i_l_e, ----eexxppoorrtt=_f_i_l_e - Export _s_u_d_o_e_r_s in JSON format and write it to _f_i_l_e. If _f_i_l_e - is `-', the exported _s_u_d_o_e_r_s policy will be written to the - standard output. The exported format is intended to be - easier for third-party applications to parse than the - traditional _s_u_d_o_e_r_s format. The various values have explicit - types which removes much of the ambiguity of the _s_u_d_o_e_r_s - format. + --xx _o_u_t_p_u_t___f_i_l_e, ----eexxppoorrtt=_o_u_t_p_u_t___f_i_l_e + Export a _s_u_d_o_e_r_s in JSON format and write it to _o_u_t_p_u_t___f_i_l_e. + If _o_u_t_p_u_t___f_i_l_e is `-', the exported _s_u_d_o_e_r_s policy will be + written to the standard output. By default, _/_e_t_c_/_s_u_d_o_e_r_s + (and any files it includes) will be exported. The --ff option + can be used to specify a different _s_u_d_o_e_r_s file to export. + The exported format is intended to be easier for third-party + applications to parse than the traditional _s_u_d_o_e_r_s format. + The various values have explicit types which removes much of + the ambiguity of the _s_u_d_o_e_r_s format. EENNVVIIRROONNMMEENNTT The following environment variables may be consulted depending on the @@ -123,6 +125,10 @@ DDIIAAGGNNOOSSTTIICCSS only a warning by default as ssuuddoo will ignore cycles when parsing the _s_u_d_o_e_r_s file. + visudo: /etc/sudoers: input and output files must be different + The --xx flag was used and the specified _o_u_t_p_u_t___f_i_l_e has the same + path name as the _s_u_d_o_e_r_s file to export. + SSEEEE AALLSSOO vi(1), sudoers(4), sudo(1m), vipw(1m) @@ -156,4 +162,4 @@ DDIISSCCLLAAIIMMEERR file distributed with ssuuddoo or http://www.sudo.ws/sudo/license.html for complete details. -Sudo 1.8.10 February 15, 2014 Sudo 1.8.10 +Sudo 1.8.10 May 13, 2014 Sudo 1.8.10 diff --git a/doc/visudo.man.in b/doc/visudo.man.in index d26eb6761..4206cb732 100644 --- a/doc/visudo.man.in +++ b/doc/visudo.man.in @@ -21,7 +21,7 @@ .\" Agency (DARPA) and Air Force Research Laboratory, Air Force .\" Materiel Command, USAF, under agreement number F39502-99-1-0512. .\" -.TH "VISUDO" "@mansectsu@" "February 15, 2014" "Sudo @PACKAGE_VERSION@" "System Manager's Manual" +.TH "VISUDO" "@mansectsu@" "May 13, 2014" "Sudo @PACKAGE_VERSION@" "System Manager's Manual" .nh .if n .ad l .SH "NAME" @@ -32,7 +32,7 @@ \fBvisudo\fR [\fB\-chqsV\fR] [\fB\-f\fR\ \fIsudoers\fR] -[\fB\-x\fR\ \fIfile\fR] +[\fB\-x\fR\ \fIoutput_file\fR] .SH "DESCRIPTION" \fBvisudo\fR edits the @@ -205,18 +205,26 @@ and \fIsudoers\fR grammar versions and exit. .TP 12n -\fB\-x\fR \fIfile\fR, \fB\--export\fR=\fIfile\fR -Export +\fB\-x\fR \fIoutput_file\fR, \fB\--export\fR=\fIoutput_file\fR +Export a \fIsudoers\fR in JSON format and write it to -\fIfile\fR. +\fIoutput_file\fR. If -\fIfile\fR +\fIoutput_file\fR is \(oq-\(cq, the exported \fIsudoers\fR policy will be written to the standard output. +By default, +\fI@sysconfdir@/sudoers\fR +(and any files it includes) will be exported. +The +\fB\-f\fR +option can be used to specify a different +\fIsudoers\fR +file to export. The exported format is intended to be easier for third-party applications to parse than the traditional \fIsudoers\fR @@ -298,6 +306,15 @@ will ignore cycles when parsing the \fIsudoers\fR file. +.TP 6n +\fRvisudo: @sysconfdir@/sudoers: input and output files must be different\fR +The +\fB\-x\fR +flag was used and the specified +\fIoutput_file\fR +has the same path name as the +\fIsudoers\fR +file to export. .SH "SEE ALSO" vi(1), sudoers(@mansectform@), diff --git a/doc/visudo.mdoc.in b/doc/visudo.mdoc.in index c94cdbbda..a2c118309 100644 --- a/doc/visudo.mdoc.in +++ b/doc/visudo.mdoc.in @@ -19,7 +19,7 @@ .\" Agency (DARPA) and Air Force Research Laboratory, Air Force .\" Materiel Command, USAF, under agreement number F39502-99-1-0512. .\" -.Dd February 15, 2014 +.Dd May 13, 2014 .Dt VISUDO @mansectsu@ .Os Sudo @PACKAGE_VERSION@ .Sh NAME @@ -29,7 +29,7 @@ .Nm visudo .Op Fl chqsV .Op Fl f Ar sudoers -.Op Fl x Ar file +.Op Fl x Ar output_file .Sh DESCRIPTION .Nm visudo edits the @@ -196,18 +196,26 @@ Print the and .Em sudoers grammar versions and exit. -.It Fl x Ar file , Fl -export Ns = Ns Ar file -Export +.It Fl x Ar output_file , Fl -export Ns = Ns Ar output_file +Export a .Em sudoers in JSON format and write it to -.Ar file . +.Ar output_file . If -.Ar file +.Ar output_file is .Ql - , the exported .Em sudoers policy will be written to the standard output. +By default, +.Pa @sysconfdir@/sudoers +(and any files it includes) will be exported. +The +.Fl f +option can be used to specify a different +.Em sudoers +file to export. The exported format is intended to be easier for third-party applications to parse than the traditional .Em sudoers @@ -286,6 +294,14 @@ will ignore cycles when parsing the .Em sudoers file. +.It Li visudo: @sysconfdir@/sudoers: input and output files must be different +The +.Fl x +flag was used and the specified +.Ar output_file +has the same path name as the +.Em sudoers +file to export. .El .Sh SEE ALSO .Xr vi 1 , diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index 79e6486bf..757443501 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -1318,7 +1318,7 @@ static void usage(int fatal) { (void) fprintf(fatal ? stderr : stdout, - "usage: %s [-chqsV] [-f sudoers] [-x file]\n", getprogname()); + "usage: %s [-chqsV] [-f sudoers] [-x output_file]\n", getprogname()); if (fatal) exit(1); } @@ -1329,12 +1329,12 @@ help(void) (void) printf(_("%s - safely edit the sudoers file\n\n"), getprogname()); usage(0); (void) puts(_("\nOptions:\n" - " -c, --check check-only mode\n" - " -f, --file=file specify sudoers file location\n" - " -h, --help display help message and exit\n" - " -q, --quiet less verbose (quiet) syntax error messages\n" - " -s, --strict strict syntax checking\n" - " -V, --version display version information and exit\n" - " -x, --export=file export sudoers in JSON format")); + " -c, --check check-only mode\n" + " -f, --file=sudoers specify sudoers file location\n" + " -h, --help display help message and exit\n" + " -q, --quiet less verbose (quiet) syntax error messages\n" + " -s, --strict strict syntax checking\n" + " -V, --version display version information and exit\n" + " -x, --export=output_file write sudoers in JSON format to output_file")); exit(0); }