mirror of
https://github.com/johndoe6345789/SparkOS.git
synced 2026-04-24 13:34:56 +00:00
Add regular user spark and clone-sparkos.sh script, default to non-root login
Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
24
src/init.c
24
src/init.c
@@ -28,16 +28,34 @@ static void spawn_shell() {
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
// Child process - exec shell
|
||||
// Child process - exec shell as spark user (uid 1000, gid 1000)
|
||||
|
||||
// Set user and group IDs to spark user
|
||||
if (setgid(1000) != 0) {
|
||||
perror("setgid failed");
|
||||
exit(1);
|
||||
}
|
||||
if (setuid(1000) != 0) {
|
||||
perror("setuid failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
char *argv[] = {"/bin/sh", "-l", NULL};
|
||||
char *envp[] = {
|
||||
"HOME=/root",
|
||||
"HOME=/home/spark",
|
||||
"PATH=/bin:/sbin:/usr/bin:/usr/sbin",
|
||||
"TERM=linux",
|
||||
"PS1=SparkOS# ",
|
||||
"PS1=SparkOS$ ",
|
||||
"USER=spark",
|
||||
"LOGNAME=spark",
|
||||
NULL
|
||||
};
|
||||
|
||||
// Change to home directory
|
||||
if (chdir("/home/spark") != 0) {
|
||||
perror("chdir failed");
|
||||
}
|
||||
|
||||
execve("/bin/sh", argv, envp);
|
||||
|
||||
perror("failed to exec shell");
|
||||
|
||||
Reference in New Issue
Block a user