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

cLinux [now with OPTIONAL Desktop Enviroment] [Bye CraftOS, kappa]

Started by Piorjade, 17 September 2016 - 09:57 AM
Piorjade #1
Posted 17 September 2016 - 11:57 AM
cLinux, secure freedom.


Made by:
  • Piorjade
  • thecrimulo
(Current state of usability: you are able to fully use it with external programs (NOTE: programs that use the FS API inside forbidden folders will crash and display an error, use sudo or log in as root to use them, or at best (if the program has the path set as string somewhere at the top) change the path to an allowed one, please :)/>/> ) )

Join our Gitter! : https://gitter.im/cL...aign=share-link

The idea:
Spoiler
  • recreate the look of the Linux terminal
  • only allow the root to edit stuff in sensitive places
  • rewrite fs.open (and probably other functions, which could harm the OS) to only edit in allowed places, IF the user is not root
  • commands are (like in linux and CraftOS) extra files saved in /bin/
  • use 'packman' as something like 'apt-get'
  • give the user(s) the ability to add their own Desktop-Enviroment (basically like a plugin, the DE will then have the basic functions of the OS in _G (more down below)
How you may use it:
Spoiler
  • Use it with the commandline, stock.
  • Use it with the doorX DE (read more down below on how to install it and the extra steps, specific for doorX)
  • Build your own DE
  • Build your OS ontop of it (would be nice if you'd give me credit for the "kernel" )
  • Mess around with it (and maybe report any bugs)
  • other things I currently don't know of
Current functions:
Spoiler
  • if the user is in "/home/[NAME]" (or something like /home/[NAME]/my/directory), the "/home/[NAME]/" will be cut to "~" and shows for example: "~/my/directory" –> this is to prevent having less space to write a command
  • each user gets a dedicated home directory (currently I did NOT implement a way to create a second user)
  • only the root is allowed to edit stuff in /boot, /vit, /bin, /sys and edit the /startup. In every other folder, the user has access too, as that doesn't affect the system
  • basic commands are added: ls, mkdir, cd, clear, rm, edit
  • 'packman' IS added and works, but you need to run as root (or sudo)
  • you can add in your own library (put them in /lib), but they work different than os.loadAPI:
    • example:
    • 
      --myAPI
      function testfunc()
        print("Hello there")
      end
      
      _putLib('testfunc', testfunc)
      --OR--
      _put('testfunc', testfunc)
      
    • _putLib(name, function) puts a function into _G.lib.NAME()
    • _put(name, function) puts a function into _G.NAME()
  • (You can still use os.loadAPI, the automatic libloading system wont work on a normal API if you put it in /lib tho)
  • Log-In as root (password: toor)
  • give temporarely rootaccess to a program with "sudo"
  • EDITED/LIMITED FS API = These functions of the fs API are limited, if not logged in as root:
    • fs.open(path, mode):
      • mode "r" = allowed to ANYONE
      • mode "br" = allowed to ANYONE
      • mode "a" = only allowed to "root" IF the file is located in {"/boot", "/vit", "/bin", "/startup", "/sys"}
      • mode "w" = only allowed to "root" IF the file is located in {"/boot", "/vit", "/bin", "/startup", "/sys"}
      • mode "bw" = only allowed to "root" IF the file is located in {"/boot", "/vit", "/bin", "/startup", "/sys"}
    • fs.makeDir(path):
      • only allowed to "root" IF the file is located in {"/boot", "/vit", "/bin", "/startup", "/sys"}
    • fs.move(oldPath, newPath):
      • only allowed to "root" IF one of the paths is located in {"/boot", "/vit", "/bin", "/startup", "/sys"}
    • fs.copy(oldPath, newPath):
      • only allowed to "root" IF the newPath is located in {"/boot", "/vit", "/bin", "/startup", "/sys"}
    • and finally fs.delete(path):
      • only allowed to "root" IF the file is located in {"/boot", "/vit", "/bin", "/startup", "/sys"}
  • Run something else instead of the commandline! (maybe interesting for running servers on computers or starting a Desktop Enviroment (scroll down to see how to install my DE))
    • use "service core <path or name of service in /etc/services.d>" to set a main service.
    • "service enable / disable <path or name of service>" to enable/disable services aside from the main one (–> they start at boot)
    • "service start <full path>" start a program as a service for the current session
    • "service stop <full path>" stop a program, which is running as a service (yes, you can stop services, which have been started at boot, too, you need to full path tho)
  • Commandline:
    • Customize the colors of the commandline using the file .bashcol in your home directory!
      • EXAMPLE:
      • 
        
        {
        mainBg = 1,
        mainFg = 32768,
        middleBg = 1,
        middleFg = 32768,
        pathBg = 1,
        userBg = 1,
        userFg = 16384,
        }
        This sets the commandline to white background and black text
      • What values you can edit:
        • middleBg and middleFg (the @ at between the current user and the path)
        • userBg and userFg (the username)
        • pathBg and pathFg (the path)
        • mainBg and mainFg (the commandline at itself)
      • The file HAS TO use the table-scheme
    • Set aliases for programs!
      • EXAMPLE:
      • 
        {
          dir = "/bin/ls"
        }
        
        This sets the command "dir" to be the same as "ls"
      • The file HAS TO use the table-scheme
Planned functions:
Spoiler
  • log in as root (default password will be toor, you will have to change that as normal user with a command, located in /usr/bin) <—- 50 % done :)/>/>, already DONE in doorX
  • edit / add stuff under home as root (this is BASICALLY already implemented, you can't log in as root though) <– Done :)/>/>/>/>/>
  • give the ability to edit files (I need to think of what I should use…. normal edit, homemade editor (probably a copy of nano) or something like LuaIDE) DONE :)/>/>
  • give the ability to run programs, which are not located in /usr/bin (e.g. : you are in home and there is a file called 'runme', you would just write 'runme' and it starts with limited access to the FS if you aren't root) DONE :)/>/>
  • completely implement the option to run a DE at startup DONE :)/>/> , run the DE as a core service
  • start a script automatically, if it has a specific script (I think I will use /home/[name]/autorun for that)
Current functions/variables in _G:
Spoiler
  • Every library in ("/lib") IF it is coded in my valid way (look above)
NOTE (about programs that use the ShellAPI, for example shell.run() )
THIS OS HAS SHELL DUMMIES NOW:
Ok, but which do not and will not (probably ever, as I don't want to) work? :
  • shell tabs = they all return nil, for the sake of not crashing most of the programs instantly, some will still tho
  • NOTE: shell.complete does not return the last commands, will add that later but for now it does autocomplete
All the other Shell function should work as expected, I CANNOT guarantee you that. (BTW if you use shell.run, the FS API is STILL limited, AND NOONE (not even root) IS ALLOWED TO RUN PROGRAMS IN /rom/programs/ ! Why? simply because I intended to use this OS as a replacement of CraftOS, not having it ontop of it. If you want everything from CraftOS available to you, then please look at other OSes (or my doorOS, if you want))

Changelog:
Spoiler
  • 09/17/2016: initial release on GitHub &amp; Pastebin
  • 09/18/2016:
    • Added the ability to login as root: name: "root" password: "toor"
    • reworked FS system: fs.open, delete, move, copy, makeDir are LIMITED, if the user is NOT root
    • made the system safer: if the user is not root and wants to edit _G.currentUsr to root (via external program) and then tries to run some of the limited FS functions, the functions automatically check if the user has the correct password entered in _G.currentPw (so you basically HAVE to log in root, except you try to edit the _G.currentPw too… but that is really safe enough
    • fixed mkdir
    • fixed cd
    • added "rm" (you know what that is)
  • 09/19/2016 (by Anavrins):
    • Fixed how the BLAKE-256 API is used in passwords, so that older CC versions won't crash. (Thanks to Avavrins for making a pull request, but I will also look into his SHA-256 API, which is, as he says, more suitable for my password storage. :)/>/>/>/>)
    • Removed BLAKE-256 and added SHA-256, made by the same person (Anavrins)
    • A big thanks to the people, who helped me in ask a pro about sandboxing enviroments, especially Sewbacca. He showed me a code, which gives me the ability to restrict a normal user rootaccess without a password. Before he gave me the code, it was already implemented BUT if programs had replaced fs.open or even _G.currentUsr / _G.currentPw, meaning that they
    • would grant every next program rootaccess. He even tried to explain metatables to me a bit :)/>/>/>/>
    • Added "sudo" in. You basically have to enter the root password and the program gets temporarely rootaccess (until the program crashes / exits)
  • 09/20/2016 (completely alone and a bit of help by Sewbacca):
    • REWORKED INSTALLER: This doesn't use a compiled cLinux (made by my MSI-Maker), it uses apemanzilla's git-get now! (Thx, thecrimulo for merging stuff into the GitHub recently :)/>/> )
    • REWORKED ROOTCHECK AND FS API:MAJOR: Added-in Shell API dummies:
      • If the user is NOT root and uses something like fs.delete("/startup"), the FS API REDIRECTS "/" to —> "/usr/[YOURNAME]/home/" meaning that the outcome would be –> fs.delete("/usr/[YOURNAME]/home/startup"), I'd like to hear an opinion of you guys if I should keep that (would probably prevent programs from crashing), or returning to the old system –> returns an error if user tries to edit outside of home
      • The rootcheck is now built INTO the OS, it is no longer inside the FS API (this prevents the user from using programs to get rootaccess)
      • (In theory you could rewrite the FS API again inside your program, but that will always be possible, BUT you don't have the ability anymore to somehow get the original FS API)
      • shell.run(path) = works as expected BUT you are not allowed to run programs in /rom/ (I couldn't test much, I only made a dummy file which executed another one, because I don't have time for now)
      • shell.path() = works as expected (returns the path of the program you ran originally, OR the path of the program you ran with shell.run() )
      • shell.setPath() = SHOULD work (I've just realized that I didn't test this one lol)
      • shell.exit() = just returns, basically the original program, which called shell.run, is running again
      • shell.resolve(foldername/filename in your current directory) = should work as expected
      • shell.resolveProgram(program name) = should work as expected + lists programs in /usr/bin too
      • shell.aliases() = This one simulates the aliases table AS LONG AS THE ORIGINAL PROGRAM RUNS (because every shell API function gets reset after a new program starts)
      • shell.setAlias(alias, program) = Inserts into the simulated aliases table
      • shell.clearAlias(alias) = Removes from the simulated table
      • shell.programs(true/false) = Returns a table of the files in /rom/programs AND /usr/bin (+ the hidden ones, if true is entered)
      • shell.getRunningProgram() = works
      • shell.openTab(), switchTab() = doesn't work, just returns — NOTE: I won't add them, as that would destroy my future plans for multitasking
      • shell.complete() = the same as above, returns a empty table
      • shell.completeProgram(prefix) = works, returns a table with every program name containing that prefix (IN /usr/bin/ ONLY)
      • shell.setCompletionFunction() = doesn't work, returns false
      • shell.getCompletionInfo() = doesn't work, returns nil
    • ALMOST FINISHED: Something like a bluescreen, which shows the error of the os.lua, if it crashes
    • MINOR:
      • The user is now able to run programs, which are not located in /usr/bin (the #1 priority is the program in your location.)
  • 09/21/2016:
    • Fixed many bugs
    • Added in bluescreen of death (well I don't know how to trigger it now, as I didn't found ANY code issues and programs can't trigger it, BUT it works)
    • Added, but not used yet: Windowmanager ("/sys/API/wm") and Taskmanager ("/sys/API/tasks") (I guess they are documented enoug, as they aren't really something incredible)
  • 10/14/2016: (BIG REWRITE!)
    • Rewrote the system from scratch, with some help coming from thecrimulo
    • Made the system as modular as I could
    • 2 Layers of built in task-managers (1 restricted, 1 kinda accessable):
      • TLCO Level: Not accessable, starts the /boot/load file and /vit/alive, which restarts the system if something goes wrong
      • service level / shell.lua level: Half-accessable: You can have services (basically programs) in /etc/services.d/ and enable or disable them in /etc/services.conf (NOTE: services.l (/lib/services.l) updates the config everytime on boot, it inserts services from /etc/services.d into the config, which are not yet in there, and disables them)
        • services.conf NEEDS a service with "core" as it's value, as it will be the "front" of all the services. IF that service is stopped, the os should try to restart. (That's why it says ["/sys/cmdbak"] = "core")
        • It is NOT recommended to have more than ONE service as core, as I think it would mess up the windows and you don't want that…
        • To start a file as a service for the current session: shell.startServ(pathToFile[, table with arguments])
        • To stop a service (you need to know the path of the file, which is running): shell.stopServ(path)
        • To add a file into the service list or enable / disable / set a service as core: lib.serv.set( <pathToFile | nameOfServiceInServices.d> <true | false | "core" >
        • To get a list of all services in the config in form of a table: lib.serv.giveList() (it returns the table)
        • NOTE: Services don't have access directly access to the servicelayer, these functions above are the only one interacting with them and please if you find a way to interact with the servicelist and manage to do something that is not intended, write it down so I can fix it
      • The 3rd is totally optional, as you'd have to implement your own as a library or hardcode it in your files (/sys/cmdbak has it's own version of sThread.l, for example)
    • CommandLine is optional, as you can add a DE as a service and disable CommandLine. ( I'll consider making a DE later)
    • Shell dummies are better now (tho things like autocompletion are straight copied over and tabs do and will not work, I don't want that)
    • CommandLine:
      • Background/Foreground processes:
        • To start a process in the background: (–> runs at the same time as commandline and doesn't affect it, except writing on the screen) [sudo] bg <command/pathToFile> <…>
        • To start a process in the foreground: (–> commandline is paused until it crashes or finishes) [sudo] <command/pathToFile> <…>
      • Kill processes:
        • View the list of processes with: ps
        • To kill a process: kill <UID>
    • Will add more points l8er, don't have time now…
  • 10/15/2016:
    • Polished packman and added in a clinux repository, where tested programs (and maybe fixed) will be added in
      • Currently in the repo:
        • edit (the vanilla one)
        • luaide (works flawless, of course opening files in forbidden places crashes the app)
    • Fixed bugs with the CommandLine:
      • Fixed a bug where arguments could have things like : "/&amp;#46;&amp;#46;/////&amp;#46;&amp;#46;/" , etc.
      • Commands and arguments aren't allowed to have more than one "/" in a row and having more than ".." in an argument at the same time is also forbidden
        • Example: cd &amp;#46;&amp;#46;/ –> doesnt work
        • cd // –> doesnt work
        • cd /home/&amp;#46;&amp;#46;/ –> doesnt work
        • cd /home// –> doesnt work
        • etc.
  • 10/16/2016:
    • Fixed many bugs
    • Fixed even more bugs
    • Almost broke my table while fixing os.loadAPI()
    • Noticed that I didn't update os.unloadAPI, don't have the time anymore
    • HUGE ADD-ON (which is optional, cuz it has a problem):
      • OPTIONAL Desktop Enviroment:
        • ported the doorOS3.0 Desktop Enviroment over
        • with cLinux together, it is big AS F*CK
        • you need to expand the available space for computers to install it
        • Commands to install it:
        • 
          > sudo packman install doorx
          > InstallDoorX
          > service core /doorOS/sys/os.lua
          
    • Added in a new flag for GRUB:
      • text = ignores the services.conf and boots cmdbak (Command Line)
  • <some updates I probably forgot to write here>
  • 02/04/2017:
    • Added commandline color customization:
      • Create the file .bashcol in your home directory
      • Example:
      • 
        {
        mainBg = 1,
        mainFg = 32768,
        middleBg = 1,
        middleFg = 32768,
        pathBg = 1,
        userBg = 1,
        userFg = 16384,
        }
        This example makes the commandline user black text and white background (NOTE: the command/file "clear" still clears in black)
    • Added program aliases:
      • Make the file .aliases in your home directory
      • EXAMPLE:
      • 
        {
          dir = "/bin/ls"
        }
        
        This adds the command "dir" to be the same as "ls"
    • Both of these things are on user basis, so it's the same as setting aliases in .bashrc for example (real Linux)
    • Things that you can modify in .bashcol:
      • middleBg and middleFg (the @ at between the current user and the path)
      • userBg and userFg (the username)
      • pathBg and pathFg (the path)
      • mainBg and mainFg (the commandline at itself)
    • .aliases has to use full paths!
    • The .bashcol file normally HAS TO use the decimal values for colors, EXCEPT when having a custom library in /lib/
    • Both of these files also HAVE TO use the table-scheme
  • 02/10/2017:
    • Fixed bug with permission API
    • Fixed bug with shell API (setDir especially)
    • Fixed bug with rm
    • Fixed bug with mkdir
    • Fixed bug with cd
  • 04/26/2017:
    • Added addusr (–> syntax: addusr <name> <password>; doesn't need root privileges)
    • Added rmusr (–> syntax: rmusr <name>; DOES need root privileges)
    • Fixed some bugs with the perm library
    • As always, you should be good with launching
      sudo UpdateCLinux
  • 05/08/2017:
    • Changed 'rmusr' to 'delusr' (Thank you Redall!)

Screenshots:
Spoiler[attachment=2673:Capture.PNG]
[attachment=2678:InstallingDE.PNG]
[attachment=2674:page1.PNG]
[attachment=2675:2.PNG]
[attachment=2676:3.PNG]
[attachment=2677:4.PNG]

How to get it:
pastebin run d6fC8hBd 

How to get the doorX Desktop Enviroment (maybe a problem for people on public servers..):
Spoiler
  • There is one problem in CC that affects my DE: space.
    • You will need to expand the available space for computers (%appdata%/.minecraft/config/ComputerCraft.cfg > I:computerSpaceLimit=999999999, for example)
    • If you play on a server, the server owner needs to do that
  • And here is a command tutorial to install the DE:
  • 
    > sudo packman fetch
    > sudo packman install doorx
    > InstallDoorX
    > service core /doorOS/sys/os.lua
    
  • Then reboot
  • To run cLinux in commandline mode, without going to /etc/services.conf, enter "text" as a bootflag in GRUB (select clinux.i > press E > enter "text" (without ") > enter
  • To disable the DE completely and set commandline back:
  • 
    > service core /sys/cmdbak
    


Where is the code? :
https://github.com/Piorjade/cLinux

Credits:
Anavrins - For SHA-256 &amp; contributing in GitHub :3
Lyqyd - For packman
apemanzilla - For gitget (the installer)
Nevercast (&amp; me) - For Top Level Coroutine Override
Sewbacca - For various things and mainly this till' now
thecrimulo - Mainly for contributing in GitHub :)/>/>/>

Funfact:
I did this because I love Linux and finally completely destroyed my Windows 10 partition and installed Manjaro on it <3
Edited on 08 May 2017 - 10:02 AM
Piorjade #2
Posted 18 September 2016 - 09:07 PM
UPDATE

Spoiler

09/18/2016:
  • Added the ability to login as root: name: "root" password: "toor"
  • reworked FS system: fs.open, delete, move, copy, makeDir are LIMITED, if the user is NOT root
  • made the system safer: if the user is not root and wants to edit _G.currentUsr to root (via external program) and then tries to run some of the limited FS functions, the functions automatically check if the user has the correct password entered in _G.currentPw (so you basically HAVE to log in root, except you try to edit the _G.currentPw too… but that is really safe enough
  • fixed mkdir
  • fixed cd
  • added "rm" (you know what that is)
Edited on 15 October 2016 - 09:24 PM
thecrimulo #3
Posted 18 September 2016 - 11:08 PM
Okay:
I'd just like to interject for a moment, no, I am not goint to give you the GNU/Linux speech, but I have some things to say.

1) "only allow the root to edit stuff under the user/[NAME]/home/ directory"
This is the root user and I can't find the reason why would you block it from going outside, when the main reason of the root account is to modify all the system and hence why it's not a common user, and programs like apt need to run as SU.
2) "rewrite fs.open (and probably other functions, which could harm the OS) to only edit in the homedirectory, IF the logged-in user is not root (basically "emulate" the root directory"
Here I am assuming you want to make a permission and user system, which is fine, and I am doing it too in an OS I'm also developing, more carefully.
But, I think its incorrect to say you are "emulating the root directory".
3) "commands are (like in linux and CraftOS) extra files saved in /usr/bin"
This is less of an issue, but there are also binaries that are included in the system and make it unusable if they didn't come preinstalled, I am referring to commands like cd, rm or edit.
4)
If you use a program, which uses the shell API (for example, shell.run), it will give an error!!!
Why?
Well basically I use the fixed TopLevelCoroutineOverride, to completely disable Shell and start my OS as the top-coroutine, which means Shell is NOT loaded and you can't use it's functions.
Well here we got something simple, but mind that if you are nulling the shell (and multishell), you have to get replacements for the help functions, autocomplete functions, path functions and others. There is no problem on the TLCO. Buuut there is something wrong here: If you are doing a TLCO that makes you, want it or not, disable the shell (which is a program), and you are suggesting to load it with loadAPI, but 1st, the TLCO can broke, 2nd the shell will bypass the security and 3rd it is not a library.
5) Making evident the variables where the current user and (hashed and salted) password are, can just cause a simple security bypass.
6) You are implementing an user and permission system, but you can't make other users. This is undone, clearly, but I'd suggest finishing the systems, libraries and binaries after allocating the userspace.

I am making an OS, which is more advanced than this, replacing all libraries and binaries, making it crash when trying to run programs or libraries in /rom/*, (deprecating everything in rom, only useful for making the new libraries). If you need help, you can PM me, tho my holidays ended and I'll not be very active. Anyways I offer my help.

I hope I didn't make you feel bad or something, it wasn't my intention.
~ Dael
Piorjade #4
Posted 19 September 2016 - 12:40 AM
1. By emulating root I actually meant that I'm PLANNING to redirect fs.open("/blah") to fs.open("[myhome]/blah"), thats why the title also says WIP
2. As it says WIP, multiuser creation is yet not implemented
3. As stated in my post, I THOUGHT loading shell as an API would work but I didn't test it and I have to look into it's code to see how it could potentially harm the system. (but I don't recommend programmers using this OS to use any shell commands cuz the main reason of this is to REPLACE shell)
4. The normal user CAN get out of it's home but in read-only mode (I'm thinking of adding the sudo command, which will ask for the root password)
5. I don't know if we are misunderstanding each other but by saying editing 'under the homedir' I actually mean adding files, editing files, creating folders, etc. in folders like /usr/ oder / or anything thats 'under' the logged users' home, meaning that you need to be root / use sudo to do this and to use packman because they are editing files under home and you could potentially harm the OS with that, you know what I mean?
6. Sorry for not writing this in the topic but I actually stored these variables temporarely there. As you stated, having cd and basic stuff as extra file could also be pre-installed, that's actually my next step to prevent saving these variables globally :P/>

So all in one:
I got NO problem with your post here , but I think you didn't see that many things are not implemented yet and have many 'securityholes', which I know of myself.
And thank you for reply :D/>

NOTE: The 'endproduct' will be WAY more secure than that. And I made basic commands as extra files because I could then program them without restarting the whole computer all the time, because I am lazy AF :P/>

EDIT: Btw yeah I also plan to implement autocompletion
And by path functions, do you mean something like shell.setPath()? If yes, in the current state you just have to edit _G.currentDir <– I can't see any reason in this state to make some kind of function, as the Terminal would probably end up being in that directory if your program edits this string…
EDIT 2: The thing is, is it really necessary to replace ALL libraries and binaries in an OS? Considering you want to have as many programs compatible as you can because lets say you replace everything which was stock and use your stuff (using TLCO to knock shell out too) and basically having the problem that some programs probably won't work, you would probably make something like Windows vs Linux where all of these lazy dudes are who don't want to switch from the stock to your libraries (Windows vs Linux is a very good example for Game-Producers heheh :P/>) and your OS will probably end up being useless cuz you can't use any external program. (Look at dem NDFJay OSes LOL)
Edited on 18 September 2016 - 11:02 PM
Anavrins #5
Posted 19 September 2016 - 04:23 AM
Hey there, just saying that blake256 is not a custom implementation of sha256, it's a completely different algorithm that was part of the sha3 competition.
Haven't looked at it in a while, and I believe my sha256 api is much more optimized than it and might be more suited for your needs if you're using it for password storage.
I also noticed a slight misuse of it in os.lua, technically it would work on newer CC versions, but would break in older ones, so I made a pull request to fix it :)/>
H4X0RZ #6
Posted 19 September 2016 - 06:32 AM
1. By emulating root I actually meant that I'm PLANNING to redirect fs.open("/blah") to fs.open("[myhome]/blah"), thats why the title also says WIP
2. As it says WIP, multiuser creation is yet not implemented
3. As stated in my post, I THOUGHT loading shell as an API would work but I didn't test it and I have to look into it's code to see how it could potentially harm the system. (but I don't recommend programmers using this OS to use any shell commands cuz the main reason of this is to REPLACE shell)
4. The normal user CAN get out of it's home but in read-only mode (I'm thinking of adding the sudo command, which will ask for the root password)
5. I don't know if we are misunderstanding each other but by saying editing 'under the homedir' I actually mean adding files, editing files, creating folders, etc. in folders like /usr/ oder / or anything thats 'under' the logged users' home, meaning that you need to be root / use sudo to do this and to use packman because they are editing files under home and you could potentially harm the OS with that, you know what I mean?
6. Sorry for not writing this in the topic but I actually stored these variables temporarely there. As you stated, having cd and basic stuff as extra file could also be pre-installed, that's actually my next step to prevent saving these variables globally :P/>/>

So all in one:
I got NO problem with your post here , but I think you didn't see that many things are not implemented yet and have many 'securityholes', which I know of myself.
And thank you for reply :D/>/>

NOTE: The 'endproduct' will be WAY more secure than that. And I made basic commands as extra files because I could then program them without restarting the whole computer all the time, because I am lazy AF :P/>/>

EDIT: Btw yeah I also plan to implement autocompletion
And by path functions, do you mean something like shell.setPath()? If yes, in the current state you just have to edit _G.currentDir <– I can't see any reason in this state to make some kind of function, as the Terminal would probably end up being in that directory if your program edits this string…
EDIT 2: The thing is, is it really necessary to replace ALL libraries and binaries in an OS? Considering you want to have as many programs compatible as you can because lets say you replace everything which was stock and use your stuff (using TLCO to knock shell out too) and basically having the problem that some programs probably won't work, you would probably make something like Windows vs Linux where all of these lazy dudes are who don't want to switch from the stock to your libraries (Windows vs Linux is a very good example for Game-Producers heheh :P/>/>) and your OS will probably end up being useless cuz you can't use any external program. (Look at dem NDFJay OSes LOL)

Isn't that exactly why we have Wine? It's a compatibility layer between Linux and Windows, giving programs access to all the windows stuff Linux doesn't have.

Sure, you don't have to add implementations of all the stock APIs you lost because of the TLCO but you would also drop support for the majority of programs. If you really have to do everything "your own way", add dummy functions for the shell API which either do nothing, or call your custom functions.
Piorjade #7
Posted 19 September 2016 - 07:02 AM
Thx Anavrins :)/>

About doing things my own way, I was actually meaning his OS idea. I won't replace every library. (right now I think only shell doesn't work) Right now I need to make, as you said, dummy functions (for programs that use things like: shell.run() )
Btw how I understand wine, isn't it porting for example the directX code into linux-executeable code "on-the-fly" ?
I guess thats why there is a bit of a performance loss and DirectX11 is still not supported. (I really would like to have my Windows games natively ported to Linux :P/> )
Edited on 19 September 2016 - 06:06 AM
Piorjade #8
Posted 19 September 2016 - 07:55 AM
Ok I merged your pull request, going to look into your suggestion about your SHA-256 API tho.
NOTE: the new version with your fix is not yet compiled into the pastebin link, going to do this after I'm back home. (or maybe I will directly implement your SHA-256 API after I'm back home :P/>)
EDIT: Wrote your name wrong LMAO
Edited on 19 September 2016 - 06:07 AM
Piorjade #9
Posted 19 September 2016 - 08:16 AM
(I added a small information about the Shell API in the topic, if something changes and the example won't work anymore, I will change the note too. To prevent confusion:
No, I didn't implement that yet and this example will be added in the OS itself, so that older programs do NOT have to update their code, thanks for reading.)
Piorjade #10
Posted 19 September 2016 - 12:25 PM
UPDATE:

Spoiler
  • Removed BLAKE-256 and added SHA-256, made by the same person (Anavrins)
thecrimulo #11
Posted 19 September 2016 - 07:50 PM
Thanks for clarifying it all, Piorjade.
Also, as for if you should replace all libraries and binaries, it really depends a lot on what are you replacing:
If you are, like me, renaming, creating and deleting functions that can't work well with the TLCO or, to keep consistency with the rest of your APIs, also for APIs
that have code that may not work on your OS. There is no need to replace libraries like the GPS, also keep in mind that you don't have to completely deprecate the APIs in /rom/, as there are functions that you cannot recreate, like the FS ones. As for the wine-like compatibility layer, you can make functions that work just as aliases, shortcuts for another function, and that "should" do the same, in case you haven't got that, It is kind of… strange, I'd say, to lose functions that worked well and people used. Then, using those functions, you can't guarantee if they will fully work, but you can improve it by testing long programs like Nevardon, LuaIDE, Discover Store and others.

Also, by the path I didn't mean the current directory, I meant where is supposed to look for the programs, like adding a directory to the Environment Path on WIndows, just like CraftOS searches for cd or rm in /rom/programs
Piorjade #12
Posted 19 September 2016 - 09:04 PM
Yeah and thank you for replying to my post, it really motivates me to continue if people reply.
Hell even some of you guys put pull requests on my GitHub and it made me really happy to see that =)

Btw

UPDATE:
Spoiler
  • A big thanks to the people, who helped me in ask a pro about sandboxing enviroments, especially Sewbacca. He showed me a code, which gives me the ability to restrict a normal user rootaccess without a password. Before he gave me the code, it was already implemented BUT if programs had replaced fs.open or even _G.currentUsr / _G.currentPw, meaning that they would grant every next program rootaccess. He even tried to explain metatables to me a bit :)/>
  • Added "sudo" in. You basically have to enter the root password and the program gets temporarely rootaccess (until the program crashes / exits)
Piorjade #13
Posted 19 September 2016 - 09:20 PM
Thanks for clarifying it all, Piorjade.
Also, as for if you should replace all libraries and binaries, it really depends a lot on what are you replacing:
If you are, like me, renaming, creating and deleting functions that can't work well with the TLCO or, to keep consistency with the rest of your APIs, also for APIs
that have code that may not work on your OS. There is no need to replace libraries like the GPS, also keep in mind that you don't have to completely deprecate the APIs in /rom/, as there are functions that you cannot recreate, like the FS ones. As for the wine-like compatibility layer, you can make functions that work just as aliases, shortcuts for another function, and that "should" do the same, in case you haven't got that, It is kind of… strange, I'd say, to lose functions that worked well and people used. Then, using those functions, you can't guarantee if they will fully work, but you can improve it by testing long programs like Nevardon, LuaIDE, Discover Store and others.

Also, by the path I didn't mean the current directory, I meant where is supposed to look for the programs, like adding a directory to the Environment Path on WIndows, just like CraftOS searches for cd or rm in /rom/programs

And about the compatibility layer: in the current state I only need a ShellAPI layer, which shouldn't be THAT hard when looking in the wiki page :)/>
Edited on 19 September 2016 - 07:21 PM
thecrimulo #14
Posted 19 September 2016 - 09:37 PM
Thanks for clarifying it all, Piorjade.
Also, as for if you should replace all libraries and binaries, it really depends a lot on what are you replacing:
If you are, like me, renaming, creating and deleting functions that can't work well with the TLCO or, to keep consistency with the rest of your APIs, also for APIs
that have code that may not work on your OS. There is no need to replace libraries like the GPS, also keep in mind that you don't have to completely deprecate the APIs in /rom/, as there are functions that you cannot recreate, like the FS ones. As for the wine-like compatibility layer, you can make functions that work just as aliases, shortcuts for another function, and that "should" do the same, in case you haven't got that, It is kind of… strange, I'd say, to lose functions that worked well and people used. Then, using those functions, you can't guarantee if they will fully work, but you can improve it by testing long programs like Nevardon, LuaIDE, Discover Store and others.

Also, by the path I didn't mean the current directory, I meant where is supposed to look for the programs, like adding a directory to the Environment Path on WIndows, just like CraftOS searches for cd or rm in /rom/programs

And about the compatibility layer: in the current state I only need a ShellAPI layer, which shouldn't be THAT hard when looking in the wiki page :)/>

Anyways, I'd suggest a new one, programs can stop working unexpectedly, this happens when, by some call, the TLCO breaks, or the program finds a flaw, or just not executing at all. Also. Thanks for the merge, I'll keep contributing ;)/>
Piorjade #15
Posted 19 September 2016 - 09:59 PM
Thanks for clarifying it all, Piorjade.
Also, as for if you should replace all libraries and binaries, it really depends a lot on what are you replacing:
If you are, like me, renaming, creating and deleting functions that can't work well with the TLCO or, to keep consistency with the rest of your APIs, also for APIs
that have code that may not work on your OS. There is no need to replace libraries like the GPS, also keep in mind that you don't have to completely deprecate the APIs in /rom/, as there are functions that you cannot recreate, like the FS ones. As for the wine-like compatibility layer, you can make functions that work just as aliases, shortcuts for another function, and that "should" do the same, in case you haven't got that, It is kind of… strange, I'd say, to lose functions that worked well and people used. Then, using those functions, you can't guarantee if they will fully work, but you can improve it by testing long programs like Nevardon, LuaIDE, Discover Store and others.

Also, by the path I didn't mean the current directory, I meant where is supposed to look for the programs, like adding a directory to the Environment Path on WIndows, just like CraftOS searches for cd or rm in /rom/programs

And about the compatibility layer: in the current state I only need a ShellAPI layer, which shouldn't be THAT hard when looking in the wiki page :)/>

Anyways, I'd suggest a new one, programs can stop working unexpectedly, this happens when, by some call, the TLCO breaks, or the program finds a flaw, or just not executing at all. Also. Thanks for the merge, I'll keep contributing ;)/>

I'll always accept merges, if they fix something or add something useful ;)/>
Piorjade #16
Posted 19 September 2016 - 10:16 PM
OFFTOPIC:
Is it the real life syndrome where noone likes Linux or why do I still have only about 200 views on this?
But nvm I guess because these people who clicked on this were interested in this and I'm really grateful to them :)/>
thecrimulo #17
Posted 19 September 2016 - 10:22 PM
OFFTOPIC:
Is it the real life syndrome where noone likes Linux or why do I still have only about 200 views on this?
But nvm I guess because these people who clicked on this were interested in this and I'm really grateful to them :)/>
Have to say, lately the OS sections have been bloated with… flawful, incomplete, or not OSes at all, I think we need something new and better.
Piorjade #18
Posted 19 September 2016 - 10:52 PM
OFFTOPIC:
Is it the real life syndrome where noone likes Linux or why do I still have only about 200 views on this?
But nvm I guess because these people who clicked on this were interested in this and I'm really grateful to them :)/>/>
Have to say, lately the OS sections have been bloated with… flawful, incomplete, or not OSes at all, I think we need something new and better.

True, what do you think about this tho?
(And until now there haven't been REAL OSes I think but at least external program support has to be implemented, which it isn't in these NDFJay clones)

Btw:
#merged and ty for the installer
Cannot access my PC right now so I tried to copy the code over to pastebin with my phone. ( d6fC8hBd )
Could you test it out?
thecrimulo #19
Posted 19 September 2016 - 10:59 PM
I'll try tomorrow, turns out that is late and I have school. I will get back 8pm or so, spain time.
You welcome, and Cya
Piorjade #20
Posted 19 September 2016 - 11:01 PM
K cya
Piorjade #21
Posted 20 September 2016 - 08:53 PM
UPDATE:

Spoiler
  • REWORKED INSTALLER: This doesn't use a compiled cLinux (made by my MSI-Maker), it uses apemanzilla's git-get now! (Thx, thecrimulo for merging stuff into the GitHub recently :)/> )
  • REWORKED ROOTCHECK AND FS API:
    • If the user is NOT root and uses something like fs.delete("/startup"), the FS API REDIRECTS "/" to —> "/usr/[YOURNAME]/home/" meaning that the outcome would be –> fs.delete("/usr/[YOURNAME]/home/startup"), I'd like to hear an opinion of you guys if I should keep that (would probably prevent programs from crashing), or returning to the old system –> returns an error if user tries to edit outside of home
    • The rootcheck is now built INTO the OS, it is no longer inside the FS API (this prevents the user from using programs to get rootaccess)
    • (In theory you could rewrite the FS API again inside your program, but that will always be possible, BUT you don't have the ability anymore to somehow get the original FS API)
  • MAJOR: Added-in Shell API dummies:
    • shell.run(path) = works as expected BUT you are not allowed to run programs in /rom/ (I couldn't test much, I only made a dummy file which executed another one, because I don't have time for now)
    • shell.path() = works as expected (returns the path of the program you ran originally, OR the path of the program you ran with shell.run() )
    • shell.setPath() = SHOULD work (I've just realized that I didn't test this one lol)
    • shell.exit() = just returns, basically the original program, which called shell.run, is running again
    • shell.resolve(foldername/filename in your current directory) = should work as expected
    • shell.resolveProgram(program name) = should work as expected + lists programs in /usr/bin too
    • shell.aliases() = This one simulates the aliases table AS LONG AS THE ORIGINAL PROGRAM RUNS (because every shell API function gets reset after a new program starts)
    • shell.setAlias(alias, program) = Inserts into the simulated aliases table
    • shell.clearAlias(alias) = Removes from the simulated table
    • shell.programs(true/false) = Returns a table of the files in /rom/programs AND /usr/bin (+ the hidden ones, if true is entered)
    • shell.getRunningProgram() = works
    • shell.openTab(), switchTab() = doesn't work, just returns — NOTE: I won't add them, as that would destroy my future plans for multitasking
    • shell.complete() = the same as above, returns a empty table
    • shell.completeProgram(prefix) = works, returns a table with every program name containing that prefix (IN /usr/bin/ ONLY)
    • shell.setCompletionFunction() = doesn't work, returns false
    • shell.getCompletionInfo() = doesn't work, returns nil
    • ALMOST FINISHED: Something like a bluescreen, which shows the error of the os.lua, if it crashes
  • MINOR:
    • The user is now able to run programs, which are not located in /usr/bin (the #1 priority is the program in your location.)
EDIT:
Lol it just fucked up this post and I had to fix it :P/>

EDIT 2:
I just realized we reached the 1000-lines mark in os.lua, yay ^^
Edited on 20 September 2016 - 07:29 PM
thecrimulo #22
Posted 20 September 2016 - 09:34 PM
Okay hello there:
I have three things to say here, just to collaborate:

1) "The rootcheck is now built INTO the OS, it is no longer inside the FS API (this prevents the user from using programs to get rootaccess)"
Wait what. Do you mean, things like mkdir, do that thing right? If it's what I'm saying, I can just make my own mkdir to bypass it, it has to be in the FS API, Ill explain in the next thing how can you do it.

2) "(In theory you could rewrite the FS API again inside your program, but that will always be possible, BUT you don't have the ability anymore to somehow get the original FS API)"
Yours won't work, because, for the FS API, there is no code, that creates files and directories, you have to copy the APIs into _G.old, or something for the style, then do old.fs.anything(), and you asked for how to sandbox _G, approach that. Then people will not be able to replicate the FS API, and they won't be able to do anything with yours. I'll leave here a snippet that I'm using for that same thing.

--[[
mnx-sr12 : Moonux Satellite Rewrite 12
Made by thecrimulo
NAME:	    /boot/load
CATEGORY:    boot
SET:		 Boot RW12
VERSION:	 12:alpha0
DESCRIPTION:
  This script loads the old libraries
  and executes after /boot/init.
  More information on /man/bso.sm
]]--
-- Libraries to be loaded, check exclude
ilibls = {
"bit", "colors", "coroutine", "disk", "fs", "gps", "help", "http", "io", "keys", "math", "os", "paintutils",
"parallel", "peripheral", "rednet", "redstone", "settings", "string", "table", "term", "textutils", "vector"
}; libls = {}
for _,n in pairs(ilibls) do
libls[n] = n end
a = {...}
a_exclude = false
if #a > 0 then
for _,arg in pairs(a) do
  if a_exclude then
   libls[arg] = nil
  elseif arg == "exclude" then
   a_exclude = true
  end
end
end
-- Copy a table, instead of referencing it
local function _copy(a, B)/>
for c,d in pairs(a)
  b[c] = d
end
return b
end
_put("old", {})
-- NOTE: Exclude shell and multishell, for incompatibility.
-- README: Why the old libraries will load after the copy:
-- We have to copy it before the functions get overwritten, anyways it will still be called, so, we have to
-- make sure that it doesn't call itself (the API), so we avoid crashes
-- NOTE: This will copy every API content to _G.old, instead of referencing it.
for _,h in pairs(libls) do
old[h] = {}
_copy(_G[h], old[h])
end

3) Have a scheme? In case you don't
It's great to have a scheme to plan how your OS will work, what calls it will use and how will it do anything. Just that note

Cya
~ Dael
Piorjade #23
Posted 20 September 2016 - 09:53 PM
Does a program not always have the ability to 'replicate' something?
Like I got my edited FS, insert it into the SandBox Enviroment so that programs can't do what they want, but what If the program uses:

local fs.open = function(path, mode)
  --do your thing
end
(I'm reffering to "local")

I also "saved" the old FS outside of the init() enviroment (which is the enviroment, which gets cloned into the sandbox).

How I implemented the rootcheck now, is that it checks if the user is root and has the right vars for currentUsr and currentPw. (or using 'sudo' and entering the pass)
If user is root:
  • Simply clone the env to the SandBox, but without limiting FS
If user is not root:
  • Clone the env with limited FS to the env of the loaded program
  • Start the program
  • If program crashes/ends: Reload original FS to the init() env and restore currentUsr and currentPw, just in case if the program SOMEHOW managed to edit these
Btw I tried to load the saved original FS in a program (and I was a 100% it wouldnt work), and it doesn't.
My mkdir just calls fs.makeDir (if not root, it calls the edited, as it replaced fs.makeDir() ) with some extras like false directories or something.

EDIT:
I think I'll use your idea of the copy table function, if you dont bother :P/>/>

If you want, you could fork the GitHub and show me your version of it :P/>/> (Well I don't think you want to, as it would look like a hell of work to look what to replace)
Edited on 20 September 2016 - 08:00 PM
Piorjade #24
Posted 20 September 2016 - 10:11 PM
BTW: This OS is also intended to be community driven, meaning that I don't bother if you guys fork it, fix or change something. If you got better solutions (like appeariently thecrimulo does) and at best want me to use them, I'd love to see examples or even a merge request from your fork :)/>
Piorjade #25
Posted 20 September 2016 - 10:22 PM
Oh by reading your post for the 2nd time I think you thought that the rootcheck is in mkdir and others? If yes, that's wrong, sry if that changelog made you to misunderstand me :(/>/>

I built in the rootcheck into os.lua
As I said, mkdir simply calls for fs.makeDir , which is, depending on who's logged in or if sudo is used, either limited or not, that's about it.

In the previous version, where FS checked for currentUsr, the program could simply set _G.currentUsr (or local, I don't remember it anymore) and copy the hashed rootpassword to _G.currentPw to get access, no matter if I used a read-only enviroment or not (via the code sewbacca gave me) because it looks like I can't prevent the program from editing _G (if you have a code , which clones an enviroment with set functions and variables, and the program with this env can NOT edit any of these (not even _G) things (and at best NEITHER make a local variable, which has the same name as the protected variables in _G) , I'd love to take a peek into it :)/>/>)

EDIT:
Nvm it looks like you've got no chance to rewrite fs.open by hand, my bad. That means that you literally got really no chance of editing without rootaccess? If yes, awesome :)/>
(I tried to look where exactly the FS "API" is defined, but couldn't find it anywhere and not even in bios.lua. io.open() calls fs.open, which means it will be harmless too, I guess? Correct me, if I'm wrong with something.)

FOUND BUG (yeah I need help with that):

Normally If a program has an error in it, it will print that error and the OS continues to run without any problems.
But when I used io, to test if it has the limited FS API too, and I forgot a ")" at the end, which should error out and point to the missing ")", the OS COMPLETELY crashed and somehow the init() enviroment got ReadOnly too, which means it had a second error pointing to the shell, which wanted to set the currentDir…

Here's the code, which crashes the OS:

local a, b, c = assert(io.open("/test","w") ---- Here's the missing ")"
a:write("Hello")
a:close()

NOTE: If the code is correct (the missing ")" is there), then everything works as expected (returns an error, "assertion failed")

EDIT 2: (to the bug)
This happens with fs.open("/test", "w" <– (the ")" is missing too), too! Going to test it with normal code and/or print()

EDIT 3:
Ok nvm, print("Hello" <– (no ")" ) crashes the system too.
Dangit I don't know how to fix that :(/>

STATUS UPDATE (to the bug):
It looks like I misunderstood how loadfile and loadstring works, fixed it and the OS prints the error now properly :)/>

Will upload the update later, as I want to add some things too.

STATUS UPDATE 2 (general):

Ok maybe the idea with redirecting fs.open("/") to the homedirectory is not good at all because that would break "rm", "mkdir", etc.
Going to restore the old system and because I fixed the error output when a code is broken, it will display the error properly and tell you to try sudo.
Edited on 21 September 2016 - 11:27 AM
thecrimulo #26
Posted 21 September 2016 - 02:19 PM
On mobile:
"Nvm it looks like you've got no chance to rewrite fs.open by hand, my bad. That means that you literally got really no chance of editing without rootaccess? If yes, awesome
(I tried to look where exactly the FS "API" is defined, but couldn't find it anywhere and not even in bios.lua. io.open() calls fs.open, which means it will be harmless too, I guess? Correct me, if I'm wrong with something.)"

Yes, you are right. Mind that you'll have to secure _G (as you did) and load the old FS. Also, make the rootcheck and the ~/inhome dir solver in your API and io.open should be fine
Piorjade #27
Posted 21 September 2016 - 03:24 PM
STATUS UPDATE:

- Fixed the things I had problems with from above
- Currently implementing a taskmanager with external windowmanager (means that you can completely replace them or don't use them in your DE (NOTE: If everything works and you plan on making a DE, I HIGHLY don't recommend you using the stock windowmanager, as it ONLY creates fullscreen windows (well it creates windows, which are as big as their parent window)))

EDIT:

UPDATE (mainly a hotfix:)

Spoiler
  • Fixed many bugs
  • Added in bluescreen of death (well I don't know how to trigger it now, as I didn't found ANY code issues and programs can't trigger it, BUT it works)
  • Added, but not used yet: Windowmanager ("/sys/API/wm") and Taskmanager ("/sys/API/tasks") (I guess they are documented enoug, as they aren't really something incredible)
Edited on 21 September 2016 - 01:48 PM
apemanzilla #28
Posted 21 September 2016 - 04:09 PM
On mobile:
"Nvm it looks like you've got no chance to rewrite fs.open by hand, my bad. That means that you literally got really no chance of editing without rootaccess? If yes, awesome
(I tried to look where exactly the FS "API" is defined, but couldn't find it anywhere and not even in bios.lua. io.open() calls fs.open, which means it will be harmless too, I guess? Correct me, if I'm wrong with something.)"

Yes, you are right. Mind that you'll have to secure _G (as you did) and load the old FS. Also, make the rootcheck and the ~/inhome dir solver in your API and io.open should be fine

The FS api is defined in the Java side of the mod and the IO api is just a wrapper for the FS api. That means that unless you have access to the original copy of the FS api provided in _G when the computer boots, you can't make any modifications to the filesystem. Ergo, as long as this OS doesn't leak the original FS api anywhere or have an exploit in the sandbox, then there's no way to bypass the sandbox from userspace.
Piorjade #29
Posted 21 September 2016 - 04:38 PM
On mobile:
"Nvm it looks like you've got no chance to rewrite fs.open by hand, my bad. That means that you literally got really no chance of editing without rootaccess? If yes, awesome
(I tried to look where exactly the FS "API" is defined, but couldn't find it anywhere and not even in bios.lua. io.open() calls fs.open, which means it will be harmless too, I guess? Correct me, if I'm wrong with something.)"

Yes, you are right. Mind that you'll have to secure _G (as you did) and load the old FS. Also, make the rootcheck and the ~/inhome dir solver in your API and io.open should be fine

The FS api is defined in the Java side of the mod and the IO api is just a wrapper for the FS api. That means that unless you have access to the original copy of the FS api provided in _G when the computer boots, you can't make any modifications to the filesystem. Ergo, as long as this OS doesn't leak the original FS api anywhere or have an exploit in the sandbox, then there's no way to bypass the sandbox from userspace.

Thank you for clearing that up :)/>

It's also nice to see ya' here ^^
Piorjade #30
Posted 21 September 2016 - 06:28 PM
STATUS UPDATE:

I currently got the taskmanager to work, now I only have to call the function everywhere we need it and let it work together with the windowmanager
thecrimulo #31
Posted 21 September 2016 - 06:51 PM
STATUS UPDATE:

I currently got the taskmanager to work, now I only have to call the function everywhere we need it and let it work together with the windowmanager
Can you clear up the "call the function everywhere we need it"?
Piorjade #32
Posted 21 September 2016 - 07:01 PM
STATUS UPDATE:

I currently got the taskmanager to work, now I only have to call the function everywhere we need it and let it work together with the windowmanager
Can you clear up the "call the function everywhere we need it"?

I have multiple "if.. then" parts in the shell
It checks for example if the command is "cd"
or if its in usr/bin but not in the current dir
or if its in the current dir
and finally if it the command is nil / is nothing / is just "space"

By "everywhere we need it " I actually mean inserting if to every "if" part.
Currently I got multitasking fully working, but I kinda hang at the windowmanager, as there will be background processes and one foreground process.
My problem is that when creating a window, which is set to invisible, and then the loop starts and tries to run all the background processes (Every background process gets an own window) the OS kinda freezes up with a blinking cursor :/

Either it really crashes OR it doesn't go back to the main OS window ..
thecrimulo #33
Posted 21 September 2016 - 07:17 PM
Back on computer. I maaaaay have a dirty way of rewriting the Window Manager, which will also be fullscreen apps, and It is maybe easier. Do you have some kind of gitter or Discord server where we can talk as we think of things? A gitter would be great
Piorjade #34
Posted 21 September 2016 - 07:42 PM
Well I think I already fixed it, lol. :D/>
If I run into other problems with it, I'll tell you, k? :)/>

No I don't have any of those (well Discord only for me &amp; my RL friends if we want to play CSGO or something)
thecrimulo #35
Posted 21 September 2016 - 07:46 PM
Well I'd recommend gitter.im for instant chat, linking to GitHub activity, and It's pretty cool.
Also thanks, I'll be waiting
Piorjade #36
Posted 21 September 2016 - 07:49 PM
Here's the gitter chatroom:

(That's not only for thecrimulo)

https://gitter.im/cLinux-development/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link
thecrimulo #37
Posted 21 September 2016 - 07:50 PM
I'll be adding it to the readme. See you there
Piorjade #38
Posted 22 September 2016 - 12:17 AM
STATUS UPDATE:

While still working on multitasking (which is currently kinda broken, if the code doesn't yield; and that's a big problem), I'll start a secret but not so secret project parallel to this. (it's not so secret if you are on our Gitter, lol)
thecrimulo #39
Posted 22 September 2016 - 03:47 PM
On mobile again:
I can give you my thread.l code, I think i did put it on gitter. That is some kind of major rewrite, but valid
Piorjade #40
Posted 22 September 2016 - 04:28 PM
Huh, there is nothing I can see?
Piorjade #41
Posted 07 October 2016 - 10:59 PM
Information about this project

I'm currently remaking the OS, to make it more modular and compatible towards window managers / desktop enviroments and programs in general.
The thing is, I'm taking it easy meaning that I'm not very far ATM.

Who is kinda working on this too? thecrimulo. (Tho he only helped me out, I'll still ship it as ours)

I'll also consider implementing Sewbacca's own FS API (don't know how yet)
Piorjade #42
Posted 08 October 2016 - 08:57 PM
STATUS UPDATE ON REWRITE:

Spoiler
  • got shell to work (it is now the last CORE process, things like windowmanager, x, whatever are launched AFTERWARDS)
  • got modified FS API to work (works the same as before, checks where your operation will occur and if you are root or nah)
  • got perm API to work (registers users, deletes them, changes passwords, logs in, checks permission for a file/folder)
Sewbacca #43
Posted 08 October 2016 - 10:46 PM
Hey, i tested your system a bit right now.
Here are some things, i would improve:
  1. A help or cmdlist command to list all available commands
  2. Improve resolving paths (like '..', '.') (you can use fs.combine())
  3. A edit program or a view program to view a file.
Piorjade #44
Posted 08 October 2016 - 10:49 PM
Hey, i tested your system a bit right now.
Here are some things, i would improve:
  1. A help or cmdlist command to list all available commands
  2. Improve resolving paths (like '..', '.') (you can use fs.combine())
  3. A edit program or a view program to view a file.
Ty for testing! And I think you used the normal version, which isn't being worked on right now :)/>
I'm currently making a rewrite, thank you for your ideas, going to implement them in the rewrite tho.

If you want to test the rewritten code, go to the github page and then choose the rewrite branch :)/>
Sewbacca #45
Posted 08 October 2016 - 10:51 PM
I didn't looked into yet, but you can use the shell API to interact with your shell. Maybe you are doing this right now, i dunno.
Sewbacca #46
Posted 08 October 2016 - 11:00 PM
You can simplify following code in startup.lua:

str = string.reverse(str)
str = string.sub(str, 2)
str = string.reverse(str)

to


str = string.sub(str, -2)

or


str = string.sub(str, 1, -2)
Edited on 08 October 2016 - 09:00 PM
Piorjade #47
Posted 08 October 2016 - 11:04 PM
You can simplify following code in startup.lua:

str = string.reverse(str)
str = string.sub(str, 2)
str = string.reverse(str)

to


str = string.sub(str, -2)

or


str = string.sub(str, 1, -2)

Wow I'm good at math in shool but totally forgot about it while programming :D/>
Ty for that remind
Sewbacca #48
Posted 08 October 2016 - 11:11 PM
You can simplify following code in startup.lua:

str = string.reverse(str)
str = string.sub(str, 2)
str = string.reverse(str)

to


str = string.sub(str, -2)

or


str = string.sub(str, 1, -2)

Wow I'm good at math in shool but totally forgot about it while programming :D/>
Ty for that remind

Yeah, i didn't know it for a while as well.
Piorjade #49
Posted 09 October 2016 - 07:27 PM
STATUS UPDATE ON REWRITE:

Spoiler
  • Got services to work (coroutines on the shell-level, which are files saved in /etc/services.d. Later the root may be able to remove and add services. NOTE: services don't have the thread/sThread API anymore, so they need to implement their own task manager)
  • Got the commandline work as service, it has the slightly modified sThread API for multitasking and boots the console and rednet automatically.
  • Got rednet to work (NOTE: it is working in such a way, that a TLCO script may break rednet, but the commandline will continue on working.)


EDIT:
Currently almost no documentation at all LMAO
Had been stuck with multitasking for about 2 hours….

NOTE:
The commandline currently writes this:
#[a number]
This number indicates, how many tasks are running on commandline-level
When you enter a command it first prints the names/paths of the running tasks and then executes your command

For example after reboot:

#2 *presses enter*
CommandLine
RedNet
#2 *enters path to a file*
CommandLine
RedNet
<executes code of that file, the code decides to sleep for 2 seconds>
#3 _ (waits 2 seconds) --> #2 hello world (it printed the part after sleep)
#2 _


ANOTHER UPDATE ON THE REWRITE:

Spoiler
  • Got login / register system working in commandline
  • Got background/foreground processes working in commandline
    • Background: (the commandline runs at the same time, for example while a process sleeps or does read() )
      • bg <path to program>
    • Foreground: (the commandline is paused until the program end / crashes)
      • <path to program>

I know that's not much, but I have a fucked up school plan sooo yea
Edited on 11 October 2016 - 06:45 PM
Piorjade #50
Posted 14 October 2016 - 08:08 PM
REWRITE IS NOW THE OFFICIAL VERSION

Please report bugs here or on GitHub, I will work on this more often now <3

EDIT:
Some things on the first post are completely changed now, but I can't rewrite it right now, maybe later.
Edited on 14 October 2016 - 06:09 PM
Piorjade #51
Posted 15 October 2016 - 12:31 AM
UPDATE:

Spoiler
  • 10/15/2016:
    • Polished packman and added in a clinux repository, where tested programs (and maybe fixed) will be added in
      • Currently in the repo:
        • edit (the vanilla one)
        • luaide (works flawless, of course opening files in forbidden places crashes the app)
    • Fixed bugs with the CommandLine:
      • Fixed a bug where arguments could have things like : "/&#46;&#46;/////&#46;&#46;/" , etc.
      • Commands and arguments aren't allowed to have more than one "/" in a row and having more than ".." in an argument at the same time is also forbidden
        • Example: cd &#46;&#46;/ –> doesnt work
        • cd // –> doesnt work
        • cd /home/&#46;&#46;/ –> doesnt work
        • cd /home// –> doesnt work
        • etc.
Edited on 15 October 2016 - 10:37 AM
Piorjade #52
Posted 15 October 2016 - 11:16 PM
KINDA HUGE UPDATE: (literally)

Spoiler10/16/2016:
  • Fixed many bugs
  • Fixed even more bugs
  • Almost broke my table while fixing os.loadAPI()
  • Noticed that I didn't update os.unloadAPI, don't have the time anymore
  • HUGE ADD-ON (which is optional, cuz it has a problem):
    • OPTIONAL Desktop Enviroment:
      • ported the doorOS3.0 Desktop Enviroment over
      • with cLinux together, it is big AS F*CK
      • you need to expand the available space for computers to install it
      • Commands to install it:
      • 
        > sudo packman install doorx
        > InstallDoorX
        > service core /doorOS/sys/os.lua
        
  • Added in a new flag for GRUB:
    • text = ignores the services.conf and boots cmdbak (Command Line)

KNOWN BUG IN doorX:

Spoiler
  • minimizing does simply not work, lmao (it worked in doorOS3.0, I think I broke it while editing the script)
Edited on 15 October 2016 - 09:43 PM
Piorjade #53
Posted 16 October 2016 - 04:28 AM
BUGFIX (on doorX):

Spoiler
  • Fixed clipping through windows
  • Fixed selecting windows (they didn't get selected on the last 2 pixels on the right)
  • Fixed minimizing


EDIT:
Ugh I can't believe that something crashes now again when loading the languagefile…

EDIT2:
Well nvm I was dumb, fixed it.
Edited on 16 October 2016 - 02:38 AM
Piorjade #54
Posted 16 October 2016 - 05:40 AM
MINOR UPDATE:

Spoiler
  • Added the package 'updater' into the repository:
    • This script basically updates your system to the newest version on GitHub (it needs to be run as root (or sudo) ), after installing simply reboot the system
  • Fixed some bugs, again.
Piorjade #55
Posted 21 October 2016 - 08:06 PM
Upcoming feature(s) in cLinux (and doorX):
  • Add new users <– in about 2-4 days (I'm currently very busy with school)
  • Filebrowser (as packman package) <– in about 0-2 days <— already there (package fsexpose), but quite buggy, works flawless in CraftOS tho…
  • Packman GUI, for every DE you want (may take longer, I'll have to think whether I want to make my own (preffered)) <– don't know when
  • Maybe read-only homedirectory, if it's not YOUR directory <– don't know when
  • Maybe home directory encrypting, but would kill the point above <– don't know when

EDIT: INFORMATION

Well I didn't touch this for about 1-2 weeks and yesterday I was trying to fix the filebrowser, but then I found out that there is a critical bug in the thread manager, allowing a program to simply access the old FS API, which SHOULD be removed when starting a program (it even should've been removed after shell.lua finishes) but somehow they still have access to it.
So now I'm slowly starting to rewrite the system once again (not FULLY but still much) to prevent that kind of thing to happen…

(maybe I'll even know how to fix the filebrowser while coding…)

Also I may not be that active here for a couple of weeks, as I got stuff in school to do and I'm thinking of starting to program with Löve2D or even Unity.
Edited on 25 October 2016 - 03:56 PM
Stevan #56
Posted 21 November 2016 - 09:03 PM
Help! i dont know how to reboot! the reboot command dosent work :/ (yeah i know im a noob)
Piorjade #57
Posted 23 November 2016 - 11:46 AM
Help! i dont know how to reboot! the reboot command dosent work :/ (yeah i know im a noob)

Hold CTRL + R is currently the only "built-in" function.


If you want to add a reboot command do this:

sudo edit /bin/reboot
--This is inside of editor
os.reboot()
--Press CTRL, go to save, press CTRL again, go to exit
--This is in the console again
reboot



NOTE:
(I'm currently not working on the re-rewrite, as I have many exams coming up and I want to learn Unity3D. (Currently I'm completely stuck with saving a whole environment, which can be edited while playing… look Animal Crossing))
Edited on 23 November 2016 - 10:47 AM
X3ME #58
Posted 28 November 2016 - 07:14 PM
How would I go about contributing to this project? I'm a linux developer irl so this is something that satisfies me :D/>
Piorjade #59
Posted 29 November 2016 - 05:27 PM
How would I go about contributing to this project? I'm a linux developer irl so this is something that satisfies me :D/>
You can fork from GitHub if you want or make Pull Requests. I'm sure you probably already know this, but this is not linux and just tries to mimic it right?
Anyways, if you help me I'd be really happy (I can't currently work on it as I stated above)

EDIT: Had nothing to do… so I worked on the re-rewrite quite a bit again..he..he..
Edited on 29 November 2016 - 09:01 PM
Piorjade #60
Posted 30 November 2016 - 09:46 PM
Stable Update (for rewrite branch):


- Removed unnecessary threadmanagers (only using one, remade threadmanager for everything EXCEPT services, which use sThread.l)
- Got commandline working
- Got argument-passing working again
- Blah
- Things that I mentioned above are mostly fixed / done (for example programs have no access to old.fs anymore)

TODO:

- Move sThread.l to /sys/ (noticed that while writing this)
- Test out everything
- Polish commandline

Things that I can't fix:

- fsexpose (sudo packman install fsexpose) flickers (I think that has to do with the many threadmanagers, cuz there is no real multitasking)
Edited on 30 November 2016 - 08:47 PM
X3ME #61
Posted 03 December 2016 - 02:53 PM
How would I go about contributing to this project? I'm a linux developer irl so this is something that satisfies me :D/>
You can fork from GitHub if you want or make Pull Requests. I'm sure you probably already know this, but this is not linux and just tries to mimic it right?
Anyways, if you help me I'd be really happy (I can't currently work on it as I stated above)

EDIT: Had nothing to do… so I worked on the re-rewrite quite a bit again..he..he..

I'll just fork it then! (Yeah buddy, not dumb eheh)
Well I'm quite sure that I can help then!

:D/>
Piorjade #62
Posted 04 December 2016 - 08:48 PM
How would I go about contributing to this project? I'm a linux developer irl so this is something that satisfies me :D/>/>/>
You can fork from GitHub if you want or make Pull Requests. I'm sure you probably already know this, but this is not linux and just tries to mimic it right?
Anyways, if you help me I'd be really happy (I can't currently work on it as I stated above)

EDIT: Had nothing to do… so I worked on the re-rewrite quite a bit again..he..he..

I'll just fork it then! (Yeah buddy, not dumb eheh)
Well I'm quite sure that I can help then!

:D/>/>/>

If you do, you'll probably be credited or even counted as one of the main developers (look at the top of the topic)

Anyways, thanks and good luck / have fun trying stuff out :P/>/>

NOTE:
I'm not yet ready to merge the rework branch into master, as I need to kinda document stuff inside the files, clean them up and fix some stuff. BUT the current state is pretty good (part of the changes are stated above, but there are some other things that I forgot about :P/> )
Edited on 04 December 2016 - 07:52 PM
Piorjade #63
Posted 05 December 2016 - 05:22 PM
STATUS UPDATE ON REWORK:
Well…

Looks like I'm stuck at RedNet again….

*sigh*

FIXED, need to check more stuff tho

UPDATE 2:
  • this
  • and that
  • and some of that too
  • moved sThread.l
  • fixed the way I reimplemented rednet
  • blah
  • edited the way os.loadAPI worked
  • almost ready for the master branch
It's pretty much finished, but I really need to test some things out.
Probably will get merged today or tommorow.
Edited on 05 December 2016 - 05:35 PM
Piorjade #64
Posted 06 December 2016 - 05:28 PM
MERGED REWRITE INTO MASTER

(I'm honest, I'm too lazy to write the changes here, you can read them in my posts before)

Pretty much even more secure than the version before.
Biggest change is probably the threadmanager.
Sewbacca #65
Posted 12 December 2016 - 09:10 PM
I would propose you to work out an own <rednet or network or whatever api name> api with peripheral.
Piorjade #66
Posted 13 December 2016 - 05:08 PM
I would propose you to work out an own <rednet or network or whatever api name> api with peripheral.

That's why I made the API optional and deactivated at stock :)/>

I already thought about making my own, I'll take a look someday.

(I'm currently busy with making a The Escapists clone w/ multiplayer heh)
TheKickstart #67
Posted 15 December 2016 - 08:25 PM
Did anyone know that with permission, I am able to work on an openSUSE clone based on cLinux for Computercraft called openCraft
Piorjade #68
Posted 16 December 2016 - 07:30 PM
Did anyone know that with permission, I am able to work on an openSUSE clone based on cLinux for Computercraft called openCraft

Yeah maybe I should tell it everybody by writing that on the topic XD

EDIT:
Added "How you may use it"-spoiler :)/>

And for anyone who tries to build his OS ontop of it or DE:
If you have any questions, feel free to send me a message
Edited on 16 December 2016 - 06:35 PM
Bubbycolditz #69
Posted 27 December 2016 - 01:24 AM
Nice OS!
Piorjade #70
Posted 27 December 2016 - 01:24 PM
Nice OS!

Thank you! :)/>
Cross_Sans #71
Posted 25 January 2017 - 02:01 PM
Why the LL command does not exists ?
Anavrins #72
Posted 25 January 2017 - 04:22 PM
Why the LL command does not exists ?
And what does that command do?
Edit: if you're talking about the ls -l alias, that's simply because both an alias program, nor ls -l has been implemented yet.
Edited on 25 January 2017 - 03:24 PM
Cross_Sans #73
Posted 26 January 2017 - 03:50 PM
Why the LL command does not exists ?
And what does that command do?
Edit: if you're talking about the ls -l alias, that's simply because both an alias program, nor ls -l has been implemented yet.

Yes, this is the ls -l linked to ll, that should be added to the aliases (because I always use ll).
Piorjade #74
Posted 26 January 2017 - 04:14 PM
Didn't think about alias lol.

Though I might consider implementing something like .bashrc to set aliases at starting a terminal up.

Aaaaand of course alias itself.

Btw ls -l is indeed an interesting idea!


Though I'm currently struggling to learn Java and C# at the same time…. yeah… maybe I should try to learn one language at a time.
Edited on 26 January 2017 - 03:15 PM
Cross_Sans #75
Posted 26 January 2017 - 05:56 PM
Didn't think about alias lol.

Though I might consider implementing something like .bashrc to set aliases at starting a terminal up.

Aaaaand of course alias itself.

Btw ls -l is indeed an interesting idea!


Though I'm currently struggling to learn Java and C# at the same time…. yeah… maybe I should try to learn one language at a time.

Never learn two languages at the same time. You could mess it up all of your knowledge.
Otherwise, it could be a great idea to implement ~/bashrc, this would be useful.
Piorjade #76
Posted 04 February 2017 - 05:00 PM
UPDATE:
  • Added commandline color customization:
    • Create the file .bashcol in your home directory
    • Example:
    • 
      {
      mainBg = 1,
      mainFg = 32768,
      middleBg = 1,
      middleFg = 32768,
      pathBg = 1,
      userBg = 1,
      userFg = 16384,
      }
      This example makes the commandline user black text and white background (NOTE: the command/file "clear" still clears in black)
  • Added program aliases:
    • Make the file .aliases in your home directory
    • EXAMPLE:
    • 
      {
        dir = "/bin/ls"
      }
      
      This adds the command "dir" to be the same as "ls"
  • Both of these things are on user basis, so it's the same as setting aliases in .bashrc for example (real Linux)
  • Things that you can modify in .bashcol:
    • middleBg and middleFg (the @ at between the current user and the path)
    • userBg and userFg (the username)
    • pathBg and pathFg (the path)
    • mainBg and mainFg (the commandline at itself)
  • .aliases has to use full paths!
  • The .bashcol file normally HAS TO use the decimal values for colors, EXCEPT when having a custom library in /lib/
  • Both of these files also HAVE TO use the table-scheme
Edited on 04 February 2017 - 04:05 PM
Piorjade #77
Posted 10 February 2017 - 10:37 AM
UPDATE (bugfixes):
  • Fixed bug with permission API
  • Fixed bug with shell API (setDir especially)
  • Fixed bug with rm
  • Fixed bug with mkdir
  • Fixed bug with cd
Piorjade #78
Posted 11 February 2017 - 12:50 PM
SMALL UPDATE:
  • Fixed some bugs with cd and shell API
  • Added the shutdown and reboot program
Piorjade #79
Posted 12 February 2017 - 08:49 PM
I'm currently making a cLinux-"distro" for pocket computers (advanced ones) called "CraftAndroid" (oh, how creative, Piorjade…) and already got some code for the buttons at the bottom.
Though I'm currently thinking of whether I should give applications the ability to call a function that hides these buttons, so that they have an extra line at the bottom…
Thank you in advance ! :)/>

Here's a snap of the "testing-screen":

Edited on 12 February 2017 - 07:50 PM
exosceleton #80
Posted 12 February 2017 - 08:51 PM
I think one should be able to customize (change the BG/FG color) but not hide them.
Piorjade #81
Posted 12 February 2017 - 09:09 PM
I think one should be able to customize (change the BG/FG color) but not hide them.

That's a nice idea! In this pic, the entire bottom line (containing the buttons) is dedicated to these buttons, which means they are black/white.
Everything above will be the actual screen available for apps to modify.

So I think I'll figure out some functions to change each buttons backgroundcolor and textcolor :)/>

But I'll wait for other suggestions too :)/>
Lyqyd #82
Posted 12 February 2017 - 09:14 PM
Threads merged.
クデル #83
Posted 13 February 2017 - 09:52 AM
How can I create an alternate desktop environment? I didn't find doorx in the cc-packman repository so I was a little confused.

Edit: You should implement the command below.

cd ~
Edited on 13 February 2017 - 08:57 AM
Piorjade #84
Posted 13 February 2017 - 11:59 AM
How can I create an alternate desktop environment? I didn't find doorx in the cc-packman repository so I was a little confused.

Edit: You should implement the command below.

cd ~

You probably need to update your packagelist, just run "sudo packman fetch"

Also "cd ~" is already implemented, just enter "cd". That's it :P/>

Regarding the question:
There are many ways of making a DE.
The easiest I can think of is just make a program which does your DE stuff and run that program after the commandline pops up.
The more efficient way (and how I did it with doorX) is to make your DE-program, which gets run as core service.
(When you're done coding your DE, just enter "service core /path/to/DE_startupFile". This way the commandline simply does not exist. (Well it does… but it's not executed at all….you get the point tho))

If you have any other questions, feel free to ask them here or send me a PM :)/>
Edited on 13 February 2017 - 11:00 AM
Piorjade #85
Posted 13 February 2017 - 07:28 PM
Progress on CraftAndroid:

Imgur gallery with descriptions
Cross_Sans #86
Posted 09 March 2017 - 11:04 AM
If you are (re)making Android, you should implement /vendor.rc or a file called like this that contains informations about the OS and the "Vendor".
Piorjade #87
Posted 12 March 2017 - 07:41 PM
If you are (re)making Android, you should implement /vendor.rc or a file called like this that contains informations about the OS and the "Vendor".

That probably causes confusion.

FYI craftAndroid is already out and is basically an OS for Pocket Computers using cLinux as its "kernel", but I unfortunately currently cannot update it.
Piorjade #88
Posted 26 April 2017 - 06:45 PM
Small Update:
  • Added 'addusr' :
  • addusr <name> <password>
    It doesn't need root privileges
  • Added 'rmusr':
  • rmusr <name>
    DOES need root privileges
  • Fixed some bugs with the perm library
Cross_Sans #89
Posted 07 May 2017 - 03:58 PM
  • rmusr <name>
It's deluser not rmuser.
Anyway, it's your OS :)/>.
Edited on 07 May 2017 - 01:59 PM
Piorjade #90
Posted 08 May 2017 - 12:03 PM
  • rmusr <name>
It's deluser not rmuser.
Anyway, it's your OS :)/>.

Thank you m8! ;)/>

MINOR UPDATE:
  • Changed 'rmusr' to 'delusr' (You may need to delete 'rmusr' after the update as it doesn't get removed)
Cross_Sans #91
Posted 08 May 2017 - 01:36 PM
No problem Piorjade :)/>
By the way:
Edited on 08 May 2017 - 11:40 AM