unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#44261: running a daemon with userns in relocateble pack breaks
@ 2020-10-27 19:49 Jan Nieuwenhuizen
  2020-10-27 20:09 ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Nieuwenhuizen @ 2020-10-27 19:49 UTC (permalink / raw)
  To: 44261

[-- 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-11-01  6:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 19:49 bug#44261: running a daemon with userns in relocateble pack breaks Jan Nieuwenhuizen
2020-10-27 20:09 ` 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

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).