core: open more fields up to StartTransientUnit via Varlink (#43516)

This is split out of #43058 but makes a ton of sense on its own.
This commit is contained in:
Yu Watanabe
2026-09-23 08:50:36 +09:00
committed by GitHub
10 changed files with 414 additions and 72 deletions
+10
View File
@@ -519,6 +519,16 @@ ExecCommandFlags exec_command_flags_from_string(const char *s) {
return 1U << idx;
}
char* exec_command_flags_to_exec_chars(ExecCommandFlags flags) {
/* Returns the prefix characters that encode the flags in unit file ExecStart= lines, i.e. the
* inverse of the prefix parsing in load-fragment.c */
return strjoin(FLAGS_SET(flags, EXEC_COMMAND_IGNORE_FAILURE) ? "-" : "",
FLAGS_SET(flags, EXEC_COMMAND_NO_ENV_EXPAND) ? ":" : "",
FLAGS_SET(flags, EXEC_COMMAND_FULLY_PRIVILEGED) ? "+" : "",
FLAGS_SET(flags, EXEC_COMMAND_NO_SETUID) ? "!" : "",
FLAGS_SET(flags, EXEC_COMMAND_VIA_SHELL) ? "|" : "");
}
int fexecve_or_execve(int executable_fd, const char *executable, char *const argv[], char *const envp[]) {
/* Refuse invalid fds, regardless if fexecve() use is enabled or not */
if (executable_fd < 0)
+1
View File
@@ -55,6 +55,7 @@ typedef enum ExecCommandFlags {
int exec_command_flags_from_strv(char * const *ex_opts, ExecCommandFlags *ret);
int exec_command_flags_to_strv(ExecCommandFlags flags, char ***ret);
char* exec_command_flags_to_exec_chars(ExecCommandFlags flags);
DECLARE_STRING_TABLE_LOOKUP(exec_command_flags, ExecCommandFlags);
+5 -5
View File
@@ -1569,11 +1569,11 @@ static SD_VARLINK_DEFINE_STRUCT_TYPE(
SD_VARLINK_FIELD_COMMENT("The parameter passed to the condition"),
SD_VARLINK_DEFINE_FIELD(parameter, SD_VARLINK_STRING, SD_VARLINK_NULLABLE));
/* UnitContext is used both as input to StartTransient (subset settable at creation time: ID,
* Description, CollectMode, Service, and the Exec subset {WorkingDirectory, Environment, SetCredential,
* SetCredentialEncrypted}) and as output from List/StartTransient (full unit configuration). Fields
* that are not settable at creation time are rejected with PropertyNotSupported when supplied as
* input. */
/* UnitContext is used both as input to StartTransient (subset settable at creation time: ID, Description,
* CollectMode, Service, Kill (currently KillMode and SendSIGHUP only), and the Exec subset listed in
* exec_properties[] in src/core/varlink-unit.c) and as output from List/StartTransient (full unit
* configuration). Fields that are not settable at creation time are rejected with PropertyNotSupported when
* supplied as input. */
static SD_VARLINK_DEFINE_STRUCT_TYPE(
UnitContext,
SD_VARLINK_FIELD_COMMENT("The unit type"),