Fix my popen fix: conditionalize saving/restoring of euid

Should be in 2.2
This commit is contained in:
Andrey A. Chernov 1996-12-18 20:07:49 +00:00
parent 64919fdd33
commit a49b39f8d4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=20655

View File

@ -1066,7 +1066,7 @@ restore_sigs()
* 1 for success and 0 for failure.
*/
int
make_cat_file (path, man_file, cat_file)
make_cat_file (path, man_file, cat_file, manid)
register char *path;
register char *man_file;
register char *cat_file;
@ -1109,8 +1109,10 @@ make_cat_file (path, man_file, cat_file)
else {
#ifdef SETREUID
setreuid(-1, ruid);
setregid(-1, rgid);
if (manid) {
setreuid(-1, ruid);
setregid(-1, rgid);
}
#endif
if ((pp = popen(command, "r")) == NULL) {
s = errno;
@ -1118,8 +1120,10 @@ make_cat_file (path, man_file, cat_file)
errno = s;
perror("popen");
#ifdef SETREUID
setreuid(-1, euid);
setregid(-1, egid);
if (manid) {
setreuid(-1, euid);
setregid(-1, egid);
}
#endif
unlink(temp);
restore_sigs();
@ -1127,8 +1131,10 @@ make_cat_file (path, man_file, cat_file)
return 0;
}
#ifdef SETREUID
setreuid(-1, euid);
setregid(-1, egid);
if (manid) {
setreuid(-1, euid);
setregid(-1, egid);
}
#endif
while ((s = getc(pp)) != EOF)
@ -1267,10 +1273,10 @@ format_and_display (path, man_file, cat_file)
#ifdef SETREUID
setreuid(-1, euid);
setregid(-1, egid);
found = make_cat_file (path, man_file, cat_file, 1);
#else
found = make_cat_file (path, man_file, cat_file, 0);
#endif
found = make_cat_file (path, man_file, cat_file);
#ifdef SETREUID
setreuid(-1, ruid);
setregid(-1, rgid);
@ -1282,7 +1288,7 @@ format_and_display (path, man_file, cat_file)
effective group (user) ID == real group (user) ID
except for the call above, I believe the problems
of reading private man pages is avoided. */
found = make_cat_file (path, man_file, cat_file);
found = make_cat_file (path, man_file, cat_file, 0);
}
#endif
#ifdef SECURE_MAN_UID
@ -1301,7 +1307,7 @@ format_and_display (path, man_file, cat_file)
*/
setuid (getuid ());
found = make_cat_file (path, man_file, cat_file);
found = make_cat_file (path, man_file, cat_file, 0);
}
#endif
if (found)