Migrate the old code to use the new functions mutt_file_chmod(),
mutt_file_chmod_add(), mutt_file_chmod_rm() instead of plain chmod().
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));
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)
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));