static boolean isSafeExecutable (const char* path) { fileStatus *file; boolean r; Assert (path); file = eStat (path); if (!file->exists) { /* The file doesn't exist. So I cannot say it is unsafe. The caller should handle this case. */ r = TRUE; } else if (file->isSetuid) { error (WARNING, "xcmd doesn't run a setuid executable: %s", path); r = FALSE; } else if (file->isSetgid) { error (WARNING, "xcmd doesn't run a setgid executable: %s", path); r = FALSE; } else r = TRUE; eStatFree (file); return r; }
extern langType getFileLanguage (const char *const fileName) { langType language = Option.language; if (language == LANG_AUTO) { language = getExtensionLanguage (fileExtension (fileName)); if (language == LANG_IGNORE) language = getPatternLanguage (fileName); #ifdef SYS_INTERPRETER if (language == LANG_IGNORE) { fileStatus *status = eStat (fileName); if (status->isExecutable) language = getInterpreterLanguage (fileName); } #endif } return language; }
static boolean createTagsForEntry (const char *const entryName) { boolean resize = FALSE; fileStatus *status = eStat (entryName); Assert (entryName != NULL); if (isExcludedFile (entryName)) verbose ("excluding \"%s\"\n", entryName); else if (status->isSymbolicLink && ! Option.followLinks) verbose ("ignoring \"%s\" (symbolic link)\n", entryName); else if (! status->exists) error (WARNING | PERROR, "cannot open source file \"%s\"", entryName); else if (status->isDirectory) resize = recurseIntoDirectory (entryName); else if (! status->isNormalFile) verbose ("ignoring \"%s\" (special file)\n", entryName); else resize = parseFile (entryName); return resize; }
extern boolean isRecursiveLink (const char* const dirName) { boolean result = FALSE; fileStatus *status = eStat (dirName); if (status->isSymbolicLink) { char* const path = absoluteFilename (dirName); while (path [strlen (path) - 1] == PATH_SEPARATOR) path [strlen (path) - 1] = '\0'; while (! result && strlen (path) > (size_t) 1) { char *const separator = strrchr (path, PATH_SEPARATOR); if (separator == NULL) break; else if (separator == path) /* backed up to root directory */ *(separator + 1) = '\0'; else *separator = '\0'; result = isSameFile (path, dirName); } eFree (path); } return result; }
extern boolean doesExecutableExist (const char *const fileName) { fileStatus *status = eStat (fileName); return status->exists && status->isExecutable; }
extern boolean doesFileExist (const char *const fileName) { fileStatus *status = eStat (fileName); return status->exists; }