]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
include/env: minor fixes and clean ups
authorKarel Zak <kzak@redhat.com>
Tue, 16 Aug 2016 10:35:57 +0000 (12:35 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 16 Aug 2016 10:35:57 +0000 (12:35 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
include/env.h
login-utils/login.c

index ff5fc796e3e3cc3a800f7032e8788aa0b01aacae..db6f95932dc9b5ab5c7cca7cd99329bc6786eee1 100644 (file)
@@ -2,14 +2,20 @@
 #define UTIL_LINUX_ENV_H
 
 #include "c.h"
+#include "nls.h"
 
 extern void sanitize_env(void);
 extern char *safe_getenv(const char *arg);
 
+
+#ifndef XSETENV_EXIT_CODE
+# define XSETENV_EXIT_CODE EXIT_FAILURE
+#endif
+
 static inline void xsetenv(char const *name, char const *val, int overwrite)
 {
        if (setenv(name, val, overwrite) != 0)
-               err(EXIT_FAILURE, _("failed to set the %s environment variable"), name);
+               err(XSETENV_EXIT_CODE, _("failed to set the %s environment variable"), name);
 }
 
 #endif /* UTIL_LINUX_ENV_H */
index 1de24a8b895a85b7b2948b249ffaecf727a91141..2350fc3ec3b548dc989a9781b5ba78d82a836d6e 100644 (file)
@@ -1047,13 +1047,14 @@ static void init_environ(struct login_context *cxt)
        xsetenv("TERM", termenv ? termenv : "dumb", 1);
        free(termenv);
 
-       if (pwd->pw_uid)
+       if (pwd->pw_uid) {
                if (logindefs_setenv("PATH", "ENV_PATH", _PATH_DEFPATH) != 0)
                        err(EXIT_FAILURE, _("failed to set the %s environment variable"), "PATH");
 
-       else if (logindefs_setenv("PATH", "ENV_ROOTPATH", NULL) != 0)
-               if (logindefs_setenv("PATH", "ENV_SUPATH", _PATH_DEFPATH_ROOT) != 0)
+       } else if (logindefs_setenv("PATH", "ENV_ROOTPATH", NULL) != 0 &&
+                  logindefs_setenv("PATH", "ENV_SUPATH", _PATH_DEFPATH_ROOT) != 0) {
                        err(EXIT_FAILURE, _("failed to set the %s environment variable"), "PATH");
+       }
 
        /* mailx will give a funny error msg if you forget this one */
        len = snprintf(tmp, sizeof(tmp), "%s/%s", _PATH_MAILDIR, pwd->pw_name);