diff options
Diffstat (limited to 'Src/Modules')
-rw-r--r-- | Src/Modules/files.c | 19 | ||||
-rw-r--r-- | Src/Modules/parameter.c | 32 |
2 files changed, 7 insertions, 44 deletions
diff --git a/Src/Modules/files.c b/Src/Modules/files.c index b5e0b5f62..d01a59b03 100644 --- a/Src/Modules/files.c +++ b/Src/Modules/files.c @@ -71,9 +71,6 @@ bin_mkdir(char *nam, char **args, char *ops, int func) mode_t oumask = umask(0); mode_t mode = 0777 & ~oumask; int err = 0; -#ifdef HAVE_PATHCONF - int pathmax = 0; -#endif umask(oumask); if(ops['m']) { @@ -94,21 +91,11 @@ bin_mkdir(char *nam, char **args, char *ops, int func) while(ptr > *args + (**args == '/') && *--ptr == '/') *ptr = 0; -#ifdef HAVE_PATHCONF - errno = 0; - if(((pathmax = pathconf(*args,_PC_PATH_MAX)) == -1) && errno) { - zwarnnam(nam, "%s: %e", *args, errno); - err = 1; - continue; - } - else if((ztrlen(*args) > pathmax - 1) && errno != -1) { -#else - if(ztrlen(*args) > PATH_MAX - 1) { -#endif - zwarnnam(nam, "%s: %e", *args, ENAMETOOLONG); + if(zpathmax(unmeta(*args)) < 0) { + zwarnnam(nam, "%s: %e", *args, errno); err = 1; continue; - } + } if(ops['p']) { char *ptr = *args; diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index 2328eae51..b2b3657c0 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -1397,20 +1397,9 @@ scanpmjobdirs(HashTable ht, ScanFunc func, int flags) static void setpmnameddir(Param pm, char *value) { -#ifdef HAVE_PATHCONF - int pathmax = 0; - errno = 0; - pathmax = pathconf(value, _PC_PATH_MAX); - if ((pathmax == -1) && errno) { - zwarn("%s: %e", value, errno); - } - else if (!value || *value != '/' || ((strlen(value) >= pathmax) && - pathmax != -1)) -#else - if (!value || *value != '/' || strlen(value) >= PATH_MAX) -#endif - zwarn("invalid value: %s", value, 0); + if (!value || *value != '/' || zpathmax(value) < 0) + zwarn((errno ? "%s: %e" : "invalid value: %s"), value, errno); else adduserdir(pm->nam, value, 0, 1); zsfree(value); @@ -1432,9 +1421,6 @@ setpmnameddirs(Param pm, HashTable ht) { int i; HashNode hn, next, hd; -#ifdef HAVE_PATHCONF - int pathmax = 0; -#endif if (!ht) return; @@ -1457,19 +1443,9 @@ setpmnameddirs(Param pm, HashTable ht) v.arr = NULL; v.pm = (Param) hn; -#ifdef HAVE_PATHCONF errno = 0; - if((((pathmax = pathconf(val, _PC_PATH_MAX)) == -1)) && errno) - zwarn("%s: %e", val, errno); - else -#endif - if (!(val = getstrvalue(&v)) || *val != '/' || -#ifdef HAVE_PATHCONF - ((strlen(val) >= pathmax)) && pathmax != -1) -#else - strlen(val) >= PATH_MAX) -#endif - zwarn("invalid value: %s", val, 0); + if (!(val = getstrvalue(&v)) || *val != '/' || zpathmax(val) < 0) + zwarn((errno ? "%s: %e" : "invalid value: %s"), val, errno); else adduserdir(hn->nam, val, 0, 1); } |