git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@869
959494ce-11ee-0310-bf91-
de5d638817bd
-char *findfile(char *gname, char *uname, char *homedir, int filldef)
+char *findfile(char *name, char *homedir, int filldef)
{
char *path, *binpath, *etcpath, *p;
struct passwd *pw;
{
char *path, *binpath, *etcpath, *p;
struct passwd *pw;
+ if(name == NULL)
+ return(NULL);
+
mode = R_OK | (filldef ? W_OK : 0);
mode = R_OK | (filldef ? W_OK : 0);
+ homeonly = homedir != NULL;
+
+ if(!strchr(name, '/'))
+ {
if(homedir == NULL)
homedir = getenv("HOME");
if((homedir == NULL) && ((pw = getpwuid(getuid())) != NULL))
homedir = pw->pw_dir;
if(homedir == NULL)
homedir = getenv("HOME");
if((homedir == NULL) && ((pw = getpwuid(getuid())) != NULL))
homedir = pw->pw_dir;
- if((homedir != NULL) && ((path = sprintf2("%s/.%s", homedir, uname)) != NULL))
+ if((homedir != NULL) && ((path = sprintf2("%s/.%s", homedir, name)) != NULL))
{
if(!access(path, mode))
return(path);
free(path);
}
}
{
if(!access(path, mode))
return(path);
free(path);
}
}
- if(strchr(gname, '/') != NULL)
+ if(strchr(name, '/') != NULL)
- if(!access(gname, mode))
- return(sstrdup(gname));
+ if(!access(name, mode))
+ return(sstrdup(name));
} else {
if((binpath = getenv("PATH")) == NULL)
etcpath = sstrdup("/usr/local/etc:/etc:/usr/etc");
} else {
if((binpath = getenv("PATH")) == NULL)
etcpath = sstrdup("/usr/local/etc:/etc:/usr/etc");
etcpath = getetcpath(binpath);
for(p = strtok(etcpath, ":"); p != NULL; p = strtok(NULL, ":"))
{
etcpath = getetcpath(binpath);
for(p = strtok(etcpath, ":"); p != NULL; p = strtok(NULL, ":"))
{
- if((path = sprintf2("%s/%s", p, gname)) != NULL)
+ if((path = sprintf2("%s/%s", p, name)) != NULL)
{
if(!access(path, mode))
{
{
if(!access(path, mode))
{
- if(uname && homedir)
- return(sprintf2("%s/.%s", homedir, uname));
- return(sprintf2("/etc/%s", gname));
+ if(homedir)
+ return(sprintf2("%s/.%s", homedir, name));
+ return(sprintf2("/etc/%s", name));