diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2020-08-24 17:02:48 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2020-08-24 23:23:57 +0200 |
| commit | 384377632c41c5c42e32889f4a239223aaae1ca9 (patch) | |
| tree | b080c748f35e710e51fbec3979ddfe3a930f3cfb /gnu/system.scm | |
| parent | 0d203eeaa69a42a914a9981449805014ab6b7b77 (diff) | |
system: Validate sudoers file when building the system.
Suggested by pkill9 <pkill9@runbox.com>.
* gnu/system.scm (validated-sudoers-file): New procedure.
(operating-system-etc-service): Use it.
Diffstat (limited to 'gnu/system.scm')
| -rw-r--r-- | gnu/system.scm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/gnu/system.scm b/gnu/system.scm index 5dd2f7f680a..f092df56cea 100644 --- a/gnu/system.scm +++ b/gnu/system.scm | |||
| @@ -747,6 +747,18 @@ This is the GNU system. Welcome.\n") | |||
| 747 | "Return the default /etc/hosts file." | 747 | "Return the default /etc/hosts file." |
| 748 | (plain-file "hosts" (local-host-aliases host-name))) | 748 | (plain-file "hosts" (local-host-aliases host-name))) |
| 749 | 749 | ||
| 750 | (define (validated-sudoers-file file) | ||
| 751 | "Return a copy of FILE, a sudoers file, after checking that it is | ||
| 752 | syntactically correct." | ||
| 753 | (computed-file "sudoers" | ||
| 754 | (with-imported-modules '((guix build utils)) | ||
| 755 | #~(begin | ||
| 756 | (use-modules (guix build utils)) | ||
| 757 | |||
| 758 | (invoke #+(file-append sudo "/sbin/visudo") | ||
| 759 | "--check" "--file" #$file) | ||
| 760 | (copy-file #$file #$output))))) | ||
| 761 | |||
| 750 | (define* (operating-system-etc-service os) | 762 | (define* (operating-system-etc-service os) |
| 751 | "Return a <service> that builds containing the static part of the /etc | 763 | "Return a <service> that builds containing the static part of the /etc |
| 752 | directory." | 764 | directory." |
| @@ -873,7 +885,9 @@ fi\n"))) | |||
| 873 | ("timezone" ,(plain-file "timezone" (operating-system-timezone os))) | 885 | ("timezone" ,(plain-file "timezone" (operating-system-timezone os))) |
| 874 | ("localtime" ,(file-append tzdata "/share/zoneinfo/" | 886 | ("localtime" ,(file-append tzdata "/share/zoneinfo/" |
| 875 | (operating-system-timezone os))) | 887 | (operating-system-timezone os))) |
| 876 | ,@(if sudoers `(("sudoers" ,sudoers)) '()) | 888 | ,@(if sudoers |
| 889 | `(("sudoers" ,(validated-sudoers-file sudoers))) | ||
| 890 | '()) | ||
| 877 | ,@(if hurd | 891 | ,@(if hurd |
| 878 | `(("login" ,(file-append hurd "/etc/login")) | 892 | `(("login" ,(file-append hurd "/etc/login")) |
| 879 | ("motd" ,(file-append hurd "/etc/motd")) | 893 | ("motd" ,(file-append hurd "/etc/motd")) |
