blob: ce3ce627156931e36a10fc77b57009d5f47312fd [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"
Andrew Geissler595f6302022-01-24 19:11:47 +00006LICENSE = "BSD-3-Clause"
7LIC_FILES_CHKSUM = "file://COPYING;md5=c9a450b7be84eac23e6353efecb60b5b \
8 file://src/passwd.c;beginline=2;endline=30;md5=758c26751513b6795395275969dd3be1 \
9 "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010
Brad Bishop316dfdd2018-06-25 12:45:53 -040011DEPENDS = "virtual/crypt"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050012
Andrew Geissler87f5cff2022-09-30 13:13:31 -050013GITHUB_BASE_URI = "https://github.com/shadow-maint/shadow/releases"
14SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/${BP}.tar.gz \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015 ${@bb.utils.contains('PACKAGECONFIG', 'pam', '${PAM_SRC_URI}', '', d)} \
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050016 file://useradd \
Patrick Williams8e7b46e2023-05-01 14:19:06 -050017 file://0001-Fix-can-not-print-full-login.patch \
18 file://CVE-2023-29383.patch \
19 file://0001-Overhaul-valid_field.patch \
Patrick Williamsda295312023-12-05 16:48:56 -060020 file://CVE-2023-4641.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021 "
22
Patrick Williams213cb262021-08-07 19:21:33 -050023SRC_URI:append:class-target = " \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 file://login_defs_pam.sed \
25 file://shadow-update-pam-conf.patch \
26 "
27
Patrick Williams213cb262021-08-07 19:21:33 -050028SRC_URI:append:class-native = " \
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 file://commonio.c-fix-unexpected-open-failure-in-chroot-env.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031 "
Patrick Williams213cb262021-08-07 19:21:33 -050032SRC_URI:append:class-nativesdk = " \
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 "
Andrew Geissler517393d2023-01-13 08:55:19 -060035SRC_URI[sha256sum] = "813057047499c7fe81108adcf0cffa3ad4ec75e19a80151f9cbaa458ff2e86cd"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037
38# Additional Policy files for PAM
39PAM_SRC_URI = "file://pam.d/chfn \
40 file://pam.d/chpasswd \
41 file://pam.d/chsh \
42 file://pam.d/login \
43 file://pam.d/newusers \
44 file://pam.d/passwd \
45 file://pam.d/su"
46
Andrew Geissler87f5cff2022-09-30 13:13:31 -050047inherit autotools gettext github-releases
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048
Brad Bishope2d5b612018-11-23 10:55:50 +130049export CONFIG_SHELL="/bin/sh"
50
Patrick Williams0ca19cc2021-08-16 14:03:13 -050051EXTRA_OECONF += "--without-libcrack \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052 --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 = ""
Patrick Williams213cb262021-08-07 19:21:33 -050058NSCDOPT:class-native = "--without-nscd"
59NSCDOPT:class-nativesdk = "--without-nscd"
60NSCDOPT: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 \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050069 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)}"
Patrick Williams213cb262021-08-07 19:21:33 -050076PACKAGECONFIG:class-native ??= "${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
77PACKAGECONFIG:class-nativesdk = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078PACKAGECONFIG[pam] = "--with-libpam,--without-libpam,libpam,${PAM_PLUGINS}"
79PACKAGECONFIG[attr] = "--with-attr,--without-attr,attr"
80PACKAGECONFIG[acl] = "--with-acl,--without-acl,acl"
Patrick Williams0ca19cc2021-08-16 14:03:13 -050081PACKAGECONFIG[audit] = "--with-audit,--without-audit,audit"
82PACKAGECONFIG[selinux] = "--with-selinux,--without-selinux,libselinux libsemanage"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083
Patrick Williams213cb262021-08-07 19:21:33 -050084RDEPENDS:${PN} = "shadow-securetty \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050085 base-passwd \
86 util-linux-sulogin"
Patrick Williams213cb262021-08-07 19:21:33 -050087RDEPENDS:${PN}:class-native = ""
88RDEPENDS:${PN}:class-nativesdk = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050089
90do_install() {
91 oe_runmake DESTDIR="${D}" sbindir="${base_sbindir}" usbindir="${sbindir}" install
92
93 # Info dir listing isn't interesting at this point so remove it if it exists.
94 if [ -e "${D}${infodir}/dir" ]; then
95 rm -f ${D}${infodir}/dir
96 fi
97
98 # Enable CREATE_HOME by default.
99 sed -i 's/#CREATE_HOME/CREATE_HOME/g' ${D}${sysconfdir}/login.defs
100
101 # As we are on an embedded system, ensure the users mailbox is in
102 # ~/ not /var/spool/mail by default, as who knows where or how big
103 # /var is. The system MDA will set this later anyway.
104 sed -i 's/MAIL_DIR/#MAIL_DIR/g' ${D}${sysconfdir}/login.defs
105 sed -i 's/#MAIL_FILE/MAIL_FILE/g' ${D}${sysconfdir}/login.defs
106
107 # Disable checking emails.
108 sed -i 's/MAIL_CHECK_ENAB/#MAIL_CHECK_ENAB/g' ${D}${sysconfdir}/login.defs
109
110 # Comment out SU_NAME to work correctly with busybox
111 # See Bug#5359 and Bug#7173
112 sed -i 's:^SU_NAME:#SU_NAME:g' ${D}${sysconfdir}/login.defs
113
114 # Use proper encryption for passwords
115 sed -i 's/^#ENCRYPT_METHOD.*$/ENCRYPT_METHOD SHA512/' ${D}${sysconfdir}/login.defs
116
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500117 install -d ${D}${sysconfdir}/default
118 install -m 0644 ${WORKDIR}/useradd ${D}${sysconfdir}/default
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500119}
120
Patrick Williams213cb262021-08-07 19:21:33 -0500121do_install:append() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500122 # Ensure that the image has as a /var/spool/mail dir so shadow can
123 # put mailboxes there if the user reconfigures shadow to its
124 # defaults (see sed below).
Brad Bishopd5ae7d92018-06-14 09:52:03 -0700125 install -m 0775 -d ${D}${localstatedir}/spool/mail
126 chown root:mail ${D}${localstatedir}/spool/mail
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500127
128 if [ -e ${WORKDIR}/pam.d ]; then
129 install -d ${D}${sysconfdir}/pam.d/
130 install -m 0644 ${WORKDIR}/pam.d/* ${D}${sysconfdir}/pam.d/
131 # Remove defaults that are not used when supporting PAM.
132 sed -i -f ${WORKDIR}/login_defs_pam.sed ${D}${sysconfdir}/login.defs
133 fi
134
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400135 install -d ${D}${sbindir} ${D}${base_sbindir} ${D}${base_bindir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500136
137 # Move binaries to the locations we want
138 rm ${D}${sbindir}/vigr
139 ln -sf vipw.${BPN} ${D}${base_sbindir}/vigr
140 if [ "${sbindir}" != "${base_sbindir}" ]; then
141 mv ${D}${sbindir}/vipw ${D}${base_sbindir}/vipw
142 fi
143 if [ "${bindir}" != "${base_bindir}" ]; then
144 mv ${D}${bindir}/login ${D}${base_bindir}/login
145 mv ${D}${bindir}/su ${D}${base_bindir}/su
146 fi
147
148 # Handle link properly after rename, otherwise missing files would
149 # lead rpm failed dependencies.
150 ln -sf newgrp.${BPN} ${D}${bindir}/sg
Patrick Williams92b42cb2022-09-03 06:53:57 -0500151
152 # usermod requires the subuid/subgid files to be in place before being
153 # able to use the -v/-V flags otherwise it fails:
154 # usermod: /etc/subuid does not exist, you cannot use the flags -v or -V
155 install -d ${D}${sysconfdir}
156 touch ${D}${sysconfdir}/subuid
157 touch ${D}${sysconfdir}/subgid
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500158}
159
160PACKAGES =+ "${PN}-base"
Patrick Williams213cb262021-08-07 19:21:33 -0500161FILES:${PN}-base = "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500162 ${base_bindir}/login.shadow \
163 ${base_bindir}/su.shadow \
164 ${bindir}/sg \
165 ${bindir}/newgrp.shadow \
166 ${bindir}/groups.shadow \
167 ${sysconfdir}/pam.d/login \
168 ${sysconfdir}/pam.d/su \
169 ${sysconfdir}/login.defs \
170"
Patrick Williams213cb262021-08-07 19:21:33 -0500171RDEPENDS:${PN} += "${PN}-base"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500172
173inherit update-alternatives
174
175ALTERNATIVE_PRIORITY = "200"
176
Patrick Williams213cb262021-08-07 19:21:33 -0500177ALTERNATIVE:${PN} = "passwd chfn chsh chpasswd vipw vigr nologin"
Andrew Geissler5f350902021-07-23 13:09:54 -0400178ALTERNATIVE_LINK_NAME[chfn] = "${bindir}/chfn"
179ALTERNATIVE_LINK_NAME[chsh] = "${bindir}/chsh"
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
Patrick Williams213cb262021-08-07 19:21:33 -0500185ALTERNATIVE:${PN}-base = "newgrp groups login su"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500186ALTERNATIVE_LINK_NAME[login] = "${base_bindir}/login"
187ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su"
188
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500189PACKAGE_WRITE_DEPS += "shadow-native"
Patrick Williams213cb262021-08-07 19:21:33 -0500190pkg_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}