This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Kilobyte's profile picture

KilOS Open Pre-Alpha 2.3 - Multiuser support, a GUI file explorer and Sandboxing

Started by Kilobyte, 12 November 2012 - 09:52 AM
Kilobyte #1
Posted 12 November 2012 - 10:52 AM
Hey together,

here i'm presenting my new custom os. List of features and planned features:

done:
  • Custom shell with tab complete and stuff (to complete a command hit the tab-key. it will give you a preview while you type)
  • Auto-Updater
  • multi-user support
  • Sandboxing of _G aka. kernel- and usermode
  • Environment variables
planned:
  • file access protection
  • multitasking (so you can easily switch between prorams without xiting the current one and the other programs continue running in the background)
  • unix pipes
  • drivers
  • device files
  • daemons
  • multi-language support
  • moar awesome stuff
possible features:
  • file extension -> program assciation (so for example images are not executed when calling it)
Screenshots:
SpoilerA new KilOS setup just after setup
to grab yourself a copy enable http api and run these 2 commands on your computer:

pastebin get sP9WXu8n install
install
then wait, till its done (~5 seconds for me)
WARNING: if you have a startup file, rename it to .startup. before installing KilOS or it will get overwritten. the shell will run the .startup if present


included additional programs:
  • update - download and install updates (this program has lots of params, run update –help to list them all)
  • adduser <user> [<home dir>] - creates a new user
  • changepass [<user>] - changes the pass of user. if no user specified, it changes your pass.
  • browser - this program has tons of params too, again list them with browser –help
parameters in square brackets are optional.

If you don't understand how KilOS works or how to use it check out this tutorial

