* mm-decode.el (mm-file-name-delete-control)
        (mm-file-name-delete-gotchas): New functions.
        (mm-file-name-rewrite-functions): Use them.
+       (mm-attachment-file-modes): New option.
+       (mm-save-part-to-file): Use it.
 
 2003-10-02  Reiner Steib  <Reiner.Steib@gmx.de>
 
 
   :type '(choice directory (const :tag "Default" nil))
   :group 'mime-display)
 
+(defcustom mm-attachment-file-modes ?\600
+  "Set the mode bits of saved attachments to this integer."
+  :type 'integer
+  :group 'mime-display)
+
 (defcustom mm-external-terminal-program "xterm"
   "The program to start an external terminal."
   :type 'string
   (mm-with-unibyte-buffer
     (mm-insert-part handle)
     (let ((coding-system-for-write 'binary)
+         (current-file-modes (default-file-modes))
          ;; Don't re-compress .gz & al.  Arguably we should make
          ;; `file-name-handler-alist' nil, but that would chop
          ;; ange-ftp, which is reasonable to use here.
          (inhibit-file-name-operation 'write-region)
          (inhibit-file-name-handlers
           (cons 'jka-compr-handler inhibit-file-name-handlers)))
-      (write-region (point-min) (point-max) file))))
+      (set-default-file-modes mm-attachment-file-modes)
+      (unwind-protect
+         (write-region (point-min) (point-max) file)
+       (set-default-file-modes current-file-modes)))))
 
 (defun mm-pipe-part (handle)
   "Pipe HANDLE to a process."