[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[PATCH] Make the shell in tty2 and ssh all go to /root like on a real system.



ssh was already droping you there (though I'm not entirely sure where
the directory is coming from in that case), and you'd not have
.bash_history and .profile and .gdbinit.  So now everything uses /root ,
and you get the stuff you might expect.
---
 loader/init.c     |    2 ++
 loader/loader.c   |    2 ++
 scripts/mk-images |   10 +++++++---
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/loader/init.c b/loader/init.c
index cdba95e..c42f34a 100644
--- a/loader/init.c
+++ b/loader/init.c
@@ -853,6 +853,8 @@ int main(int argc, char **argv) {
             printf("Development mode requested spawning shell...\n");
 
             if ((shellpid = fork()) == 0) {
+                chdir("/root");
+                setenv("HOME", "/root", 1);
                 execl("/sbin/bash", "/sbin/bash", NULL);
             }
             else if (shellpid > 0) {
diff --git a/loader/loader.c b/loader/loader.c
index 32f84fc..b43b6ed 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -156,6 +156,8 @@ void doShell(void) {
     child = fork();
 
     if (child == 0) {
+        chdir("/root");
+        setenv("HOME", "/root", 1);
         if (execl("/sbin/bash", "/sbin/bash", "-i", NULL) == -1) {
             logMessage(ERROR, "%s (%d): %m", __func__, __LINE__);
             _exit(1);
diff --git a/scripts/mk-images b/scripts/mk-images
index 1125c9b..fd4b80c 100755
--- a/scripts/mk-images
+++ b/scripts/mk-images
@@ -910,13 +910,17 @@ EOF
 
     setupSshd
 
-    cat > $MBD_DIR/.profile <<EOF
+    mkdir $MBD_DIR/root
+    chmod 0700 $MBD_DIR/root
+    chown root:root $MBD_DIR/root
+
+    cat > $MBD_DIR/root/.profile <<EOF
 PS1="[anaconda \u \h \W]\\\\$ "
 PATH=/bin:/usr/bin:/usr/sbin:/mnt/sysimage/sbin:/mnt/sysimage/usr/sbin:/mnt/sysimage/bin:/mnt/sysimage/usr/bin
 export PATH PS1
 EOF
 
-    cat > $MBD_DIR/.bash_history <<EOF
+    cat > $MBD_DIR/root/.bash_history <<EOF
 kill -USR2 \`cat /var/run/anaconda.pid\`
 kill -HUP \`cat /var/run/anaconda.pid\`
 udevadm info --export-db | less
@@ -926,7 +930,7 @@ dmsetup table
 multipath -d
 EOF
 
-    cp /usr/share/doc/python-devel-*/gdbinit $MBD_DIR/.gdbinit
+    cp /usr/share/doc/python-devel-*/gdbinit $MBD_DIR/root/.gdbinit
 
     rm -f $MBD_FSIMAGE
     (cd $MBD_DIR; find . |cpio --quiet -c -o) |gzip -9 > $MBD_FSIMAGE
-- 
1.7.1.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]