From: Ray Strode Date: Sun, 21 Oct 2007 22:37:30 +0000 (-0400) Subject: chroot back to original / before spawning nash. X-Git-Tag: 0.1.0~143^2~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78302f06c38f4ada1100fee6a2f319a194f7c2ad;p=thirdparty%2Fplymouth.git chroot back to original / before spawning nash. Also use ply-utils ls functiona and add random multilib fixes --- diff --git a/src/main.c b/src/main.c index b612a477..e6feebc2 100644 --- a/src/main.c +++ b/src/main.c @@ -59,7 +59,14 @@ on_session_start (state_t *state) if (fchdir (state->original_root_dir_fd) < 0) { ply_trace ("Could not change to original root directory " - "to start session: %m"); + "to start session: %m"); + return; + } + + if (chroot (".") < 0) + { + ply_trace ("Could not change root back to original directory " + "to start session: %m"); return; } ply_trace ("changed to original root fs"); @@ -208,12 +215,10 @@ create_working_directory (state_t *state) if (!ply_create_directory ("usr/share/plymouth")) return false; - ply_trace ("creating usr/lib/plymouth subdirectory"); - if (!ply_create_directory ("usr/lib/plymouth")) + ply_trace ("creating " PLYMOUTH_PLUGIN_PATH " subdirectory"); + if (!ply_create_directory (PLYMOUTH_PLUGIN_PATH + 1)) return false; - ply_trace ("created detachable working directory '%s'", - PLY_WORKING_DIRECTORY); return true; } @@ -304,52 +309,14 @@ copy_data_files (state_t *state) ply_trace ("copied data files"); ply_trace ("copying plugins"); - if (!ply_copy_directory ("/usr/lib/plymouth", - "usr/lib/plymouth")) + if (!ply_copy_directory (PLYMOUTH_PLUGIN_PATH, + PLYMOUTH_PLUGIN_PATH + 1)) return false; ply_trace ("copied plugins files"); return true; } -static void -ls (const char *path) -{ - DIR *dir; - struct dirent *entry; - static int level = 0; - - dir = opendir (path); - - if (dir == NULL) - return; - - if (level > 5) - return; - - int index = 0; - while ((entry = readdir (dir)) != NULL) - { - char *subdir; - - index++; - - if (index > 10) - break; - - subdir = NULL; - asprintf (&subdir, "%s/%s", path, entry->d_name); - ply_error ("%s ", subdir); - level++; - if (entry->d_name[0] != '.') - ls (subdir); - level--; - free (subdir); - } - - closedir (dir); -} - static bool initialize_environment (state_t *state) { @@ -401,6 +368,7 @@ main (int argc, if (!initialize_environment (&state)) { ply_error ("could not setup basic operating environment: %m"); + ply_list_directory (PLY_WORKING_DIRECTORY); return EX_OSERR; }