version 1.4, 2002/04/25 15:49:03 |
version 1.5, 2003/03/15 21:23:54 |
|
|
/* |
/* |
* Copyright (c) 1996, 1998-2001 Todd C. Miller <Todd.Miller@courtesan.com> |
* Copyright (c) 1996, 1998-2003 Todd C. Miller <Todd.Miller@courtesan.com> |
* All rights reserved. |
* All rights reserved. |
* |
* |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
|
|
#include "sudo.h" |
#include "sudo.h" |
|
|
#ifndef lint |
#ifndef lint |
static const char rcsid[] = "$Sudo: find_path.c,v 1.98 2001/12/14 06:40:03 millert Exp $"; |
static const char rcsid[] = "$Sudo: find_path.c,v 1.101 2003/03/15 20:31:02 millert Exp $"; |
#endif /* lint */ |
#endif /* lint */ |
|
|
/* |
/* |
|
|
char *origpath; /* so we can free path later */ |
char *origpath; /* so we can free path later */ |
char *result = NULL; /* result of path/file lookup */ |
char *result = NULL; /* result of path/file lookup */ |
int checkdot = 0; /* check current dir? */ |
int checkdot = 0; /* check current dir? */ |
|
int len; /* length parameter */ |
|
|
if (strlen(infile) >= MAXPATHLEN) { |
if (strlen(infile) >= MAXPATHLEN) { |
(void) fprintf(stderr, "%s: path too long: %s\n", Argv[0], infile); |
(void) fprintf(stderr, "%s: path too long: %s\n", Argv[0], infile); |
|
|
* there is no need to look at $PATH. |
* there is no need to look at $PATH. |
*/ |
*/ |
if (strchr(infile, '/')) { |
if (strchr(infile, '/')) { |
(void) strcpy(command, infile); |
strlcpy(command, infile, sizeof(command)); /* paranoia */ |
if (sudo_goodpath(command)) { |
if (sudo_goodpath(command)) { |
*outfile = command; |
*outfile = command; |
return(FOUND); |
return(FOUND); |
|
|
/* |
/* |
* Resolve the path and exit the loop if found. |
* Resolve the path and exit the loop if found. |
*/ |
*/ |
if (strlen(path) + strlen(infile) + 1 >= MAXPATHLEN) { |
len = snprintf(command, sizeof(command), "%s/%s", path, infile); |
|
if (len <= 0 || len >= sizeof(command)) { |
(void) fprintf(stderr, "%s: path too long: %s\n", Argv[0], infile); |
(void) fprintf(stderr, "%s: path too long: %s\n", Argv[0], infile); |
exit(1); |
exit(1); |
} |
} |
(void) sprintf(command, "%s/%s", path, infile); |
|
if ((result = sudo_goodpath(command))) |
if ((result = sudo_goodpath(command))) |
break; |
break; |
|
|