made newer installer that does not require tar stuff
This commit is contained in:
1
prod/hysh/bin/chattr
Normal file
1
prod/hysh/bin/chattr
Normal file
@@ -0,0 +1 @@
|
||||
local a=syscall.getTask(syscall.getpid()).name;local b={R=false,help=false}local c={}local d=nil;for e,f in ipairs({...})do if f:sub(1,2)=="--"then local g=f:sub(3)if b[g]==nil then print(a..": unrecognized option '"..f.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;b[g]=true elseif f:sub(1,1)=="-"and not f:match("^%-[%+%-]")then local h=true;for i=2,#f do local j=f:sub(i,i)if b[j]~=nil then b[j]=true else h=false;break end end;if not h then d=f end elseif f:sub(1,1)=="+"or f:sub(1,1)=="-"and f:match("^%-[a-zA-Z]")then d=f else table.insert(c,f)end end;if b.help then print("Usage: "..a.." [OPTION]... +-= ATTRS FILE...")print("Change file attributes on a filesystem.")print("")print("Attributes:")print(" i immutable: file cannot be modified, renamed, or deleted")print(" a append-only: file can only be appended to")print("")print("Operators: +attr add, -attr remove")print("Example: "..a.." +i /etc/passwd")print("")print("Options:")print(" -R operate on files and directories recursively")print(" --help display this help and exit")return end;if not d or#c<1 then print(a..": missing operand")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local k=d:sub(1,1)local l=d:sub(2)if k~="+"and k~="-"then print(a..": invalid operator '"..k.."' (use + or -)")syscall.exit(1)return end;local function m(n)local o=pcall(function()return syscall.stat(n)end)and syscall.stat(n)if o then return o.xattr or""end;return""end;local p="|i"local q="|a"local function r(j)if j=="i"then return p elseif j=="a"then return q else return nil end end;local function s(n)local o=syscall.stat(n)if not o then print(a..": cannot stat '"..n.."': No such file or directory")return false end;if o.etype==0x01 then return true end;if not syscall.setxattr then print(a..": kernel does not expose setxattr syscall; cannot modify attributes")syscall.exit(1)return false end;local t=o.xattr or""for i=1,#l do local j=l:sub(i,i)local u=r(j)if not u then print(a..": unsupported attribute '"..j.."'")syscall.exit(1)return false end;local v=t:find(u,1,true)if k=="+"and not v then t=t..u elseif k=="-"and v then t=t:gsub(u:gsub("|","%%|"),"")end end;local w,x=pcall(syscall.setxattr,n,t)if not w then print(a..": cannot set attributes on '"..n.."': "..tostring(x))return false end;return true end;local function y(n)if not s(n)then return end;if syscall.type(n)=="directory"then local w,z=pcall(syscall.listdir,n)if w then for e,A in ipairs(z)do local B=n;if B:sub(-1)~="/"then B=B.."/"end;y(B..A)end end end end;local C=syscall.getcwd()local function D(E)if E:sub(1,1)~="/"then E=C.."/"..E end;return E end;if not syscall.setxattr then print(a..": kernel does not expose setxattr; attributes cannot be persisted")print(a..": add sys[\"setxattr\"] = vfs.setxattr to 10_vfs.kmod to enable this")syscall.exit(1)return end;local F=0;for i=1,#c do local n=D(c[i])if not syscall.exists(n)then print(a..": cannot access '"..c[i].."': No such file or directory")F=1 elseif b.R then y(n)else if not s(n)then F=1 end end end;syscall.exit(F)
|
||||
1
prod/hysh/bin/chgrp
Normal file
1
prod/hysh/bin/chgrp
Normal file
@@ -0,0 +1 @@
|
||||
local a=syscall.getTask(syscall.getpid()).name;local b={R=false,help=false}local c={}for d,e in ipairs({...})do if e:sub(1,2)=="--"then local f=e:sub(3)if b[f]==nil then print(a..": unrecognized option '"..e.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;b[f]=true elseif e:sub(1,1)=="-"then for g=2,#e do local f=e:sub(g,g)if b[f]==nil then print(a..": invalid option '-"..f.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;b[f]=true end else table.insert(c,e)end end;if b.help then print("Usage: "..a.." [OPTION]... GROUP FILE...")print("Change the group of each FILE to GROUP.")print("GROUP may be a group name or numeric ID.")print("")print("Options:")print(" -R operate on files and directories recursively")print(" --help display this help and exit")return end;if#c<2 then print(a..": missing operand")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local h=c[1]local function i(j)local k=tonumber(j)if k then return k end;local l=syscall.getuidbyname and syscall.getuidbyname(j)if l then local m=syscall.getpasswd(l)if m then return m.gid end end;print(a..": invalid group: '"..j.."'")syscall.exit(1)end;local n=i(h)local function o(p)local q=syscall.stat(p)if not q then print(a..": cannot stat '"..p.."': no such file or directory")return false end;local r,s=pcall(syscall.chown,p,q.owner,n)if not r then local t=tostring(s)if t:find("EPERM")or t:find("EACCES")then t="operation not permitted (must be root)"elseif t:find("ENOENT")then t="no such file or directory"end;print(a..": cannot change group of '"..p.."': "..t)return false end;return true end;local function u(p)if not o(p)then return end;if syscall.type(p)=="directory"then local r,v=pcall(syscall.listdir,p)if r then for d,w in ipairs(v)do local x=p;if x:sub(-1)~="/"then x=x.."/"end;u(x..w)end end end end;local y=syscall.getcwd()local function z(A)if A:sub(1,1)~="/"then A=y.."/"..A end;return A end;local B=0;for g=2,#c do local p=z(c[g])if not syscall.exists(p)then print(a..": cannot access '"..c[g].."': No such file or directory")B=1 elseif b.R then u(p)else if not o(p)then B=1 end end end;syscall.exit(B)
|
||||
1
prod/hysh/bin/chmod
Normal file
1
prod/hysh/bin/chmod
Normal file
File diff suppressed because one or more lines are too long
1
prod/hysh/bin/chown
Normal file
1
prod/hysh/bin/chown
Normal file
@@ -0,0 +1 @@
|
||||
local a=syscall.getTask(syscall.getpid()).name;local b={R=false,help=false}local c={}for d,e in ipairs({...})do if e:sub(1,2)=="--"then local f=e:sub(3)if b[f]==nil then print(a..": unrecognized option '"..e.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;b[f]=true elseif e:sub(1,1)=="-"then for g=2,#e do local f=e:sub(g,g)if b[f]==nil then print(a..": invalid option '-"..f.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;b[f]=true end else table.insert(c,e)end end;if b.help then print("Usage: "..a.." [OPTION]... OWNER[:GROUP] FILE...")print(" "..a.." [OPTION]... :GROUP FILE...")print("Change the owner and/or group of each FILE.")print("OWNER and GROUP may be names or numeric IDs.")print("")print("Options:")print(" -R operate on files and directories recursively")print(" --help display this help and exit")return end;if#c<2 then print(a..": missing operand")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local h=c[1]local i,j;if h:sub(1,1)==":"then j=h:sub(2)else local k=h:find(":",1,true)if k then i=h:sub(1,k-1)j=h:sub(k+1)if j==""then j=nil end else i=h end end;local function l(m)if not m or m==""then return nil end;local n=tonumber(m)if n then return n end;local o=syscall.getuidbyname and syscall.getuidbyname(m)if o then return o end;print(a..": invalid user: '"..m.."'")syscall.exit(1)end;local function p(m)if not m or m==""then return nil end;local n=tonumber(m)if n then return n end;local o=syscall.getuidbyname and syscall.getuidbyname(m)if o then local q=syscall.getpasswd(o)if q then return q.gid end end;print(a..": invalid group: '"..m.."'")syscall.exit(1)end;local r=l(i)local s=p(j)if r==nil and s==nil then print(a..": no owner or group specified")syscall.exit(1)return end;local function t(u)local v=syscall.stat(u)if not v then print(a..": cannot stat '"..u.."': no such file or directory")return false end;local o=r~=nil and r or v.owner;local w=s~=nil and s or v.group;local x,y=pcall(syscall.chown,u,o,w)if not x then local z=tostring(y)if z:find("EPERM")or z:find("EACCES")then z="operation not permitted (must be root)"elseif z:find("ENOENT")then z="no such file or directory"end;print(a..": cannot change owner of '"..u.."': "..z)return false end;return true end;local function A(u)if not t(u)then return end;if syscall.type(u)=="directory"then local x,B=pcall(syscall.listdir,u)if x then for d,C in ipairs(B)do local D=u;if D:sub(-1)~="/"then D=D.."/"end;A(D..C)end end end end;local E=syscall.getcwd()local function F(G)if G:sub(1,1)~="/"then G=E.."/"..G end;return G end;local H=0;for g=2,#c do local u=F(c[g])if not syscall.exists(u)then print(a..": cannot access '"..c[g].."': No such file or directory")H=1 elseif b.R then A(u)else if not t(u)then H=1 end end end;syscall.exit(H)
|
||||
1
prod/hysh/bin/chroot
Normal file
1
prod/hysh/bin/chroot
Normal file
@@ -0,0 +1 @@
|
||||
local a=syscall.getTask(syscall.getpid()).name;local b={}local c={help=false}for d,e in ipairs({...})do if e:sub(1,2)=="--"then local f=e:sub(3)if f=="help"then c.help=true else print(a..": unrecognized option '"..e.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end elseif e:sub(1,1)=="-"then print(a..": invalid option '"..e.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return else table.insert(b,e)end end;if c.help then print("Usage: "..a.." NEWROOT [COMMAND [ARG]...]")print("Run COMMAND with root directory set to NEWROOT.")print("If COMMAND is omitted, runs the current user's shell.")print("")print("Requires root (uid 0).")return end;if#b<1 then print(a..": missing operand")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local g=syscall.geteuid and syscall.geteuid()or syscall.getuid()if g~=0 then print(a..": cannot change root directory: Permission denied")syscall.exit(1)return end;local h=b[1]if h:sub(1,1)~="/"then h=syscall.getcwd().."/"..h end;if not syscall.exists(h)then print(a..": cannot change root directory to '"..b[1].."': No such file or directory")syscall.exit(1)return end;if syscall.type(h)~="directory"then print(a..": '"..b[1].."': Not a directory")syscall.exit(1)return end;local i,j=pcall(syscall.chroot,h)if not i then print(a..": cannot change root directory to '"..b[1].."': "..tostring(j))syscall.exit(1)return end;local k;if#b>=2 then k=b[2]else local l=syscall.getuid()local m=syscall.getpasswd(l)k=m and m.shell or"/bin/hysh"end;local n={}for o=3,#b do table.insert(n,b[o])end;local p,q=pcall(syscall.exec,k,n)if not p then print(a..": failed to run command '"..k.."': "..tostring(q))syscall.exit(127)end
|
||||
1
prod/hysh/bin/help
Normal file
1
prod/hysh/bin/help
Normal file
File diff suppressed because one or more lines are too long
1
prod/hysh/bin/hfetch
Normal file
1
prod/hysh/bin/hfetch
Normal file
@@ -0,0 +1 @@
|
||||
local a=0x00FFFF;local b=0xFFFFFF;local c=0xDBDBDB;local d=0x6D6D6D;local e=0x00FF00;local function f(g)syscall.devctl(1,"sfgc",g)end;local h=syscall.getUsername()or"Unknown"local i=syscall.getHostname()or"Unknown"local j=h.."@"..i;local function k(l)local m=math.floor(l/1000)local n=math.floor(m/60)local o=math.floor(n/60)local p=math.floor(o/24)m=m%60;n=n%60;o=o%24;local q={}if p>0 then q[#q+1]=p.."d"end;if o>0 then q[#q+1]=o.."h"end;if n>0 then q[#q+1]=n.."m"end;q[#q+1]=m.."s"return table.concat(q," ")end;local r=syscall.getHost()or"Unknown"local s=r:match("ComputerCraft ([%d%.]+)")or r;local t={{nil,j},{nil,string.rep("-",#j)},{"OS",syscall.version()or"Unknown"},{"Host",s},{"Arch",syscall.arch()or"Unknown"},{"Uptime",k(syscall.getUptime()or 0)},{"Tasks",tostring(#(syscall.getTasks()or{}))},{"Shell",syscall.getEnviron("SHELL")or"Unknown"},{"Terminal","tty1"},{"UID",tostring(syscall.getuid())},{"Packages","n/a (spm)"}}local u={".. *. .. "," *= +@* +* "," .@#. -@@@= :#@. "," =@@+ *@@@# +@@= "," %@@%: *@@@# -%@@% "," :@@@@+ *@@@# .*@@@@: "," :*@@@%- *@@@# -@@@@*: "," =%@@#. *@@@# .#@@%= "," :=. :*@@= *@@@# =@@+: .=: "," %@#=..*# +@@@# #*..=#@# "," .@@@@+=# .%@%: #=+@@@@. "," .....=# -@= *+...:. "," -*%*-@= - =@-*%*- "," -@*. -@%. :%@- :*@- "," .#@#@* "," -#- "," "}local v=math.max(#u,#t)for w=1,v do local x=u[w]or string.rep(" ",36)f(a)printInline(x)f(c)printInline("| ")local y=t[w]if y then if y[1]==nil and w==1 then f(e)printInline(y[2])elseif y[1]==nil and w==2 then f(d)printInline(y[2])elseif y[1]then f(c)printInline(y[1]..": ")f(b)printInline(y[2])end end;f(b)print("")end
|
||||
1
prod/hysh/bin/hysh
Normal file
1
prod/hysh/bin/hysh
Normal file
File diff suppressed because one or more lines are too long
1
prod/hysh/bin/id
Normal file
1
prod/hysh/bin/id
Normal file
@@ -0,0 +1 @@
|
||||
local a={...}local b;if a[1]then b=syscall.getuid(a[1])if not b then print("id: user '"..a[1].."' does not exist")syscall.exit(1)return end else b=syscall.getuid()end;local c=syscall.getpasswd(b)local d=c and c.username or tostring(b)local e=c and c.gid or b;print(string.format("uid=%d(%s) gid=%d(%s)",b,d,e,d))
|
||||
3
prod/hysh/bin/ll
Normal file
3
prod/hysh/bin/ll
Normal file
@@ -0,0 +1,3 @@
|
||||
local args={...}
|
||||
table.insert(args, "-lah")
|
||||
syscall.exec("/bin/ls", args)
|
||||
1
prod/hysh/bin/ln
Normal file
1
prod/hysh/bin/ln
Normal file
@@ -0,0 +1 @@
|
||||
local a=syscall.getTask(syscall.getpid()).name;local b={s=false,f=false,help=false}local c={}for d,e in ipairs({...})do if e:sub(1,2)=="--"then local f=e:sub(3)if b[f]==nil then print(a..": unrecognized option '"..e.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;b[f]=true elseif e:sub(1,1)=="-"then for g=2,#e do local f=e:sub(g,g)if b[f]==nil then print(a..": invalid option '-"..f.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;b[f]=true end else table.insert(c,e)end end;if b.help then print("Usage: "..a.." [OPTION]... TARGET LINK_NAME")print(" "..a.." [OPTION]... TARGET... DIRECTORY")print("Create links between files.")print("")print("Options:")print(" -s make symbolic links instead of hard links")print(" -f remove existing destination files")print(" --help display this help and exit")print("")print("With no -s, hard links are not supported (filesystem limitation).")print("Use -s for symbolic links.")return end;if#c<2 then print(a..": missing operand")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;if not b.s then print(a..": hard links are not supported; use -s for symbolic links")syscall.exit(1)return end;local h=c[#c]local i=syscall.type(h)=="directory"local function j()local k=syscall.getcwd()if k:sub(-1)~="/"then k=k.."/"end;return k end;local function l(m)if m:sub(1,1)~="/"then m=j()..m end;return m end;for g=1,#c-1 do local n=c[g]local o;if i then local p=n:match("[^/]+$")or n;o=l(h)if o:sub(-1)~="/"then o=o.."/"end;o=o..p else o=l(h)end;if b.f and syscall.exists(o)then local q,r=pcall(syscall.remove,o)if not q then print(a..": cannot remove '"..o.."': "..tostring(r))syscall.exit(1)return end end;local q,r=pcall(syscall.symlink,n,o)if not q then print(a..": failed to create symlink '"..o.."' -> '"..n.."': "..tostring(r))syscall.exit(1)return end end
|
||||
1
prod/hysh/bin/login
Normal file
1
prod/hysh/bin/login
Normal file
@@ -0,0 +1 @@
|
||||
syscall.open("/dev/tty/1","r")syscall.open("/dev/tty/1","w")syscall.open("/dev/null","w")local a=3;local function b(c)local d=""while true do local e=syscall.read(0)if not e or e==""then elseif e=="\n"then syscall.write(1,"\n")return d 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,c or e)end end end;local function f()local g=""local h,i=pcall(function()local j=syscall.open("/etc/shadow","r")g=syscall.read(j,65535)or""syscall.close(j)end)if g:match("%S")then return end;syscall.devctl(1,"clear")syscall.devctl(1,"spos",1,1)syscall.devctl(1,"sfgc",0x00FF00)syscall.write(1,"HyperionOS First Boot Setup\n")syscall.devctl(1,"sfgc",0xFFFFFF)syscall.write(1,"No root password is set. Please create one now.\n\n")while true do syscall.write(1,"New root password: ")local k=b("*")syscall.write(1,"Confirm password: ")local l=b("*")if k~=l then syscall.devctl(1,"sfgc",0xFF0000)syscall.write(1,"Passwords do not match. Try again.\n\n")syscall.devctl(1,"sfgc",0xFFFFFF)elseif#k<6 then syscall.devctl(1,"sfgc",0xFF0000)syscall.write(1,"Password too short (minimum 6 characters).\n\n")syscall.devctl(1,"sfgc",0xFFFFFF)else local m,n=syscall.setpassword(0,k)if m then syscall.devctl(1,"sfgc",0x00FF00)syscall.write(1,"Root password set.\n\n")syscall.devctl(1,"sfgc",0xFFFFFF)sleep(0.5)break else syscall.devctl(1,"sfgc",0xFF0000)syscall.write(1,"Error: "..tostring(n).."\n")syscall.devctl(1,"sfgc",0xFFFFFF)end end end end;local function o(p,q,r,s)local t,u=pcall(syscall.exists,r)if not t or not u then syscall.write(1,"login: shell not found: "..r.."\n")sleep(2)return false end;local v,w=pcall(syscall.access,r,"rx")syscall.setEnviron("HOME",s)syscall.setEnviron("USER",p)syscall.setEnviron("SHELL",r)syscall.setEnviron("PATH","/bin/")local x,y=pcall(syscall.setuid,q)if not x then syscall.write(1,"login: setuid failed: "..tostring(y).."\n")sleep(2)return false end;local z,A=pcall(syscall.chdir,s)if not z then pcall(syscall.chdir,"/")end;local m,n=pcall(syscall.execspawn,r,p..":shell")if not m then syscall.write(1,"login: failed to launch shell: "..tostring(n).."\n")sleep(2)return false end;syscall.exit(0)end;local function B()syscall.devctl(1,"clear")syscall.devctl(1,"sfgc",0xFFFFFF)syscall.devctl(1,"sbgc",0x000000)syscall.devctl(1,"spos",1,1)local C=syscall.getHostname()or"hyperion"syscall.write(1,"HyperionOS\n")syscall.write(1,C.." login\n\n")local D=0;while D<a do syscall.devctl(1,"sfgc",0xFFFFFF)syscall.write(1,"Username: ")local p=b(nil)if p~=""then syscall.write(1,"Password: ")local E=b("*")local q=syscall.getuidbyname(p)local m,n=syscall.login(q,E)if m then local q=syscall.getuid()local F=syscall.getpasswd(q)local r=F and F.shell or"/bin/hysh"local s=F and F.homedir or"/"syscall.devctl(1,"sfgc",0x00FF00)syscall.write(1,"\nWelcome, "..p.."!\n")syscall.devctl(1,"sfgc",0xFFFFFF)sleep(0.3)o(p,q,r,s)return else D=D+1;sleep(1)syscall.devctl(1,"sfgc",0xFF0000)syscall.write(1,"Login incorrect.\n\n")syscall.devctl(1,"sfgc",0xFFFFFF)end end end;syscall.devctl(1,"sfgc",0xFF0000)syscall.write(1,"Maximum login attempts exceeded.\n")syscall.devctl(1,"sfgc",0xFFFFFF)sleep(5)end;f()while true do B()end
|
||||
1
prod/hysh/bin/loimgcreate
Normal file
1
prod/hysh/bin/loimgcreate
Normal file
@@ -0,0 +1 @@
|
||||
local a=syscall.getTask(syscall.getpid()).name;local b,c={},{x=false,help=false}for d,e in ipairs({...})do if e:sub(1,2)=="--"then local f=e:sub(3)if f=="help"then c.help=true else print(a..": unrecognised option '"..e.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end elseif e:sub(1,1)=="-"then for g=2,#e do local h=e:sub(g,g)if c[h]~=nil then c[h]=true else print(a..": invalid option '-"..h.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end end else table.insert(b,e)end end;if c.help then print("Usage: "..a.." <srcdir> <image.hfs>")print(" "..a.." -x <image.hfs> <destdir>")print("")print("Pack a directory into a portable HFS image file, or extract one.")print("")print(" <srcdir> <image.hfs> recursively pack srcdir into image.hfs")print(" -x <image.hfs> <dest> extract image.hfs into dest (created if needed)")print("")print("HFS images can be mounted with:")print(" mount -o loop /path/to/image.hfs /mnt/point")print("")print("Requires root.")return end;local i=require("fs")if c.x then if#b<2 then print(a..": -x requires <image.hfs> and <destdir>")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local j=b[1]local k=b[2]if j:sub(1,1)~="/"then j=syscall.getcwd().."/"..j end;if k:sub(1,1)~="/"then k=syscall.getcwd().."/"..k end;local l="/tmp/._loimgcreate_"..tostring(math.random(100000,999999))local m,n=pcall(syscall.losetup,j,true)if not m then print(a..": losetup: "..tostring(n))syscall.exit(1)return end;local o,p=pcall(syscall.mount,l,n)if not o then pcall(syscall.lodetach,n)print(a..": mount: "..tostring(p))syscall.exit(1)return end;if not i.isDir(k)then local q,r=pcall(syscall.mkdir,k)if not q then pcall(syscall.umount,l)pcall(syscall.lodetach,n)print(a..": mkdir '"..b[2].."': "..tostring(r))syscall.exit(1)return end end;local s=0;local function t(u,v)local w=i.list(u)if not w then return end;for d,x in ipairs(w)do local y=u:gsub("/$","").."/"..x;local z=v:gsub("/$","").."/"..x;if i.isDir(y)then pcall(syscall.mkdir,z)t(y,z)else local A,B=pcall(syscall.open,y,"r")if A then local o,C=pcall(syscall.open,z,"w")if o then local q,D=pcall(syscall.read,B,65536*16)if q and D then pcall(syscall.write,C,D)end;pcall(syscall.close,C)s=s+1 end;pcall(syscall.close,B)end end end end;t(l,k)pcall(syscall.umount,l)pcall(syscall.lodetach,n)syscall.devctl(1,"sfgc",0x00FFFF)print(a..": extracted "..s.." file(s) to "..k)syscall.devctl(1,"sfgc",0xFFFFFF)return end;if#b<2 then print(a..": missing operands — need <srcdir> and <image.hfs>")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local E=b[1]local j=b[2]if E:sub(1,1)~="/"then E=syscall.getcwd().."/"..E end;if j:sub(1,1)~="/"then j=syscall.getcwd().."/"..j end;if not i.isDir(E)then print(a..": '"..b[1].."': not a directory")syscall.exit(1)return end;local A,F=pcall(syscall.loimgcreate,E)if not A then local G=tostring(F)if G:find("EPERM")then G="Permission denied"elseif G:find("ENOTDIR")then G="'"..b[1].."': not a directory"end;print(a..": "..G)syscall.exit(1)return end;local o,H=pcall(syscall.loimgwrite,F,j)if not o then print(a..": write '"..b[2].."': "..tostring(H))syscall.exit(1)return end;local I=0;for d in F:gmatch("\n")do I=I+1 end;local J=#F;syscall.devctl(1,"sfgc",0x00FFFF)print(a..": image written to "..j)syscall.devctl(1,"sfgc",0x6D00FF)print(string.format(" %d records, %d bytes",I-1,J))syscall.devctl(1,"sfgc",0xFFFFFF)
|
||||
1
prod/hysh/bin/losetup
Normal file
1
prod/hysh/bin/losetup
Normal file
@@ -0,0 +1 @@
|
||||
local a=syscall.getTask(syscall.getpid()).name;local b,c={},{d=false,l=false,i=false,help=false}for d,e in ipairs({...})do if e:sub(1,2)=="--"then local f=e:sub(3)if f=="help"then c.help=true else print(a..": unrecognised option '"..e.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end elseif e:sub(1,1)=="-"then for g=2,#e do local h=e:sub(g,g)if c[h]~=nil then c[h]=true else print(a..": invalid option '-"..h.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end end else table.insert(b,e)end end;if c.help then print("Usage: "..a.." <path>")print(" "..a.." -i <path>")print(" "..a.." -d <id>")print(" "..a.." -l")print("")print("Manage loop devices.")print("")print(" <path> attach a directory (bind) or .hfs image file")print(" -i <path> force image mode for the given file")print(" -d <id> detach loop device by id (must be unmounted first)")print(" -l list all currently attached loop devices")print("")print("Requires root. Loop device ids look like loop0, loop1, …")return end;if c.l then local i,j=pcall(syscall.lolist)if not i then print(a..": "..tostring(j))syscall.exit(1)return end;local k=false;local l={}for m in pairs(j)do l[#l+1]=m end;table.sort(l)for d,m in ipairs(l)do k=true;local n=j[m]local o=type(n)=="table"and n.mode or"bind"local p=type(n)=="table"and n.path or tostring(n)local q=o=="image"and 0x00FFFF or 0x0000FF;syscall.devctl(1,"sfgc",0x00FF00)printInline(string.format("%-10s",m))syscall.devctl(1,"sfgc",q)printInline(string.format("%-7s","["..o.."]"))syscall.devctl(1,"sfgc",0xFFFFFF)print(" "..p)end;if not k then syscall.devctl(1,"sfgc",0x6D00FF)print(a..": no loop devices attached")syscall.devctl(1,"sfgc",0xFFFFFF)end;return end;if c.d then if#b<1 then print(a..": -d requires a loop device id")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local m=b[1]local i,r=pcall(syscall.lodetach,m)if not i then local s=tostring(r)if s:find("EPERM")then s="Permission denied"elseif s:find("ENXIO")then s="no such loop device '"..m.."'"elseif s:find("EBUSY")then s="device '"..m.."' is still mounted, unmount first"end;print(a..": "..s)syscall.exit(1)return end;syscall.devctl(1,"sfgc",0x00FFFF)print(a..": detached "..m)syscall.devctl(1,"sfgc",0xFFFFFF)return end;if#b<1 then print(a..": missing path operand")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local p=b[1]if p:sub(1,1)~="/"then p=syscall.getcwd().."/"..p end;local t=syscall.type and syscall.type(p)if not(t=="file"or t=="directory")then print(a..": '"..b[1].."': no such file or directory")syscall.exit(1)return end;local i,u=pcall(syscall.losetup,p,c.i or nil)if not i then local s=tostring(u)if s:find("EPERM")then s="Permission denied"elseif s:find("ENOENT")then s="'"..b[1].."': no such file"elseif s:find("EINVAL")then s="'"..b[1].."': not a directory or .hfs image"elseif s:find("EIO")then s="'"..b[1].."': I/O error reading image"end;print(a..": "..s)syscall.exit(1)return end;print(u)
|
||||
1
prod/hysh/bin/ls
Normal file
1
prod/hysh/bin/ls
Normal file
@@ -0,0 +1 @@
|
||||
local a={a=false,h=false,l=false,help=false}local b={...}local c={}local d=syscall.getTask(syscall.getpid()).name;for e,f in pairs(b)do if f:sub(1,2)=="--"then local g=f:sub(3)if a[g]==nil then print(d..": unrecognized option '"..f.."'.")print("try '"..d.." --help' for more information.")return end;a[g]=true elseif f:sub(1,1)=="-"then for h=2,#f do local g=f:sub(h,h)if a[g]==nil then print(d..": invalid option '-"..g.."'.")print("try '"..d.." --help' for more information.")return end;a[g]=true end else table.insert(c,f)end end;if a.help then print("Usage: "..d.." [OPTION]... [DIR]")print("List all entries in the specified DIRectory, or cwd if not specified.")print("")print("Options:")print(" -a do not ignore entries starting with .")print(" -h with -l, print sizes in human readable format")print(" -l use a long listing format")print(" --help display this help and exit")return end;local i=require("fs")local j=c[1]or""if j:sub(1,1)~="/"then j=syscall.getcwd().."/"..j end;if j:sub(-1)~="/"then j=j.."/"end;if not i.isDir(j)then print(d..": cannot access '"..(c[1]or j).."': no such directory")return end;local function k(l,m)local function n(o)return math.floor(l/2^o)%2==1 end;local p;if m==0x01 then p="l"elseif m==nil then p="-"else p="-"end;local q=n(5)and"r"or"-"local r=n(4)and"w"or"-"local s=n(9)and(n(6)and"s"or"x")or(n(6)and"S"or"-")local t=n(3)and"r"or"-"local u=n(2)and"w"or"-"local v=n(8)and"x"or"-"local w=n(1)and"r"or"-"local x=n(0)and"w"or"-"local y=n(7)and"x"or"-"return p..q..r..s..t..u..v..w..x..y end;local z={"K","M","G","T"}local function A(B)local C=0;while B>=1024 and C<#z do B=B/1024;C=C+1 end;if C==0 then return tostring(B).."B"end;if B<10 then return string.format("%.1f%s",B,z[C])end;return math.floor(B)..z[C]end;local D=syscall.devctl(1,"size")local E=tonumber(D:match("^(%d+)"))or 80;local F=i.list(j)if not a.a then for h=#F,1,-1 do if F[h]:sub(1,1)=="."then table.remove(F,h)end end end;table.sort(F)if#F==0 then return end;if a.l then for e,f in ipairs(F)do local G=j..f;local H=syscall.lstat and syscall.lstat(G)or syscall.stat(G)local I=i.isDir(G)local J=H and H.etype==0x01;local isSock=H and H.etype==0x02;local K;if J then K="l"elseif I then K="d"elseif isSock then K="s"else K="-"end;local L;if H and H.perms then L=k(H.perms,H.etype)else L=K.."---------"end;local B=H and H.size or 0;local M=a.h and A(B)or tostring(B)local N=H and H.modified and math.floor(H.modified/1000)or 0;local O=H and tostring(H.owner)or"0"local P=H and tostring(H.group)or"0"printInline(L.." "..O.." "..P.." ")printInline(string.format("%6s",M).." ")printInline(tostring(N).." ")if J then syscall.devctl(1,"sfgc",0x00FFFF)printInline(f)syscall.devctl(1,"sfgc",0xFFFFFF)local Q,R=pcall(syscall.readlink,G)if Q then printInline(" -> ")local S=pcall(syscall.stat,G)syscall.devctl(1,"sfgc",S and 0x00FFFF or 0xFF0000)printInline(R)syscall.devctl(1,"sfgc",0xFFFFFF)end elseif I then syscall.devctl(1,"sfgc",0x6D00FF)printInline(f)syscall.devctl(1,"sfgc",0xFFFFFF)elseif isSock then syscall.devctl(1,"sfgc",0xFF00FF)printInline(f)syscall.devctl(1,"sfgc",0xFFFFFF)else local T=H and H.perms and math.floor(H.perms/2^9)%2==1;syscall.devctl(1,"sfgc",T and 0x00FF00 or 0xFFFFFF)printInline(f)syscall.devctl(1,"sfgc",0xFFFFFF)end;print("")end;return end;local U=0;for e,f in ipairs(F)do if#f+2>U then U=#f+2 end end;local V=math.max(1,math.floor(E/U))for h,f in ipairs(F)do local G=j..f;local I=i.isDir(G)local H=syscall.lstat and syscall.lstat(G)or syscall.stat(G)local J=H and H.etype==0x01;if J then syscall.devctl(1,"sfgc",0x00FFFF)elseif I then syscall.devctl(1,"sfgc",0x6D00FF)elseif isSock then syscall.devctl(1,"sfgc",0xFF00FF)else local T=H and H.perms and math.floor(H.perms/2^9)%2==1;syscall.devctl(1,"sfgc",T and 0x00FF00 or 0xFFFFFF)end;printInline(f)syscall.devctl(1,"sfgc",0xFFFFFF)printInline((" "):rep(U-#f))if h%V==0 then print("")end end;if#F%V~=0 then print("")end
|
||||
1
prod/hysh/bin/lsusers
Normal file
1
prod/hysh/bin/lsusers
Normal file
@@ -0,0 +1 @@
|
||||
local a=syscall.listusers()if not a or#a==0 then print("No users found.")return end;syscall.devctl(1,"sfgc",0xDBDBDB)print(string.format("%-6s %-6s %-16s %-20s %s","UID","GID","Username","Home","Shell"))print(string.rep("-",65))syscall.devctl(1,"sfgc",0xFFFFFF)for b,c in ipairs(a)do local d=c.locked and" [locked]"or""if c.locked then syscall.devctl(1,"sfgc",0xFF0000)end;print(string.format("%-6d %-6d %-16s %-20s %s%s",c.uid,c.gid,c.username,c.homedir,c.shell,d))if c.locked then syscall.devctl(1,"sfgc",0xFFFFFF)end end
|
||||
1
prod/hysh/bin/mount
Normal file
1
prod/hysh/bin/mount
Normal file
@@ -0,0 +1 @@
|
||||
local a=syscall.getTask(syscall.getpid()).name;local b,c={},{help=false,o=nil}local d=1;local e={...}while d<=#e do local f=e[d]if f:sub(1,2)=="--"then local g=f:sub(3)if g=="help"then c.help=true else print(a..": unrecognised option '"..f.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end elseif f=="-o"then d=d+1;c.o=e[d]elseif f:sub(1,1)=="-"then local h=f:sub(2)if h:sub(1,1)=="o"then if#h>1 then c.o=h:sub(2)else d=d+1;c.o=e[d]end else print(a..": invalid option '"..f.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end else table.insert(b,f)end;d=d+1 end;if c.help then print("Usage: "..a)print(" "..a.." <id> <mountpoint>")print(" "..a.." -o loop <source> <mountpoint>")print("")print("Mount a loop device or filesystem.")print("")print(" (no args) list all active mount points")print(" <id> <mountpoint> mount an already-attached loop device")print(" -o loop <src> <dest> attach src as loop device and mount at dest")print(" src can be a directory (bind) or .hfs image")print("")print("Requires root for all operations except listing.")return end;if#b==0 and not c.o then local i,j=pcall(syscall.mounts or function()error("ENOSYS")end)local k={}local l,m=pcall(syscall.lolist)if l then for n,o in pairs(m)do local p=type(o)=="table"and o.path or tostring(o)local q=type(o)=="table"and o.mode or"bind"k[n]={path=p,mode=q}end end;if next(k)==nil then syscall.devctl(1,"sfgc",0xFF00FF)print("(no loop devices attached)")syscall.devctl(1,"sfgc",0xFFFFFF)return end;for n,o in pairs(k)do local r=o.mode=="image"and 0x00FFFF or 0x0000FF;syscall.devctl(1,"sfgc",r)printInline(o.mode.." "..n)syscall.devctl(1,"sfgc",0xFFFFFF)print(" on "..o.path)end;return end;if c.o and c.o:lower()=="loop"then if#b<2 then print(a..": -o loop requires <source> and <mountpoint>")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local s=b[1]local t=b[2]if s:sub(1,1)~="/"then s=syscall.getcwd().."/"..s end;if t:sub(1,1)~="/"then t=syscall.getcwd().."/"..t end;local i,u=pcall(syscall.losetup,s)if not i then local v=tostring(u)if v:find("EPERM")then v="Permission denied"elseif v:find("EINVAL")then v="'"..b[1].."': not a directory or .hfs image"elseif v:find("EIO")then v="'"..b[1].."': I/O error reading image"end;print(a..": losetup: "..v)syscall.exit(1)return end;local w,x=pcall(syscall.mount,t,u)if not w then pcall(syscall.lodetach,u)local v=tostring(x)if v:find("EPERM")then v="Permission denied"elseif v:find("EBUSY")then v="'"..t.."' is already a mount point"elseif v:find("ENODEV")then v="loop device not found (internal error)"end;print(a..": mount: "..v)syscall.exit(1)return end;syscall.devctl(1,"sfgc",0x00FFFF)print(a..": "..u.." mounted at "..t)syscall.devctl(1,"sfgc",0xFFFFFF)return end;if#b==2 then local u=b[1]local t=b[2]if t:sub(1,1)~="/"then t=syscall.getcwd().."/"..t end;local i,y=pcall(syscall.mount,t,u)if not i then local v=tostring(y)if v:find("EPERM")then v="Permission denied"elseif v:find("ENODEV")then v="'"..u.."': no such device - use losetup first"elseif v:find("EBUSY")then v="'"..t.."' is already a mount point"elseif v:find("EINVAL")then v="invalid arguments"end;print(a..": "..v)syscall.exit(1)return end;syscall.devctl(1,"sfgc",0x00FFFF)print(a..": "..u.." mounted at "..t)syscall.devctl(1,"sfgc",0xFFFFFF)return end;print(a..": wrong number of arguments")print("try '"..a.." --help' for more information.")syscall.exit(1)
|
||||
1
prod/hysh/bin/passwd
Normal file
1
prod/hysh/bin/passwd
Normal file
@@ -0,0 +1 @@
|
||||
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.."'")
|
||||
1
prod/hysh/bin/ps
Normal file
1
prod/hysh/bin/ps
Normal file
@@ -0,0 +1 @@
|
||||
for a,b in ipairs(syscall.getTasks())do local c=syscall.getTask(b)print(c.pid,c.username,c.name,c.status)end
|
||||
1
prod/hysh/bin/readlink
Normal file
1
prod/hysh/bin/readlink
Normal file
@@ -0,0 +1 @@
|
||||
local a=syscall.getTask(syscall.getpid()).name;local b={n=false,f=false,e=false,help=false}local c={}for d,e in ipairs({...})do if e:sub(1,2)=="--"then local f=e:sub(3)if b[f]==nil then print(a..": unrecognized option '"..e.."'")syscall.exit(1)return end;b[f]=true elseif e:sub(1,1)=="-"then for g=2,#e do local f=e:sub(g,g)if b[f]==nil then print(a..": invalid option '-"..f.."'")syscall.exit(1)return end;b[f]=true end else table.insert(c,e)end end;if b.help then print("Usage: "..a.." [OPTION]... FILE...")print("Print the resolved target of symbolic links.")print("")print("Options:")print(" -f canonicalize: follow every symlink; last component need not exist")print(" -e like -f but all components must exist")print(" -n do not output trailing newline")print(" --help display this help and exit")return end;if#c==0 then print(a..": missing operand")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local function h(i)if i:sub(1,1)~="/"then local j=syscall.getcwd()if j:sub(-1)~="/"then j=j.."/"end;i=j..i end;return i end;local k=false;for d,l in ipairs(c)do l=h(l)if b.f or b.e then local m,n=pcall(syscall.stat,l)if not m then if b.e then print(a..": "..l..": "..tostring(n))k=true else if not b.n then print(l)else printInline(l)end end else if not b.n then print(l)else printInline(l)end end else local m,o=pcall(syscall.readlink,l)if not m then print(a..": "..l..": "..tostring(o))k=true else if not b.n then print(o)else printInline(o)end end end end;if k then syscall.exit(1)end
|
||||
1
prod/hysh/bin/su
Normal file
1
prod/hysh/bin/su
Normal file
@@ -0,0 +1 @@
|
||||
local a=({...})[1]local b=syscall.getuid()if syscall.geteuid()~=0 then syscall.exec("/bin/su",{...})end;local c;if a then c=syscall.getuidbyname(a)else c=0 end;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.login(c,d)if not f then sleep(1)print("su: Authentication failure")syscall.exit(1)return end else syscall.setuid(c)end;local h=syscall.getpasswd(c)local i=h and h.shell or"/bin/hysh"local j=h and h.homedir or"/"local k=h and h.username or"Unknown"local l,m=pcall(syscall.chdir,j)if not l then j="/"syscall.chdir(j)end;syscall.setEnviron("HOME",j)syscall.setEnviron("USER",k)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
|
||||
1
prod/hysh/bin/sudo
Normal file
1
prod/hysh/bin/sudo
Normal file
@@ -0,0 +1 @@
|
||||
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] <command> [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
|
||||
1
prod/hysh/bin/sysdump
Normal file
1
prod/hysh/bin/sysdump
Normal file
@@ -0,0 +1 @@
|
||||
local a=...a=a or"/dev/tty/1"local b=syscall.sysdump()local c=syscall.open(a,"w")for d=1,#b do syscall.write(c,b[d].."\n")end;syscall.write(c,"Total # of syscalls: "..tostring(#b))syscall.close(c)
|
||||
1
prod/hysh/bin/umount
Normal file
1
prod/hysh/bin/umount
Normal file
@@ -0,0 +1 @@
|
||||
local a=syscall.getTask(syscall.getpid()).name;local b,c={},{l=false,["no-detach"]=false,help=false}for d,e in ipairs({...})do if e:sub(1,2)=="--"then local f=e:sub(3)if c[f]~=nil then c[f]=true else print(a..": unrecognised option '"..e.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end elseif e:sub(1,1)=="-"then for g=2,#e do local h=e:sub(g,g)if c[h]~=nil then c[h]=true else print(a..": invalid option '-"..h.."'")print("try '"..a.." --help' for more information.")syscall.exit(1)return end end else table.insert(b,e)end end;if c.help then print("Usage: "..a.." <mountpoint>")print(" "..a.." --no-detach <mountpoint>")print(" "..a.." -l <loopid>")print("")print("Unmount a filesystem mounted at <mountpoint>.")print("")print(" <mountpoint> unmount and auto-detach any loop device")print(" --no-detach unmount but keep the loop device attached")print(" -l <loopid> forcibly detach a loop device (no unmount)")print("")print("Requires root.")return end;if c.l then if#b<1 then print(a..": -l requires a loop device id")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local i=b[1]local j,k=pcall(syscall.lodetach,i)if not j then local l=tostring(k)if l:find("EPERM")then l="Permission denied"elseif l:find("ENXIO")then l="no such loop device '"..i.."'"elseif l:find("EBUSY")then l="'"..i.."' is still mounted - unmount first or omit -l"end;print(a..": "..l)syscall.exit(1)return end;syscall.devctl(1,"sfgc",0x00FFFF)print(a..": detached "..i)syscall.devctl(1,"sfgc",0xFFFFFF)return end;if#b<1 then print(a..": missing mount point operand")print("try '"..a.." --help' for more information.")syscall.exit(1)return end;local m=b[1]if m:sub(1,1)~="/"then m=syscall.getcwd().."/"..m end;local n=nil;if not c["no-detach"]then local o,p=pcall(syscall.lolist)if o then n={}for i in pairs(p)do n[#n+1]=i end end end;local j,k=pcall(syscall.umount,m)if not j then local l=tostring(k)if l:find("EPERM")then l="Permission denied"elseif l:find("EINVAL")then l="'"..b[1].."' is not a mount point"elseif l:find("EBUSY")then l="'"..b[1].."' is busy - close open files first"end;print(a..": "..l)syscall.exit(1)return end;syscall.devctl(1,"sfgc",0x00FFFF)print(a..": unmounted "..m)syscall.devctl(1,"sfgc",0xFFFFFF)if n then for d,i in ipairs(n)do local q=pcall(syscall.lodetach,i)if q then syscall.devctl(1,"sfgc",0xFF00FF)print(a..": auto-detached "..i)syscall.devctl(1,"sfgc",0xFFFFFF)end end end
|
||||
1
prod/hysh/bin/useradd
Normal file
1
prod/hysh/bin/useradd
Normal file
@@ -0,0 +1 @@
|
||||
local a={...}local b=1;local c={createHome=true}while b<=#a do local d=a[b]if d=="-p"then b=b+1;c.password=a[b]elseif d=="-g"then b=b+1;c.gid=tonumber(a[b])elseif d=="-d"then b=b+1;c.homedir=a[b]elseif d=="-s"then b=b+1;c.shell=a[b]elseif d=="-M"then c.createHome=false elseif d:sub(1,1)~="-"then c.username=d else print("useradd: unknown option: "..d)return end;b=b+1 end;if not c.username then print("Usage: useradd [-p password] [-g gid] [-d homedir] [-s shell] [-M] <username>")syscall.exit(1)return end;local e=c.password;if not e then printInline("New password: ")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;printInline("Confirm password: ")local g=""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#g>0 then g=g:sub(1,-2)syscall.write(1,"\b \b")end else g=g..f;syscall.write(1,"*")end end;if e~=g then print("useradd: passwords do not match")syscall.exit(1)return end end;local h,i=syscall.newuser(c.username,e,c.gid,c.homedir,c.shell or"/bin/hysh")if not h then print("useradd: "..tostring(i))syscall.exit(1)return end;if c.createHome then local j=c.homedir or"/home/"..c.username;local k,l=pcall(syscall.mkdir,j)if not k then print("useradd: warning: could not create home "..j..": "..tostring(l))end end;print("useradd: created user '"..c.username.."' with uid="..tostring(h))
|
||||
1
prod/hysh/bin/userdel
Normal file
1
prod/hysh/bin/userdel
Normal file
@@ -0,0 +1 @@
|
||||
local a={...}local b=false;local c=nil;for d,e in ipairs(a)do if e=="-r"then b=true elseif e:sub(1,1)~="-"then c=e else print("userdel: unknown option: "..e)syscall.exit(1)return end end;if not c then print("Usage: userdel [-r] <username>")syscall.exit(1)return end;local f=syscall.getuid(c)if not f then print("userdel: user '"..c.."' does not exist")syscall.exit(1)return end;local g=syscall.getpasswd(f)local h,i=syscall.deleteuser(f)if not h then print("userdel: "..tostring(i))syscall.exit(1)return end;if b and g and g.homedir then local j=require("fs")local k,l=pcall(function()local function m(n)for d,o in ipairs(j.list(n)or{})do local p=n.."/"..o;if j.isDir(p)then m(p)else syscall.remove(p)end end;syscall.remove(n)end;if j.exists(g.homedir)then m(g.homedir)end end)if not k then print("userdel: warning: could not remove home: "..tostring(l))end end;print("userdel: deleted user '"..c.."'")
|
||||
1
prod/hysh/bin/usermod
Normal file
1
prod/hysh/bin/usermod
Normal file
@@ -0,0 +1 @@
|
||||
local a={...}local b=1;local c={}while b<=#a do local d=a[b]if d=="-l"then b=b+1;c.newname=a[b]elseif d=="-p"then b=b+1;c.password=a[b]elseif d=="-g"then b=b+1;c.gid=tonumber(a[b])elseif d=="-d"then b=b+1;c.homedir=a[b]elseif d=="-s"then b=b+1;c.shell=a[b]elseif d=="-L"then c.lock=true elseif d=="-U"then c.unlock=true elseif d:sub(1,1)~="-"then c.username=d else print("usermod: unknown option: "..d)syscall.exit(1)return end;b=b+1 end;if not c.username then print("Usage: usermod [-l newname] [-p password] [-g gid] [-d homedir] [-s shell] [-L] [-U] <username>")syscall.exit(1)return end;if c.lock and c.unlock then print("usermod: -L and -U are mutually exclusive")syscall.exit(1)return end;local e=syscall.getuid(c.username)if not e then print("usermod: user '"..c.username.."' does not exist")syscall.exit(1)return end;local function f(g,...)local h,i=g(...)if not h then print("usermod: "..tostring(i))syscall.exit(1)end end;if c.newname then f(syscall.setusername,e,c.newname)end;if c.password then f(syscall.setpassword,e,c.password)end;if c.gid then f(syscall.setgid,e,c.gid)end;if c.homedir then f(syscall.sethomedir,e,c.homedir)end;if c.shell then f(syscall.setshell,e,c.shell)end;if c.lock then f(syscall.lockuser,e)end;if c.unlock then f(syscall.unlockuser,e)end;print("usermod: updated user '"..c.username.."'")
|
||||
1
prod/hysh/bin/yes
Normal file
1
prod/hysh/bin/yes
Normal file
@@ -0,0 +1 @@
|
||||
local a={...}while true do if#a==0 then print("y")else print(table.concat(a," "))end end
|
||||
Reference in New Issue
Block a user