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 \ |
Patrick Williams | 705982a | 2024-01-12 09:51:57 -0600 | [diff] [blame] | 8 | file://src/passwd.c;beginline=2;endline=7;md5=67bcf314687820b2f010d4863fce3fc5 \ |
Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 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 | |
Andrew Geissler | 87f5cff | 2022-09-30 13:13:31 -0500 | [diff] [blame] | 13 | GITHUB_BASE_URI = "https://github.com/shadow-maint/shadow/releases" |
| 14 | SRC_URI = "${GITHUB_BASE_URI}/download/${PV}/${BP}.tar.gz \ |
Patrick Williams | 03514f1 | 2024-04-05 07:04:11 -0500 | [diff] [blame] | 15 | file://0001-lib-copydir-copy_entry-use-temporary-stat-buffer.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 | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 26 | file://commonio.c-fix-unexpected-open-failure-in-chroot-env.patch \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 27 | " |
Patrick Williams | 44b3caf | 2024-04-12 16:51:14 -0500 | [diff] [blame] | 28 | SRC_URI[sha256sum] = "377fe0d7c1a0aa5e3514c08fdf5ddc70c9dcbb391678c2134445ed97326bcc26" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 29 | |
| 30 | # Additional Policy files for PAM |
| 31 | PAM_SRC_URI = "file://pam.d/chfn \ |
| 32 | file://pam.d/chpasswd \ |
| 33 | file://pam.d/chsh \ |
| 34 | file://pam.d/login \ |
| 35 | file://pam.d/newusers \ |
| 36 | file://pam.d/passwd \ |
| 37 | file://pam.d/su" |
| 38 | |
Patrick Williams | 705982a | 2024-01-12 09:51:57 -0600 | [diff] [blame] | 39 | inherit autotools gettext github-releases pkgconfig |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 40 | |
Brad Bishop | e2d5b61 | 2018-11-23 10:55:50 +1300 | [diff] [blame] | 41 | export CONFIG_SHELL="/bin/sh" |
| 42 | |
Patrick Williams | 44b3caf | 2024-04-12 16:51:14 -0500 | [diff] [blame] | 43 | EXTRA_OECONF += " \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 44 | --with-group-name-max-length=24 \ |
| 45 | --enable-subordinate-ids=yes \ |
Andrew Geissler | 82c905d | 2020-04-13 13:39:40 -0500 | [diff] [blame] | 46 | --without-sssd \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 47 | ${NSCDOPT}" |
| 48 | |
Patrick Williams | 705982a | 2024-01-12 09:51:57 -0600 | [diff] [blame] | 49 | CFLAGS:append:libc-musl = " -DLIBBSD_OVERLAY" |
| 50 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 51 | NSCDOPT = "" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 52 | NSCDOPT:class-native = "--without-nscd" |
| 53 | NSCDOPT:class-nativesdk = "--without-nscd" |
| 54 | NSCDOPT:libc-glibc = "--with-nscd" |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 55 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 56 | PAM_PLUGINS = "libpam-runtime \ |
| 57 | pam-plugin-faildelay \ |
| 58 | pam-plugin-securetty \ |
| 59 | pam-plugin-nologin \ |
| 60 | pam-plugin-env \ |
| 61 | pam-plugin-group \ |
| 62 | pam-plugin-limits \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 63 | pam-plugin-motd \ |
| 64 | pam-plugin-mail \ |
| 65 | pam-plugin-shells \ |
| 66 | pam-plugin-rootok" |
| 67 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 68 | PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \ |
| 69 | ${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}" |
Patrick Williams | 705982a | 2024-01-12 09:51:57 -0600 | [diff] [blame] | 70 | PACKAGECONFIG:class-native ??= "${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)} libbsd" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 71 | PACKAGECONFIG:class-nativesdk = "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 72 | PACKAGECONFIG[pam] = "--with-libpam,--without-libpam,libpam,${PAM_PLUGINS}" |
| 73 | PACKAGECONFIG[attr] = "--with-attr,--without-attr,attr" |
| 74 | PACKAGECONFIG[acl] = "--with-acl,--without-acl,acl" |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 75 | PACKAGECONFIG[audit] = "--with-audit,--without-audit,audit" |
| 76 | PACKAGECONFIG[selinux] = "--with-selinux,--without-selinux,libselinux libsemanage" |
Patrick Williams | 705982a | 2024-01-12 09:51:57 -0600 | [diff] [blame] | 77 | PACKAGECONFIG[libbsd] = "--with-libbsd,--without-libbsd,libbsd" |
Patrick Williams | 73bd93f | 2024-02-20 08:07:48 -0600 | [diff] [blame] | 78 | PACKAGECONFIG[logind] = "--enable-logind,--disable-logind,systemd" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 79 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 80 | RDEPENDS:${PN} = "shadow-securetty \ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | base-passwd \ |
| 82 | util-linux-sulogin" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 83 | RDEPENDS:${PN}:class-native = "" |
| 84 | RDEPENDS:${PN}:class-nativesdk = "" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 85 | |
| 86 | do_install() { |
| 87 | oe_runmake DESTDIR="${D}" sbindir="${base_sbindir}" usbindir="${sbindir}" install |
| 88 | |
| 89 | # Info dir listing isn't interesting at this point so remove it if it exists. |
| 90 | if [ -e "${D}${infodir}/dir" ]; then |
| 91 | rm -f ${D}${infodir}/dir |
| 92 | fi |
| 93 | |
| 94 | # Enable CREATE_HOME by default. |
| 95 | sed -i 's/#CREATE_HOME/CREATE_HOME/g' ${D}${sysconfdir}/login.defs |
| 96 | |
| 97 | # As we are on an embedded system, ensure the users mailbox is in |
| 98 | # ~/ not /var/spool/mail by default, as who knows where or how big |
| 99 | # /var is. The system MDA will set this later anyway. |
| 100 | sed -i 's/MAIL_DIR/#MAIL_DIR/g' ${D}${sysconfdir}/login.defs |
| 101 | sed -i 's/#MAIL_FILE/MAIL_FILE/g' ${D}${sysconfdir}/login.defs |
| 102 | |
| 103 | # Disable checking emails. |
| 104 | sed -i 's/MAIL_CHECK_ENAB/#MAIL_CHECK_ENAB/g' ${D}${sysconfdir}/login.defs |
| 105 | |
| 106 | # Comment out SU_NAME to work correctly with busybox |
| 107 | # See Bug#5359 and Bug#7173 |
| 108 | sed -i 's:^SU_NAME:#SU_NAME:g' ${D}${sysconfdir}/login.defs |
| 109 | |
| 110 | # Use proper encryption for passwords |
| 111 | sed -i 's/^#ENCRYPT_METHOD.*$/ENCRYPT_METHOD SHA512/' ${D}${sysconfdir}/login.defs |
| 112 | |
Andrew Geissler | d159c7f | 2021-09-02 21:05:58 -0500 | [diff] [blame] | 113 | install -d ${D}${sysconfdir}/default |
| 114 | install -m 0644 ${WORKDIR}/useradd ${D}${sysconfdir}/default |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 115 | } |
| 116 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 117 | do_install:append() { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 118 | # Ensure that the image has as a /var/spool/mail dir so shadow can |
| 119 | # put mailboxes there if the user reconfigures shadow to its |
| 120 | # defaults (see sed below). |
Brad Bishop | d5ae7d9 | 2018-06-14 09:52:03 -0700 | [diff] [blame] | 121 | install -m 0775 -d ${D}${localstatedir}/spool/mail |
| 122 | chown root:mail ${D}${localstatedir}/spool/mail |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 123 | |
| 124 | if [ -e ${WORKDIR}/pam.d ]; then |
| 125 | install -d ${D}${sysconfdir}/pam.d/ |
| 126 | install -m 0644 ${WORKDIR}/pam.d/* ${D}${sysconfdir}/pam.d/ |
| 127 | # Remove defaults that are not used when supporting PAM. |
| 128 | sed -i -f ${WORKDIR}/login_defs_pam.sed ${D}${sysconfdir}/login.defs |
| 129 | fi |
| 130 | |
Brad Bishop | f3f93bb | 2019-10-16 14:33:32 -0400 | [diff] [blame] | 131 | install -d ${D}${sbindir} ${D}${base_sbindir} ${D}${base_bindir} |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 132 | |
| 133 | # Move binaries to the locations we want |
| 134 | rm ${D}${sbindir}/vigr |
| 135 | ln -sf vipw.${BPN} ${D}${base_sbindir}/vigr |
| 136 | if [ "${sbindir}" != "${base_sbindir}" ]; then |
| 137 | mv ${D}${sbindir}/vipw ${D}${base_sbindir}/vipw |
| 138 | fi |
| 139 | if [ "${bindir}" != "${base_bindir}" ]; then |
| 140 | mv ${D}${bindir}/login ${D}${base_bindir}/login |
| 141 | mv ${D}${bindir}/su ${D}${base_bindir}/su |
| 142 | fi |
| 143 | |
| 144 | # Handle link properly after rename, otherwise missing files would |
| 145 | # lead rpm failed dependencies. |
| 146 | ln -sf newgrp.${BPN} ${D}${bindir}/sg |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 147 | |
| 148 | # usermod requires the subuid/subgid files to be in place before being |
| 149 | # able to use the -v/-V flags otherwise it fails: |
| 150 | # usermod: /etc/subuid does not exist, you cannot use the flags -v or -V |
| 151 | install -d ${D}${sysconfdir} |
| 152 | touch ${D}${sysconfdir}/subuid |
| 153 | touch ${D}${sysconfdir}/subgid |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 154 | } |
| 155 | |
Patrick Williams | f52e3dd | 2024-01-26 13:04:43 -0600 | [diff] [blame] | 156 | # Make executables look for dynamically linked libraries in a custom location, and install |
| 157 | # the needed libraries there. That way we can use them from sstate |
| 158 | # in setscene tasks without worrying about the dependency libraries being available. |
| 159 | do_install:append:class-native() { |
| 160 | binaries=$(find ${D}${base_bindir}/ ${D}${base_sbindir}/ ${D}${bindir}/ ${D}${sbindir}/ -executable -type f) |
| 161 | chrpath -k -r ${STAGING_DIR_NATIVE}/lib-shadow-deps $binaries |
| 162 | mkdir -p ${D}${STAGING_DIR_NATIVE}/lib-shadow-deps/ |
Patrick Williams | 03514f1 | 2024-04-05 07:04:11 -0500 | [diff] [blame] | 163 | libattr=${@bb.utils.contains('DISTRO_FEATURES', 'xattr', "${STAGING_LIBDIR_NATIVE}/libattr.so.*", '', d)} |
| 164 | install $libattr ${STAGING_LIBDIR_NATIVE}/libbsd.so.* ${STAGING_LIBDIR_NATIVE}/libmd.so.* ${D}${STAGING_DIR_NATIVE}/lib-shadow-deps/ |
Patrick Williams | f52e3dd | 2024-01-26 13:04:43 -0600 | [diff] [blame] | 165 | install ${D}${libdir}/*.so.* ${D}${STAGING_DIR_NATIVE}/lib-shadow-deps/ |
| 166 | } |
| 167 | |
| 168 | SYSROOT_DIRS:append:class-native = " ${STAGING_DIR_NATIVE}/lib-shadow-deps/" |
| 169 | INSANE_SKIP:${PN}:class-native = "already-stripped" |
| 170 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 171 | PACKAGES =+ "${PN}-base" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 172 | FILES:${PN}-base = "\ |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 173 | ${base_bindir}/login.shadow \ |
| 174 | ${base_bindir}/su.shadow \ |
| 175 | ${bindir}/sg \ |
| 176 | ${bindir}/newgrp.shadow \ |
| 177 | ${bindir}/groups.shadow \ |
| 178 | ${sysconfdir}/pam.d/login \ |
| 179 | ${sysconfdir}/pam.d/su \ |
| 180 | ${sysconfdir}/login.defs \ |
| 181 | " |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 182 | RDEPENDS:${PN} += "${PN}-base" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 183 | |
| 184 | inherit update-alternatives |
| 185 | |
| 186 | ALTERNATIVE_PRIORITY = "200" |
| 187 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 188 | ALTERNATIVE:${PN} = "passwd chfn chsh chpasswd vipw vigr nologin" |
Andrew Geissler | 5f35090 | 2021-07-23 13:09:54 -0400 | [diff] [blame] | 189 | ALTERNATIVE_LINK_NAME[chfn] = "${bindir}/chfn" |
| 190 | ALTERNATIVE_LINK_NAME[chsh] = "${bindir}/chsh" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 191 | ALTERNATIVE_LINK_NAME[chpasswd] = "${sbindir}/chpasswd" |
| 192 | ALTERNATIVE_LINK_NAME[vipw] = "${base_sbindir}/vipw" |
| 193 | ALTERNATIVE_LINK_NAME[vigr] = "${base_sbindir}/vigr" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 194 | ALTERNATIVE_LINK_NAME[nologin] = "${base_sbindir}/nologin" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 195 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 196 | ALTERNATIVE:${PN}-base = "newgrp groups login su" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 197 | ALTERNATIVE_LINK_NAME[login] = "${base_bindir}/login" |
| 198 | ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su" |
| 199 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 200 | PACKAGE_WRITE_DEPS += "shadow-native" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 201 | pkg_postinst:${PN}:class-target () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 202 | if [ "x$D" != "x" ]; then |
| 203 | rootarg="--root $D" |
| 204 | else |
| 205 | rootarg="" |
| 206 | fi |
| 207 | |
| 208 | pwconv $rootarg || exit 1 |
| 209 | grpconv $rootarg || exit 1 |
| 210 | } |