blob: cc189649b2b5fc2cf68b26e451d90a3cb9cfb5bf [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "Tools to change and administer password and group data"
2HOMEPAGE = "http://pkg-shadow.alioth.debian.org"
3BUGTRACKER = "https://alioth.debian.org/tracker/?group_id=30580"
4SECTION = "base/utils"
5LICENSE = "BSD | Artistic-1.0"
6LIC_FILES_CHKSUM = "file://COPYING;md5=ed80ff1c2b40843cf5768e5229cf16e5 \
7 file://src/passwd.c;beginline=8;endline=30;md5=d83888ea14ae61951982d77125947661"
8
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009DEPENDS_class-native = ""
10DEPENDS_class-nativesdk = ""
11
12SRC_URI = "http://pkg-shadow.alioth.debian.org/releases/${BPN}-${PV}.tar.xz \
13 file://shadow-4.1.3-dots-in-usernames.patch \
14 file://usermod-fix-compilation-failure-with-subids-disabled.patch \
15 file://fix-installation-failure-with-subids-disabled.patch \
16 file://0001-Do-not-read-login.defs-before-doing-chroot.patch \
17 file://check_size_of_uid_t_and_gid_t_using_AC_CHECK_SIZEOF.patch \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050018 file://0001-useradd-copy-extended-attributes-of-home.patch \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050019 file://0001-shadow-CVE-2017-12424 \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020 ${@bb.utils.contains('PACKAGECONFIG', 'pam', '${PAM_SRC_URI}', '', d)} \
21 "
22
23SRC_URI_append_class-target = " \
24 file://login_defs_pam.sed \
25 file://shadow-update-pam-conf.patch \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060026 file://shadow-relaxed-usernames.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027 "
28
29SRC_URI_append_class-native = " \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050030 file://0001-Disable-use-of-syslog-for-sysroot.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031 file://allow-for-setting-password-in-clear-text.patch \
32 file://commonio.c-fix-unexpected-open-failure-in-chroot-env.patch \
33 file://0001-useradd.c-create-parent-directories-when-necessary.patch \
34 "
35SRC_URI_append_class-nativesdk = " \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050036 file://0001-Disable-use-of-syslog-for-sysroot.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037 "
38
39SRC_URI[md5sum] = "2bfafe7d4962682d31b5eba65dba4fc8"
40SRC_URI[sha256sum] = "3b0893d1476766868cd88920f4f1231c4795652aa407569faff802bcda0f3d41"
41
42# Additional Policy files for PAM
43PAM_SRC_URI = "file://pam.d/chfn \
44 file://pam.d/chpasswd \
45 file://pam.d/chsh \
46 file://pam.d/login \
47 file://pam.d/newusers \
48 file://pam.d/passwd \
49 file://pam.d/su"
50
51inherit autotools gettext
52
53EXTRA_OECONF += "--without-audit \
54 --without-libcrack \
55 --without-selinux \
56 --with-group-name-max-length=24 \
57 --enable-subordinate-ids=yes \
58 ${NSCDOPT}"
59
60NSCDOPT = ""
61NSCDOPT_class-native = "--without-nscd"
62NSCDOPT_class-nativesdk = "--without-nscd"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063NSCDOPT_libc-glibc = "${@bb.utils.contains('DISTRO_FEATURES', 'libc-spawn', '--with-nscd', '--without-nscd', d)}"
64
65PAM_PLUGINS = "libpam-runtime \
66 pam-plugin-faildelay \
67 pam-plugin-securetty \
68 pam-plugin-nologin \
69 pam-plugin-env \
70 pam-plugin-group \
71 pam-plugin-limits \
72 pam-plugin-lastlog \
73 pam-plugin-motd \
74 pam-plugin-mail \
75 pam-plugin-shells \
76 pam-plugin-rootok"
77
Brad Bishop6e60e8b2018-02-01 10:27:11 -050078PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \
79 ${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
80PACKAGECONFIG_class-native ??= "${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050081PACKAGECONFIG_class-nativesdk = ""
82PACKAGECONFIG[pam] = "--with-libpam,--without-libpam,libpam,${PAM_PLUGINS}"
83PACKAGECONFIG[attr] = "--with-attr,--without-attr,attr"
84PACKAGECONFIG[acl] = "--with-acl,--without-acl,acl"
85
86RDEPENDS_${PN} = "shadow-securetty \
87 base-passwd \
88 util-linux-sulogin"
89RDEPENDS_${PN}_class-native = ""
90RDEPENDS_${PN}_class-nativesdk = ""
91
92do_install() {
93 oe_runmake DESTDIR="${D}" sbindir="${base_sbindir}" usbindir="${sbindir}" install
94
95 # Info dir listing isn't interesting at this point so remove it if it exists.
96 if [ -e "${D}${infodir}/dir" ]; then
97 rm -f ${D}${infodir}/dir
98 fi
99
100 # Enable CREATE_HOME by default.
101 sed -i 's/#CREATE_HOME/CREATE_HOME/g' ${D}${sysconfdir}/login.defs
102
103 # As we are on an embedded system, ensure the users mailbox is in
104 # ~/ not /var/spool/mail by default, as who knows where or how big
105 # /var is. The system MDA will set this later anyway.
106 sed -i 's/MAIL_DIR/#MAIL_DIR/g' ${D}${sysconfdir}/login.defs
107 sed -i 's/#MAIL_FILE/MAIL_FILE/g' ${D}${sysconfdir}/login.defs
108
109 # Disable checking emails.
110 sed -i 's/MAIL_CHECK_ENAB/#MAIL_CHECK_ENAB/g' ${D}${sysconfdir}/login.defs
111
112 # Comment out SU_NAME to work correctly with busybox
113 # See Bug#5359 and Bug#7173
114 sed -i 's:^SU_NAME:#SU_NAME:g' ${D}${sysconfdir}/login.defs
115
116 # Use proper encryption for passwords
117 sed -i 's/^#ENCRYPT_METHOD.*$/ENCRYPT_METHOD SHA512/' ${D}${sysconfdir}/login.defs
118
119 # Now we don't have a mail system. Disable mail creation for now.
120 sed -i 's:/bin/bash:/bin/sh:g' ${D}${sysconfdir}/default/useradd
121 sed -i '/^CREATE_MAIL_SPOOL/ s:^:#:' ${D}${sysconfdir}/default/useradd
122
123 # Use users group by default
124 sed -i 's,^GROUP=1000,GROUP=100,g' ${D}${sysconfdir}/default/useradd
125}
126
127do_install_append() {
128 # Ensure that the image has as a /var/spool/mail dir so shadow can
129 # put mailboxes there if the user reconfigures shadow to its
130 # defaults (see sed below).
131 install -d ${D}${localstatedir}/spool/mail
132
133 if [ -e ${WORKDIR}/pam.d ]; then
134 install -d ${D}${sysconfdir}/pam.d/
135 install -m 0644 ${WORKDIR}/pam.d/* ${D}${sysconfdir}/pam.d/
136 # Remove defaults that are not used when supporting PAM.
137 sed -i -f ${WORKDIR}/login_defs_pam.sed ${D}${sysconfdir}/login.defs
138 fi
139
140 install -d ${D}${sbindir} ${D}${base_sbindir} ${D}${base_bindir}
141
142 # Move binaries to the locations we want
143 rm ${D}${sbindir}/vigr
144 ln -sf vipw.${BPN} ${D}${base_sbindir}/vigr
145 if [ "${sbindir}" != "${base_sbindir}" ]; then
146 mv ${D}${sbindir}/vipw ${D}${base_sbindir}/vipw
147 fi
148 if [ "${bindir}" != "${base_bindir}" ]; then
149 mv ${D}${bindir}/login ${D}${base_bindir}/login
150 mv ${D}${bindir}/su ${D}${base_bindir}/su
151 fi
152
153 # Handle link properly after rename, otherwise missing files would
154 # lead rpm failed dependencies.
155 ln -sf newgrp.${BPN} ${D}${bindir}/sg
156}
157
158PACKAGES =+ "${PN}-base"
159FILES_${PN}-base = "\
160 ${base_bindir}/login.shadow \
161 ${base_bindir}/su.shadow \
162 ${bindir}/sg \
163 ${bindir}/newgrp.shadow \
164 ${bindir}/groups.shadow \
165 ${sysconfdir}/pam.d/login \
166 ${sysconfdir}/pam.d/su \
167 ${sysconfdir}/login.defs \
168"
169RDEPENDS_${PN} += "${PN}-base"
170
171inherit update-alternatives
172
173ALTERNATIVE_PRIORITY = "200"
174
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500175ALTERNATIVE_${PN} = "passwd chfn chsh chpasswd vipw vigr nologin"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176ALTERNATIVE_LINK_NAME[chpasswd] = "${sbindir}/chpasswd"
177ALTERNATIVE_LINK_NAME[vipw] = "${base_sbindir}/vipw"
178ALTERNATIVE_LINK_NAME[vigr] = "${base_sbindir}/vigr"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500179ALTERNATIVE_LINK_NAME[nologin] = "${base_sbindir}/nologin"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500180
181ALTERNATIVE_${PN}-base = "newgrp groups login su"
182ALTERNATIVE_LINK_NAME[login] = "${base_bindir}/login"
183ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su"
184
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500185ALTERNATIVE_${PN}-doc = "passwd.5 getspnam.3 groups.1 su.1 nologin.8"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500186ALTERNATIVE_LINK_NAME[passwd.5] = "${mandir}/man5/passwd.5"
187ALTERNATIVE_LINK_NAME[getspnam.3] = "${mandir}/man3/getspnam.3"
188ALTERNATIVE_LINK_NAME[groups.1] = "${mandir}/man1/groups.1"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600189ALTERNATIVE_LINK_NAME[su.1] = "${mandir}/man1/su.1"
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500190ALTERNATIVE_LINK_NAME[nologin.8] = "${mandir}/man8/nologin.8"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500191
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500192PACKAGE_WRITE_DEPS += "shadow-native"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500193pkg_postinst_${PN} () {
194 if [ "x$D" != "x" ]; then
195 rootarg="--root $D"
196 else
197 rootarg=""
198 fi
199
200 pwconv $rootarg || exit 1
201 grpconv $rootarg || exit 1
202}