blob: 2278541f6b1bdb1ca3f55b88d4f3ca3adbe80829 [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"
Andrew Geissler95ac1b82021-03-31 14:34:31 -05003DESCRIPTION = "${SUMMARY}"
Brad Bishopf3f93bb2019-10-16 14:33:32 -04004BUGTRACKER = "http://github.com/shadow-maint/shadow/issues"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005SECTION = "base/utils"
6LICENSE = "BSD | Artistic-1.0"
7LIC_FILES_CHKSUM = "file://COPYING;md5=ed80ff1c2b40843cf5768e5229cf16e5 \
Brad Bishopc68388fc2019-08-26 01:33:31 -04008 file://src/passwd.c;beginline=2;endline=30;md5=5720ff729a6ff39ecc9f64555d75f4af"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009
Brad Bishop316dfdd2018-06-25 12:45:53 -040010DEPENDS = "virtual/crypt"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011
Brad Bishopd5ae7d92018-06-14 09:52:03 -070012UPSTREAM_CHECK_URI = "https://github.com/shadow-maint/shadow/releases"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080013SRC_URI = "https://github.com/shadow-maint/shadow/releases/download/${PV}/${BP}.tar.gz \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014 file://shadow-4.1.3-dots-in-usernames.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015 ${@bb.utils.contains('PACKAGECONFIG', 'pam', '${PAM_SRC_URI}', '', d)} \
Brad Bishop00e122a2019-10-05 11:10:57 -040016 file://shadow-relaxed-usernames.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017 "
18
19SRC_URI_append_class-target = " \
20 file://login_defs_pam.sed \
21 file://shadow-update-pam-conf.patch \
22 "
23
24SRC_URI_append_class-native = " \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050025 file://0001-Disable-use-of-syslog-for-sysroot.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050026 file://0002-Allow-for-setting-password-in-clear-text.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027 file://commonio.c-fix-unexpected-open-failure-in-chroot-env.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028 "
29SRC_URI_append_class-nativesdk = " \
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 "
32
Andrew Geissler82c905d2020-04-13 13:39:40 -050033SRC_URI[md5sum] = "3d97f11e66bfb0b14702b115fa8be480"
34SRC_URI[sha256sum] = "3ee3081fbbcbcfea5c8916419e46bc724807bab271072104f23e7a29e9668f3a"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050035
36# Additional Policy files for PAM
37PAM_SRC_URI = "file://pam.d/chfn \
38 file://pam.d/chpasswd \
39 file://pam.d/chsh \
40 file://pam.d/login \
41 file://pam.d/newusers \
42 file://pam.d/passwd \
43 file://pam.d/su"
44
45inherit autotools gettext
46
Brad Bishope2d5b612018-11-23 10:55:50 +130047export CONFIG_SHELL="/bin/sh"
48
Patrick Williamsc124f4f2015-09-15 14:41:29 -050049EXTRA_OECONF += "--without-audit \
50 --without-libcrack \
51 --without-selinux \
52 --with-group-name-max-length=24 \
53 --enable-subordinate-ids=yes \
Andrew Geissler82c905d2020-04-13 13:39:40 -050054 --without-sssd \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055 ${NSCDOPT}"
56
57NSCDOPT = ""
58NSCDOPT_class-native = "--without-nscd"
59NSCDOPT_class-nativesdk = "--without-nscd"
Brad Bishop19323692019-04-05 15:28:33 -040060NSCDOPT_libc-glibc = "--with-nscd"
Brad Bishopf3f93bb2019-10-16 14:33:32 -040061
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062PAM_PLUGINS = "libpam-runtime \
63 pam-plugin-faildelay \
64 pam-plugin-securetty \
65 pam-plugin-nologin \
66 pam-plugin-env \
67 pam-plugin-group \
68 pam-plugin-limits \
69 pam-plugin-lastlog \
70 pam-plugin-motd \
71 pam-plugin-mail \
72 pam-plugin-shells \
73 pam-plugin-rootok"
74
Andrew Geisslerd1e89492021-02-12 15:35:20 -060075PAM_PLUGINS_remove_libc-musl = "pam-plugin-lastlog"
76
Brad Bishop6e60e8b2018-02-01 10:27:11 -050077PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \
78 ${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
79PACKAGECONFIG_class-native ??= "${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080PACKAGECONFIG_class-nativesdk = ""
81PACKAGECONFIG[pam] = "--with-libpam,--without-libpam,libpam,${PAM_PLUGINS}"
82PACKAGECONFIG[attr] = "--with-attr,--without-attr,attr"
83PACKAGECONFIG[acl] = "--with-acl,--without-acl,acl"
84
85RDEPENDS_${PN} = "shadow-securetty \
86 base-passwd \
87 util-linux-sulogin"
88RDEPENDS_${PN}_class-native = ""
89RDEPENDS_${PN}_class-nativesdk = ""
90
91do_install() {
92 oe_runmake DESTDIR="${D}" sbindir="${base_sbindir}" usbindir="${sbindir}" install
93
94 # Info dir listing isn't interesting at this point so remove it if it exists.
95 if [ -e "${D}${infodir}/dir" ]; then
96 rm -f ${D}${infodir}/dir
97 fi
98
99 # Enable CREATE_HOME by default.
100 sed -i 's/#CREATE_HOME/CREATE_HOME/g' ${D}${sysconfdir}/login.defs
101
102 # As we are on an embedded system, ensure the users mailbox is in
103 # ~/ not /var/spool/mail by default, as who knows where or how big
104 # /var is. The system MDA will set this later anyway.
105 sed -i 's/MAIL_DIR/#MAIL_DIR/g' ${D}${sysconfdir}/login.defs
106 sed -i 's/#MAIL_FILE/MAIL_FILE/g' ${D}${sysconfdir}/login.defs
107
108 # Disable checking emails.
109 sed -i 's/MAIL_CHECK_ENAB/#MAIL_CHECK_ENAB/g' ${D}${sysconfdir}/login.defs
110
111 # Comment out SU_NAME to work correctly with busybox
112 # See Bug#5359 and Bug#7173
113 sed -i 's:^SU_NAME:#SU_NAME:g' ${D}${sysconfdir}/login.defs
114
115 # Use proper encryption for passwords
116 sed -i 's/^#ENCRYPT_METHOD.*$/ENCRYPT_METHOD SHA512/' ${D}${sysconfdir}/login.defs
117
118 # Now we don't have a mail system. Disable mail creation for now.
119 sed -i 's:/bin/bash:/bin/sh:g' ${D}${sysconfdir}/default/useradd
120 sed -i '/^CREATE_MAIL_SPOOL/ s:^:#:' ${D}${sysconfdir}/default/useradd
121
122 # Use users group by default
123 sed -i 's,^GROUP=1000,GROUP=100,g' ${D}${sysconfdir}/default/useradd
124}
125
126do_install_append() {
127 # Ensure that the image has as a /var/spool/mail dir so shadow can
128 # put mailboxes there if the user reconfigures shadow to its
129 # defaults (see sed below).
Brad Bishopd5ae7d92018-06-14 09:52:03 -0700130 install -m 0775 -d ${D}${localstatedir}/spool/mail
131 chown root:mail ${D}${localstatedir}/spool/mail
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500132
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
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400140 install -d ${D}${sbindir} ${D}${base_sbindir} ${D}${base_bindir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500141
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"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400193pkg_postinst_${PN}_class-target () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500194 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}