blob: c91f2739cff8ac8232cc65cbec1da9864160f937 [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 Geisslerd159c7f2021-09-02 21:05:58 -05006LICENSE = "BSD-3-Clause | Artistic-1.0"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007LIC_FILES_CHKSUM = "file://COPYING;md5=ed80ff1c2b40843cf5768e5229cf16e5 \
Brad Bishopc68388fc2019-08-26 01:33:31 -04008 file://src/passwd.c;beginline=2;endline=30;md5=5720ff729a6ff39ecc9f64555d75f4af"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009
Brad Bishop316dfdd2018-06-25 12:45:53 -040010DEPENDS = "virtual/crypt"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050011
Brad Bishopd5ae7d92018-06-14 09:52:03 -070012UPSTREAM_CHECK_URI = "https://github.com/shadow-maint/shadow/releases"
Patrick Williams213cb262021-08-07 19:21:33 -050013SRC_URI = "https://github.com/shadow-maint/shadow/releases/download/v${PV}/${BP}.tar.gz \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050014 file://shadow-4.1.3-dots-in-usernames.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015 ${@bb.utils.contains('PACKAGECONFIG', 'pam', '${PAM_SRC_URI}', '', d)} \
Brad Bishop00e122a2019-10-05 11:10:57 -040016 file://shadow-relaxed-usernames.patch \
Patrick Williams213cb262021-08-07 19:21:33 -050017 file://0001-Fix-out-of-tree-builds-with-respect-to-libsubid-incl.patch \
18 file://0001-libsubid-link-to-PAM-libraries.patch \
Andrew Geisslerd159c7f2021-09-02 21:05:58 -050019 file://0001-libmisc-fix-default-value-in-SHA_get_salt_rounds.patch \
20 file://useradd \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050021 "
22
Patrick Williams213cb262021-08-07 19:21:33 -050023SRC_URI:append:class-target = " \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024 file://login_defs_pam.sed \
25 file://shadow-update-pam-conf.patch \
26 "
27
Patrick Williams213cb262021-08-07 19:21:33 -050028SRC_URI:append:class-native = " \
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 file://commonio.c-fix-unexpected-open-failure-in-chroot-env.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031 "
Patrick Williams213cb262021-08-07 19:21:33 -050032SRC_URI:append:class-nativesdk = " \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050033 file://0001-Disable-use-of-syslog-for-sysroot.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050034 "
35
Patrick Williams213cb262021-08-07 19:21:33 -050036SRC_URI[sha256sum] = "6c4627ff9c9422b96664517ae753c944f2902e92809d0698b65f5fef11985212"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050037
38# Additional Policy files for PAM
39PAM_SRC_URI = "file://pam.d/chfn \
40 file://pam.d/chpasswd \
41 file://pam.d/chsh \
42 file://pam.d/login \
43 file://pam.d/newusers \
44 file://pam.d/passwd \
45 file://pam.d/su"
46
47inherit autotools gettext
48
Brad Bishope2d5b612018-11-23 10:55:50 +130049export CONFIG_SHELL="/bin/sh"
50
Patrick Williams0ca19cc2021-08-16 14:03:13 -050051EXTRA_OECONF += "--without-libcrack \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050052 --with-group-name-max-length=24 \
53 --enable-subordinate-ids=yes \
Andrew Geissler82c905d2020-04-13 13:39:40 -050054 --without-sssd \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050055 ${NSCDOPT}"
56
57NSCDOPT = ""
Patrick Williams213cb262021-08-07 19:21:33 -050058NSCDOPT:class-native = "--without-nscd"
59NSCDOPT:class-nativesdk = "--without-nscd"
60NSCDOPT:libc-glibc = "--with-nscd"
Brad Bishopf3f93bb2019-10-16 14:33:32 -040061
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062PAM_PLUGINS = "libpam-runtime \
63 pam-plugin-faildelay \
64 pam-plugin-securetty \
65 pam-plugin-nologin \
66 pam-plugin-env \
67 pam-plugin-group \
68 pam-plugin-limits \
69 pam-plugin-lastlog \
70 pam-plugin-motd \
71 pam-plugin-mail \
72 pam-plugin-shells \
73 pam-plugin-rootok"
74
Patrick Williams213cb262021-08-07 19:21:33 -050075PAM_PLUGINS:remove:libc-musl = "pam-plugin-lastlog"
Andrew Geisslerd1e89492021-02-12 15:35:20 -060076
Brad Bishop6e60e8b2018-02-01 10:27:11 -050077PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \
78 ${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
Patrick Williams213cb262021-08-07 19:21:33 -050079PACKAGECONFIG:class-native ??= "${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
80PACKAGECONFIG:class-nativesdk = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050081PACKAGECONFIG[pam] = "--with-libpam,--without-libpam,libpam,${PAM_PLUGINS}"
82PACKAGECONFIG[attr] = "--with-attr,--without-attr,attr"
83PACKAGECONFIG[acl] = "--with-acl,--without-acl,acl"
Patrick Williams0ca19cc2021-08-16 14:03:13 -050084PACKAGECONFIG[audit] = "--with-audit,--without-audit,audit"
85PACKAGECONFIG[selinux] = "--with-selinux,--without-selinux,libselinux libsemanage"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050086
Patrick Williams213cb262021-08-07 19:21:33 -050087RDEPENDS:${PN} = "shadow-securetty \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050088 base-passwd \
89 util-linux-sulogin"
Patrick Williams213cb262021-08-07 19:21:33 -050090RDEPENDS:${PN}:class-native = ""
91RDEPENDS:${PN}:class-nativesdk = ""
Patrick Williamsc124f4f2015-09-15 14:41:29 -050092
93do_install() {
94 oe_runmake DESTDIR="${D}" sbindir="${base_sbindir}" usbindir="${sbindir}" install
95
96 # Info dir listing isn't interesting at this point so remove it if it exists.
97 if [ -e "${D}${infodir}/dir" ]; then
98 rm -f ${D}${infodir}/dir
99 fi
100
101 # Enable CREATE_HOME by default.
102 sed -i 's/#CREATE_HOME/CREATE_HOME/g' ${D}${sysconfdir}/login.defs
103
104 # As we are on an embedded system, ensure the users mailbox is in
105 # ~/ not /var/spool/mail by default, as who knows where or how big
106 # /var is. The system MDA will set this later anyway.
107 sed -i 's/MAIL_DIR/#MAIL_DIR/g' ${D}${sysconfdir}/login.defs
108 sed -i 's/#MAIL_FILE/MAIL_FILE/g' ${D}${sysconfdir}/login.defs
109
110 # Disable checking emails.
111 sed -i 's/MAIL_CHECK_ENAB/#MAIL_CHECK_ENAB/g' ${D}${sysconfdir}/login.defs
112
113 # Comment out SU_NAME to work correctly with busybox
114 # See Bug#5359 and Bug#7173
115 sed -i 's:^SU_NAME:#SU_NAME:g' ${D}${sysconfdir}/login.defs
116
117 # Use proper encryption for passwords
118 sed -i 's/^#ENCRYPT_METHOD.*$/ENCRYPT_METHOD SHA512/' ${D}${sysconfdir}/login.defs
119
Andrew Geisslerd159c7f2021-09-02 21:05:58 -0500120 install -d ${D}${sysconfdir}/default
121 install -m 0644 ${WORKDIR}/useradd ${D}${sysconfdir}/default
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500122}
123
Patrick Williams213cb262021-08-07 19:21:33 -0500124do_install:append() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500125 # Ensure that the image has as a /var/spool/mail dir so shadow can
126 # put mailboxes there if the user reconfigures shadow to its
127 # defaults (see sed below).
Brad Bishopd5ae7d92018-06-14 09:52:03 -0700128 install -m 0775 -d ${D}${localstatedir}/spool/mail
129 chown root:mail ${D}${localstatedir}/spool/mail
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500130
131 if [ -e ${WORKDIR}/pam.d ]; then
132 install -d ${D}${sysconfdir}/pam.d/
133 install -m 0644 ${WORKDIR}/pam.d/* ${D}${sysconfdir}/pam.d/
134 # Remove defaults that are not used when supporting PAM.
135 sed -i -f ${WORKDIR}/login_defs_pam.sed ${D}${sysconfdir}/login.defs
136 fi
137
Brad Bishopf3f93bb2019-10-16 14:33:32 -0400138 install -d ${D}${sbindir} ${D}${base_sbindir} ${D}${base_bindir}
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500139
140 # Move binaries to the locations we want
141 rm ${D}${sbindir}/vigr
142 ln -sf vipw.${BPN} ${D}${base_sbindir}/vigr
143 if [ "${sbindir}" != "${base_sbindir}" ]; then
144 mv ${D}${sbindir}/vipw ${D}${base_sbindir}/vipw
145 fi
146 if [ "${bindir}" != "${base_bindir}" ]; then
147 mv ${D}${bindir}/login ${D}${base_bindir}/login
148 mv ${D}${bindir}/su ${D}${base_bindir}/su
149 fi
150
151 # Handle link properly after rename, otherwise missing files would
152 # lead rpm failed dependencies.
153 ln -sf newgrp.${BPN} ${D}${bindir}/sg
154}
155
156PACKAGES =+ "${PN}-base"
Patrick Williams213cb262021-08-07 19:21:33 -0500157FILES:${PN}-base = "\
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500158 ${base_bindir}/login.shadow \
159 ${base_bindir}/su.shadow \
160 ${bindir}/sg \
161 ${bindir}/newgrp.shadow \
162 ${bindir}/groups.shadow \
163 ${sysconfdir}/pam.d/login \
164 ${sysconfdir}/pam.d/su \
165 ${sysconfdir}/login.defs \
166"
Patrick Williams213cb262021-08-07 19:21:33 -0500167RDEPENDS:${PN} += "${PN}-base"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168
169inherit update-alternatives
170
171ALTERNATIVE_PRIORITY = "200"
172
Patrick Williams213cb262021-08-07 19:21:33 -0500173ALTERNATIVE:${PN} = "passwd chfn chsh chpasswd vipw vigr nologin"
Andrew Geissler5f350902021-07-23 13:09:54 -0400174ALTERNATIVE_LINK_NAME[chfn] = "${bindir}/chfn"
175ALTERNATIVE_LINK_NAME[chsh] = "${bindir}/chsh"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500176ALTERNATIVE_LINK_NAME[chpasswd] = "${sbindir}/chpasswd"
177ALTERNATIVE_LINK_NAME[vipw] = "${base_sbindir}/vipw"
178ALTERNATIVE_LINK_NAME[vigr] = "${base_sbindir}/vigr"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500179ALTERNATIVE_LINK_NAME[nologin] = "${base_sbindir}/nologin"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500180
Patrick Williams213cb262021-08-07 19:21:33 -0500181ALTERNATIVE:${PN}-base = "newgrp groups login su"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500182ALTERNATIVE_LINK_NAME[login] = "${base_bindir}/login"
183ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su"
184
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500185PACKAGE_WRITE_DEPS += "shadow-native"
Patrick Williams213cb262021-08-07 19:21:33 -0500186pkg_postinst:${PN}:class-target () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500187 if [ "x$D" != "x" ]; then
188 rootarg="--root $D"
189 else
190 rootarg=""
191 fi
192
193 pwconv $rootarg || exit 1
194 grpconv $rootarg || exit 1
195}