27 lines
617 B
Text
27 lines
617 B
Text
|
local tArgs = { ... }
|
||
|
|
||
|
if #tArgs < 1 then
|
||
|
kerneldraw.printAppInfo( "userdel", "Specify a user" )
|
||
|
return
|
||
|
end
|
||
|
|
||
|
if not security.getSU() or tArgs[1] == "root" then
|
||
|
exception.throw("RestrictedOpsException")
|
||
|
return
|
||
|
end
|
||
|
|
||
|
local pathA = "/etc/passwd/"..tArgs[1]..".dat"
|
||
|
local pathB = "/etc/passwd/.shadow/"..tArgs[1]..".usr"
|
||
|
local pathC = "/home/"..tArgs[1]
|
||
|
|
||
|
if fs.exists(pathA) then
|
||
|
if kerneldraw.request("remove user record") then
|
||
|
fs.delete( pathA )
|
||
|
if fs.exists(pathB) then
|
||
|
fs.delete( pathB )
|
||
|
end
|
||
|
fs.delete( pathC )
|
||
|
end
|
||
|
else
|
||
|
kerneldraw.printAppInfo("userdel", "User " .. tArgs[1] .. " does not exist")
|
||
|
end
|