blob: 16b99a0b60e8d0237ad156479787992eda485f49 [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 \
Patrick Williams705982a2024-01-12 09:51:57 -06008 file://src/passwd.c;beginline=2;endline=7;md5=67bcf314687820b2f010d4863fce3fc5 \
Andrew Geissler595f6302022-01-24 19:11:47 +00009 "
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 Williamsc124f4f2015-09-15 14:41:29 -050017 "
18
Patrick Williams213cb262021-08-07 19:21:33 -050019SRC_URI:append:class-target = " \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020 file://login_defs_pam.sed \
21 file://shadow-update-pam-conf.patch \
22 "
23
Patrick Williams213cb262021-08-07 19:21:33 -050024SRC_URI:append:class-native = " \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025 file://commonio.c-fix-unexpected-open-failure-in-chroot-env.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026 "
Patrick Williams705982a2024-01-12 09:51:57 -060027SRC_URI[sha256sum] = "a305edf5d19bddbdf5e836d2d609fa8bff2d35458819de4d9f06306a1cf24342"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028
29# Additional Policy files for PAM
30PAM_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 Williams705982a2024-01-12 09:51:57 -060038inherit autotools gettext github-releases pkgconfig
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039
Brad Bishope2d5b612018-11-23 10:55:50 +130040export CONFIG_SHELL="/bin/sh"
41
Patrick Williams0ca19cc2021-08-16 14:03:13 -050042EXTRA_OECONF += "--without-libcrack \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050043 --with-group-name-max-length=24 \
44 --enable-subordinate-ids=yes \
Andrew Geissler82c905d2020-04-13 13:39:40 -050045 --without-sssd \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050046 ${NSCDOPT}"
47
Patrick Williams705982a2024-01-12 09:51:57 -060048CFLAGS:append:libc-musl = " -DLIBBSD_OVERLAY"
49
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050NSCDOPT = ""
Patrick Williams213cb262021-08-07 19:21:33 -050051NSCDOPT:class-native = "--without-nscd"
52NSCDOPT:class-nativesdk = "--without-nscd"
53NSCDOPT:libc-glibc = "--with-nscd"
Brad Bishopf3f93bb2019-10-16 14:33:32 -040054
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055PAM_PLUGINS = "libpam-runtime \
56 pam-plugin-faildelay \
57 pam-plugin-securetty \
58 pam-plugin-nologin \
59 pam-plugin-env \
60 pam-plugin-group \
61 pam-plugin-limits \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062 pam-plugin-motd \
63 pam-plugin-mail \
64 pam-plugin-shells \
65 pam-plugin-rootok"
66
Brad Bishop6e60e8b2018-02-01 10:27:11 -050067PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \
68 ${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
Patrick Williams705982a2024-01-12 09:51:57 -060069PACKAGECONFIG:class-native ??= "${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)} libbsd"
Patrick Williams213cb262021-08-07 19:21:33 -050070PACKAGECONFIG:class-nativesdk = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050071PACKAGECONFIG[pam] = "--with-libpam,--without-libpam,libpam,${PAM_PLUGINS}"
72PACKAGECONFIG[attr] = "--with-attr,--without-attr,attr"
73PACKAGECONFIG[acl] = "--with-acl,--without-acl,acl"
Patrick Williams0ca19cc2021-08-16 14:03:13 -050074PACKAGECONFIG[audit] = "--with-audit,--without-audit,audit"
75PACKAGECONFIG[selinux] = "--with-selinux,--without-selinux,libselinux libsemanage"
Patrick Williams705982a2024-01-12 09:51:57 -060076PACKAGECONFIG[libbsd] = "--with-libbsd,--without-libbsd,libbsd"
Patrick Williams73bd93f2024-02-20 08:07:48 -060077PACKAGECONFIG[logind] = "--enable-logind,--disable-logind,systemd"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078
Patrick Williams213cb262021-08-07 19:21:33 -050079RDEPENDS:${PN} = "shadow-securetty \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050080 base-passwd \
81 util-linux-sulogin"
Patrick Williams213cb262021-08-07 19:21:33 -050082RDEPENDS:${PN}:class-native = ""
83RDEPENDS:${PN}:class-nativesdk = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084
85do_install() {
86 oe_runmake DESTDIR="${D}" sbindir="${base_sbindir}" usbindir="${sbindir}" install
87
88 # Info dir listing isn't interesting at this point so remove it if it exists.
89 if [ -e "${D}${infodir}/dir" ]; then
90 rm -f ${D}${infodir}/dir
91 fi
92
93 # Enable CREATE_HOME by default.
94 sed -i 's/#CREATE_HOME/CREATE_HOME/g' ${D}${sysconfdir}/login.defs
95
96 # As we are on an embedded system, ensure the users mailbox is in
97 # ~/ not /var/spool/mail by default, as who knows where or how big
98 # /var is. The system MDA will set this later anyway.
99 sed -i 's/MAIL_DIR/#MAIL_DIR/g' ${D}${sysconfdir}/login.defs
100 sed -i 's/#MAIL_FILE/MAIL_FILE/g' ${D}${sysconfdir}/login.defs
101
102 # Disable checking emails.
103 sed -i 's/MAIL_CHECK_ENAB/#MAIL_CHECK_ENAB/g' ${D}${sysconfdir}/login.defs
104
105 # Comment out SU_NAME to work correctly with busybox
106 # See Bug#5359 and Bug#7173
107 sed -i 's:^SU_NAME:#SU_NAME:g' ${D}${sysconfdir}/login.defs
108
109 # Use proper encryption for passwords
110 sed -i 's/^#ENCRYPT_METHOD.*$/ENCRYPT_METHOD SHA512/' ${D}${sysconfdir}/login.defs
111
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500112 install -d ${D}${sysconfdir}/default
113 install -m 0644 ${WORKDIR}/useradd ${D}${sysconfdir}/default
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500114}
115
Patrick Williams213cb262021-08-07 19:21:33 -0500116do_install:append() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117 # Ensure that the image has as a /var/spool/mail dir so shadow can
118 # put mailboxes there if the user reconfigures shadow to its
119 # defaults (see sed below).
Brad Bishopd5ae7d92018-06-14 09:52:03 -0700120 install -m 0775 -d ${D}${localstatedir}/spool/mail
121 chown root:mail ${D}${localstatedir}/spool/mail
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500122
123 if [ -e ${WORKDIR}/pam.d ]; then
124 install -d ${D}${sysconfdir}/pam.d/
125 install -m 0644 ${WORKDIR}/pam.d/* ${D}${sysconfdir}/pam.d/
126 # Remove defaults that are not used when supporting PAM.
127 sed -i -f ${WORKDIR}/login_defs_pam.sed ${D}${sysconfdir}/login.defs
128 fi
129
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400130 install -d ${D}${sbindir} ${D}${base_sbindir} ${D}${base_bindir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500131
132 # Move binaries to the locations we want
133 rm ${D}${sbindir}/vigr
134 ln -sf vipw.${BPN} ${D}${base_sbindir}/vigr
135 if [ "${sbindir}" != "${base_sbindir}" ]; then
136 mv ${D}${sbindir}/vipw ${D}${base_sbindir}/vipw
137 fi
138 if [ "${bindir}" != "${base_bindir}" ]; then
139 mv ${D}${bindir}/login ${D}${base_bindir}/login
140 mv ${D}${bindir}/su ${D}${base_bindir}/su
141 fi
142
143 # Handle link properly after rename, otherwise missing files would
144 # lead rpm failed dependencies.
145 ln -sf newgrp.${BPN} ${D}${bindir}/sg
Patrick Williams92b42cb2022-09-03 06:53:57 -0500146
147 # usermod requires the subuid/subgid files to be in place before being
148 # able to use the -v/-V flags otherwise it fails:
149 # usermod: /etc/subuid does not exist, you cannot use the flags -v or -V
150 install -d ${D}${sysconfdir}
151 touch ${D}${sysconfdir}/subuid
152 touch ${D}${sysconfdir}/subgid
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500153}
154
Patrick Williamsf52e3dd2024-01-26 13:04:43 -0600155# Make executables look for dynamically linked libraries in a custom location, and install
156# the needed libraries there. That way we can use them from sstate
157# in setscene tasks without worrying about the dependency libraries being available.
158do_install:append:class-native() {
159 binaries=$(find ${D}${base_bindir}/ ${D}${base_sbindir}/ ${D}${bindir}/ ${D}${sbindir}/ -executable -type f)
160 chrpath -k -r ${STAGING_DIR_NATIVE}/lib-shadow-deps $binaries
161 mkdir -p ${D}${STAGING_DIR_NATIVE}/lib-shadow-deps/
162 install ${STAGING_LIBDIR_NATIVE}/libattr.so.* ${STAGING_LIBDIR_NATIVE}/libbsd.so.* ${STAGING_LIBDIR_NATIVE}/libmd.so.* ${D}${STAGING_DIR_NATIVE}/lib-shadow-deps/
163 install ${D}${libdir}/*.so.* ${D}${STAGING_DIR_NATIVE}/lib-shadow-deps/
164}
165
166SYSROOT_DIRS:append:class-native = " ${STAGING_DIR_NATIVE}/lib-shadow-deps/"
167INSANE_SKIP:${PN}:class-native = "already-stripped"
168
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500169PACKAGES =+ "${PN}-base"
Patrick Williams213cb262021-08-07 19:21:33 -0500170FILES:${PN}-base = "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171 ${base_bindir}/login.shadow \
172 ${base_bindir}/su.shadow \
173 ${bindir}/sg \
174 ${bindir}/newgrp.shadow \
175 ${bindir}/groups.shadow \
176 ${sysconfdir}/pam.d/login \
177 ${sysconfdir}/pam.d/su \
178 ${sysconfdir}/login.defs \
179"
Patrick Williams213cb262021-08-07 19:21:33 -0500180RDEPENDS:${PN} += "${PN}-base"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500181
182inherit update-alternatives
183
184ALTERNATIVE_PRIORITY = "200"
185
Patrick Williams213cb262021-08-07 19:21:33 -0500186ALTERNATIVE:${PN} = "passwd chfn chsh chpasswd vipw vigr nologin"
Andrew Geissler5f350902021-07-23 13:09:54 -0400187ALTERNATIVE_LINK_NAME[chfn] = "${bindir}/chfn"
188ALTERNATIVE_LINK_NAME[chsh] = "${bindir}/chsh"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500189ALTERNATIVE_LINK_NAME[chpasswd] = "${sbindir}/chpasswd"
190ALTERNATIVE_LINK_NAME[vipw] = "${base_sbindir}/vipw"
191ALTERNATIVE_LINK_NAME[vigr] = "${base_sbindir}/vigr"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500192ALTERNATIVE_LINK_NAME[nologin] = "${base_sbindir}/nologin"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500193
Patrick Williams213cb262021-08-07 19:21:33 -0500194ALTERNATIVE:${PN}-base = "newgrp groups login su"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500195ALTERNATIVE_LINK_NAME[login] = "${base_bindir}/login"
196ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su"
197
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500198PACKAGE_WRITE_DEPS += "shadow-native"
Patrick Williams213cb262021-08-07 19:21:33 -0500199pkg_postinst:${PN}:class-target () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500200 if [ "x$D" != "x" ]; then
201 rootarg="--root $D"
202 else
203 rootarg=""
204 fi
205
206 pwconv $rootarg || exit 1
207 grpconv $rootarg || exit 1
208}