blessmail.el 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ;;; blessmail.el --- decide whether movemail needs special privileges -*- no-byte-compile: t -*-
  2. ;; Copyright (C) 1994, 2001-2012 Free Software Foundation, Inc.
  3. ;; Maintainer: FSF
  4. ;; Keywords: internal
  5. ;; Package: emacs
  6. ;; This file is part of GNU Emacs.
  7. ;; GNU Emacs is free software: you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;; This is loaded into a bare Emacs to create the blessmail script,
  19. ;; which (on systems that need it) is used during installation
  20. ;; to give appropriate permissions to movemail.
  21. ;;
  22. ;; It has to be done from lisp in order to be sure of getting the
  23. ;; correct value of rmail-spool-directory.
  24. ;;; Code:
  25. ;; These are no longer needed because we run this in emacs instead of temacs.
  26. ;; (message "Using load-path %s" load-path)
  27. ;; (load "paths.el")
  28. ;; It is not safe to load site-init.el here, because it might have things in it
  29. ;; that won't load properly unless all the rest of Emacs is loaded.
  30. (let ((dirname (directory-file-name rmail-spool-directory))
  31. linkname attr modes)
  32. ;; Check for symbolic link
  33. (while (setq linkname (file-symlink-p dirname))
  34. (setq dirname (if (file-name-absolute-p linkname)
  35. linkname
  36. (concat (file-name-directory dirname) linkname))))
  37. (insert "#!/bin/sh\n")
  38. (setq attr (file-attributes dirname))
  39. (if (not (eq t (car attr)))
  40. (insert (format "echo %s is not a directory\n" rmail-spool-directory))
  41. (setq modes (nth 8 attr))
  42. (cond ((= ?w (aref modes 8))
  43. ;; Nothing needs to be done.
  44. )
  45. ((= ?w (aref modes 5))
  46. (insert "chgrp " (number-to-string (nth 3 attr))
  47. " $* && chmod g+s $*\n"))
  48. ((= ?w (aref modes 2))
  49. (insert "chown " (number-to-string (nth 2 attr))
  50. " $* && chmod u+s $*\n"))
  51. (t
  52. (insert "chown root $* && chmod u+s $*\n"))))
  53. (insert "echo mail directory = " dirname "\n"))
  54. (write-region (point-min) (point-max) "blessmail")
  55. (kill-emacs)
  56. ;;; blessmail.el ends here