Support suidperl as well.
This commit is contained in:
parent
860a2bf505
commit
2b488685e3
@ -3,6 +3,7 @@
|
||||
PROG= perl
|
||||
NOMAN=
|
||||
WARNS?= 6
|
||||
LINKS= ${BINDIR}/perl ${BINDIR}/perl5
|
||||
LINKS= ${BINDIR}/perl ${BINDIR}/perl5 \
|
||||
${BINDIR}/perl ${BINDIR}/suidperl
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -44,15 +44,19 @@ int
|
||||
main(int argc __unused, char *argv[])
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
const char *p, *q, *self;
|
||||
const char *cmd, *p, *q, *self;
|
||||
size_t len;
|
||||
|
||||
self = argv[0];
|
||||
if ((cmd = strrchr(self, '/')) == NULL)
|
||||
cmd = self;
|
||||
else
|
||||
cmd++;
|
||||
argv[0] = path;
|
||||
for (p = q = getenv("PATH"); p && *p && *q; p = q + 1) {
|
||||
for (q = p; *q && *q != ':'; ++q)
|
||||
/* nothing */ ;
|
||||
len = snprintf(path, sizeof path, "%.*s/perl", (int)(q - p), p);
|
||||
len = snprintf(path, sizeof path, "%.*s/%s", (int)(q - p), p, cmd);
|
||||
if (len >= PATH_MAX || strcmp(path, self) == 0)
|
||||
continue;
|
||||
execve(path, argv, environ);
|
||||
|
Loading…
Reference in New Issue
Block a user