version 1.2, 2000/01/28 01:10:20 |
version 1.2.8.1, 2002/01/18 16:14:46 |
|
|
/* |
/* |
* Copyright (c) 1996, 1998, 1999 Todd C. Miller <Todd.Miller@courtesan.com> |
* Copyright (c) 1996, 1998-2001 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 "config.h" |
#include "config.h" |
|
|
|
#include <sys/types.h> |
|
#include <sys/param.h> |
|
#include <sys/stat.h> |
#include <stdio.h> |
#include <stdio.h> |
#ifdef STDC_HEADERS |
#ifdef STDC_HEADERS |
#include <stdlib.h> |
# include <stdlib.h> |
|
# include <stddef.h> |
|
#else |
|
# ifdef HAVE_STDLIB_H |
|
# include <stdlib.h> |
|
# endif |
#endif /* STDC_HEADERS */ |
#endif /* STDC_HEADERS */ |
#ifdef HAVE_UNISTD_H |
|
#include <unistd.h> |
|
#endif /* HAVE_UNISTD_H */ |
|
#ifdef HAVE_STRING_H |
#ifdef HAVE_STRING_H |
#include <string.h> |
# include <string.h> |
|
#else |
|
# ifdef HAVE_STRINGS_H |
|
# include <strings.h> |
|
# endif |
#endif /* HAVE_STRING_H */ |
#endif /* HAVE_STRING_H */ |
#ifdef HAVE_STRINGS_H |
#ifdef HAVE_UNISTD_H |
#include <strings.h> |
# include <unistd.h> |
#endif /* HAVE_STRINGS_H */ |
#endif /* HAVE_UNISTD_H */ |
#include <errno.h> |
#include <errno.h> |
#include <sys/types.h> |
|
#include <sys/param.h> |
|
#include <sys/stat.h> |
|
|
|
#include "sudo.h" |
#include "sudo.h" |
|
|
#ifndef STDC_HEADERS |
|
extern char *getenv __P((const char *)); |
|
extern char *strcpy __P((char *, const char *)); |
|
extern int fprintf __P((FILE *, const char *, ...)); |
|
extern ssize_t readlink __P((const char *, VOID *, size_t)); |
|
extern int stat __P((const char *, struct stat *)); |
|
extern int lstat __P((const char *, struct stat *)); |
|
#endif /* !STDC_HEADERS */ |
|
|
|
#ifndef lint |
#ifndef lint |
static const char rcsid[] = "$Sudo: find_path.c,v 1.95 2000/01/27 04:31:58 millert Exp $"; |
static const char rcsid[] = "$Sudo: find_path.c,v 1.99 2001/12/14 19:52:47 millert Exp $"; |
#endif /* lint */ |
#endif /* lint */ |
|
|
/* |
/* |
|
|
* but it is in '.' and IGNORE_DOT is set. |
* but it is in '.' and IGNORE_DOT is set. |
*/ |
*/ |
int |
int |
find_path(infile, outfile) |
find_path(infile, outfile, path) |
char *infile; /* file to find */ |
char *infile; /* file to find */ |
char **outfile; /* result parameter */ |
char **outfile; /* result parameter */ |
|
char *path; /* path to search */ |
{ |
{ |
static char command[MAXPATHLEN]; /* qualified filename */ |
static char command[MAXPATHLEN]; /* qualified filename */ |
char *n; /* for traversing path */ |
char *n; /* for traversing path */ |
char *path = NULL; /* contents of PATH env var */ |
|
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? */ |
|
|
return(NOT_FOUND); |
return(NOT_FOUND); |
} |
} |
|
|
/* |
/* Use PATH passed in unless SECURE_PATH is in effect. */ |
* Grab PATH out of the environment (or from the string table |
#ifdef SECURE_PATH |
* if SECURE_PATH is in effect) and make a local copy. |
if (!user_is_exempt()) |
*/ |
path = SECURE_PATH; |
if (def_str(I_SECURE_PATH) && !user_is_exempt()) |
#endif /* SECURE_PATH */ |
path = def_str(I_SECURE_PATH); |
if (path == NULL) |
else if ((path = getenv("PATH")) == NULL) |
|
return(NOT_FOUND); |
return(NOT_FOUND); |
path = estrdup(path); |
path = estrdup(path); |
origpath = path; |
origpath = path; |