Text   |  XML   |  ReML   |   Visible Warnings:

File System Race Condition  at eacces-error.c:65

No properties have been set. | edit properties
Jump to warning location ↓ warning details...
Show Events | Options

mbox_get_list_settings

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/index/mbox/mbox-storage.c)expand/collapse
Show more  
 279  mbox_get_list_settings(struct mailbox_list_settings *list_set,
 280                         const char *data, struct mail_storage *storage,
 281                         const char **layout_r, const char **error_r)
 282  {
 283          enum mail_storage_flags flags = storage->flags;
 284          bool debug = (flags & MAIL_STORAGE_FLAG_DEBUG) != 0;
 285          const char *p;
 286          struct stat st;
 287          bool autodetect;
 288   
 289          *layout_r = "fs";
 290   
 291          memset(list_set, 0, sizeof(*list_set));
 292          list_set->subscription_fname = MBOX_SUBSCRIPTION_FILE_NAME;
 293          list_set->maildir_name = "";
 294   
 295          autodetect = data == NULL || *data == '\0';
 296          if (autodetect) {
 297                  if ((flags & MAIL_STORAGE_FLAG_NO_AUTODETECTION) != 0) {
 298                          *error_r = "Root mail directory not given";
 299                          return -1;
 300                  }
 301   
 302                  /* we'll need to figure out the mail location ourself.
 303                     it's root dir if we've already chroot()ed, otherwise 
 304                     either ~/mail or ~/Mail */
 305[+]                 list_set->root_dir = get_root_dir(storage);
 306                  if (list_set->root_dir == NULL) {
 307                          *error_r = "Autodetection failed";
 308                          return -1;
 309                  }
 310          } else {
 311                  if (debug)
 312                          i_info("mbox: data=%s", data);
 313                  p = strchr(data, ':');
 314                  if ((flags & MAIL_STORAGE_FLAG_NO_AUTODETECTION) == 0 &&
 315                      p == NULL && data[strlen(data)-1] != '/') {
 316                          /* if the data points to a file, treat it as an INBOX */
 317
326
Show [ Lines 317 to 326 omitted. ]
 327                          return -1;
 328                  } else {
 329                          if (mailbox_list_settings_parse(data, list_set,
 330                                                          storage->ns,
 331                                                          layout_r, NULL,
 332                                                          error_r) < 0)
 333                                  return -1;
 334                  }
 335          }
 336   
 337          if (list_set->root_dir == NULL || *list_set->root_dir == '\0') {
 338                  if ((flags & MAIL_STORAGE_FLAG_NO_AUTOCREATE) != 0) {
 339                          *error_r = "Root mail directory not given";
 340                          return -1;
 341                  }
 342   
 343                  list_set->root_dir = create_root_dir(storage, error_r);
 344                  if (list_set->root_dir == NULL)
 345                          return -1;
 346          } else {
 347                  /* make sure the directory exists */
 348                  if (lstat(list_set->root_dir, &st) == 0) {
 349                          /* yep, go ahead */
 350                  } else if (errno == EACCES) {
 351                          *error_r = mail_error_eacces_msg("lstat",
 352[+]                                                          list_set->root_dir);
expand/collapse

mail_error_eacces_msg

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib-storage/mail-error.c)expand/collapse
Show more  
 26  const char *mail_error_eacces_msg(const char *func, const char *path)
 27  {
 28[+]         return eacces_error_get(func, path);
expand/collapse

eacces_error_get

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/eacces-error.c)expand/collapse
Show more  
 153  const char *eacces_error_get(const char *func, const char *path)
 154  {
 155[+]         return eacces_error_get_full(func, path, FALSE);
expand/collapse

eacces_error_get_full

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/eacces-error.c)expand/collapse
Show more  
 83  static const char *
 84  eacces_error_get_full(const char *func, const char *path, bool creating)
 85  {
 86          const char *prev_path = path, *dir = "/", *p;
 87          const struct passwd *pw;
 88          const struct group *group;
 89          string_t *errmsg;
 90          struct stat st, dir_st;
 91          int orig_errno, ret = -1;
 92   
 93          orig_errno = errno;
 94          errmsg = t_str_new(256);
 95          str_printfa(errmsg, "%s(%s) failed: Permission denied (euid=%s",
 96                      func, path, dec2str(geteuid()));
 97   
 98          pw = getpwuid(geteuid());
 99          if (pw != NULL)
 100                  str_printfa(errmsg, "(%s)", pw->pw_name);
 101   
 102          str_printfa(errmsg, " egid=%s", dec2str(getegid()));
 103          group = getgrgid(getegid());
 104          if (group != NULL)
 105                  str_printfa(errmsg, "(%s)", group->gr_name);
 106   
 107          while ((p = strrchr(prev_path, '/')) != NULL) {
 108                  dir = t_strdup_until(prev_path, p);
 109                  ret = stat(dir, &st);
 110                  if (ret == 0)
 111                          break;
 112                  if (errno == EACCES) {
 113                          /* see if we have access to parent directory */
 114                  } else if (errno == ENOENT && creating) {
 115                          /* probably mkdir_parents() failed here, find the first 
 116                             parent directory we couldn't create */
 117                  } else {
 118                          /* some other error, can't handle it */
 119                          str_printfa(errmsg, " stat(%s) failed: %m", dir);
 120                          break;
 121                  }
 122                  prev_path = dir;
 123                  dir = "/";
 124                  dir_st = st;
 125          }
 126   
 127          if (ret == 0) {
 128                  /* dir is the first parent directory we can stat() */
 129[+]                 if (test_access(dir, X_OK, errmsg) < 0) {
 130                          if (errno == EACCES)
 131                                  str_printfa(errmsg, " missing +x perm: %s", dir);
 132                  } else if (creating && test_access(dir, W_OK, errmsg) < 0) {
 133                          if (errno == EACCES)
 134                                  str_printfa(errmsg, " missing +w perm: %s", dir);
 135                  } else if (prev_path == path &&
 136[+]                            test_access(path, R_OK, errmsg) < 0) {
expand/collapse

test_access

(/home/sate/Testcases/c/cve/dovecot-1.2.0/src/lib/eacces-error.c)expand/collapse
Show more  
 29  static int test_access(const char *path, int mode, string_t *errmsg)
 30  {
 31          struct stat st;
 32   
 33          if (getuid() == geteuid()) {
 34                  if (access(path, mode) == 0)
 35                          return 0;
 36   
 37                  if (errno != EACCES) {
 38                          str_printfa(errmsg, " access(%s, %d) failed: %m",
 39                                      path, mode);
 40                  }
 41                  return -1;
 42          }  
 43   
 44          /* access() uses real uid, not effective uid.
 45             we'll have to do these checks manually. */
 46          switch (mode) {
 47          case X_OK:
 48                  if (stat(t_strconcat(path, "/test", NULL), &st) == 0)
 49                          return 0;
 50                  if (errno == ENOENT || errno == ENOTDIR)
 51                          return 0;
 52                  if (errno != EACCES)
 53                          str_printfa(errmsg, " stat(%s/test) failed: %m", path);
 54                  return -1;
 55          case R_OK:
 56                  mode = 04;
 57                  break;
 58          case W_OK:
 59                  mode = 02;
 60                  break;
 61          default:
 62                  i_unreached();
 63          }
 64   
 65          if (stat(path, &st) < 0) {
Show more  
Show more  
Show more  
Show more  
Show more  




Change Warning 7433.25051 : File System Race Condition

Priority:
State:
Finding:
Owner:
Note: