]> granicus.if.org Git - sudo/commitdiff
Add support for wildcards in the hostname.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 23 Mar 2000 04:09:53 +0000 (04:09 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 23 Mar 2000 04:09:53 +0000 (04:09 +0000)
parse.c
parse.h
parse.yacc
sudo.tab.c
sudoers.cat
sudoers.man.in
sudoers.pod
testsudoers.c
visudo.c

diff --git a/parse.c b/parse.c
index 77cacf662871d3ac55f231eb30a304daac1a738d..915ca2c34f8e0c79d62f1f52a3ab141f7fc03980 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -385,6 +385,21 @@ addr_matches(n)
     return(FALSE);
 }
 
+/*
+ * Returns 0 if the hostname matches the pattern and non-zero otherwise.
+ */
+int
+hostname_matches(host, pattern)
+    char *host;
+    char *pattern;
+{
+
+    if (has_meta(pattern))
+       return(fnmatch(pattern, host, FNM_CASEFOLD));
+    else
+       return(strcasecmp(host, pattern));
+}
+
 /*
  *  Returns TRUE if the given user belongs to the named group,
  *  else returns FALSE.
diff --git a/parse.h b/parse.h
index 2316fd66ceaa14e49872b0d5e39f6cc60bdafec6..5e727185a7073d8e3e1a58b392370f2e06c47d0b 100644 (file)
--- a/parse.h
+++ b/parse.h
@@ -109,6 +109,7 @@ extern int top;
  */
 int addr_matches       __P((char *));
 int command_matches    __P((char *, char *, char *, char *));
+int hostname_matches   __P((char *, char *));
 int netgr_matches      __P((char *, char *, char *, char *));
 int usergr_matches     __P((char *, char *));
 
