From 287b146621ad8d9bbaedd0355e314366eeb58902 Mon Sep 17 00:00:00 2001 From: Astronand Date: Thu, 19 Feb 2026 11:18:02 -0500 Subject: [PATCH 1/2] Update Src/Hyperion-bash/bin/bash --- Src/Hyperion-bash/bin/bash | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Src/Hyperion-bash/bin/bash b/Src/Hyperion-bash/bin/bash index b9f4b18..26eee21 100644 --- a/Src/Hyperion-bash/bin/bash +++ b/Src/Hyperion-bash/bin/bash @@ -173,6 +173,17 @@ local function getUserInput() end local function runCommand(command) + do + local func = load("return " .. command, "@equation", "t", {}) + if func then + local success, result = pcall(func) + if success and type(result) == "number" then + print(result) + return + end + end + end + terminate = false local args = string.split(command, " ") if builtinCmds[args[1]] then From 10bc775e6435fee0f3bc603182d193adc3179c6a Mon Sep 17 00:00:00 2001 From: Astronand Date: Fri, 20 Feb 2026 11:34:53 -0500 Subject: [PATCH 2/2] e --- .vscode/settings.json | 3 +- Src/Hyperion-bash/bin/cat | 3 +- .../bin/su => Hyperion-core/bin/login} | 0 .../bin/sudo => Hyperion-core/bin/su} | 0 Src/Hyperion-core/bin/sudo | 0 Src/Hyperion-core/sbin/init.lua | 1 - Src/Hyperion-kernel/boot/kernel.lua | 14 ++-- Src/Hyperion-kernel/etc/passwd | 1 + Src/Hyperion-kernel/etc/shadow | 0 .../lib/modules/Hyperion/01_stdlib.kmod | 4 ++ .../lib/modules/Hyperion/26_tty.kmod | 3 +- .../Hyperion/{40_pam.kmod => 40_auth.kmod} | 71 +++++++++---------- .../lib/modules/Hyperion/45_hypervisor.kmod | 16 ++--- .../lib/modules/Hyperion/90_init.kmod | 1 - 14 files changed, 57 insertions(+), 60 deletions(-) rename Src/{Hyperion-bash/bin/su => Hyperion-core/bin/login} (100%) rename Src/{Hyperion-bash/bin/sudo => Hyperion-core/bin/su} (100%) create mode 100644 Src/Hyperion-core/bin/sudo create mode 100644 Src/Hyperion-kernel/etc/passwd create mode 100644 Src/Hyperion-kernel/etc/shadow rename Src/Hyperion-kernel/lib/modules/Hyperion/{40_pam.kmod => 40_auth.kmod} (80%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 7bcec0c..81d26b7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,6 +4,7 @@ "isEqualToAll", "syscall", "printf", - "printInline" + "printInline", + "toHex" ] } \ No newline at end of file diff --git a/Src/Hyperion-bash/bin/cat b/Src/Hyperion-bash/bin/cat index 1ebd5b6..b9dbe6a 100644 --- a/Src/Hyperion-bash/bin/cat +++ b/Src/Hyperion-bash/bin/cat @@ -20,4 +20,5 @@ while content~=nil or file == 0 do content=syscall.read(file, 1024) printInline(content) end -syscall.close(file) \ No newline at end of file +syscall.close(file) +print("") \ No newline at end of file diff --git a/Src/Hyperion-bash/bin/su b/Src/Hyperion-core/bin/login similarity index 100% rename from Src/Hyperion-bash/bin/su rename to Src/Hyperion-core/bin/login diff --git a/Src/Hyperion-bash/bin/sudo b/Src/Hyperion-core/bin/su similarity index 100% rename from Src/Hyperion-bash/bin/sudo rename to Src/Hyperion-core/bin/su diff --git a/Src/Hyperion-core/bin/sudo b/Src/Hyperion-core/bin/sudo new file mode 100644 index 0000000..e69de29 diff --git a/Src/Hyperion-core/sbin/init.lua b/Src/Hyperion-core/sbin/init.lua index 16ad4c6..b95bce5 100644 --- a/Src/Hyperion-core/sbin/init.lua +++ b/Src/Hyperion-core/sbin/init.lua @@ -25,7 +25,6 @@ for i,v in ipairs(files) do kernel.log("Error loading startup script '" .. filepath .. "': " .. err, "ERROR") else syscall.spawn(function() - syscall.setUsername("User") syscall.setuid(1) local status, err = pcall(startupFunc) if not status then diff --git a/Src/Hyperion-kernel/boot/kernel.lua b/Src/Hyperion-kernel/boot/kernel.lua index 8f87f3a..498b95a 100644 --- a/Src/Hyperion-kernel/boot/kernel.lua +++ b/Src/Hyperion-kernel/boot/kernel.lua @@ -10,7 +10,7 @@ local kernel = {} kernel.LOG_Text="" kernel.version="HyperionOS V1.0.0" kernel.process = "Kernel" -kernel.username = "root" +kernel.users={[0]="root",[1]="User"} kernel.hostname = "hyperion" kernel.groups = {} kernel.uid = 0 @@ -27,15 +27,15 @@ local windowsExp = false function kernel.log(msg, level, c) c=c or 12 - kernel.LOG_Text = kernel.LOG_Text..tostring(computer:time()).." "..kernel.username.." "..kernel.process.."["..tostring(level or "INFO").."]: "..msg.."\n" + kernel.LOG_Text = kernel.LOG_Text..tostring(computer:time()).." "..kernel.users[kernel.uid].." "..kernel.process.."["..tostring(level or "INFO").."]: "..msg.."\n" if kernel.status == "start" then screen:setTextColor(c) - screen:print(tostring(computer:time()).." "..kernel.username.." "..kernel.process.."["..tostring(level or "INFO").."]: "..msg) - elseif kernel.status == "init" then + screen:print(string.format("%X",c-1).." "..tostring(computer:time()).." "..kernel.users[kernel.uid].." "..kernel.process.."["..tostring(level or "INFO").."]: "..msg) + elseif kernel.status == "term" then kernel.standbyTask=kernel.currentTask kernel.currentTask=kernel.kernelTask kernel.vfs.devctl(1,"sfgc",c) - kernel.vfs.write(1,tostring(computer:time()).." "..kernel.username.." "..kernel.process.."["..tostring(level or "INFO").."]: "..msg) + kernel.vfs.write(1,string.format("%X",c-1).." "..tostring(computer:time()).." "..kernel.users[kernel.uid].." "..kernel.process.."["..tostring(level or "INFO").."]: "..msg.."\n") kernel.currentTask=kernel.standbyTask end end @@ -204,7 +204,6 @@ kernel.kernelTask = { status="R", pid=0, tgid=0, - username="root", uid=0, fd={}, exit="", @@ -232,12 +231,11 @@ end kernel.syscalls["time"]=function() return kernel.computer:time() end kernel.syscalls["log"]=kernel.log kernel.syscalls["getUptime"]=function() return kernel.computer:clock() end -kernel.syscalls["getUsername"]=function() return kernel.username end +kernel.syscalls["getUsername"]=function(uid) return kernel.users[uid or kernel.uid] end kernel.syscalls["getHostname"]=function() return kernel.hostname end kernel.syscalls["getHost"]=function() return kernel.apis._HOST end kernel.syscalls["version"]=function() return kernel.version end kernel.syscalls["setHostname"]=function(name) if kernel.uid~=0 then error("Permission denied") end kernel.hostname=name end -kernel.syscalls["setUsername"]=function(user) if kernel.uid~=0 then error("Permission denied") end kernel.currentTask.username=user end kernel.syscalls["arch"]=function() return arch end kernel.syscalls["sysdump"]=function() local rv={} diff --git a/Src/Hyperion-kernel/etc/passwd b/Src/Hyperion-kernel/etc/passwd new file mode 100644 index 0000000..2d4ba4c --- /dev/null +++ b/Src/Hyperion-kernel/etc/passwd @@ -0,0 +1 @@ +0:0:root:/root:/bin/bash \ No newline at end of file diff --git a/Src/Hyperion-kernel/etc/shadow b/Src/Hyperion-kernel/etc/shadow new file mode 100644 index 0000000..e69de29 diff --git a/Src/Hyperion-kernel/lib/modules/Hyperion/01_stdlib.kmod b/Src/Hyperion-kernel/lib/modules/Hyperion/01_stdlib.kmod index 66b614e..c637b97 100644 --- a/Src/Hyperion-kernel/lib/modules/Hyperion/01_stdlib.kmod +++ b/Src/Hyperion-kernel/lib/modules/Hyperion/01_stdlib.kmod @@ -205,6 +205,10 @@ function string.replace(s, target, repl) return table.concat(result) end +function toHex(num) + return string.format("%X", num) +end + syscall = setmetatable({}, { __index = function(self, name) return function(...) diff --git a/Src/Hyperion-kernel/lib/modules/Hyperion/26_tty.kmod b/Src/Hyperion-kernel/lib/modules/Hyperion/26_tty.kmod index aa70865..3d1bcb1 100644 --- a/Src/Hyperion-kernel/lib/modules/Hyperion/26_tty.kmod +++ b/Src/Hyperion-kernel/lib/modules/Hyperion/26_tty.kmod @@ -2,4 +2,5 @@ local kernel=... kernel.vfs.open("/dev/null", "r") kernel.vfs.open("/dev/tty/TTY1", "w") -kernel.vfs.open("/dev/null", "w") \ No newline at end of file +kernel.vfs.open("/dev/null", "w") +kernel.status="term" \ No newline at end of file diff --git a/Src/Hyperion-kernel/lib/modules/Hyperion/40_pam.kmod b/Src/Hyperion-kernel/lib/modules/Hyperion/40_auth.kmod similarity index 80% rename from Src/Hyperion-kernel/lib/modules/Hyperion/40_pam.kmod rename to Src/Hyperion-kernel/lib/modules/Hyperion/40_auth.kmod index 8a4c0e5..4dbf725 100644 --- a/Src/Hyperion-kernel/lib/modules/Hyperion/40_pam.kmod +++ b/Src/Hyperion-kernel/lib/modules/Hyperion/40_auth.kmod @@ -1,8 +1,22 @@ --:Minify:-- local kernel = ... -local pam = {} -kernel.pam = pam -local loggedIn = {} +local auth = {} +kernel.auth = auth + +-- @SPSF work here + +-- needed + +-- login -- sets the current proccess to the specifyed user id +-- setPassword -- sets the password for specifiyed user id +-- setUsername -- sets +-- newUser -- sets + +-- PASSWD FILE FORMAT +-- uid:gid:username:homedir:shell + +-- SHADOW FILE FORMAT +-- uid:salt:hash local function getFile(path) local file = kernel.vfs.open(path, "r") @@ -13,7 +27,6 @@ local function getFile(path) end local blake2s - do local MOD32 = 2^32 local function norm(x) @@ -187,9 +200,10 @@ end if not blake2s then error("Failed to load blake2s") end if not kernel.vfs.exists("/etc/pam.d/secret") then + kernel.log("PAM SECRET REGENERATING PLEASE USE ROOT") local key = "" for i=1, 256 do - key=key..string.char(math.random(1,255)) + key=key..string.char(math.random(0,255)) end local handle = kernel.vfs.open("/etc/pam.d/secret", "w") kernel.vfs.write(handle, key) @@ -197,41 +211,22 @@ if not kernel.vfs.exists("/etc/pam.d/secret") then end local pepper = getFile("/etc/pam.d/secret") +local passwdFile = getFile("/etc/passwd") +local shadowFile = getFile("/etc/shadow") +local passwdLines = string.split(passwdFile,"\n") +local shadowLines = string.split(shadowFile,"\n") +local passwd,shadow={},{} -function pam.authenticate(username, password) - local fpasswd = getFile("/etc/passwd") - local fshadow = getFile("/etc/shadow") - - local passwdLines = string.split(fpasswd, "\n") - local shadowLines = string.split(fshadow, "\n") - - local passwd = {} - local shadow = {} - for _, line in ipairs(passwdLines) do - local fields = string.split(line, ":") - passwd[fields[1]] = fields - end - for _, line in ipairs(shadowLines) do - local fields = string.split(line, ":") - shadow[fields[1]] = fields - end - - for user, fields in pairs(passwd) do - if user == username then - local shadowPasswd = string.split(shadow[user][2], "$") - local salt = shadowPasswd[2] - local hashedPassword = blake2s(password .. salt, pepper) - if hashedPassword == shadowPasswd[3] then - loggedIn[username] = kernel.newUUID() - return loggedIn[username] - else - return false - end - end - end +for _,v in ipairs(passwdLines) do + passwd[#passwd+1]=string.split(v,":") end -function pam.authToken(username, token) - return loggedIn[username] == token +for _,v in ipairs(shadowLines) do + shadow[#shadow+1]=string.split(v,":") end +for i,v in pairs(passwd) do + kernel.users[tonumber(v[1])]=v[3] +end +kernel.passwd=passwd + diff --git a/Src/Hyperion-kernel/lib/modules/Hyperion/45_hypervisor.kmod b/Src/Hyperion-kernel/lib/modules/Hyperion/45_hypervisor.kmod index e9d9ca7..a976753 100644 --- a/Src/Hyperion-kernel/lib/modules/Hyperion/45_hypervisor.kmod +++ b/Src/Hyperion-kernel/lib/modules/Hyperion/45_hypervisor.kmod @@ -11,15 +11,14 @@ function sys.spawn(func, name, envars, args, tgid) tasks[tostring(id)] = { coro = coroutine.create(function() - local ok, err = xpcall(func, debug.traceback, - table.unpack(args or {})) + local ok, err = xpcall(func, debug.traceback, table.unpack(args or {})) if not ok then if kernel.config.logTaskExit then kernel.log( "Task " .. tostring(id) .. " exited with err: " .. tostring(err), "ERROR", 2) end - tasks[tostring(id)].status = "Z" + if type(err) == "number" then tasks[tostring(id)].exit = err end @@ -34,11 +33,14 @@ function sys.spawn(func, name, envars, args, tgid) " exited without code", "INFO") end end - tasks[tostring(id)].status = "Z" + if type(err) == "number" then tasks[tostring(id)].exit = err end end + for v, _ in ipairs(tasks[tostring(id)].fd) do pcall(kernel.vfs.close,v) end + tasks[tostring(id)].status = "Z" + end), name = name or ("task" .. tostring(id)), envars = envars or kernel.currentTask.envars, @@ -46,7 +48,6 @@ function sys.spawn(func, name, envars, args, tgid) status = "R", pid = id, tgid = tgid or kernel.currentTask.tgid, - username = kernel.username, uid = kernel.uid, fd = {}, sleep = 0, @@ -87,7 +88,7 @@ function sys.getTask(pid) status = task.status, pid = task.pid, tgid = task.tgid, - username = task.username, + username = kernel.users[task.uid], uid = task.uid, exit = task.exit, sleep = task.sleep, @@ -235,7 +236,6 @@ local function reapDeadTasks() for pid, task in pairs(tasks) do if task.status == "Z" and not task.reapTime then kernel.currentTask = task - kernel.username = task.username kernel.uid = task.uid kernel.process = task.name task.coro = nil @@ -250,7 +250,6 @@ local function reapDeadTasks() task.timeSlice = nil task.syscallReturn = nil task.sleep = nil - for v, _ in ipairs(task.fd) do pcall(kernel.vfs.close,v) end task.fd = nil task.reapTime = kernel.computer:time() + 30000 @@ -302,7 +301,6 @@ function kernel.main() end if task.status == "R" then kernel.currentTask = task - kernel.username = task.username kernel.uid = task.uid kernel.process = task.name N = N + 1 diff --git a/Src/Hyperion-kernel/lib/modules/Hyperion/90_init.kmod b/Src/Hyperion-kernel/lib/modules/Hyperion/90_init.kmod index e9dfde3..f4d592d 100644 --- a/Src/Hyperion-kernel/lib/modules/Hyperion/90_init.kmod +++ b/Src/Hyperion-kernel/lib/modules/Hyperion/90_init.kmod @@ -24,7 +24,6 @@ kernel.tasks["1"] = { status = "R", pid = 1, tgid = 1, - username = "root", uid = 0, fd = {}, envars = {},