blob: f86e5e03c0f059b7a504645f24215f2392fc2d23 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "Tools to change and administer password and group data"
Brad Bishopf3f93bb2019-10-16 14:33:32 -04002HOMEPAGE = "http://github.com/shadow-maint/shadow"
3BUGTRACKER = "http://github.com/shadow-maint/shadow/issues"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05004SECTION = "base/utils"
5LICENSE = "BSD | Artistic-1.0"
6LIC_FILES_CHKSUM = "file://COPYING;md5=ed80ff1c2b40843cf5768e5229cf16e5 \
Brad Bishopc68388fc2019-08-26 01:33:31 -04007 file://src/passwd.c;beginline=2;endline=30;md5=5720ff729a6ff39ecc9f64555d75f4af"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05008
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"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012SRC_URI = "https://github.com/shadow-maint/shadow/releases/download/${PV}/${BP}.tar.gz \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013 file://shadow-4.1.3-dots-in-usernames.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014 ${@bb.utils.contains('PACKAGECONFIG', 'pam', '${PAM_SRC_URI}', '', d)} \
Brad Bishop00e122a2019-10-05 11:10:57 -040015 file://shadow-relaxed-usernames.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016 "
17
18SRC_URI_append_class-target = " \
19 file://login_defs_pam.sed \
20 file://shadow-update-pam-conf.patch \
21 "
22
23SRC_URI_append_class-native = " \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050024 file://0001-Disable-use-of-syslog-for-sysroot.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050025 file://0002-Allow-for-setting-password-in-clear-text.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026 file://commonio.c-fix-unexpected-open-failure-in-chroot-env.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027 "
28SRC_URI_append_class-nativesdk = " \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050029 file://0001-Disable-use-of-syslog-for-sysroot.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050030 "
31
Andrew Geissler82c905d2020-04-13 13:39:40 -050032SRC_URI[md5sum] = "3d97f11e66bfb0b14702b115fa8be480"
33SRC_URI[sha256sum] = "3ee3081fbbcbcfea5c8916419e46bc724807bab271072104f23e7a29e9668f3a"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034
35# Additional Policy files for PAM
36PAM_SRC_URI = "file://pam.d/chfn \
37 file://pam.d/chpasswd \
38 file://pam.d/chsh \
39 file://pam.d/login \
40 file://pam.d/newusers \
41 file://pam.d/passwd \
42 file://pam.d/su"
43
44inherit autotools gettext
45
Brad Bishope2d5b612018-11-23 10:55:50 +130046export CONFIG_SHELL="/bin/sh"
47
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048EXTRA_OECONF += "--without-audit \
49 --without-libcrack \
50 --without-selinux \
51 --with-group-name-max-length=24 \
52 --enable-subordinate-ids=yes \
Andrew Geissler82c905d2020-04-13 13:39:40 -050053 --without-sssd \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054 ${NSCDOPT}"
55
56NSCDOPT = ""
57NSCDOPT_class-native = "--without-nscd"
58NSCDOPT_class-nativesdk = "--without-nscd"
Brad Bishop19323692019-04-05 15:28:33 -040059NSCDOPT_libc-glibc = "--with-nscd"
Brad Bishopf3f93bb2019-10-16 14:33:32 -040060
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061PAM_PLUGINS = "libpam-runtime \
62 pam-plugin-faildelay \
63 pam-plugin-securetty \
64 pam-plugin-nologin \
65 pam-plugin-env \
66 pam-plugin-group \
67 pam-plugin-limits \
68 pam-plugin-lastlog \
69 pam-plugin-motd \
70 pam-plugin-mail \
71 pam-plugin-shells \
72 pam-plugin-rootok"
73
Brad Bishop6e60e8b2018-02-01 10:27:11 -050074PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \
75 ${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
76PACKAGECONFIG_class-native ??= "${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050077PACKAGECONFIG_class-nativesdk = ""
78PACKAGECONFIG[pam] = "--with-libpam,--without-libpam,libpam,${PAM_PLUGINS}"
79PACKAGECONFIG[attr] = "--with-attr,--without-attr,attr"
80PACKAGECONFIG[acl] = "--with-acl,--without-acl,acl"
81
82RDEPENDS_${PN} = "shadow-securetty \
83 base-passwd \
84 util-linux-sulogin"
85RDEPENDS_${PN}_class-native = ""
86RDEPENDS_${PN}_class-nativesdk = ""
87
88do_install() {
89 oe_runmake DESTDIR="${D}" sbindir="${base_sbindir}" usbindir="${sbindir}" install
90
91 # Info dir listing isn't interesting at this point so remove it if it exists.
92 if [ -e "${D}${infodir}/dir" ]; then
93 rm -f ${D}${infodir}/dir
94 fi
95
96 # Enable CREATE_HOME by default.
97 sed -i 's/#CREATE_HOME/CREATE_HOME/g' ${D}${sysconfdir}/login.defs
98
99 # As we are on an embedded system, ensure the users mailbox is in
100 # ~/ not /var/spool/mail by default, as who knows where or how big
101 # /var is. The system MDA will set this later anyway.
102 sed -i 's/MAIL_DIR/#MAIL_DIR/g' ${D}${sysconfdir}/login.defs
103 sed -i 's/#MAIL_FILE/MAIL_FILE/g' ${D}${sysconfdir}/login.defs
104
105 # Disable checking emails.
106 sed -i 's/MAIL_CHECK_ENAB/#MAIL_CHECK_ENAB/g' ${D}${sysconfdir}/login.defs
107
108 # Comment out SU_NAME to work correctly with busybox
109 # See Bug#5359 and Bug#7173
110 sed -i 's:^SU_NAME:#SU_NAME:g' ${D}${sysconfdir}/login.defs
111
112 # Use proper encryption for passwords
113 sed -i 's/^#ENCRYPT_METHOD.*$/ENCRYPT_METHOD SHA512/' ${D}${sysconfdir}/login.defs
114
115 # Now we don't have a mail system. Disable mail creation for now.
116 sed -i 's:/bin/bash:/bin/sh:g' ${D}${sysconfdir}/default/useradd
117 sed -i '/^CREATE_MAIL_SPOOL/ s:^:#:' ${D}${sysconfdir}/default/useradd
118
119 # Use users group by default
120 sed -i 's,^GROUP=1000,GROUP=100,g' ${D}${sysconfdir}/default/useradd
121}
122
123do_install_append() {
124 # Ensure that the image has as a /var/spool/mail dir so shadow can
125 # put mailboxes there if the user reconfigures shadow to its
126 # defaults (see sed below).
Brad Bishopd5ae7d92018-06-14 09:52:03 -0700127 install -m 0775 -d ${D}${localstatedir}/spool/mail
128 chown root:mail ${D}${localstatedir}/spool/mail
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500129
130 if [ -e ${WORKDIR}/pam.d ]; then
131 install -d ${D}${sysconfdir}/pam.d/
132 install -m 0644 ${WORKDIR}/pam.d/* ${D}${sysconfdir}/pam.d/
133 # Remove defaults that are not used when supporting PAM.
134 sed -i -f ${WORKDIR}/login_defs_pam.sed ${D}${sysconfdir}/login.defs
135 fi
136
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400137 install -d ${D}${sbindir} ${D}${base_sbindir} ${D}${base_bindir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500138
139 # Move binaries to the locations we want
140 rm ${D}${sbindir}/vigr
141 ln -sf vipw.${BPN} ${D}${base_sbindir}/vigr
142 if [ "${sbindir}" != "${base_sbindir}" ]; then
143 mv ${D}${sbindir}/vipw ${D}${base_sbindir}/vipw
144 fi
145 if [ "${bindir}" != "${base_bindir}" ]; then
146 mv ${D}${bindir}/login ${D}${base_bindir}/login
147 mv ${D}${bindir}/su ${D}${base_bindir}/su
148 fi
149
150 # Handle link properly after rename, otherwise missing files would
151 # lead rpm failed dependencies.
152 ln -sf newgrp.${BPN} ${D}${bindir}/sg
153}
154
155PACKAGES =+ "${PN}-base"
156FILES_${PN}-base = "\
157 ${base_bindir}/login.shadow \
158 ${base_bindir}/su.shadow \
159 ${bindir}/sg \
160 ${bindir}/newgrp.shadow \
161 ${bindir}/groups.shadow \
162 ${sysconfdir}/pam.d/login \
163 ${sysconfdir}/pam.d/su \
164 ${sysconfdir}/login.defs \
165"
166RDEPENDS_${PN} += "${PN}-base"
167
168inherit update-alternatives
169
170ALTERNATIVE_PRIORITY = "200"
171
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500172ALTERNATIVE_${PN} = "passwd chfn chsh chpasswd vipw vigr nologin"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500173ALTERNATIVE_LINK_NAME[chpasswd] = "${sbindir}/chpasswd"
174ALTERNATIVE_LINK_NAME[vipw] = "${base_sbindir}/vipw"
175ALTERNATIVE_LINK_NAME[vigr] = "${base_sbindir}/vigr"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500176ALTERNATIVE_LINK_NAME[nologin] = "${base_sbindir}/nologin"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500177
178ALTERNATIVE_${PN}-base = "newgrp groups login su"
179ALTERNATIVE_LINK_NAME[login] = "${base_bindir}/login"
180ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su"
181
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500182ALTERNATIVE_${PN}-doc = "passwd.5 getspnam.3 groups.1 su.1 nologin.8"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500183ALTERNATIVE_LINK_NAME[passwd.5] = "${mandir}/man5/passwd.5"
184ALTERNATIVE_LINK_NAME[getspnam.3] = "${mandir}/man3/getspnam.3"
185ALTERNATIVE_LINK_NAME[groups.1] = "${mandir}/man1/groups.1"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600186ALTERNATIVE_LINK_NAME[su.1] = "${mandir}/man1/su.1"
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500187ALTERNATIVE_LINK_NAME[nologin.8] = "${mandir}/man8/nologin.8"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500188
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500189PACKAGE_WRITE_DEPS += "shadow-native"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400190pkg_postinst_${PN}_class-target () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500191 if [ "x$D" != "x" ]; then
192 rootarg="--root $D"
193 else
194 rootarg=""
195 fi
196
197 pwconv $rootarg || exit 1
198 grpconv $rootarg || exit 1
199}