guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch wip-offload updated: tmp7


From: Mathieu Othacehe
Subject: branch wip-offload updated: tmp7
Date: Sun, 13 Dec 2020 11:09:32 -0500

This is an automated email from the git hooks/post-receive script.

mothacehe pushed a commit to branch wip-offload
in repository guix-cuirass.

The following commit(s) were added to refs/heads/wip-offload by this push:
     new 7aae9c3  tmp7
7aae9c3 is described below

commit 7aae9c3321fa274c0756dfff463db97c5d87ec4d
Author: Mathieu Othacehe <othacehe@gnu.org>
AuthorDate: Sun Dec 13 17:09:20 2020 +0100

    tmp7
---
 src/cuirass/remote-server.scm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/cuirass/remote-server.scm b/src/cuirass/remote-server.scm
index d233475..3e96446 100644
--- a/src/cuirass/remote-server.scm
+++ b/src/cuirass/remote-server.scm
@@ -82,6 +82,8 @@ Start a remote build server.\n"))
   (display (G_ "
   -c, --cache=DIRECTORY     cache built items to DIRECTORY"))
   (display (G_ "
+  -u, --user=USER           change privileges to USER as soon as possible"))
+  (display (G_ "
       --public-key=FILE     use FILE as the public key for signatures"))
   (display (G_ "
       --private-key=FILE    use FILE as the private key for signatures"))
@@ -113,6 +115,9 @@ Start a remote build server.\n"))
         (option '(#\c "cache") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'cache arg result)))
+        (option '(#\u "user") #t #f
+                (lambda (opt name arg result)
+                  (alist-cons 'user arg result)))
         (option '("public-key") #t #f
                 (lambda (opt name arg result)
                   (alist-cons 'public-key-file arg result)))
@@ -518,6 +523,18 @@ exiting."
 
         (exit 1)))))
 
+(define (gather-user-privileges user)
+  "switch to the identity of user, a user name."
+  (catch 'misc-error
+    (lambda ()
+      (let ((user (getpw user)))
+        (setgroups #())
+        (setgid (passwd:gid user))
+        (setuid (passwd:uid user))))
+    (lambda (key proc message args . rest)
+      (leave (G_ "user '~a' not found: ~a~%")
+             user (apply format #f message args)))))
+
 (define (remote-server args)
   (signal-handler)
 
@@ -532,6 +549,7 @@ exiting."
            (backend-port (assoc-ref opts 'backend-port))
            (publish-port (assoc-ref opts 'publish-port))
            (cache (assoc-ref opts 'cache))
+           (user (assoc-ref opts 'user))
            (public-key
             (read-file-sexp
              (assoc-ref opts 'public-key-file)))
@@ -543,6 +561,8 @@ exiting."
                      (%cache-directory cache)
                      (%public-key public-key)
                      (%private-key private-key))
+        (when user
+          (gather-user-privileges user))
 
         (atomic-box-set!
          %publish-pid



reply via email to

[Prev in Thread] Current Thread [Next in Thread]