X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Flib%2Fgetvservercfgstyle.c;h=7fca17a7b648c61a03a49d8c8a0ab8ca7dca1957;hb=3eb1b2279739d0f16391a3724a9897c686f030d3;hp=ed99a45b0f7076596da82daf0e754add53f99580;hpb=b73136f9960c2b4b58f5064c3fd1d88fbd23f9ec;p=util-vserver.git diff --git a/util-vserver/lib/getvservercfgstyle.c b/util-vserver/lib/getvservercfgstyle.c index ed99a45..7fca17a 100644 --- a/util-vserver/lib/getvservercfgstyle.c +++ b/util-vserver/lib/getvservercfgstyle.c @@ -22,6 +22,7 @@ #include "vserver.h" #include "pathconfig.h" +#include "internal.h" #include #include @@ -40,6 +41,10 @@ isAbsPath(char const *p) return p[0]=='/'; } +#define ISDIR utilvserver_isDirectory(buf, true) +#define ISFILE utilvserver_isFile(buf, true) +#define ISLINK utilvserver_isLink(buf) + vcCfgStyle vc_getVserverCfgStyle(char const *id) { @@ -49,24 +54,27 @@ vc_getVserverCfgStyle(char const *id) MAX(sizeof(CONFDIR "/"),sizeof(DEFAULT_VSERVERDIR "/")) + MAX(sizeof("/legacy"), sizeof(".conf")) - 1]; char * marker = 0; + bool is_path; strcpy(buf, id); marker = buf+l1; strcpy(marker, "/vdir"); - if (access(buf, X_OK)==0) res = vcCFG_RECENT_FULL; - else if (!isRelPath(buf) && !isAbsPath(buf)) { + is_path = isAbsPath(buf) || isRelPath(buf); + if (is_path && (ISDIR || ISLINK)) + res = vcCFG_RECENT_FULL; + else if (!is_path) { strcpy(buf, CONFDIR "/"); strcpy(buf+sizeof(CONFDIR "/") - 1, id); marker = buf+sizeof(CONFDIR "/")+l1 - 1; strcpy(marker, "/vdir"); - if (access(buf, X_OK)==0) res = vcCFG_RECENT_SHORT; + if (ISDIR) res = vcCFG_RECENT_SHORT; else { strcpy(buf, DEFAULT_VSERVERDIR "/"); strcpy(buf+sizeof(DEFAULT_VSERVERDIR)+1 - 1, id); - if (access(buf, X_OK)==0) res = vcCFG_LEGACY; + if (ISDIR) res = vcCFG_LEGACY; } if (res==vcCFG_LEGACY) { @@ -74,7 +82,7 @@ vc_getVserverCfgStyle(char const *id) strcpy(buf+sizeof(CONFDIR "/") - 1, id); strcpy(buf+sizeof(CONFDIR "/")+l1 - 1, ".conf"); - if (access(buf, R_OK)!=0) res = vcCFG_NONE; + if (!ISFILE) res = vcCFG_NONE; } }