blob: 09c37ef8a354c5b77d18268aeb6a2dfda632d4bd [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "Tools to change and administer password and group data"
2HOMEPAGE = "http://pkg-shadow.alioth.debian.org"
3BUGTRACKER = "https://alioth.debian.org/tracker/?group_id=30580"
4SECTION = "base/utils"
5LICENSE = "BSD | Artistic-1.0"
6LIC_FILES_CHKSUM = "file://COPYING;md5=ed80ff1c2b40843cf5768e5229cf16e5 \
7 file://src/passwd.c;beginline=8;endline=30;md5=d83888ea14ae61951982d77125947661"
8
Brad Bishop316dfdd2018-06-25 12:45:53 -04009DEPENDS = "virtual/crypt"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050010
Brad Bishopd5ae7d92018-06-14 09:52:03 -070011UPSTREAM_CHECK_URI = "https://github.com/shadow-maint/shadow/releases"
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080012SRC_URI = "https://github.com/shadow-maint/shadow/releases/download/${PV}/${BP}.tar.gz \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013 file://shadow-4.1.3-dots-in-usernames.patch \
Brad Bishop6e60e8b2018-02-01 10:27:11 -050014 file://0001-useradd-copy-extended-attributes-of-home.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050015 ${@bb.utils.contains('PACKAGECONFIG', 'pam', '${PAM_SRC_URI}', '', d)} \
16 "
17
18SRC_URI_append_class-target = " \
19 file://login_defs_pam.sed \
20 file://shadow-update-pam-conf.patch \
Patrick Williamsc0f7c042017-02-23 20:41:17 -060021 file://shadow-relaxed-usernames.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050022 "
23
24SRC_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://allow-for-setting-password-in-clear-text.patch \
27 file://commonio.c-fix-unexpected-open-failure-in-chroot-env.patch \
28 file://0001-useradd.c-create-parent-directories-when-necessary.patch \
29 "
30SRC_URI_append_class-nativesdk = " \
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050031 file://0001-Disable-use-of-syslog-for-sysroot.patch \
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032 "
33
Brad Bishop1a4b7ee2018-12-16 17:11:34 -080034SRC_URI[md5sum] = "36feb15665338ae3de414f2a88e434db"
35SRC_URI[sha256sum] = "4668f99bd087399c4a586084dc3b046b75f560720d83e92fd23bf7a89dda4d31"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050036
37# Additional Policy files for PAM
38PAM_SRC_URI = "file://pam.d/chfn \
39 file://pam.d/chpasswd \
40 file://pam.d/chsh \
41 file://pam.d/login \
42 file://pam.d/newusers \
43 file://pam.d/passwd \
44 file://pam.d/su"
45
46inherit autotools gettext
47
Brad Bishope2d5b612018-11-23 10:55:50 +130048export CONFIG_SHELL="/bin/sh"
49
Patrick Williamsc124f4f2015-09-15 14:41:29 -050050EXTRA_OECONF += "--without-audit \
51 --without-libcrack \
52 --without-selinux \
53 --with-group-name-max-length=24 \
54 --enable-subordinate-ids=yes \
55 ${NSCDOPT}"
56
57NSCDOPT = ""
58NSCDOPT_class-native = "--without-nscd"
59NSCDOPT_class-nativesdk = "--without-nscd"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060NSCDOPT_libc-glibc = "${@bb.utils.contains('DISTRO_FEATURES', 'libc-spawn', '--with-nscd', '--without-nscd', d)}"
61
62PAM_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
Brad Bishop6e60e8b2018-02-01 10:27:11 -050075PACKAGECONFIG ??= "${@bb.utils.filter('DISTRO_FEATURES', 'pam', d)} \
76 ${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
77PACKAGECONFIG_class-native ??= "${@bb.utils.contains('DISTRO_FEATURES', 'xattr', 'attr', '', d)}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078PACKAGECONFIG_class-nativesdk = ""
79PACKAGECONFIG[pam] = "--with-libpam,--without-libpam,libpam,${PAM_PLUGINS}"
80PACKAGECONFIG[attr] = "--with-attr,--without-attr,attr"
81PACKAGECONFIG[acl] = "--with-acl,--without-acl,acl"
82
83RDEPENDS_${PN} = "shadow-securetty \
84 base-passwd \
85 util-linux-sulogin"
86RDEPENDS_${PN}_class-native = ""
87RDEPENDS_${PN}_class-nativesdk = ""
88
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
116 # Now we don't have a mail system. Disable mail creation for now.
117 sed -i 's:/bin/bash:/bin/sh:g' ${D}${sysconfdir}/default/useradd
118 sed -i '/^CREATE_MAIL_SPOOL/ s:^:#:' ${D}${sysconfdir}/default/useradd
119
120 # Use users group by default
121 sed -i 's,^GROUP=1000,GROUP=100,g' ${D}${sysconfdir}/default/useradd
122}
123
124do_install_append() {
125 # 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
138 install -d ${D}${sbindir} ${D}${base_sbindir} ${D}${base_bindir}
139
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"
157FILES_${PN}-base = "\
158 ${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"
167RDEPENDS_${PN} += "${PN}-base"
168
169inherit update-alternatives
170
171ALTERNATIVE_PRIORITY = "200"
172
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500173ALTERNATIVE_${PN} = "passwd chfn chsh chpasswd vipw vigr nologin"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500174ALTERNATIVE_LINK_NAME[chpasswd] = "${sbindir}/chpasswd"
175ALTERNATIVE_LINK_NAME[vipw] = "${base_sbindir}/vipw"
176ALTERNATIVE_LINK_NAME[vigr] = "${base_sbindir}/vigr"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500177ALTERNATIVE_LINK_NAME[nologin] = "${base_sbindir}/nologin"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500178
179ALTERNATIVE_${PN}-base = "newgrp groups login su"
180ALTERNATIVE_LINK_NAME[login] = "${base_bindir}/login"
181ALTERNATIVE_LINK_NAME[su] = "${base_bindir}/su"
182
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500183ALTERNATIVE_${PN}-doc = "passwd.5 getspnam.3 groups.1 su.1 nologin.8"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500184ALTERNATIVE_LINK_NAME[passwd.5] = "${mandir}/man5/passwd.5"
185ALTERNATIVE_LINK_NAME[getspnam.3] = "${mandir}/man3/getspnam.3"
186ALTERNATIVE_LINK_NAME[groups.1] = "${mandir}/man1/groups.1"
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600187ALTERNATIVE_LINK_NAME[su.1] = "${mandir}/man1/su.1"
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500188ALTERNATIVE_LINK_NAME[nologin.8] = "${mandir}/man8/nologin.8"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500189
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500190PACKAGE_WRITE_DEPS += "shadow-native"
Brad Bishop316dfdd2018-06-25 12:45:53 -0400191pkg_postinst_${PN}_class-target () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500192 if [ "x$D" != "x" ]; then
193 rootarg="--root $D"
194 else
195 rootarg=""
196 fi
197
198 pwconv $rootarg || exit 1
199 grpconv $rootarg || exit 1
200}