Annotation of embedaddon/sudo/doc/fixmdoc.sh, revision 1.1.1.3
1.1 misho 1: #!/bin/sh
1.1.1.2 misho 2: #
3: # Copyright (c) 2012-2013 Todd C. Miller <Todd.Miller@courtesan.com>
4: #
5: # Permission to use, copy, modify, and distribute this software for any
6: # purpose with or without fee is hereby granted, provided that the above
7: # copyright notice and this permission notice appear in all copies.
8: #
9: # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10: # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11: # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12: # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13: # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14: # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15: # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16: #
1.1 misho 17:
18: OUTFILE="$1"
19: rm -f "$OUTFILE"
20: > "$OUTFILE"
21:
22: # Page specific hacks
23: case "$OUTFILE" in
24: sudo.mdoc.sed)
25: # Replace "0 minutes" with "unlimited"
26: cat >>"$OUTFILE" <<-'EOF'
27: /^\.Li 0$/ {
28: N
29: s/^\.Li 0\nminutes\.$/unlimited./
30: }
31: EOF
32:
33: # BSD auth
34: BA_FLAG=
35: if [ X"$BAMAN" != X"1" ]; then
1.1.1.3 ! misho 36: BA_FLAG='/^.*\n\.Op Fl a Ar type/{;N;/^.*\n\.Ek$/d;};'
1.1 misho 37: cat >>"$OUTFILE" <<-'EOF'
38: /^\.It Fl a Ar type/,/BSD authentication\.$/ {
39: d
40: }
41: EOF
42: fi
43:
44: # BSD login class
45: LC_FLAG=
46: if [ X"$LCMAN" != X"1" ]; then
47: LC_FLAG='/^.*\n\.Op Fl c Ar class/{;N;/^.*\n\.Ek$/d;};'
48: cat >>"$OUTFILE" <<-'EOF'
49: /^\.It Fl c Ar class/,/BSD login classes\.$/ {
50: d
51: }
52: /^\.Xr login_cap 3 ,$/d
53: /^BSD login class$/ {
54: N
55: /^BSD login class\n\.It$/d
56: }
57: EOF
58: fi
59:
60: # SELinux
61: SE_FLAG=
62: if [ X"$SEMAN" != X"1" ]; then
63: SE_FLAG='/^.*\n\.Op Fl r Ar role/{;N;/^.*\n\.Ek$/d;};/^.*\n\.Op Fl t Ar type/{;N;/^.*\n\.Ek$/d;};'
64: cat >>"$OUTFILE" <<-'EOF'
1.1.1.2 misho 65: /^\.It Fl r Ar role/,/^\.Ar role \.$/ {
1.1 misho 66: d
67: }
1.1.1.3 ! misho 68: /^\.It Fl t Ar type/,/derived from the role\.$/ {
1.1 misho 69: d
70: }
71: /^SELinux role and type$/ {
72: N
73: /^SELinux role and type\n\.It$/d
74: }
75: EOF
76: fi
77:
78: # Solaris privileges
79: if [ X"$PSMAN" != X"1" ]; then
80: cat >>"$OUTFILE" <<-'EOF'
81: /^Solaris project$/ {
82: N
83: N
84: N
85: /^Solaris project\n\.It\nSolaris privileges\n\.It$/d
86: }
87: EOF
88: fi
89:
90: # Unsupported flags must be removed together
91: if [ -n "$BA_FLAG$LC_FLAG$SE_FLAG" ]; then
92: cat >>"$OUTFILE" <<-EOF
93: /^\.Bk -words\$/ {
94: N
95: $BA_FLAG$LC_FLAG$SE_FLAG
96: }
97: EOF
98: fi
99: ;;
100: sudoers.mdoc.sed)
101: # Subsections to remove (SELinux and Solaris are adjacent)
102: RM_SS=
103: if [ X"$PSMAN" != X"1" ]; then
104: if [ X"$SEMAN" != X"1" ]; then
105: RM_SS='/^\.Ss SELinux_Spec/,/^\.Ss [^S]/{;/^\.Ss [^S][^o][^l]/!d;};'
106: else
107: RM_SS='/^\.Ss Solaris_Priv_Spec/,/^\.Ss/{;/^\.Ss [^S][^o][^l]/!d;};'
108: fi
109: elif [ X"$SEMAN" != X"1" ]; then
110: RM_SS='/^\.Ss SELinux_Spec/,/^\.Ss/{;/^\.Ss [^S][^E][^L]/!d;};'
111: fi
112: if [ -n "$RM_SS" ]; then
113: cat >>"$OUTFILE" <<-EOF
114: $RM_SS
115: EOF
116: fi
117:
118: # BSD login class
119: if [ X"$LCMAN" != X"1" ]; then
120: cat >>"$OUTFILE" <<-'EOF'
121: /^On BSD systems/,/\.$/ {
122: d
123: }
124: /^\.It use_loginclass$/,/^\.It/ {
125: /^\.It [^u][^s][^e][^_][^l]/!d
126: }
127: EOF
128: fi
129:
130: # Solaris PrivSpec
131: if [ X"$PSMAN" != X"1" ]; then
132: cat >>"$OUTFILE" <<-'EOF'
133: s/Solaris_Priv_Spec? //
134: /^Solaris_Priv_Spec ::=/ {
135: N
136: d
137: }
138: /^\.It limitprivs$/,/^\.It/ {
139: /^\.It [^l][^i][^m][^i][^t]/!d
140: }
141: /^\.It privs$/,/^\.It/ {
142: /^\.It [^p][^r][^i][^v][^s]$/!d
143: }
144: /^On Solaris 10/,/^\.Pp/ {
145: d
146: }
147: EOF
148: fi
149:
150: # SELinux
151: if [ X"$SEMAN" != X"1" ]; then
152: cat >>"$OUTFILE" <<-'EOF'
153: s/SELinux_Spec? //
154: /^SELinux_Spec ::=/ {
155: N
156: d
157: }
158: /^\.It [rt][oy][lp]e$/,/^\.It/ {
159: /^\.It [^rt][^oy][^lp][^e]$/!d
160: }
161: EOF
162: fi
163: ;;
164: esac
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>