diff options
| -rw-r--r-- | src/lamina/main.c | 34 | ||||
| -rw-r--r-- | todo.org | 4 |
2 files changed, 36 insertions, 2 deletions
diff --git a/src/lamina/main.c b/src/lamina/main.c index 2314019..f461058 100644 --- a/src/lamina/main.c +++ b/src/lamina/main.c @@ -528,6 +528,38 @@ Cleanup(void) if(MountsCleanup == true) unmount_all(); } +static int +Shell(void) +{ + pid_t PID = fork(); + if(PID == -1) + { + fprintf(stderr, "fork: %s\n", strerror(errno)); + return -1; + } + if(PID == 0) + { + close_all(); + if(chroot(Root) == -1) + { + fprintf(stderr, "chroot %s: %s\n", Root, strerror(errno)); + exit(-1); + } + if(chdir("/") == -1) + { + fprintf(stderr, "chdir /: %s\n", strerror(errno)); + exit(-1); + } + execlp("/bin/sh", "sh", NULL); + fprintf(stderr, "execlp /bin/sh: %s\n", strerror(errno)); + exit(-1); + } + int Exit; + waitpid(PID, &Exit, 0); + if(!WIFEXITED(Exit) || (WEXITSTATUS(Exit) != 0)) return -1; + return 0; +} + int main(int ArgCount, char **Arg) { @@ -567,6 +599,8 @@ main(int ArgCount, char **Arg) if(Execute(Line, (size_t)LineLength) == -1) { fprintf(stderr, "(line %zu)\n", LineAt); + fprintf(stderr, "starting a shell inside %s\n", Root); + Shell(); break; } } @@ -97,7 +97,7 @@ - [ ] 9p - this will probably have to wait for 15.0-RELEASE -- [-] sf.lamina +- [X] sf.lamina - [X] parse commands - [X] commands - [X] LAYER @@ -106,7 +106,7 @@ - [X] CHDIR - [X] COPY - [X] USER - - [ ] if a failure occurs, drop into a shell inside the chroot + - [X] if a failure occurs, drop into a shell inside the chroot - [ ] sf.gui - Web gui would be nice... I should first play with canvas a bit and javascript. I have no previous experience with this. |
