]> granicus.if.org Git - mutt/commitdiff
Back out $umask.
authorBrendan Cully <brendan@kublai.com>
Wed, 21 Mar 2007 18:26:38 +0000 (11:26 -0700)
committerBrendan Cully <brendan@kublai.com>
Wed, 21 Mar 2007 18:26:38 +0000 (11:26 -0700)
attach.c
globals.h
init.c
init.h
lib.c
mh.c
mx.c

index 609525d712052ebff8e0fbae2d48837ca225c67d..8c3edf2e5df894e19dab463109fe82eb7d0ecce4 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -736,21 +736,12 @@ bail:
 static FILE *
 mutt_save_attachment_open (char *path, int flags)
 {
-  mode_t omask;
-  FILE *fp = NULL;
-
-  omask = umask(Umask);
-
   if (flags == M_SAVE_APPEND)
-    fp = fopen (path, "a");
-  else if (flags == M_SAVE_OVERWRITE)
-    fp = fopen (path, "w");            /* __FOPEN_CHECKED__ */
-  else
-    fp = safe_fopen (path, "w");
-
-  umask(omask);
-
-  return fp;
+    return fopen (path, "a");
+  if (flags == M_SAVE_OVERWRITE)
+    return fopen (path, "w");          /* __FOPEN_CHECKED__ */
+  
+  return safe_fopen (path, "w");
 }
 
 /* returns 0 on success, -1 on error */
index 6c9a16c5535ef25cde36a4602d31fec3301d9623..0d025dfe338d943dc4a3102fd1398596fef45140 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -200,7 +200,6 @@ WHERE short SaveHist;
 WHERE short SendmailWait;
 WHERE short SleepTime INITVAL (1);
 WHERE short Timeout;
-WHERE short Umask;
 WHERE short Wrap;
 WHERE short WriteInc;
 
diff --git a/init.c b/init.c
index 26fed9432d4316e92472c401cb25de6ee11b9c15..0008ab7f77967b63490021e6b400b1b724a1328c 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1980,10 +1980,7 @@ static int parse_set (BUFFER *tmp, BUFFER *s, unsigned long data, BUFFER *err)
          val = *ptr < 0 ? -*ptr : 0;
 
        /* user requested the value of this variable */
-       if (mutt_strcmp (MuttVars[idx].option, "umask") == 0)
-         snprintf (err->data, err->dsize, "%s=0%o", MuttVars[idx].option, val);
-       else
-         snprintf (err->data, err->dsize, "%s=%d", MuttVars[idx].option, val);
+       snprintf (err->data, err->dsize, "%s=%d", MuttVars[idx].option, val);
        break;
       }
 
@@ -2569,10 +2566,7 @@ static int var_to_string (int idx, char* val, size_t len)
     if (mutt_strcmp (MuttVars[idx].option, "wrapmargin") == 0)
       sval = sval > 0 ? 0 : -sval;
 
