diff --git a/usr.bin/perl/Makefile b/usr.bin/perl/Makefile index 0eaf69c1d7c3..17994debee0b 100644 --- a/usr.bin/perl/Makefile +++ b/usr.bin/perl/Makefile @@ -2,7 +2,7 @@ PROG= perl NOMAN= -WARNS?= 6 +WARNS?= 5 LINKS= ${BINDIR}/perl ${BINDIR}/perl5 \ ${BINDIR}/perl ${BINDIR}/perl5.6.1 \ ${BINDIR}/perl ${BINDIR}/suidperl diff --git a/usr.bin/perl/perl.c b/usr.bin/perl/perl.c index cb4345718f1f..2bd55e7fc28d 100644 --- a/usr.bin/perl/perl.c +++ b/usr.bin/perl/perl.c @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include @@ -49,8 +50,13 @@ main(int argc __unused, char *argv[]) char path[PATH_MAX], *cp; const char *cmd, *p, *q, *self; size_t len; + struct stat self_stat, perl_stat; self = argv[0]; + if (stat (self, &self_stat) != 0) { + self_stat.st_dev = makedev (0, 0); + self_stat.st_ino = 0; + } if ((cmd = strrchr(self, '/')) == NULL) cmd = self; else @@ -79,6 +85,10 @@ main(int argc __unused, char *argv[]) len = snprintf(path, sizeof path, "%.*s/%s", (int)(q - p), p, cmd); if (len >= PATH_MAX || strcmp(path, self) == 0) continue; + if (stat (path, &perl_stat) == 0 + && self_stat.st_dev == perl_stat.st_dev + && self_stat.st_ino == perl_stat.st_ino) + continue; execve(path, argv, environ); if (errno != ENOENT) err(1, "%s", path);