]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: use logindefs_setenv_path()
authorKarel Zak <kzak@redhat.com>
Wed, 7 May 2025 10:06:21 +0000 (12:06 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 7 May 2025 10:06:21 +0000 (12:06 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/login.c

index 321f9d6ce321bf5a04fd965cc6a38b718bee3083..b77a8040f54a798c1e09fc2f5157b6756aac3863 100644 (file)
@@ -1212,14 +1212,8 @@ static void init_environ(struct login_context *cxt)
        xsetenv("USER", pwd->pw_name, 1);
        xsetenv("SHELL", pwd->pw_shell, 1);
 
-       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 &&
-                  logindefs_setenv("PATH", "ENV_SUPATH", _PATH_DEFPATH_ROOT) != 0) {
-                       err(EXIT_FAILURE, _("failed to set the %s environment variable"), "PATH");
-       }
+       if (logindefs_setenv_path(pwd->pw_uid) != 0)
+               err(EXIT_FAILURE, _("failed to set the PATH environment variable"));
 
        /* mailx will give a funny error msg if you forget this one */
        len = snprintf(tmp, sizeof(tmp), "%s/%s", _PATH_MAILDIR, pwd->pw_name);