-static void
-check_file(
- char * filename,
- int mode)
-{
- struct stat stat_buf;
- char *quoted;
-
- if(!stat(filename, &stat_buf)) {
- if(!S_ISREG(stat_buf.st_mode)) {
- quoted = quote_string(filename);
- printf("ERROR [%s is not a file]\n", quoted);
- amfree(quoted);
- }
- }
- check_access(filename, mode);
-}
-
-static void
-check_dir(
- char * dirname,
- int mode)
-{
- struct stat stat_buf;
- char *quoted;
- char *dir;
-
- if(!stat(dirname, &stat_buf)) {
- if(!S_ISDIR(stat_buf.st_mode)) {
- quoted = quote_string(dirname);
- printf("ERROR [%s is not a directory]\n", quoted);
- amfree(quoted);
- }
- }
- dir = stralloc2(dirname, "/.");
- check_access(dir, mode);
- amfree(dir);
-}
-
-static void
-check_suid(
- char * filename)
-{
-/* The following is only valid for real Unixs */
-#ifndef IGNORE_UID_CHECK
- struct stat stat_buf;
- char *quoted = quote_string(filename);
-
- if(!stat(filename, &stat_buf)) {
- if(stat_buf.st_uid != 0 ) {
- printf("ERROR [%s is not owned by root]\n", quoted);
- }
- if((stat_buf.st_mode & S_ISUID) != S_ISUID) {
- printf("ERROR [%s is not SUID root]\n", quoted);
- }
- }
- else {
- printf("ERROR [can not stat %s]\n", quoted);
- }
- amfree(quoted);
-#else
- (void)filename; /* Quiet unused parameter warning */
-#endif
-}