diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/dbus-common.c | 4 | ||||
-rw-r--r-- | src/shared/util.c | 14 | ||||
-rw-r--r-- | src/shared/util.h | 1 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/shared/dbus-common.c b/src/shared/dbus-common.c index b8c15cb9fc..f579567321 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@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 2edf9cd875..d0bbf78bf3 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 64e63b8c07..e6f9312e95 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); |