Re: [systemd-devel] [PATCH 1/2] manager: connect to private bus even if $DBUS_SESSION_BUS_ADDRESS is not set

2013-10-13 Thread Colin Walters
On Wed, 2013-10-09 at 17:33 +0300, Mantas Mikulėnas wrote:
 On Wed, Oct 9, 2013 at 3:59 PM, Colin Walters walt...@verbum.org wrote:
  Your patch seems to be at odds with the commit message; since
  DBUS_SESSION_BUS_ADDRESS won't be set for the user bus, we won't
  attempt a connection, right?
 
 In the current code? Yes, but then it won't attempt to set up the
 *private* socket either ($XDG_RUNTIME_DIR/systemd/private), because
 bus_init() is skipped completely.

Ok, I see.  Makes sense.  Pushed, thanks!


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] [PATCH 1/2] manager: connect to private bus even if $DBUS_SESSION_BUS_ADDRESS is not set

2013-10-09 Thread Mantas Mikulėnas
Because that's exactly the kind of situation where the private bus is
necessary.
---
 src/core/manager.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/core/manager.c b/src/core/manager.c
index 58dacdc..e183325 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -485,6 +485,7 @@ static int manager_default_environment(Manager *m) {
 int manager_new(SystemdRunningAs running_as, bool reexecuting, Manager **_m) {
 Manager *m;
 int r = -ENOMEM;
+bool try_bus_connect = false;
 
 assert(_m);
 assert(running_as = 0);
@@ -556,15 +557,18 @@ int manager_new(SystemdRunningAs running_as, bool 
reexecuting, Manager **_m) {
 if (r  0)
 goto fail;
 
-/* Try to connect to the busses, if possible. */
-if ((running_as == SYSTEMD_USER  getenv(DBUS_SESSION_BUS_ADDRESS)) 
||
-running_as == SYSTEMD_SYSTEM) {
-r = bus_init(m, reexecuting || running_as != SYSTEMD_SYSTEM);
-if (r  0)
-goto fail;
-} else
+if (running_as == SYSTEMD_SYSTEM)
+try_bus_connect = reexecuting;
+else if (getenv(DBUS_SESSION_BUS_ADDRESS))
+try_bus_connect = true;
+else
 log_debug(Skipping DBus session bus connection attempt - no 
DBUS_SESSION_BUS_ADDRESS set...);
 
+/* Try to connect to the busses, if possible. */
+r = bus_init(m, try_bus_connect);
+if (r  0)
+goto fail;
+
 m-taint_usr = dir_is_empty(/usr)  0;
 
 *_m = m;
-- 
1.8.4

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/2] manager: connect to private bus even if $DBUS_SESSION_BUS_ADDRESS is not set

2013-10-09 Thread Colin Walters
Your patch seems to be at odds with the commit message; since
DBUS_SESSION_BUS_ADDRESS won't be set for the user bus, we won't
attempt a connection, right?

What you're really trying to fix I assume is the warning systemd outputs
when it currently spawns user@?

Note I also patched this code in
https://people.gnome.org/~walters/user-session-patches/systemd/0001-Many-fixes-for-per-user-systemd-to-be-split-up.patch

But this code doesn't really make sense at all without
https://bugs.freedesktop.org/show_bug.cgi?id=61301


On Wed, 2013-10-09 at 14:57 +0300, Mantas Mikulėnas wrote:
 Because that's exactly the kind of situation where the private bus is
 necessary.
 ---
  src/core/manager.c | 18 +++---
  1 file changed, 11 insertions(+), 7 deletions(-)
 
 diff --git a/src/core/manager.c b/src/core/manager.c
 index 58dacdc..e183325 100644
 --- a/src/core/manager.c
 +++ b/src/core/manager.c
 @@ -485,6 +485,7 @@ static int manager_default_environment(Manager *m) {
  int manager_new(SystemdRunningAs running_as, bool reexecuting, Manager **_m) 
 {
  Manager *m;
  int r = -ENOMEM;
 +bool try_bus_connect = false;
  
  assert(_m);
  assert(running_as = 0);
 @@ -556,15 +557,18 @@ int manager_new(SystemdRunningAs running_as, bool 
 reexecuting, Manager **_m) {
  if (r  0)
  goto fail;
  
 -/* Try to connect to the busses, if possible. */
 -if ((running_as == SYSTEMD_USER  
 getenv(DBUS_SESSION_BUS_ADDRESS)) ||
 -running_as == SYSTEMD_SYSTEM) {
 -r = bus_init(m, reexecuting || running_as != SYSTEMD_SYSTEM);
 -if (r  0)
 -goto fail;
 -} else
 +if (running_as == SYSTEMD_SYSTEM)
 +try_bus_connect = reexecuting;
 +else if (getenv(DBUS_SESSION_BUS_ADDRESS))
 +try_bus_connect = true;
 +else
  log_debug(Skipping DBus session bus connection attempt - no 
 DBUS_SESSION_BUS_ADDRESS set...);
  
 +/* Try to connect to the busses, if possible. */
 +r = bus_init(m, try_bus_connect);
 +if (r  0)
 +goto fail;
 +
  m-taint_usr = dir_is_empty(/usr)  0;
  
  *_m = m;


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] [PATCH 1/2] manager: connect to private bus even if $DBUS_SESSION_BUS_ADDRESS is not set

2013-10-09 Thread Mantas Mikulėnas
On Wed, Oct 9, 2013 at 3:59 PM, Colin Walters walt...@verbum.org wrote:
 Your patch seems to be at odds with the commit message; since
 DBUS_SESSION_BUS_ADDRESS won't be set for the user bus, we won't
 attempt a connection, right?

In the current code? Yes, but then it won't attempt to set up the
*private* socket either ($XDG_RUNTIME_DIR/systemd/private), because
bus_init() is skipped completely.

However, when bus_init(m, false) is called, then it won't try the
system or api bus, but will set up the private socket anyway.

 What you're really trying to fix I assume is the warning systemd outputs
 when it currently spawns user@?

No – what I'm trying to fix is systemd's behavior in the (admittedly
very unlikely) case when it's started without DBUS_SESSION_BUS_ADDRESS
in environment (for example, which I had to do last week when helping
someone on IRC fix their user@.service).

Specifically, systemd --user should always be controllable through the
$XDG_RUNTIME_DIR/systemd/private socket – even if said DBus
environment variable is missing or if it cannot connect to DBus for
some other reason. (On the second thought, I should've probably also
adjusted bus_init() to move the call to bus_init_private() a little
higher.)

-- 
Mantas Mikulėnas graw...@gmail.com
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel