diff options
| author | Glenn Morris | 2007-12-11 05:50:37 +0000 |
|---|---|---|
| committer | Glenn Morris | 2007-12-11 05:50:37 +0000 |
| commit | 812498713a4bc715d7aaffb4f68382b73fb83ede (patch) | |
| tree | 5c9d3699eee66094c120b55516daa220f1a187c1 | |
| parent | 57f44ca44a21b5030a29860918b26fad5297e55b (diff) | |
| download | emacs-812498713a4bc715d7aaffb4f68382b73fb83ede.tar.gz emacs-812498713a4bc715d7aaffb4f68382b73fb83ede.zip | |
(url-make-private-file): New function.
| -rw-r--r-- | lisp/url/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/url/url-util.el | 22 |
2 files changed, 29 insertions, 0 deletions
diff --git a/lisp/url/ChangeLog b/lisp/url/ChangeLog index 7016382f71e..aadd79ccc02 100644 --- a/lisp/url/ChangeLog +++ b/lisp/url/ChangeLog | |||
| @@ -1,3 +1,10 @@ | |||
| 1 | 2007-12-11 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * url-util.el (url-make-private-file): New function. | ||
| 4 | * url-cookie.el (url-cookie-write-file): | ||
| 5 | * url-history.el (url-history-save-history): | ||
| 6 | Use url-make-private-file and with-temp-buffer. | ||
| 7 | |||
| 1 | 2007-12-02 Glenn Morris <rgm@gnu.org> | 8 | 2007-12-02 Glenn Morris <rgm@gnu.org> |
| 2 | 9 | ||
| 3 | * url-news.el (nntp-open-tls-stream, nntp-open-ssl-stream): | 10 | * url-news.el (nntp-open-tls-stream, nntp-open-ssl-stream): |
diff --git a/lisp/url/url-util.el b/lisp/url/url-util.el index d7d8e2b4a4b..4f5b4b8cd17 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 |