[systemd-commits] 2 commits - man/systemd.exec.xml man/systemd-system.conf.xml src/core src/shared
Zbigniew JÄdrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Thu Jun 20 13:29:27 PDT 2013
man/systemd-system.conf.xml | 21 +++++++++++++++++++++
man/systemd.exec.xml | 5 +++--
src/core/load-fragment.c | 8 ++++++--
src/core/main.c | 5 +++++
src/core/manager.c | 12 ++++++++++++
src/core/manager.h | 1 +
src/core/system.conf | 1 +
src/shared/logs-show.c | 4 ++--
8 files changed, 51 insertions(+), 6 deletions(-)
New commits:
commit 97d0e5f83ba4dd713170f802b90149b7325bc992
Author: Umut Tezduyar <umut at tezduyar.com>
Date: Sun Jun 9 07:08:46 2013 +0200
manager: add DefaultEnvironment option
This complements existing functionality of setting variables
through 'systemctl set-environment', the kernel command line,
and through normal environment variables for systemd in session
mode.
diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml
index d8bfd12..5886855 100644
--- a/man/systemd-system.conf.xml
+++ b/man/systemd-system.conf.xml
@@ -263,6 +263,27 @@
</varlistentry>
<varlistentry>
+ <term><varname>DefaultEnvironment=</varname></term>
+
+ <listitem><para>Sets systemd manager
+ environment variables for executed
+ processes. Takes a space-separated
+ list of variable assignments.
+ </para>
+
+ <para>Example:
+ <programlisting>Environment="VAR1=word1 word2" VAR2=word3 "VAR3=word 5 6"</programlisting>
+ gives three variables <literal>VAR1</literal>,
+ <literal>VAR2</literal>, <literal>VAR3</literal>.
+ </para>
+
+ <para>
+ See
+ <citerefentry><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry>
+ for details about environment variables.</para></listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><varname>DefaultLimitCPU=</varname></term>
<term><varname>DefaultLimitFSIZE=</varname></term>
<term><varname>DefaultLimitDATA=</varname></term>
diff --git a/man/systemd.exec.xml b/man/systemd.exec.xml
index ab1712e..8d5948a 100644
--- a/man/systemd.exec.xml
+++ b/man/systemd.exec.xml
@@ -288,8 +288,9 @@
variables is reset, all prior
assignments have no effect.
Variable expansion is not performed
- inside the strings, and $ has no special
- meaning.
+ inside the strings, however, specifier
+ expansion is possible. $ character has
+ no special meaning.
If you need to assign a value containing spaces
to a variable, use double quotes (")
for the assignment.</para>
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index 4a835b6..15fabe8 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -1564,7 +1564,7 @@ int config_parse_environ(const char *unit,
assert(filename);
assert(lvalue);
assert(rvalue);
- assert(u);
+ assert(data);
if (isempty(rvalue)) {
/* Empty assignment resets the list */
@@ -1573,7 +1573,11 @@ int config_parse_environ(const char *unit,
return 0;
}
- k = unit_full_printf(u, rvalue);
+ if (u)
+ k = unit_full_printf(u, rvalue);
+ else
+ k = strdup(rvalue);
+
if (!k)
return log_oom();
diff --git a/src/core/main.c b/src/core/main.c
index 26aa561..470fecf 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -94,6 +94,7 @@ static ExecOutput arg_default_std_output = EXEC_OUTPUT_JOURNAL;
static ExecOutput arg_default_std_error = EXEC_OUTPUT_INHERIT;
static usec_t arg_runtime_watchdog = 0;
static usec_t arg_shutdown_watchdog = 10 * USEC_PER_MINUTE;
+static char **arg_default_environment = NULL;
static struct rlimit *arg_default_rlimit[RLIMIT_NLIMITS] = {};
static uint64_t arg_capability_bounding_set_drop = 0;
static nsec_t arg_timer_slack_nsec = (nsec_t) -1;
@@ -646,6 +647,7 @@ static int parse_config_file(void) {
{ "Manager", "ShutdownWatchdogSec", config_parse_sec, 0, &arg_shutdown_watchdog },
{ "Manager", "CapabilityBoundingSet", config_parse_bounding_set, 0, &arg_capability_bounding_set_drop },
{ "Manager", "TimerSlackNSec", config_parse_nsec, 0, &arg_timer_slack_nsec },
+ { "Manager", "DefaultEnvironment", config_parse_environ, 0, &arg_default_environment },
{ "Manager", "DefaultLimitCPU", config_parse_limit, 0, &arg_default_rlimit[RLIMIT_CPU]},
{ "Manager", "DefaultLimitFSIZE", config_parse_limit, 0, &arg_default_rlimit[RLIMIT_FSIZE]},
{ "Manager", "DefaultLimitDATA", config_parse_limit, 0, &arg_default_rlimit[RLIMIT_DATA]},
@@ -1630,6 +1632,9 @@ int main(int argc, char *argv[]) {
if (arg_default_controllers)
manager_set_default_controllers(m, arg_default_controllers);
+ if (arg_default_environment)
+ manager_set_default_environment(m, arg_default_environment);
+
manager_set_show_status(m, arg_show_status);
/* Remember whether we should queue the default job */
diff --git a/src/core/manager.c b/src/core/manager.c
index f16621a..5c3a2c7 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -2570,6 +2570,18 @@ void manager_undo_generators(Manager *m) {
remove_generator_dir(m, &m->generator_unit_path_late);
}
+int manager_set_default_environment(Manager *m, char **environment) {
+
+ char **e = NULL;
+ assert(m);
+ e = strv_env_merge(2, m->environment, environment);
+ if (!e)
+ return -ENOMEM;
+ strv_free(m->environment);
+ m->environment = e;
+ return 0;
+}
+
int manager_set_default_controllers(Manager *m, char **controllers) {
char **l;
diff --git a/src/core/manager.h b/src/core/manager.h
index e21c8f7..f0bb2eb 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -272,6 +272,7 @@ unsigned manager_dispatch_load_queue(Manager *m);
unsigned manager_dispatch_run_queue(Manager *m);
unsigned manager_dispatch_dbus_queue(Manager *m);
+int manager_set_default_environment(Manager *m, char **environment);
int manager_set_default_controllers(Manager *m, char **controllers);
int manager_set_default_rlimits(Manager *m, struct rlimit **default_rlimit);
diff --git a/src/core/system.conf b/src/core/system.conf
index 508e0f5..f2817bc 100644
--- a/src/core/system.conf
+++ b/src/core/system.conf
@@ -25,6 +25,7 @@
#ShutdownWatchdogSec=10min
#CapabilityBoundingSet=
#TimerSlackNSec=
+#DefaultEnvironment=
#DefaultLimitCPU=
#DefaultLimitFSIZE=
#DefaultLimitDATA=
commit 8c1396b1c2dfecbb59af61064f6a0f624385004d
Author: Zbigniew JÄdrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Thu Jun 20 16:15:04 2013 -0400
journalctl: show lines in full with --all
In 31f7bf1 "logs-show: print multiline messages", I forgot
to take into account the fact that --all implies --full for
journalctl.
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index 013a281..40efad3 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -101,7 +101,7 @@ static bool shall_print(const char *p, size_t l, OutputFlags flags) {
return true;
}
-static void print_multiline(FILE *f, unsigned prefix, unsigned n_columns, int flags, int priority, const char* message, size_t message_len) {
+static void print_multiline(FILE *f, unsigned prefix, unsigned n_columns, OutputMode flags, int priority, const char* message, size_t message_len) {
const char *color_on = "", *color_off = "";
const char *pos, *end;
bool continuation = false;
@@ -123,7 +123,7 @@ static void print_multiline(FILE *f, unsigned prefix, unsigned n_columns, int fl
len = end - pos;
assert(len >= 0);
- if ((flags & OUTPUT_FULL_WIDTH) || (prefix + len + 1 < n_columns))
+ if (flags & (OUTPUT_FULL_WIDTH | OUTPUT_SHOW_ALL) || prefix + len + 1 < n_columns)
fprintf(f, "%*s%s%.*s%s\n",
continuation * prefix, "",
color_on, len, pos, color_off);
More information about the systemd-commits
mailing list