diff options
| author | Glenn Morris | 2007-12-11 05:48:40 +0000 |
|---|---|---|
| committer | Glenn Morris | 2007-12-11 05:48:40 +0000 |
| commit | 8703ea5358af50c74f3958cc699707731b253ecc (patch) | |
| tree | d731e33081bb43fe2db75b92d2269240b0de72da | |
| parent | 4577244fc903ff0344abd1f9cf3d75e50b4fa953 (diff) | |
| download | emacs-8703ea5358af50c74f3958cc699707731b253ecc.tar.gz emacs-8703ea5358af50c74f3958cc699707731b253ecc.zip | |
(url-make-private-file): New function.
| -rw-r--r-- | lisp/url/url-util.el | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el index 119f40b4da4..865c3981ec1 100644 --- a/lisp/url/url-util.el +++ b/lisp/url/url-util.el | |||
| @@ -523,6 +523,28 @@ Has a preference for looking backward when not directly on a symbol." | |||
| 523 | (set (make-local-variable 'url-current-mime-headers) | 523 | (set (make-local-variable 'url-current-mime-headers) |
| 524 | (mail-header-extract))))) | 524 | (mail-header-extract))))) |
| 525 | 525 | ||
| 526 | (defun url-make-private-file (file) | ||
| 527 | "Make FILE only readable and writable by the current user. | ||
| 528 | Creates FILE and its parent directories if they do not exist." | ||
| 529 | (let ((dir (file-name-directory file))) | ||
| 530 | (when dir | ||
| 531 | ;; For historical reasons. | ||
| 532 | (make-directory dir t))) | ||
| 533 | ;; Based on doc-view-make-safe-dir. | ||
| 534 | (condition-case nil | ||
| 535 | (let ((umask (default-file-modes))) | ||
| 536 | (unwind-protect | ||
| 537 | (progn | ||
| 538 | (set-default-file-modes #o0600) | ||
| 539 | (with-temp-buffer | ||
| 540 | (write-region (point-min) (point-max) | ||
| 541 | file nil 'silent nil 'excl))) | ||
| 542 | (set-default-file-modes umask))) | ||
| 543 | (file-already-exists | ||
| 544 | (if (file-symlink-p file) | ||
| 545 | (error "Danger: `%s' is a symbolic link" file)) | ||
| 546 | (set-file-modes file #o0600)))) | ||
| 547 | |||
| 526 | (provide 'url-util) | 548 | (provide 'url-util) |
| 527 | 549 | ||
| 528 | ;; arch-tag: 24352abc-5a5a-412e-90cd-313b26bed5c9 | 550 | ;; arch-tag: 24352abc-5a5a-412e-90cd-313b26bed5c9 |