activation: Make sure /etc/sudoers & co. are regular files.

Before that, 'sudo' would exit with:

  sudo: /etc/sudoers is not a regular file
  sudo: no valid sudoers sources found, quitting

* gnu/build/activation.scm (activate-etc): Check if SOURCE matches
  'file-is-directory?'.  If not, use 'copy-file' instead of 'symlink'.
This commit is contained in:
Ludovic Courtès 2014-09-11 21:34:30 +02:00
parent 286cacaded
commit c6a0536d08
1 changed files with 8 additions and 1 deletions

View File

@ -155,7 +155,14 @@ numeric gid or #f."
(let ((target (string-append "/etc/" file)) (let ((target (string-append "/etc/" file))
(source (string-append "/etc/static/" file))) (source (string-append "/etc/static/" file)))
(rm-f target) (rm-f target)
(symlink source target)))
;; Things such as /etc/sudoers must be regular files, not
;; symlinks; furthermore, they could be modified behind our
;; back---e.g., with 'visudo'. Thus, make a copy instead of
;; symlinking them.
(if (file-is-directory? source)
(symlink source target)
(copy-file source target))))
(scandir etc (scandir etc
(lambda (file) (lambda (file)
(not (member file '("." "..")))) (not (member file '("." ".."))))