git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/doldaconnect@744
959494ce-11ee-0310-bf91-
de5d638817bd
{
char *path, *binpath, *etcpath, *p;
struct passwd *pw;
{
char *path, *binpath, *etcpath, *p;
struct passwd *pw;
+ mode = R_OK | (filldef ? W_OK : 0);
+ 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) && ((pw = getpwuid(getuid())) != NULL))
homedir = pw->pw_dir;
if((homedir != NULL) && ((path = sprintf2("%s/.%s", homedir, uname)) != NULL))
{
- if(!access(path, F_OK))
+ if(!access(path, mode))
return(path);
free(path);
}
return(path);
free(path);
}
{
if(strchr(gname, '/') != NULL)
{
{
if(strchr(gname, '/') != NULL)
{
- if(!access(gname, F_OK))
+ if(!access(gname, mode))
return(sstrdup(gname));
} else {
if((binpath = getenv("PATH")) == NULL)
return(sstrdup(gname));
} else {
if((binpath = getenv("PATH")) == NULL)
{
if((path = sprintf2("%s/%s", p, gname)) != NULL)
{
{
if((path = sprintf2("%s/%s", p, gname)) != NULL)
{
- if(!access(path, F_OK))
+ if(!access(path, mode))
{
free(etcpath);
return(path);
{
free(etcpath);
return(path);
}
if(filldef) {
if(uname && homedir)
}
if(filldef) {
if(uname && homedir)
- return("%s/.%s", homedir, uname);
- return("/etc/%s", gname);
+ return(sprintf2("%s/.%s", homedir, uname));
+ return(sprintf2("/etc/%s", gname));