This repository has been archived on 2024-04-19. You can view files and clone it, but cannot push or open issues or pull requests.
FREAX/bin/useradd
2022-07-18 19:33:40 +02:00

25 lines
No EOL
694 B
Text

local tArgs = {...}
if #tArgs < 2 then
kerneldraw.printAppInfo("useradd", "Specify a user")
return
end
if fs.exists("/etc/passwd/"..tArgs[1]..".dat") and not fs.isDir("/etc/passwd/"..tArgs[1]..".dat") then
kerneldraw.printAppInfo("useradd", "User already exists")
return
end
if not security.getSU() then
exception.throw("RestrictedOpsException")
return
end
if security.passbyte(tArgs[1], tArgs[2]) then
kerneldraw.printAppSuccess("useradd", "User "..tArgs[1].." added")
log.writeSecurity("User "..tArgs[1].." added")
fs.makeDir("/home/"..tArgs[1])
else
kerneldraw.printAppInfo("useradd", "Failed to add user " .. tArgs[1])
log.writeSecurity("Failed to add user " .. tArgs[1])
end