1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils pam multilib libtool
13 *_beta*|*_rc*) uri_prefix=beta/ ;;
16 DESCRIPTION="Allows users or groups to run commands as other users"
17 HOMEPAGE="https://www.sudo.ws/"
18 SRC_URI="https://www.sudo.ws/sudo/dist/${uri_prefix}${MY_P}.tar.gz
19 ftp://ftp.sudo.ws/pub/sudo/${uri_prefix}${MY_P}.tar.gz"
21 # Basic license is ISC-style as-is, some files are released under
22 # 3-clause BSD license
25 if [[ ${PV} != *_beta* ]] && [[ ${PV} != *_rc* ]] ; then
26 KEYWORDS="alpha amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh sparc x86 ~amd64-fbsd ~x86-fbsd ~sparc-solaris"
28 IUSE="gcrypt ldap nls pam offensive openssl sasl selinux +sendmail skey"
31 gcrypt? ( dev-libs/libgcrypt:= )
32 openssl? ( dev-libs/openssl:0= )
34 sasl? ( dev-libs/cyrus-sasl )
35 skey? ( >=sys-auth/skey-1.1.5-r1 )
37 >=net-nds/openldap-2.1.30-r1
44 selinux? ( sec-policy/selinux-sudo )
45 ldap? ( dev-lang/perl )
46 pam? ( sys-auth/pambase )
47 >=app-misc/editor-wrapper-3
49 sendmail? ( virtual/mta )
56 S="${WORKDIR}/${MY_P}"
72 # FIXME: secure_path is a compile time setting. using ROOTPATH
73 # is not perfect, env-update may invalidate this, but until it
74 # is available as a sudoers setting this will have to do.
75 einfo "Setting secure_path ..."
77 # first extract the default ROOTPATH from build env
78 ROOTPATH=$(unset ROOTPATH; . "${EPREFIX}"/etc/profile.env; echo "${ROOTPATH}")
79 if [[ -z ${ROOTPATH} ]] ; then
80 ewarn " Failed to find ROOTPATH, please report this"
83 # then remove duplicate path entries
85 local newpath thisp IFS=:
87 if [[ :${newpath}: != *:${thisp}:* ]] ; then
90 einfo " Duplicate entry ${thisp} removed..."
95 cleanpath /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin${ROOTPATH:+:${ROOTPATH}}
97 # finally, strip gcc paths #136027
99 local e newpath thisp IFS=:
100 for thisp in ${ROOTPATH} ; do
101 for e ; do [[ $thisp == $e ]] && continue 2 ; done
104 ROOTPATH=${newpath#:}
106 rmpath '*/gcc-bin/*' '*/gnat-gcc-bin/*' '*/gnat-gcc/*'
115 # audit: somebody got to explain me how I can test this before I
116 # enable it.. - Diego
117 # plugindir: autoconf code is crappy and does not delay evaluation
118 # until `make` time, so we have to use a full path here rather than
119 # basing off other values.
122 --with-editor="${EPREFIX}"/usr/libexec/editor
124 --with-plugindir="${EPREFIX}"/usr/$(get_libdir)/sudo
125 --with-rundir="${EPREFIX}"/var/run/sudo
126 --with-secure-path="${ROOTPATH}"
127 --with-vardir="${EPREFIX}"/var/db/sudo
128 --without-linux-audit
132 $(use_enable openssl)
134 $(use_with offensive insults)
135 $(use_with offensive all-insults)
136 $(use_with ldap ldap_conf_file /etc/ldap.conf.sudo)
143 econf "${myeconfargs[@]}"
151 dosbin plugins/sudoers/sudoers2ldif
153 cat <<-EOF > "${T}"/ldap.conf.sudo
154 # See ldap.conf(5) and README.LDAP for details
155 # This file should only be readable by root
157 # supported directives: host, port, ssl, ldap_version
158 # uri, binddn, bindpw, sudoers_base, sudoers_debug
159 # tls_{checkpeer,cacertfile,cacertdir,randfile,ciphers,cert,key}
163 doins "${T}"/ldap.conf.sudo
164 fperms 0440 /etc/ldap.conf.sudo
166 insinto /etc/openldap/schema
167 newins doc/schema.OpenLDAP sudo.schema
170 pamd_mimic system-auth sudo auth account session
172 keepdir /var/db/sudo/lectured
173 fperms 0700 /var/db/sudo/lectured
174 fperms 0711 /var/db/sudo #652958
176 # Don't install into /var/run as that is a tmpfs most of the time
178 rm -rf "${ED}"/var/run
183 local sudo_db="${EROOT}/var/db/sudo"
184 if [[ "$(stat -c %a "${sudo_db}")" -ne 711 ]] ; then
185 chmod 711 "${sudo_db}" || die
190 ewarn "sudo uses the /etc/ldap.conf.sudo file for ldap configuration."
192 if grep -qs '^[[:space:]]*sudoers:' "${ROOT}"/etc/nsswitch.conf ; then
193 ewarn "In 1.7 series, LDAP is no more consulted, unless explicitly"
194 ewarn "configured in /etc/nsswitch.conf."
196 ewarn "To make use of LDAP, add this line to your /etc/nsswitch.conf:"
197 ewarn " sudoers: ldap files"
203 ewarn "To use sudo, you need to change file ownership and permissions"
204 ewarn "with root privileges, as follows:"
206 ewarn " # chown root:root ${EPREFIX}/usr/bin/sudo"
207 ewarn " # chown root:root ${EPREFIX}/usr/lib/sudo/sudoers.so"
208 ewarn " # chown root:root ${EPREFIX}/etc/sudoers"
209 ewarn " # chown root:root ${EPREFIX}/etc/sudoers.d"
210 ewarn " # chown root:root ${EPREFIX}/var/db/sudo"
211 ewarn " # chmod 4111 ${EPREFIX}/usr/bin/sudo"
215 elog "To use the -A (askpass) option, you need to install a compatible"
216 elog "password program from the following list. Starred packages will"
217 elog "automatically register for the use with sudo (but will not force"
218 elog "the -A option):"
220 elog " [*] net-misc/ssh-askpass-fullscreen"
221 elog " net-misc/x11-ssh-askpass"
223 elog "You can override the choice by setting the SUDO_ASKPASS environmnent"
224 elog "variable to the program you want to use."