changelog:
SpoilerPre-Alpha 2.3:
Fixed: Shell now deletes tab-preview when hitting enter
Added: term.getBackgroundColor and term.getTextColor (and their british equivalents) to sandbox
Added: parameters to updater
Fixed: sandbox being extremely insecure (thanks to Nia <3, i'm a too big noob to even understand the new code fully lol)
Added: config api
Added: slightly modified version of Mouse File Explorer by BigSHinyToys
Changed: Added Copy, cut and paste to file explorer, also added param support
Fixed: a lot af small other bugs
Pre-Alpha 2.2.1:
Fixed: turtle API now works within the Sandbox
Fixed: os.setComputerLabel doing nothing
Pre-Alpha 2.2:
Added: Basic sandboxing
Fixed: username now displays properly on shell
Changed: os.setComputerLabel now requires you to be root
Added: Environment variables
Added: environment variable "startup" to specify autostart directorys and files
Fixed: if KiloShell errors or gets terminated the Computer will now shut down to prevent bypassing of the permission system instead of returning to CraftOS
Pre-Alpha 2.1.1:
Changed: changepass no longer asks for your current password if its empty
Pre-Alpha 2.1:
Change: Made shell a bit fancier
Pre-Alpha 2.0:
Added: multi-user support
Added: ~/.login gets executed on login (after .startup)
Pre-Alpha 1.3:
Fixed: some crash on initial Boot
Pre-Alpha 1.2:
Event: Intial public release

Additional Credits/Thanks
Thomass, because i use his really awesome stringutils api. (btw. its avaible as stringutils.<function> in KilOS for all programs)
max96at for saving me time while adding the startup env var handling
The users of #KilOS for being really fast with finding bugs
BigSHinyToys for making The Mouse File Explorer which we use (i also edited it a bit, dunno if he will provide my version)
Nia for helping me with fixing the sandbox

If you encounter any bugs please tell me immediately (either on irc, i'm Kilobyte there or by replying to this topic) you may also join #KilOS on esper.net (click to open webchat) or and this is maybe the best way: go to https://bitbucket.or...te/kilos/issues and report it there. you may do feature requests there too (mark it as suggestion). please don't post an issue there if you want me to add some program or api by someone else. in that case post a reply to this topic, ask me on irc or write me a PM. Also i will only add it if i 1. like it, 2. its useful to others 3. its stable and 4. it doesn't exploit any bugs. but if i think that its awesome and i think it is useful for others i might add it (and i'll credit the author ofc)

KilOS will check for updates and inform you if there are new ones when you start it. to install them simply run update

Also on out GIT repository (link is somewhere above) you can get the latest version. this is NOT guaranteed to be stable. So only use it if you know what you are doing and on your own risk. This is the paste to upgrade: http://pastebin.com/8SxTk8EB run it, then reboot and run "devupdate". thats it.
ElvishJerricco #2
Posted 12 November 2012 - 01:14 PM
I downloaded this to check it out… At first i was not surprised to find yet another extension over the normal shell. I began to think that it was just as bad as the others on here. Then I took a look at the source code of it and saw how much work you've put into making it structurally like UNIX and was impressed. If i'm not mistaken though, it's still very much CraftOS. This is nonetheless one of the most technically interesting OS's on the forums.
Kilobyte #3
Posted 12 November 2012 - 10:12 PM
I downloaded this to check it out… At first i was not surprised to find yet another extension over the normal shell. I began to think that it was just as bad as the others on here. Then I took a look at the source code of it and saw how much work you've put into making it structurally like UNIX and was impressed. If i'm not mistaken though, it's still very much CraftOS. This is nonetheless one of the most technically interesting OS's on the forums.

Thanks, dude!

Yes, i know there are quite a few OSes out there and most of them are just some APIs and so. i don't call that os. i call it an API (pack). an OS must provide fundamental changes and other nice tweaks. (and thats my aim as you guessed right :P/>/>)
and yes, i'm planning to keep it very similar to linux. Also my biggest aim is that every program written for regular CraftOS can run on KilOS without a single change. next step will be the user-system so stay tuned :)/>/>
and yes, currently its pretty much just a custom shell
Kilobyte #4
Posted 13 November 2012 - 01:06 AM
Ok, updated to Pre-Alpha 2.0

Changes:
Added basic multiuser system.
BigSHinyToys #5
Posted 13 November 2012 - 01:29 AM
This looks interesting but having never used UNIX or multi user OS systems this is hard to use. maybe adding some how to use info or a vid would be helpful
Kilobyte #6
Posted 13 November 2012 - 02:21 AM
i try to make everything either self-explanoratory or at least give some documentation. i'll add some pages to my wiki at some point.

and if something isn't clear yu can always post here or ask me (Kilobyte) on irc.

Also you don't have to care about multiuser unless you want to. the reasone is that you only have a passwordless root account by default. (if not, please delete /etc/users) and if the computer detects this exact state (so only 1 user account with the name root and this account has no password) it will autologin as root. but again. there will be some documention and tutorials
ElvishJerricco #7
Posted 13 November 2012 - 02:28 AM
If you want some advice for making it capable of multitasking, and you don't want to roll your own launcher (I did and it wasn't too hard) os.run() is pretty cool. Lets you define environments for the program to run in. That'll let you define a custom term object if you want programs to write to a separate screen buffer that'll get displayed when it's in the foreground.
Kilobyte #8
Posted 13 November 2012 - 02:50 AM
ofc every program will get its own environment. first of all because different users have or will have different permissions (especially with the fs api) also i don't want that a program where you forgot a local messes up another one. the environment thngy won't be much of an issue, trust me. the bigger part will be dynamic event dirstibution. so for example key, mouse or char events should only go to the program that is currently in the foreground, but events like rednet_message or redstone are interesting for minimized programs too.
BigSHinyToys #9
Posted 13 November 2012 - 03:49 AM
dynamic distribution is simple
this a non function ruff example


local onlyForActive = {key = true,char = true,mouse_click = true,mouse_drag = true,mouse_scroll = true}
local tPrograms = {}
local activeProgram = 1
local function newProgram(prog,...)
    table.insert(tPrograms,{prog = coroutine.create(loadfile(prog),...),})
end
while true do
    event = {os.pullEvent()}
    for i,v in pairs(tPrograms) do
	    if onlyForActive[event[1]] and i == activeProgram then
		    coroutine.resume(v.prog,unpack(event))
	    elseif not onlyForActive[event[1]] then
		    coroutine.resume(v.prog,unpack(event))
	    end	   
    end
end
Kilobyte #10
Posted 13 November 2012 - 07:41 AM
actually yeah, i'm prob making it more complicated than necessary, but i wanna be able to send events to just a specific coroutine and some other stuff. but meh i'll figure it out :P/>/>
ElvishJerricco #11
Posted 13 November 2012 - 08:53 AM
ofc every program will get its own environment. first of all because different users have or will have different permissions (especially with the fs api) also i don't want that a program where you forgot a local messes up another one. the environment thngy won't be much of an issue, trust me. the bigger part will be dynamic event dirstibution. so for example key, mouse or char events should only go to the program that is currently in the foreground, but events like rednet_message or redstone are interesting for minimized programs too.

BigSHinyToys' design is pretty effective actually. For my OS, I redid everything so I'll have to write a CraftOS emulator but programs are expected to register for events, and when you create a window, it automatically registers for mouse and keyboard events, then only shows them when it's active. Also, while os.loadAPI is cool, it's really unsafe from a memory protection standpoint. I can change shell.getRunningProgram to something else if i want. So that's an obvious security hole. I'd look into that if you haven't already.
Kilobyte #12
Posted 13 November 2012 - 09:35 AM
actually os.loadApi will load the api inside the sandbox. so no danger there.

Also all craftos programs will run on KilOS as usualy on CraftOS
ElvishJerricco #13
Posted 13 November 2012 - 09:59 AM
actually os.loadApi will load the api inside the sandbox. so no danger there.

Also all craftos programs will run on KilOS as usualy on CraftOS

Are you sure that that happens?
*checks bios.lua*
Cuz bios.lua puts the API in the _G table.
Or is that behavior of your OS?

And I understand your OS runs CraftOS programs fine this but not all of us want to be so close to CraftOS =P
Kilobyte #14
Posted 13 November 2012 - 11:20 AM
its like with fml. fml can load modloader mods but you can use fml to make it much fancier. fml = KilOS, modloader = CraftOS

Also i'll sandbox os.loadAPI(so i overwrite it)

<EDIT>
Actually when i init the sandbox and call the first function inside it will have about the same state as when bios.lua starts its work. so only the most basic APIs are avaible (and these are ofc sandboxed too). then i set up the other APIs inside of it. at leasts thats the plan. also i will prob add some handler based event system.
</EDIT>
Sammich Lord #15
Posted 14 November 2012 - 09:31 AM
its like with fml. fml can load modloader mods but you can use fml to make it much fancier. fml = KilOS, modloader = CraftOS

Also i'll sandbox os.loadAPI(so i overwrite it)

<EDIT>
Actually when i init the sandbox and call the first function inside it will have about the same state as when bios.lua starts its work. so only the most basic APIs are avaible (and these are ofc sandboxed too). then i set up the other APIs inside of it. at leasts thats the plan. also i will prob add some handler based event system.
</EDIT>
When you said "FML" I thought you meant "Fuck My Life", then I realize you were talking about Forge. So, is this going to have the standard "1, 2, 4" Linux perm system? I was going to work on something very similar to this.
Kilobyte #16
Posted 14 November 2012 - 10:15 AM
yes, it will have. also just added basic sandboxing (as of Pre-Alpha 2.2)
Kilobyte #17
Posted 15 November 2012 - 11:27 AM
hey, everyone who is interested in dev builds heres our official GIT repo: https://bitbucket.or...obyte/kilos/src

current new features: some bug fixes, update now supports some params. (type update –help to see a list)

also you may post any bugs and suggestions on the issue tracker

EDIT: YAAAAAAAAAAAAAAAAAAAAAAAAAAAY 50th post - now i'm a script kiddie :P/>/> </offtopic>
Sammich Lord #18
Posted 15 November 2012 - 03:28 PM
I like how everything acts like a Linux terminal! Keep up the good work! This is actually one of the only true OS's on the forums. You obviously put a lot of work into it.
Kilobyte #19
Posted 16 November 2012 - 02:32 AM
i can just thank again for all the good feedback :P/>/>

but really i stared like monday(its thursday now) and it is only like 5-10 % done yet. so yeah expect A LOT more. also feature requests are welcomed
Kilobyte #20
Posted 16 November 2012 - 10:18 AM
Ok, finally, Next release of KilOS!
just grab it as new copy or with the updater

changelog is pretty long this time so make sure to don't miss anything :P/>/>
and yes, KilOS is getting more awesome with almost every version imo :)/>/>
Kilobyte #21
Posted 17 November 2012 - 11:42 AM
Ok, just noticed a crashbug when running a non-existent program on shell :)/>/>
we are working on it.
Kilobyte #22
Posted 18 November 2012 - 09:16 PM
Ok, guys,
Fixed the issue along with a few others. This is currently NOT in the public release. And its not in the dev Build either. you need to grabg yourself a copy from the GIT repository (linked in first post). i plan on releasing it later though, after we've done more testing
oneru #23
Posted 24 November 2012 - 12:40 AM
Created an account to tell you that this is really epic looking. and to share a few thoughts

A few thoughts: You are obviously mimicking Linux (unix type os, if you want to nitpick), which is great. That said, why are the commands not passwd and useradd?

As far as the multitasking goes, you should use the gnu screen setup and shortcuts. Ctrl + a and then c to create a new term, ctrl + a, n to switch to the next, etc.

A telnet program that actually works connecting to the outside would be amazing (I may try to hack this one together myself) Is there a way to tie into your os so a telnet program would work from one computer to another in game, too?

Another thought, as nifty as the cc licenses are, would the gpl v2 or v3 be better for this project?

Anyway, awesome looking work. I look forward to the future progress, and hacking on it as well, if I have time. (Yay for learning Lua )
Sammich Lord #24
Posted 24 November 2012 - 01:38 AM
You should add the ability to give users root access. Also, it is a good idea for some commands to need root access for security reasons. Such as "sudo update".
Kilobyte #25
Posted 02 December 2012 - 05:01 AM
Created an account to tell you that this is really epic looking. and to share a few thoughts
Thanks dude
A few thoughts: You are obviously mimicking Linux (unix type os, if you want to nitpick), which is great. That said, why are the commands not passwd and useradd?
ummm… dunno might change or add aliases
As far as the multitasking goes, you should use the gnu screen setup and shortcuts. Ctrl + a and then c to create a new term, ctrl + a, n to switch to the next, etc.
CC can't track simutaneously keystrokes :(/> might make it like in edit though once i get windowinfg working
A telnet program that actually works connecting to the outside would be amazing (I may try to hack this one together myself) Is there a way to tie into your os so a telnet program would work from one computer to another in game, too?
Had that idea too already
Another thought, as nifty as the cc licenses are, would the gpl v2 or v3 be better for this project?

Anyway, awesome looking work. I look forward to the future progress, and hacking on it as well, if I have time. (Yay for learning Lua )
I *might*, but i kinda like creative commons


You should add the ability to give users root access. Also, it is a good idea for some commands to need root access for security reasons. Such as "sudo update".
sudo is comimg
also once i get file access restrictions going install will require root perms because it changes system files
yaaay #26
Posted 03 December 2012 - 12:34 AM
I Want to help you for multi-language(Not Code but text)
I Can Do Chinese
Can U Give me a list of text?
makerimages #27
Posted 03 December 2012 - 12:51 AM
I could help out with estonian.
Kilobyte #28
Posted 07 December 2012 - 04:47 AM
I Want to help you for multi-language(Not Code but text)
I Can Do Chinese
Can U Give me a list of text?

I could help out with estonian.
Guys, awesome, but i dunno if the computers like chineese that much… i'll add the hooks for language support very soon. well like i said, i lack the time right now due to a lot of tests for school. this should be done not that long time away though :)/>


Kilobyte (aka Stiepen) I love you!

this thing is just AWESOME!
Thanks dude :)/>
CoolisTheName007 #29
Posted 07 December 2012 - 08:03 AM
This seems very interesting, and since I'm actually working on multitasking/networking(sockets…routing), I would be able to adapt to your needs.
I've done some code that might interest you, but if it doesn't, I would love some feedback so I can improve. If that's ok.
-loadreq: like Lua's require. I recently changed it so that you can customize behavior based on extensions. If you filter file access based on overwriting the fs API, it will work.
-luasched port: a port of a multitasking framework. locks, pipes, timers, ect. Currently under heavy changes, as I'm trying to merge the improvements of another framework based on luasched, Lumen. So you probably wouldn't want to use it now, but I could take in consideration KilOS needs.
Kilobyte #30
Posted 08 December 2012 - 01:52 AM
This seems very interesting, and since I'm actually working on multitasking/networking(sockets…routing), I would be able to adapt to your needs.
I've done some code that might interest you, but if it doesn't, I would love some feedback so I can improve. If that's ok.
-loadreq: like Lua's require. I recently changed it so that you can customize behavior based on extensions. If you filter file access based on overwriting the fs API, it will work.
-luasched port: a port of a multitasking framework. locks, pipes, timers, ect. Currently under heavy changes, as I'm trying to merge the improvements of another framework based on luasched, Lumen. So you probably wouldn't want to use it now, but I could take in consideration KilOS needs.
Wow that sounds really nice! actually i was planning to add sockets and require. my idea is that i have a libpath environment var that will contain paths to all API dirs. If you want to talk to me more direct you might wanna come to #KilOS on irc.esper.net. (link to webchat should be in OP in case you never used IRC before :)/>) I'd really appreciate help.

