GNU bug report logs - #30256
[PATCH 3/3] scripts: environment: Add --no-cwd.

Previous Next

Package: guix-patches;

Reported by: Mike Gerwitz <mtg <at> gnu.org>

Date: Fri, 26 Jan 2018 03:31:03 UTC

Severity: normal

Tags: moreinfo, patch

Merged with 30254

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 30256 in the body.
You can then email your comments to 30256 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Fri, 26 Jan 2018 03:31:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mike Gerwitz <mtg <at> gnu.org>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 26 Jan 2018 03:31:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: guix-patches <at> gnu.org
Subject: [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Thu, 25 Jan 2018 22:29:45 -0500
[Message part 1 (text/plain, inline)]
* doc/guix.texi (Invoking guix environment): Add --no-cwd.
* guix/scripts/environment.scm (show-help, %options): Add --no-cwd.
(launch-environment/container): Add 'map-cwd?' param; only add mapping for cwd
if #t.  Only change to cwd within container if #t, otherwise home.
(guix-environment): Error if --no-cwd without --container.  Provide '(not
no-cwd?)' to launch-environment/container as 'map-cwd?'.
* tests/guix-environment.sh: Add test for no-cwd.
---
 doc/guix.texi                |  8 ++++++++
 guix/scripts/environment.scm | 33 ++++++++++++++++++++++++---------
 tests/guix-environment.sh    |  8 ++++++++
 3 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 8218c6637..ce4545038 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -7209,6 +7209,14 @@ While this will limit the leaking of user identity through home paths
 and each of the user fields, this is only one useful component of a
 broader privacy/anonymity solution---not one in and of itself.
 
+@item --no-cwd
+For containers, the default behavior is to share the current working
+directory with the isolated container and immediately change to that
+directory within the container.  If this is undesirable, @code{--no-cwd}
+will cause the current working directory to @emph{not} be automatically
+shared and will change to the user's home directory within the container
+instead.  See also @code{--user}.
+
 @item --expose=@var{source}[=@var{target}]
 For containers, expose the file system @var{source} from the host system
 as the read-only file system @var{target} within the container.  If
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index f50018faf..6be263a64 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -165,6 +165,9 @@ COMMAND or an interactive shell in that environment.\n"))
   -u, --user=USER        instead of copying the name and home of the current
                          user into an isolated container, use the name USER
                          with home directory /home/USER"))
