]> granicus.if.org Git - neomutt/commitdiff
Migrate code to use mutt_file_chmod{,_add,_rm} functions
authorReis Radomil <reisradomil@fake-box.com>
Sat, 18 Nov 2017 16:47:32 +0000 (17:47 +0100)
committerRichard Russon <rich@flatcap.org>
Mon, 20 Nov 2017 12:40:51 +0000 (12:40 +0000)
Migrate the old code to use the new functions mutt_file_chmod(),
mutt_file_chmod_add(), mutt_file_chmod_rm() instead of plain chmod().

attach.c
editmsg.c

index 7e4635404360c114272bca7753551b6a44bc3cde..d11d6e4990fcc48cb71b55e5ff14dde00c040877 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -453,7 +453,7 @@ int mutt_view_attachment(FILE *fp, struct Body *a, int flag, struct Header *hdr,
       FREE(&fname);
       if (mutt_save_attachment(fp, a, tempfile, 0, NULL) == -1)
         goto return_error;
-      chmod(tempfile, 0400);
+      mutt_file_chmod(tempfile, S_IRUSR);
     }
 
     use_pipe = rfc1524_expand_command(a, tempfile, type, command, sizeof(command));
@@ -631,7 +631,7 @@ return_error:
   if (fp && tempfile[0])
   {
     /* Restore write permission so mutt_file_unlink can open the file for writing */
-    chmod(tempfile, 0600);
+    mutt_file_chmod_add(tempfile, S_IWUSR);
     mutt_file_unlink(tempfile);
   }
   else if (unlink_tempfile)
index 5a787b4c72d73af7c52e6f3ce0672061031deff6..e93bb29c06f8ee7038f306eb6ce289accb6cfe69 100644 (file)
--- a/editmsg.c
+++ b/editmsg.c
@@ -120,10 +120,10 @@ static int edit_or_view_one_message(bool edit, struct Context *ctx, struct Heade
     goto bail;
   }
 
-  /* remove write permissions */
   if (!edit)
   {
-    rc = chmod(tmp, sb.st_mode & ~(S_IWUSR | S_IWGRP | S_IWOTH));
+    /* remove write permissions */
+    rc = mutt_file_chmod_rm_stat(tmp, S_IWUSR | S_IWGRP | S_IWOTH, &sb);
     if (rc == -1)
     {
       mutt_debug(1, "Could not remove write permissions of %s: %s", tmp, strerror(errno));