xref: /OK3568_Linux_fs/yocto/poky/meta/recipes-extended/shadow/shadow-securetty_4.6.bb (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593SmuzhiyunSUMMARY = "Provider of the machine specific securetty file"
2*4882a593SmuzhiyunSECTION = "base utils"
3*4882a593SmuzhiyunLICENSE = "MIT"
4*4882a593SmuzhiyunLIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunINHIBIT_DEFAULT_DEPS = "1"
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunPR = "r3"
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunSRC_URI = "file://securetty"
11*4882a593Smuzhiyun
12*4882a593SmuzhiyunS = "${WORKDIR}"
13*4882a593Smuzhiyun
14*4882a593Smuzhiyun# Since SERIAL_CONSOLES is likely to be set from the machine configuration
15*4882a593SmuzhiyunPACKAGE_ARCH = "${MACHINE_ARCH}"
16*4882a593Smuzhiyun
17*4882a593Smuzhiyundo_install () {
18*4882a593Smuzhiyun	# Ensure we add a suitable securetty file to the package that has
19*4882a593Smuzhiyun	# most common embedded TTYs defined.
20*4882a593Smuzhiyun	install -d ${D}${sysconfdir}
21*4882a593Smuzhiyun	install -m 0400 ${WORKDIR}/securetty ${D}${sysconfdir}/securetty
22*4882a593Smuzhiyun	if [ ! -z "${SERIAL_CONSOLES}" ]; then
23*4882a593Smuzhiyun		# Our SERIAL_CONSOLES contains a baud rate and sometimes extra
24*4882a593Smuzhiyun		# options as well. The following pearl :) takes that and converts
25*4882a593Smuzhiyun		# it into newline-separated tty's and appends them into
26*4882a593Smuzhiyun		# securetty. So if a machine has a weird looking console device
27*4882a593Smuzhiyun		# node (e.g. ttyAMA0) that securetty does not know, it will get
28*4882a593Smuzhiyun		# appended to securetty and root logins will be allowed on that
29*4882a593Smuzhiyun		# console.
30*4882a593Smuzhiyun		tmp="${SERIAL_CONSOLES}"
31*4882a593Smuzhiyun		for entry in $tmp ; do
32*4882a593Smuzhiyun			ttydev=`echo "$entry" | sed -e 's/^[0-9]*\;//' -e 's/\;.*//'`
33*4882a593Smuzhiyun			if ! grep -q $ttydev ${D}${sysconfdir}/securetty; then
34*4882a593Smuzhiyun				echo $ttydev >> ${D}${sysconfdir}/securetty
35*4882a593Smuzhiyun			fi
36*4882a593Smuzhiyun		done
37*4882a593Smuzhiyun	fi
38*4882a593Smuzhiyun}
39