File: oidentdconfig

package info (click to toggle)
oidentd 2.0.3-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 840 kB
  • ctags: 505
  • sloc: ansic: 5,290; sh: 3,215; yacc: 364; lex: 335; makefile: 101
file content (181 lines) | stat: -rw-r--r-- 3,772 bytes parent folder | download
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/sh -e

ACTION=probe
case "$1" in
	--help|-h)
		echo "$0 [--show] [--exec]"
		exit 0
		;;
	--show)
		ACTION=show
		;;
	--exec)
		ACTION=exec
		;;
esac

# read old config
. /etc/default/oidentd

CLEAN=yes
SPOOF=no
SPOOFPRIV=no
HIDE=no
MASQ=no
NEW_OPTIONS="$OIDENT_OPTIONS"
case "$OIDENT_OPTIONS" in
	*-A*)
		SPOOFPRIV=yes
		NEW_OPTIONS="`echo $NEW_OPTIONS|sed -e 's/-A//g'`"
		;;
esac
case "$OIDENT_OPTIONS" in
	*-s*)
		test -f /etc/identd.spoof &&
		grep -v '^#' /etc/identd.spoof | grep -qv '^$' &&
		SPOOF=normal &&
		CLEAN=no &&
		NEW_OPTIONS="`echo $NEW_OPTIONS|sed -e 's/-s//g'`"
		;;
esac
case "$OIDENT_OPTIONS" in
	*-S*)
		# all users but those in identd.spoof are allowed to spoof
		SPOOF=reverse
		NEW_OPTIONS="`echo $NEW_OPTIONS|sed -e 's/-S//g'`"
		;;
esac
case "$OIDENT_OPTIONS" in
	*-N*)
		# users are allowed to hide them
		CLEAN=no
		HIDE=yes
		NEW_OPTIONS="`echo $NEW_OPTIONS|sed -e 's/-N//g'`"
		;;
esac
case "$OIDENT_OPTIONS" in
	*-m*)
		# handle new location of masquarading config file
		test -f /etc/oidentd.users &&
		grep -v '^#' /etc/oidentd.users | grep -qv '^$' &&
		case "$ACTION" in
		show)
			echo "### Please move /etc/oidentd.users to /etc/oidentd_masq.conf"
			echo
			;;
		exec)
			mv /etc/oidentd.users /etc/oidentd_masq.conf
			;;
		esac &&
		CLEAN=no
		;;
esac
case "$OIDENT_OPTIONS" in
	*-F*)
		CLEAN=no
		NEW_OPTIONS="`echo $NEW_OPTIONS|sed -e 's/-F/-f/g'`"
		;;
esac
case "$OIDENT_OPTIONS" in
	*-x*)
		CLEAN=no
		NEW_OPTIONS="`echo $NEW_OPTIONS|sed -e 's/-x/-r/g'`"
		;;
esac

if [ "$SPOOF" = reverse -o "$HIDE" = yes ]; then
	{
		[ "$SPOOF" = reverse ] &&
			echo "		allow spoof"
		[ "$SPOOFPRIV" = yes ] &&
			echo "		allow spoof_privport"
		[ "$HIDE" = yes ] &&
			echo "		allow hide"
		echo
	} | case "$ACTION" in
	show)
		echo "### Please add these lines to the default section of your /etc/oidentd.conf:"
		cat
		;;
	exec)
		ln /etc/oidentd.conf /etc/oidentd.conf.old &&
		perl -pe 'if(/^\s+default/){print;system("cat");$_=""};' /etc/oidentd.conf > /etc/oidentd.conf.new &&
		mv /etc/oidentd.conf.new /etc/oidentd.conf
		;;
	esac
fi
if [ "$SPOOF" != no ]; then
	USER=undef
	grep -v '^#' /etc/identd.spoof | grep -v '^$' | {
	# convert old to new format
	  IFS=:
	  read USER REPLY
	  while [ -n "$USER" ]; do
		echo "user \"$USER\" {"
		echo "	default {"
		if [ -z "$REPLY" ]; then
			if [ "$SPOOF" = reverse ]; then
				echo "		deny spoof"
			else
				echo "		allow spoof"
				[ "$SPOOFPRIV" = yes ] && echo "		allow spoof_privport"
			fi
		else
			echo "		force reply \"$REPLY\""
		fi
		echo "	}"
		echo "}"
		echo
		read USER REPLY
	done } | case "$ACTION" in
	show)
		echo "### Please add these lines to your /etc/oidentd.conf:"
		cat
		echo "### afterwards, you may delete /etc/identd.spoof."
		echo
		;;
	exec)
		cat >> /etc/oidentd.conf
		rm /etc/identd.spoof
		;;
	esac
fi

if [ "$OIDENT_OPTIONS" != "$NEW_OPTIONS" ]; then
	case "$ACTION" in
	show)
		echo "### Edit /etc/default/oidentd to contain:"
		echo "OIDENT_OPTIONS=\"$NEW_OPTIONS\""
		echo
		;;
	exec)
		cat /etc/default/oidentd |
		sed -e 's/^OIDENT_OPTIONS=.*$/OIDENT_OPTIONS="'$NEW_OPTIONS'"/' > /etc/default/oidentd.new
		mv /etc/default/oidentd.new /etc/default/oidentd
		;;
	esac
fi

if [ "$CLEAN" = yes ]; then
	if [ "$ACTION" = show ]; then
		echo "You already have a new oidentd config."
	fi
	exit 0
fi

case "$ACTION" in
probe)
	echo "Your new oidentd won't work with the old configuration files."
	echo "please see '/usr/sbin/oidentdconfig --show' to fix it."
	exit 1
	;;
show)
	echo "### you may run '/usr/sbin/oidentdconfig --exec' to do all this automatically"
	exit 1
	;;
exec)
	echo "your oidentd config should work with the new oidentd now,"
	echo "but please have a look at it for yourself before starting the daemon."
	exit 0
	;;
esac