mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-26 04:29:25 -05:00
activation: Factorize the link-or-copy trick.
* gnu/build/activation.scm (link-or-copy): New procedure. (activate-setuid-programs): Use it.
This commit is contained in:
parent
f489668723
commit
095f4deb4b
1 changed files with 12 additions and 7 deletions
|
@ -175,19 +175,24 @@ (define %setuid-directory
|
||||||
;; Place where setuid programs are stored.
|
;; Place where setuid programs are stored.
|
||||||
"/run/setuid-programs")
|
"/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)
|
(define (activate-setuid-programs programs)
|
||||||
"Turn PROGRAMS, a list of file names, into setuid programs stored under
|
"Turn PROGRAMS, a list of file names, into setuid programs stored under
|
||||||
%SETUID-DIRECTORY."
|
%SETUID-DIRECTORY."
|
||||||
(define (make-setuid-program prog)
|
(define (make-setuid-program prog)
|
||||||
(let ((target (string-append %setuid-directory
|
(let ((target (string-append %setuid-directory
|
||||||
"/" (basename prog))))
|
"/" (basename prog))))
|
||||||
(catch 'system-error
|
(link-or-copy prog target)
|
||||||
(lambda ()
|
|
||||||
(link prog target))
|
|
||||||
(lambda args
|
|
||||||
;; Perhaps PROG and TARGET live in a different file system, so copy
|
|
||||||
;; PROG.
|
|
||||||
(copy-file prog target)))
|
|
||||||
(chown target 0 0)
|
(chown target 0 0)
|
||||||
(chmod target #o6555)))
|
(chmod target #o6555)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue