File: auth.sh

package info (click to toggle)
kickseed 0.64
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 304 kB
  • sloc: sh: 1,709; makefile: 2
file content (63 lines) | stat: -rw-r--r-- 1,785 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#! /bin/sh

auth_handler () {
	# TODO --enableldap, --enableldapauth, --ldapserver=, --ldapbasedn=,
	# --enableldaptls, --enablekrb5, --krb5realm=, --krb5kdc=,
	# --krb5adminserver=, --enablehesiod, --hesiodlhs,
	# --hesiodrhs, --enablesmbauth, --smbservers=, --smbworkgroup=
	eval set -- "$(getopt -o '' -l enablemd5,enablenis,nisdomain:,nisserver:,useshadow,enableshadow,enablecache -- "$@")" || { warn_getopt auth; return; }
	while :; do
		case $1 in
			--enablemd5)
				ks_preseed passwd passwd/md5 boolean true
				shift
				;;
			--enablenis)
				mkdir -p "$POSTSPOOL/auth.handler"
				touch "$POSTSPOOL/auth.handler/nis"
				shift
				;;
			--nisdomain)
				mkdir -p "$POSTSPOOL/auth.handler"
				echo "$2" > "$POSTSPOOL/auth.handler/nisdomain"
				shift 2
				;;
			--nisserver)
				mkdir -p "$POSTSPOOL/auth.handler"
				echo "$2" > "$POSTSPOOL/auth.handler/nisserver"
				shift 2
				;;
			--useshadow|--enableshadow)
				# TODO: this is true by default already
				ks_preseed passwd passwd/shadow boolean true
				shift
				;;
			--enablecache)
				warn "nscd not supported"
				shift
				;;
			--)	shift; break ;;
			*)	warn_getopt auth; return ;;
		esac
	done
}

auth_post () {
	if [ -f "$POSTSPOOL/auth.handler/nisdomain" ]; then
		cp "$POSTSPOOL/auth.handler/nisdomain" /target/etc/defaultdomain
	fi

	if [ -e "$POSTSPOOL/auth.handler/nis" ]; then
		sed -i '/^\(passwd\|group\|shadow\):/s/$/ nis/;
			/^hosts:/s/files/files nis/;
			/^\(protocols\|services\):/s/$/ nis/' \
			/target/etc/nsswitch.conf
		apt-install nis || true
	fi

	# Must come after installing nis, since /etc/yp.conf is a conffile.
	if [ -f "$POSTSPOOL/auth.handler/nisserver" ]; then
		nisserver="$(cat "$POSTSPOOL/auth.handler/nisserver")"
		echo "ypserver $nisserver" >> /target/etc/yp.conf
	fi
}