Added setreuid() calls so that shell escapes work.
The effective ID's need to be set to the real ID's before invoking a shell for security reasons.
This commit is contained in:
parent
08cbe8b148
commit
e5082edc10
@ -16,7 +16,8 @@ MAN1= ${.CURDIR}/man.1
|
|||||||
.endif
|
.endif
|
||||||
|
|
||||||
DPADD+= ${MAN1}
|
DPADD+= ${MAN1}
|
||||||
CFLAGS+= -I${.CURDIR}/../lib -DSTDC_HEADERS -DPOSIX -DHAS_TROFF -DDO_UNCOMPRESS -DALT_SYSTEMS
|
CFLAGS+= -I${.CURDIR}/../lib -DSTDC_HEADERS -DPOSIX -DHAS_TROFF
|
||||||
|
CFLAGS+= -DDO_UNCOMPRESS -DALT_SYSTEMS -DSETREUID -DCATMODE=664
|
||||||
CLEANFILES+= ${MAN1}
|
CLEANFILES+= ${MAN1}
|
||||||
|
|
||||||
${MAN1}: ${.CURDIR}/man.man
|
${MAN1}: ${.CURDIR}/man.man
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#define MAN_MAIN
|
#define MAN_MAIN
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -104,6 +105,13 @@ static char args[] = "M:P:S:adfhkp:w?";
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef SETREUID
|
||||||
|
uid_t ruid;
|
||||||
|
uid_t euid;
|
||||||
|
uid_t rgid;
|
||||||
|
uid_t egid;
|
||||||
|
#endif
|
||||||
|
|
||||||
int
|
int
|
||||||
main (argc, argv)
|
main (argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
@ -138,6 +146,15 @@ main (argc, argv)
|
|||||||
gripe_no_name (tmp);
|
gripe_no_name (tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef SETREUID
|
||||||
|
ruid = getuid();
|
||||||
|
rgid = getgid();
|
||||||
|
euid = geteuid();
|
||||||
|
egid = getegid();
|
||||||
|
setreuid(-1, ruid);
|
||||||
|
setregid(-1, rgid);
|
||||||
|
#endif
|
||||||
|
|
||||||
while (optind < argc)
|
while (optind < argc)
|
||||||
{
|
{
|
||||||
nextarg = argv[optind++];
|
nextarg = argv[optind++];
|
||||||
@ -1136,7 +1153,28 @@ format_and_display (path, man_file, cat_file)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef SETREUID
|
||||||
|
setreuid(-1, euid);
|
||||||
|
setregid(-1, egid);
|
||||||
|
#endif
|
||||||
|
|
||||||
found = make_cat_file (path, man_file, cat_file);
|
found = make_cat_file (path, man_file, cat_file);
|
||||||
|
|
||||||
|
#ifdef SETREUID
|
||||||
|
setreuid(-1, ruid);
|
||||||
|
setregid(-1, rgid);
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
/* Try again as real user - see note below.
|
||||||
|
By running with
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef SECURE_MAN_UID
|
#ifdef SECURE_MAN_UID
|
||||||
if (!found)
|
if (!found)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user