GNOME Bugzilla – Bug 793445
Refusing to render service to dead parents.
Last modified: 2018-02-16 15:41:46 UTC
Admin backend doesn't work on some systems due to "Refusing to render service to dead parents." pkexec error. Pkexec can't figure out the parent process: https://cgit.freedesktop.org/polkit/tree/src/programs/pkexec.c#n727 I'm just wondering why that approach works e.g. on Fedora and not e.g. in RHEL/CentOS. See: https://mail.gnome.org/archives/gvfs-list/2018-February/msg00000.html
Created attachment 368340 [details] [review] admin: Use really persistent d-bus name Commit 8e9439ef introduced DBusName=org.gtk.vfs.mountpoint_admin in admin.mount.in, but forgot to set the necessary mount options. So, each client spawns new daemon currently, which is not necessary. Let's set the missing -DMOUNTABLE_DBUS_NAME options.
Created attachment 368341 [details] [review] admin: Add pkexec wrapper script pkexec fails on some systems (e.g. RHEL) with "Refusing to render service to dead parents." error currently. Let's introduce gvfsd-admin-pkexec wrapper script which workarounds this issue.
However, I would be happier if the wrapper doesn't have to be added. Any ideas?
Any idea what is a difference between "sh -c" and "#!/bin/sh" script in regards to ppid?
It seems that G_SPAWN_DO_NOT_REAP_CHILD when spawning may fix the issue without adding the wrapper. I will test later...
Created attachment 368367 [details] [review] daemon: Fix admin backend spawning pkexec fails on some systems with "Refusing to render service to dead parents.", which is caused by double forking when spawning the process. Let's prevent this by G_SPAWN_DO_NOT_REAP_CHILD flag and clean up manually using g_child_watch_add.
The second approach seems to fix this issue also and do not require additional files, though not sure that it doesn't have any unwanted side-effects... Philip, don't you know?
Comment on attachment 368340 [details] [review] admin: Use really persistent d-bus name Attachment 368340 [details] pushed as 2502641 - admin: Use really persistent d-bus name
(In reply to Ondrej Holy from comment #3) > However, I would be happier if the wrapper doesn't have to be added. Any > ideas? I would like, very much, not to have the wrapper if there's any ways around it.
(In reply to Ondrej Holy from comment #4) > Any idea what is a difference between "sh -c" and "#!/bin/sh" script in > regards to ppid? According to https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html#index-PPID : PPID The process ID of the shell’s parent process. This variable is readonly. So I don't think there would be any difference in regards to ppid, except for maybe sh, on some systems, might run the real sh, whereas on my system, #!/bin/sh is a symbolic-link to a /bin/bash. which sh shows sh is /usr/bin/sh, which happens to also be a symbolic link to /bin/bash. Are you seeing a difference in behaviour when you use sh -c versus #!/bin/sh with regards to the PPID variable?
Review of attachment 368367 [details] [review]: (In reply to Ondrej Holy from comment #7) > The second approach seems to fix this issue also and do not require > additional files, though not sure that it doesn't have any unwanted > side-effects... Philip, don't you know? I don’t really know what the situation is here. If this works, go for it. I can’t think of any side effects which it could cause (honestly, I thought that the code you’ve added with g_child_watch_add() is equivalent to not passing the G_SPAWN_DO_NOT_REAP_CHILD_FLAG). Looking at gspawn.c, it seems that if you don’t pass G_SPAWN_DO_NOT_REAP_CHILD, an intermediate child process is spawned, and the process you actually want to spawn becomes your grandchild. That might have been interfering with the ppid. ::: daemon/mount.c @@ +475,1 @@ /* TODO: Add a timeout here to detect spawned app crashing */ Implementing this TODO will be possible now that you’re using g_child_watch_add() (since the watch callback will be called if the child crashes).
Philip, thanks, I have understood it, in the same way, though still wonder why it currently works on Fedora and not in RHEL and possibly in others :-)
Created attachment 368428 [details] [review] daemon: Fix admin backend spawning pkexec fails on some systems with "Refusing to render service to dead parents.", which is caused by double forking when spawning the process. Let's prevent this by G_SPAWN_DO_NOT_REAP_CHILD flag and clean up manually using g_child_watch_add.
Attachment 368428 [details] pushed as cb1c755 - daemon: Fix admin backend spawning