2 lines
1.4 KiB
Plaintext
2 lines
1.4 KiB
Plaintext
local a={...}local b=a[1]local c=syscall.getuid()local d;if b then d=syscall.getuid()if not d then print("passwd: user '"..b.."' does not exist")syscall.exit(1)return end;if c~=0 and d~=c then print("passwd: permission denied")syscall.exit(1)return end else d=c;b=syscall.getUsername(c)or tostring(c)end;if c~=0 then printInline("Current password: ")local e=""while true do local f=syscall.read(0)if not f or f==""then elseif f=="\n"then syscall.write(1,"\n")break elseif f=="\b"then if#e>0 then e=e:sub(1,-2)syscall.write(1,"\b \b")end else e=e..f;syscall.write(1,"*")end end;local g,h=syscall.login(d,e)if not g then sleep(1)print("passwd: authentication failure")syscall.exit(1)return end end;printInline("New password: ")local i=""while true do local f=syscall.read(0)if not f or f==""then elseif f=="\n"then syscall.write(1,"\n")break elseif f=="\b"then if#i>0 then i=i:sub(1,-2)syscall.write(1,"\b \b")end else i=i..f;syscall.write(1,"*")end end;printInline("Confirm password: ")local j=""while true do local f=syscall.read(0)if not f or f==""then elseif f=="\n"then syscall.write(1,"\n")break elseif f=="\b"then if#j>0 then j=j:sub(1,-2)syscall.write(1,"\b \b")end else j=j..f;syscall.write(1,"*")end end;if i~=j then print("passwd: passwords do not match")syscall.exit(1)return end;local g,h=syscall.setpassword(d,i)if not g then print("passwd: "..tostring(h))syscall.exit(1)return end;print("passwd: password updated for '"..b.."'")
|