local a=require("fs")local b={...}local c="root"local d=1;if b[d]=="-u"then d=d+1;local e=b[d]or"root"local f=tonumber(e)if f then local g=syscall.getpasswd(f)c=g and g.username or e else c=e end;d=d+1 end;local h=b[d]if not h or h==""then print("usage: sudo [-u user] [args...]")syscall.exit(1)return end;local i={}for j=d+1,#b do i[#i+1]=b[j]end;local k=syscall.getuid()local l=syscall.getUsername(k)or tostring(k)local m=syscall.getuidbyname(c)if not m then print("sudo: user '"..c.."' does not exist")syscall.exit(1)return end;if k~=0 then printInline("[sudo] password for root: ")local n=""while true do local o=syscall.read(0)if not o or o==""then elseif o=="\n"then syscall.write(1,"\n")break elseif o=="\b"then if#n>0 then n=n:sub(1,-2)syscall.write(1,"\b \b")end else n=n..o;syscall.write(1,"*")end end;local p,q=syscall.login(0,n)if not p then sleep(1)print("sudo: Authentication failure")syscall.exit(1)return end;if m~=k then syscall.setuid(m)end else if m~=k then syscall.setuid(m)end end;local r=""if h:find("/")then if a.exists(h)then r=h end else local s=string.split(syscall.getEnviron("PATH")or"/bin/",":")for t,u in ipairs(s)do local v=u..h;if a.exists(v)then r=v;break end end end;if r==""then print("sudo: command not found: "..h)syscall.exit(1)return end;local w=a.readAllText(r)local x,y=load(w,"@"..r)if not x then print("sudo: cannot load "..h..": "..tostring(y))syscall.exit(1)return end;local g=syscall.getpasswd(m)if g and g.homedir then syscall.setEnviron("HOME",g.homedir)end;syscall.setEnviron("USER",c)local p,q=xpcall(x,debug.traceback,table.unpack(i))if not p then print("sudo: "..h..": "..tostring(q))syscall.exit(1)end