shadow-4.4-r2.ebuild 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. inherit eutils libtool pam multilib
  5. DESCRIPTION="Utilities to deal with user accounts"
  6. HOMEPAGE="https://github.com/shadow-maint/shadow http://pkg-shadow.alioth.debian.org/"
  7. SRC_URI="https://github.com/shadow-maint/shadow/releases/download/${PV}/${P}.tar.gz"
  8. LICENSE="BSD GPL-2"
  9. SLOT="0"
  10. KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86"
  11. IUSE="acl audit cracklib nls pam selinux skey xattr"
  12. # Taken from the man/Makefile.am file.
  13. LANGS=( cs da de es fi fr hu id it ja ko pl pt_BR ru sv tr zh_CN zh_TW )
  14. IUSE+=" $(printf 'linguas_%s ' ${LANGS[*]})"
  15. RDEPEND="acl? ( sys-apps/acl:0= )
  16. audit? ( >=sys-process/audit-2.6:0= )
  17. cracklib? ( >=sys-libs/cracklib-2.7-r3:0= )
  18. pam? ( virtual/pam:0= )
  19. skey? ( sys-auth/skey:0= )
  20. selinux? (
  21. >=sys-libs/libselinux-1.28:0=
  22. sys-libs/libsemanage:0=
  23. )
  24. nls? ( virtual/libintl )
  25. xattr? ( sys-apps/attr:0= )"
  26. DEPEND="${RDEPEND}
  27. app-arch/xz-utils
  28. nls? ( sys-devel/gettext )"
  29. RDEPEND="${RDEPEND}
  30. pam? ( >=sys-auth/pambase-20150213 )"
  31. PATCHES=(
  32. "${FILESDIR}"/${PN}-4.1.3-dots-in-usernames.patch
  33. "${FILESDIR}"/${P}-su-snprintf.patch
  34. "${FILESDIR}"/${P}-prototypes.patch
  35. "${FILESDIR}"/${P}-load_defaults.patch
  36. "${FILESDIR}"/${P}-CVE-2017-2616.patch #610804
  37. )
  38. src_prepare() {
  39. epatch "${PATCHES[@]}"
  40. epatch_user
  41. #eautoreconf
  42. elibtoolize
  43. }
  44. src_configure() {
  45. econf \
  46. --without-group-name-max-length \
  47. --without-tcb \
  48. --enable-shared=no \
  49. --enable-static=yes \
  50. $(use_with acl) \
  51. $(use_with audit) \
  52. $(use_with cracklib libcrack) \
  53. $(use_with pam libpam) \
  54. $(use_with skey) \
  55. $(use_with selinux) \
  56. $(use_enable nls) \
  57. $(use_with elibc_glibc nscd) \
  58. $(use_with xattr attr)
  59. has_version 'sys-libs/uclibc[-rpc]' && sed -i '/RLOGIN/d' config.h #425052
  60. if use nls ; then
  61. local l langs="po" # These are the pot files.
  62. for l in ${LANGS[*]} ; do
  63. use linguas_${l} && langs+=" ${l}"
  64. done
  65. sed -i "/^SUBDIRS = /s:=.*:= ${langs}:" man/Makefile || die
  66. fi
  67. }
  68. set_login_opt() {
  69. local comment="" opt=$1 val=$2
  70. if [[ -z ${val} ]]; then
  71. comment="#"
  72. sed -i \
  73. -e "/^${opt}\>/s:^:#:" \
  74. "${ED}"/etc/login.defs || die
  75. else
  76. sed -i -r \
  77. -e "/^#?${opt}\>/s:.*:${opt} ${val}:" \
  78. "${ED}"/etc/login.defs
  79. fi
  80. local res=$(grep "^${comment}${opt}\>" "${ED}"/etc/login.defs)
  81. einfo "${res:-Unable to find ${opt} in /etc/login.defs}"
  82. }
  83. src_install() {
  84. emake DESTDIR="${D}" suidperms=4711 install
  85. # Remove libshadow and libmisc; see bug 37725 and the following
  86. # comment from shadow's README.linux:
  87. # Currently, libshadow.a is for internal use only, so if you see
  88. # -lshadow in a Makefile of some other package, it is safe to
  89. # remove it.
  90. rm -f "${ED}"/{,usr/}$(get_libdir)/lib{misc,shadow}.{a,la}
  91. insinto /etc
  92. if ! use pam ; then
  93. insopts -m0600
  94. doins etc/login.access etc/limits
  95. fi
  96. # needed for 'useradd -D'
  97. insinto /etc/default
  98. insopts -m0600
  99. doins "${FILESDIR}"/default/useradd
  100. # move passwd to / to help recover broke systems #64441
  101. mv "${ED}"/usr/bin/passwd "${ED}"/bin/ || die
  102. dosym /bin/passwd /usr/bin/passwd
  103. cd "${S}"
  104. insinto /etc
  105. insopts -m0644
  106. newins etc/login.defs login.defs
  107. set_login_opt CREATE_HOME yes
  108. if ! use pam ; then
  109. set_login_opt MAIL_CHECK_ENAB no
  110. set_login_opt SU_WHEEL_ONLY yes
  111. set_login_opt CRACKLIB_DICTPATH /usr/$(get_libdir)/cracklib_dict
  112. set_login_opt LOGIN_RETRIES 3
  113. set_login_opt ENCRYPT_METHOD SHA512
  114. set_login_opt CONSOLE
  115. else
  116. dopamd "${FILESDIR}"/pam.d-include/shadow
  117. for x in chpasswd chgpasswd newusers; do
  118. newpamd "${FILESDIR}"/pam.d-include/passwd ${x}
  119. done
  120. for x in chage chsh chfn \
  121. user{add,del,mod} group{add,del,mod} ; do
  122. newpamd "${FILESDIR}"/pam.d-include/shadow ${x}
  123. done
  124. # comment out login.defs options that pam hates
  125. local opt sed_args=()
  126. for opt in \
  127. CHFN_AUTH \
  128. CONSOLE \
  129. CRACKLIB_DICTPATH \
  130. ENV_HZ \
  131. ENVIRON_FILE \
  132. FAILLOG_ENAB \
  133. FTMP_FILE \
  134. LASTLOG_ENAB \
  135. MAIL_CHECK_ENAB \
  136. MOTD_FILE \
  137. NOLOGINS_FILE \
  138. OBSCURE_CHECKS_ENAB \
  139. PASS_ALWAYS_WARN \
  140. PASS_CHANGE_TRIES \
  141. PASS_MIN_LEN \
  142. PORTTIME_CHECKS_ENAB \
  143. QUOTAS_ENAB \
  144. SU_WHEEL_ONLY
  145. do
  146. set_login_opt ${opt}
  147. sed_args+=( -e "/^#${opt}\>/b pamnote" )
  148. done
  149. sed -i "${sed_args[@]}" \
  150. -e 'b exit' \
  151. -e ': pamnote; i# NOTE: This setting should be configured via /etc/pam.d/ and not in this file.' \
  152. -e ': exit' \
  153. "${ED}"/etc/login.defs || die
  154. # remove manpages that pam will install for us
  155. # and/or don't apply when using pam
  156. find "${ED}"/usr/share/man \
  157. '(' -name 'limits.5*' -o -name 'suauth.5*' ')' \
  158. -delete
  159. # Remove pam.d files provided by pambase.
  160. rm "${ED}"/etc/pam.d/{login,passwd,su} || die
  161. fi
  162. # Remove manpages that are handled by other packages
  163. find "${ED}"/usr/share/man \
  164. '(' -name id.1 -o -name passwd.5 -o -name getspnam.3 ')' \
  165. -delete
  166. cd "${S}"
  167. dodoc ChangeLog NEWS TODO
  168. newdoc README README.download
  169. cd doc
  170. dodoc HOWTO README* WISHLIST *.txt
  171. }
  172. pkg_preinst() {
  173. rm -f "${EROOT}"/etc/pam.d/system-auth.new \
  174. "${EROOT}/etc/login.defs.new"
  175. }
  176. pkg_postinst() {
  177. # Enable shadow groups.
  178. if [ ! -f "${EROOT}"/etc/gshadow ] ; then
  179. if grpck -r -R "${EROOT}" 2>/dev/null ; then
  180. grpconv -R "${EROOT}"
  181. else
  182. ewarn "Running 'grpck' returned errors. Please run it by hand, and then"
  183. ewarn "run 'grpconv' afterwards!"
  184. fi
  185. fi
  186. einfo "The 'adduser' symlink to 'useradd' has been dropped."
  187. }