index 6553189025ab58051eab69aa699016c0e55d8c2b..4d756bdf463755c485dbf19fb80c34c465c53dfe 100644 (file)
@@ -361,14 +361,14 @@ host              :       ALL {
                            free($1);
                        }
                |       WORD {
-                           if (strcasecmp(user_shost, $1) == 0)
+                           if (hostname_matches(user_shost, $1) == 0)
                                $$ = TRUE;
                            else
                                $$ = -1;
                            free($1);
                        }
                |       FQHOST {
-                           if (strcasecmp(user_host, $1) == 0)
+                           if (hostname_matches(user_host, $1) == 0)
                                $$ = TRUE;
                            else
                                $$ = -1;
@@ -380,7 +380,7 @@ host                :       ALL {
                            /* could be an all-caps hostname */
                            if (aip)
                                $$ = aip->val;
-                           else if (strcasecmp(user_shost, $1) == 0)
+                           else if (hostname_matches(user_shost, $1) == 0)
                                $$ = TRUE;
                            else {
                                if (pedantic) {
index e21cb1610ebb0f107c879b128237c851f64aba8a..4805d6846a4e8706f9a2f65d2e7c82ed7f01b109 100644 (file)
@@ -1275,7 +1275,7 @@ break;
 case 31:
 #line 363 "parse.yacc"
 {
-                           if (strcasecmp(user_shost, yyvsp[0].string) == 0)
+                           if (hostname_matches(user_shost, yyvsp[0].string) == 0)
                                yyval.BOOLEAN = TRUE;
                            else
                                yyval.BOOLEAN = -1;
@@ -1285,7 +1285,7 @@ break;
 case 32:
 #line 370 "parse.yacc"
 {
-                           if (strcasecmp(user_host, yyvsp[0].string) == 0)
+                           if (hostname_matches(user_host, yyvsp[0].string) == 0)
                                yyval.BOOLEAN = TRUE;
                            else
                                yyval.BOOLEAN = -1;
@@ -1300,7 +1300,7 @@ case 33:
                            /* could be an all-caps hostname */
                            if (aip)
                                yyval.BOOLEAN = aip->val;
-                           else if (strcasecmp(user_shost, yyvsp[0].string) == 0)
+                           else if (hostname_matches(user_shost, yyvsp[0].string) == 0)
                                yyval.BOOLEAN = TRUE;
                            else {
                                if (pedantic) {
index 60ac83e7c332724a2c06d990c34dc400602edc47..a7c035b7eedb1981e78526548cda7374a4a73ecb 100644 (file)
@@ -150,7 +150,11 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
        ethernet _\bi_\bn_\bt_\be_\br_\bf_\ba_\bc_\be(s) will be used when matching.  The
        netmask may be specified either in dotted quad notation
        (eg.  255.255.255.0) or CIDR notation (number of bits, eg.
-       24).
+       24).  A hostname may include shell-style wildcards (see
+       `Wildcards' section below), but unless the hostname
+       command on your machine returns the fully qualified
+       hostname, you'll need to use the _\bf_\bq_\bd_\bn option for wildcards
+       to be useful.
 
         Cmnd_List ::= Cmnd |
                       Cmnd ',' Cmnd_List
@@ -164,7 +168,7 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
                  '!'* Cmnd_Alias
 
        A Cmnd_List is a list of one or more commandnames,
-       directories, and other aliases.  A commandname is a fully-
+       directories, and other aliases.  A commandname is a fully
        qualified filename which may include shell-style wildcards
        (see `Wildcards' section below).  A simple filename allows
        the user to run the command with any arguments he/she
@@ -183,13 +187,9 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
        be escaped with a '\' if they are used in command
        arguments: ',', ':', '=', '\'.
 
-       D\bD\bD\bDe\be\be\bef\bf\bf\bfa\ba\ba\bau\bu\bu\bul\bl\bl\blt\bt\bt\bts\bs\bs\bs
 
-       Certain configuration options may be changed from their
-       default values at runtime via one or more Default_Entry
-       lines.  These may affect all users on any host, all users
-       on a specific host, or just a specific user.  When
-       multiple entries match, they are applied in order.  Where
+
+
 
 
 
@@ -202,6 +202,13 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+       D\bD\bD\bDe\be\be\bef\bf\bf\bfa\ba\ba\bau\bu\bu\bul\bl\bl\blt\bt\bt\bts\bs\bs\bs
+
+       Certain configuration options may be changed from their
+       default values at runtime via one or more Default_Entry
+       lines.  These may affect all users on any host, all users
+       on a specific host, or just a specific user.  When
+       multiple entries match, they are applied in order.  Where
        there are conflicting values, the last value on a matching
        line takes effect.
 
@@ -249,13 +256,6 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
                    if the invoking user exists in the _\bs_\bu_\bd_\bo_\be_\br_\bs
                    file, but is not allowed to run commands on
                    the current host.  This flag is off by
-                   default.
-
-       mail_no_perms
-                   If set, mail will be sent to the _\bm_\ba_\bi_\bl_\bt_\bo user
-                   if the invoking user allowed to use s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo but
-                   the command they are trying is not listed in
-                   their _\bs_\bu_\bd_\bo_\be_\br_\bs file entry.  This flag is off by
 
 
 
@@ -270,6 +270,13 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 
                    default.
 
+       mail_no_perms
+                   If set, mail will be sent to the _\bm_\ba_\bi_\bl_\bt_\bo user
+                   if the invoking user allowed to use s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo but
+                   the command they are trying is not listed in
+                   their _\bs_\bu_\bd_\bo_\be_\br_\bs file entry.  This flag is off by
+                   default.
+
        tty_tickets If set, users must authenticate on a per-tty
                    basis.  Normally, s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo uses a directory in the
                    ticket dir with the same name as the user
@@ -315,13 +322,6 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
        set_home    If set and s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo is invoked with the -s flag
                    the HOME environment variable will be set to
                    the home directory of the target user (which
-                   is root unless the -u option is used).  This
-                   effectively makes the -s flag imply -H.  This
-                   flag is off by default.
-
-       path_info   Normally, s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo will tell the user when a
-                   command could not be found in their $PATH.
-                   Some sites may wish to disable this as it
 
 
 
@@ -334,6 +334,13 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+                   is root unless the -u option is used).  This
+                   effectively makes the -s flag imply -H.  This
+                   flag is off by default.
+
+       path_info   Normally, s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo will tell the user when a
+                   command could not be found in their $PATH.
+                   Some sites may wish to disable this as it
                    could be used to gather information on the
                    location of executables that the normal user
                    does not have access to.  The disadvantage is
@@ -381,13 +388,6 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
                    to get a shell (which would be a root shell
                    and not be logged).
 
-       rootpw      If set, s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo will prompt for the root password
-                   instead of the password of the invoking user.
-
-       runaspw     If set, s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo will prompt for the password of
-                   the user defined by the _\br_\bu_\bn_\ba_\bs_\b__\bd_\be_\bf_\ba_\bu_\bl_\bt option
-                   (defaults to root) instead of the password of
-                   the invoking user.
 
 
 
@@ -400,6 +400,14 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+       rootpw      If set, s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo will prompt for the root password
+                   instead of the password of the invoking user.
+
+       runaspw     If set, s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo will prompt for the password of
+                   the user defined by the _\br_\bu_\bn_\ba_\bs_\b__\bd_\be_\bf_\ba_\bu_\bl_\bt option
+                   (defaults to root) instead of the password of
+                   the invoking user.
+
        targetpw    If set, s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo will prompt for the password of
                    the user specified by the -u flag (defaults to
                    root) instead of the password of the invoking
@@ -446,25 +454,25 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
        passwd_timeout
                    Number of minutes before the s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo password
                    prompt times out.  The default is 5, set this
-                   to 0 for no password timeout.
 
-       umask       Umask to use when running the root command.
-                   Set this to 0777 to not override the user's
-                   umask.  The default is 0022.
 
-       S\bS\bS\bSt\bt\bt\btr\br\br\bri\bi\bi\bin\bn\bn\bng\bg\bg\bgs\bs\bs\bs:
 
+22/Mar/2000                   1.6.3                             7
 
 
 
-22/Mar/2000                   1.6.3                             7
 
 
+sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+                   to 0 for no password timeout.
 
-sudoers(5)                 FILE FORMATS                sudoers(5)
+       umask       Umask to use when running the root command.
+                   Set this to 0777 to not override the user's
+                   umask.  The default is 0022.
 
+       S\bS\bS\bSt\bt\bt\btr\br\br\bri\bi\bi\bin\bn\bn\bng\bg\bg\bgs\bs\bs\bs:
 
        mailsub     Subject of the mail sent to the _\bm_\ba_\bi_\bl_\bt_\bo user.
                    The escape %h will expand to the hostname of
@@ -512,14 +520,6 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 
        syslog      Syslog facility if syslog is being used for
                    logging (negate to disable syslog logging).
-                   Defaults to "local2".
-
-       mailerpath  Path to mail program used to send warning
-                   mail.  Defaults to the path to sendmail found
-                   at configure time.
-
-       mailerflags Flags to use when invoking mailer. Defaults to
-                   -t.
 
 
 
@@ -532,6 +532,15 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+                   Defaults to "local2".
+
+       mailerpath  Path to mail program used to send warning
+                   mail.  Defaults to the path to sendmail found
+                   at configure time.
+
+       mailerflags Flags to use when invoking mailer. Defaults to
+                   -t.
+
        mailto      Address to send warning and erorr mail to.
                    Defaults to "root".
 
@@ -576,16 +585,7 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
                                    current host must have the C<NOPASSWD>
                                    flag set to avoid entering a password.
 
-                       any         At least one of the user's I<sudoers> entries
-                                   for the current host must have the
-                                   C<NOPASSWD> flag set to avoid entering a
-                                   password.
 
-                       never       The user need never enter a password to use
-                                   the B<-l> flag.
-
-                       always      The user must always enter a password to use
-                                   the B<-l> flag.
 
 
 
@@ -598,6 +598,17 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+                       any         At least one of the user's I<sudoers> entries
+                                   for the current host must have the
+                                   C<NOPASSWD> flag set to avoid entering a
+                                   password.
+
+                       never       The user need never enter a password to use
+                                   the B<-l> flag.
+
+                       always      The user must always enter a password to use
+                                   the B<-l> flag.
+
                    The default value is `any'.
 
        When logging via _\bs_\by_\bs_\bl_\bo_\bg(3), s\bs\bs\bsu\bu\bu\bud\bd\bd\bdo\bo\bo\bo accepts the following
@@ -642,27 +653,26 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
        The user d\bd\bd\bdg\bg\bg\bgb\bb\bb\bb may run _\b/_\bb_\bi_\bn_\b/_\bl_\bs, _\b/_\bb_\bi_\bn_\b/_\bk_\bi_\bl_\bl, and _\b/_\bu_\bs_\br_\b/_\bb_\bi_\bn_\b/_\bl_\bp_\br_\bm
        -- but only as o\bo\bo\bop\bp\bp\bpe\be\be\ber\br\br\bra\ba\ba\bat\bt\bt\bto\bo\bo\bor\br\br\br.  Eg.
 
-           sudo -u operator /bin/ls.
-
-       It is also possible to override a Runas_Spec later on in
-       an entry.  If we modify the entry like so:
 
-        dgb    boulder = (operator) /bin/ls, (root) /bin/kill, /usr/bin/lprm
 
-       Then user d\bd\bd\bdg\bg\bg\bgb\bb\bb\bb is now allowed to run _\b/_\bb_\bi_\bn_\b/_\bl_\bs as o\bo\bo\bop\bp\bp\bpe\be\be\ber\br\br\bra\ba\ba\bat\bt\bt\bto\bo\bo\bor\br\br\br,
-       but  _\b/_\bb_\bi_\bn_\b/_\bk_\bi_\bl_\bl and _\b/_\bu_\bs_\br_\b/_\bb_\bi_\bn_\b/_\bl_\bp_\br_\bm as r\br\br\bro\bo\bo\boo\bo\bo\bot\bt\bt\bt.
+22/Mar/2000                   1.6.3                            10
 
 
 
 
-22/Mar/2000                   1.6.3                            10
 
+sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+           sudo -u operator /bin/ls.
 
+       It is also possible to override a Runas_Spec later on in
+       an entry.  If we modify the entry like so:
 
-sudoers(5)                 FILE FORMATS                sudoers(5)
+        dgb    boulder = (operator) /bin/ls, (root) /bin/kill, /usr/bin/lprm
 
+       Then user d\bd\bd\bdg\bg\bg\bgb\bb\bb\bb is now allowed to run _\b/_\bb_\bi_\bn_\b/_\bl_\bs as o\bo\bo\bop\bp\bp\bpe\be\be\ber\br\br\bra\ba\ba\bat\bt\bt\bto\bo\bo\bor\br\br\br,
+       but  _\b/_\bb_\bi_\bn_\b/_\bk_\bi_\bl_\bl and _\b/_\bu_\bs_\br_\b/_\bb_\bi_\bn_\b/_\bl_\bp_\br_\bm as r\br\br\bro\bo\bo\boo\bo\bo\bot\bt\bt\bt.
 
        N\bN\bN\bNO\bO\bO\bOP\bP\bP\bPA\bA\bA\bAS\bS\bS\bSS\bS\bS\bSW\bW\bW\bWD\bD\bD\bD a\ba\ba\ban\bn\bn\bnd\bd\bd\bd P\bP\bP\bPA\bA\bA\bAS\bS\bS\bSS\bS\bS\bSW\bW\bW\bWD\bD\bD\bD
 
@@ -707,16 +717,6 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 
        [...]   Matches any character in the specified range.
 
-       [!...]  Matches any character n\bn\bn\bno\bo\bo\bot\bt\bt\bt in the specified range.
-
-       \x      For any character "x", evaluates to "x".  This is
-               used to escape special characters such as: "*",
-               "?", "[", and "}".
-
-       Note that a forward slash ('/') will n\bn\bn\bno\bo\bo\bot\bt\bt\bt be matched by
-       wildcards used in the pathname.  When matching the command
-       line arguments, however, as slash d\bd\bd\bdo\bo\bo\boe\be\be\bes\bs\bs\bs get matched by
-       wildcards.  This is to make a path like:
 
 
 
@@ -730,6 +730,17 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+       [!...]  Matches any character n\bn\bn\bno\bo\bo\bot\bt\bt\bt in the specified range.
+
+       \x      For any character "x", evaluates to "x".  This is
+               used to escape special characters such as: "*",
+               "?", "[", and "}".
+
+       Note that a forward slash ('/') will n\bn\bn\bno\bo\bo\bot\bt\bt\bt be matched by
+       wildcards used in the pathname.  When matching the command
+       line arguments, however, as slash d\bd\bd\bdo\bo\bo\boe\be\be\bes\bs\bs\bs get matched by
+       wildcards.  This is to make a path like:
+
            /usr/bin/*
 
        match /usr/bin/who but not /usr/bin/X11/xterm.
@@ -774,17 +785,6 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
        syntactic characters in a _\bU_\bs_\be_\br _\bS_\bp_\be_\bc_\bi_\bf_\bi_\bc_\ba_\bt_\bi_\bo_\bn ('=', ':',
        '(', ')') is optional.
 
-       The following characters must be escaped with a backslash
-       ('\') when used as part of a word (eg. a username or
-       hostname): '@', '!', '=', ':', ',', '(', ')', '\'.
-
-E\bE\bE\bEX\bX\bX\bXA\bA\bA\bAM\bM\bM\bMP\bP\bP\bPL\bL\bL\bLE\bE\bE\bES\bS\bS\bS
-       Below are example _\bs_\bu_\bd_\bo_\be_\br_\bs entries.  Admittedly, some of
-       these are a bit contrived.  First, we define our _\ba_\bl_\bi_\ba_\bs_\be_\bs:
-
-
-
-
 
 
 22/Mar/2000                   1.6.3                            12
@@ -796,6 +796,14 @@ E\bE\bE\bEX\bX\bX\bXA\bA\bA\bAM\bM\bM\bMP\bP\bP\bPL\bL\bL\bLE\bE\bE\bES\bS\bS\bS
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+       The following characters must be escaped with a backslash
+       ('\') when used as part of a word (eg. a username or
+       hostname): '@', '!', '=', ':', ',', '(', ')', '\'.
+
+E\bE\bE\bEX\bX\bX\bXA\bA\bA\bAM\bM\bM\bMP\bP\bP\bPL\bL\bL\bLE\bE\bE\bES\bS\bS\bS
+       Below are example _\bs_\bu_\bd_\bo_\be_\br_\bs entries.  Admittedly, some of
+       these are a bit contrived.  First, we define our _\ba_\bl_\bi_\ba_\bs_\be_\bs:
+
         # User alias specification
         User_Alias     FULLTIMERS = millert, mikef, dowdy
         User_Alias     PARTTIMERS = bostley, jwfox, crawl
@@ -843,14 +851,6 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
         Defaults:millert       !authenticate
         Defaults@SERVERS       log_year, logfile=/var/log/sudo.log
 
-       The _\bU_\bs_\be_\br _\bs_\bp_\be_\bc_\bi_\bf_\bi_\bc_\ba_\bt_\bi_\bo_\bn is the part that actually
-       determines who may run what.
-
-        root           ALL = (ALL) ALL
-        %wheel         ALL = (ALL) ALL
-
-       We let r\br\br\bro\bo\bo\boo\bo\bo\bot\bt\bt\bt and any user in group w\bw\bw\bwh\bh\bh\bhe\be\be\bee\be\be\bel\bl\bl\bl run any command on
-
 
 
 22/Mar/2000                   1.6.3                            13
@@ -862,6 +862,13 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+       The _\bU_\bs_\be_\br _\bs_\bp_\be_\bc_\bi_\bf_\bi_\bc_\ba_\bt_\bi_\bo_\bn is the part that actually
+       determines who may run what.
+
+        root           ALL = (ALL) ALL
+        %wheel         ALL = (ALL) ALL
+
+       We let r\br\br\bro\bo\bo\boo\bo\bo\bot\bt\bt\bt and any user in group w\bw\bw\bwh\bh\bh\bhe\be\be\bee\be\be\bel\bl\bl\bl run any command on
        any host as any user.
 
         FULLTIMERS     ALL = NOPASSWD: ALL
@@ -909,13 +916,6 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
        assumes _\bp_\ba_\bs_\bs_\bw_\bd(1) does not take multiple usernames on the
        command line.
 
-        bob            SPARC = (OP) ALL : SGI = (OP) ALL
-
-       The user b\bb\bb\bbo\bo\bo\bob\bb\bb\bb may run anything on the _\bS_\bP_\bA_\bR_\bC and _\bS_\bG_\bI
-       machines as any user listed in the _\bO_\bP Runas_Alias (r\br\br\bro\bo\bo\boo\bo\bo\bot\bt\bt\bt
-       and o\bo\bo\bop\bp\bp\bpe\be\be\ber\br\br\bra\ba\ba\bat\bt\bt\bto\bo\bo\bor\br\br\br).
-
-        jim            +biglab = ALL
 
 
 
@@ -928,6 +928,14 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+        bob            SPARC = (OP) ALL : SGI = (OP) ALL
+
+       The user b\bb\bb\bbo\bo\bo\bob\bb\bb\bb may run anything on the _\bS_\bP_\bA_\bR_\bC and _\bS_\bG_\bI
+       machines as any user listed in the _\bO_\bP Runas_Alias (r\br\br\bro\bo\bo\boo\bo\bo\bot\bt\bt\bt
+       and o\bo\bo\bop\bp\bp\bpe\be\be\ber\br\br\bra\ba\ba\bat\bt\bt\bto\bo\bo\bor\br\br\br).
+
+        jim            +biglab = ALL
+
        The user j\bj\bj\bji\bi\bi\bim\bm\bm\bm may run any command on machines in the _\bb_\bi_\bg_\bl_\ba_\bb
        netgroup.  S\bS\bS\bSu\bu\bu\bud\bd\bd\bdo\bo\bo\bo knows that "biglab" is a netgroup due to
        the '+' prefix.
@@ -974,14 +982,6 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 
        On the host www, any user in the _\bW_\bE_\bB_\bM_\bA_\bS_\bT_\bE_\bR_\bS User_Alias
        (will, wendy, and wim), may run any command as user www
-       (which owns the web pages) or simply _\bs_\bu(1) to www.
-
-        ALL            CDROM = NOPASSWD: /sbin/umount /CDROM,\
-                       /sbin/mount -o nosuid\,nodev /dev/cd0a /CDROM
-
-       Any user may mount or unmount a CD-ROM on the machines in
-       the CDROM Host_Alias (orion, perseus, hercules) without
-       entering a password.  This is a bit tedious for users to
 
 
 
@@ -994,6 +994,14 @@ sudoers(5)                 FILE FORMATS                sudoers(5)
 sudoers(5)                 FILE FORMATS                sudoers(5)
 
 
+       (which owns the web pages) or simply _\bs_\bu(1) to www.
+
+        ALL            CDROM = NOPASSWD: /sbin/umount /CDROM,\
+                       /sbin/mount -o nosuid\,nodev /dev/cd0a /CDROM
+
+       Any user may mount or unmount a CD-ROM on the machines in
+       the CDROM Host_Alias (orion, perseus, hercules) without
+       entering a password.  This is a bit tedious for users to
        type, so it is a prime candiate for encapsulating in a
        shell script.
 
@@ -1020,9 +1028,9 @@ C\bC\bC\bCA\bA\bA\bAV\bV\bV\bVE\bE\bE\bEA\bA\bA\bAT\bT\bT\bTS\bS\bS\bS
        incorrect _\bs_\bu_\bd_\bo_\be_\br_\bs file.
 
        When using netgroups of machines (as opposed to users), if
-       you store fully-qualified hostnames in the netgroup (as is
+       you store fully qualified hostnames in the netgroup (as is
        usually the case), you either need to have the machine's
-       hostname be fully-qualified as returned by the hostname
+       hostname be fully qualified as returned by the hostname
        command or use the _\bf_\bq_\bd_\bn option in _\bs_\bu_\bd_\bo_\be_\br_\bs.
 
 F\bF\bF\bFI\bI\bI\bIL\bL\bL\bLE\bE\bE\bES\bS\bS\bS
@@ -1043,14 +1051,6 @@ S\bS\bS\bSE\bE\bE\bEE\bE\bE\bE A\bA\bA\bAL\bL\bL\bLS\bS\bS\bSO\bO\bO\bO
 
 
 
-
-
-
-
-
-
-
-
 22/Mar/2000                   1.6.3                            16
 
 
index 214c604824a0b97fb43062b01a3efef48b3e278a..ce7f5d150c7ade091469322b27b6e87aa96c2016 100644 (file)
@@ -2,8 +2,8 @@
 ''' $RCSfile$$Revision$$Date$
 '''
 ''' $Log$
-''' Revision 1.3  2000/03/23 03:20:57  millert
-''' Document set_logname option and enbolden refs to sudo and visudo.
+''' Revision 1.4  2000/03/23 04:09:53  millert
+''' Add support for wildcards in the hostname.
 '''
 '''
 .de Sh
@@ -315,7 +315,11 @@ Again, the value of an item may be negated with the \*(L'!\*(R' operator.
 If you do not specify a netmask with a network number, the netmask
 of the host's ethernet \fIinterface\fR\|(s) will be used when matching.
 The netmask may be specified either in dotted quad notation (eg.
-255.255.255.0) or \s-1CIDR\s0 notation (number of bits, eg. 24).
+255.255.255.0) or \s-1CIDR\s0 notation (number of bits, eg. 24).  A hostname
+may include shell-style wildcards (see `Wildcards\*(R' section below),
+but unless the \f(CWhostname\fR command on your machine returns the fully
+qualified hostname, you'll need to use the \fIfqdn\fR option for wildcards
+to be useful.
 .PP
 .Vb 2
 \& Cmnd_List ::= Cmnd |
@@ -332,7 +336,7 @@ The netmask may be specified either in dotted quad notation (eg.
 \&          '!'* Cmnd_Alias
 .Ve
 A \f(CWCmnd_List\fR is a list of one or more commandnames, directories, and other
-aliases.  A commandname is a fully-qualified filename which may include
+aliases.  A commandname is a fully qualified filename which may include
 shell-style wildcards (see `Wildcards\*(R' section below).  A simple
 filename allows the user to run the command with any arguments he/she
 wishes.  However, you may also command line arguments (including wildcards).
@@ -961,8 +965,8 @@ imperative that \fIsudoers\fR be free of syntax errors since \fBsudo\fR
 will not run with a syntactically incorrect \fIsudoers\fR file.
 .PP
 When using netgroups of machines (as opposed to users), if you
-store fully-qualified hostnames in the netgroup (as is usually the
-case), you either need to have the machine's hostname be fully-qualified
+store fully qualified hostnames in the netgroup (as is usually the
+case), you either need to have the machine's hostname be fully qualified
 as returned by the \f(CWhostname\fR command or use the \fIfqdn\fR option in
 \fIsudoers\fR.
 .SH "FILES"
index dba8dd56ee0a069d41bc9dad4e7ec63714431639..a592f2ad38639fffccd664c220d48a50516f8b44 100644 (file)
@@ -162,7 +162,11 @@ Again, the value of an item may be negated with the '!' operator.
 If you do not specify a netmask with a network number, the netmask
 of the host's ethernet interface(s) will be used when matching.
 The netmask may be specified either in dotted quad notation (eg.
-255.255.255.0) or CIDR notation (number of bits, eg. 24).
+255.255.255.0) or CIDR notation (number of bits, eg. 24).  A hostname
+may include shell-style wildcards (see `Wildcards' section below),
+but unless the C<hostname> command on your machine returns the fully
+qualified hostname, you'll need to use the I<fqdn> option for wildcards
+to be useful.
 
  Cmnd_List ::= Cmnd |
               Cmnd ',' Cmnd_List
@@ -176,7 +180,7 @@ The netmask may be specified either in dotted quad notation (eg.
          '!'* Cmnd_Alias
 
 A C<Cmnd_List> is a list of one or more commandnames, directories, and other
-aliases.  A commandname is a fully-qualified filename which may include
+aliases.  A commandname is a fully qualified filename which may include
 shell-style wildcards (see `Wildcards' section below).  A simple
 filename allows the user to run the command with any arguments he/she
 wishes.  However, you may also command line arguments (including wildcards).
@@ -910,8 +914,8 @@ imperative that I<sudoers> be free of syntax errors since B<sudo>
 will not run with a syntactically incorrect I<sudoers> file.
 
 When using netgroups of machines (as opposed to users), if you
-store fully-qualified hostnames in the netgroup (as is usually the
-case), you either need to have the machine's hostname be fully-qualified
+store fully qualified hostnames in the netgroup (as is usually the
+case), you either need to have the machine's hostname be fully qualified
 as returned by the C<hostname> command or use the I<fqdn> option in
 I<sudoers>.
 
index 9f7b5337401cffec16b2f89cf810080bca5767ff..b517910dd2850cc13411a8116b5807500ed7a9aa 100644 (file)
@@ -210,6 +210,18 @@ addr_matches(n)
     return(FALSE);
 }
 
+int
+hostname_matches(host, pattern)
+    char *host;
+    char *pattern;
+{
+    if (has_meta(pattern)) 
+       return(fnmatch(pattern, host, FNM_CASEFOLD));
+    else
+       return(strcasecmp(host, pattern));
+}
+
 int
 usergr_matches(group, user)
     char *group;
index f7cbd984fbc0329c646e9458ec66022a8eb53808..b9c53e20a77f9a7bb996923b19a9045a9e88f282 100644 (file)
--- a/visudo.c
+++ b/visudo.c
@@ -93,6 +93,7 @@ static RETSIGTYPE Exit                __P((int));
 static void setup_signals      __P((void));
 int command_matches            __P((char *, char *, char *, char *));
 int addr_matches               __P((char *));
+int hostname_matches           __P((char *, char *));
 int netgr_matches              __P((char *, char *, char *, char *));
 int usergr_matches             __P((char *, char *));
 void init_parser               __P((void));
@@ -405,6 +406,13 @@ addr_matches(n)
     return(TRUE);
 }
 
+int
+hostname_matches(h, p)
+    char *h, *p;
+{
+    return(TRUE);
+}
+
 int
 usergr_matches(g, u)
     char *g, *u;