This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Spelling - megapatch
[metaconfig.git] / U / modified / d_dosuid.U
CommitLineData
e9723731
MB
1?RCS: $Id: d_dosuid.U 1 2006-08-24 12:32:52Z rmanfredi $
2?RCS:
3?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
65a32477
MBT
4?RCS:
5?RCS: You may redistribute only under the terms of the Artistic License,
e9723731
MB
6?RCS: as specified in the README file that comes with the distribution.
7?RCS: You may reuse parts of this distribution only within the terms of
65a32477 8?RCS: that same Artistic License; a copy of which may be found at the root
e9723731 9?RCS: of the source tree for dist 4.0.
65a32477 10?RCS:
e9723731
MB
11?RCS: Tye McQueen <tye@metronet.com> added safe setuid script checks.
12?RCS:
13?RCS: $Log: d_dosuid.U,v $
14?RCS: Revision 3.0.1.2 1997/02/28 15:33:03 ram
15?RCS: patch61: moved unit to TOP via a ?Y: layout directive
16?RCS: patch61: tell them /dev/fd is not about floppy disks
17?RCS:
18?RCS: Revision 3.0.1.1 1994/10/29 16:12:08 ram
19?RCS: patch36: added checks for secure setuid scripts (Tye McQueen)
20?RCS:
21?RCS: Revision 3.0 1993/08/18 12:05:55 ram
22?RCS: Baseline for dist 3.0 netwide release.
23?RCS:
24?MAKE:d_dosuid d_suidsafe: cat contains ls rm test Myread Setvar \
25 Oldconfig Guess package hint patchlevel
26?MAKE: -pick add $@ %<
27?S:d_suidsafe:
28?S: This variable conditionally defines SETUID_SCRIPTS_ARE_SECURE_NOW
29?S: if setuid scripts can be secure. This test looks in /dev/fd/.
30?S:.
31?S:d_dosuid:
32?S: This variable conditionally defines the symbol DOSUID, which
33?S: tells the C program that it should insert setuid emulation code
34?S: on hosts which have setuid #! scripts disabled.
35?S:.
36?C:SETUID_SCRIPTS_ARE_SECURE_NOW:
37?C: This symbol, if defined, indicates that the bug that prevents
38?C: setuid scripts from being secure is not present in this kernel.
39?C:.
40?C:DOSUID:
41?C: This symbol, if defined, indicates that the C program should
42?C: check the script that it is executing for setuid/setgid bits, and
43?C: attempt to emulate setuid/setgid on systems that have disabled
44?C: setuid #! scripts because the kernel can't do it securely.
45?C: It is up to the package designer to make sure that this emulation
46?C: is done securely. Among other things, it should do an fstat on
47?C: the script it just opened to make sure it really is a setuid/setgid
48?C: script, it should make sure the arguments passed correspond exactly
49?C: to the argument on the #! line, and it should not trust any
50?C: subprocesses to which it must pass the filename rather than the
51?C: file descriptor of the script to be executed.
52?C:.
53?H:#$d_suidsafe SETUID_SCRIPTS_ARE_SECURE_NOW /**/
54?H:#$d_dosuid DOSUID /**/
55?H:.
56?Y:TOP
57?F:!reflect
58?LINT: set d_suidsafe
59: see if setuid scripts can be secure
60$cat <<EOM
61
62Some kernels have a bug that prevents setuid #! scripts from being
63secure. Some sites have disabled setuid #! scripts because of this.
64
65First let's decide if your kernel supports secure setuid #! scripts.
66(If setuid #! scripts would be secure but have been disabled anyway,
67don't say that they are secure if asked.)
68
69EOM
70
71val="$undef"
72if $test -d /dev/fd; then
73 echo "#!$ls" >reflect
74 chmod +x,u+s reflect
75 ./reflect >flect 2>&1
76 if $contains "/dev/fd" flect >/dev/null; then
77 echo "Congratulations, your kernel has secure setuid scripts!" >&4
78 val="$define"
79 else
80 $cat <<EOM
81If you are not sure if they are secure, I can check but I'll need a
82username and password different from the one you are using right now.
83If you don't have such a username or don't want me to test, simply
84enter 'none'.
85
86EOM
87 rp='Other username to test security of setuid scripts with?'
88 dflt='none'
89 . ./myread
90 case "$ans" in
91 n|none)
92 case "$d_suidsafe" in
93 '') echo "I'll assume setuid scripts are *not* secure." >&4
94 dflt=n;;
95 "$undef")
96 echo "Well, the $hint value is *not* secure." >&4
97 dflt=n;;
98 *) echo "Well, the $hint value *is* secure." >&4
99 dflt=y;;
100 esac
101 ;;
102 *)
103 $rm -f reflect flect
104 echo "#!$ls" >reflect
105 chmod +x,u+s reflect
106 echo >flect
107 chmod a+w flect
108 echo '"su" will (probably) prompt you for '"$ans's password."
109 su $ans -c './reflect >flect'
110 if $contains "/dev/fd" flect >/dev/null; then
111 echo "Okay, it looks like setuid scripts are secure." >&4
112 dflt=y
113 else
114 echo "I don't think setuid scripts are secure." >&4
115 dflt=n
116 fi
117 ;;
118 esac
119 rp='Does your kernel have *secure* setuid scripts?'
120 . ./myread
121 case "$ans" in
122 [yY]*) val="$define";;
123 *) val="$undef";;
124 esac
125 fi
126else
127 echo "I don't think setuid scripts are secure (no /dev/fd directory)." >&4
128 echo "(That's for file descriptors, not floppy disks.)"
129 val="$undef"
130fi
131set d_suidsafe
132eval $setvar
133
134$rm -f reflect flect
135
136: now see if they want to do setuid emulation
137if $test $patchlevel -lt 11; then
138echo " "
139val="$undef"
140case "$d_suidsafe" in
141"$define")
142 val="$undef"
0f4b7766 143 echo "No need to emulate SUID scripts since they are secure here." >&4
e9723731
MB
144 ;;
145*)
146 $cat <<EOM
147Some systems have disabled setuid scripts, especially systems where
148setuid scripts cannot be secure. On systems where setuid scripts have
149been disabled, the setuid/setgid bits on scripts are currently
150useless. It is possible for $package to detect those bits and emulate
151setuid/setgid in a secure fashion. This emulation will only work if
152setuid scripts have been disabled in your kernel.
153
154EOM
155 case "$d_dosuid" in
156 "$define") dflt=y ;;
157 *) dflt=n ;;
158 esac
159 rp="Do you want to do setuid/setgid emulation?"
160 . ./myread
161 case "$ans" in
162 [yY]*) val="$define";;
163 *) val="$undef";;
164 esac
165 ;;
166esac
167set d_dosuid
168eval $setvar
169else
170 case "$d_dosuid" in
171 "$define")
172 cat >&4 <<EOH
173
174SUID emulation has been removed for 5.12
175Please re-run Configure without -Dd_dosuid
176
177EOH
178 exit 1;
179 ;;
180 esac
181 d_dosuid=undef
182fi
183