[systemd-commits] 2 commits - src/core src/hostname src/locale src/login src/shared src/systemctl src/timedate

Zbigniew Jędrzejewski-Szmek zbyszek at kemper.freedesktop.org
Sun Jun 9 15:27:30 PDT 2013


 src/core/service.c         |    2 +-
 src/hostname/hostnamectl.c |    5 +++--
 src/locale/localectl.c     |    5 +++--
 src/login/loginctl.c       |    5 +++--
 src/shared/dbus-common.c   |    4 ++--
 src/shared/util.c          |   14 ++++++++++++++
 src/shared/util.h          |    1 +
 src/systemctl/systemctl.c  |    7 ++++---
 src/timedate/timedatectl.c |    5 +++--
 9 files changed, 34 insertions(+), 14 deletions(-)

New commits:
commit 62220cf70e381f6e08390523e4696f7bc431f927
Author: Ross Lagerwall <rosslagerwall at gmail.com>
Date:   Sun Jun 9 17:28:44 2013 +0100

    service: don't report alien child as alive when it's not
    
    When a sigchld is received from an alien child, main_pid is set to
    0 then service_enter_running calls main_pid_good to check if the
    child is running.  This incorrectly returned true because
    kill(main_pid, 0) would return >= 0.
    
    This fixes an error where a service would die and the cgroup would
    become empty but the service would still report as active (running).

