Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | SUMMARY = "Tools to change and administer password and group data" |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 2 | HOMEPAGE = "http://github.com/shadow-maint/shadow" |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 3 | DESCRIPTION = "${SUMMARY}" |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 4 | BUGTRACKER = "http://github.com/shadow-maint/shadow/issues" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 5 | SECTION = "base/utils" |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 6 | LICENSE = "BSD-3-Clause" |
| 7 | LIC_FILES_CHKSUM = "file://COPYING;md5=c9a450b7be84eac23e6353efecb60b5b \ |
| 8 | file://src/passwd.c;beginline=2;endline=30;md5=758c26751513b6795395275969dd3be1 \ |
| 9 | " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 10 | |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 11 | DEPENDS = "virtual/crypt" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 12 | |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 13 | UPSTREAM_CHECK_URI = "https://github.com/shadow-maint/shadow/releases" |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 14 | SRC_URI = "https://github.com/shadow-maint/shadow/releases/download/${PV}/${BP}.tar.gz \ |
| 15 | file://0001-shadow-use-relaxed-usernames.patch \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | ${@bb.utils.contains('PACKAGECONFIG', 'pam', '${PAM_SRC_URI}', '', d)} \ |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 17 | file://useradd \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 18 | " |
| 19 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 20 | SRC_URI:append:class-target = " \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 21 | file://login_defs_pam.sed \ |
| 22 | file://shadow-update-pam-conf.patch \ |
| 23 | " |
| 24 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 25 | SRC_URI:append:class-native = " \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 26 | file://0001-Disable-use-of-syslog-for-sysroot.patch \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 27 | file://commonio.c-fix-unexpected-open-failure-in-chroot-env.patch \ |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 28 | file://0001-Drop-nsswitch.conf-message-when-not-in-place-eg.-musl.patch \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 29 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 30 | SRC_URI:append:class-nativesdk = " \ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 31 | file://0001-Disable-use-of-syslog-for-sysroot.patch \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 32 | " |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 33 | SRC_URI[sha256sum] = "9fdb73b5d2b44e8ba9fcee1b4493ac75dd5040bda35b9ac8b06570cd192e7ee3" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 35 | |
| 36 | # Additional Policy files for PAM |
| 37 | PAM_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 | |
| 45 | inherit autotools gettext |
| 46 | |
Brad Bishop | e2d5b61 | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 47 | export CONFIG_SHELL="/bin/sh" |
| 48 | |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 49 | EXTRA_OECONF += "--without-libcrack \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 50 | --with-group-name-max-length=24 \ |
| 51 | --enable-subordinate-ids=yes \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 52 | --without-sssd \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 53 | ${NSCDOPT}" |
| 54 | |
| 55 | NSCDOPT = "" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 56 | NSCDOPT:class-native = "--without-nscd" |
| 57 | NSCDOPT:class-nativesdk = "--without-nscd" |
| 58 | NSCDOPT:libc-glibc = "--with-nscd" |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 59 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 60 | PAM_PLUGINS = "libpam-runtime \ |
| 61 | pam-plugin-faildelay \ |
| 62 | pam-plugin-securetty \ |
| 63 | pam-plugin-nologin \ |
| 64 | pam-plugin-env \ |
| 65 | pam-plugin-group \ |
| 66 | pam-plugin-limits \ |
| 67 | pam-plugin-lastlog \ |
| 68 | pam-plugin-motd \ |
| 69 | pam-plugin-mail \ |
| 70 | pam-plugin-shells \ |
| 71 | pam-plugin-rootok" |
| 72 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 73 | PAM_PLUGINS:remove:libc-musl = "pam-plugin-lastlog" |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 74 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 75 | PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \ |
| 76 | ${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 77 | PACKAGECONFIG:class-native ??= "${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}" |
| 78 | PACKAGECONFIG:class-nativesdk = "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | PACKAGECONFIG[pam] = "--with-libpam,--without-libpam,libpam,${PAM_PLUGINS}" |
| 80 | PACKAGECONFIG[attr] = "--with-attr,--without-attr,attr" |
| 81 | PACKAGECONFIG[acl] = "--with-acl,--without-acl,acl" |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 82 | PACKAGECONFIG[audit] = "--with-audit,--without-audit,audit" |
| 83 | PACKAGECONFIG[selinux] = "--with-selinux,--without-selinux,libselinux libsemanage" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 84 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 85 | RDEPENDS:${PN} = "shadow-securetty \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 86 | base-passwd \ |
| 87 | util-linux-sulogin" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 88 | RDEPENDS:${PN}:class-native = "" |
| 89 | RDEPENDS:${PN}:class-nativesdk = "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 90 | |
| 91 | do_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 | |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 118 | install -d ${D}${sysconfdir}/default |
| 119 | install -m 0644 ${WORKDIR}/useradd ${D}${sysconfdir}/default |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 120 | } |
| 121 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 122 | do_install:append() { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 123 | # Ensure that the image has as a /var/spool/mail dir so shadow can |
| 124 | # put mailboxes there if the user reconfigures shadow to its |
| 125 | # defaults (see sed below). |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 126 | install -m 0775 -d ${D}${localstatedir}/spool/mail |
| 127 | chown root:mail ${D}${localstatedir}/spool/mail |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 128 | |
| 129 | if [ -e ${WORKDIR}/pam.d ]; then |
| 130 | install -d ${D}${sysconfdir}/pam.d/ |
| 131 | install -m 0644 ${WORKDIR}/pam.d/* ${D}${sysconfdir}/pam.d/ |
| 132 | # Remove defaults that are not used when supporting PAM. |
| 133 | sed -i -f ${WORKDIR}/login_defs_pam.sed ${D}${sysconfdir}/login.defs |
| 134 | fi |
| 135 | |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 136 | install -d ${D}${sbindir} ${D}${base_sbindir} ${D}${base_bindir} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 137 | |
| 138 | # Move binaries to the locations we want |
| 139 | rm ${D}${sbindir}/vigr |
| 140 | ln -sf vipw.${BPN} ${D}${base_sbindir}/vigr |
| 141 | if [ "${sbindir}" != "${base_sbindir}" ]; then |
| 142 | mv ${D}${sbindir}/vipw ${D}${base_sbindir}/vipw |
| 143 | fi |
| 144 | if [ "${bindir}" != "${base_bindir}" ]; then |
| 145 | mv ${D}${bindir}/login ${D}${base_bindir}/login |
| 146 | mv ${D}${bindir}/su ${D}${base_bindir}/su |
| 147 | fi |
| 148 | |
| 149 | # Handle link properly after rename, otherwise missing files would |
| 150 | # lead rpm failed dependencies. |
| 151 | ln -sf newgrp.${BPN} ${D}${bindir}/sg |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame^] | 152 | |
| 153 | # usermod requires the subuid/subgid files to be in place before being |
| 154 | # able to use the -v/-V flags otherwise it fails: |
| 155 | # usermod: /etc/subuid does not exist, you cannot use the flags -v or -V |
| 156 | install -d ${D}${sysconfdir} |
| 157 | touch ${D}${sysconfdir}/subuid |
| 158 | touch ${D}${sysconfdir}/subgid |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | PACKAGES =+ "${PN}-base" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 162 | FILES:${PN}-base = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 163 | ${base_bindir}/login.shadow \ |
| 164 | ${base_bindir}/su.shadow \ |
| 165 | ${bindir}/sg \ |
| 166 | ${bindir}/newgrp.shadow \ |
| 167 | ${bindir}/groups.shadow \ |
| 168 | ${sysconfdir}/pam.d/login \ |
| 169 | ${sysconfdir}/pam.d/su \ |
| 170 | ${sysconfdir}/login.defs \ |
| 171 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 172 | RDEPENDS:${PN} += "${PN}-base" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 173 | |
| 174 | inherit update-alternatives |
| 175 | |
| 176 | ALTERNATIVE_PRIORITY = "200" |
| 177 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 178 | ALTERNATIVE:${PN} = "passwd chfn chsh chpasswd vipw vigr nologin" |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 179 | ALTERNATIVE_LINK_NAME[chfn] = "${bindir}/chfn" |
| 180 | ALTERNATIVE_LINK_NAME[chsh] = "${bindir}/chsh" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 181 | ALTERNATIVE_LINK_NAME[chpasswd] = "${sbindir}/chpasswd" |
| 182 | ALTERNATIVE_LINK_NAME[vipw] = "${base_sbindir}/vipw" |
| 183 | ALTERNATIVE_LINK_NAME[vigr] = "${base_sbindir}/vigr" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 184 | ALTERNATIVE_LINK_NAME[nologin] = "${base_sbindir}/nologin" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 185 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 186 | ALTERNATIVE:${PN}-base = "newgrp groups login su" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 187 | ALTERNATIVE_LINK_NAME[login] = "${base_bindir}/login" |
| 188 | ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su" |
| 189 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 190 | PACKAGE_WRITE_DEPS += "shadow-native" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 191 | pkg_postinst:${PN}:class-target () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 192 | if [ "x$D" != "x" ]; then |
| 193 | rootarg="--root $D" |
| 194 | else |
| 195 | rootarg="" |
| 196 | fi |
| 197 | |
| 198 | pwconv $rootarg || exit 1 |
| 199 | grpconv $rootarg || exit 1 |
| 200 | } |