init: Don't leak pwent fd to child processes

This commit is contained in:
Bananymous 2024-09-11 22:11:05 +03:00
parent 467ac6c365
commit 86dcb5c471
1 changed files with 6 additions and 1 deletions

View File

@ -114,7 +114,12 @@ int main()
setenv("HOME", pwd->pw_dir, 1);
chdir(pwd->pw_dir);
execl(pwd->pw_shell, pwd->pw_shell, nullptr);
char shell_path[PATH_MAX];
strcpy(shell_path, pwd->pw_shell);
endpwent();
execl(shell_path, shell_path, nullptr);
perror("execl");
exit(1);