Merge pull request #30837 from poettering/varlink-over-ssh
varlink: add "ssh:" transport for talking to remote servers
This commit is contained in:
+26
-5
@@ -1012,8 +1012,8 @@ int putenv_dup(const char *assignment, bool override) {
|
||||
}
|
||||
|
||||
int setenv_systemd_exec_pid(bool update_only) {
|
||||
char str[DECIMAL_STR_MAX(pid_t)];
|
||||
const char *e;
|
||||
int r;
|
||||
|
||||
/* Update $SYSTEMD_EXEC_PID=pid except when '*' is set for the variable. */
|
||||
|
||||
@@ -1024,10 +1024,9 @@ int setenv_systemd_exec_pid(bool update_only) {
|
||||
if (streq_ptr(e, "*"))
|
||||
return 0;
|
||||
|
||||
xsprintf(str, PID_FMT, getpid_cached());
|
||||
|
||||
if (setenv("SYSTEMD_EXEC_PID", str, 1) < 0)
|
||||
return -errno;
|
||||
r = setenvf("SYSTEMD_EXEC_PID", /* overwrite= */ 1, PID_FMT, getpid_cached());
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1122,3 +1121,25 @@ int set_full_environment(char **env) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int setenvf(const char *name, bool overwrite, const char *valuef, ...) {
|
||||
_cleanup_free_ char *value = NULL;
|
||||
va_list ap;
|
||||
int r;
|
||||
|
||||
assert(name);
|
||||
|
||||
if (!valuef)
|
||||
return RET_NERRNO(unsetenv(name));
|
||||
|
||||
va_start(ap, valuef);
|
||||
DISABLE_WARNING_FORMAT_NONLITERAL;
|
||||
r = vasprintf(&value, valuef, ap);
|
||||
REENABLE_WARNING;
|
||||
va_end(ap);
|
||||
|
||||
if (r < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
return RET_NERRNO(setenv(name, value, overwrite));
|
||||
}
|
||||
|
||||
@@ -80,3 +80,5 @@ int getenv_path_list(const char *name, char ***ret_paths);
|
||||
int getenv_steal_erase(const char *name, char **ret);
|
||||
|
||||
int set_full_environment(char **env);
|
||||
|
||||
int setenvf(const char *name, bool overwrite, const char *valuef, ...) _printf_(3,4);
|
||||
|
||||
@@ -170,6 +170,19 @@ int fd_nonblock(int fd, bool nonblock) {
|
||||
return RET_NERRNO(fcntl(fd, F_SETFL, nflags));
|
||||
}
|
||||
|
||||
int stdio_disable_nonblock(void) {
|
||||
int ret = 0;
|
||||
|
||||
/* stdin/stdout/stderr really should have O_NONBLOCK, which would confuse apps if left on, as
|
||||
* write()s might unexpectedly fail with EAGAIN. */
|
||||
|
||||
RET_GATHER(ret, fd_nonblock(STDIN_FILENO, false));
|
||||
RET_GATHER(ret, fd_nonblock(STDOUT_FILENO, false));
|
||||
RET_GATHER(ret, fd_nonblock(STDERR_FILENO, false));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fd_cloexec(int fd, bool cloexec) {
|
||||
int flags, nflags;
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(DIR*, closedir, NULL);
|
||||
#define _cleanup_close_pair_ _cleanup_(close_pairp)
|
||||
|
||||
int fd_nonblock(int fd, bool nonblock);
|
||||
int stdio_disable_nonblock(void);
|
||||
|
||||
int fd_cloexec(int fd, bool cloexec);
|
||||
int fd_cloexec_many(const int fds[], size_t n_fds, bool cloexec);
|
||||
|
||||
|
||||
@@ -1667,6 +1667,9 @@ int safe_fork_full(
|
||||
log_full_errno(prio, r, "Failed to rearrange stdio fds: %m");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
/* Turn off O_NONBLOCK on the fdio fds, in case it was left on */
|
||||
stdio_disable_nonblock();
|
||||
} else {
|
||||
r = make_null_stdio();
|
||||
if (r < 0) {
|
||||
|
||||
Reference in New Issue
Block a user