blob: 9691c3879a6376b39a0fe9827a8ec2285e98ca3a [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
Brad Bishop316dfdd2018-06-25 12:45:53 -04009DEPENDS = "virtual/crypt"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010
Brad Bishopd5ae7d92018-06-14 09:52:03 -070011UPSTREAM_CHECK_URI = "https://github.com/shadow-maint/shadow/releases"
12
13SRC_URI = "https://downloads.yoctoproject.org/mirror/sources/${BP}.tar.xz \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014 file://shadow-4.1.3-dots-in-usernames.patch \
15 file://usermod-fix-compilation-failure-with-subids-disabled.patch \
16 file://fix-installation-failure-with-subids-disabled.patch \
17 file://0001-Do-not-read-login.defs-before-doing-chroot.patch \
18 file://check_size_of_uid_t_and_gid_t_using_AC_CHECK_SIZEOF.patch \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050019 file://0001-useradd-copy-extended-attributes-of-home.patch \
Brad Bishopd7bf8c12018-02-25 22:55:05 -050020 file://0001-shadow-CVE-2017-12424 \
Brad Bishopd5ae7d92018-06-14 09:52:03 -070021 file://CVE-2017-2616.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 ${@bb.utils.contains('PACKAGECONFIG', 'pam', '${PAM_SRC_URI}', '', d)} \
Brad Bishop220d5532018-08-14 00:59:39 +010023 file://CVE-2018-7169.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 "
25
26SRC_URI_append_class-target = " \
27 file://login_defs_pam.sed \
28 file://shadow-update-pam-conf.patch \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060029 file://shadow-relaxed-usernames.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030 "
31
32SRC_URI_append_class-native = " \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050033 file://0001-Disable-use-of-syslog-for-sysroot.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 file://allow-for-setting-password-in-clear-text.patch \
35 file://commonio.c-fix-unexpected-open-failure-in-chroot-env.patch \
36 file://0001-useradd.c-create-parent-directories-when-necessary.patch \
37 "
38SRC_URI_append_class-nativesdk = " \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050039 file://0001-Disable-use-of-syslog-for-sysroot.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050040 "
41
42SRC_URI[md5sum] = "2bfafe7d4962682d31b5eba65dba4fc8"
43SRC_URI[sha256sum] = "3b0893d1476766868cd88920f4f1231c4795652aa407569faff802bcda0f3d41"
44
45# Additional Policy files for PAM
46PAM_SRC_URI = "file://pam.d/chfn \
47 file://pam.d/chpasswd \
48 file://pam.d/chsh \
49 file://pam.d/login \
50 file://pam.d/newusers \
51 file://pam.d/passwd \
52 file://pam.d/su"
53
54inherit autotools gettext
55
56EXTRA_OECONF += "--without-audit \
57 --without-libcrack \
58 --without-selinux \
59 --with-group-name-max-length=24 \
60 --enable-subordinate-ids=yes \
61 ${NSCDOPT}"
62
63NSCDOPT = ""
64NSCDOPT_class-native = "--without-nscd"
65NSCDOPT_class-nativesdk = "--without-nscd"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050066NSCDOPT_libc-glibc = "${@bb.utils.contains('DISTRO_FEATURES', 'libc-spawn', '--with-nscd', '--without-nscd', d)}"
67
68PAM_PLUGINS = "libpam-runtime \
69 pam-plugin-faildelay \
70 pam-plugin-securetty \
71 pam-plugin-nologin \
72 pam-plugin-env \
73 pam-plugin-group \
74 pam-plugin-limits \
75 pam-plugin-lastlog \
76 pam-plugin-motd \
77 pam-plugin-mail \
78 pam-plugin-shells \
79 pam-plugin-rootok"
80
Brad Bishop6e60e8b2018-02-01 10:27:11 -050081PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \
82 ${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
83PACKAGECONFIG_class-native ??= "${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084PACKAGECONFIG_class-nativesdk = ""
85PACKAGECONFIG[pam] = "--with-libpam,--without-libpam,libpam,${PAM_PLUGINS}"
86PACKAGECONFIG[attr] = "--with-attr,--without-attr,attr"
87PACKAGECONFIG[acl] = "--with-acl,--without-acl,acl"
88
89RDEPENDS_${PN} = "shadow-securetty \
90 base-passwd \
91 util-linux-sulogin"
92RDEPENDS_${PN}_class-native = ""
93RDEPENDS_${PN}_class-nativesdk = ""
94
95do_install() {
96 oe_runmake DESTDIR="${D}" sbindir="${base_sbindir}" usbindir="${sbindir}" install
97
98 # Info dir listing isn't interesting at this point so remove it if it exists.
99 if [ -e "${D}${infodir}/dir" ]; then
100 rm -f ${D}${infodir}/dir
101 fi
102
103 # Enable CREATE_HOME by default.
104 sed -i 's/#CREATE_HOME/CREATE_HOME/g' ${D}${sysconfdir}/login.defs
105
106 # As we are on an embedded system, ensure the users mailbox is in
107 # ~/ not /var/spool/mail by default, as who knows where or how big
108 # /var is. The system MDA will set this later anyway.
109 sed -i 's/MAIL_DIR/#MAIL_DIR/g' ${D}${sysconfdir}/login.defs
110 sed -i 's/#MAIL_FILE/MAIL_FILE/g' ${D}${sysconfdir}/login.defs
111
112 # Disable checking emails.
113 sed -i 's/MAIL_CHECK_ENAB/#MAIL_CHECK_ENAB/g' ${D}${sysconfdir}/login.defs
114
115 # Comment out SU_NAME to work correctly with busybox
116 # See Bug#5359 and Bug#7173
117 sed -i 's:^SU_NAME:#SU_NAME:g' ${D}${sysconfdir}/login.defs
118
119 # Use proper encryption for passwords
120 sed -i 's/^#ENCRYPT_METHOD.*$/ENCRYPT_METHOD SHA512/' ${D}${sysconfdir}/login.defs
121
122 # Now we don't have a mail system. Disable mail creation for now.
123 sed -i 's:/bin/bash:/bin/sh:g' ${D}${sysconfdir}/default/useradd
124 sed -i '/^CREATE_MAIL_SPOOL/ s:^:#:' ${D}${sysconfdir}/default/useradd
125
126 # Use users group by default
127 sed -i 's,^GROUP=1000,GROUP=100,g' ${D}${sysconfdir}/default/useradd
128}
129
130do_install_append() {
131 # Ensure that the image has as a /var/spool/mail dir so shadow can
132 # put mailboxes there if the user reconfigures shadow to its
133 # defaults (see sed below).
Brad Bishopd5ae7d92018-06-14 09:52:03 -0700134 install -m 0775 -d ${D}${localstatedir}/spool/mail
135 chown root:mail ${D}${localstatedir}/spool/mail
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136
137 if [ -e ${WORKDIR}/pam.d ]; then
138 install -d ${D}${sysconfdir}/pam.d/
139 install -m 0644 ${WORKDIR}/pam.d/* ${D}${sysconfdir}/pam.d/
140 # Remove defaults that are not used when supporting PAM.
141 sed -i -f ${WORKDIR}/login_defs_pam.sed ${D}${sysconfdir}/login.defs
142 fi
143
144 install -d ${D}${sbindir} ${D}${base_sbindir} ${D}${base_bindir}
145
146 # Move binaries to the locations we want
147 rm ${D}${sbindir}/vigr
148 ln -sf vipw.${BPN} ${D}${base_sbindir}/vigr
149 if [ "${sbindir}" != "${base_sbindir}" ]; then
150 mv ${D}${sbindir}/vipw ${D}${base_sbindir}/vipw
151 fi
152 if [ "${bindir}" != "${base_bindir}" ]; then
153 mv ${D}${bindir}/login ${D}${base_bindir}/login
154 mv ${D}${bindir}/su ${D}${base_bindir}/su
155 fi
156
157 # Handle link properly after rename, otherwise missing files would
158 # lead rpm failed dependencies.
159 ln -sf newgrp.${BPN} ${D}${bindir}/sg
160}
161
162PACKAGES =+ "${PN}-base"
163FILES_${PN}-base = "\
164 ${base_bindir}/login.shadow \
165 ${base_bindir}/su.shadow \
166 ${bindir}/sg \
167 ${bindir}/newgrp.shadow \
168 ${bindir}/groups.shadow \
169 ${sysconfdir}/pam.d/login \
170 ${sysconfdir}/pam.d/su \
171 ${sysconfdir}/login.defs \
172"
173RDEPENDS_${PN} += "${PN}-base"
174
175inherit update-alternatives
176
177ALTERNATIVE_PRIORITY = "200"
178
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500179ALTERNATIVE_${PN} = "passwd chfn chsh chpasswd vipw vigr nologin"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500180ALTERNATIVE_LINK_NAME[chpasswd] = "${sbindir}/chpasswd"
181ALTERNATIVE_LINK_NAME[vipw] = "${base_sbindir}/vipw"
182ALTERNATIVE_LINK_NAME[vigr] = "${base_sbindir}/vigr"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500183ALTERNATIVE_LINK_NAME[nologin] = "${base_sbindir}/nologin"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500184
185ALTERNATIVE_${PN}-base = "newgrp groups login su"
186ALTERNATIVE_LINK_NAME[login] = "${base_bindir}/login"
187ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su"
188
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500189ALTERNATIVE_${PN}-doc = "passwd.5 getspnam.3 groups.1 su.1 nologin.8"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500190ALTERNATIVE_LINK_NAME[passwd.5] = "${mandir}/man5/passwd.5"
191ALTERNATIVE_LINK_NAME[getspnam.3] = "${mandir}/man3/getspnam.3"
192ALTERNATIVE_LINK_NAME[groups.1] = "${mandir}/man1/groups.1"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600193ALTERNATIVE_LINK_NAME[su.1] = "${mandir}/man1/su.1"
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500194ALTERNATIVE_LINK_NAME[nologin.8] = "${mandir}/man8/nologin.8"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500195
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500196PACKAGE_WRITE_DEPS += "shadow-native"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400197pkg_postinst_${PN}_class-target () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500198 if [ "x$D" != "x" ]; then
199 rootarg="--root $D"
200 else
201 rootarg=""
202 fi
203
204 pwconv $rootarg || exit 1
205 grpconv $rootarg || exit 1
206}