1818#include < sys/wait.h>
1919#include < unistd.h>
2020
21+ static constexpr Array WELL_KNOWN_HOME_DIRS = { " Desktop" sv, " Documents" sv, " Downloads" sv, " Music" sv, " Pictures" sv, " Videos" sv };
22+
2123static void child_process (Core::Account const & account)
2224{
2325 pid_t rc = setsid ();
@@ -31,6 +33,15 @@ static void child_process(Core::Account const& account)
3133 exit (1 );
3234 }
3335
36+ // Create well-known home subdirectories when not existing
37+ for (auto dir : WELL_KNOWN_HOME_DIRS) {
38+ auto path = MUST (String::formatted (" {}/{}" , account.home_directory (), dir));
39+ if (FileSystem::exists (path))
40+ continue ;
41+ MUST (Core::System::mkdir (path, 0755 ));
42+ MUST (Core::System::chown (path, account.uid (), account.gid ()));
43+ }
44+
3445 if (auto const result = account.login (); result.is_error ()) {
3546 dbgln (" failed to switch users: {}" , result.error ());
3647 exit (1 );
@@ -65,7 +76,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
6576 auto app = TRY (GUI::Application::create (arguments));
6677
6778 TRY (Core::System::pledge (" stdio recvfd sendfd cpath chown rpath exec proc id" ));
68- TRY (Core::System::unveil (" /home" , " r " ));
79+ TRY (Core::System::unveil (" /home" , " rwc " ));
6980 TRY (Core::System::unveil (" /tmp" , " c" ));
7081 TRY (Core::System::unveil (" /etc/passwd" , " r" ));
7182 TRY (Core::System::unveil (" /etc/shadow" , " r" ));
0 commit comments