sudoRole. Instead of defining a Cmnd_Alias that is referenced by multiple users, one can create a
sudoRolethat contains the commands and assign multiple users to it.
ou=SUDOersLDAP container. Sudo first looks for the
cn=defaultentry in the SUDOers container. If found, the multi-valued
sudoOptionattribute is parsed in the same manner as a global
Defaultsline in /etc/sudoers. In the following example, the
SSH_AUTH_SOCKvariable 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
sudoRole. It consists of the following attributes:
#’), Unix group (prefixed with ‘
%’), Unix group ID (prefixed with ‘
%#’), or user netgroup (prefixed with ‘
+’). The special value
ALLwill match any host.
ALLwill match any command. If a command is prefixed with an exclamation point ‘
!’, the user will be prohibited from running that command.
sudoRolein which it resides.
#’) 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 special value
ALLwill match any user. The
sudoRunAsUserattribute is only available in sudo versions 1.7.0 and higher. Older versions of sudo use the
#’) that commands may be run as. The special value
ALLwill match any group. The
sudoRunAsGroupattribute is only available in sudo versions 1.7.0 and higher.
yyyymmddHHMMSSZthat can be used to provide a start date/time for when the
sudoRolewill be valid. If multiple
sudoNotBeforeentries are present, the earliest is used. Note that timestamps must be in Coordinated Universal Time (UTC), not the local timezone. The minute and seconds portions are optional, but some LDAP servers require that they be present (contrary to the RFC). The
sudoNotBeforeattribute is only available in sudo versions 1.7.5 and higher and must be explicitly enabled via the SUDOERS_TIMED option in /etc/ldap.conf.
yyyymmddHHMMSSZthat indicates an expiration date/time, after which the
sudoRolewill no longer be valid. If multiple
sudoNotBeforeentries are present, the last one is used. Note that timestamps must be in Coordinated Universal Time (UTC), not the local timezone. The minute and seconds portions are optional, but some LDAP servers require that they be present (contrary to the RFC). The
sudoNotAfterattribute is only available in sudo versions 1.7.5 and higher and must be explicitly enabled via the SUDOERS_TIMED option in /etc/ldap.conf.
sudoRoleentries retrieved from the LDAP directory have no inherent order. The
sudoOrderattribute is an integer (or floating point value for LDAP servers that support it) that is used to sort the matching entries. This allows LDAP-based sudoers entries to more closely mimic the behaviour of the sudoers file, where the of the entries influences the result. If multiple entries match, the entry with the highest
sudoOrderattribute is chosen. This corresponds to the “last match” behavior of the sudoers file. If the
sudoOrderattribute is not present, a value of 0 is assumed. The
sudoOrderattribute is only available in sudo versions 1.7.5 and higher.
sudoRolemust contain at least one
sudoCommand. The following example allows users in group wheel to run any command on any host via sudo:
dn: cn=%wheel,ou=SUDOers,dc=example,dc=com objectClass: top objectClass: sudoRole cn: %wheel sudoUser: %wheel sudoHost: ALL sudoCommand: ALL
ALLtag is matched in this query too.) If no match is returned for the user's name and groups, a third query returns all entries containing user netgroups and checks to see if the user belongs to any of them. If timed entries are enabled with the SUDOERS_TIMED configuration directive, the LDAP queries include a subfilter that limits retrieval to entries that satisfy the time constraints, if any.
sudoOrderattribute, but there is no way to guarantee the order of attributes within a specific entry. If there are conflicting command rules in an entry, the negative takes precedence. This is 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
# 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 web01 # rather, matches all hosts including web01 sudoHost: ALL sudoHost: !web01
sudoUserattribute. Three versions of the schema: one for OpenLDAP servers (schema.OpenLDAP), one for Netscape-derived servers (schema.iPlanet), and one for Microsoft Active Directory (schema.ActiveDirectory) may be found in the sudo distribution. The schema for sudo in OpenLDAP form is also included in the EXAMPLES section. -specific. Note that sudo parses /etc/ldap.conf itself and may support options that differ from those described in the system's ldap.conf(8) manual. Also note that on systems using the OpenLDAP libraries, default values specified in /etc/openldap/ldap.conf or the user's .ldaprc files are not used. Only those options explicitly listed in /etc/ldap.conf as being supported by sudo are honored. Configuration options are listed below in upper case but are parsed in a case-independent manner.
ldap://or port 636 for
ldaps://. If no hostname is specified, sudo will connect to localhost. Multiple URI lines are treated identically to a URI line containing multiple entries. Only systems using the OpenSSL libraries support the mixing of
ldaps://URIs. Both the Netscape-derived and Tivoli LDAP libraries used on most commercial versions of Unix are only capable of supporting one or the other.
:’). The HOST parameter is deprecated in favor of the URI specification and is included for backwards compatibility.
ou=SUDOers,dc=example,dc=comfor the domain
example.com. Multiple SUDOERS_BASE lines may be specified, in which case they are queried in the order specified.
sudoNotAfterattributes that implement time-dependent sudoers entries.
yes, TLS (SSL) encryption is always used when communicating with the LDAP server. Typically, this involves connecting to the server on port 636 (ldaps).
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 dedicated port for encrypted communications. This parameter is only supported by LDAP servers that honor the start_tls extension, such as the OpenLDAP and Tivoli Directory servers.
.sthfile extension instead of
ldapkey.sth. The default
ldapkey.kdbthat ships with Tivoli Directory Server is encrypted with the password
ssl_password. This option is only supported by the Tivoli LDAP libraries.
sudoers: and uses this to determine the search order. Note that sudo does not stop searching after the first match and later matches take precedence over earlier ones. The following sources are recognized:
[NOTFOUND=return]will short-circuit the search if the user was not found in the preceding source. To consult LDAP first followed by the local sudoers file (if it exists), use:
sudoers: ldap files
sudoers = ldap, files
sudoers = ldap
sudoers = ldap = auth, files
authqualfier only affects user lookups; both LDAP and sudoers will be queried for
Defaultsentries. If the /etc/netsvc.conf file is not present or there is no sudoers line, the following default is assumed:
sudoers = files
# 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; may be specified multiple times. sudoers_base ou=SUDOers,dc=example,dc=com # # verbose sudoers matching from ldap #sudoers_debug 2 # # Enable support for time-based entries in sudoers. #sudoers_timed yes # # optional proxy credentials #binddn <who to search as> #bindpw <password> #rootbinddn <who to search as, uses /etc/ldap.secret for bindpw> # # 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 <cipher-list> # # 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, tls_cert and tls_key may specify either # a directory, in which case the files in the directory must have the # default names (e.g. cert8.db and key4.db), or the path to the cert # and key files themselves. However, a bug in version 5.0 of the LDAP # SDK will prevent specific file names from working. For this reason # it is suggested that tls_cert and tls_key be set to a directory, # not a file name. # # The certificate database 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 #tls_key /var/ldap # # If using SASL authentication for LDAP (OpenSSL) # use_sasl yes # sasl_auth_id <SASL user name> # rootuse_sasl yes # rootsasl_auth_id <SASL user name for root access> # sasl_secprops none # krb5_ccname /etc/.ldapcache
includeline in slapd.conf and restart slapd.
attributetype ( 184.108.40.206.4.1.159220.127.116.11 NAME 'sudoUser' DESC 'User(s) who may run sudo' EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 18.104.22.168.4.1.1422.214.171.124.26 ) attributetype ( 126.96.36.199.4.1.159188.8.131.52 NAME 'sudoHost' DESC 'Host(s) who may run sudo' EQUALITY caseExactIA5Match SUBSTR caseExactIA5SubstringsMatch SYNTAX 184.108.40.206.4.1.14220.127.116.11.26 ) attributetype ( 18.104.22.168.4.1.15922.214.171.124 NAME 'sudoCommand' DESC 'Command(s) to be executed by sudo' EQUALITY caseExactIA5Match SYNTAX 126.96.36.199.4.1.14188.8.131.52.26 ) attributetype ( 184.108.40.206.4.1.159220.127.116.11 NAME 'sudoRunAs' DESC 'User(s) impersonated by sudo' EQUALITY caseExactIA5Match SYNTAX 18.104.22.168.4.1.1422.214.171.124.26 ) attributetype ( 126.96.36.199.4.1.159188.8.131.52 NAME 'sudoOption' DESC 'Options(s) followed by sudo' EQUALITY caseExactIA5Match SYNTAX 184.108.40.206.4.1.14220.127.116.11.26 ) attributetype ( 18.104.22.168.4.1.15922.214.171.124 NAME 'sudoRunAsUser' DESC 'User(s) impersonated by sudo' EQUALITY caseExactIA5Match SYNTAX 126.96.36.199.4.1.14188.8.131.52.26 ) attributetype ( 184.108.40.206.4.1.159220.127.116.11 NAME 'sudoRunAsGroup' DESC 'Group(s) impersonated by sudo' EQUALITY caseExactIA5Match SYNTAX 18.104.22.168.4.1.1422.214.171.124.26 ) attributetype ( 126.96.36.199.4.1.159188.8.131.52 NAME 'sudoNotBefore' DESC 'Start of time interval for which the entry is valid' EQUALITY generalizedTimeMatch ORDERING generalizedTimeOrderingMatch SYNTAX 184.108.40.206.4.1.14220.127.116.11.24 ) attributetype ( 18.104.22.168.4.1.15922.214.171.124 NAME 'sudoNotAfter' DESC 'End of time interval for which the entry is valid' EQUALITY generalizedTimeMatch ORDERING generalizedTimeOrderingMatch SYNTAX 126.96.36.199.4.1.14188.8.131.52.24 ) attributeTypes ( 184.108.40.206.4.1.159220.127.116.11 NAME 'sudoOrder' DESC 'an integer to order the sudoRole entries' EQUALITY integerMatch ORDERING integerOrderingMatch SYNTAX 18.104.22.168.4.1.1422.214.171.124.27 ) objectclass ( 126.96.36.199.4.1.159188.8.131.52 NAME 'sudoRole' SUP top STRUCTURAL DESC 'Sudoer Entries' MUST ( cn ) MAY ( sudoUser $ sudoHost $ sudoCommand $ sudoRunAs $ sudoRunAsUser $ sudoRunAsGroup $ sudoOption $ sudoNotBefore $ sudoNotAfter $ sudoOrder $ description ) )