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