annotate lisp/utils/blessmail.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children ac2d302a0011
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; blessmail.el --- Decide whether movemail needs special privileges.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;;; Copyright (C) 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Maintainer: FSF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: internal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Synched up with: FSF 19.30.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; This is loaded into a bare Emacs to create the blessmail script,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; which (on systems that need it) is used during installation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; to give appropriate permissions to movemail.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; It has to be done from lisp in order to be sure of getting the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; correct value of rmail-spool-directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; These are no longer needed because we run this in emacs instead of temacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; (message "Using load-path %s" load-path)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; (load "paths.el")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; It is not safe to load site-init.el here, because it might have things in it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; that won't load properly unless all the rest of Emacs is loaded.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (let ((dirname (directory-file-name rmail-spool-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 linkname attr modes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; Check for symbolic link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 (while (setq linkname (file-symlink-p dirname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (setq dirname (if (file-name-absolute-p linkname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 linkname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (concat (file-name-directory dirname) linkname))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 (insert "#!/bin/sh\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (setq attr (file-attributes dirname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (if (not (eq t (car attr)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 (insert (format "echo %s is not a directory\n" rmail-spool-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (setq modes (nth 8 attr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (cond ((= ?w (aref modes 8))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; Nothing needs to be done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ((= ?w (aref modes 5))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (insert "chgrp " (number-to-string (nth 3 attr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 " $* && chmod g+s $*\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ((= ?w (aref modes 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (insert "chown " (number-to-string (nth 2 attr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 " $* && chmod u+s $*\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (insert "chown root $* && chmod u+s $*\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (insert "echo mail directory = " dirname "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (write-region (point-min) (point-max) "blessmail")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (kill-emacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;; blessmail.el ends here