- if (strchr(service,'/')) {
- r= stat(service,&stab);
- if (r) syscallfailure("execute-from-path (contains slash)"
- " cannot check for executable `%s'",service);
- execpath= service;
- } else {
- string= getenv("PATH");
- if (!string) failure("execute-from-path, but daemon inherited no PATH !");
- while (string) {
- delim= strchr(string,':');
- if (delim) {
- if (delim-string > INT_MAX)
- failure("execute-from-path, but PATH component too long");
- partsize= delim-string;
- nextstring= delim+1;
- } else {
- partsize= strlen(string);
- nextstring= 0;
- }
- part= xstrsubsave(string,partsize);
- exectry= part[0] ? xstrcat3save(part,"/",service) : xstrsave(service);
- free(part);
- r= stat(exectry,&stab);
- if (!r) { execpath= exectry; break; }
- free(exectry);
- string= nextstring;
- }
- if (!execpath) failure("execute-from-path, but program `%s' not found",service);
- }