unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Jan Nieuwenhuizen <janneke@gnu.org>
To: 44261@debbugs.gnu.org
Subject: bug#44261: running a daemon with userns in relocateble pack breaks
Date: Tue, 27 Oct 2020 20:49:19 +0100	[thread overview]
Message-ID: <87blgn30w0.fsf@gnu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1667 bytes --]

Hi!

As mentioned on IRC, running a daemon from a guix relocatable pack on a
foreign distro using the user namespace feature is troublesome: it looks
as if the daemon "loses" (its view of) the file-system once the parent
process that creates the daemon exits.

I'm attatching a package description for a test package "vork".  It
builds a program "test" that forks the program "daemon".

The daemon program reads a character from /dev/urandom, prints it,
and sleeps for a second; 10 times.

The "test" parent program exits after 5 seconds.  When the parent
program exits, the daemon crashes.

To reproduce, put "vork.scm" in a fresh directory and do something like:

--8<---------------cut here---------------start------------->8---
fakeroot tar xf $(GUIX_PACKAGE_PATH=. guix pack --relocatable\
  --symlink=/gnu/bin=bin guile shepherd vork --no-offload)
guix gc -D $(guix build -f vork.scm)
touch /tmp/daemon.log
tail -f /tmp/daemon.log &
GUILE_LOAD_COMPILED_PATH=$PWD/$(ls -1d gnu/store/*profile)/lib/guile/3.0/ccache\
:$PWD/$(ls -1d gnu/store/*profile)/lib/guile/3.0/site-ccache gnu/bin/test
--8<---------------cut here---------------end--------------->8---

this gives something like

--8<---------------cut here---------------start------------->8---
.daemon-start
daemon: 10 ?
.daemon: 9 ?
.daemon: 8 T
.daemon: 7 ^O
.daemon: 6 O

exit
20:42:38 janneke@dundal:~/src/guix/master/vork [env]
$ 20:42:38 janneke@dundal:~/src/guix/master/vork [env]
$ Backtrace:
Exception thrown while printing backtrace:
In procedure public-lookup: Module named (system repl debug) does not exist
--8<---------------cut here---------------end--------------->8---

Greetings,
Janneke


[-- Attachment #2: vork.scm --]
[-- Type: application/octet-stream, Size: 2424 bytes --]

(define-module (vork)
  #:use-module (guix licenses)
  #:use-module (guix build-system trivial)
  #:use-module (guix packages)
  #:use-module (gnu packages admin)
  #:use-module (gnu packages guile)
  #:use-module (gnu packages pkg-config))

(define-public shepherd-guile-3.0-latest
  (package
    (inherit shepherd)
    (native-inputs
     `(("pkg-config" ,pkg-config)
       ("guile" ,guile-3.0-latest)))
    (inputs
     `(("guile" ,guile-3.0-latest)))))

(define-public vork
  (package
    (name "vork")
    (version "0")
    (source #f)
    (build-system trivial-build-system)
    (inputs `(("guile" ,guile-3.0-latest)
              ("shepherd" ,shepherd-guile-3.0-latest)))
    (arguments
     `(#:guile ,guile-3.0-latest
       #:modules ((ice-9 popen)
                  (guix build utils))
       #:builder
       (begin
         (use-modules (ice-9 popen)
                      (guix build utils))
         (let* ((out (assoc-ref %outputs "out"))
                (bin (string-append out "/bin"))
                (guile (assoc-ref %build-inputs "guile"))
                (guile (string-append guile "/bin/guile"))
                (daemon (string-append bin "/daemon"))
                (test (string-append bin "/test")))
           (mkdir-p bin)
           (call-with-output-file test
             (lambda (p)
               (format p "#! ~a --no-auto-compile\n" guile p)
               (format p "!#
(use-modules (shepherd service))
(fork+exec-command (list ~s) #:log-file \"/tmp/daemon.log\")
(let loop ((count 5))
  (unless (zero? count)
    (display \".\")
    (sleep 1)
    (loop (1- count))))
(format #t \"\\nexit\\n\")
" daemon)))
           (chmod test #o755)
           (call-with-output-file daemon
             (lambda (p)
               (format p "#! ~a --no-auto-compile\n" guile p)
               (display "!#
(format #t \"daemon-start\\n\")
(let loop ((count 10))
  (unless (zero? count)
    (let ((char (with-input-from-file \"/dev/urandom\" read-char)))
      (format #t \"daemon: ~a ~a\\n\" count char)
      (force-output (current-output-port))
      (call-with-output-file \"/dev/null\"
        (lambda (p) (format p \"daemon: ~a ~a\\n\" count char)))
      (sleep 1)
      (loop (1- count)))))
(format #t \"\ndaemon-exit\\n\")
" p)))
           (chmod daemon #o755))
         #t)))
    (home-page "https://dezyne.org")
    (synopsis "vork")
    (description "vork")
    (license gpl3+)))

vork


[-- Attachment #3: Type: text/plain, Size: 152 bytes --]


-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

             reply	other threads:[~2020-10-27 19:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 19:49 Jan Nieuwenhuizen [this message]
2020-10-27 20:09 ` bug#44261: running a daemon with userns in relocateble pack breaks Jan Nieuwenhuizen
2020-10-30 21:33   ` Ludovic Courtès
2020-10-30 22:05     ` Jan Nieuwenhuizen
2020-10-31 22:19       ` Ludovic Courtès
2020-11-01  6:07         ` Jan Nieuwenhuizen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87blgn30w0.fsf@gnu.org \
    --to=janneke@gnu.org \
    --cc=44261@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).