blob: 2c70a2d00e3872b7c07410440473be8b9d9fb837 [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 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 Williamsd8c66bc2016-06-20 12:57:21 -050025 file://0001-Disable-use-of-syslog-for-sysroot.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026 file://commonio.c-fix-unexpected-open-failure-in-chroot-env.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027 "
Patrick Williams213cb262021-08-07 19:21:33 -050028SRC_URI:append:class-nativesdk = " \
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 "
Andrew Geissler517393d2023-01-13 08:55:19 -060031SRC_URI[sha256sum] = "813057047499c7fe81108adcf0cffa3ad4ec75e19a80151f9cbaa458ff2e86cd"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033
34# Additional Policy files for PAM
35PAM_SRC_URI = "file://pam.d/chfn \
36 file://pam.d/chpasswd \
37 file://pam.d/chsh \
38 file://pam.d/login \
39 file://pam.d/newusers \
40 file://pam.d/passwd \
41 file://pam.d/su"
42
Andrew Geissler87f5cff2022-09-30 13:13:31 -050043inherit autotools gettext github-releases
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044
Brad Bishope2d5b612018-11-23 10:55:50 +130045export CONFIG_SHELL="/bin/sh"
46
Patrick Williams0ca19cc2021-08-16 14:03:13 -050047EXTRA_OECONF += "--without-libcrack \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050048 --with-group-name-max-length=24 \
49 --enable-subordinate-ids=yes \
Andrew Geissler82c905d2020-04-13 13:39:40 -050050 --without-sssd \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050051 ${NSCDOPT}"
52
53NSCDOPT = ""
Patrick Williams213cb262021-08-07 19:21:33 -050054NSCDOPT:class-native = "--without-nscd"
55NSCDOPT:class-nativesdk = "--without-nscd"
56NSCDOPT:libc-glibc = "--with-nscd"
Brad Bishopf3f93bb2019-10-16 14:33:32 -040057
Patrick Williamsc124f4f2015-09-15 14:41:29 -050058PAM_PLUGINS = "libpam-runtime \
59 pam-plugin-faildelay \
60 pam-plugin-securetty \
61 pam-plugin-nologin \
62 pam-plugin-env \
63 pam-plugin-group \
64 pam-plugin-limits \
65 pam-plugin-lastlog \
66 pam-plugin-motd \
67 pam-plugin-mail \
68 pam-plugin-shells \
69 pam-plugin-rootok"
70
Patrick Williams213cb262021-08-07 19:21:33 -050071PAM_PLUGINS:remove:libc-musl = "pam-plugin-lastlog"
Andrew Geisslerd1e89492021-02-12 15:35:20 -060072
Brad Bishop6e60e8b2018-02-01 10:27:11 -050073PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \
74 ${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
Patrick Williams213cb262021-08-07 19:21:33 -050075PACKAGECONFIG:class-native ??= "${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
76PACKAGECONFIG:class-nativesdk = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050077PACKAGECONFIG[pam] = "--with-libpam,--without-libpam,libpam,${PAM_PLUGINS}"
78PACKAGECONFIG[attr] = "--with-attr,--without-attr,attr"
79PACKAGECONFIG[acl] = "--with-acl,--without-acl,acl"
Patrick Williams0ca19cc2021-08-16 14:03:13 -050080PACKAGECONFIG[audit] = "--with-audit,--without-audit,audit"
81PACKAGECONFIG[selinux] = "--with-selinux,--without-selinux,libselinux libsemanage"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050082
Patrick Williams213cb262021-08-07 19:21:33 -050083RDEPENDS:${PN} = "shadow-securetty \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050084 base-passwd \
85 util-linux-sulogin"
Patrick Williams213cb262021-08-07 19:21:33 -050086RDEPENDS:${PN}:class-native = ""
87RDEPENDS:${PN}:class-nativesdk = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088
89do_install() {
90 oe_runmake DESTDIR="${D}" sbindir="${base_sbindir}" usbindir="${sbindir}" install
91
92 # Info dir listing isn't interesting at this point so remove it if it exists.
93 if [ -e "${D}${infodir}/dir" ]; then
94 rm -f ${D}${infodir}/dir
95 fi
96
97 # Enable CREATE_HOME by default.
98 sed -i 's/#CREATE_HOME/CREATE_HOME/g' ${D}${sysconfdir}/login.defs
99
100 # As we are on an embedded system, ensure the users mailbox is in
101 # ~/ not /var/spool/mail by default, as who knows where or how big
102 # /var is. The system MDA will set this later anyway.
103 sed -i 's/MAIL_DIR/#MAIL_DIR/g' ${D}${sysconfdir}/login.defs
104 sed -i 's/#MAIL_FILE/MAIL_FILE/g' ${D}${sysconfdir}/login.defs
105
106 # Disable checking emails.
107 sed -i 's/MAIL_CHECK_ENAB/#MAIL_CHECK_ENAB/g' ${D}${sysconfdir}/login.defs
108
109 # Comment out SU_NAME to work correctly with busybox
110 # See Bug#5359 and Bug#7173
111 sed -i 's:^SU_NAME:#SU_NAME:g' ${D}${sysconfdir}/login.defs
112
113 # Use proper encryption for passwords
114 sed -i 's/^#ENCRYPT_METHOD.*$/ENCRYPT_METHOD SHA512/' ${D}${sysconfdir}/login.defs
115
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500116 install -d ${D}${sysconfdir}/default
117 install -m 0644 ${WORKDIR}/useradd ${D}${sysconfdir}/default
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500118}
119
Patrick Williams213cb262021-08-07 19:21:33 -0500120do_install:append() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500121 # Ensure that the image has as a /var/spool/mail dir so shadow can
122 # put mailboxes there if the user reconfigures shadow to its
123 # defaults (see sed below).
Brad Bishopd5ae7d92018-06-14 09:52:03 -0700124 install -m 0775 -d ${D}${localstatedir}/spool/mail
125 chown root:mail ${D}${localstatedir}/spool/mail
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500126
127 if [ -e ${WORKDIR}/pam.d ]; then
128 install -d ${D}${sysconfdir}/pam.d/
129 install -m 0644 ${WORKDIR}/pam.d/* ${D}${sysconfdir}/pam.d/
130 # Remove defaults that are not used when supporting PAM.
131 sed -i -f ${WORKDIR}/login_defs_pam.sed ${D}${sysconfdir}/login.defs
132 fi
133
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400134 install -d ${D}${sbindir} ${D}${base_sbindir} ${D}${base_bindir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500135
136 # Move binaries to the locations we want
137 rm ${D}${sbindir}/vigr
138 ln -sf vipw.${BPN} ${D}${base_sbindir}/vigr
139 if [ "${sbindir}" != "${base_sbindir}" ]; then
140 mv ${D}${sbindir}/vipw ${D}${base_sbindir}/vipw
141 fi
142 if [ "${bindir}" != "${base_bindir}" ]; then
143 mv ${D}${bindir}/login ${D}${base_bindir}/login
144 mv ${D}${bindir}/su ${D}${base_bindir}/su
145 fi
146
147 # Handle link properly after rename, otherwise missing files would
148 # lead rpm failed dependencies.
149 ln -sf newgrp.${BPN} ${D}${bindir}/sg
Patrick Williams92b42cb2022-09-03 06:53:57 -0500150
151 # usermod requires the subuid/subgid files to be in place before being
152 # able to use the -v/-V flags otherwise it fails:
153 # usermod: /etc/subuid does not exist, you cannot use the flags -v or -V
154 install -d ${D}${sysconfdir}
155 touch ${D}${sysconfdir}/subuid
156 touch ${D}${sysconfdir}/subgid
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500157}
158
159PACKAGES =+ "${PN}-base"
Patrick Williams213cb262021-08-07 19:21:33 -0500160FILES:${PN}-base = "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500161 ${base_bindir}/login.shadow \
162 ${base_bindir}/su.shadow \
163 ${bindir}/sg \
164 ${bindir}/newgrp.shadow \
165 ${bindir}/groups.shadow \
166 ${sysconfdir}/pam.d/login \
167 ${sysconfdir}/pam.d/su \
168 ${sysconfdir}/login.defs \
169"
Patrick Williams213cb262021-08-07 19:21:33 -0500170RDEPENDS:${PN} += "${PN}-base"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171
172inherit update-alternatives
173
174ALTERNATIVE_PRIORITY = "200"
175
Patrick Williams213cb262021-08-07 19:21:33 -0500176ALTERNATIVE:${PN} = "passwd chfn chsh chpasswd vipw vigr nologin"
Andrew Geissler5f350902021-07-23 13:09:54 -0400177ALTERNATIVE_LINK_NAME[chfn] = "${bindir}/chfn"
178ALTERNATIVE_LINK_NAME[chsh] = "${bindir}/chsh"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500179ALTERNATIVE_LINK_NAME[chpasswd] = "${sbindir}/chpasswd"
180ALTERNATIVE_LINK_NAME[vipw] = "${base_sbindir}/vipw"
181ALTERNATIVE_LINK_NAME[vigr] = "${base_sbindir}/vigr"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500182ALTERNATIVE_LINK_NAME[nologin] = "${base_sbindir}/nologin"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500183
Patrick Williams213cb262021-08-07 19:21:33 -0500184ALTERNATIVE:${PN}-base = "newgrp groups login su"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500185ALTERNATIVE_LINK_NAME[login] = "${base_bindir}/login"
186ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su"
187
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500188PACKAGE_WRITE_DEPS += "shadow-native"
Patrick Williams213cb262021-08-07 19:21:33 -0500189pkg_postinst:${PN}:class-target () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500190 if [ "x$D" != "x" ]; then
191 rootarg="--root $D"
192 else
193 rootarg=""
194 fi
195
196 pwconv $rootarg || exit 1
197 grpconv $rootarg || exit 1
198}