]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
user-util: be more strict when reading $HOME and $SHELL
authorLennart Poettering <lennart@poettering.net>
Thu, 7 Mar 2019 09:53:23 +0000 (10:53 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 12 Mar 2019 15:10:55 +0000 (16:10 +0100)
src/basic/user-util.c

index 4cf4c5a341459e61dbbc6d8f83f3894f30a6361d..47d6763f1c917f82db0ee6606b0aa5a16e4c79c3 100644 (file)
@@ -458,7 +458,7 @@ int get_home_dir(char **_h) {
 
         /* Take the user specified one */
         e = secure_getenv("HOME");
-        if (e && path_is_absolute(e)) {
+        if (e && path_is_valid(e) && path_is_absolute(e)) {
                 h = strdup(e);
                 if (!h)
                         return -ENOMEM;
@@ -493,7 +493,8 @@ int get_home_dir(char **_h) {
         if (!p)
                 return errno > 0 ? -errno : -ESRCH;
 
-        if (!path_is_absolute(p->pw_dir))
+        if (!path_is_valid(p->pw_dir) ||
+            !path_is_absolute(p->pw_dir))
                 return -EINVAL;
 
         h = strdup(p->pw_dir);
@@ -514,7 +515,7 @@ int get_shell(char **_s) {
 
         /* Take the user specified one */
         e = getenv("SHELL");
-        if (e) {
+        if (e && path_is_valid(e) && path_is_absolute(e)) {
                 s = strdup(e);
                 if (!s)
                         return -ENOMEM;
@@ -549,7 +550,8 @@ int get_shell(char **_s) {
         if (!p)
                 return errno > 0 ? -errno : -ESRCH;
 
-        if (!path_is_absolute(p->pw_shell))
+        if (!path_is_valid(p->pw_shell) ||
+            !path_is_absolute(p->pw_shell))
                 return -EINVAL;
 
         s = strdup(p->pw_shell);