1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 inherit eutils pam multilib libtool
7 if [[ ${PV} == "9999" ]] ; then
8 EHG_REPO_URI="http://www.sudo.ws/repos/sudo"
17 *_beta*|*_rc*) uri_prefix=beta/ ;;
20 DESCRIPTION="Allows users or groups to run commands as other users"
21 HOMEPAGE="http://www.sudo.ws/"
22 if [[ ${PV} != "9999" ]] ; then
23 SRC_URI="http://www.sudo.ws/sudo/dist/${uri_prefix}${MY_P}.tar.gz
24 ftp://ftp.sudo.ws/pub/sudo/${uri_prefix}${MY_P}.tar.gz"
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 ~sparc-fbsd ~x86-fbsd ~sparc-solaris"
30 # Basic license is ISC-style as-is, some files are released under
31 # 3-clause BSD license
34 IUSE="gcrypt ldap nls openssl offensive pam selinux skey +sendmail"
39 >=net-nds/openldap-2.1.30-r1
42 gcrypt? ( dev-libs/libgcrypt:= )
43 openssl? ( dev-libs/openssl:0= )
45 skey? ( >=sys-auth/skey-1.1.5-r1 )
49 >=app-misc/editor-wrapper-3
51 ldap? ( dev-lang/perl )
52 pam? ( sys-auth/pambase )
53 selinux? ( sec-policy/selinux-sudo )
54 sendmail? ( virtual/mta )
61 S="${WORKDIR}/${MY_P}"
77 # FIXME: secure_path is a compile time setting. using ROOTPATH
78 # is not perfect, env-update may invalidate this, but until it
79 # is available as a sudoers setting this will have to do.
80 einfo "Setting secure_path ..."
82 # first extract the default ROOTPATH from build env
83 ROOTPATH=$(unset ROOTPATH; . "${EPREFIX}"/etc/profile.env; echo "${ROOTPATH}")
84 if [[ -z ${ROOTPATH} ]] ; then
85 ewarn " Failed to find ROOTPATH, please report this"
88 # then remove duplicate path entries
90 local newpath thisp IFS=:
92 if [[ :${newpath}: != *:${thisp}:* ]] ; then
95 einfo " Duplicate entry ${thisp} removed..."
100 cleanpath /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin${ROOTPATH:+:${ROOTPATH}}
102 # finally, strip gcc paths #136027
104 local e newpath thisp IFS=:
105 for thisp in ${ROOTPATH} ; do
106 for e ; do [[ $thisp == $e ]] && continue 2 ; done
109 ROOTPATH=${newpath#:}
111 rmpath '*/gcc-bin/*' '*/gnat-gcc-bin/*' '*/gnat-gcc/*'
120 # audit: somebody got to explain me how I can test this before I
121 # enable it.. - Diego
122 # plugindir: autoconf code is crappy and does not delay evaluation
123 # until `make` time, so we have to use a full path here rather than
124 # basing off other values.
127 --with-editor="${EPREFIX}"/usr/libexec/editor
129 --with-plugindir="${EPREFIX}"/usr/$(get_libdir)/sudo
130 --with-rundir="${EPREFIX}"/var/run/sudo
131 --with-secure-path="${ROOTPATH}"
132 --with-vardir="${EPREFIX}"/var/db/sudo
133 --without-linux-audit
137 $(use_enable openssl)
138 $(use_with offensive insults)
139 $(use_with offensive all-insults)
140 $(use_with ldap ldap_conf_file /etc/ldap.conf.sudo)
147 econf "${myeconfargs[@]}"
155 dosbin plugins/sudoers/sudoers2ldif
157 cat <<-EOF > "${T}"/ldap.conf.sudo
158 # See ldap.conf(5) and README.LDAP for details
159 # This file should only be readable by root
161 # supported directives: host, port, ssl, ldap_version
162 # uri, binddn, bindpw, sudoers_base, sudoers_debug
163 # tls_{checkpeer,cacertfile,cacertdir,randfile,ciphers,cert,key}
167 doins "${T}"/ldap.conf.sudo
168 fperms 0440 /etc/ldap.conf.sudo
170 insinto /etc/openldap/schema
171 newins doc/schema.OpenLDAP sudo.schema
174 pamd_mimic system-auth sudo auth account session
177 fperms 0700 /var/db/sudo
179 # Don't install into /var/run as that is a tmpfs most of the time
181 rm -rf "${D}"/var/run
187 ewarn "sudo uses the /etc/ldap.conf.sudo file for ldap configuration."
189 if grep -qs '^[[:space:]]*sudoers:' "${ROOT}"/etc/nsswitch.conf ; then
190 ewarn "In 1.7 series, LDAP is no more consulted, unless explicitly"
191 ewarn "configured in /etc/nsswitch.conf."
193 ewarn "To make use of LDAP, add this line to your /etc/nsswitch.conf:"
194 ewarn " sudoers: ldap files"
200 ewarn "To use sudo, you need to change file ownership and permissions"
201 ewarn "with root privileges, as follows:"
203 ewarn " # chown root:root ${EPREFIX}/usr/bin/sudo"
204 ewarn " # chown root:root ${EPREFIX}/usr/lib/sudo/sudoers.so"
205 ewarn " # chown root:root ${EPREFIX}/etc/sudoers"
206 ewarn " # chown root:root ${EPREFIX}/etc/sudoers.d"
207 ewarn " # chown root:root ${EPREFIX}/var/db/sudo"
208 ewarn " # chmod 4111 ${EPREFIX}/usr/bin/sudo"
212 elog "To use the -A (askpass) option, you need to install a compatible"
213 elog "password program from the following list. Starred packages will"
214 elog "automatically register for the use with sudo (but will not force"
215 elog "the -A option):"
217 elog " [*] net-misc/ssh-askpass-fullscreen"
218 elog " net-misc/x11-ssh-askpass"
220 elog "You can override the choice by setting the SUDO_ASKPASS environmnent"
221 elog "variable to the program you want to use."