diff --git a/src/core/service.c b/src/core/service.c
index 20990d2..dadd981 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -1865,7 +1865,7 @@ static int main_pid_good(Service *s) {
 
                 /* If it's an alien child let's check if it is still
                  * alive ... */
-                if (s->main_pid_alien)
+                if (s->main_pid_alien && s->main_pid > 0)
                         return kill(s->main_pid, 0) >= 0 || errno != ESRCH;
 
                 /* .. otherwise assume we'll get a SIGCHLD for it,

commit 7085053a437456ab87d726f3697002dd811fdf7a
Author: Daniel Wallace <danielwallace at gtmanfred.com>
Date:   Sun Jun 9 15:54:39 2013 -0500

    Allow for the use of @ in remote host calls
    
    Without this you have to use %40 with the -H flag because dbus doesn't
    like the @ sign being unescaped.

diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index d108a24..f7d844b 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -44,7 +44,8 @@ static enum transport {
         TRANSPORT_POLKIT
 } arg_transport = TRANSPORT_NORMAL;
 static bool arg_ask_password = true;
-static const char *arg_host = NULL;
+static char *arg_host = NULL;
+static char *arg_user = NULL;
 static bool arg_set_transient = false;
 static bool arg_set_pretty = false;
 static bool arg_set_static = false;
@@ -421,7 +422,7 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case 'H':
                         arg_transport = TRANSPORT_SSH;
-                        arg_host = optarg;
+                        parse_user_at_host(optarg, &arg_user, &arg_host);
                         break;
 
                 case ARG_SET_TRANSIENT:
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index b5cd344..cd7356a 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -46,7 +46,8 @@ static enum transport {
         TRANSPORT_POLKIT
 } arg_transport = TRANSPORT_NORMAL;
 static bool arg_ask_password = true;
-static const char *arg_host = NULL;
+static char *arg_host = NULL;
+static char *arg_user = NULL;
 static bool arg_convert = true;
 
 static void pager_open_if_enabled(void) {
@@ -777,7 +778,7 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case 'H':
                         arg_transport = TRANSPORT_SSH;
-                        arg_host = optarg;
+                        parse_user_at_host(optarg, &arg_user, &arg_host);
                         break;
 
                 case ARG_NO_CONVERT:
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index caaea8d..b09aa37 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -50,7 +50,8 @@ static enum transport {
         TRANSPORT_POLKIT
 } arg_transport = TRANSPORT_NORMAL;
 static bool arg_ask_password = true;
-static const char *arg_host = NULL;
+static char *arg_host = NULL;
+static char *arg_user = NULL;
 
 static void pager_open_if_enabled(void) {
 
@@ -1421,7 +1422,7 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case 'H':
                         arg_transport = TRANSPORT_SSH;
-                        arg_host = optarg;
+                        parse_user_at_host(optarg, &arg_user, &arg_host);
                         break;
 
                 case ARG_FULL:
diff --git a/src/shared/dbus-common.c b/src/shared/dbus-common.c
index b8c15cb..f579567 100644
--- a/src/shared/dbus-common.c
+++ b/src/shared/dbus-common.c
@@ -178,9 +178,9 @@ int bus_connect_system_ssh(const char *user, const char *host, DBusConnection **
         assert(user || host);
 
         if (user && host)
-                asprintf(&p, "unixexec:path=ssh,argv1=-xT,argv2=%s@%s,argv3=systemd-stdio-bridge", user, host);
+                asprintf(&p, "unixexec:path=ssh,argv1=-xT,argv2=%s%%40%s,argv3=systemd-stdio-bridge", user, host);
         else if (user)
-                asprintf(&p, "unixexec:path=ssh,argv1=-xT,argv2=%s at localhost,argv3=systemd-stdio-bridge", user);
+                asprintf(&p, "unixexec:path=ssh,argv1=-xT,argv2=%s%%40localhost,argv3=systemd-stdio-bridge", user);
         else if (host)
                 asprintf(&p, "unixexec:path=ssh,argv1=-xT,argv2=%s,argv3=systemd-stdio-bridge", host);
 
diff --git a/src/shared/util.c b/src/shared/util.c
index 2edf9cd..d0bbf78 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -5847,3 +5847,17 @@ bool id128_is_valid(const char *s) {
 
         return true;
 }
+
+void parse_user_at_host(char *arg, char **user, char **host) {
+        assert(arg);
+        assert(user);
+        assert(host);
+
+        *host = strchr(arg, '@');
+        if (*host == NULL)
+                *host = arg;
+        else {
+                *host[0]++ = '\0';
+                *user = arg;
+        }
+}
diff --git a/src/shared/util.h b/src/shared/util.h
index 64e63b8..e6f9312 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -732,3 +732,4 @@ static inline void _reset_locale_(struct _locale_struct_ *s) {
              _saved_locale_.quit = true)
 
 bool id128_is_valid(const char *s) _pure_;
+void parse_user_at_host(char *arg, char **user, char **host);
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 0ba3568..3e4cefe 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -129,7 +129,8 @@ static enum transport {
         TRANSPORT_SSH,
         TRANSPORT_POLKIT
 } arg_transport = TRANSPORT_NORMAL;
-static const char *arg_host = NULL;
+static char *arg_host = NULL;
+static char *arg_user = NULL;
 static unsigned arg_lines = 10;
 static OutputMode arg_output = OUTPUT_SHORT;
 static bool arg_plain = false;
@@ -5065,7 +5066,7 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
 
                 case 'H':
                         arg_transport = TRANSPORT_SSH;
-                        arg_host = optarg;
+                        parse_user_at_host(optarg, &arg_user, &arg_host);
                         break;
 
                 case ARG_RUNTIME:
@@ -6086,7 +6087,7 @@ int main(int argc, char*argv[]) {
                         bus_connect_system_polkit(&bus, &error);
                         private_bus = false;
                 } else if (arg_transport == TRANSPORT_SSH) {
-                        bus_connect_system_ssh(NULL, arg_host, &bus, &error);
+                        bus_connect_system_ssh(arg_user, arg_host, &bus, &error);
                         private_bus = false;
                 } else
                         assert_not_reached("Uh, invalid transport...");
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index e8bc452..d2b483e 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -44,7 +44,8 @@ static enum transport {
         TRANSPORT_POLKIT
 } arg_transport = TRANSPORT_NORMAL;
 static bool arg_ask_password = true;
-static const char *arg_host = NULL;
+static char *arg_host = NULL;
+static char *arg_user = NULL;
 
 static void pager_open_if_enabled(void) {
 
@@ -560,7 +561,7 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case 'H':
                         arg_transport = TRANSPORT_SSH;
-                        arg_host = optarg;
+                        parse_user_at_host(optarg, &arg_user, &arg_host);
                         break;
 
                 case ARG_NO_ASK_PASSWORD:



More information about the systemd-commits mailing list