From: ak1 Date: Sun, 23 Jan 2005 21:47:27 +0000 (+0000) Subject: Andreas Krennmair: X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=commitdiff_plain;h=1d7238dc43311c4545883dc1151bf5b142d88c0b Andreas Krennmair: implemented umask option. git-svn-id: svn://svn.berlios.de/mutt-ng/trunk@26 e385b8ad-14ed-0310-8656-cc95a2468c6d --- diff --git a/ChangeLog.mutt-ng b/ChangeLog.mutt-ng index 3940ac0..6437827 100644 --- a/ChangeLog.mutt-ng +++ b/ChangeLog.mutt-ng @@ -1,4 +1,8 @@ Changes specific to mutt-ng: + +2004-01-23: + * Implemented umask option after Wolfgang Karall's idea + 2004-01-22: * Reverted the xface patch as it broke a lot of things * Removed a few pscan(1) warnings diff --git a/alias.c b/alias.c index 508e24b..1da1582 100644 --- a/alias.c +++ b/alias.c @@ -327,7 +327,7 @@ retry_name: if (mutt_get_field (_("Save to file: "), buf, sizeof (buf), M_FILE) != 0) return; mutt_expand_path (buf, sizeof (buf)); - if ((rc = fopen (buf, "a"))) + if ((rc = safe_fopen (buf, "a"))) { if (mutt_check_alias_name (new->name, NULL)) mutt_quote_filename (buf, sizeof (buf), new->name); diff --git a/attach.c b/attach.c index 06dc12b..2179a49 100644 --- a/attach.c +++ b/attach.c @@ -723,7 +723,7 @@ mutt_save_attachment_open (char *path, int flags) if (flags == M_SAVE_APPEND) return fopen (path, "a"); if (flags == M_SAVE_OVERWRITE) - return fopen (path, "w"); /* __FOPEN_CHECKED__ */ + return safe_fopen (path, "w"); /* __FOPEN_CHECKED__ */ return safe_fopen (path, "w"); } @@ -848,7 +848,7 @@ int mutt_decode_save_attachment (FILE *fp, BODY *m, char *path, if (flags == M_SAVE_APPEND) s.fpout = fopen (path, "a"); else if (flags == M_SAVE_OVERWRITE) - s.fpout = fopen (path, "w"); /* __FOPEN_CHECKED__ */ + s.fpout = safe_fopen (path, "w"); /* __FOPEN_CHECKED__ */ else s.fpout = safe_fopen (path, "w"); diff --git a/commands.c b/commands.c index 5a8862e..29e5d4c 100644 --- a/commands.c +++ b/commands.c @@ -873,7 +873,7 @@ int mutt_update_list_file (char *filename, char *section, char *key, char *line) return (-1); } dprint (1, (debugfile, "Opening %s\n", filename)); - if (!(ofp = fopen (filename, "w"))) + if (!(ofp = safe_fopen (filename, "w"))) { fclose (ifp); mutt_perror _("Unable to open new file for writing"); diff --git a/compile.sh b/compile.sh index 6a8a49d..e967ab5 100755 --- a/compile.sh +++ b/compile.sh @@ -1,4 +1,8 @@ #!/bin/sh # ./configure --enable-pgp --enable-smime --with-regex --enable-pop --enable-imap --enable-nntp --enable-imap-edit-threads --with-ssl --enable-hcache --with-libesmtp && make +if [ `uname -s` = 'Darwin' ] ; then + export CFLAGS="-I/sw/include" + export LDFLAGS="-L/sw/lib" +fi ./configure --enable-pgp --enable-smime --with-regex --enable-pop --enable-imap --enable-nntp --enable-imap-edit-threads --with-ssl --enable-hcache && make diff --git a/compress.c b/compress.c index 6641964..11d4fa4 100644 --- a/compress.c +++ b/compress.c @@ -309,7 +309,7 @@ int mutt_open_append_compressed (CONTEXT *ctx) if (!is_new (ctx->realpath)) if (ctx->magic == M_MBOX || ctx->magic == M_MMDF) - if ((fh = fopen (ctx->path, "w"))) + if ((fh = safe_fopen (ctx->path, "w"))) fclose (fh); /* No error checking - the parent function will catch it */ diff --git a/compress.h b/compress.h new file mode 100644 index 0000000..9dbf027 --- /dev/null +++ b/compress.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 1997 Alain Penders + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +int mutt_can_read_compressed (const char *); +int mutt_can_append_compressed (const char *); +int mutt_open_read_compressed (CONTEXT *); +int mutt_open_append_compressed (CONTEXT *); +int mutt_slow_close_compressed (CONTEXT *); +int mutt_sync_compressed (CONTEXT *); +int mutt_test_compress_command (const char *); +int mutt_check_mailbox_compressed (CONTEXT *); +void mutt_fast_close_compressed (CONTEXT *); diff --git a/edit.c b/edit.c index e29cb66..8cd407b 100644 --- a/edit.c +++ b/edit.c @@ -118,7 +118,7 @@ static int be_barf_file (const char *path, char **buf, int buflen) FILE *f; int i; - if ((f = fopen (path, "w")) == NULL) /* __FOPEN_CHECKED__ */ + if ((f = safe_fopen (path, "w")) == NULL) /* __FOPEN_CHECKED__ */ { addstr (strerror (errno)); addch ('\n'); diff --git a/globals.h b/globals.h index 3d8d510..1c226ea 100644 --- a/globals.h +++ b/globals.h @@ -187,6 +187,7 @@ WHERE short ReadInc; WHERE short SendmailWait; WHERE short SleepTime INITVAL (1); WHERE short Timeout; +WHERE short Umask INITVAL(0077); WHERE short WrapMargin; WHERE short WriteInc; diff --git a/handler.c b/handler.c index 666638b..ccb8069 100644 --- a/handler.c +++ b/handler.c @@ -1897,7 +1897,7 @@ void mutt_body_handler (BODY *b, STATE *s) /* restore final destination and substitute the tempfile for input */ s->fpout = fp; fp = s->fpin; - s->fpin = fopen (tempfile, "r"); + s->fpin = safe_fopen (tempfile, "r"); unlink (tempfile); /* restore the prefix */ diff --git a/init.h b/init.h index c5b325f..e7c8068 100644 --- a/init.h +++ b/init.h @@ -2879,6 +2879,12 @@ struct option_t MuttVars[] = { ** machine without having to enter a password. */ #endif + { "umask", DT_NUM, R_NONE, UL &Umask, 0077 }, + /* + ** .pp + ** This sets the umask that will be used by mutt-ng when creating all + ** kinds of files. If unset, the default value is 077. + */ { "use_8bitmime", DT_BOOL, R_NONE, OPTUSE8BITMIME, 0 }, /* ** .pp diff --git a/lib.c b/lib.c index 33d5757..56d78b5 100644 --- a/lib.c +++ b/lib.c @@ -38,6 +38,8 @@ #include "lib.h" +extern short Umask; + void mutt_nocurses_error (const char *fmt, ...) { va_list ap; @@ -381,6 +383,8 @@ int safe_open (const char *path, int flags) */ FILE *safe_fopen (const char *path, const char *mode) { + /* first set the current umask */ + umask(Umask); if (mode[0] == 'w') { int fd; diff --git a/pgppubring.c b/pgppubring.c index 878b10a..4d6f23a 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -50,6 +50,8 @@ extern char *optarg; extern int optind; +short Umask; /* dirty hack because we need Umask in lib.c but don't want globals.h there */ + #include "sha1.h" #include "md5.h" #include "lib.h"