/[imapfilter]/imapfilter/file.c
ViewVC logotype

Diff of /imapfilter/file.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.58 by lefcha, Fri Aug 8 00:20:23 2003 UTC revision 1.59 by lefcha, Sat Feb 7 23:54:16 2004 UTC
# Line 13  Line 13 
13    
14    
15  extern char *home;  extern char *home;
16    extern unsigned int options;
17    
18    
19  /*  /*
# Line 30  create_homedir(void) Line 31  create_homedir(void)
31                          error("could not create directory %s; %s\n", hd,                          error("could not create directory %s; %s\n", hd,
32                              strerror(errno));                              strerror(errno));
33          }          }
 #ifdef CHECK_PERMISSIONS  
         else {  
                 check_dir_perms(hd, S_IRUSR | S_IWUSR | S_IXUSR);  
         }  
 #endif  
   
34          return 0;          return 0;
35  }  }
36    
# Line 103  create_file(char *fname, mode_t mode) Line 98  create_file(char *fname, mode_t mode)
98  }  }
99    
100    
 #ifdef CHECK_PERMISSIONS  
101  /*  /*
102   * Check the permissions of a file.   * Check the permissions of a file.
103   */   */
# Line 112  check_file_perms(char *fname, mode_t mod Line 106  check_file_perms(char *fname, mode_t mod
106  {  {
107          struct stat fs;          struct stat fs;
108    
109            if (!(options & OPTION_PERMISSIONS))
110                    return 0;
111    
112          if (stat(fname, &fs)) {          if (stat(fname, &fs)) {
113                  error("getting file %s status; %s\n", fname,                  error("getting file %s status; %s\n", fname,
114                      strerror(errno));                      strerror(errno));
# Line 122  check_file_perms(char *fname, mode_t mod Line 119  check_file_perms(char *fname, mode_t mod
119                  return ERROR_TRIVIAL;                  return ERROR_TRIVIAL;
120          }          }
121          if ((fs.st_mode & 00777) != mode) {          if ((fs.st_mode & 00777) != mode) {
122                  error("warning: improper file %s permissions\n", fname);                  error("warning: file's %s mode should be %o not %o\n", fname,
123                  error("warning: file's mode should be %o not %o\n", mode,                      mode, fs.st_mode & 00777);
                     fs.st_mode & 00777);  
124                  return ERROR_TRIVIAL;                  return ERROR_TRIVIAL;
125          }          }
126          return 0;          return 0;
# Line 133  check_file_perms(char *fname, mode_t mod Line 129  check_file_perms(char *fname, mode_t mod
129    
130  /*  /*
131   * Check the permissions of a directory.   * Check the permissions of a directory.
132   */   *
133  int  int
134  check_dir_perms(char *dname, mode_t mode)  check_dir_perms(char *dname, mode_t mode)
135  {  {
136          struct stat ds;          struct stat ds;
137    
138            if (!(options & OPTION_PERMISSIONS))
139                    return 0;
140    
141          if (stat(dname, &ds)) {          if (stat(dname, &ds)) {
142                  error("getting file %s status; %s\n", dname,                  error("getting file %s status; %s\n", dname,
143                      strerror(errno));                      strerror(errno));
# Line 149  check_dir_perms(char *dname, mode_t mode Line 148  check_dir_perms(char *dname, mode_t mode
148                  return ERROR_TRIVIAL;                  return ERROR_TRIVIAL;
149          }          }
150          if ((ds.st_mode & 00777) != mode) {          if ((ds.st_mode & 00777) != mode) {
151                  error("warning: improper dir %s permissions\n", dname);                  error("warning: dir's %s mode should be %o not %o\n", dname,
152                  error("warning: dir's mode should be %o not %o\n", mode,                  mode, ds.st_mode & 00777);
                     ds.st_mode & 00777);  
153                  return ERROR_TRIVIAL;                  return ERROR_TRIVIAL;
154          }          }
155          return 0;          return 0;
156  }  }*/
 #endif                          /* CHECK_PERMISSIONS */  

Legend:
Removed from v.1.58  
changed lines
  Added in v.1.59

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26