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:
copilot-swe-agent[bot]
2025-12-28 15:55:25 +00:00
parent 5f366534aa
commit e1acbfc231
10 changed files with 250 additions and 12 deletions

View File

@@ -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");