From: Reis Radomil Date: Sat, 18 Nov 2017 16:47:32 +0000 (+0100) Subject: Migrate code to use mutt_file_chmod{,_add,_rm} functions X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9e84f134862ad840c4a77695b7f5c0049dc839bf;p=neomutt Migrate code to use mutt_file_chmod{,_add,_rm} functions Migrate the old code to use the new functions mutt_file_chmod(), mutt_file_chmod_add(), mutt_file_chmod_rm() instead of plain chmod(). --- diff --git a/attach.c b/attach.c index 7e4635404..d11d6e499 100644 --- 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) diff --git a/editmsg.c b/editmsg.c index 5a787b4c7..e93bb29c0 100644 --- 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));