]> granicus.if.org Git - sudo/commitdiff
Emphasize that wildcards are not regexps. Bug #692
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 7 Aug 2015 18:37:15 +0000 (12:37 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 7 Aug 2015 18:37:15 +0000 (12:37 -0600)
doc/sudoers.cat
doc/sudoers.man.in
doc/sudoers.mdoc.in

index 4f5dabad3ae4b60deb3bc00eaacf185f95ea9e9c..ae7c8a95bf1876357c2dcd591b83ede518b5e0a5 100644 (file)
@@ -675,43 +675,47 @@ S\bSU\bUD\bDO\bOE\bER\bRS\bS F\bFI\bIL\bLE\bE F\bFO\bOR\bRM\bMA\bAT\bT
      s\bsu\bud\bdo\bo allows shell-style _\bw_\bi_\bl_\bd_\bc_\ba_\br_\bd_\bs (aka meta or glob characters) to be
      used in host names, path names and command line arguments in the _\bs_\bu_\bd_\bo_\be_\br_\bs
      file.  Wildcard matching is done via the glob(3) and fnmatch(3) functions
-     as specified by IEEE Std 1003.1 (``POSIX.1'').  Note that these are _\bn_\bo_\bt
-     regular expressions.
+     as specified by IEEE Std 1003.1 (``POSIX.1'').
 
-     *         Matches any set of zero or more characters.
+     *         Matches any set of zero or more characters (including white
+               space).
 
-     ?         Matches any single character.
+     ?         Matches any single character (including white space).
 
      [...]     Matches any character in the specified range.
 
-     [!...]    Matches any character n\bno\bot\bt in the specified range.
+     [!...]    Matches any character _\bn_\bo_\bt in the specified range.
 
      \x        For any character `x', evaluates to `x'.  This is used to
                escape special characters such as: `*', `?', `[', and `]'.
 
-     Character classes may also be used if your system's glob(3) and
-     fnmatch(3) functions support them.  However, because the `:' character
-     has special meaning in _\bs_\bu_\bd_\bo_\be_\br_\bs, it must be escaped.  For example:
+     N\bNo\bot\bte\be t\bth\bha\bat\bt t\bth\bhe\bes\bse\be a\bar\bre\be n\bno\bot\bt r\bre\beg\bgu\bul\bla\bar\br e\bex\bxp\bpr\bre\bes\bss\bsi\bio\bon\bns\bs.\b.  Unlike a regular expression
+     there is no way to match one or more characters within a range.
+
+     Character classes may be used if your system's glob(3) and fnmatch(3)
+     functions support them.  However, because the `:' character has special
+     meaning in _\bs_\bu_\bd_\bo_\be_\br_\bs, it must be escaped.  For example:
 
          /bin/ls [[\:alpha\:]]*
 
      Would match any file name beginning with a letter.
 
-     Note that a forward slash (`/') will n\bno\bot\bt be matched by wildcards used in
+     Note that a forward slash (`/') will _\bn_\bo_\bt be matched by wildcards used in
      the file name portion of the command.  This is to make a path like:
 
          /usr/bin/*
 
      match _\b/_\bu_\bs_\br_\b/_\bb_\bi_\bn_\b/_\bw_\bh_\bo but not _\b/_\bu_\bs_\br_\b/_\bb_\bi_\bn_\b/_\bX_\b1_\b1_\b/_\bx_\bt_\be_\br_\bm.
 
-     When matching the command line arguments, however, a slash d\bdo\boe\bes\bs get
+     When matching the command line arguments, however, a slash _\bd_\bo_\be_\bs get
      matched by wildcards since command line arguments may contain arbitrary
      strings and not just path names.
 
      W\bWi\bil\bld\bdc\bca\bar\brd\bds\bs i\bin\bn c\bco\bom\bmm\bma\ban\bnd\bd l\bli\bin\bne\be a\bar\brg\bgu\bum\bme\ben\bnt\bts\bs s\bsh\bho\bou\bul\bld\bd b\bbe\be u\bus\bse\bed\bd w\bwi\bit\bth\bh c\bca\bar\bre\be.\b.
      Command line arguments are matched as a single, concatenated string.
-     This mean a wildcard such as `?' or `*' will match _\bm_\bu_\bl_\bt_\bi_\bp_\bl_\be words.  For
-     example, while a sudoers entry like:
+     This mean a wildcard character such as `?' or `*' will match across word
+     boundaries, which may be unexpected.  For example, while a sudoers entry
+     like:
 
          %operator ALL = /bin/cat /var/log/messages*
 
@@ -723,14 +727,15 @@ S\bSU\bUD\bDO\bOE\bER\bRS\bS F\bFI\bIL\bLE\bE F\bFO\bOR\bRM\bMA\bAT\bT
 
          $ sudo cat /var/log/messages /etc/shadow
 
-     which is probably not what was intended.
+     which is probably not what was intended.  In most cases it is better to
+     do command line processing outside of _\bs_\bu_\bd_\bo_\be_\br_\bs in a scripting language.
 
    E\bEx\bxc\bce\bep\bpt\bti\bio\bon\bns\bs t\bto\bo w\bwi\bil\bld\bdc\bca\bar\brd\bd r\bru\bul\ble\bes\bs
      The following exceptions apply to the above rules:
 
      ""        If the empty string "" is the only command line argument in the
                _\bs_\bu_\bd_\bo_\be_\br_\bs entry it means that command is not allowed to be run
-               with a\ban\bny\by arguments.
+               with _\ba_\bn_\by arguments.
 
      sudoedit  Command line arguments to the _\bs_\bu_\bd_\bo_\be_\bd_\bi_\bt built-in command should
                always be path names, so a forward slash (`/') will not be
@@ -782,7 +787,7 @@ S\bSU\bUD\bDO\bOE\bER\bRS\bS F\bFI\bIL\bLE\bE F\bFO\bOR\bRM\bMA\bAT\bT
      manager or editor temporary/backup files.  Files are parsed in sorted
      lexical order.  That is, _\b/_\be_\bt_\bc_\b/_\bs_\bu_\bd_\bo_\be_\br_\bs_\b._\bd_\b/_\b0_\b1_\b__\bf_\bi_\br_\bs_\bt will be parsed before
      _\b/_\be_\bt_\bc_\b/_\bs_\bu_\bd_\bo_\be_\br_\bs_\b._\bd_\b/_\b1_\b0_\b__\bs_\be_\bc_\bo_\bn_\bd.  Be aware that because the sorting is lexical,
-     not numeric, _\b/_\be_\bt_\bc_\b/_\bs_\bu_\bd_\bo_\be_\br_\bs_\b._\bd_\b/_\b1_\b__\bw_\bh_\bo_\bo_\bp_\bs would be loaded a\baf\bft\bte\ber\br
+     not numeric, _\b/_\be_\bt_\bc_\b/_\bs_\bu_\bd_\bo_\be_\br_\bs_\b._\bd_\b/_\b1_\b__\bw_\bh_\bo_\bo_\bp_\bs would be loaded _\ba_\bf_\bt_\be_\br
      _\b/_\be_\bt_\bc_\b/_\bs_\bu_\bd_\bo_\be_\br_\bs_\b._\bd_\b/_\b1_\b0_\b__\bs_\be_\bc_\bo_\bn_\bd.  Using a consistent number of leading zeroes in
      the file names can be used to avoid such problems.
 
@@ -804,7 +809,7 @@ S\bSU\bUD\bDO\bOE\bER\bRS\bS F\bFI\bIL\bLE\bE F\bFO\bOR\bRM\bMA\bAT\bT
      User_Alias, Runas_Alias, or Host_Alias.  You should not try to define
      your own _\ba_\bl_\bi_\ba_\bs called A\bAL\bLL\bL as the built-in alias will be used in
      preference to your own.  Please note that using A\bAL\bLL\bL can be dangerous
-     since in a command context, it allows the user to run a\ban\bny\by command on the
+     since in a command context, it allows the user to run _\ba_\bn_\by command on the
      system.
 
      An exclamation point (`!') can be used as a logical _\bn_\bo_\bt operator in a
index 74531000666e5c4b14e05c2de846c44e1e0e90f8..3ea41689f31067262c694972679c2baa5e60f515 100644 (file)
@@ -1463,22 +1463,19 @@ and
 fnmatch(3)
 functions as specified by
 IEEE Std 1003.1 (\(LqPOSIX.1\(Rq).
-Note that these are
-\fInot\fR
-regular expressions.
 .TP 10n
 \fR*\fR
-Matches any set of zero or more characters.
+Matches any set of zero or more characters (including white space).
 .TP 10n
 \fR\&?\fR
-Matches any single character.
+Matches any single character (including white space).
 .TP 10n
 \fR[...]\fR
 Matches any character in the specified range.
 .TP 10n
 \fR[!...]\fR
 Matches any character
-\fBnot\fR
+\fInot\fR
 in the specified range.
 .TP 10n
 \fR\ex\fR
@@ -1493,7 +1490,11 @@ This is used to escape special characters such as:
 and
 \(oq]\&\(cq.
 .PP
-Character classes may also be used if your system's
+\fBNote that these are not regular expressions.\fR
+Unlike a regular expression there is no way to match one or more
+characters within a range.
+.PP
+Character classes may be used if your system's
 glob(3)
 and
 fnmatch(3)
@@ -1517,7 +1518,7 @@ Would match any file name beginning with a letter.
 Note that a forward slash
 (\(oq/\(cq)
 will
-\fBnot\fR
+\fInot\fR
 be matched by
 wildcards used in the file name portion of the command.
 This is to make a path like:
@@ -1534,20 +1535,18 @@ but not
 \fI/usr/bin/X11/xterm\fR.
 .PP
 When matching the command line arguments, however, a slash
-\fBdoes\fR
+\fIdoes\fR
 get matched by wildcards since command line arguments may contain
 arbitrary strings and not just path names.
 .PP
 \fBWildcards in command line arguments should be used with care.\fR
 .br
 Command line arguments are matched as a single, concatenated string.
-This mean a wildcard such as
+This mean a wildcard character such as
 \(oq\&?\(cq
 or
 \(oq*\(cq
-will match
-\fImultiple\fR
-words.
+will match across word boundaries, which may be unexpected.
 For example, while a sudoers entry like:
 .nf
 .sp
@@ -1573,6 +1572,10 @@ $ sudo cat /var/log/messages /etc/shadow
 .fi
 .PP
 which is probably not what was intended.
+In most cases it is better to do command line processing
+outside of
+\fIsudoers\fR
+in a scripting language.
 .SS "Exceptions to wildcard rules"
 The following exceptions apply to the above rules:
 .TP 10n
@@ -1582,7 +1585,7 @@ If the empty string
 is the only command line argument in the
 \fIsudoers\fR
 entry it means that command is not allowed to be run with
-\fBany\fR
+\fIany\fR
 arguments.
 .TP 10n
 sudoedit
@@ -1709,7 +1712,7 @@ will be parsed before
 Be aware that because the sorting is lexical, not numeric,
 \fI/etc/sudoers.d/1_whoops\fR
 would be loaded
-\fBafter\fR
+\fIafter\fR
 \fI/etc/sudoers.d/10_second\fR.
 Using a consistent number of leading zeroes in the file names can be used
 to avoid such problems.
@@ -1757,7 +1760,7 @@ as the built-in alias will be used in preference to your own.
 Please note that using
 \fBALL\fR
 can be dangerous since in a command context, it allows the user to run
-\fBany\fR
+\fIany\fR
 command on the system.
 .PP
 An exclamation point
index d1f1f9e342f69d0826785ba5b3a22c3ca4bedaa1..e704dd328b6d3e423a79608cff0d97129f8b213e 100644 (file)
@@ -1368,19 +1368,16 @@ and
 .Xr fnmatch 3
 functions as specified by
 .St -p1003.1 .
-Note that these are
-.Em not
-regular expressions.
 .Bl -tag -width 8n
 .It Li *
-Matches any set of zero or more characters.
+Matches any set of zero or more characters (including white space).
 .It Li \&?
-Matches any single character.
+Matches any single character (including white space).
 .It Li [...]
 Matches any character in the specified range.
 .It Li [!...]
 Matches any character
-.Sy not
+.Em not
 in the specified range.
 .It Li \ex
 For any character
@@ -1395,7 +1392,13 @@ and
 .Ql ]\& .
 .El
 .Pp
-Character classes may also be used if your system's
+.Bf -symbolic
+Note that these are not regular expressions.
+.Ef
+Unlike a regular expression there is no way to match one or more
+characters within a range.
+.Pp
+Character classes may be used if your system's
 .Xr glob 3
 and
 .Xr fnmatch 3
@@ -1416,7 +1419,7 @@ Would match any file name beginning with a letter.
 Note that a forward slash
 .Pq Ql /
 will
-.Sy not
+.Em not
 be matched by
 wildcards used in the file name portion of the command.
 This is to make a path like:
@@ -1430,7 +1433,7 @@ but not
 .Pa /usr/bin/X11/xterm .
 .Pp
 When matching the command line arguments, however, a slash
-.Sy does
+.Em does
 get matched by wildcards since command line arguments may contain
 arbitrary strings and not just path names.
 .Pp
@@ -1439,13 +1442,11 @@ Wildcards in command line arguments should be used with care.
 .Ef
 .br
 Command line arguments are matched as a single, concatenated string.
-This mean a wildcard such as
+This mean a wildcard character such as
 .Ql \&?
 or
 .Ql *
-will match
-.Em multiple
-words.
+will match across word boundaries, which may be unexpected.
 For example, while a sudoers entry like:
 .Bd -literal -offset 4n
 %operator ALL = /bin/cat /var/log/messages*
@@ -1462,6 +1463,10 @@ $ sudo cat /var/log/messages /etc/shadow
 .Ed
 .Pp
 which is probably not what was intended.
+In most cases it is better to do command line processing
+outside of
+.Em sudoers
+in a scripting language.
 .Ss Exceptions to wildcard rules
 The following exceptions apply to the above rules:
 .Bl -tag -width 8n
@@ -1471,7 +1476,7 @@ If the empty string
 is the only command line argument in the
 .Em sudoers
 entry it means that command is not allowed to be run with
-.Sy any
+.Em any
 arguments.
 .It sudoedit
 Command line arguments to the
@@ -1586,7 +1591,7 @@ will be parsed before
 Be aware that because the sorting is lexical, not numeric,
 .Pa /etc/sudoers.d/1_whoops
 would be loaded
-.Sy after
+.Em after
 .Pa /etc/sudoers.d/10_second .
 Using a consistent number of leading zeroes in the file names can be used
 to avoid such problems.
@@ -1634,7 +1639,7 @@ as the built-in alias will be used in preference to your own.
 Please note that using
 .Sy ALL
 can be dangerous since in a command context, it allows the user to run
-.Sy any
+.Em any
 command on the system.
 .Pp
 An exclamation point