-2007-03-30 19:22 -0700 Brendan Cully <brendan@kublai.com> (e9451c4c0092)
+2007-03-30 19:51 -0700 Brendan Cully <brendan@kublai.com> (4828ffd619f6)
+
+ * mh.c, mutt.h: Move mtime_cur from CONTEXT to mh_data
+
+ * imap/imap.c, imap/imap.h, mh.c: Add close hook for
+ mh/maildir. stat the directory on open. Make IMAP close function
+ match prototype.
* imap/imap.c, mutt.h, mx.c, pop.c: Add function pointer for close
hook in Context. Slowly inch towards function pointers instead of
struct mh_data
{
time_t mtime_cur;
- mode_t mode; /* mode of mail folder. New messages should match. */
+ mode_t mh_umask;
};
/* mh_sequences support */
safe_fclose (&fp);
}
+static inline mode_t mh_umask (CONTEXT* ctx)
+{
+ struct stat st;
+ struct mh_data* data = mh_data (ctx);
+
+ if (data && data->mh_umask)
+ return data->mh_umask;
+
+ if (stat (ctx->path, &st))
+ {
+ dprint (1, (debugfile, "stat failed on %s\n", ctx->path));
+ return 077;
+ }
+
+ return 0777 & ~(st.st_mode);
+}
+
int mh_buffy (const char *path)
{
int i, r = 0;
{
int fd;
char path[_POSIX_PATH_MAX];
+ mode_t omask;
+ struct mh_data* data = mh_data (dest);
+ omask = umask (mh_umask (dest));
FOREVER
{
snprintf (path, _POSIX_PATH_MAX, "%s/.mutt-%s-%d-%d",
dest->path, NONULL (Hostname), (int) getpid (), Counter++);
- if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0600)) == -1)
+ if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1)
{
if (errno != EEXIST)
{
mutt_perror (path);
+ umask (omask);
return -1;
}
}
break;
}
}
+ umask (omask);
if ((*fp = fdopen (fd, "w")) == NULL)
{
struct mh_sequences mhs;
struct maildir **last;
struct mh_data *data;
- struct stat st;
int count;
char msgbuf[STRING];
progress_t progress;
maildir_move_to_context (ctx, &md);
- if (!data->mode)
- {
- if (stat (ctx->path, &st))
- {
- /* shouldn't happen this late */
- dprint (1, (debugfile, "stat failed opening maildir\n"));
- data->mode = 0700;
- }
- else
- data->mode = st.st_mode;
- }
+ if (!data->mh_umask)
+ data->mh_umask = mh_umask (ctx);
return 0;
}
char path[_POSIX_PATH_MAX];
char suffix[16];
char subdir[16];
+ mode_t omask;
if (hdr)
{
else
strfcpy (subdir, "new", sizeof (subdir));
+ omask = umask (mh_umask (dest));
FOREVER
{
snprintf (path, _POSIX_PATH_MAX, "%s/tmp/%s.%ld.%u_%d.%s%s",
dprint (2, (debugfile, "maildir_open_new_message (): Trying %s.\n",
path));
- if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0600)) == -1)
+ if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1)
{
if (errno != EEXIST)
{
+ umask (omask);
mutt_perror (path);
return -1;
}
break;
}
}
+ umask (omask);
if ((msg->fp = fdopen (fd, "w")) == NULL)
{