Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken with ostree-as-host /var/home #493

Closed
cgwalters opened this issue Jan 18, 2017 · 4 comments
Closed

Broken with ostree-as-host /var/home #493

cgwalters opened this issue Jan 18, 2017 · 4 comments

Comments

@cgwalters
Copy link
Collaborator

cgwalters commented Jan 18, 2017

$ atomic host status
● atomic-ws:atomicws/fedora/x86_64/continuous
       Version: 25.2016.134 (2017-01-10 17:17:46)
    BaseCommit: 9fe637a8723b5637ba2841de4a2a7233840802205e247d0015953c2b53217dd5
        Commit: dbe59630eef865202daf471e1fb3403d15d78c6f8bc25d76ce1a6e09b659600d
        OSName: fedora
      Packages: ansible emacs fuse-sshfs gdb gimp git keepassx krb5-workstation libgit2 libvirt opensc pcsc-lite-ccid powerline strace vagrant-hostmanager vagrant-libvirt vagrant-sshfs virt-manager xchat xsel ykclient ykpers
      Unlocked: development
$ strace -f -e symlink,symlinkat flatpak run org.gnome.Evince
strace: Process 14551 attached
strace: Process 14552 attached
strace: Process 14553 attached
strace: Process 14554 attached
[pid 14553] +++ exited with 0 +++
[pid 14550] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=14553, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
strace: Process 14555 attached
[pid 14555] symlink("usr/bin", "/newroot/bin") = 0
[pid 14555] symlink("var/home", "/newroot/home") = 0
[pid 14555] symlink("usr/lib", "/newroot/lib") = 0
[pid 14555] symlink("usr/lib64", "/newroot/lib64") = 0
[pid 14555] symlink("run/media", "/newroot/media") = 0
[pid 14555] symlink("var/mnt", "/newroot/mnt") = 0
[pid 14555] symlink("var/opt", "/newroot/opt") = 0
[pid 14555] symlink("sysroot/ostree", "/newroot/ostree") = 0
[pid 14555] symlink("var/roothome", "/newroot/root") = 0
[pid 14555] symlink("usr/sbin", "/newroot/sbin") = 0
[pid 14555] symlink("var/srv", "/newroot/srv") = 0
[pid 14555] symlink("sysroot/tmp", "/newroot/tmp") = 0
strace: Process 14556 attached
[pid 14552] +++ exited with 0 +++
[pid 14551] +++ exited with 0 +++
strace: Process 14557 attached
[pid 14557] symlink("../run", "/newroot/var/run") = 0
[pid 14557] symlink("/proc/mounts", "/newroot/etc/mtab") = 0
[pid 14557] symlink("usr/lib", "/newroot/lib") = 0
[pid 14557] symlink("usr/lib64", "/newroot/lib64") = 0
[pid 14557] symlink("usr/bin", "/newroot/bin") = 0
[pid 14557] symlink("usr/sbin", "/newroot/sbin") = 0
[pid 14557] symlink("/run/host/monitor/localtime", "/newroot/etc/localtime") = 0
[pid 14557] symlink("/run/host/monitor/resolv.conf", "/newroot/etc/resolv.conf") = 0
[pid 14557] symlink("../../../.flatpak-info", "/newroot/run/user/1000/flatpak-info") = 0
[pid 14557] symlink("/proc/self/fd/0", "/newroot/dev/stdin") = 0
[pid 14557] symlink("/proc/self/fd/1", "/newroot/dev/stdout") = 0
[pid 14557] symlink("/proc/self/fd/2", "/newroot/dev/stderr") = 0
[pid 14557] symlink("pts/ptmx", "/newroot/dev/ptmx") = 0
[pid 14557] symlink("var/home", "/newroot/home") = -1 EEXIST (File exists)
Can't make symlink at /home: File exists
[pid 14557] +++ exited with 1 +++
[pid 14556] +++ exited with 0 +++
[pid 14550] +++ exited with 1 +++
[pid 14555] +++ exited with 0 +++
+++ exited with 0 +++

@alexlarsson
Copy link
Member

I guess HOME is /home/walters, and /home is a symlink to /var/home ?

@cgwalters
Copy link
Collaborator Author

Yep.

alexlarsson added a commit that referenced this issue Jan 19, 2017
If the homedir is on a symlink (say /home -> /var/home) but the homedir
is in /home, then we shouldn't create a directory in /home because
then the symlink creation will fail. Instead we move the homedir
creation to the end, where we will create it in the symlink if needed.

This should fix #493

(cherry picked from commit fa6f7228886e983a5c1ff64e1d9db8ea0014ec26)
@cgwalters
Copy link
Collaborator Author

Now I get:

flatpak run org.gnome.Evince
Can't bind mount /oldroot/var/home/walters/.config/dconf on /newroot/home/walters/.config/dconf: Invalid argument

I can take a look at this at some point if you're just doing blind patches.

@cgwalters
Copy link
Collaborator Author

Hm, confused, I built git master, it still didn't work, added patches to debug, now it works. Removing my patches it still works.

Here's what I started FWIW

diff --git a/common/flatpak-run.c b/common/flatpak-run.c
index fb29c73..7199158 100644
--- a/common/flatpak-run.c
+++ b/common/flatpak-run.c
@@ -3335,22 +3335,23 @@ add_document_portal_args (GPtrArray  *argv_array,
 gchar *
 join_args (GPtrArray *argv_array, gsize *len_out)
 {
-  gchar *string;
-  gchar *ptr;
+  g_autoptr(GString) nulsepbuf = g_string_new (NULL);
+  g_autoptr(GString) spacesepbuf = g_string_new (NULL);
   gint i;
-  gsize len = 0;
 
   for (i = 0; i < argv_array->len; i++)
-    len +=  strlen (argv_array->pdata[i]) + 1;
+    {
+      const char *arg = argv_array->pdata[i];
+      g_string_append (nulsepbuf, arg);
+      g_string_append_c (nulsepbuf, '\0');
+      g_string_append (spacesepbuf, arg);
+      g_string_append_c (spacesepbuf, ' ');
+    }
 
-  string = g_new (gchar, len);
-  *string = 0;
-  ptr = string;
-  for (i = 0; i < argv_array->len; i++)
-    ptr = g_stpcpy (ptr, argv_array->pdata[i]) + 1;
+  g_debug ("bwrap arg fd: %s", spacesepbuf->str);
 
-  *len_out = len;
-  return string;
+  *len_out = nulsepbuf->len;
+  return g_string_free (g_steal_pointer (&nulsepbuf), FALSE);
 }
 
 typedef struct {
@@ -4222,6 +4223,16 @@ flatpak_run_app (const char     *app_ref,
 
   g_ptr_array_add (real_argv_array, NULL);
 
+  {
+    g_autoptr(GString) buf = g_string_new ("");
+    for (guint i = 0; i < argv_array->len; i++)
+      {
+        g_string_append (buf, argv_array->pdata[i]);
+        g_string_append_c (buf, ' ');
+      }
+    g_debug ("Running: %s", buf->str);
+  }
+
   if ((flags & FLATPAK_RUN_FLAG_BACKGROUND) != 0)
     {
       if (!g_spawn_async (NULL,

matthiasclasen pushed a commit to matthiasclasen/flatpak that referenced this issue Feb 21, 2017
If the homedir is on a symlink (say /home -> /var/home) but the homedir
is in /home, then we shouldn't create a directory in /home because
then the symlink creation will fail. Instead we move the homedir
creation to the end, where we will create it in the symlink if needed.

This should fix flatpak#493
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants