[systemd-commits] 2 commits - src/execute.c src/load-fragment.c src/strv.c src/strv.h src/test-env-replace.c units/getty at .service.m4

Lennart Poettering lennart at kemper.freedesktop.org
Thu Jan 6 11:44:27 PST 2011


 src/execute.c           |    2 ++
 src/load-fragment.c     |    2 +-
 src/strv.c              |   23 ++++++++++++++++++++++-
 src/strv.h              |    2 ++
 src/test-env-replace.c  |   21 ++++++++++++++++++++-
 units/getty at .service.m4 |    4 ++++
 6 files changed, 51 insertions(+), 3 deletions(-)

New commits:
commit 1640944a847249d3f5f0fb0d5a5f820a82efaed0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 6 20:38:06 2011 +0100

    getty: unset locale before execution
    
    On the console indian characters cannot be displayed, hence it is
    advisable to disable indian locales on the console, which most
    distributions traditionally did from a shell fragment executed post
    login. If getty gets started with locale settings passed it would itself
    however be translated without the no-indian-on-console fixup applied.
    
    Hence, for now don't pass any locale settings to getty/login, and thus
    rely on the classic post-login script fragment to set and fix the
    locale.
    
    Eventually we probably want to drop this again since the system locale
    should be read and set at one place, and not at multiple, and that one
    place should be PID 1.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=663900

diff --git a/units/getty at .service.m4 b/units/getty at .service.m4
index 0b3160e..74ec1f3 100644
--- a/units/getty at .service.m4
+++ b/units/getty at .service.m4
@@ -32,6 +32,10 @@ RestartSec=0
 UtmpIdentifier=%I
 KillMode=process-group
 
+# Unset locale for the console getty since the console has problems
+# displaying some internationalized messages.
+Environment=LANG= LC_CTYPE= LC_NUMERIC= LC_TIME= LC_COLLATE= LC_MONETARY= LC_MESSAGE= LC_PAPER= LC_NAME= LC_ADDRESS= LC_TELEPHONE= LC_MEASUREMENT= LC_IDENTIFICATION=
+
 # Some login implementations ignore SIGTERM, so we send SIGHUP
 # instead, to ensure that login terminates cleanly.
 KillSignal=SIGHUP

commit a6ff950e71ea665fff99740f7b3e0137d451a79e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 6 20:38:02 2011 +0100

    execute: drop empty assignments from env blocks on execution but keep them around otherwise to make them visible

diff --git a/src/execute.c b/src/execute.c
index 05abd5a..8f486e2 100644
--- a/src/execute.c
+++ b/src/execute.c
@@ -1303,6 +1303,8 @@ int exec_spawn(ExecCommand *command,
                         goto fail;
                 }
 
+                final_env = strv_env_clean(final_env);
+
                 execve(command->path, final_argv, final_env);
                 r = EXIT_EXEC;
 
diff --git a/src/load-fragment.c b/src/load-fragment.c
index 334dd68..261180d 100644
--- a/src/load-fragment.c
+++ b/src/load-fragment.c
@@ -1399,7 +1399,7 @@ static int config_parse_env_file(
                         goto finish;
                 }
 
-                t = strv_env_set(*env, u);
+                t = strv_append(*env, u);
                 free(u);
 
                 if (!t) {
diff --git a/src/strv.c b/src/strv.c
index d9aef98..d1c7b2c 100644
--- a/src/strv.c
+++ b/src/strv.c
@@ -380,7 +380,7 @@ static int env_append(char **r, char ***k, char **a) {
 
         /* Add the entries of a to *k unless they already exist in *r
          * in which case they are overriden instead. This assumes
-         * there is enough space in the r */
+         * there is enough space in the r array. */
 
         for (; *a; a++) {
                 char **j;
@@ -556,3 +556,24 @@ char *strv_env_get_with_length(char **l, const char *name, size_t k) {
 char *strv_env_get(char **l, const char *name) {
         return strv_env_get_with_length(l, name, strlen(name));
 }
+
+char **strv_env_clean(char **l) {
+        char **r, **ret;
+
+        for (r = ret = l; *l; l++) {
+                const char *equal;
+
+                equal = strchr(*l, '=');
+
+                if (equal && equal[1] == 0) {
+                        free(*l);
+                        continue;
+                }
+
+                *(r++) = *l;
+        }
+
+        *r = NULL;
+
+        return ret;
+}
diff --git a/src/strv.h b/src/strv.h
index 1103e19..5af84ee 100644
--- a/src/strv.h
+++ b/src/strv.h
@@ -63,6 +63,8 @@ char **strv_env_set(char **x, const char *p);
 char *strv_env_get_with_length(char **l, const char *name, size_t k);
 char *strv_env_get(char **x, const char *n);
 
+char **strv_env_clean(char **l);
+
 #define STRV_FOREACH(s, l)                      \
         for ((s) = (l); (s) && *(s); (s)++)
 
diff --git a/src/test-env-replace.c b/src/test-env-replace.c
index 37dd7ff..4188c67 100644
--- a/src/test-env-replace.c
+++ b/src/test-env-replace.c
@@ -47,7 +47,7 @@ int main(int argc, char *argv[]) {
                 NULL
         };
 
-        char **i, **r, *t;
+        char **i, **r, *t, **a, **b;
 
         r = replace_env_argv((char**) line, (char**) env);
 
@@ -96,5 +96,24 @@ int main(int argc, char *argv[]) {
         printf("%s\n", t);
         free(t);
 
+        a = strv_new("FOO=BAR", "WALDO=WALDO", "WALDO=", "PIEP", "SCHLUMPF=SMURF", NULL);
+        b = strv_new("FOO=KKK", "FOO=", "PIEP=", "SCHLUMPF=SMURFF", "NANANANA=YES", NULL);
+
+        r = strv_env_merge(2, a, b);
+        strv_free(a);
+        strv_free(b);
+
+        STRV_FOREACH(i, r)
+                printf("%s\n", *i);
+
+        printf("CLEANED UP:\n");
+
+        r = strv_env_clean(r);
+
+        STRV_FOREACH(i, r)
+                printf("%s\n", *i);
+
+        strv_free(r);
+
         return 0;
 }



More information about the systemd-commits mailing list