OLD | NEW |
(Empty) | |
| 1 # Copyright 1999-2010 Gentoo Foundation |
| 2 # Distributed under the terms of the GNU General Public License v2 |
| 3 # $Header: /var/cvsroot/gentoo-x86/app-admin/sudo/sudo-1.7.4_p4.ebuild,v 1.6 201
0/10/24 15:20:02 armin76 Exp $ |
| 4 |
| 5 inherit eutils pam |
| 6 |
| 7 MY_P=${P/_/} |
| 8 MY_P=${MY_P/beta/b} |
| 9 |
| 10 case "${P}" in |
| 11 *_beta* | *_rc*) |
| 12 uri_prefix=beta/ |
| 13 ;; |
| 14 *) |
| 15 uri_prefix="" |
| 16 ;; |
| 17 esac |
| 18 |
| 19 DESCRIPTION="Allows users or groups to run commands as other users" |
| 20 HOMEPAGE="http://www.sudo.ws/" |
| 21 SRC_URI="http://www.sudo.ws/sudo/dist/${uri_prefix}${MY_P}.tar.gz |
| 22 ftp://ftp.sudo.ws/pub/sudo/${uri_prefix}${MY_P}.tar.gz" |
| 23 |
| 24 # Basic license is ISC-style as-is, some files are released under |
| 25 # 3-clause BSD license |
| 26 LICENSE="as-is BSD" |
| 27 |
| 28 SLOT="0" |
| 29 KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ~ppc64 s390 sh sparc x86 ~spa
rc-fbsd ~x86-fbsd" |
| 30 IUSE="pam skey offensive ldap selinux" |
| 31 |
| 32 DEPEND="pam? ( virtual/pam ) |
| 33 ldap? ( |
| 34 >=net-nds/openldap-2.1.30-r1 |
| 35 dev-libs/cyrus-sasl |
| 36 ) |
| 37 !pam? ( skey? ( >=sys-auth/skey-1.1.5-r1 ) ) |
| 38 app-editors/gentoo-editor |
| 39 virtual/editor |
| 40 virtual/mta" |
| 41 RDEPEND="selinux? ( sec-policy/selinux-sudo ) |
| 42 ldap? ( dev-lang/perl ) |
| 43 pam? ( sys-auth/pambase ) |
| 44 ${DEPEND}" |
| 45 DEPEND="${DEPEND} |
| 46 sys-devel/bison" |
| 47 |
| 48 S=${WORKDIR}/${MY_P} |
| 49 |
| 50 pkg_setup() { |
| 51 if use pam && use skey; then |
| 52 ewarn "You cannot enable both S/KEY and PAM at the same time, PA
M will" |
| 53 ewarn "be used then." |
| 54 fi |
| 55 } |
| 56 |
| 57 src_unpack() { |
| 58 unpack ${A}; cd "${S}" |
| 59 |
| 60 # compatability fix. |
| 61 epatch "${FILESDIR}"/${PN}-skeychallengeargs.diff |
| 62 |
| 63 # additional variables to disallow, should user disable env_reset. |
| 64 |
| 65 # NOTE: this is not a supported mode of operation, these variables |
| 66 # are added to the blacklist as a convenience to administrators |
| 67 # who fail to heed the warnings of allowing untrusted users |
| 68 # to access sudo. |
| 69 # |
| 70 # there is *no possible way* to foresee all attack vectors in |
| 71 # all possible applications that could potentially be used via |
| 72 # sudo, these settings will just delay the inevitable. |
| 73 # |
| 74 # that said, I will accept suggestions for variables that can |
| 75 # be misused in _common_ interpreters or libraries, such as |
| 76 # perl, bash, python, ruby, etc., in the hope of dissuading |
| 77 # a casual attacker. |
| 78 |
| 79 # XXX: perl should be using suid_perl. |
| 80 # XXX: users can remove/add more via env_delete and env_check. |
| 81 # XXX: <?> = probably safe enough for most circumstances. |
| 82 |
| 83 einfo "Blacklisting common variables (env_delete)..." |
| 84 sudo_bad_var() { |
| 85 local target='env.c' marker='\*initial_badenv_table\[\]' |
| 86 |
| 87 ebegin " $1" |
| 88 sed -i 's#\(^.*'${marker}'.*$\)#\1\n\t"'${1}'",#' "${S}"
/${target} |
| 89 eend $? |
| 90 } |
| 91 |
| 92 sudo_bad_var 'PERLIO_DEBUG' # perl, write debug to file. |
| 93 sudo_bad_var 'FPATH' # ksh, search path for functions. |
| 94 sudo_bad_var 'NULLCMD' # zsh, command on null-redir. <?> |
| 95 sudo_bad_var 'READNULLCMD' # zsh, command on null-redir. <?> |
| 96 sudo_bad_var 'GLOBIGNORE' # bash, glob paterns to ignore. <?
> |
| 97 sudo_bad_var 'PYTHONHOME' # python, module search path. |
| 98 sudo_bad_var 'PYTHONPATH' # python, search path. |
| 99 sudo_bad_var 'PYTHONINSPECT' # python, allow inspection. |
| 100 sudo_bad_var 'RUBYLIB' # ruby, lib load path. |
| 101 sudo_bad_var 'RUBYOPT' # ruby, cl options. |
| 102 sudo_bad_var 'ZDOTDIR' # zsh, path to search for dotfiles
. |
| 103 einfo "...done." |
| 104 |
| 105 # prevent binaries from being stripped. |
| 106 sed -i 's/\($(INSTALL).*\) -s \(.*[(sudo|visudo)]\)/\1 \2/g' Makefile.in |
| 107 } |
| 108 |
| 109 src_compile() { |
| 110 local line ROOTPATH |
| 111 |
| 112 # FIXME: secure_path is a compile time setting. using ROOTPATH |
| 113 # is not perfect, env-update may invalidate this, but until it |
| 114 # is available as a sudoers setting this will have to do. |
| 115 einfo "Setting secure_path..." |
| 116 |
| 117 # why not use grep? variable might be expanded from other variab
les |
| 118 # declared in that file. cannot just source the file, would over
ride |
| 119 # any variables already set. |
| 120 eval `PS4= bash -x /etc/profile.env 2>&1 | \ |
| 121 while read line; do |
| 122 case $line in |
| 123 ROOTPATH=*) echo $line; break;; |
| 124 *) continue;; |
| 125 esac |
| 126 done` && einfo " Found ROOTPATH..." || \ |
| 127 ewarn " Failed to find ROOTPATH, please report t
his." |
| 128 |
| 129 # remove duplicate path entries from $1 |
| 130 cleanpath() { |
| 131 local i=1 x n IFS=: |
| 132 local -a paths; paths=($1) |
| 133 |
| 134 for ((n=${#paths[*]}-1;i<=n;i++)); do |
| 135 for ((x=0;x<i;x++)); do |
| 136 test "${paths[i]}" == "${paths[x]}" && { |
| 137 einfo " Duplicate entry ${paths[
i]} removed..." 1>&2 |
| 138 unset paths[i]; continue 2; } |
| 139 done; # einfo " Adding ${paths[i]}..." 1>&2 |
| 140 done; echo "${paths[*]}" |
| 141 } |
| 142 |
| 143 ROOTPATH=$(cleanpath /bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bi
n:/usr/local/sbin:/opt/bin${ROOTPATH:+:${ROOTPATH}}) |
| 144 |
| 145 # strip gcc path (bug #136027) |
| 146 rmpath() { |
| 147 declare e newpath oldpath=${!1} PATHvar=$1 thisp IFS=: |
| 148 shift |
| 149 for thisp in $oldpath; do |
| 150 for e; do [[ $thisp == $e ]] && continue 2; done |
| 151 newpath=$newpath:$thisp |
| 152 done |
| 153 eval $PATHvar='${newpath#:}' |
| 154 } |
| 155 |
| 156 rmpath ROOTPATH '*/gcc-bin/*' |
| 157 |
| 158 einfo "...done." |
| 159 |
| 160 if use pam; then |
| 161 myconf="--with-pam --without-skey" |
| 162 elif use skey; then |
| 163 myconf="--without-pam --with-skey" |
| 164 else |
| 165 myconf="--without-pam --without-skey" |
| 166 fi |
| 167 |
| 168 # audit: somebody got to explain me how I can test this before I |
| 169 # enable it.. — Diego |
| 170 econf --with-secure-path="${ROOTPATH}" \ |
| 171 --with-editor=/usr/libexec/gentoo-editor \ |
| 172 --with-env-editor \ |
| 173 $(use_with offensive insults) \ |
| 174 $(use_with offensive all-insults) \ |
| 175 $(use_with ldap ldap_conf_file /etc/ldap.conf.sudo) \ |
| 176 $(use_with ldap) \ |
| 177 --without-linux-audit \ |
| 178 --with-timedir=/var/db/sudo \ |
| 179 --docdir=/usr/share/doc/${PF} \ |
| 180 ${myconf} |
| 181 |
| 182 emake || die |
| 183 } |
| 184 |
| 185 src_install() { |
| 186 emake DESTDIR="${D}" install || die |
| 187 |
| 188 if use ldap; then |
| 189 dodoc README.LDAP schema.OpenLDAP |
| 190 dosbin sudoers2ldif |
| 191 |
| 192 cat - > "${T}"/ldap.conf.sudo <<EOF |
| 193 # See ldap.conf(5) and README.LDAP for details\n" |
| 194 # This file should only be readable by root\n\n" |
| 195 # supported directives: host, port, ssl, ldap_version\n" |
| 196 # uri, binddn, bindpw, sudoers_base, sudoers_debug\n" |
| 197 # tls_{checkpeer,cacertfile,cacertdir,randfile,ciphers,cert,key |
| 198 EOF |
| 199 |
| 200 insinto /etc |
| 201 doins "${T}"/ldap.conf.sudo |
| 202 fperms 0440 /etc/ldap.conf.sudo |
| 203 fi |
| 204 |
| 205 pamd_mimic system-auth sudo auth account session |
| 206 |
| 207 insinto /etc |
| 208 doins "${S}"/sudoers |
| 209 fperms 0440 /etc/sudoers |
| 210 |
| 211 keepdir /var/db/sudo |
| 212 fperms 0700 /var/db/sudo |
| 213 } |
| 214 |
| 215 pkg_postinst() { |
| 216 if use ldap; then |
| 217 ewarn |
| 218 ewarn "sudo uses the /etc/ldap.conf.sudo file for ldap configura
tion." |
| 219 ewarn |
| 220 if egrep -q '^[[:space:]]*sudoers:' "${ROOT}"/etc/nsswitch.conf;
then |
| 221 ewarn "In 1.7 series, LDAP is no more consulted, unless
explicitly" |
| 222 ewarn "configured in /etc/nsswitch.conf." |
| 223 ewarn |
| 224 ewarn "To make use of LDAP, add this line to your /etc/n
sswitch.conf:" |
| 225 ewarn " sudoers: ldap files" |
| 226 ewarn |
| 227 fi |
| 228 fi |
| 229 |
| 230 elog "To use the -A (askpass) option, you need to install a compatible" |
| 231 elog "password program from the following list. Starred packages will" |
| 232 elog "automatically register for the use with sudo (but will not force" |
| 233 elog "the -A option):" |
| 234 elog "" |
| 235 elog " [*] net-misc/ssh-askpass-fullscreen" |
| 236 elog " net-misc/x11-ssh-askpass" |
| 237 elog "" |
| 238 elog "You can override the choice by setting the SUDO_ASKPASS environmne
nt" |
| 239 elog "variable to the program you want to use." |
| 240 } |
OLD | NEW |