Additional thoughts (not sure if i'll ad most of them):
i might rework all the apis to make coding more efficient but then i'd need to add a comatibility mode for other programs… well we'll see. My thoughts are a handler-based event system, streams (like stdout, stdin and stderr) for console interaction (they are different to curent version in the matter that they can only transport characters, no other information) and a window api to draw windows (windows support everything what you can do using term and print/write/read currently).
another thing is that i might support remapping of peripherals: you access a peripheral on left side, but in reality its on right side) or what is even better: you can specify the side "modem" and it will adress the modem on the left side (you'd need to remap modem to left before though). this will also become handy with cccables.
And last, but not least i will add peripheral.search(). example: you wanna use a peripheral but you don't know which side its on. for example a modem. just use side=peripheral.search("modem") then. the best part will be though that it will also detect peripherals attached to cccables :)/> (i use this addon on the server i'm on and i'm pissed of because edit doesn't recognize priters attached via a peripheral cable :/).

so yeah prepare for a lot more awesomeness
CoolisTheName007 #31
Posted 08 December 2012 - 03:20 AM
snip

Regarding the i'm-in-a-hurry post: Hey, no worries. I prefer to take projects slowly but safely to a success.

Regarding esper.net: I will try to find you there, but no guarantees!

Regarding libpath: loadreq has a var paths, which is like the described libpath; if you already have a sand-boxing function like protect(), you can protect that var, that the user and programs will still be able to override it without overwriting it.
Protecting files implies that calls to fs.open(arbitrary string) must be dealt with by overwriting fs or supplying a replacement for fs, which will automatically make loadreq sandbox safe.

Regarding multitasking: luasched uses an event handler. In order to sandbox what tasks can do, I will have to think a little.

Regarding remaping peripherals: we could use sockets for that: each peripheral gets it's socket. Then it will be easier to redirect sockets over cables/rednet.
Kilobyte #32
Posted 11 December 2012 - 12:12 AM
also nice ideas :P/>
yeah was just dumping the ideas from over a week without much filtering

Regarding language support: i started some work, not working too well yet though :P/>

(it crashes after login, lang api seems to not get loaded :/)
Kilobyte #33
Posted 26 December 2012 - 12:37 AM
Ok, guys Language support is done for a big chunk. I will now send out a few pms to the persons who offered to make language files. also i will update the git repo. current supported languages are English and German.

Whoever wants to check the stuff out run devupdate on a computer with KilOS.

EDIT: PMs are sent and Repo is up-to-date
yaaay #34
Posted 06 January 2013 - 02:23 AM
Ok, guys Language support is done for a big chunk. I will now send out a few pms to the persons who offered to make language files. also i will update the git repo. current supported languages are English and German.

Whoever wants to check the stuff out run devupdate on a computer with KilOS.

EDIT: PMs are sent and Repo is up-to-date

chinese has loads of characters…nearly 20 thousand?
Kilobyte #35
Posted 13 January 2013 - 01:34 PM
wow, thats a lot :P/>
1lann #36
Posted 13 January 2013 - 09:02 PM
CC only supports standard ascii. That means you can't do any non english characters. However you can do pinyin (using the tone system where the tone number goes at the end) but it would be ridiculously long.
superaxander #37
Posted 05 March 2013 - 07:16 PM
What you still don't have a +1
It's coming now!
NeptunasLT #38
Posted 05 March 2013 - 07:21 PM
This is like linux terminal.
Can i code new OS in this KilOS?
Kilobyte #39
Posted 16 March 2013 - 09:07 AM
This is like linux terminal.
Can i code new OS in this KilOS?
Ofc you can, i don't recommend it though at this point. see more below
What you still don't have a +1
It's coming now!
yay, thanks

ok, now for the content i actually wanted to post:
I am working on an entire rewrite. its probably like 30% done at this point but yeah, here the repo link: https://bitbucket.org/Kilobyte/kilos-new/src USE ON YOUR OWN RISK. IT IS IN NO WAY STABLE, basicly: don't use it unless you know what you do for now. also, KilOS will no longer maintain CraftOS compatibility. there will be an emulator at some point. if anyone wants to help, just ask me on espernet (you can catch me in #KilOS or #ThermalExpansion)
thegreatstudio #40
Posted 16 March 2013 - 04:08 PM
You recently copy debian and then make it lua.
willwac #41
Posted 10 September 2013 - 06:52 PM
Will you make a program called logout.lua that, when run will take you back to the login screen?
Lyqyd #42
Posted 10 September 2013 - 09:36 PM
This is pretty much dead, I think. Locked.

OP, report the topic if you're still working on this.