From 961a79b743f31db432e6b7578202952deb6aecc1 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sun, 20 Jan 2008 01:25:39 +0000 Subject: [PATCH] Fill in some of the missing pieces. Still needs some reorganization and editing. --- sudoers.ldap.cat | 548 +++++++++++++++++++++++++++++++++++--------- sudoers.ldap.man.in | 419 ++++++++++++++++++++++++--------- sudoers.ldap.pod | 412 ++++++++++++++++++++++++++------- 3 files changed, 1081 insertions(+), 298 deletions(-) diff --git a/sudoers.ldap.cat b/sudoers.ldap.cat index 569d68fef..0dc5cb06b 100644 --- a/sudoers.ldap.cat +++ b/sudoers.ldap.cat @@ -10,7 +10,7 @@ NNAAMMEE DDEESSCCRRIIPPTTIIOONN In addition to the standard _s_u_d_o_e_r_s file, ssuuddoo may be con- figured via LAP. This can be especially useful for syn- - cronizing _s_u_d_o_e_r_s in a large, distributed environment. + chronizing _s_u_d_o_e_r_s in a large, distributed environment. Using LDAP for _s_u_d_o_e_r_s has several benefits: @@ -89,6 +89,86 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) (10.2.3.4/255.255.0.0). Alternately, they can all just be pasted into the LDAP record. + SSUUDDOOeerrss LLDDAAPP ccoonnttaaiinneerr + + The _s_u_d_o_e_r_s configuration is contained in the ou=SUDOers + LDAP container. + + Sudo first looks for the cn=default entry in the SUDOers + container. If found, the multi-valued sudoOption + attribute is parsed in the same manner as a global + Defaults line in _/_e_t_c_/_s_u_d_o_e_r_s. In the following example, + the SSH_AUTH_SOCK variable will be preserved in the envi- + ronment for all users. + + dn: cn=defaults,ou=SUDOers,dc=example,dc=com + objectClass: top + objectClass: sudoRole + cn: defaults + description: Default sudoOption's go here + sudoOption: env_keep+=SSH_AUTH_SOCK + + The equivalent of a sudoer in LDAP is a sudoRole. It con- + sists of the following components: + + sudoUser + A user name, uid (prefixed with '#'), Unix group (pre- + fixed with a '%') or user netgroup (prefixed with a + '+'). + + sudoHost + A host name, IP address, IP network, or host netgroup + (prefixed with a '+'). The special value ALL will + match any host. + + sudoCommand + A Unix command with optional command line arguments, + potentially including globbing characters (aka wild + + + +1.7 January 19, 2008 2 + + + + + +SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) + + + cards). The special value ALL will match any command. + + sudoOption + Similar to the global options described above, but + specific to the sudoRole in which it resides. + + sudoRunAsUser + A user name or uid (prefixed with '#') that commands + may be run as or a Unix group (prefixed with a '%') or + user netgroup (prefixed with a '+') that contains a + list of users that commands may be run as. The spe- + cial value ALL will match any user. + + sudoRunAsGroup + A Unix group or gid (prefixed with '#') that commands + may be run as. The special value ALL will match any + group. + + Each entry listed above contains a single value, but may + be repeated multiple times. A sudoRole must contain at + least one sudoUser, sudoHost and sudoCommand. + + The following example allows users in group wheel to run + any command on any host via ssuuddoo: + + dn: cn=%wheel,ou=SUDOers,dc=example,dc=com + objectClass: top + objectClass: sudoRole + cn: %wheel + sudoUser: %wheel + sudoHost: ALL + sudoCommand: ALL + DDiiffffeerreenncceess bbeettwweeeenn LLDDAAPP aanndd nnoonn--LLDDAAPP ssuuddooeerrss There are some subtle differences in the way sudoers is @@ -102,32 +182,18 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) Here is an example: - # /etc/sudoers: - # Allow all commands except shell - johnny ALL=(root) ALL,!/bin/sh - # Always allows all commands because ALL is matched last - puddles ALL=(root) !/bin/sh,ALL + # /etc/sudoers: + # Allow all commands except shell + johnny ALL=(root) ALL,!/bin/sh + # Always allows all commands because ALL is matched last + puddles ALL=(root) !/bin/sh,ALL - # LDAP equivalent of Johnny - # Allows all commands except shell - dn: cn=role1,ou=Sudoers,dc=my-domain,dc=com - objectClass: sudoRole - objectClass: top - cn: role1 - sudoUser: johnny - sudoHost: ALL - sudoCommand: ALL - sudoCommand: !/bin/sh - - - - -1.7 January 19, 2008 2 +1.7 January 19, 2008 3 @@ -136,64 +202,64 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) - # LDAP equivalent of Puddles - # Notice that even though ALL comes last, it still behaves like - # role1 since the LDAP code assumes the more paranoid configuration - dn: cn=role2,ou=Sudoers,dc=my-domain,dc=com - objectClass: sudoRole - objectClass: top - cn: role2 - sudoUser: puddles - sudoHost: ALL - sudoCommand: !/bin/sh - sudoCommand: ALL + # LDAP equivalent of Johnny + # Allows all commands except shell + dn: cn=role1,ou=Sudoers,dc=my-domain,dc=com + objectClass: sudoRole + objectClass: top + cn: role1 + sudoUser: johnny + sudoHost: ALL + sudoCommand: ALL + sudoCommand: !/bin/sh + + # LDAP equivalent of Puddles + # Notice that even though ALL comes last, it still behaves like + # role1 since the LDAP code assumes the more paranoid configuration + dn: cn=role2,ou=Sudoers,dc=my-domain,dc=com + objectClass: sudoRole + objectClass: top + cn: role2 + sudoUser: puddles + sudoHost: ALL + sudoCommand: !/bin/sh + sudoCommand: ALL Another difference is that negations on the Host, User or Runas are currently ignorred. For example, the following attributes do not do what they might appear to do. - # does not match all but joe - # rather, does not match anyone - sudoUser: !joe - - # does not match all but joe - # rather, matches everyone including Joe - sudoUser: ALL - sudoUser: !joe + # does not match all but joe + # rather, does not match anyone + sudoUser: !joe - # does not match all but web01 - # rather, matches all hosts including web01 - sudoHost: ALL - sudoHost: !web01 + # does not match all but joe + # rather, matches everyone including Joe + sudoUser: ALL + sudoUser: !joe - DDeessccrriippttiioonn ooff ssuuddooRRoollee + # does not match all but web01 + # rather, matches all hosts including web01 + sudoHost: ALL + sudoHost: !web01 - The equivalent of a sudoer in LDAP is a 'sudoRole'. It - contains sudoUser(s), sudoHost, sudoCommand and optional - sudoOption(s), sudoRunAsUser(s) and sudoRunAsGroup(s). + SSuuddooeerrss SScchheemmaa - The following example allows users in group wheel to run - any command on any host via ssuuddoo: + In order to use ssuuddoo's LDAP support, the ssuuddoo schema must + be installed on your LDAP server. In addition, be sure to + index the 'sudoUser' attribute. - dn: cn=%wheel,ou=SUDOers,dc=example,dc=com - objectClass: top - objectClass: sudoRole - cn: %wheel - sudoUser: %wheel - sudoHost: ALL - sudoCommand: ALL + Two versions of the schema, one for OpenLDAP servers + (_s_c_h_e_m_a_._O_p_e_n_L_D_A_P) and another for Netscape-derived servers + (_s_c_h_e_m_a_._i_P_l_a_n_e_t), may be found in the ssuuddoo distribution. - SSuuddooeerrss SScchheemmaa + The schema for ssuuddoo in OpenLDAP form is included below. - In order to use ssuuddoo's LDAP support the ssuuddoo schema must - be installled on your LDAP server. In addition, be sure - to index the attribute 'sudoUser'. - Two versions of the schema, one for OpenLDAP servers and -1.7 January 19, 2008 3 +1.7 January 19, 2008 4 @@ -202,10 +268,6 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) - another for netscape-derived servers, may also be found in - the ssuuddoo distribution. The schema for ssuuddoo in OpenLDAP - form appears below. - attributetype ( 1.3.6.1.4.1.15953.9.1.1 NAME 'sudoUser' DESC 'User(s) who may run sudo' @@ -259,7 +321,11 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) -1.7 January 19, 2008 4 + + + + +1.7 January 19, 2008 5 @@ -295,7 +361,7 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) or port 636 for ldaps://. If no _h_o_s_t_n_a_m_e is speci- fied, ssuuddoo will connect to llooccaallhhoosstt. Only systems using the OpenSSL libraries support the mixing of - ldap:// and ldaps:// URIs. The netscape-derived + ldap:// and ldaps:// URIs. The Netscape-derived libraries used on most commercial versions of Unix are only capable of supporting one or the other. @@ -325,7 +391,7 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) -1.7 January 19, 2008 5 +1.7 January 19, 2008 6 @@ -334,19 +400,23 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) + TIMELIMIT seconds + The TTIIMMEELLIIMMIITT parameter specifies the amount of time, + in seconds, to wait for a response to an LDAP query. + SUDOERS_BASE base - The base DN to use when performing ssuuddoo LDAP lookups. + The base DN to use when performing ssuuddoo LDAP queries. Typically this is of the form ou=SUDOers,dc=exam- ple,dc=com for the domain example.com. SUDOERS_DEBUG debug_level - This sets the debug level for ssuuddoo LDAP lookups. - Debuging information is printed to the standard error. - A value of 1 results in a moderate amount of debugging - information. A value of 2 shows the results of the - matches themselves. This parameter should not be set - in a production environment as the extra information - is likely to confuse users. + This sets the debug level for ssuuddoo LDAP queries. + Debugging information is printed to the standard + error. A value of 1 results in a moderate amount of + debugging information. A value of 2 shows the results + of the matches themselves. This parameter should not + be set in a production environment as the extra infor- + mation is likely to confuse users. BINDDN DN The BBIINNDDDDNN parameter specifies the identity, in the @@ -365,7 +435,7 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) The RROOOOTTBBIINNDDDDNN parameter specifies the identity, in the form of a Distinguished Name (DN), to use when performing privileged LDAP operations, such as _s_u_d_o_e_r_s - lookups. The password corresponding to the identity + queries. The password corresponding to the identity should be stored in If not speci- fied, the BBIINNDDDDNN identity is used (if any). @@ -384,14 +454,10 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) If the SSSSLL parameter is set to start_tls, the LDAP server connection is initiated normally and TLS encryption is begun before the bind credentials are - sent. This has the advantage of not requiring a dedi- - cated port for encrypted communications. This parame- - ter is only supported by LDAP servers that honor the - start_tls extension, such as the OpenLDAP server. -1.7 January 19, 2008 6 +1.7 January 19, 2008 7 @@ -400,6 +466,11 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) + sent. This has the advantage of not requiring a dedi- + cated port for encrypted communications. This parame- + ter is only supported by LDAP servers that honor the + start_tls extension, such as the OpenLDAP server. + TLS_CHECKPEER on/true/yes/off/false/no If enabled, TTLLSS__CCHHEECCKKPPEEEERR will cause the LDAP server's TLS certificated to be verified. If the server's TLS @@ -408,36 +479,125 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) be unable to connect to it. If TTLLSS__CCHHEECCKKPPEEEERR is dis- abled, no check is made. - TLS_CACERTFILE - TLS_CACERTDIR - TLS_RANDFILE - TLS_CIPHERS - TLS_CERT - TLS_KEY - USE_SASL - SASL_AUTH_ID - ROOTUSE_SASL - ROOTSASL_AUTH_ID - SASL_SECPROPS - KRB5_CCNAME + TLS_CACERTFILE file name + The path to a certificate authority bundle which con- + tains the certificates for all the Certificate Author- + ities the client knows to be valid, e.g. + _/_e_t_c_/_s_s_l_/_c_a_-_b_u_n_d_l_e_._p_e_m. This option is only supported + by the OpenLDAP libraries. + + TLS_CACERTDIR directory + Similar to TTLLSS__CCAACCEERRTTFFIILLEE but instead of a file, it is + a directory containing individual Certificate Author- + ity certificates, e.g. _/_e_t_c_/_s_s_l_/_c_e_r_t_s. The directory + specified by TTLLSS__CCAACCEERRTTDDIIRR is checked after TTLLSS__CCAACC-- + EERRTTFFIILLEE. This option is only supported by the OpenL- + DAP libraries. + + TLS_CERT file name + The path to a file containing the client certificate + which can be used to authenticate the client to the + LDAP server. + + OpenLDAP tls_cert /etc/ssl/client_cert.pem + + Netscape-derived tls_cert /var/ldap/cert7.db + + When using Netscape-derived libraries, this file may + also contain Certificate Authority certificates. + + TLS_KEY file name + The path to a file containing the private key which + matches the certificate specified by TTLLSS__CCEERRTT. The + private key must not be password-protected. + + OpenLDAP tls_cert /etc/ssl/client_key.pem + + Netscape-derived tls_cert /var/ldap/key3.db + + TLS_RANDFILE file name + The TTLLSS__RRAANNDDFFIILLEE parameter specifies the path to an + entropy source for systems that lack a random device. + It is generally used in conjunction with _p_r_n_g_d or _e_g_d. + This option is only supported by the OpenLDAP + + + +1.7 January 19, 2008 8 + + + + + +SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) + + + libraries. + + TLS_CIPHERS cipher list + The TTLLSS__CCIIPPHHEERRSS parameter allows the administer to + restrict which encryption algorithms may be used for + TLS (SSL) connections. See the OpenSSL manual for a + list of valid ciphers. This option is only supported + by the OpenLDAP libraries. + + USE_SASL on/true/yes/off/false/no + Enable UUSSEE__SSAASSLL for LDAP servers that support SASL + authentication. + + SASL_AUTH_ID identity + The SASL user name to use when connecting to the LDAP + server. By default, ssuuddoo will use an anonymous con- + nection. + + ROOTUSE_SASL on/true/yes/off/false/no + Enable RROOOOTTUUSSEE__SSAASSLL to enable SASL authentication when + connecting to an LDAP server from a privileged pro- + cess, such as ssuuddoo. + + ROOTSASL_AUTH_ID identity + The SASL user name to use when RROOOOTTUUSSEE__SSAASSLL is + enabled. + + SASL_SECPROPS none/properties + SASL security properties or _n_o_n_e for no properties. + See the SASL programmer's manual for details. + + KRB5_CCNAME file name + The path to the Kerberos 5 credential cache to use + when authenticating with the remote server. + + See the ldap.conf entry in the EXAMPLES section. CCoonnffiigguurriinngg nnsssswwiittcchh..ccoonnff Sudo consults the Name Service Switch file, _/_e_t_c_/_n_s_s_- _w_i_t_c_h_._c_o_n_f, to specify the _s_u_d_o_e_r_s search order. Sudo - looks for a line begining with sudoers: and uses this to + looks for a line beginning with sudoers: and uses this to determine the search order. Note that ssuuddoo does not stop searching after the first match and later matches take precedence over earlier ones. - The following sources are recognized. - files read sudoers from a file (usually _/_e_t_c_/_s_u_d_o_e_r_s) - ldap read sudoers from LDAP + The following sources are recognized: + + files read sudoers from a file (usually F) + ldap read sudoers from LDAP In addition, the entry [NOTFOUND=return] will short-cir- cuit the search if the user was not found in the preceding source. + + +1.7 January 19, 2008 9 + + + + + +SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) + + To consult LDAP first followed by the local sudoers file (if it exists), use: @@ -452,12 +612,50 @@ SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) sudoers: files + Note that _/_e_t_c_/_n_s_s_w_i_t_c_h_._c_o_n_f is supported even when the + underlying operating system does not use an nsswitch.conf + file. + FFIILLEESS _/_e_t_c_/_l_d_a_p_._c_o_n_f LDAP configuration file + + _/_e_t_c_/_n_s_s_w_i_t_c_h_._c_o_n_f determines sudoers source order + +EEXXAAMMPPLLEESS + XXXXXX nnsssswwiittcchh..ccoonnff eexxaammppllee?? + + + XXXXXX ssuuddooeerrss llddiiff eexxaammppllee?? + + + EExxaammppllee llddaapp..ccoonnff + + + + + + + + + + + + + + + + + + + + -1.7 January 19, 2008 7 + + + +1.7 January 19, 2008 10 @@ -466,14 +664,113 @@ FFIILLEESS SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) - _/_e_t_c_/_n_s_s_w_i_t_c_h_._c_o_n_f determines sudoers source order + # Either specify one or more URIs or one or more host:port pairs. + # If neither is specified sudo will default to localhost, port 389. + # + #host ldapserver + #host ldapserver1 ldapserver2:390 + # + # Default port if host is specified without one, defaults to 389. + #port 389 + # + # URI will override the host and port settings. + uri ldap://ldapserver + #uri ldaps://secureldapserver + #uri ldaps://secureldapserver ldap://ldapserver + # + # The amount of time, in seconds, to wait while trying to connect to + # an LDAP server. + bind_timelimit 30 + # + # The amount of time, in seconds, to wait while performing an LDAP query. + timelimit 30 + # + # must be set or sudo will ignore LDAP + sudoers_base ou=SUDOers,dc=example,dc=com + # + # verbose sudoers matching from ldap + #sudoers_debug 2 + # + # optional proxy credentials + #binddn + #bindpw + #rootbinddn + # + # LDAP protocol version, defaults to 3 + #ldap_version 3 + # + # Define if you want to use an encrypted LDAP connection. + # Typically, you must also set the port to 636 (ldaps). + #ssl on + # + # Define if you want to use port 389 and switch to + # encryption before the bind credentials are sent. + # Only supported by LDAP servers that support the start_tls + # extension such as OpenLDAP. + #ssl start_tls + # + # Additional TLS options follow that allow tweaking of the + # SSL/TLS connection. + # + #tls_checkpeer yes # verify server SSL certificate + #tls_checkpeer no # ignore server SSL certificate + # + # If you enable tls_checkpeer, specify either tls_cacertfile + # or tls_cacertdir. Only supported when using OpenLDAP. + # + + + +1.7 January 19, 2008 11 + -EEXXAAMMPPLLEESS - Example entries - Example ldap.conf - Debugging info + +SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) + + + #tls_cacertfile /etc/certs/trusted_signers.pem + #tls_cacertdir /etc/certs + # + # For systems that don't have /dev/random + # use this along with PRNGD or EGD.pl to seed the + # random number pool to generate cryptographic session keys. + # Only supported when using OpenLDAP. + # + #tls_randfile /etc/egd-pool + # + # You may restrict which ciphers are used. Consult your SSL + # documentation for which options go here. + # Only supported when using OpenLDAP. + # + #tls_ciphers + # + # Sudo can provide a client certificate when communicating to + # the LDAP server. + # Tips: + # * Enable both lines at the same time. + # * Do not password protect the key file. + # * Ensure the keyfile is only readable by root. + # + # For OpenLDAP: + #tls_cert /etc/certs/client_cert.pem + #tls_key /etc/certs/client_key.pem + # + # For SunONE or iPlanet LDAP, the file specified by tls_cert may + # contain CA certs and/or the client's cert. If the client's + # cert is included, tls_key should be specified as well. + # For backward compatibility, sslpath may be used in place of tls_cert. + #tls_cert /var/ldap/cert7.db + #tls_key /var/ldap/key3.db + # + # If using SASL authentication for LDAP (OpenSSL) + # use_sasl yes + # sasl_auth_id + # rootuse_sasl yes + # rootsasl_auth_id + # sasl_secprops none + # krb5_ccname /etc/.ldapcache SSEEEE AALLSSOO _l_d_a_p_._c_o_n_f(4), _s_u_d_o_e_r_s(4) @@ -486,8 +783,20 @@ BBUUGGSS bug report at http://www.sudo.ws/sudo/bugs/ SSUUPPPPOORRTT - Limited free support is available via the sudo-users mail- - ing list, see http://www.sudo.ws/mail- + Limited free support is available via the sudo-users + + + +1.7 January 19, 2008 12 + + + + + +SUDOERS.LDAP(4) MAINTENANCE COMMANDS SUDOERS.LDAP(4) + + + mailing list, see http://www.sudo.ws/mail- man/listinfo/sudo-users to subscribe or search the archives. @@ -523,6 +832,27 @@ DDIISSCCLLAAIIMMEERR -1.7 January 19, 2008 8 + + + + + + + + + + + + + + + + + + + + + +1.7 January 19, 2008 13 diff --git a/sudoers.ldap.man.in b/sudoers.ldap.man.in index 7f53192e4..a01295cd9 100644 --- a/sudoers.ldap.man.in +++ b/sudoers.ldap.man.in @@ -152,7 +152,7 @@ sudoers.ldap \- sudo LDAP configuration .SH "DESCRIPTION" .IX Header "DESCRIPTION" In addition to the standard \fIsudoers\fR file, \fBsudo\fR may be configured -via \s-1LAP\s0. This can be especially useful for syncronizing \fIsudoers\fR +via \s-1LAP\s0. This can be especially useful for synchronizing \fIsudoers\fR in a large, distributed environment. .PP Using \s-1LDAP\s0 for \fIsudoers\fR has several benefits: @@ -210,6 +210,74 @@ into the \s-1LDAP\s0 record. If you need to specify a large number of hosts in an entry, use netgroups or \s-1IP\s0 address matches (10.2.3.4/255.255.0.0). Alternately, they can all just be pasted into the \s-1LDAP\s0 record. +.Sh "SUDOers \s-1LDAP\s0 container" +.IX Subsection "SUDOers LDAP container" +The \fIsudoers\fR configuration is contained in the \f(CW\*(C`ou=SUDOers\*(C'\fR \s-1LDAP\s0 +container. +.PP +Sudo first looks for the \f(CW\*(C`cn=default\*(C'\fR entry in the SUDOers container. +If found, the multi-valued \f(CW\*(C`sudoOption\*(C'\fR attribute is parsed in the +same manner as a global \f(CW\*(C`Defaults\*(C'\fR line in \fI/etc/sudoers\fR. In +the following example, the \f(CW\*(C`SSH_AUTH_SOCK\*(C'\fR variable will be preserved +in the environment for all users. +.PP +.Vb 6 +\& dn: cn=defaults,ou=SUDOers,dc=example,dc=com +\& objectClass: top +\& objectClass: sudoRole +\& cn: defaults +\& description: Default sudoOption's go here +\& sudoOption: env_keep+=SSH_AUTH_SOCK +.Ve +.PP +The equivalent of a sudoer in \s-1LDAP\s0 is a \f(CW\*(C`sudoRole\*(C'\fR. It consists of +the following components: +.IP "sudoUser" 4 +.IX Item "sudoUser" +A user name, uid (prefixed with \f(CW'#'\fR), Unix group (prefixed with +a \f(CW'%'\fR) or user netgroup (prefixed with a \f(CW'+'\fR). +.IP "sudoHost" 4 +.IX Item "sudoHost" +A host name, \s-1IP\s0 address, \s-1IP\s0 network, or host netgroup (prefixed +with a \f(CW'+'\fR). +The special value \f(CW\*(C`ALL\*(C'\fR will match any host. +.IP "sudoCommand" 4 +.IX Item "sudoCommand" +A Unix command with optional command line arguments, potentially +including globbing characters (aka wild cards). +The special value \f(CW\*(C`ALL\*(C'\fR will match any command. +.IP "sudoOption" 4 +.IX Item "sudoOption" +Similar to the global options described above, but specific to the +\&\f(CW\*(C`sudoRole\*(C'\fR in which it resides. +.IP "sudoRunAsUser" 4 +.IX Item "sudoRunAsUser" +A user name or uid (prefixed with \f(CW'#'\fR) that commands may be run +as or a Unix group (prefixed with a \f(CW'%'\fR) or user netgroup (prefixed +with a \f(CW'+'\fR) that contains a list of users that commands may be +run as. +The special value \f(CW\*(C`ALL\*(C'\fR will match any user. +.IP "sudoRunAsGroup" 4 +.IX Item "sudoRunAsGroup" +A Unix group or gid (prefixed with \f(CW'#'\fR) that commands may be run as. +The special value \f(CW\*(C`ALL\*(C'\fR will match any group. +.PP +Each entry listed above contains a single value, but may be repeated +multiple times. A sudoRole must contain at least one \f(CW\*(C`sudoUser\*(C'\fR, +\&\f(CW\*(C`sudoHost\*(C'\fR and \f(CW\*(C`sudoCommand\*(C'\fR. +.PP +The following example allows users in group wheel to run any command +on any host via \fBsudo\fR: +.PP +.Vb 7 +\& dn: cn=%wheel,ou=SUDOers,dc=example,dc=com +\& objectClass: top +\& objectClass: sudoRole +\& cn: %wheel +\& sudoUser: %wheel +\& sudoHost: ALL +\& sudoCommand: ALL +.Ve .Sh "Differences between \s-1LDAP\s0 and non-LDAP sudoers" .IX Subsection "Differences between LDAP and non-LDAP sudoers" There are some subtle differences in the way sudoers is handled @@ -222,38 +290,38 @@ called paranoid behavior (not necessarily the most specific match). Here is an example: .PP .Vb 5 -\& # /etc/sudoers: -\& # Allow all commands except shell -\& johnny ALL=(root) ALL,!/bin/sh -\& # Always allows all commands because ALL is matched last -\& puddles ALL=(root) !/bin/sh,ALL +\& # /etc/sudoers: +\& # Allow all commands except shell +\& johnny ALL=(root) ALL,!/bin/sh +\& # Always allows all commands because ALL is matched last +\& puddles ALL=(root) !/bin/sh,ALL .Ve .PP .Vb 10 -\& # LDAP equivalent of Johnny -\& # Allows all commands except shell -\& dn: cn=role1,ou=Sudoers,dc=my-domain,dc=com -\& objectClass: sudoRole -\& objectClass: top -\& cn: role1 -\& sudoUser: johnny -\& sudoHost: ALL -\& sudoCommand: ALL -\& sudoCommand: !/bin/sh +\& # LDAP equivalent of Johnny +\& # Allows all commands except shell +\& dn: cn=role1,ou=Sudoers,dc=my-domain,dc=com +\& objectClass: sudoRole +\& objectClass: top +\& cn: role1 +\& sudoUser: johnny +\& sudoHost: ALL +\& sudoCommand: ALL +\& sudoCommand: !/bin/sh .Ve .PP .Vb 11 -\& # LDAP equivalent of Puddles -\& # Notice that even though ALL comes last, it still behaves like -\& # role1 since the LDAP code assumes the more paranoid configuration -\& dn: cn=role2,ou=Sudoers,dc=my-domain,dc=com -\& objectClass: sudoRole -\& objectClass: top -\& cn: role2 -\& sudoUser: puddles -\& sudoHost: ALL -\& sudoCommand: !/bin/sh -\& sudoCommand: ALL +\& # LDAP equivalent of Puddles +\& # Notice that even though ALL comes last, it still behaves like +\& # role1 since the LDAP code assumes the more paranoid configuration +\& dn: cn=role2,ou=Sudoers,dc=my-domain,dc=com +\& objectClass: sudoRole +\& objectClass: top +\& cn: role2 +\& sudoUser: puddles +\& sudoHost: ALL +\& sudoCommand: !/bin/sh +\& sudoCommand: ALL .Ve .PP Another difference is that negations on the Host, User or Runas are @@ -261,52 +329,35 @@ currently ignorred. For example, the following attributes do not do what they might appear to do. .PP .Vb 3 -\& # does not match all but joe -\& # rather, does not match anyone -\& sudoUser: !joe +\& # does not match all but joe +\& # rather, does not match anyone +\& sudoUser: !joe .Ve .PP .Vb 4 -\& # does not match all but joe -\& # rather, matches everyone including Joe -\& sudoUser: ALL -\& sudoUser: !joe +\& # does not match all but joe +\& # rather, matches everyone including Joe +\& sudoUser: ALL +\& sudoUser: !joe .Ve .PP .Vb 4 -\& # does not match all but web01 -\& # rather, matches all hosts including web01 -\& sudoHost: ALL -\& sudoHost: !web01 -.Ve -.Sh "Description of sudoRole" -.IX Subsection "Description of sudoRole" -The equivalent of a sudoer in \s-1LDAP\s0 is a 'sudoRole'. It contains -sudoUser(s), sudoHost, sudoCommand and optional sudoOption(s), -sudoRunAsUser(s) and sudoRunAsGroup(s). -.PP -The following example allows users in group wheel to run any command -on any host via \fBsudo\fR: -.PP -.Vb 7 -\& dn: cn=%wheel,ou=SUDOers,dc=example,dc=com -\& objectClass: top -\& objectClass: sudoRole -\& cn: %wheel -\& sudoUser: %wheel -\& sudoHost: ALL -\& sudoCommand: ALL +\& # does not match all but web01 +\& # rather, matches all hosts including web01 +\& sudoHost: ALL +\& sudoHost: !web01 .Ve .Sh "Sudoers Schema" .IX Subsection "Sudoers Schema" -In order to use \fBsudo\fR's \s-1LDAP\s0 support the \fBsudo\fR schema must be -installled on your \s-1LDAP\s0 server. In addition, be sure to index the -attribute 'sudoUser'. +In order to use \fBsudo\fR's \s-1LDAP\s0 support, the \fBsudo\fR schema must be +installed on your \s-1LDAP\s0 server. In addition, be sure to index the +\&'sudoUser' attribute. +.PP +Two versions of the schema, one for OpenLDAP servers (\fIschema.OpenLDAP\fR) +and another for Netscape-derived servers (\fIschema.iPlanet\fR), may +be found in the \fBsudo\fR distribution. .PP -Two versions of the schema, one for OpenLDAP servers and another -for netscape-derived servers, may also be found in the \fBsudo\fR -distribution. The schema for \fBsudo\fR in OpenLDAP form appears -below. +The schema for \fBsudo\fR in OpenLDAP form is included below. .PP .Vb 6 \& attributetype ( 1.3.6.1.4.1.15953.9.1.1 @@ -398,7 +449,7 @@ encryption. If no \fIport\fR is specified, the default is port 389 for \&\f(CW\*(C`ldap://\*(C'\fR or port 636 for \f(CW\*(C`ldaps://\*(C'\fR. If no \fIhostname\fR is specified, \&\fBsudo\fR will connect to \fBlocalhost\fR. Only systems using the OpenSSL libraries support the mixing of \f(CW\*(C`ldap://\*(C'\fR and \f(CW\*(C`ldaps://\*(C'\fR URIs. -The netscape-derived libraries used on most commercial versions of +The Netscape-derived libraries used on most commercial versions of Unix are only capable of supporting one or the other. .IP "\s-1HOST\s0 name[:port] ..." 4 .IX Item "HOST name[:port] ..." @@ -421,14 +472,18 @@ The \fB\s-1BIND_TIMELIMIT\s0\fR parameter specifies the amount of time, in secon to wait while trying to connect to an \s-1LDAP\s0 server. If multiple \fB\s-1URI\s0\fRs or \&\fB\s-1HOST\s0\fRs are specified, this is the amount of time to wait before trying the next one in the list. +.IP "\s-1TIMELIMIT\s0 seconds" 4 +.IX Item "TIMELIMIT seconds" +The \fB\s-1TIMELIMIT\s0\fR parameter specifies the amount of time, in seconds, +to wait for a response to an \s-1LDAP\s0 query. .IP "\s-1SUDOERS_BASE\s0 base" 4 .IX Item "SUDOERS_BASE base" -The base \s-1DN\s0 to use when performing \fBsudo\fR \s-1LDAP\s0 lookups. Typically +The base \s-1DN\s0 to use when performing \fBsudo\fR \s-1LDAP\s0 queries. Typically this is of the form \f(CW\*(C`ou=SUDOers,dc=example,dc=com\*(C'\fR for the domain \&\f(CW\*(C`example.com\*(C'\fR. .IP "\s-1SUDOERS_DEBUG\s0 debug_level" 4 .IX Item "SUDOERS_DEBUG debug_level" -This sets the debug level for \fBsudo\fR \s-1LDAP\s0 lookups. Debuging +This sets the debug level for \fBsudo\fR \s-1LDAP\s0 queries. Debugging information is printed to the standard error. A value of 1 results in a moderate amount of debugging information. A value of 2 shows the results of the matches themselves. This parameter should not @@ -449,7 +504,7 @@ The \fB\s-1BINDPW\s0\fR parameter specifies the password to use when performing .IX Item "ROOTBINDDN DN" The \fB\s-1ROOTBINDDN\s0\fR parameter specifies the identity, in the form of a Distinguished Name (\s-1DN\s0), to use when performing privileged \s-1LDAP\s0 -operations, such as \fIsudoers\fR lookups. The password corresponding +operations, such as \fIsudoers\fR queries. The password corresponding to the identity should be stored in If not specified, the \fB\s-1BINDDN\s0\fR identity is used (if any). .IP "\s-1LDAP_VERSION\s0 number" 4 @@ -477,43 +532,102 @@ certificated to be verified. If the server's \s-1TLS\s0 certificate cannot be verified (usually because it is signed by an unknown certificate authority), \fBsudo\fR will be unable to connect to it. If \fB\s-1TLS_CHECKPEER\s0\fR is disabled, no check is made. -.IP "\s-1TLS_CACERTFILE\s0" 4 -.IX Item "TLS_CACERTFILE" -.PD 0 -.IP "\s-1TLS_CACERTDIR\s0" 4 -.IX Item "TLS_CACERTDIR" -.IP "\s-1TLS_RANDFILE\s0" 4 -.IX Item "TLS_RANDFILE" -.IP "\s-1TLS_CIPHERS\s0" 4 -.IX Item "TLS_CIPHERS" -.IP "\s-1TLS_CERT\s0" 4 -.IX Item "TLS_CERT" -.IP "\s-1TLS_KEY\s0" 4 -.IX Item "TLS_KEY" -.IP "\s-1USE_SASL\s0" 4 -.IX Item "USE_SASL" -.IP "\s-1SASL_AUTH_ID\s0" 4 -.IX Item "SASL_AUTH_ID" -.IP "\s-1ROOTUSE_SASL\s0" 4 -.IX Item "ROOTUSE_SASL" -.IP "\s-1ROOTSASL_AUTH_ID\s0" 4 -.IX Item "ROOTSASL_AUTH_ID" -.IP "\s-1SASL_SECPROPS\s0" 4 -.IX Item "SASL_SECPROPS" -.IP "\s-1KRB5_CCNAME\s0" 4 -.IX Item "KRB5_CCNAME" -.PD +.IP "\s-1TLS_CACERTFILE\s0 file name" 4 +.IX Item "TLS_CACERTFILE file name" +The path to a certificate authority bundle which contains the certificates +for all the Certificate Authorities the client knows to be valid, +e.g. \fI/etc/ssl/ca\-bundle.pem\fR. +This option is only supported by the OpenLDAP libraries. +.IP "\s-1TLS_CACERTDIR\s0 directory" 4 +.IX Item "TLS_CACERTDIR directory" +Similar to \fB\s-1TLS_CACERTFILE\s0\fR but instead of a file, it is a +directory containing individual Certificate Authority certificates, +e.g. \fI/etc/ssl/certs\fR. +The directory specified by \fB\s-1TLS_CACERTDIR\s0\fR is checked after +\&\fB\s-1TLS_CACERTFILE\s0\fR. +This option is only supported by the OpenLDAP libraries. +.IP "\s-1TLS_CERT\s0 file name" 4 +.IX Item "TLS_CERT file name" +The path to a file containing the client certificate which can +be used to authenticate the client to the \s-1LDAP\s0 server. +.RS 4 +.IP "OpenLDAP" 18 +.IX Item "OpenLDAP" +\&\f(CW\*(C`tls_cert /etc/ssl/client_cert.pem\*(C'\fR +.IP "Netscape-derived" 18 +.IX Item "Netscape-derived" +\&\f(CW\*(C`tls_cert /var/ldap/cert7.db\*(C'\fR +.RE +.RS 4 +.Sp +When using Netscape-derived libraries, this file may also contain +Certificate Authority certificates. +.RE +.IP "\s-1TLS_KEY\s0 file name" 4 +.IX Item "TLS_KEY file name" +The path to a file containing the private key which matches the +certificate specified by \fB\s-1TLS_CERT\s0\fR. The private key must not be +password\-protected. +.RS 4 +.IP "OpenLDAP" 18 +.IX Item "OpenLDAP" +\&\f(CW\*(C`tls_cert /etc/ssl/client_key.pem\*(C'\fR +.IP "Netscape-derived" 18 +.IX Item "Netscape-derived" +\&\f(CW\*(C`tls_cert /var/ldap/key3.db\*(C'\fR +.RE +.RS 4 +.RE +.IP "\s-1TLS_RANDFILE\s0 file name" 4 +.IX Item "TLS_RANDFILE file name" +The \fB\s-1TLS_RANDFILE\s0\fR parameter specifies the path to an entropy +source for systems that lack a random device. It is generally used +in conjunction with \fIprngd\fR or \fIegd\fR. +This option is only supported by the OpenLDAP libraries. +.IP "\s-1TLS_CIPHERS\s0 cipher list" 4 +.IX Item "TLS_CIPHERS cipher list" +The \fB\s-1TLS_CIPHERS\s0\fR parameter allows the administer to restrict +which encryption algorithms may be used for \s-1TLS\s0 (\s-1SSL\s0) connections. +See the OpenSSL manual for a list of valid ciphers. +This option is only supported by the OpenLDAP libraries. +.IP "\s-1USE_SASL\s0 on/true/yes/off/false/no" 4 +.IX Item "USE_SASL on/true/yes/off/false/no" +Enable \fB\s-1USE_SASL\s0\fR for \s-1LDAP\s0 servers that support \s-1SASL\s0 authentication. +.IP "\s-1SASL_AUTH_ID\s0 identity" 4 +.IX Item "SASL_AUTH_ID identity" +The \s-1SASL\s0 user name to use when connecting to the \s-1LDAP\s0 server. +By default, \fBsudo\fR will use an anonymous connection. +.IP "\s-1ROOTUSE_SASL\s0 on/true/yes/off/false/no" 4 +.IX Item "ROOTUSE_SASL on/true/yes/off/false/no" +Enable \fB\s-1ROOTUSE_SASL\s0\fR to enable \s-1SASL\s0 authentication when connecting +to an \s-1LDAP\s0 server from a privileged process, such as \fBsudo\fR. +.IP "\s-1ROOTSASL_AUTH_ID\s0 identity" 4 +.IX Item "ROOTSASL_AUTH_ID identity" +The \s-1SASL\s0 user name to use when \fB\s-1ROOTUSE_SASL\s0\fR is enabled. +.IP "\s-1SASL_SECPROPS\s0 none/properties" 4 +.IX Item "SASL_SECPROPS none/properties" +\&\s-1SASL\s0 security properties or \fInone\fR for no properties. See the +\&\s-1SASL\s0 programmer's manual for details. +.IP "\s-1KRB5_CCNAME\s0 file name" 4 +.IX Item "KRB5_CCNAME file name" +The path to the Kerberos 5 credential cache to use when authenticating +with the remote server. +.PP +See the \f(CW\*(C`ldap.conf\*(C'\fR entry in the \s-1EXAMPLES\s0 section. .Sh "Configuring nsswitch.conf" .IX Subsection "Configuring nsswitch.conf" Sudo consults the Name Service Switch file, \fI/etc/nsswitch.conf\fR, to specify the \fIsudoers\fR search order. Sudo looks for a line -begining with \f(CW\*(C`sudoers:\*(C'\fR and uses this to determine the search +beginning with \f(CW\*(C`sudoers:\*(C'\fR and uses this to determine the search order. Note that \fBsudo\fR does not stop searching after the first match and later matches take precedence over earlier ones. .PP -The following sources are recognized. - files read sudoers from a file (usually \fI/etc/sudoers\fR) - ldap read sudoers from \s-1LDAP\s0 +The following sources are recognized: +.PP +.Vb 2 +\& files read sudoers from a file (usually F) +\& ldap read sudoers from LDAP +.Ve .PP In addition, the entry \f(CW\*(C`[NOTFOUND=return]\*(C'\fR will short-circuit the search if the user was not found in the preceding source. @@ -537,6 +651,9 @@ sudoers line, the following default is assumed: .Vb 1 \& sudoers: files .Ve +.PP +Note that \fI/etc/nsswitch.conf\fR is supported even when the underlying +operating system does not use an nsswitch.conf file. .SH "FILES" .IX Header "FILES" .IP "\fI/etc/ldap.conf\fR" 24 @@ -547,11 +664,109 @@ sudoers line, the following default is assumed: determines sudoers source order .SH "EXAMPLES" .IX Header "EXAMPLES" -Example entries -.PP -Example ldap.conf -.PP -Debugging info +.Sh "\s-1XXX\s0 nsswitch.conf example?" +.IX Subsection "XXX nsswitch.conf example?" +.Sh "\s-1XXX\s0 sudoers ldif example?" +.IX Subsection "XXX sudoers ldif example?" +.Sh "Example ldap.conf" +.IX Subsection "Example ldap.conf" +.Vb 95 +\& # Either specify one or more URIs or one or more host:port pairs. +\& # If neither is specified sudo will default to localhost, port 389. +\& # +\& #host ldapserver +\& #host ldapserver1 ldapserver2:390 +\& # +\& # Default port if host is specified without one, defaults to 389. +\& #port 389 +\& # +\& # URI will override the host and port settings. +\& uri ldap://ldapserver +\& #uri ldaps://secureldapserver +\& #uri ldaps://secureldapserver ldap://ldapserver +\& # +\& # The amount of time, in seconds, to wait while trying to connect to +\& # an LDAP server. +\& bind_timelimit 30 +\& # +\& # The amount of time, in seconds, to wait while performing an LDAP query. +\& timelimit 30 +\& # +\& # must be set or sudo will ignore LDAP +\& sudoers_base ou=SUDOers,dc=example,dc=com +\& # +\& # verbose sudoers matching from ldap +\& #sudoers_debug 2 +\& # +\& # optional proxy credentials +\& #binddn +\& #bindpw +\& #rootbinddn +\& # +\& # LDAP protocol version, defaults to 3 +\& #ldap_version 3 +\& # +\& # Define if you want to use an encrypted LDAP connection. +\& # Typically, you must also set the port to 636 (ldaps). +\& #ssl on +\& # +\& # Define if you want to use port 389 and switch to +\& # encryption before the bind credentials are sent. +\& # Only supported by LDAP servers that support the start_tls +\& # extension such as OpenLDAP. +\& #ssl start_tls +\& # +\& # Additional TLS options follow that allow tweaking of the +\& # SSL/TLS connection. +\& # +\& #tls_checkpeer yes # verify server SSL certificate +\& #tls_checkpeer no # ignore server SSL certificate +\& # +\& # If you enable tls_checkpeer, specify either tls_cacertfile +\& # or tls_cacertdir. Only supported when using OpenLDAP. +\& # +\& #tls_cacertfile /etc/certs/trusted_signers.pem +\& #tls_cacertdir /etc/certs +\& # +\& # For systems that don't have /dev/random +\& # use this along with PRNGD or EGD.pl to seed the +\& # random number pool to generate cryptographic session keys. +\& # Only supported when using OpenLDAP. +\& # +\& #tls_randfile /etc/egd-pool +\& # +\& # You may restrict which ciphers are used. Consult your SSL +\& # documentation for which options go here. +\& # Only supported when using OpenLDAP. +\& # +\& #tls_ciphers +\& # +\& # Sudo can provide a client certificate when communicating to +\& # the LDAP server. +\& # Tips: +\& # * Enable both lines at the same time. +\& # * Do not password protect the key file. +\& # * Ensure the keyfile is only readable by root. +\& # +\& # For OpenLDAP: +\& #tls_cert /etc/certs/client_cert.pem +\& #tls_key /etc/certs/client_key.pem +\& # +\& # For SunONE or iPlanet LDAP, the file specified by tls_cert may +\& # contain CA certs and/or the client's cert. If the client's +\& # cert is included, tls_key should be specified as well. +\& # For backward compatibility, sslpath may be used in place of tls_cert. +\& #tls_cert /var/ldap/cert7.db +\& #tls_key /var/ldap/key3.db +\& # +\& # If using SASL authentication for LDAP (OpenSSL) +\& # use_sasl yes +\& # sasl_auth_id +\& # rootuse_sasl yes +\& # rootsasl_auth_id +\& # sasl_secprops none +\& # krb5_ccname /etc/.ldapcache +.Ve .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fIldap.conf\fR\|(4), \fIsudoers\fR\|(4) diff --git a/sudoers.ldap.pod b/sudoers.ldap.pod index cbff8de19..f26dfe7ac 100644 --- a/sudoers.ldap.pod +++ b/sudoers.ldap.pod @@ -25,7 +25,7 @@ sudoers.ldap - sudo LDAP configuration =head1 DESCRIPTION In addition to the standard I file, B may be configured -via LAP. This can be especially useful for syncronizing I +via LAP. This can be especially useful for synchronizing I in a large, distributed environment. Using LDAP for I has several benefits: @@ -98,6 +98,81 @@ they can all just be pasted into the LDAP record. =back +=head2 SUDOers LDAP container + +The I configuration is contained in the C LDAP +container. + +Sudo first looks for the C entry in the SUDOers container. +If found, the multi-valued C attribute is parsed in the +same manner as a global C line in F. In +the following example, the C variable will be preserved +in the environment for all users. + + dn: cn=defaults,ou=SUDOers,dc=example,dc=com + objectClass: top + objectClass: sudoRole + cn: defaults + description: Default sudoOption's go here + sudoOption: env_keep+=SSH_AUTH_SOCK + +The equivalent of a sudoer in LDAP is a C. It consists of +the following components: + +=over 4 + +=item sudoUser + +A user name, uid (prefixed with C<'#'>), Unix group (prefixed with +a C<'%'>) or user netgroup (prefixed with a C<'+'>). + +=item sudoHost + +A host name, IP address, IP network, or host netgroup (prefixed +with a C<'+'>). +The special value C will match any host. + +=item sudoCommand + +A Unix command with optional command line arguments, potentially +including globbing characters (aka wild cards). +The special value C will match any command. + +=item sudoOption + +Similar to the global options described above, but specific to the +C in which it resides. + +=item sudoRunAsUser + +A user name or uid (prefixed with C<'#'>) that commands may be run +as or a Unix group (prefixed with a C<'%'>) or user netgroup (prefixed +with a C<'+'>) that contains a list of users that commands may be +run as. +The special value C will match any user. + +=item sudoRunAsGroup + +A Unix group or gid (prefixed with C<'#'>) that commands may be run as. +The special value C will match any group. + +=back + +Each entry listed above contains a single value, but may be repeated +multiple times. A sudoRole must contain at least one C, +C and C. + +The following example allows users in group wheel to run any command +on any host via B: + + dn: cn=%wheel,ou=SUDOers,dc=example,dc=com + objectClass: top + objectClass: sudoRole + cn: %wheel + sudoUser: %wheel + sudoHost: ALL + sudoCommand: ALL + =head2 Differences between LDAP and non-LDAP sudoers There are some subtle differences in the way sudoers is handled @@ -109,80 +184,64 @@ called paranoid behavior (not necessarily the most specific match). Here is an example: - # /etc/sudoers: - # Allow all commands except shell - johnny ALL=(root) ALL,!/bin/sh - # Always allows all commands because ALL is matched last - puddles ALL=(root) !/bin/sh,ALL - - # LDAP equivalent of Johnny - # Allows all commands except shell - dn: cn=role1,ou=Sudoers,dc=my-domain,dc=com - objectClass: sudoRole - objectClass: top - cn: role1 - sudoUser: johnny - sudoHost: ALL - sudoCommand: ALL - sudoCommand: !/bin/sh - - # LDAP equivalent of Puddles - # Notice that even though ALL comes last, it still behaves like - # role1 since the LDAP code assumes the more paranoid configuration - dn: cn=role2,ou=Sudoers,dc=my-domain,dc=com - objectClass: sudoRole - objectClass: top - cn: role2 - sudoUser: puddles - sudoHost: ALL - sudoCommand: !/bin/sh - sudoCommand: ALL + # /etc/sudoers: + # Allow all commands except shell + johnny ALL=(root) ALL,!/bin/sh + # Always allows all commands because ALL is matched last + puddles ALL=(root) !/bin/sh,ALL + + # LDAP equivalent of Johnny + # Allows all commands except shell + dn: cn=role1,ou=Sudoers,dc=my-domain,dc=com + objectClass: sudoRole + objectClass: top + cn: role1 + sudoUser: johnny + sudoHost: ALL + sudoCommand: ALL + sudoCommand: !/bin/sh + + # LDAP equivalent of Puddles + # Notice that even though ALL comes last, it still behaves like + # role1 since the LDAP code assumes the more paranoid configuration + dn: cn=role2,ou=Sudoers,dc=my-domain,dc=com + objectClass: sudoRole + objectClass: top + cn: role2 + sudoUser: puddles + sudoHost: ALL + sudoCommand: !/bin/sh + sudoCommand: ALL Another difference is that negations on the Host, User or Runas are currently ignorred. For example, the following attributes do not do what they might appear to do. - # does not match all but joe - # rather, does not match anyone - sudoUser: !joe + # does not match all but joe + # rather, does not match anyone + sudoUser: !joe - # does not match all but joe - # rather, matches everyone including Joe - sudoUser: ALL - sudoUser: !joe + # does not match all but joe + # rather, matches everyone including Joe + sudoUser: ALL + sudoUser: !joe - # does not match all but web01 - # rather, matches all hosts including web01 - sudoHost: ALL - sudoHost: !web01 - -=head2 Description of sudoRole - -The equivalent of a sudoer in LDAP is a 'sudoRole'. It contains -sudoUser(s), sudoHost, sudoCommand and optional sudoOption(s), -sudoRunAsUser(s) and sudoRunAsGroup(s). - -The following example allows users in group wheel to run any command -on any host via B: - - dn: cn=%wheel,ou=SUDOers,dc=example,dc=com - objectClass: top - objectClass: sudoRole - cn: %wheel - sudoUser: %wheel - sudoHost: ALL - sudoCommand: ALL + # does not match all but web01 + # rather, matches all hosts including web01 + sudoHost: ALL + sudoHost: !web01 =head2 Sudoers Schema -In order to use B's LDAP support the B schema must be -installled on your LDAP server. In addition, be sure to index the -attribute 'sudoUser'. +In order to use B's LDAP support, the B schema must be +installed on your LDAP server. In addition, be sure to index the +'sudoUser' attribute. -Two versions of the schema, one for OpenLDAP servers and another -for netscape-derived servers, may also be found in the B -distribution. The schema for B in OpenLDAP form appears -below. +Two versions of the schema, one for OpenLDAP servers (F) +and another for Netscape-derived servers (F), may +be found in the B distribution. + +The schema for B in OpenLDAP form is included below. attributetype ( 1.3.6.1.4.1.15953.9.1.1 NAME 'sudoUser' @@ -262,7 +321,7 @@ encryption. If no I is specified, the default is port 389 for C or port 636 for C. If no I is specified, B will connect to B. Only systems using the OpenSSL libraries support the mixing of C and C URIs. -The netscape-derived libraries used on most commercial versions of +The Netscape-derived libraries used on most commercial versions of Unix are only capable of supporting one or the other. =item HOST name[:port] ... @@ -289,15 +348,20 @@ to wait while trying to connect to an LDAP server. If multiple Bs or Bs are specified, this is the amount of time to wait before trying the next one in the list. +=item TIMELIMIT seconds + +The B parameter specifies the amount of time, in seconds, +to wait for a response to an LDAP query. + =item SUDOERS_BASE base -The base DN to use when performing B LDAP lookups. Typically +The base DN to use when performing B LDAP queries. Typically this is of the form C for the domain C. =item SUDOERS_DEBUG debug_level -This sets the debug level for B LDAP lookups. Debuging +This sets the debug level for B LDAP queries. Debugging information is printed to the standard error. A value of 1 results in a moderate amount of debugging information. A value of 2 shows the results of the matches themselves. This parameter should not @@ -321,7 +385,7 @@ B parameter. The B parameter specifies the identity, in the form of a Distinguished Name (DN), to use when performing privileged LDAP -operations, such as I lookups. The password corresponding +operations, such as I queries. The password corresponding to the identity should be stored in If not specified, the B identity is used (if any). @@ -354,41 +418,116 @@ be verified (usually because it is signed by an unknown certificate authority), B will be unable to connect to it. If B is disabled, no check is made. -=item TLS_CACERTFILE +=item TLS_CACERTFILE file name + +The path to a certificate authority bundle which contains the certificates +for all the Certificate Authorities the client knows to be valid, +e.g. F. +This option is only supported by the OpenLDAP libraries. + +=item TLS_CACERTDIR directory + +Similar to B but instead of a file, it is a +directory containing individual Certificate Authority certificates, +e.g. F. +The directory specified by B is checked after +B. +This option is only supported by the OpenLDAP libraries. + +=item TLS_CERT file name -=item TLS_CACERTDIR +The path to a file containing the client certificate which can +be used to authenticate the client to the LDAP server. -=item TLS_RANDFILE +=over 18 -=item TLS_CIPHERS +=item OpenLDAP -=item TLS_CERT +C + +=item Netscape-derived + +C + +=back -=item TLS_KEY +When using Netscape-derived libraries, this file may also contain +Certificate Authority certificates. -=item USE_SASL +=item TLS_KEY file name -=item SASL_AUTH_ID +The path to a file containing the private key which matches the +certificate specified by B. The private key must not be +password-protected. -=item ROOTUSE_SASL +=over 18 -=item ROOTSASL_AUTH_ID +=item OpenLDAP -=item SASL_SECPROPS +C -=item KRB5_CCNAME +=item Netscape-derived + +C =back +=item TLS_RANDFILE file name + +The B parameter specifies the path to an entropy +source for systems that lack a random device. It is generally used +in conjunction with I or I. +This option is only supported by the OpenLDAP libraries. + +=item TLS_CIPHERS cipher list + +The B parameter allows the administer to restrict +which encryption algorithms may be used for TLS (SSL) connections. +See the OpenSSL manual for a list of valid ciphers. +This option is only supported by the OpenLDAP libraries. + +=item USE_SASL on/true/yes/off/false/no + +Enable B for LDAP servers that support SASL authentication. + +=item SASL_AUTH_ID identity + +The SASL user name to use when connecting to the LDAP server. +By default, B will use an anonymous connection. + +=item ROOTUSE_SASL on/true/yes/off/false/no + +Enable B to enable SASL authentication when connecting +to an LDAP server from a privileged process, such as B. + +=item ROOTSASL_AUTH_ID identity + +The SASL user name to use when B is enabled. + +=item SASL_SECPROPS none/properties + +SASL security properties or I for no properties. See the +SASL programmer's manual for details. + +=item KRB5_CCNAME file name + +The path to the Kerberos 5 credential cache to use when authenticating +with the remote server. + +=back + +See the C entry in the L section. + =head2 Configuring nsswitch.conf Sudo consults the Name Service Switch file, F, to specify the I search order. Sudo looks for a line -begining with C and uses this to determine the search +beginning with C and uses this to determine the search order. Note that B does not stop searching after the first match and later matches take precedence over earlier ones. -The following sources are recognized. +The following sources are recognized: + files read sudoers from a file (usually F) ldap read sudoers from LDAP @@ -409,6 +548,9 @@ sudoers line, the following default is assumed: sudoers: files +Note that F is supported even when the underlying +operating system does not use an nsswitch.conf file. + =head1 FILES =over 24 @@ -425,11 +567,107 @@ determines sudoers source order =head1 EXAMPLES -Example entries - -Example ldap.conf - -Debugging info +=head2 XXX nsswitch.conf example? + +=head2 XXX sudoers ldif example? + +=head2 Example ldap.conf + + # Either specify one or more URIs or one or more host:port pairs. + # If neither is specified sudo will default to localhost, port 389. + # + #host ldapserver + #host ldapserver1 ldapserver2:390 + # + # Default port if host is specified without one, defaults to 389. + #port 389 + # + # URI will override the host and port settings. + uri ldap://ldapserver + #uri ldaps://secureldapserver + #uri ldaps://secureldapserver ldap://ldapserver + # + # The amount of time, in seconds, to wait while trying to connect to + # an LDAP server. + bind_timelimit 30 + # + # The amount of time, in seconds, to wait while performing an LDAP query. + timelimit 30 + # + # must be set or sudo will ignore LDAP + sudoers_base ou=SUDOers,dc=example,dc=com + # + # verbose sudoers matching from ldap + #sudoers_debug 2 + # + # optional proxy credentials + #binddn + #bindpw + #rootbinddn + # + # LDAP protocol version, defaults to 3 + #ldap_version 3 + # + # Define if you want to use an encrypted LDAP connection. + # Typically, you must also set the port to 636 (ldaps). + #ssl on + # + # Define if you want to use port 389 and switch to + # encryption before the bind credentials are sent. + # Only supported by LDAP servers that support the start_tls + # extension such as OpenLDAP. + #ssl start_tls + # + # Additional TLS options follow that allow tweaking of the + # SSL/TLS connection. + # + #tls_checkpeer yes # verify server SSL certificate + #tls_checkpeer no # ignore server SSL certificate + # + # If you enable tls_checkpeer, specify either tls_cacertfile + # or tls_cacertdir. Only supported when using OpenLDAP. + # + #tls_cacertfile /etc/certs/trusted_signers.pem + #tls_cacertdir /etc/certs + # + # For systems that don't have /dev/random + # use this along with PRNGD or EGD.pl to seed the + # random number pool to generate cryptographic session keys. + # Only supported when using OpenLDAP. + # + #tls_randfile /etc/egd-pool + # + # You may restrict which ciphers are used. Consult your SSL + # documentation for which options go here. + # Only supported when using OpenLDAP. + # + #tls_ciphers + # + # Sudo can provide a client certificate when communicating to + # the LDAP server. + # Tips: + # * Enable both lines at the same time. + # * Do not password protect the key file. + # * Ensure the keyfile is only readable by root. + # + # For OpenLDAP: + #tls_cert /etc/certs/client_cert.pem + #tls_key /etc/certs/client_key.pem + # + # For SunONE or iPlanet LDAP, the file specified by tls_cert may + # contain CA certs and/or the client's cert. If the client's + # cert is included, tls_key should be specified as well. + # For backward compatibility, sslpath may be used in place of tls_cert. + #tls_cert /var/ldap/cert7.db + #tls_key /var/ldap/key3.db + # + # If using SASL authentication for LDAP (OpenSSL) + # use_sasl yes + # sasl_auth_id + # rootuse_sasl yes + # rootsasl_auth_id + # sasl_secprops none + # krb5_ccname /etc/.ldapcache =head1 SEE ALSO -- 2.40.0