Annotation of embedaddon/sudo/doc/fixman.sh, revision 1.1.1.2
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: # HP-UX friendly header/footer for all man pages
23: if [ X"`uname 2>&1`" = X"HP-UX" ]; then
24: cat >>"$OUTFILE" <<-'EOF'
25: s/^\.TH \("[^"]*"\) \("[^"]*"\) "\([^"]*\)" "\([^"]*\)" \("[^"]*"\)/.TH \1 \2\
26: .ds )H \4\
27: .ds ]W \3/
28: EOF
29: fi
30:
31: # Page specific hacks
32: case "$OUTFILE" in
33: sudo.man.sed)
34: # Replace "0 minutes" with "unlimited"
35: cat >>"$OUTFILE" <<-'EOF'
36: /^\\fR0\\fR$/ {
37: N
38: s/^\\fR0\\fR\nminutes\.$/unlimited./
39: }
40: EOF
41:
42: # BSD auth
43: if [ X"$BAMAN" != X"1" ]; then
44: cat >>"$OUTFILE" <<-'EOF'
45: /^\[\\fB\\-a\\fR\\ \\fIauth_type\\fR/d
46: /^\\fB\\-a\\fR \\fItype\\fR$/,/^\.TP 12n$/ {
47: /^\.PD$/!d
48: }
49: EOF
50: fi
51:
52: # BSD login class
53: if [ X"$LCMAN" != X"1" ]; then
54: cat >>"$OUTFILE" <<-'EOF'
55: /^\[\\fB\\-c\\fR\\ \\fIclass\\fR/d
56: /^\\fB\\-c\\fR \\fIclass\\fR$/,/^\.TP 12n$/ {
57: /^\.PD$/!d
58: }
59: /^login_cap(3),$/d
60: /^BSD login class$/ {
61: N
62: N
63: /^BSD login class\n\.TP 4n\n\\fBo\\fR$/d
64: }
65: EOF
66: fi
67:
68: # SELinux
69: if [ X"$SEMAN" != X"1" ]; then
70: cat >>"$OUTFILE" <<-'EOF'
71: /^\[\\fB\\-[rt]\\fR\\ \\fI[rt][oy][lp]e\\fR/d
72: /^\\fB\\-[rt]\\fR \\fI[rt][oy][lp]e\\fR$/,/^\.TP 12n$/ {
73: /^\.PD$/!d
74: }
75: /^SELinux role and type$/ {
76: N
77: N
78: /^SELinux role and type\n\.TP 4n\n\\fBo\\fR$/d
79: }
80: EOF
81: fi
82:
83: # Solaris privileges
84: if [ X"$PSMAN" != X"1" ]; then
85: cat >>"$OUTFILE" <<-'EOF'
86: /^Solaris project$/ {
87: N
88: N
89: N
90: N
91: N
92: /^Solaris project\n\.TP 4n\n\\fBo\\fR\nSolaris privileges\n\.TP 4n\n\\fBo\\fR$/d
93: }
94: EOF
95: fi
96: ;;
97: sudoers.man.sed)
98: # Subsections to remove (SELinux and Solaris are adjacent)
99: RM_SS=
100: if [ X"$PSMAN" != X"1" ]; then
101: if [ X"$SEMAN" != X"1" ]; then
102: RM_SS='/^\.SS "SELinux_Spec"/,/^\.SS "[^S]/{;/^\.SS "[^S][^o][^l]/!d;};'
103: else
104: RM_SS='/^\.SS "Solaris_Priv_Spec"/,/^\.SS/{;/^\.SS "[^S][^o][^l]/!d;};'
105: fi
106: elif [ X"$SEMAN" != X"1" ]; then
107: RM_SS='/^\.SS "SELinux_Spec"/,/^\.SS/{;/^\.SS "[^S][^E][^L]/!d;};'
108: fi
109: if [ -n "$RM_SS" ]; then
110: cat >>"$OUTFILE" <<-EOF
111: $RM_SS
112: EOF
113: fi
114:
115: # BSD login class
116: if [ X"$LCMAN" != X"1" ]; then
117: cat >>"$OUTFILE" <<-EOF
118: /^On BSD systems/,/\.$/ {
119: d
120: }
121: /^use_loginclass$/,/^\.TP 18n$/ {
122: /^\.PD$/!d
123: }
124: EOF
125: fi
126:
127: # Solaris PrivSpec
128: if [ X"$PSMAN" != X"1" ]; then
129: cat >>"$OUTFILE" <<-EOF
130: s/Solaris_Priv_Spec? //
131: /^Solaris_Priv_Spec ::=/ {
132: N
133: d
134: }
135: /^l*i*m*i*t*privs$/,/^\.TP 18n$/ {
136: /^\.PD$/!d
137: }
138: /^On Solaris 10/,/^\.[sP][pP]/ {
139: d
140: }
141: EOF
142: fi
143:
144: # SELinux
145: if [ X"$SEMAN" != X"1" ]; then
146: cat >>"$OUTFILE" <<-EOF
147: s/SELinux_Spec? //
148: /^SELinux_Spec ::=/ {
149: N
150: d
151: }
152: /^[rt][oy][lp]e$/,/^\.TP 18n$/ {
153: /^\.PD$/!d
154: }
155: EOF
156: fi
157: ;;
158: esac
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>