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