25 lines
694 B
Text
25 lines
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
|