summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/init/init.c23
-rw-r--r--src/cmd/login/login.c89
-rw-r--r--sysroot/Users/dzwdz/private/secrets.txt2
-rw-r--r--sysroot/Users/dzwdz/public/stuff.txt2
-rw-r--r--sysroot/bin/sh/mkuser7
-rw-r--r--sysroot/usr/arp.etherbin64 -> 0 bytes
6 files changed, 4 insertions, 119 deletions
diff --git a/src/cmd/init/init.c b/src/cmd/init/init.c
index 093e281..7f26f1b 100644
--- a/src/cmd/init/init.c
+++ b/src/cmd/init/init.c
@@ -56,18 +56,15 @@ int main(void) {
MOUNT_AT("/") {
fs_dirinject2((const char*[]){
- "/keyboard/",
"/usr/",
"/bin/",
- "/Users/",
"/tmp/",
- "/vtty",
"/net/",
NULL
});
}
- MOUNT_AT("/keyboard") {
+ MOUNT_AT("/dev/keyboard") {
MOUNT_AT("/") { fs_whitelist((const char*[]){"/dev/ps2/kb", NULL}); }
ps2_drv();
}
@@ -86,26 +83,14 @@ int main(void) {
NULL
});
}
- MOUNT_AT("/Users/") {
- MOUNT_AT("/tmp/") {
- const char *argv[] = {"/bin/tmpfs", NULL};
- execv(argv[0], (void*)argv);
- }
- // TODO a simple union isn't enough here
- fs_union((const char*[]){
- "/tmp/",
- "/init/Users/",
- NULL
- });
- }
MOUNT_AT("/tmp/") {
const char *allow[] = {"/bin/tmpfs", NULL};
const char *argv[] = {"/bin/tmpfs", NULL};
MOUNT_AT("/") { fs_whitelist(allow); }
execv(argv[0], (void*)argv);
}
- MOUNT_AT("/vtty") {
- const char *allow[] = {"/bin/vterm", "/dev/video/", "/keyboard", "/init/usr/share/fonts/", NULL};
+ MOUNT_AT("/dev/vtty") {
+ const char *allow[] = {"/bin/vterm", "/dev/video/", "/dev/keyboard", "/init/usr/share/fonts/", NULL};
const char *argv[] = {"/bin/vterm", NULL};
MOUNT_AT("/") { fs_whitelist(allow); }
execv(argv[0], (void*)argv);
@@ -119,7 +104,7 @@ int main(void) {
if (!fork()) {
redirect("/bin/shell", "/dev/com1", "/dev/com1");
- redirect("/bin/shell", "/vtty", "/keyboard");
+ redirect("/bin/shell", "/dev/vtty", "/dev/keyboard");
exit(1);
}
diff --git a/src/cmd/login/login.c b/src/cmd/login/login.c
deleted file mode 100644
index 0f9e8b7..0000000
--- a/src/cmd/login/login.c
+++ /dev/null
@@ -1,89 +0,0 @@
-#include <camellia/flags.h>
-#include <camellia/syscalls.h>
-#include <ctype.h>
-#include <errno.h>
-#include <limits.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-#include <camellia/fs/misc.h>
-
-static const char *shell = "/bin/shell";
-
-static void cutspace(char *s) {
- for (; *s; s++) {
- if (isspace(*s)) {
- *s = '\0';
- break;
- }
- }
-}
-
-static bool segcmp(const char *path, int idx, const char *s2) {
- if (idx < 0) return false;
- while (idx > 0) {
- if (*path == '\0') return false;
- if (*path == '/') idx--;
- path++;
- }
- /* path is at the start of the selected segment */
- while (*s2 && *path++ == *s2++);
- return (*path == '\0' || *path == '/') && *s2 == '\0';
-}
-
-static void drv(const char *user) {
- char *buf = malloc(PATH_MAX);
- for (;;) {
- struct ufs_request req;
- hid_t reqh = ufs_wait(buf, PATH_MAX, &req);
- if (reqh < 0) break;
- switch (req.op) {
- case VFSOP_OPEN:
- if (segcmp(buf, 1, "Users") && segcmp(buf, 2, user)) { // /Users/$user/**
- forward_open(reqh, buf, req.len, req.flags);
- } else if (segcmp(buf, 1, "Users") && segcmp(buf, 3, "private")) { // /Users/*/private/**
- _sys_fs_respond(reqh, NULL, -EACCES, 0);
- } else if (!OPEN_WRITEABLE(req.flags)) {
- forward_open(reqh, buf, req.len, req.flags);
- } else {
- _sys_fs_respond(reqh, NULL, -EACCES, 0);
- }
- break;
-
- default:
- _sys_fs_respond(reqh, NULL, -1, 0);
- break;
- }
- }
- free(buf);
-}
-
-static void trylogin(const char *user) {
- if (strcmp(user, "root") != 0) {
- char buf[128];
- snprintf(buf, sizeof buf, "/Users/%s/", user);
- if (chdir(buf) < 0) {
- printf("no such user: %s\n", user);
- return;
- }
- MOUNT_AT("/") { drv(user); }
- }
-
- execv(shell, NULL);
- fprintf(stderr, "login: couldn't launch %s\n", shell);
- exit(1);
-}
-
-int main(void) {
- char user[64];
- printf("\nCamellia\n");
- for (;;) {
- printf("login: ");
- fgets(user, sizeof user, stdin);
- if (ferror(stdin)) return -1;
-
- cutspace(user);
- if (user[0]) trylogin(user);
- }
-}
diff --git a/sysroot/Users/dzwdz/private/secrets.txt b/sysroot/Users/dzwdz/private/secrets.txt
deleted file mode 100644
index 7f1bcbc..0000000
--- a/sysroot/Users/dzwdz/private/secrets.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-I enjoyed Twilight.
-
diff --git a/sysroot/Users/dzwdz/public/stuff.txt b/sysroot/Users/dzwdz/public/stuff.txt
deleted file mode 100644
index b864fc2..0000000
--- a/sysroot/Users/dzwdz/public/stuff.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-A publicly readable file.
-
diff --git a/sysroot/bin/sh/mkuser b/sysroot/bin/sh/mkuser
deleted file mode 100644
index a1544c6..0000000
--- a/sysroot/bin/sh/mkuser
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/shell
-touch /Users/user/
-cd /Users/user/
-touch private/
-echo secrets! > private/secret.txt
-touch public/
-echo no secrets here > public/hi.txt \ No newline at end of file
diff --git a/sysroot/usr/arp.ether b/sysroot/usr/arp.ether
deleted file mode 100644
index c8fbec7..0000000
--- a/sysroot/usr/arp.ether
+++ /dev/null
Binary files differ