version 1.5, 2003/03/15 21:23:54 |
version 1.6, 2003/04/03 19:15:34 |
|
|
#ifdef HAVE_UNISTD_H |
#ifdef HAVE_UNISTD_H |
# include <unistd.h> |
# include <unistd.h> |
#endif /* HAVE_UNISTD_H */ |
#endif /* HAVE_UNISTD_H */ |
#include <errno.h> |
#ifdef HAVE_ERR_H |
|
# include <err.h> |
|
#else |
|
# include "emul/err.h" |
|
#endif /* HAVE_ERR_H */ |
|
|
#include "sudo.h" |
#include "sudo.h" |
|
|
#ifndef lint |
#ifndef lint |
static const char rcsid[] = "$Sudo: find_path.c,v 1.101 2003/03/15 20:31:02 millert Exp $"; |
static const char rcsid[] = "$Sudo: find_path.c,v 1.102 2003/04/02 18:25:19 millert Exp $"; |
#endif /* lint */ |
#endif /* lint */ |
|
|
/* |
/* |
|
|
int checkdot = 0; /* check current dir? */ |
int checkdot = 0; /* check current dir? */ |
int len; /* length parameter */ |
int len; /* length parameter */ |
|
|
if (strlen(infile) >= MAXPATHLEN) { |
if (strlen(infile) >= MAXPATHLEN) |
(void) fprintf(stderr, "%s: path too long: %s\n", Argv[0], infile); |
errx(1, "%s: File name too long", infile); |
exit(1); |
|
} |
|
|
|
/* |
/* |
* If we were given a fully qualified or relative path |
* If we were given a fully qualified or relative path |
|
|
* Resolve the path and exit the loop if found. |
* Resolve the path and exit the loop if found. |
*/ |
*/ |
len = snprintf(command, sizeof(command), "%s/%s", path, infile); |
len = snprintf(command, sizeof(command), "%s/%s", path, infile); |
if (len <= 0 || len >= sizeof(command)) { |
if (len <= 0 || len >= sizeof(command)) |
(void) fprintf(stderr, "%s: path too long: %s\n", Argv[0], infile); |
errx(1, "%s: File name too long", infile); |
exit(1); |
|
} |
|
if ((result = sudo_goodpath(command))) |
if ((result = sudo_goodpath(command))) |
break; |
break; |
|
|