libattr: remove libattr because it is clashing with udev/attr and is not used by...
[openembedded.git] / recipes / shadow / shadow.inc
blob460930b22a9b5c8cf8219ad78e1069c9315d93f7
1 # Configuration parameters
2 SHADOW_MAILFILE ?= "Mailbox"
3 SHADOW_MAILDIR ?= "${localstatedir}/spool/mail"
4 SHADOW_UTMPDIR ?= "${localstatedir}/utmp"
5 SHADOW_LOGDIR ?= "${localstatedir}/log"
7 # Metadata
8 DESCRIPTION = "Tools to change and administer password and group data."
9 HOMEPAGE = "http://pkg-shadow.alioth.debian.org/"
10 LICENSE = "BSD"
11 SECTION = "base"
12 DEPENDS += "${@base_contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}"
14 PACKAGE_ARCH_${PN} = "${MACHINE_ARCH}"
16 INC_PR = "r14"
18 # Additional Policy files for PAM
19 PAM_SRC_URI = " \
20            file://pam.d/chfn \
21            file://pam.d/chpasswd \
22            file://pam.d/chsh \
23            file://pam.d/login \
24            file://pam.d/newusers \
25            file://pam.d/passwd \
26            file://pam.d/su \
29 SRC_URI = "ftp://pkg-shadow.alioth.debian.org/pub/pkg-shadow/shadow-${PV}.tar.bz2 \
30            file://login_defs_pam.sed \
31            ${@base_contains('DISTRO_FEATURES', 'pam', '${PAM_SRC_URI}', '', d)} \
32            file://securetty \
35 inherit autotools gettext
37 EXTRA_OECONF += "\
38     --disable-account-tools-setuid \
39     --without-audit \
40     --without-selinux \
41     --without-libcrack \
42     ${@base_contains('DISTRO_FEATURES', 'pam', '--with-libpam', '--without-libpam', d)} \
45 CFLAGS += "-I../include"
47 do_configure_prepend () {
48     export CONFIG_SITE="${CONFIG_SITE} ${B}/cachedpaths"
49     cat <<END >${B}/cachedpaths
50 shadow_cv_maildir=${SHADOW_MAILDIR}
51 shadow_cv_mailfile=${SHADOW_MAILFILE}
52 shadow_cv_utmpdir=${SHADOW_UTMPDIR}
53 shadow_cv_logdir=${SHADOW_LOGDIR}
54 shadow_cv_passwd_dir=${bindir}
55 END
58 do_install_append() {
59   # Ensure that /etc/skel is created so any default files that we want copied into new users home
60   # dirs can be put in there later (ideal for .xinitrc for example).
61   install -d ${D}${sysconfdir}/skel/  
62   
63   # Ensure that the image has as /var/spool/mail dir so shadow can put mailboxes there if the user
64   # reconfigures Shadow to default (see sed below).
65   install -d ${D}${SHADOW_MAILDIR}
67   if [ -e ${WORKDIR}/pam.d ]; then
68       install -d ${D}${sysconfdir}/pam.d/
69       install -m 0644 ${WORKDIR}/pam.d/* ${D}${sysconfdir}/pam.d/
70   fi
72   # Remove defaults that are not used when supporting PAM
73   ${@base_contains('DISTRO_FEATURES', 'pam', 'sed -i -f ${WORKDIR}/login_defs_pam.sed ${D}${sysconfdir}/login.defs', '', d)}
75   # Enable CREATE_HOME by default.
76   sed -i 's/#CREATE_HOME/CREATE_HOME/g' ${D}${sysconfdir}/login.defs
78   # As we are on an embedded system ensure the users mailbox is in ~/ not
79   # /var/spool/mail by default as who knows where or how big /var is.
80   # The system MDA will set this later anyway.
81   sed -i 's/MAIL_DIR/#MAIL_DIR/g' ${D}${sysconfdir}/login.defs
82   sed -i 's/#MAIL_FILE/MAIL_FILE/g' ${D}${sysconfdir}/login.defs
84   install -d ${D}${sbindir} ${D}${base_sbindir} ${D}${base_bindir} 
85   for i in passwd chfn newgrp chsh ; do
86     mv ${D}${bindir}/$i ${D}${bindir}/$i.${PN}
87   done
89   mv ${D}${sbindir}/chpasswd ${D}${sbindir}/chpasswd.${PN}
90   mv ${D}${sbindir}/vigr ${D}${base_sbindir}/vigr.${PN}
91   mv ${D}${sbindir}/vipw ${D}${base_sbindir}/vipw.${PN}
92   mv ${D}${bindir}/login ${D}${base_bindir}/login.${PN}
94   # Ensure we add a suitable securetty file to the package that has most common embedded TTYs defined.
95   if [ ! -z "${SERIAL_CONSOLE}" ]; then
96   # our SERIAL_CONSOLE contains baud rate too and sometime -L option as well.
97   # the following pearl :) takes that and converts it into newline sepated tty's and appends
98   # them into securetty. So if a machine has a weird looking console device node (e.g. ttyAMA0) that securetty
99   # does not know then it will get appended to securetty and root login will be allowed on
100   # that console.
101     echo "${SERIAL_CONSOLE}" | sed -e 's/[0-9][0-9]\|\-L//g'|tr "[ ]" "[\n]"  >> ${WORKDIR}/securetty
102   fi
103   install -m 0400 ${WORKDIR}/securetty ${D}${sysconfdir}/securetty 
106 pkg_postinst_${PN} () {
107     update-alternatives --install ${bindir}/passwd passwd passwd.${PN} 200
108     update-alternatives --install ${sbindir}/chpasswd chpasswd chpasswd.${PN} 200
109     update-alternatives --install ${bindir}/chfn chfn chfn.${PN} 200
110     update-alternatives --install ${bindir}/newgrp newgrp newgrp.${PN} 200
111     update-alternatives --install ${bindir}/chsh chsh chsh.${PN} 200
112     update-alternatives --install ${base_bindir}/login login login.${PN} 200
113     update-alternatives --install ${base_sbindir}/vipw vipw vipw.${PN} 200
114     update-alternatives --install ${base_sbindir}/vigr vigr vigr.${PN} 200
115     if [ "x$D" != "x" ]; then
116         exit 1
117     fi  
118         pwconv
119         grpconv
122 pkg_prerm_${PN} () {
123     for i in passwd chpasswd chfn newgrp chsh login vipw vigr ; do
124         update-alternatives --remove $i $i.${PN}
125     done