+  (display (G_ "
+      --no-cwd           do not share current working directory with an
+                         isolated container"))
   (display (G_ "
       --share=SPEC       for containers, share writable host file system
                          according to SPEC"))
@@ -251,6 +254,9 @@ COMMAND or an interactive shell in that environment.\n"))
                  (lambda (opt name arg result)
                    (alist-cons 'user arg
                                (alist-delete 'user result eq?))))
+         (option '("no-cwd") #f #f
+                 (lambda (opt name arg result)
+                   (alist-cons 'no-cwd? #t result)))
          (option '("share") #t #f
                  (lambda (opt name arg result)
                    (alist-cons 'file-system-mapping
@@ -399,7 +405,8 @@ environment variables are cleared before setting the new ones."
            ((_ . status) status)))))
 
 (define* (launch-environment/container #:key command bash user user-mappings
-                                       profile paths link-profile? network?)
+                                       profile paths link-profile? network?
+                                       map-cwd?)
   "Run COMMAND within a container that features the software in PROFILE.
 Environment variables are set according to PATHS, a list of native search
 paths.  The global shell is BASH, a file name for a GNU Bash binary in the
@@ -425,11 +432,13 @@ will be used for the passwd entry.  LINK-PROFILE? creates a symbolic link from
              (override-user-mappings
               user home
               (append user-mappings
-                      ;; Current working directory.
-                      (list (file-system-mapping
-                             (source cwd)
-                             (target cwd)
-                             (writable? #t)))
+                      ;; Share current working directory, unless asked not to.
+                      (if map-cwd?
+                          (list (file-system-mapping
+                                 (source cwd)
+                                 (target cwd)
+                                 (writable? #t)))
+                          '())
                       ;; When in Rome, do as Nix build.cc does: Automagically
                       ;; map common network configuration files.
                       (if network?
@@ -488,8 +497,10 @@ will be used for the passwd entry.  LINK-PROFILE? creates a symbolic link from
                 (newline port)))
 
             ;; For convenience, start in the user's current working
-            ;; directory rather than the root directory.
-            (chdir (override-user-dir user home cwd))
+            ;; directory or, if unmapped, the home directory.
+            (chdir (if map-cwd?
+                       (override-user-dir user home cwd)
+                       home-dir))
 
             (primitive-exit/status
              ;; A container's environment is already purified, so no need to
@@ -640,6 +651,7 @@ message if any test fails."
            (container? (assoc-ref opts 'container?))
            (link-prof? (assoc-ref opts 'link-profile?))
            (network?   (assoc-ref opts 'network?))
+           (no-cwd?    (assoc-ref opts 'no-cwd?))
            (user       (assoc-ref opts 'user))
            (bootstrap? (assoc-ref opts 'bootstrap?))
            (system     (assoc-ref opts 'system))
@@ -677,6 +689,8 @@ message if any test fails."
         (leave (G_ "--link-prof cannot be used without --container~%")))
       (when (and (not container?) user)
         (leave (G_ "--user cannot be used without --container~%")))
+      (when (and (not container?) no-cwd?)
+        (leave (G_ "--no-cwd cannot be used without --container~%")))
 
       (with-store store
         (set-build-options-from-command-line store opts)
@@ -729,7 +743,8 @@ message if any test fails."
                                                   #:profile profile
                                                   #:paths paths
                                                   #:link-profile? link-prof?
-                                                  #:network? network?)))
+                                                  #:network? network?
+                                                  #:map-cwd? (not no-cwd?))))
                  (else
                   (return
                    (exit/status
diff --git a/tests/guix-environment.sh b/tests/guix-environment.sh
index a1ce96579..abb019794 100644
--- a/tests/guix-environment.sh
+++ b/tests/guix-environment.sh
@@ -84,6 +84,14 @@ HOME="$tmpdir" guix environment --bootstrap --container --user=foognu \
      --share="$tmpdir/umock" \
      -- guile -c "$usertest"
 
+# if not sharing CWD, chdir home
+(
+  cd "$tmpdir" \
+    && guix environment --bootstrap --container --no-cwd --user=foo  \
+            --ad-hoc guile-bootstrap --pure \
+            -- /bin/sh -c 'test $(pwd) == "/home/foo" -a ! -d '"$tmpdir"
+)
+
 # Make sure '-r' works as expected.
 rm -f "$gcroot"
 expected="`guix environment --bootstrap --ad-hoc guile-bootstrap \
-- 
2.15.1

[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Fri, 02 Mar 2018 10:55:01 GMT) Full text and rfc822 format available.

Message #8 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mike Gerwitz <mtg <at> gnu.org>
Cc: 30256 <at> debbugs.gnu.org
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Fri, 02 Mar 2018 11:54:30 +0100
Mike Gerwitz <mtg <at> gnu.org> skribis:

> * doc/guix.texi (Invoking guix environment): Add --no-cwd.
> * guix/scripts/environment.scm (show-help, %options): Add --no-cwd.
> (launch-environment/container): Add 'map-cwd?' param; only add mapping for cwd
> if #t.  Only change to cwd within container if #t, otherwise home.
> (guix-environment): Error if --no-cwd without --container.  Provide '(not
> no-cwd?)' to launch-environment/container as 'map-cwd?'.
> * tests/guix-environment.sh: Add test for no-cwd.

This one LGTM as well (with the test moved to
guix-environment-container.sh).  There’s just a minor issue:

> --- a/tests/guix-environment.sh
> +++ b/tests/guix-environment.sh
> @@ -84,6 +84,14 @@ HOME="$tmpdir" guix environment --bootstrap --container --user=foognu \
>       --share="$tmpdir/umock" \
>       -- guile -c "$usertest"
>  
> +# if not sharing CWD, chdir home
> +(
> +  cd "$tmpdir" \
> +    && guix environment --bootstrap --container --no-cwd --user=foo  \
> +            --ad-hoc guile-bootstrap --pure \
> +            -- /bin/sh -c 'test $(pwd) == "/home/foo" -a ! -d '"$tmpdir"
> +)
> +

This test would fail for me because my test store is at
~ludo/src/guix/test-tmp/store and my CWD is ~/src/guix.  So when using
both --user and --no-cwd, the effect is that
~ludo/src/guix/test-tmp/store is not available at all within the
container, and thus execve("/bin/sh") fails with ENOENT:

--8<---------------cut here---------------start------------->8---
$ ./test-env guix environment --bootstrap --container --no-cwd --user=foo --ad-hoc guile-bootstrap
accepted connection from pid 29684, user ludo
accepted connection from pid 29695, user ludo
./test-env: line 1: 29683 Terminated              "/home/ludo/src/guix/pre-inst-env" "/home/ludo/src/guix/guix-daemon" --disable-chroot --substitute-urls="$GUIX_BINARY_SUBSTITUTE_URL"
$ echo $?
1
--8<---------------cut here---------------end--------------->8---

Thoughts?

TIA,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Fri, 02 Mar 2018 18:03:02 GMT) Full text and rfc822 format available.

Message #11 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 30256 <at> debbugs.gnu.org
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Fri, 02 Mar 2018 13:00:36 -0500
[Message part 1 (text/plain, inline)]
Hey, Ludo!

Sorry I've been silent on the script you provided to me---between my GNU
volunteer work and preparing for my LP2018 talk, I've had no free time,
so I haven't even looked at it yet.  After the conference I'll have the
time to collaborate a bit more.

Also---I thought the decision was that this patchset was inappropriate
for `guix environment`; did I misinterpret?

On Fri, Mar 02, 2018 at 11:54:30 +0100, Ludovic Courtès wrote:
>> --- a/tests/guix-environment.sh
>> +++ b/tests/guix-environment.sh
>> @@ -84,6 +84,14 @@ HOME="$tmpdir" guix environment --bootstrap --container --user=foognu \
>>       --share="$tmpdir/umock" \
>>       -- guile -c "$usertest"
>>  
>> +# if not sharing CWD, chdir home
>> +(
>> +  cd "$tmpdir" \
>> +    && guix environment --bootstrap --container --no-cwd --user=foo  \
>> +            --ad-hoc guile-bootstrap --pure \
>> +            -- /bin/sh -c 'test $(pwd) == "/home/foo" -a ! -d '"$tmpdir"
>> +)
>> +
>
> This test would fail for me because my test store is at
> ~ludo/src/guix/test-tmp/store and my CWD is ~/src/guix.  So when using
> both --user and --no-cwd, the effect is that
> ~ludo/src/guix/test-tmp/store is not available at all within the
> container, and thus execve("/bin/sh") fails with ENOENT:
>
> $ ./test-env guix environment --bootstrap --container --no-cwd --user=foo --ad-hoc guile-bootstrap
> accepted connection from pid 29684, user ludo
> accepted connection from pid 29695, user ludo
> ./test-env: line 1: 29683 Terminated              "/home/ludo/src/guix/pre-inst-env" "/home/ludo/src/guix/guix-daemon" --disable-chroot --substitute-urls="$GUIX_BINARY_SUBSTITUTE_URL"
> $ echo $?
> 1
>
> Thoughts?

I admit that I forgot some of the implementation details of my own
patch; I'd have to look at it in more detail.  I'll consider it tonight
or this weekend.

Thanks for taking a look at and applying these.  If there are better
solutions, I'm fine with that---I just wanted a proof-of-concept to
start the discussion.  Though, starting the discussion and then ducking
out for other obligations wasn't quite what I had in mind...

-- 
Mike Gerwitz
Free Software Hacker+Activist | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Sat, 03 Mar 2018 14:45:01 GMT) Full text and rfc822 format available.

Message #14 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mike Gerwitz <mtg <at> gnu.org>
Cc: 30256 <at> debbugs.gnu.org
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Sat, 03 Mar 2018 15:44:43 +0100
Hi Mike,

Mike Gerwitz <mtg <at> gnu.org> skribis:

> Sorry I've been silent on the script you provided to me---between my GNU
> volunteer work and preparing for my LP2018 talk, I've had no free time,
> so I haven't even looked at it yet.  After the conference I'll have the
> time to collaborate a bit more.

Sure, understood!

> Also---I thought the decision was that this patchset was inappropriate
> for `guix environment`; did I misinterpret?

My initial reaction was that we shouldn’t stretch ‘guix environment’ to
do something that’s unrelated to environment management.

However as I looked at your patches, I found that the additions you made
are useful per se (for instance I’ve been wanting ‘--link-profile’ on a
couple of occasions for reasons like the one you gave, Fontconfig,
etc.).  And the patches had tests, documentation, and everything, so it
seemed more beneficial to include them.  :-)

> I admit that I forgot some of the implementation details of my own
> patch; I'd have to look at it in more detail.  I'll consider it tonight
> or this weekend.

OK!

> Thanks for taking a look at and applying these.  If there are better
> solutions, I'm fine with that---I just wanted a proof-of-concept to
> start the discussion.  Though, starting the discussion and then ducking
> out for other obligations wasn't quite what I had in mind...

Sure.  I think the issue of least-authority execution of programs
remains open anway.  Do we want a ‘guix run’-like command?  Something in
the shell, but which shell(s) then?  Automatically-generated wrappers so
we don’t depend on specific shells?

Thanks,
Ludo’.




Merged 30254 30256. Request was from ludo <at> gnu.org (Ludovic Courtès) to control <at> debbugs.gnu.org. (Sat, 03 Mar 2018 21:23:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Sun, 04 Mar 2018 18:04:02 GMT) Full text and rfc822 format available.

Message #19 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 30256 <at> debbugs.gnu.org
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Sun, 04 Mar 2018 13:03:02 -0500
[Message part 1 (text/plain, inline)]
On Sat, Mar 03, 2018 at 15:44:43 +0100, Ludovic Courtès wrote:
>> Also---I thought the decision was that this patchset was inappropriate
>> for `guix environment`; did I misinterpret?
>
> My initial reaction was that we shouldn’t stretch ‘guix environment’ to
> do something that’s unrelated to environment management.
>
> However as I looked at your patches, I found that the additions you made
> are useful per se (for instance I’ve been wanting ‘--link-profile’ on a
> couple of occasions for reasons like the one you gave, Fontconfig,
> etc.).  And the patches had tests, documentation, and everything, so it
> seemed more beneficial to include them.  :-)

Okay, sounds good.

>> Thanks for taking a look at and applying these.  If there are better
>> solutions, I'm fine with that---I just wanted a proof-of-concept to
>> start the discussion.  Though, starting the discussion and then ducking
>> out for other obligations wasn't quite what I had in mind...
>
> Sure.  I think the issue of least-authority execution of programs
> remains open anway.  Do we want a ‘guix run’-like command?  Something in
> the shell, but which shell(s) then?  Automatically-generated wrappers so
> we don’t depend on specific shells?

One thing in particular about using `guix environment --ad-hoc' that is
particularly unfortunate with how I'm abusing it is that it will build
new derivations as necessary (as it is supposed to).  So "starting
icecat" in a container isn't just that.  I recently upgraded Guix, and
icecat isn't available on Hydra yet, so I'm unable to start icecat at
all until it compiles, which is hours on an X200 (though I'm assuming
that reverting ~/.config/guix/latest might allow me to work around it
temporarily with an old version).  This would not have been a problem
with a normal icecat installation in my profile.

Obviously the desirable behavior is to just containerize whatever is in
your profile, if possible.  Maybe the script you sent me does just
that.  I'm excited to play around with it, I just can't atm. :(

-- 
Mike Gerwitz
Free Software Hacker+Activist | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Sun, 04 Mar 2018 22:25:01 GMT) Full text and rfc822 format available.

Message #22 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mike Gerwitz <mtg <at> gnu.org>
Cc: 30256 <at> debbugs.gnu.org
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Sun, 04 Mar 2018 23:24:27 +0100
Heya,

Mike Gerwitz <mtg <at> gnu.org> skribis:

> On Sat, Mar 03, 2018 at 15:44:43 +0100, Ludovic Courtès wrote:

[...]

>> Sure.  I think the issue of least-authority execution of programs
>> remains open anway.  Do we want a ‘guix run’-like command?  Something in
>> the shell, but which shell(s) then?  Automatically-generated wrappers so
>> we don’t depend on specific shells?
>
> One thing in particular about using `guix environment --ad-hoc' that is
> particularly unfortunate with how I'm abusing it is that it will build
> new derivations as necessary (as it is supposed to).  So "starting
> icecat" in a container isn't just that.  I recently upgraded Guix, and
> icecat isn't available on Hydra yet, so I'm unable to start icecat at
> all until it compiles, which is hours on an X200 (though I'm assuming
> that reverting ~/.config/guix/latest might allow me to work around it
> temporarily with an old version).  This would not have been a problem
> with a normal icecat installation in my profile.

Right.  The ‘guix run’ script I sent doesn’t try to build things; it
just takes whatever is in $PATH (which has to be in the store,
ultimately) and runs it.

> Obviously the desirable behavior is to just containerize whatever is in
> your profile, if possible.  Maybe the script you sent me does just
> that.  I'm excited to play around with it, I just can't atm. :(

You still have to explicitly run ‘guix run icecat’, which isn’t great:
if you’re using GNOME Shell and clicking on the icon, you don’t get to
run it in a containerized environment.

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Mon, 05 Mar 2018 18:05:02 GMT) Full text and rfc822 format available.

Message #25 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 30256 <at> debbugs.gnu.org
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Mon, 05 Mar 2018 13:03:39 -0500
[Message part 1 (text/plain, inline)]
On Sun, Mar 04, 2018 at 23:24:27 +0100, Ludovic Courtès wrote:
> Right.  The ‘guix run’ script I sent doesn’t try to build things; it
> just takes whatever is in $PATH (which has to be in the store,
> ultimately) and runs it.

Oh, great!

>> Obviously the desirable behavior is to just containerize whatever is in
>> your profile, if possible.  Maybe the script you sent me does just
>> that.  I'm excited to play around with it, I just can't atm. :(
>
> You still have to explicitly run ‘guix run icecat’, which isn’t great:
> if you’re using GNOME Shell and clicking on the icon, you don’t get to
> run it in a containerized environment.

Well, I do everything from a shell, so that works for me personally. :)
But yes, what you are describing is important.

But, from a security perspective, I'd like for containerization to be
_guaranteed_, otherwise a malicious script could just subvert it
(e.g. open icecat with an argument to a malicious HTML file).  I used
`guix environment` not only because of its container support, but
because that ensured that icecat wasn't in my profile at all to be
invoked by something else.

Currently, I'd have to write a package definition to add a wrapper; that
wouldn't be done automatically for me.  But considering a functional
package manager, it'd be an interesting problem to try to get around
that.  And you don't want containerized versions of _every_
package---that's some serious bloat.  Unless maybe they're packages that
are generated from existing package definitions (in some
yet-to-be-defined manner), and maybe those packages have a special
containerized output (in addition to `out',
e.g. `icecat:container').  (I suppose short-term, such outputs can be
created manually for select packages.)

Just spewing thoughts.  I'm still not well-versed in Guix.  So maybe
`guix run` is a good starting point and can be used by a wrapper in the
future.  It also allows users to containerize something optionally---for
example, maybe a user doesn't want to containerize their PDF reader, but
if they are opening an untrusted PDF, they'll want to.  A GNOME context
menu option to say "Open in isolated container" (sorta like Qubes)
sounds attractive.

-- 
Mike Gerwitz
Free Software Hacker+Activist | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Tue, 06 Mar 2018 10:21:02 GMT) Full text and rfc822 format available.

Message #28 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mike Gerwitz <mtg <at> gnu.org>
Cc: 30256 <at> debbugs.gnu.org
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Tue, 06 Mar 2018 11:20:23 +0100
Hello,

Mike Gerwitz <mtg <at> gnu.org> skribis:

> On Sun, Mar 04, 2018 at 23:24:27 +0100, Ludovic Courtès wrote:

[...]

>> You still have to explicitly run ‘guix run icecat’, which isn’t great:
>> if you’re using GNOME Shell and clicking on the icon, you don’t get to
>> run it in a containerized environment.
>
> Well, I do everything from a shell, so that works for me personally. :)
> But yes, what you are describing is important.
>
> But, from a security perspective, I'd like for containerization to be
> _guaranteed_, otherwise a malicious script could just subvert it
> (e.g. open icecat with an argument to a malicious HTML file).  I used
> `guix environment` not only because of its container support, but
> because that ensured that icecat wasn't in my profile at all to be
> invoked by something else.

Good point.

> Currently, I'd have to write a package definition to add a wrapper; that
> wouldn't be done automatically for me.  But considering a functional
> package manager, it'd be an interesting problem to try to get around
> that.  And you don't want containerized versions of _every_
> package---that's some serious bloat.  Unless maybe they're packages that
> are generated from existing package definitions (in some
> yet-to-be-defined manner), and maybe those packages have a special
> containerized output (in addition to `out',
> e.g. `icecat:container').  (I suppose short-term, such outputs can be
> created manually for select packages.)

I was thinking ‘guix package’ could create those wrappers automatically
based on a number of criteria: a package property could request
containerization, command-line options could disable that, and so on.

> Just spewing thoughts.  I'm still not well-versed in Guix.  So maybe
> `guix run` is a good starting point and can be used by a wrapper in the
> future.  It also allows users to containerize something optionally---for
> example, maybe a user doesn't want to containerize their PDF reader, but
> if they are opening an untrusted PDF, they'll want to.  A GNOME context
> menu option to say "Open in isolated container" (sorta like Qubes)
> sounds attractive.

Yeah, though I very much think least authority would be a better default
than ambient authority.  :-)

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Tue, 06 Mar 2018 18:17:01 GMT) Full text and rfc822 format available.

Message #31 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 30256 <at> debbugs.gnu.org
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Tue, 06 Mar 2018 13:07:52 -0500
[Message part 1 (text/plain, inline)]
On Tue, Mar 06, 2018 at 11:20:23 +0100, Ludovic Courtès wrote:
> Mike Gerwitz <mtg <at> gnu.org> skribis:
>> Currently, I'd have to write a package definition to add a wrapper; that
>> wouldn't be done automatically for me.  But considering a functional
>> package manager, it'd be an interesting problem to try to get around
>> that.  And you don't want containerized versions of _every_
>> package---that's some serious bloat.  Unless maybe they're packages that
>> are generated from existing package definitions (in some
>> yet-to-be-defined manner), and maybe those packages have a special
>> containerized output (in addition to `out',
>> e.g. `icecat:container').  (I suppose short-term, such outputs can be
>> created manually for select packages.)
>
> I was thinking ‘guix package’ could create those wrappers automatically
> based on a number of criteria: a package property could request
> containerization, command-line options could disable that, and so on.

Yes, I'd much prefer that.  That package definition might not be able to
infer certain things, so we'd need to be able to specify e.g. paths to
include in the container.  Preferably overridable as well---for example,
I don't share ~/.cache/mozilla/icecat with the container (I want it to
be ephemeral), but other users may prefer to.

>> Just spewing thoughts.  I'm still not well-versed in Guix.  So maybe
>> `guix run` is a good starting point and can be used by a wrapper in the
>> future.  It also allows users to containerize something optionally---for
>> example, maybe a user doesn't want to containerize their PDF reader, but
>> if they are opening an untrusted PDF, they'll want to.  A GNOME context
>> menu option to say "Open in isolated container" (sorta like Qubes)
>> sounds attractive.
>
> Yeah, though I very much think least authority would be a better default
> than ambient authority.  :-)

I agree for my needs; I suppose we'd need to see what downsides exist
from containerization (if any) that might make the user think
otherwise.  If containerization by default is suitable, then there may
be no need to provide a non-container option, so long as the user can
choose paths to share with the container (and network access).  This is
sounding more like an AppArmor type of permission system.  (Without the
AppArmor, of course.)

-- 
Mike Gerwitz
Free Software Hacker+Activist | GNU Maintainer & Volunteer
GPG: D6E9 B930 028A 6C38 F43B  2388 FEF6 3574 5E6F 6D05
https://mikegerwitz.com
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Wed, 17 Oct 2018 12:20:03 GMT) Full text and rfc822 format available.

Message #34 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mike Gerwitz <mtg <at> gnu.org>
Cc: 30254 <at> debbugs.gnu.org, 30256 <at> debbugs.gnu.org
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Wed, 17 Oct 2018 14:19:33 +0200
Hello Mike,

There’s this last patch from the series you submitted a while back
that’s ready modulo an issue with the test.  Could you take a look?

TIA,
Ludo’.

ludo <at> gnu.org (Ludovic Courtès) skribis:

> Mike Gerwitz <mtg <at> gnu.org> skribis:
>
>> * doc/guix.texi (Invoking guix environment): Add --no-cwd.
>> * guix/scripts/environment.scm (show-help, %options): Add --no-cwd.
>> (launch-environment/container): Add 'map-cwd?' param; only add mapping for cwd
>> if #t.  Only change to cwd within container if #t, otherwise home.
>> (guix-environment): Error if --no-cwd without --container.  Provide '(not
>> no-cwd?)' to launch-environment/container as 'map-cwd?'.
>> * tests/guix-environment.sh: Add test for no-cwd.
>
> This one LGTM as well (with the test moved to
> guix-environment-container.sh).  There’s just a minor issue:
>
>> --- a/tests/guix-environment.sh
>> +++ b/tests/guix-environment.sh
>> @@ -84,6 +84,14 @@ HOME="$tmpdir" guix environment --bootstrap --container --user=foognu \
>>       --share="$tmpdir/umock" \
>>       -- guile -c "$usertest"
>>  
>> +# if not sharing CWD, chdir home
>> +(
>> +  cd "$tmpdir" \
>> +    && guix environment --bootstrap --container --no-cwd --user=foo  \
>> +            --ad-hoc guile-bootstrap --pure \
>> +            -- /bin/sh -c 'test $(pwd) == "/home/foo" -a ! -d '"$tmpdir"
>> +)
>> +
>
> This test would fail for me because my test store is at
> ~ludo/src/guix/test-tmp/store and my CWD is ~/src/guix.  So when using
> both --user and --no-cwd, the effect is that
> ~ludo/src/guix/test-tmp/store is not available at all within the
> container, and thus execve("/bin/sh") fails with ENOENT:
>
> $ ./test-env guix environment --bootstrap --container --no-cwd --user=foo --ad-hoc guile-bootstrap
> accepted connection from pid 29684, user ludo
> accepted connection from pid 29695, user ludo
> ./test-env: line 1: 29683 Terminated              "/home/ludo/src/guix/pre-inst-env" "/home/ludo/src/guix/guix-daemon" --disable-chroot --substitute-urls="$GUIX_BINARY_SUBSTITUTE_URL"
> $ echo $?
> 1
>
> Thoughts?
>
> TIA,
> Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Thu, 08 Nov 2018 01:58:03 GMT) Full text and rfc822 format available.

Message #37 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: ludo <at> gnu.org (Ludovic Courtès)
Cc: 30254 <at> debbugs.gnu.org, 30256 <at> debbugs.gnu.org
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Wed, 07 Nov 2018 20:56:34 -0500
[Message part 1 (text/plain, inline)]
Ludo:

On Wed, Oct 17, 2018 at 15:19:33 +0200, Ludovic Courtès wrote:
> There’s this last patch from the series you submitted a while back
> that’s ready modulo an issue with the test.  Could you take a look?

I'm not ignoring this; I'll have time to look over the next couple of
weeks.  I'll need to research the issue.

-- 
Mike Gerwitz
[signature.asc (application/pgp-signature, inline)]

Added tag(s) moreinfo. Request was from Ricardo Wurmus <rekado <at> elephly.net> to control <at> debbugs.gnu.org. (Mon, 04 Feb 2019 17:16:02 GMT) Full text and rfc822 format available.

Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Sat, 29 Jun 2019 23:28:02 GMT) Full text and rfc822 format available.

Message #42 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: Carl Dong <contact <at> carldong.me>
To: "30256 <at> debbugs.gnu.org" <30256 <at> debbugs.gnu.org>
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Sat, 29 Jun 2019 23:27:43 +0000
Hi Mike and Ludo!

I believe I've found a solution to the problem that Ludo was encountering. The
reason why Ludo was having trouble was because when a user specifies `--user`,
we rewrite the targets of our filesystem mappings so that every instance of
`$HOME` (as seen ouside the container) becomes `/home/$USER`. Since this applied
to all filesystem mappings, it included our filesystem mappings for inputs too.
However, our symlinks were not updated.

My change makes it so that we _only_ update the mappings that are either
user-specified, or cwd (if applicable). This solves Ludo's problems.

Here's the patch, let me know if it looks good:
https://github.com/dongcarl/guix/compare/8e92d5465fc154fed5d06f7e4a64d7dcccded74d...2019-06-env-no-cwd-fix.patch

Cheers,
Carl Dong




Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Sun, 07 Jul 2019 13:19:02 GMT) Full text and rfc822 format available.

Message #45 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Carl Dong <contact <at> carldong.me>
Cc: Ricardo Wurmus <rekado <at> elephly.net>, 30254 <at> debbugs.gnu.org,
 "30256 <at> debbugs.gnu.org" <30256 <at> debbugs.gnu.org>, Mike Gerwitz <mtg <at> gnu.org>
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Sun, 07 Jul 2019 15:18:20 +0200
[Message part 1 (text/plain, inline)]
Hi Carl,

Carl Dong <contact <at> carldong.me> skribis:

> I believe I've found a solution to the problem that Ludo was encountering. The
> reason why Ludo was having trouble was because when a user specifies `--user`,
> we rewrite the targets of our filesystem mappings so that every instance of
> `$HOME` (as seen ouside the container) becomes `/home/$USER`. Since this applied
> to all filesystem mappings, it included our filesystem mappings for inputs too.
> However, our symlinks were not updated.
>
> My change makes it so that we _only_ update the mappings that are either
> user-specified, or cwd (if applicable). This solves Ludo's problems.
>
> Here's the patch, let me know if it looks good:
> https://github.com/dongcarl/guix/compare/8e92d5465fc154fed5d06f7e4a64d7dcccded74d...2019-06-env-no-cwd-fix.patch

Good catch!  The patches LGTM.  (Note: you can use the ‘Co-authored-by’
tag for the second patch, I think it’s a more or less common
convention.)

Speaking of which, could you create an account on Savannah?  That way we
could grant you commit access to make it more convenient for you and so
you can review and apply other people’s patches in your areas of expertise.

Please let me know what your account is, and reply with a message signed
by the key you’ll use to sign commits.  Also please read the ‘HACKING’
file for info on the commit “rules”.

Thanks!

Ludo’.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Sun, 07 Jul 2019 13:54:02 GMT) Full text and rfc822 format available.

Message #48 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: Mike Gerwitz <mtg <at> gnu.org>
To: Carl Dong <contact <at> carldong.me>
Cc: "30256 <at> debbugs.gnu.org" <30256 <at> debbugs.gnu.org>
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Sun, 07 Jul 2019 09:45:22 -0400
[Message part 1 (text/plain, inline)]
On Sat, Jun 29, 2019 at 23:27:43 +0000, Carl Dong wrote:
> Hi Mike and Ludo!
>
> I believe I've found a solution to the problem that Ludo was encountering.

Thank you for picking this up, and sorry again that I wasn't able to
find the time.  I'm glad this patch is useful to someone else, and I'm
looking forward to seeing it applied.

-- 
Mike Gerwitz
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Sun, 07 Jul 2019 14:26:02 GMT) Full text and rfc822 format available.

Message #51 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: Carl Dong <contact <at> carldong.me>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Ricardo Wurmus <rekado <at> elephly.net>, Mike Gerwitz <mtg <at> gnu.org>,
 "30256\\@debbugs.gnu.org" <30256 <at> debbugs.gnu.org>
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Sun, 07 Jul 2019 14:24:44 +0000
Hi Ludo!

> Good catch! The patches LGTM. (Note: you can use the ‘Co-authored-by’ tag for
> the second patch, I think it’s a more or less common convention.)

Done! Updated at the same link as last time:
https://github.com/dongcarl/guix/compare/8e92d5465fc154fed5d06f7e4a64d7dcccded74d...2019-06-env-no-cwd-fix.patch


> Speaking of which, could you create an account on Savannah? That way we could
> grant you commit access to make it more convenient for you and so you can
> review and apply other people’s patches in your areas of expertise.

That's super exciting! :-)

> Please let me know what your account is, and reply with a message signed by
> the key you’ll use to sign commits.

Here you go!

My fingerprint:

0401 7A2A 6D9A 0CCD C81D  8EC2 96AB 007F 1A7E D999

My signed account info:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

My Savannah account as of (Sun 07 Jul 2019 02:06:45 PM UTC) is carl.
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEECc3SW1JEo3Z49u6oDMUhUxl5kaUFAl0h/I8ACgkQDMUhUxl5
kaW7tw//fxTNv+9afaC0QHoos7CQ6zhjVxyRoyGC1b9tYssXA/I/O+vEzthy2T/H
FTbJaa5YjTr09AMwKFzxp1yrGh6+yzp5YQF5uGG26N8NGTOHxet43AtMg1c7Cm7H
vG2KxQLvpUkmroc7NX+P/BZ5RruN+PJSOpssTB5PrDb3DDUzbMNTTmhWZWdEw6Er
0JIz/zH5iZhcWZZ68EILeI3OXGpgWI8D2MTrBkmgtwwL3/Z9fVDV0ui11KtSV4jK
ZTj7SJnHra9HJ6UxO47hs98oTdI1ho7cXFOBQ7GqsBwSzWBCMXaU8VsTtfGdoeMz
2EQQ0NMVOzPIeH4DHnvFLJVuTUS+0wXzmsTVvmq+NASZjZRS7H6xGjunLet/G0wQ
WqRA85tpSc6Lvr1Ab/oMRxZZnxeBQ8mJU7Y/ROe6GubdiAT5bdJBTLjeCjbARadp
UTbp+WclI0VVD/tPAcOlxJnj0iVEMBRe/hFa2o9Uvv4mZl+3NAlGKRycWXByq+l2
3Fjfqn7aF5a7R9y/itBAGh9fGUShK08Cb8/TfbTH/voX1VIzzXhAjnhBoL2p0Mi8
4l+PUZ7T7Ob5HGaz1VxztWFucXKPXZCOu9Igv1EIirTKbKzsyWZr1OGmDi8YzqHo
bD4yP39Buyoj/v/S0OE/ocGidtXx/FGGoR84yWYrx3nLtCWin+E=
=RXBz
-----END PGP SIGNATURE-----

> Also please read the ‘HACKING’ file for info on the commit “rules”.

Done!

Cheers,
Carl Dong
contact <at> carldong.me
"I fight for the users"




Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Mon, 08 Jul 2019 09:42:02 GMT) Full text and rfc822 format available.

Message #54 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Carl Dong <contact <at> carldong.me>
Cc: Ricardo Wurmus <rekado <at> elephly.net>, Mike Gerwitz <mtg <at> gnu.org>,
 "30256 <at> debbugs.gnu.org" <30256 <at> debbugs.gnu.org>
Subject: Re: [bug#30256] [PATCH 3/3] scripts: environment: Add --no-cwd.
Date: Mon, 08 Jul 2019 11:41:32 +0200
Hello!

Carl Dong <contact <at> carldong.me> skribis:

>> Good catch! The patches LGTM. (Note: you can use the ‘Co-authored-by’ tag for
>> the second patch, I think it’s a more or less common convention.)
>
> Done! Updated at the same link as last time:
> https://github.com/dongcarl/guix/compare/8e92d5465fc154fed5d06f7e4a64d7dcccded74d...2019-06-env-no-cwd-fix.patch

Alright!

>> Speaking of which, could you create an account on Savannah? That way we could
>> grant you commit access to make it more convenient for you and so you can
>> review and apply other people’s patches in your areas of expertise.
>
> That's super exciting! :-)
>
>> Please let me know what your account is, and reply with a message signed by
>> the key you’ll use to sign commits.
>
> Here you go!
>
> My fingerprint:
>
> 0401 7A2A 6D9A 0CCD C81D  8EC2 96AB 007F 1A7E D999
>
> My signed account info:
>
> My Savannah account as of (Sun 07 Jul 2019 02:06:45 PM UTC) is carl.

Cool, I’ve added you to the Savannah group.  You can now push these two
patches to test it.

Thank you and welcome on board!  :-)

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#30256; Package guix-patches. (Wed, 14 Jul 2021 13:19:01 GMT) Full text and rfc822 format available.

Message #57 received at 30256 <at> debbugs.gnu.org (full text, mbox):

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Ricardo Wurmus <rekado <at> elephly.net>, Mike Gerwitz <mtg <at> gnu.org>,
 30254-done <at> debbugs.gnu.org,
 "30256-done <at> debbugs.gnu.org" <30256 <at> debbugs.gnu.org>,
 Carl Dong <contact <at> carldong.me>
Subject: Re: bug#30254: [PATCH 0/3] guix environment --user, --link-profile,
 --no-cwd
Date: Wed, 14 Jul 2021 09:18:43 -0400
Hello,

Ludovic Courtès <ludo <at> gnu.org> writes:

> Hello!
>
> Carl Dong <contact <at> carldong.me> skribis:
>
>>> Good catch! The patches LGTM. (Note: you can use the ‘Co-authored-by’ tag for
>>> the second patch, I think it’s a more or less common convention.)
>>
>> Done! Updated at the same link as last time:
>> https://github.com/dongcarl/guix/compare/8e92d5465fc154fed5d06f7e4a64d7dcccded74d...2019-06-env-no-cwd-fix.patch
>
> Alright!
>
>>> Speaking of which, could you create an account on Savannah? That way we could
>>> grant you commit access to make it more convenient for you and so you can
>>> review and apply other people’s patches in your areas of expertise.

[...]

> Cool, I’ve added you to the Savannah group.  You can now push these two
> patches to test it.

Seems the patches have indeed been pushed :-).

Closing.

Maxim




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 12 Aug 2021 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 257 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.