14 Commits

Author SHA1 Message Date
8762b8f022 Merge pull request '1.2-dev' (#9) from 1.2-dev into main
Reviewed-on: #9
2026-03-11 10:37:44 -04:00
677b2cccec user login fixed 2026-03-11 10:37:13 -04:00
a5e8624368 forgot to edit login 2026-03-11 08:54:47 -04:00
bbda3b3937 fixed elevate VULN 2026-03-11 08:52:41 -04:00
585d39bec2 Merge pull request '1.2-dev' (#8) from 1.2-dev into main
Reviewed-on: #8
2026-03-11 08:23:21 -04:00
b08b14763a i am a we bit stupid (fixed cct bug) 2026-03-11 08:22:53 -04:00
de6696003b fix capitaization part 2 2026-03-11 07:26:38 -04:00
9220281365 fix capitalization part 1 2026-03-11 07:25:52 -04:00
813ddabd9d fixed disk detection i think 2026-03-10 21:13:52 -04:00
5177639d71 Merge pull request 'update build.tar' (#7) from 1.2-dev into main
Reviewed-on: #7
i was dumb
2026-03-10 20:05:26 -04:00
528b4f31bd update build.tar 2026-03-10 20:04:53 -04:00
60162c7c57 Merge pull request '1.2.4' (#6) from 1.2-dev into main
Reviewed-on: #6
2026-03-10 20:02:20 -04:00
18f5c454bb fixed bug where cct drivers are inaccessable 2026-03-10 20:00:21 -04:00
849ecb7dd6 made procfs self 2026-03-10 19:41:54 -04:00
18 changed files with 208 additions and 76 deletions

View File

@@ -6,31 +6,147 @@ local native = apis.peripheral
local peripheral = {} local peripheral = {}
local sides = {"top", "bottom", "left", "right", "front", "back"} local sides = {"top", "bottom", "left", "right", "front", "back"}
function peripheral.getType(name) function peripheral.getNames()
if native.isPresent(name) then return native.getType(name) end local results = {}
for n = 1, #sides do for n = 1, #sides do
local side = sides[n] local side = sides[n]
if native.hasType(side, "peripheral_hub") and if native.isPresent(side) then
native.call(side, "isPresentRemote", name) then table.insert(results, side)
return native.call(side, "getTypeRemote", name) if native.hasType(side, "peripheral_hub") then
local remote = native.call(side, "getNamesRemote")
for _, name in ipairs(remote) do
table.insert(results, name)
end
end
end
end
return results
end
function peripheral.isPresent(name)
if native.isPresent(name) then
return true
end
for n = 1, #sides do
local side = sides[n]
if native.hasType(side, "peripheral_hub") and native.call(side, "isPresentRemote", name) then
return true
end
end
return false
end
function peripheral.getType(peripheral)
if type(peripheral) == "string" then
if native.isPresent(peripheral) then
return native.getType(peripheral)
end
for n = 1, #sides do
local side = sides[n]
if native.hasType(side, "peripheral_hub") and native.call(side, "isPresentRemote", peripheral) then
return native.call(side, "getTypeRemote", peripheral)
end
end
return nil
else
local mt = getmetatable(peripheral)
if not mt or mt.__name ~= "peripheral" or type(mt.types) ~= "table" then
error("bad argument #1 (table is not a peripheral)", 2)
end
return table.unpack(mt.types)
end
end
function peripheral.hasType(peripheral, peripheral_type)
if type(peripheral) == "string" then
if native.isPresent(peripheral) then
return native.hasType(peripheral, peripheral_type)
end
for n = 1, #sides do
local side = sides[n]
if native.hasType(side, "peripheral_hub") and native.call(side, "isPresentRemote", peripheral) then
return native.call(side, "hasTypeRemote", peripheral, peripheral_type)
end
end
return nil
else
local mt = getmetatable(peripheral)
if not mt or mt.__name ~= "peripheral" or type(mt.types) ~= "table" then
error("bad argument #1 (table is not a peripheral)", 2)
end
return mt.types[peripheral_type] ~= nil
end
end
function peripheral.getMethods(name)
if native.isPresent(name) then
return native.getMethods(name)
end
for n = 1, #sides do
local side = sides[n]
if native.hasType(side, "peripheral_hub") and native.call(side, "isPresentRemote", name) then
return native.call(side, "getMethodsRemote", name)
end end
end end
return nil return nil
end end
function peripheral.getNames() function peripheral.getName(peripheral)
local names = {} local mt = getmetatable(peripheral)
if not mt or mt.__name ~= "peripheral" or type(mt.name) ~= "string" then
error("bad argument #1 (table is not a peripheral)", 2)
end
return mt.name
end
function peripheral.call(name, method, ...)
if native.isPresent(name) then
return native.call(name, method, ...)
end
for n = 1, #sides do for n = 1, #sides do
local side = sides[n] local side = sides[n]
if native.isPresent(side) then table.insert(names, side) end if native.hasType(side, "peripheral_hub") and native.call(side, "isPresentRemote", name) then
if native.hasType(side, "peripheral_hub") then return native.call(side, "callRemote", name, method, ...)
local hubSides = native.call(side, "getConnectedSides") end
for _, hubSide in ipairs(hubSides) do end
table.insert(names, hubSide) return nil
end
function peripheral.wrap(name)
local methods = peripheral.getMethods(name)
if not methods then
return nil
end
local types = { peripheral.getType(name) }
for i = 1, #types do types[types[i]] = true end
local result = setmetatable({}, {
__name = "peripheral",
name = name,
type = types[1],
types = types,
})
for _, method in ipairs(methods) do
result[method] = function(...)
return peripheral.call(name, method, ...)
end
end
return result
end
function peripheral.find(ty, filter)
local results = {}
for _, name in ipairs(peripheral.getNames()) do
if peripheral.hasType(name, ty) then
local wrapped = peripheral.wrap(name)
if filter == nil or filter(name, wrapped) then
table.insert(results, wrapped)
end end
end end
end end
return names return table.unpack(results)
end end
local disks = {} local disks = {}
@@ -130,14 +246,9 @@ local function refresh()
if not peripheral.getType(id) then disks[id] = nil end if not peripheral.getType(id) then disks[id] = nil end
end end
for _, name in ipairs(peripheral.getNames()) do for _, disk in ipairs({peripheral.find("drive")}) do
if peripheral.getType(name) == "disk" then if disk.isDiskPresent() then
if not disks[name] then disks[tostring(disk.getDiskID())]=createDisk("cctdisk"..tostring(disk.getDiskID()), disk.getMountPath(), false, fs)
local mount = disk.getMountPath(name)
if mount then
disks[name] = createDisk(name, mount, false, disk)
end
end
end end
end end
end end

View File

@@ -1,26 +0,0 @@
local args={...}
local kernel=args[1]
local driver={}
driver.name="CCT Term Module"
driver.version="0.1.0"
driver.type="gpio"
driver.description="CCT redstone Module Kernel Module"
driver.arch="cct"
driver.author="HyperionOS Dev Team"
driver.license="MIT"
driver.api={}
function driver.load()
-- will
end
function driver.unload()
-- Nothing to unload
end
function driver.main()
-- Nothing to run
end
-- kernel.drivers.register(driver)

View File

@@ -1,4 +1,5 @@
--:Minify:-- --:Minify:--
local kernel = ... local kernel = ...
local apis = kernel.apis local apis = kernel.apis
local native = apis.peripheral local native = apis.peripheral

View File

@@ -132,6 +132,17 @@ function proxy:open(path, mode)
if type(step[steps[#steps]]) == "function" then if type(step[steps[#steps]]) == "function" then
return step[steps[#steps]]("open", mode) return step[steps[#steps]]("open", mode)
end end
elseif tostring(steps[1])=="self" then
local task=kernel.currentTask
local step = newtaskproxy(task)
for i=2, #steps-1 do
local dat = step[steps[i]]
if type(dat) ~= "table" then error("ENFILE") end
step=dat
end
if type(step[steps[#steps]]) == "function" then
return step[steps[#steps]]("open", mode)
end
else else
for i=1, #steps-1 do for i=1, #steps-1 do
local dat = step[steps[i]] local dat = step[steps[i]]
@@ -166,6 +177,21 @@ function proxy:type(path, mode)
if type(step[steps[#steps]]) == "table" then if type(step[steps[#steps]]) == "table" then
return "directory" return "directory"
end end
elseif tostring(steps[1])=="self" then
local task=kernel.currentTask
if #steps==1 then return "directory" end
local step = newtaskproxy(task)
for i=2, #steps-1 do
local dat = step[steps[i]]
if type(dat) ~= "table" then error("ENFILE") end
step=dat
end
if type(step[steps[#steps]]) == "function" then
return step[steps[#steps]]("type", mode)
end
if type(step[steps[#steps]]) == "table" then
return "directory"
end
else else
for i=1, #steps-1 do for i=1, #steps-1 do
local dat = step[steps[i]] local dat = step[steps[i]]
@@ -186,7 +212,7 @@ function proxy:list(path)
local steps = kernel.vfs.splitPath(path) local steps = kernel.vfs.splitPath(path)
local step = data local step = data
if #steps == 0 then if #steps == 0 then
return table.merge(table.keys(data),table.keys(kernel.tasks)) return table.merge(table.keys(data),table.keys(kernel.tasks),{"self"})
end end
if tonumber(steps[1]) then if tonumber(steps[1]) then
local task=kernel.tasks[steps[1]] local task=kernel.tasks[steps[1]]
@@ -200,6 +226,18 @@ function proxy:list(path)
if type(step[steps[#steps]]) == "table" then if type(step[steps[#steps]]) == "table" then
return table.keys(step[steps[#steps]]) return table.keys(step[steps[#steps]])
end end
elseif tostring(steps[1])=="self" then
local task=kernel.currentTask
local step = newtaskproxy(task)
if #steps==1 then return table.keys(step) end
for i=2, #steps-1 do
local dat = step[steps[i]]
if type(dat) ~= "table" then error("ENOENT") end
step=dat
end
if type(step[steps[#steps]]) == "table" then
return table.keys(step[steps[#steps]])
end
else else
for i=1, #steps-1 do for i=1, #steps-1 do
local dat = step[steps[i]] local dat = step[steps[i]]

View File

@@ -236,19 +236,18 @@ local function nextUID()
return max + 1 return max + 1
end end
function auth.login(username, password) function auth.login(uid, password)
if type(username) ~= "string" or type(password) ~= "string" then if type(uid) ~= "number" or type(password) ~= "string" then
return nil, "Authentication failure" return nil, "Authentication failure"
end end
local entry = getPasswdByUsername(username) local entry = getPasswdByUID(uid)
if not entry then if not entry then
-- timing attack resistance -- timing attack resistance
hashPassword(password, "aaaaaaaaaaaaaaaa") hashPassword(password, "aaaaaaaaaaaaaaaa")
return nil, "Authentication failure" return nil, "Authentication failure"
end end
local uid = tonumber(entry[1])
local sEntry = getShadowByUID(uid) local sEntry = getShadowByUID(uid)
if not sEntry then if not sEntry then
hashPassword(password, "aaaaaaaaaaaaaaaa") hashPassword(password, "aaaaaaaaaaaaaaaa")
@@ -273,7 +272,7 @@ function auth.login(username, password)
_task.egid = tonumber(entry[2]) or uid _task.egid = tonumber(entry[2]) or uid
end end
kernel.log("AUTH: login uid=" .. tostring(uid) .. " (" .. username .. ")") kernel.log("AUTH: login uid=" .. tostring(uid) .. " (" .. getPasswdByUID(uid)[3] .. ")")
return true return true
end end

View File

@@ -96,8 +96,8 @@ if kernel.firstBoot then
{"sbin", REG, 0, 0, RWX_RX_RX}, {"sbin", REG, 0, 0, RWX_RX_RX},
{"tmp", REG, 0, 0, RWXRWXRWX}, {"tmp", REG, 0, 0, RWXRWXRWX},
{"usr", REG, 0, 0, RWX_RX_RX}, {"usr", REG, 0, 0, RWX_RX_RX},
{"var", REG, 0, 0, RWX_RX_RX}, {"var", REG, 0, 0, RWXRWXRWX},
{"opt", REG, 0, 0, RWXRWXRWX}, {"opt", REG, 0, 0, RWX_RX_RX},
}) })
mergeMeta("/bin", { mergeMeta("/bin", {

View File

@@ -130,8 +130,9 @@ local function doLogin()
syscall.write(1, "Password: ") syscall.write(1, "Password: ")
local password = readLine("*") local password = readLine("*")
local uid = syscall.getuidbyname(username)
local ok, err = syscall.login(username, password) local ok, err = syscall.login(uid, password)
if ok then if ok then
local uid = syscall.getuid() local uid = syscall.getuid()
local pwent = syscall.getpasswd(uid) local pwent = syscall.getpasswd(uid)

View File

@@ -9,7 +9,7 @@ local currentUid = syscall.getuid()
local targetUid local targetUid
if targetName then if targetName then
targetUid = syscall.getuid(targetName) targetUid = syscall.getuid()
if not targetUid then if not targetUid then
print("passwd: user '" .. targetName .. "' does not exist") print("passwd: user '" .. targetName .. "' does not exist")
syscall.exit(1); return syscall.exit(1); return
@@ -36,7 +36,7 @@ if currentUid ~= 0 then
if #cur > 0 then cur=cur:sub(1,-2); syscall.write(1,"\b \b") end if #cur > 0 then cur=cur:sub(1,-2); syscall.write(1,"\b \b") end
else cur=cur..ch; syscall.write(1,"*") end else cur=cur..ch; syscall.write(1,"*") end
end end
local ok, err = syscall.elevate(targetName, cur) local ok, err = syscall.login(targetUid, cur)
if not ok then if not ok then
sleep(1) sleep(1)
print("passwd: authentication failure") print("passwd: authentication failure")

View File

@@ -1,7 +1,12 @@
--:Minify:-- --:Minify:--
local targetUser = ({ ... })[1] or "root" local targetUser = ({ ... })[1]
local currentUid = syscall.getuid() local currentUid = syscall.getuid()
local targetUid = syscall.getuidbyname(targetUser) local targetUid
if targetUser then
targetUid = syscall.getuidbyname(targetUser)
else
targetUid = 0
end
if not targetUid then if not targetUid then
print("su: user '" .. targetUser .. "' does not exist") print("su: user '" .. targetUser .. "' does not exist")
@@ -25,20 +30,21 @@ if currentUid ~= 0 then
end end
end end
local ok, err = syscall.elevate(targetUser, pw) local ok, err = syscall.login(targetUid, pw)
if not ok then if not ok then
sleep(1) sleep(1)
print("su: Authentication failure") print("su: Authentication failure")
syscall.exit(1) syscall.exit(1)
return return
end end
else
syscall.setuid(targetUid)
end end
syscall.setuid(targetUid)
local pwent = syscall.getpasswd(targetUid) local pwent = syscall.getpasswd(targetUid)
local shell = (pwent and pwent.shell) or "/bin/hysh" local shell = (pwent and pwent.shell) or "/bin/hysh"
local homedir = (pwent and pwent.homedir) or "/" local homedir = (pwent and pwent.homedir) or "/"
local username= (pwent and pwent.username)or "Unknown"
local ok_cd, err_cd = pcall(syscall.chdir, homedir) local ok_cd, err_cd = pcall(syscall.chdir, homedir)
if not ok_cd then if not ok_cd then
@@ -46,7 +52,7 @@ if not ok_cd then
syscall.chdir(homedir) syscall.chdir(homedir)
end end
syscall.setEnviron("HOME", homedir) syscall.setEnviron("HOME", homedir)
syscall.setEnviron("USER", targetUser) syscall.setEnviron("USER", username)
syscall.setEnviron("SHELL", shell) syscall.setEnviron("SHELL", shell)
local ok, err = pcall(syscall.exec, shell) local ok, err = pcall(syscall.exec, shell)

View File

@@ -55,7 +55,7 @@ if currentUid ~= 0 then
end end
end end
local ok, err = syscall.elevate("root", pw) local ok, err = syscall.login(0, pw)
if not ok then if not ok then
sleep(1) sleep(1)
print("sudo: Authentication failure") print("sudo: Authentication failure")

Binary file not shown.

View File

@@ -3,6 +3,8 @@
--- @diagnostic disable: duplicate-set-field --- @diagnostic disable: duplicate-set-field
syscall={} syscall={}
--- @alias userinfo {username:string,homedir:string,shell:string,uid:number,gid:number}
--- Sets home directory of User with corresponding uid to homedir --- Sets home directory of User with corresponding uid to homedir
--- @param uid integer --- @param uid integer
--- @param homedir string --- @param homedir string
@@ -164,7 +166,7 @@ syscall.setpassword=function(uid, newPassword) end
--- Set environment variable --- Set environment variable
--- @param key string --- @param key string
--- @param value string --- @param value any
--- @return boolean --- @return boolean
syscall.setEnviron=function(key, value) end syscall.setEnviron=function(key, value) end
@@ -197,7 +199,7 @@ syscall.exit=function(code) end
--- Get environment variable --- Get environment variable
--- @param key string --- @param key string
--- @return string|nil --- @return any
syscall.getEnviron=function(key) end syscall.getEnviron=function(key) end
--- Continue a stopped task --- Continue a stopped task
@@ -337,7 +339,7 @@ syscall.remove=function(path) end
--- @return string|nil --- @return string|nil
syscall.type=function(path) end syscall.type=function(path) end
--- Elevate to another user with password --- Elevate to root with password (Disabled due to VULN)
--- @param targetUsername string --- @param targetUsername string
--- @param password string --- @param password string
--- @return boolean --- @return boolean
@@ -374,11 +376,11 @@ syscall.setusername=function(uid, newUsername) end
--- @return integer --- @return integer
syscall.geteuid=function() end syscall.geteuid=function() end
--- Login user --- Login as user
--- @param username string --- @param uid integer
--- @param password string --- @param password string
--- @return boolean --- @return boolean
syscall.login=function(username, password) end syscall.login=function(uid, password) end
--- Get system hostname --- Get system hostname
--- @return string --- @return string
@@ -514,9 +516,9 @@ syscall.access=function(path, mode) end
--- Ignore current signal --- Ignore current signal
syscall.sigignore=function() end syscall.sigignore=function() end
--- Get user password hash --- Get user information
--- @param uid integer --- @param uid integer
--- @return string|nil --- @return userinfo|nil
syscall.getpasswd=function(uid) end syscall.getpasswd=function(uid) end
--- Get OS version --- Get OS version