-    if (mutt_strcmp (MuttVars[idx].option, "umask") == 0)
-      snprintf (tmp, sizeof (tmp), "0%o", sval);
-    else
-      snprintf (tmp, sizeof (tmp), "%d", sval);
+    snprintf (tmp, sizeof (tmp), "%d", sval);
   }
   else if (DTYPE (MuttVars[idx].type) == DT_SORT)
   {
diff --git a/init.h b/init.h
index b940b32ab79a4ad08080579073fc985491ce8c09..0aab36bbb48edb15d43f70f86387594f4d4f4619 100644 (file)
--- a/init.h
+++ b/init.h
@@ -2909,12 +2909,6 @@ struct option_t MuttVars[] = {
   ** machine without having to enter a password.
   */
 #endif
-  { "umask", DT_NUM, R_NONE, &Umask, 0077 },
-  /*
-  ** .pp
-  ** Sets the umask to use when creating mailboxes or saving attachments.
-  */
-  
   { "use_8bitmime",    DT_BOOL, R_NONE, OPTUSE8BITMIME, 0 },
   /*
   ** .pp
diff --git a/lib.c b/lib.c
index 070311c7607c610017609e4af4a741c7db77cd01..e6e80c2edc253583c20d25524641ee492ea8e3b1 100644 (file)
--- a/lib.c
+++ b/lib.c
@@ -570,7 +570,7 @@ int safe_open (const char *path, int flags)
                        safe_dir, sizeof (safe_dir)) == -1)
       return -1;
     
-    if ((fd = open (safe_file, flags, 0666)) < 0)
+    if ((fd = open (safe_file, flags, 0600)) < 0)
     {
       rmdir (safe_dir);
       return fd;
@@ -584,7 +584,7 @@ int safe_open (const char *path, int flags)
   }
   else
   {
-    if ((fd = open (path, flags, 0666)) < 0)
+    if ((fd = open (path, flags, 0600)) < 0)
       return fd;
   }
     
diff --git a/mh.c b/mh.c
index 7a15833bcfcbd89d0adb2e2bb18256a59507a64d..1447d142f1f98b4bf6a08be32f5003ad7a85002e 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -207,7 +207,7 @@ static int mh_mkstemp (CONTEXT * dest, FILE ** fp, char **tgt)
   {
     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, 0666)) == -1)
+    if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0600)) == -1)
     {
       if (errno != EEXIST)
       {
@@ -1145,7 +1145,7 @@ int maildir_open_new_message (MESSAGE * msg, CONTEXT * dest, HEADER * hdr)
     dprint (2, (debugfile, "maildir_open_new_message (): Trying %s.\n",
                path));
 
-    if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0666)) == -1)
+    if ((fd = open (path, O_WRONLY | O_EXCL | O_CREAT, 0600)) == -1)
     {
       if (errno != EEXIST)
       {
diff --git a/mx.c b/mx.c
index 7e8c7a2387d3198daa3ebf0786cb4fdbea95fec9..87c15b8453ceee76fa4845262f1e60df07ab9e35 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -492,7 +492,6 @@ int mx_access (const char* path, int flags)
 static int mx_open_mailbox_append (CONTEXT *ctx, int flags)
 {
   struct stat sb;
-  mode_t omask;
 
   ctx->append = 1;
 
@@ -503,8 +502,6 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int flags)
 
 #endif
   
-  omask = umask(Umask);
-
   if(stat(ctx->path, &sb) == 0)
   {
     ctx->magic = mx_get_magic (ctx->path);
@@ -526,33 +523,33 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int flags)
     {
       char tmp[_POSIX_PATH_MAX];
 
-      if (mkdir (ctx->path, S_IRWXU|S_IRWXG|S_IRWXO))
+      if (mkdir (ctx->path, S_IRWXU))
       {
        mutt_perror (ctx->path);
-       goto err_umask;
+       return (-1);
       }
 
       if (ctx->magic == M_MAILDIR)
       {
        snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
-       if (mkdir (tmp, S_IRWXU|S_IRWXG|S_IRWXO))
+       if (mkdir (tmp, S_IRWXU))
        {
          mutt_perror (tmp);
          rmdir (ctx->path);
-         goto err_umask;
+         return (-1);
        }
 
        snprintf (tmp, sizeof (tmp), "%s/new", ctx->path);
-       if (mkdir (tmp, S_IRWXU|S_IRWXG|S_IRWXO))
+       if (mkdir (tmp, S_IRWXU))
        {
          mutt_perror (tmp);
          snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
          rmdir (tmp);
          rmdir (ctx->path);
-         goto err_umask;
+         return (-1);
        }
        snprintf (tmp, sizeof (tmp), "%s/tmp", ctx->path);
-       if (mkdir (tmp, S_IRWXU|S_IRWXG|S_IRWXO))
+       if (mkdir (tmp, S_IRWXU))
        {
          mutt_perror (tmp);
          snprintf (tmp, sizeof (tmp), "%s/cur", ctx->path);
@@ -560,7 +557,7 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int flags)
          snprintf (tmp, sizeof (tmp), "%s/new", ctx->path);
          rmdir (tmp);
          rmdir (ctx->path);
-         goto err_umask;
+         return (-1);
        }
       }
       else
@@ -568,11 +565,11 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int flags)
        int i;
 
        snprintf (tmp, sizeof (tmp), "%s/.mh_sequences", ctx->path);
-       if ((i = creat (tmp, S_IRWXU|S_IRWXG|S_IRWXO)) == -1)
+       if ((i = creat (tmp, S_IRWXU)) == -1)
        {
          mutt_perror (tmp);
          rmdir (ctx->path);
-         goto err_umask;
+         return (-1);
        }
        close (i);
       }
@@ -581,7 +578,7 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int flags)
   else
   {
     mutt_perror (ctx->path);
-    goto err_umask;
+    return (-1);
   }
 
   switch (ctx->magic)
@@ -598,7 +595,7 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int flags)
          mutt_error (_("Couldn't lock %s\n"), ctx->path);
          safe_fclose (&ctx->fp);
        }
-       goto err_umask;
+       return (-1);
       }
       fseek (ctx->fp, 0, 2);
       break;
@@ -609,15 +606,10 @@ static int mx_open_mailbox_append (CONTEXT *ctx, int flags)
       break;
 
     default:
-      goto err_umask;
+      return (-1);
   }
 
-  umask(omask);
   return 0;
-
- err_umask:
-  umask(omask);
-  return -1;
 }
 
 /*
@@ -1266,7 +1258,6 @@ MESSAGE *mx_open_new_message (CONTEXT *dest, HEADER *hdr, int flags)
   MESSAGE *msg;
   int (*func) (MESSAGE *, CONTEXT *, HEADER *);
   ADDRESS *p = NULL;
-  mode_t omask;
 
   switch (dest->magic)
   {
@@ -1305,8 +1296,6 @@ MESSAGE *mx_open_new_message (CONTEXT *dest, HEADER *hdr, int flags)
 
   if(msg->received == 0)
     time(&msg->received);
-
-  omask = umask(Umask);
   
   if (func (msg, dest, hdr) == 0)
   {
@@ -1332,8 +1321,6 @@ MESSAGE *mx_open_new_message (CONTEXT *dest, HEADER *hdr, int flags)
   else
     FREE (&msg);
 
-  umask(omask);
-
   return msg;
 }