local a=({...})[1]or"root"local b=syscall.getuid()local c=syscall.getuidbyname(a)if not c then print("su: user '"..a.."' does not exist")syscall.exit(1)return end;if b~=0 then printInline("Password: ")local d=""while true do local e=syscall.read(0)if not e or e==""then elseif e=="\n"then syscall.write(1,"\n")break elseif e=="\b"then if#d>0 then d=d:sub(1,-2)syscall.write(1,"\b \b")end else d=d..e;syscall.write(1,"*")end end;local f,g=syscall.elevate(a,d)if not f then sleep(1)print("su: Authentication failure")syscall.exit(1)return end end;syscall.setuid(c)local h=syscall.getpasswd(c)local i=h and h.shell or"/bin/hysh"local j=h and h.homedir or"/"local k,l=pcall(syscall.chdir,j)if not k then j="/"syscall.chdir(j)end;syscall.setEnviron("HOME",j)syscall.setEnviron("USER",a)syscall.setEnviron("SHELL",i)local f,g=pcall(syscall.exec,i)if not f then print("su: cannot exec shell '"..i.."': "..tostring(g))syscall.exit(1)end
