logo

overlay

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

shadow-4.11.1.ebuild (6319B)


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