mirror of
https://github.com/morgan9e/systemd
synced 2026-04-15 08:56:15 +09:00
user-util: be more strict when reading $HOME and $SHELL
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user