logo

overlay

My own overlay for experimentations, use with caution, no support is provided git clone https://hacktivis.me/git/overlay.git

shadow-4.9-r4.ebuild (6236B)


  1. # Copyright 1999-2021 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=7
  4. inherit autotools pam
  5. DESCRIPTION="Utilities to deal with user accounts"
  6. HOMEPAGE="https://github.com/shadow-maint/shadow"
  7. SRC_URI="https://github.com/shadow-maint/shadow/releases/download/v${PV}/${P}.tar.xz"
  8. LICENSE="BSD GPL-2"
  9. SLOT="0"
  10. KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
  11. IUSE="acl audit bcrypt cracklib nls pam selinux skey split-usr +su tcb 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. REQUIRED_USE="?? ( cracklib pam )"
  15. BDEPEND="
  16. app-arch/xz-utils
  17. sys-devel/gettext
  18. "
  19. COMMON_DEPEND="
  20. virtual/libcrypt:=
  21. acl? ( sys-apps/acl:0= )
  22. audit? ( >=sys-process/audit-2.6:0= )
  23. cracklib? ( >=sys-libs/cracklib-2.7-r3:0= )
  24. nls? ( virtual/libintl )
  25. pam? ( sys-libs/pam:0= )
  26. skey? ( sys-auth/skey:0= )
  27. selinux? (
  28. >=sys-libs/libselinux-1.28:0=
  29. sys-libs/libsemanage:0=
  30. )
  31. tcb? ( sys-apps/tcb )
  32. xattr? ( sys-apps/attr:0= )
  33. "
  34. DEPEND="${COMMON_DEPEND}
  35. >=sys-kernel/linux-headers-4.14
  36. "
  37. RDEPEND="${COMMON_DEPEND}
  38. !<sys-apps/man-pages-5.11-r1
  39. !=sys-apps/man-pages-5.12-r0
  40. !=sys-apps/man-pages-5.12-r1
  41. nls? (
  42. !<app-i18n/man-pages-it-5.06-r1
  43. !<app-i18n/man-pages-ja-20180315-r1
  44. !<app-i18n/man-pages-ru-5.03.2390.2390.20191017-r1
  45. )
  46. pam? ( >=sys-auth/pambase-20150213 )
  47. su? ( !sys-apps/util-linux[su(-)] )
  48. "
  49. PATCHES=(
  50. "${FILESDIR}/${PN}-4.1.3-dots-in-usernames.patch"
  51. "${FILESDIR}/${P}-libsubid_pam_linking.patch"
  52. "${FILESDIR}/${P}-libsubid_oot_build.patch"
  53. "${FILESDIR}/shadow-4.9-libcrack.patch"
  54. "${FILESDIR}/shadow-4.9-SHA-rounds.patch"
  55. "${FILESDIR}/${P}-gpasswd-double-free.patch"
  56. "${FILESDIR}/${P}-configure-typo.patch"
  57. )
  58. src_prepare() {
  59. default
  60. eautoreconf
  61. #elibtoolize
  62. }
  63. src_configure() {
  64. local myeconfargs=(
  65. --disable-account-tools-setuid
  66. --with-btrfs
  67. --without-group-name-max-length
  68. $(use_enable nls)
  69. $(use_with acl)
  70. $(use_with audit)
  71. $(use_with bcrypt)
  72. $(use_with cracklib libcrack)
  73. $(use_with elibc_glibc nscd)
  74. $(use_with pam libpam)
  75. $(use_with selinux)
  76. $(use_with skey)
  77. $(use_with su)
  78. $(use_with tcb)
  79. $(use_with xattr attr)
  80. )
  81. econf "${myeconfargs[@]}"
  82. has_version 'sys-libs/uclibc[-rpc]' && sed -i '/RLOGIN/d' config.h #425052
  83. if use nls ; then
  84. local l langs="po" # These are the pot files.
  85. for l in ${LANGS[*]} ; do
  86. has ${l} ${LINGUAS-${l}} && langs+=" ${l}"
  87. done
  88. sed -i "/^SUBDIRS = /s:=.*:= ${langs}:" man/Makefile || die
  89. fi
  90. }
  91. set_login_opt() {
  92. local comment="" opt=${1} val=${2}
  93. if [[ -z ${val} ]]; then
  94. comment="#"
  95. sed -i \
  96. -e "/^${opt}\>/s:^:#:" \
  97. "${ED}"/etc/login.defs || die
  98. else
  99. sed -i -r \
  100. -e "/^#?${opt}\>/s:.*:${opt} ${val}:" \
  101. "${ED}"/etc/login.defs
  102. fi
  103. local res=$(grep "^${comment}${opt}\>" "${ED}"/etc/login.defs)
  104. einfo "${res:-Unable to find ${opt} in /etc/login.defs}"
  105. }
  106. src_install() {
  107. emake DESTDIR="${D}" suidperms=4711 install
  108. # 4.9 regression: https://github.com/shadow-maint/shadow/issues/389
  109. emake DESTDIR="${D}" -C man install
  110. find "${ED}" -name '*.la' -type f -delete || die
  111. insinto /etc
  112. if ! use pam ; then
  113. insopts -m0600
  114. doins etc/login.access etc/limits
  115. fi
  116. # needed for 'useradd -D'
  117. insinto /etc/default
  118. insopts -m0600
  119. doins "${FILESDIR}"/default/useradd
  120. if use split-usr ; then
  121. # move passwd to / to help recover broke systems #64441
  122. # We cannot simply remove this or else net-misc/scponly
  123. # and other tools will break because of hardcoded passwd
  124. # location
  125. dodir /bin
  126. mv "${ED}"/usr/bin/passwd "${ED}"/bin/ || die
  127. dosym ../../bin/passwd /usr/bin/passwd
  128. fi
  129. cd "${S}" || die
  130. insinto /etc
  131. insopts -m0644
  132. newins etc/login.defs login.defs
  133. set_login_opt CREATE_HOME yes
  134. if ! use pam ; then
  135. set_login_opt MAIL_CHECK_ENAB no
  136. set_login_opt SU_WHEEL_ONLY yes
  137. set_login_opt CRACKLIB_DICTPATH /usr/lib/cracklib_dict
  138. set_login_opt LOGIN_RETRIES 3
  139. set_login_opt ENCRYPT_METHOD SHA512
  140. set_login_opt CONSOLE
  141. else
  142. dopamd "${FILESDIR}"/pam.d-include/shadow
  143. for x in chsh shfn ; do
  144. newpamd "${FILESDIR}"/pam.d-include/passwd ${x}
  145. done
  146. for x in chpasswd newusers ; do
  147. newpamd "${FILESDIR}"/pam.d-include/chpasswd ${x}
  148. done
  149. newpamd "${FILESDIR}"/pam.d-include/shadow-r1 groupmems
  150. # comment out login.defs options that pam hates
  151. local opt sed_args=()
  152. for opt in \
  153. CHFN_AUTH \
  154. CONSOLE \
  155. CRACKLIB_DICTPATH \
  156. ENV_HZ \
  157. ENVIRON_FILE \
  158. FAILLOG_ENAB \
  159. FTMP_FILE \
  160. LASTLOG_ENAB \
  161. MAIL_CHECK_ENAB \
  162. MOTD_FILE \
  163. NOLOGINS_FILE \
  164. OBSCURE_CHECKS_ENAB \
  165. PASS_ALWAYS_WARN \
  166. PASS_CHANGE_TRIES \
  167. PASS_MIN_LEN \
  168. PORTTIME_CHECKS_ENAB \
  169. QUOTAS_ENAB \
  170. SU_WHEEL_ONLY
  171. do
  172. set_login_opt ${opt}
  173. sed_args+=( -e "/^#${opt}\>/b pamnote" )
  174. done
  175. sed -i "${sed_args[@]}" \
  176. -e 'b exit' \
  177. -e ': pamnote; i# NOTE: This setting should be configured via /etc/pam.d/ and not in this file.' \
  178. -e ': exit' \
  179. "${ED}"/etc/login.defs || die
  180. # remove manpages that pam will install for us
  181. # and/or don't apply when using pam
  182. find "${ED}"/usr/share/man -type f \
  183. '(' -name 'limits.5*' -o -name 'suauth.5*' ')' \
  184. -delete
  185. # Remove pam.d files provided by pambase.
  186. rm "${ED}"/etc/pam.d/{login,passwd} || die
  187. if use su ; then
  188. rm "${ED}"/etc/pam.d/su || die
  189. fi
  190. fi
  191. # Remove manpages that are handled by other packages
  192. find "${ED}"/usr/share/man -type f \
  193. '(' -name id.1 -o -name getspnam.3 ')' \
  194. -delete
  195. cd "${S}" || die
  196. dodoc ChangeLog NEWS TODO
  197. newdoc README README.download
  198. cd doc || die
  199. dodoc HOWTO README* WISHLIST *.txt
  200. }
  201. pkg_preinst() {
  202. rm -f "${EROOT}"/etc/pam.d/system-auth.new \
  203. "${EROOT}/etc/login.defs.new"
  204. }
  205. pkg_postinst() {
  206. # Enable shadow groups.
  207. if [ ! -f "${EROOT}"/etc/gshadow ] ; then
  208. if grpck -r -R "${EROOT}" 2>/dev/null ; then
  209. grpconv -R "${EROOT}"
  210. else
  211. ewarn "Running 'grpck' returned errors. Please run it by hand, and then"
  212. ewarn "run 'grpconv' afterwards!"
  213. fi
  214. fi
  215. [[ ! -f "${EROOT}"/etc/subgid ]] &&
  216. touch "${EROOT}"/etc/subgid
  217. [[ ! -f "${EROOT}"/etc/subuid ]] &&
  218. touch "${EROOT}"/etc/subuid
  219. einfo "The 'adduser' symlink to 'useradd' has been dropped."
  220. }