diff options
author | Ludovic Courtès <ludo@gnu.org> | 2014-09-11 21:25:58 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2014-09-12 00:14:52 +0200 |
commit | 095f4deb4b78c45ab284e47c1f427f9812b5a67b (patch) | |
tree | 83e27f39720566ae9a8cde402b71c59b71f16e76 | |
parent | f489668723113b0802b81c1e7fc2d9d2932961c3 (diff) | |
download | guix-095f4deb4b78c45ab284e47c1f427f9812b5a67b.tar.gz |
activation: Factorize the link-or-copy trick.
* gnu/build/activation.scm (link-or-copy): New procedure. (activate-setuid-programs): Use it.
-rw-r--r-- | gnu/build/activation.scm | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm index 362669cbf9..d17bb7943f 100644 --- a/gnu/build/activation.scm +++ b/gnu/build/activation.scm @@ -175,19 +175,24 @@ numeric gid or #f." ;; Place where setuid programs are stored. "/run/setuid-programs") +(define (link-or-copy source target) + "Attempt to make TARGET a hard link to SOURCE; if it fails, fall back to +copy SOURCE to TARGET." + (catch 'system-error + (lambda () + (link source target)) + (lambda args + ;; Perhaps SOURCE and TARGET live in a different file system, so copy + ;; SOURCE. + (copy-file source target)))) + (define (activate-setuid-programs programs) "Turn PROGRAMS, a list of file names, into setuid programs stored under %SETUID-DIRECTORY." (define (make-setuid-program prog) (let ((target (string-append %setuid-directory "/" (basename prog)))) - (catch 'system-error - (lambda () - (link prog target)) - (lambda args - ;; Perhaps PROG and TARGET live in a different file system, so copy - ;; PROG. - (copy-file prog target))) + (link-or-copy prog target) (chown target 0 0) (chmod target #o6555))) |