summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/Applications/PaperWork/Makefile31
-rw-r--r--Source/Applications/PaperWork/main.cpp52
-rw-r--r--Source/Applications/Shell/Shell-fs.ns.cpp2
-rw-r--r--Source/Kernel/Core/kmain.wtf.cpp16
-rw-r--r--Source/Kernel/Makefile1
-rw-r--r--Source/Kernel/Ressources/Configuration/Users4
-rw-r--r--Source/Kernel/TaskManager/Process-sc.class.cpp143
-rw-r--r--Source/Kernel/TaskManager/Process.class.cpp113
-rw-r--r--Source/Kernel/TaskManager/Process.class.h2
-rw-r--r--Source/Kernel/UserManager/User.class.h9
-rw-r--r--Source/Kernel/UserManager/Usr.ns.cpp15
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal-sc.proto.cpp25
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.proto.cpp19
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.proto.h2
-rw-r--r--Source/Library/Interface/Process.iface.h4
-rw-r--r--Source/Library/Userland/Binding/Process.class.h6
-rw-r--r--Source/Library/Userland/Binding/VirtualTerminal.class.h4
-rw-r--r--Source/Library/Userland/Start.cpp10
-rw-r--r--Source/Library/Userland/Syscall/Syscall.wtf.cpp4
-rw-r--r--Source/Library/Userland/Syscall/Syscall.wtf.h2
20 files changed, 309 insertions, 155 deletions
diff --git a/Source/Applications/PaperWork/Makefile b/Source/Applications/PaperWork/Makefile
new file mode 100644
index 0000000..fe8d564
--- /dev/null
+++ b/Source/Applications/PaperWork/Makefile
@@ -0,0 +1,31 @@
+.PHONY: clean, mrproper
+
+CXX = g++
+CXXFLAGS = -nostartfiles -nostdlib -ffreestanding -fno-exceptions -fno-rtti -I ../../Library/Common -I ../../Library/Interface -I ../../Library/Userland -D THIS_IS_MELON_USERLAND
+
+LD = ld
+LDFLAGS = -T ../../Library/Link.ld -L ../../Library
+
+Objects = main.o
+OutFile = PaperWork
+
+all: $(OutFile)
+ echo "* Done with $(OutFile)."
+
+rebuild: mrproper all
+
+$(OutFile): $(Objects)
+ echo "* Linking $@..."
+ $(LD) $(LDFLAGS) $^ -o $@
+
+%.o: %.cpp
+ echo "* Compiling $<..."
+ $(CXX) $(CXXFLAGS) -c $< -o $@
+
+clean:
+ echo "* Removing object files..."
+ rm -rf *.o
+
+mrproper: clean
+ echo "* Removing applications..."
+ rm -rf $(OutFile)
diff --git a/Source/Applications/PaperWork/main.cpp b/Source/Applications/PaperWork/main.cpp
new file mode 100644
index 0000000..0ec6512
--- /dev/null
+++ b/Source/Applications/PaperWork/main.cpp
@@ -0,0 +1,52 @@
+#include <Binding/Process.class.h>
+#include <String.class.h>
+
+int main(Vector<String> args) {
+ String act = "init";
+ if (args.size() == 2) {
+ if (args[1] == "login") {
+ act = "login";
+ } else if (args[1] == "init") {
+ act = "init";
+ }
+ }
+
+ if (act == "init") {
+ while (1) {
+ Process p = Process::run("/System/Applications/PaperWork.app");
+ if (p.valid()) {
+ p.setInVT(invt);
+ p.setOutVT(outvt);
+ p.pushArg("login");
+ p.start();
+ p.wait();
+ } else {
+ return 1;
+ }
+ }
+ } else if (act == "login") {
+ outvt << "Logging in to Melon\n";
+ String user, pw;
+ while (1) {
+ outvt << "Username : ";
+ user = invt.readLine();
+ outvt << "Password : ";
+ pw = invt.readLine(false);
+ if (!Process::get().authenticatePW(user, pw)) {
+ outvt << "Authentication failed.\n\n";
+ continue;
+ }
+ Process p = Process::run("/Applications/Shell/Shell.app");
+ if (p.valid()) {
+ p.setInVT(invt);
+ p.setOutVT(outvt);
+ p.start();
+ p.wait();
+ outvt << "\n\n";
+ } else {
+ return 1;
+ }
+ return 0;
+ }
+ }
+}
diff --git a/Source/Applications/Shell/Shell-fs.ns.cpp b/Source/Applications/Shell/Shell-fs.ns.cpp
index cd9de8a..0b51299 100644
--- a/Source/Applications/Shell/Shell-fs.ns.cpp
+++ b/Source/Applications/Shell/Shell-fs.ns.cpp
@@ -27,7 +27,7 @@ void ls(Vector<String>& args) {
String perm = "rwxrwxrwx";
u32int p = n.getPerm();
for (u32int i = 0; i < 9; i++) {
- if (((p >> i) & 1) == 0) perm[9 - i] = "-";
+ if (((p >> i) & 1) == 0) perm[8 - i] = "-";
}
if (n.type() == NT_FILE) {
outvt << " FILE " << perm << " " << n.getName();
diff --git a/Source/Kernel/Core/kmain.wtf.cpp b/Source/Kernel/Core/kmain.wtf.cpp
index 76d8971..62f96d5 100644
--- a/Source/Kernel/Core/kmain.wtf.cpp
+++ b/Source/Kernel/Core/kmain.wtf.cpp
@@ -171,6 +171,7 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
asm volatile("sti");
Log::log(KL_STATUS, "kmain : Interrupts enabled.");
+ /*
new KernelShell(cwd); //No need to save that in a var, it is automatically destroyed anyways
Log::log(KL_STATUS, "kmain : Kernel shell launched");
//kvt->unmap();
@@ -181,6 +182,21 @@ void kmain(multiboot_info_t* mbd, u32int magic) {
Log::log(KL_STATUS, "kmain : All kernel shells finished. Halting.");
Sys::halt();
+ */
+
+ Process* p = Process::run("/System/Applications/PaperWork.app", 0);
+ if (p == 0) {
+ PANIC("Could not launch PaperWork !");
+ } else {
+ VirtualTerminal* vt = new ScrollableVT(15, 76, 200, SHELL_FGCOLOR, SHELL_BGCOLOR);
+ Kbd::setFocus(vt);
+ ((ScrollableVT*)vt)->map(9);
+ p->setInVT(vt);
+ p->setOutVT(vt);
+ p->start();
+ while (p->getState() != P_FINISHED) Task::currThread()->sleep(100);
+ PANIC("PaperWork finished.");
+ }
PANIC("END OF KMAIN");
}
diff --git a/Source/Kernel/Makefile b/Source/Kernel/Makefile
index 301d64c..b7a8bd3 100644
--- a/Source/Kernel/Makefile
+++ b/Source/Kernel/Makefile
@@ -26,6 +26,7 @@ Objects = Core/loader.wtf.o \
DeviceManager/Time.ns.o \
DeviceManager/Kbd.ns.o \
TaskManager/Process.class.o \
+ TaskManager/Process-sc.class.o \
TaskManager/Thread.class.o \
TaskManager/Task.ns.o \
TaskManager/Task.wtf.o \
diff --git a/Source/Kernel/Ressources/Configuration/Users b/Source/Kernel/Ressources/Configuration/Users
index cc98bf5..490bc6b 100644
--- a/Source/Kernel/Ressources/Configuration/Users
+++ b/Source/Kernel/Ressources/Configuration/Users
@@ -1,4 +1,4 @@
# format is uid:username:maingroup:completename
-0:melon:0::The Melon Operating System
-1000:alexis211:1::
+0:melon:0::The Melon Operating System:admin
+1000:alexis211:1::The Creator:iamgod
diff --git a/Source/Kernel/TaskManager/Process-sc.class.cpp b/Source/Kernel/TaskManager/Process-sc.class.cpp
new file mode 100644
index 0000000..5a94c81
--- /dev/null
+++ b/Source/Kernel/TaskManager/Process-sc.class.cpp
@@ -0,0 +1,143 @@
+#include "Process.class.h"
+#include <TaskManager/Task.ns.h>
+#include <Process.iface.h>
+#include <UserManager/Usr.ns.h>
+#include <VirtualTerminal.iface.h>
+#include <SyscallManager/Res.ns.h>
+
+#define ISPARENT Task::currProcess()->getPid() == m_ppid
+
+call_t Process::m_callTable[] = {
+ CALL0(PRIF_EXIT, &Process::exitSC),
+ CALL1(PRIF_ALLOCPAGE, &Process::allocPageSC),
+ CALL1(PRIF_FREEPAGE, &Process::freePageSC),
+ CALL0(PRIF_GETPID, &Process::getPid),
+ CALL0(PRIF_GETPPID, &Process::getPpid),
+ CALL0(PRIF_ARGC, &Process::argcSC),
+ CALL1(PRIF_ARGV, &Process::argvSC),
+ CALL0(PRIF_START, &Process::startSC),
+ CALL1(PRIF_AUTODELETE, &Process::autoDeleteSC),
+ CALL1(PRIF_PUSHARG, &Process::pushArgSC),
+ CALL1(PRIF_SETOUTVT, &Process::setOutVTSC),
+ CALL1(PRIF_SETINVT, &Process::setInVTSC),
+ CALL2(PRIF_AUTHPW, &Process::authPWSC),
+ CALL1(PRIF_AUTHNOPW, &Process::authNoPWSC),
+ CALL0(0, 0)
+};
+
+u32int Process::scall(u8int wat, u32int a, u32int b, u32int c, u32int d) {
+ if (wat == PRIF_SGETCPR) return Task::currProcess()->resId();
+ if (wat == PRIF_SRUN) {
+ String* e = (String*)a;
+ Process* p = Process::run(*e, Usr::uid());
+ if (p != 0) return p->resId();
+ }
+ if (wat == PRIF_SWAIT) {
+ Process* p = Res::get<Process>(a, PRIF_OBJTYPE);
+ if (Task::currProcess()->getPid() != p->m_ppid) return 0;
+ while (p->m_state != P_FINISHED and !p->m_autodelete) Task::currThread()->sleep(20);
+ if (p->m_autodelete) return E_AUTODELETE;
+ s32int ret = p->m_retval;
+ delete p;
+ return ret;
+ }
+ return (u32int) - 1;
+}
+
+u32int Process::exitSC() {
+ if (Task::currProcess() != this) return 1;
+ Task::currentThreadExits(E_EXIT);
+ return 0;
+}
+
+u32int Process::allocPageSC(u32int pos) {
+ if (Task::currProcess() != this) return 1;
+ if ((pos & 0x00000FFF) != 0) pos = (pos & 0xFFFFF000) + 0x1000;
+ if (pos >= 0xC0000000) return 1;
+ m_pagedir->allocFrame(pos, true, true);
+ return 0;
+}
+
+u32int Process::argcSC() {
+ if (Usr::uid() == m_uid or ISROOT or ISPARENT) {
+ return (m_arguments.size());
+ }
+ return (u32int) - 1;
+}
+
+u32int Process::argvSC(u32int idx) {
+ if (idx >= m_arguments.size()) return (u32int) - 1;
+ if (Usr::uid() == m_uid or ISROOT or ISPARENT) {
+ return m_arguments[idx].serialize();
+ }
+ return (u32int) - 1;
+}
+
+u32int Process::freePageSC(u32int pos) {
+ if (Task::currProcess() != this) return 1;
+ if ((pos & 0x00000FFF) != 0) pos = (pos & 0xFFFFF000) + 0x1000;
+ if (pos >= 0xC0000000) return 1;
+ m_pagedir->freeFrame(pos);
+ return 0;
+}
+
+u32int Process::startSC() {
+ if (Task::currProcess()->getPid() == m_ppid) {
+ start();
+ return 1;
+ }
+ return 0;
+}
+
+u32int Process::autoDeleteSC(u32int d) {
+ if (Task::currProcess()->getPid() != m_ppid) return 2;
+ m_autodelete = (d != 0);
+ return (m_autodelete ? 1 : 0);
+}
+
+u32int Process::pushArgSC(u32int arg) {
+ String* a = (String*)arg;
+ m_arguments.push(*a);
+ return 0;
+}
+
+u32int Process::setInVTSC(u32int vtid) {
+ if (Task::currProcess()->getPid() != m_ppid) return 0;
+ VirtualTerminal* vt = Res::get<VirtualTerminal>(vtid, VTIF_OBJTYPE);
+ if (vt != 0) setInVT(vt);
+ return 1;
+}
+
+u32int Process::setOutVTSC(u32int vtid) {
+ if (Task::currProcess()->getPid() != m_ppid) return 0;
+ VirtualTerminal* vt = Res::get<VirtualTerminal>(vtid, VTIF_OBJTYPE);
+ if (vt != 0) setOutVT(vt);
+ return 1;
+}
+
+u32int Process::authPWSC(u32int user, u32int pw) {
+ if (Task::currProcess() != this) return 0;
+ String* u = (String*)user;
+ String* p = (String*)pw;
+ User* usr = Usr::user(*u);
+ if (usr == 0) return 0;
+ if (usr->vrfyPassword(*p)) {
+ m_uid = usr->getUid();
+ return 1;
+ }
+ return 0;
+}
+
+u32int Process::authNoPWSC(u32int user) {
+ if (Task::currProcess() != this) return 0;
+ if (!ISROOT) return 0;
+ String* u = (String*)user;
+ User* usr = Usr::user(*u);
+ if (usr == 0) return 0;
+ m_uid = usr->getUid();
+ return 1;
+}
+
+bool Process::accessible() {
+ return (m_uid == Usr::uid());
+}
diff --git a/Source/Kernel/TaskManager/Process.class.cpp b/Source/Kernel/TaskManager/Process.class.cpp
index eec28d8..bca5f1c 100644
--- a/Source/Kernel/TaskManager/Process.class.cpp
+++ b/Source/Kernel/TaskManager/Process.class.cpp
@@ -8,47 +8,10 @@
#include <VirtualTerminal.iface.h>
#include <SyscallManager/Res.ns.h>
-#define ISPARENT Task::currProcess()->getPid() == m_ppid
-
namespace Mem {
extern Heap kheap;
}
-call_t Process::m_callTable[] = {
- CALL0(PRIF_EXIT, &Process::exitSC),
- CALL1(PRIF_ALLOCPAGE, &Process::allocPageSC),
- CALL1(PRIF_FREEPAGE, &Process::freePageSC),
- CALL0(PRIF_GETPID, &Process::getPid),
- CALL0(PRIF_GETPPID, &Process::getPpid),
- CALL0(PRIF_ARGC, &Process::argcSC),
- CALL1(PRIF_ARGV, &Process::argvSC),
- CALL0(PRIF_START, &Process::startSC),
- CALL1(PRIF_AUTODELETE, &Process::autoDeleteSC),
- CALL1(PRIF_PUSHARG, &Process::pushArgSC),
- CALL1(PRIF_SETOUTVT, &Process::setOutVTSC),
- CALL1(PRIF_SETINVT, &Process::setInVTSC),
- CALL0(0, 0)
-};
-
-u32int Process::scall(u8int wat, u32int a, u32int b, u32int c, u32int d) {
- if (wat == PRIF_SGETCPR) return Task::currProcess()->resId();
- if (wat == PRIF_SRUN) {
- String* e = (String*)a;
- Process* p = Process::run(*e, Usr::uid());
- if (p != 0) return p->resId();
- }
- if (wat == PRIF_SWAIT) {
- Process* p = Res::get<Process>(a, PRIF_OBJTYPE);
- if (Task::currProcess()->getPid() != p->m_ppid) return 0;
- while (p->m_state != P_FINISHED and !p->m_autodelete) Task::currThread()->sleep(20);
- if (p->m_autodelete) return E_AUTODELETE;
- s32int ret = p->m_retval;
- delete p;
- return ret;
- }
- return (u32int) - 1;
-}
-
Process::Process() : Ressource(PRIF_OBJTYPE, m_callTable) { //Private constructor, does nothing
}
@@ -196,79 +159,3 @@ void Process::setInVT(VirtualTerminal* vt) {
void Process::setOutVT(VirtualTerminal* vt) {
m_outVT = vt;
}
-
-u32int Process::exitSC() {
- if (Task::currProcess() != this) return 1;
- Task::currentThreadExits(E_EXIT);
- return 0;
-}
-
-u32int Process::allocPageSC(u32int pos) {
- if (Task::currProcess() != this) return 1;
- if ((pos & 0x00000FFF) != 0) pos = (pos & 0xFFFFF000) + 0x1000;
- if (pos >= 0xC0000000) return 1;
- m_pagedir->allocFrame(pos, true, true);
- return 0;
-}
-
-u32int Process::argcSC() {
- if (Usr::uid() == m_uid or ISROOT or ISPARENT) {
- return (m_arguments.size());
- }
- return (u32int) - 1;
-}
-
-u32int Process::argvSC(u32int idx) {
- if (idx >= m_arguments.size()) return (u32int) - 1;
- if (Usr::uid() == m_uid or ISROOT or ISPARENT) {
- return m_arguments[idx].serialize();
- }
- return (u32int) - 1;
-}
-
-u32int Process::freePageSC(u32int pos) {
- if (Task::currProcess() != this) return 1;
- if ((pos & 0x00000FFF) != 0) pos = (pos & 0xFFFFF000) + 0x1000;
- if (pos >= 0xC0000000) return 1;
- m_pagedir->freeFrame(pos);
- return 0;
-}
-
-u32int Process::startSC() {
- if (Task::currProcess()->getPid() == m_ppid) {
- start();
- return 1;
- }
- return 0;
-}
-
-u32int Process::autoDeleteSC(u32int d) {
- if (Task::currProcess()->getPid() != m_ppid) return 2;
- m_autodelete = (d != 0);
- return (m_autodelete ? 1 : 0);
-}
-
-u32int Process::pushArgSC(u32int arg) {
- String* a = (String*)arg;
- m_arguments.push(*a);
- return 0;
-}
-
-u32int Process::setInVTSC(u32int vtid) {
- if (Task::currProcess()->getPid() != m_ppid) return 0;
- VirtualTerminal* vt = Res::get<VirtualTerminal>(vtid, VTIF_OBJTYPE);
- if (vt != 0) setInVT(vt);
- return 1;
-}
-
-u32int Process::setOutVTSC(u32int vtid) {
- if (Task::currProcess()->getPid() != m_ppid) return 0;
- VirtualTerminal* vt = Res::get<VirtualTerminal>(vtid, VTIF_OBJTYPE);
- if (vt != 0) setOutVT(vt);
- return 1;
-}
-
-
-bool Process::accessible() {
- return (m_uid == Usr::uid());
-}
diff --git a/Source/Kernel/TaskManager/Process.class.h b/Source/Kernel/TaskManager/Process.class.h
index 11da57b..053a640 100644
--- a/Source/Kernel/TaskManager/Process.class.h
+++ b/Source/Kernel/TaskManager/Process.class.h
@@ -64,6 +64,8 @@ class Process : public Ressource {
u32int pushArgSC(u32int);
u32int setOutVTSC(u32int);
u32int setInVTSC(u32int);
+ u32int authPWSC(u32int, u32int);
+ u32int authNoPWSC(u32int);
bool accessible();
public:
diff --git a/Source/Kernel/UserManager/User.class.h b/Source/Kernel/UserManager/User.class.h
index ae02281..9d13ef1 100644
--- a/Source/Kernel/UserManager/User.class.h
+++ b/Source/Kernel/UserManager/User.class.h
@@ -8,13 +8,13 @@ class User {
friend void Usr::load();
private:
- String m_username, m_completeName;
+ String m_username, m_completeName, m_password;
u32int m_uid;
Group* m_group;
Vector<Group*> m_extraGroups;
- User(String username, String completeName, Group* group, String extragroups, u32int uid)
- : m_username(username), m_completeName(completeName), m_uid(uid), m_group(group) {
+ User(String username, String completeName, String password, Group* group, String extragroups, u32int uid)
+ : m_username(username), m_completeName(completeName), m_password(password), m_uid(uid), m_group(group) {
Vector<String> eg = extragroups.split(",");
for (u32int i = 0; i < eg.size(); i++) {
Group* g = Usr::group(eg[i].toInt());
@@ -25,6 +25,7 @@ class User {
public:
String getUserName() { return m_username; }
String getCompleteName() { return m_completeName; }
+ String getPassword() { return m_password; }
u32int getUid() { return m_uid; }
Group* getGroup() { return m_group; }
bool isInGroup(u32int gid) {
@@ -45,6 +46,7 @@ class User {
if (m_extraGroups[i] == g) return true;
return false;
}
+ bool vrfyPassword(String pw) { return pw == m_password; }
String getGroups() {
String ret;
@@ -57,6 +59,7 @@ class User {
void setUserName(String wat) { m_username = wat; Usr::save(); }
void setCompleteName(String wat) { m_completeName = wat; Usr::save(); }
+ void setPassword(String wat) { m_password = wat; Usr::save(); }
void setGroup(Group* group) { m_group = group; Usr::save(); }
void addGroup(u32int gid) {
Group* g = Usr::group(gid);
diff --git a/Source/Kernel/UserManager/Usr.ns.cpp b/Source/Kernel/UserManager/Usr.ns.cpp
index db371ae..ecf9bae 100644
--- a/Source/Kernel/UserManager/Usr.ns.cpp
+++ b/Source/Kernel/UserManager/Usr.ns.cpp
@@ -5,10 +5,11 @@
#include <SimpleList.class.h>
#include <TaskManager/Task.ns.h>
#include <TextFile.class.h>
+#include <VFS/VFS.ns.h>
/*
* Syntax for Users and Groups configuration files : one entry per line
- * syntax for Users : <uid>:<username>:<basegroup>:<extragroup>,<extragroup>:<completename>
+ * syntax for Users : <uid>:<username>:<basegroup>:<extragroup>,<extragroup>:<completename>:<password>
* syntax for Groups : <gid>:<name>
*/
@@ -22,6 +23,8 @@ void load() {
if (m_groups != 0) delete m_groups;
m_users = 0, m_groups = 0;
+ if (VFS::find("/System/Configuration/Groups")) VFS::find("/System/Configuration/Groups")->setPermissions(0600);
+ if (VFS::find("/System/Configuration/Users")) VFS::find("/System/Configuration/Users")->setPermissions(0600);
TextFile groups("/System/Configuration/Groups", FM_READ);
while (!groups.eof()) {
String s = groups.readLine();
@@ -38,13 +41,14 @@ void load() {
TextFile users("/System/Configuration/Users", FM_READ);
while (!users.eof()) {
String s = users.readLine();
+ if (s == "" or s[0] == WChar("#")) continue;
Vector<String> data = s.split(":");
- if (data.size() == 5 and !(s[0] == WChar("#"))) {
- m_users = m_users->cons(User(data[1], data[4], group(data[2].toInt()), data[3], data[0].toInt()));
+ if (data.size() == 6) {
+ m_users = m_users->cons(User(data[1], data[4], data[5], group(data[2].toInt()), data[3], data[0].toInt()));
}
}
if (m_users == 0) {
- m_users = m_users->cons(User("melon", "MelOS", group(0), "", 0));
+ m_users = m_users->cons(User("melon", "MelOS", "", group(0), "", 0));
Log::log(KL_WARNING, "Usr.ns : users file invalid, had to add default users.");
}
}
@@ -58,7 +62,8 @@ void save() {
for (SimpleList<User> *iter = m_users; iter != 0; iter = iter->next()) {
users.write(String::number(iter->v().getUid()) + ":" + iter->v().getUserName() + ":"
+ String::number(iter->v().getGroup()->getGid()) + ":"
- + iter->v().getGroups() + ":" + iter->v().getCompleteName(), true);
+ + iter->v().getGroups() + ":" + iter->v().getCompleteName() + ":" +
+ iter->v().getPassword(), true);
}
}
diff --git a/Source/Kernel/VTManager/VirtualTerminal-sc.proto.cpp b/Source/Kernel/VTManager/VirtualTerminal-sc.proto.cpp
index 0a4e14b..5506c74 100644
--- a/Source/Kernel/VTManager/VirtualTerminal-sc.proto.cpp
+++ b/Source/Kernel/VTManager/VirtualTerminal-sc.proto.cpp
@@ -1,4 +1,25 @@
#include "VirtualTerminal.proto.h"
+#include <VirtualTerminal.iface.h>
+#include <TaskManager/Task.ns.h>
+
+call_t VirtualTerminal::m_callTable[] = {
+ CALL1(VTIF_WRITEHEX, &VirtualTerminal::writeHexSC),
+ CALL2(VTIF_WRITEDEC, &VirtualTerminal::writeDecSC),
+ CALL1(VTIF_WRITE, &VirtualTerminal::writeSC),
+ CALL1(VTIF_PUT, &VirtualTerminal::putSC),
+ CALL1(VTIF_READLINE, &VirtualTerminal::readLineSC),
+ CALL1(VTIF_SETCOLOR, &VirtualTerminal::setColorSC),
+ CALL1(VTIF_SETCSRLINE, &VirtualTerminal::setCursorLineSC),
+ CALL1(VTIF_SETCSRCOL, &VirtualTerminal::setCursorColSC),
+ CALL0(VTIF_ISBOXED, &VirtualTerminal::isBoxedSC),
+ CALL0(0, 0)
+};
+
+u32int VirtualTerminal::scall(u8int wat, u32int a, u32int b, u32int c, u32int d) {
+ if (wat == VTIF_SGETPRINVT) return Task::currProcess()->getInVT()->resId();
+ if (wat == VTIF_SGETPROUTVT) return Task::currProcess()->getOutVT()->resId();
+ return (u32int) - 1;
+}
u32int VirtualTerminal::writeHexSC(u32int number) {
writeHex(number);
@@ -22,8 +43,8 @@ u32int VirtualTerminal::putSC(u32int code) {
return 0;
}
-u32int VirtualTerminal::readLineSC() {
- return readLine().serialize();
+u32int VirtualTerminal::readLineSC(u32int show) {
+ return readLine(show != 0).serialize();
}
u32int VirtualTerminal::setColorSC(u32int x) {
diff --git a/Source/Kernel/VTManager/VirtualTerminal.proto.cpp b/Source/Kernel/VTManager/VirtualTerminal.proto.cpp
index 2587369..0079707 100644
--- a/Source/Kernel/VTManager/VirtualTerminal.proto.cpp
+++ b/Source/Kernel/VTManager/VirtualTerminal.proto.cpp
@@ -5,25 +5,6 @@
#include <VirtualTerminal.iface.h>
-call_t VirtualTerminal::m_callTable[] = {
- CALL1(VTIF_WRITEHEX, &VirtualTerminal::writeHexSC),
- CALL2(VTIF_WRITEDEC, &VirtualTerminal::writeDecSC),
- CALL1(VTIF_WRITE, &VirtualTerminal::writeSC),
- CALL1(VTIF_PUT, &VirtualTerminal::putSC),
- CALL0(VTIF_READLINE, &VirtualTerminal::readLineSC),
- CALL1(VTIF_SETCOLOR, &VirtualTerminal::setColorSC),
- CALL1(VTIF_SETCSRLINE, &VirtualTerminal::setCursorLineSC),
- CALL1(VTIF_SETCSRCOL, &VirtualTerminal::setCursorColSC),
- CALL0(VTIF_ISBOXED, &VirtualTerminal::isBoxedSC),
- CALL0(0, 0)
-};
-
-u32int VirtualTerminal::scall(u8int wat, u32int a, u32int b, u32int c, u32int d) {
- if (wat == VTIF_SGETPRINVT) return Task::currProcess()->getInVT()->resId();
- if (wat == VTIF_SGETPROUTVT) return Task::currProcess()->getOutVT()->resId();
- return (u32int) - 1;
-}
-
VirtualTerminal::VirtualTerminal() :
Ressource(VTIF_OBJTYPE, m_callTable), m_kbdMutex(false), m_kbdbuffMutex(false), m_kbdbuff() {
}
diff --git a/Source/Kernel/VTManager/VirtualTerminal.proto.h b/Source/Kernel/VTManager/VirtualTerminal.proto.h
index 90fa88e..9c138ec 100644
--- a/Source/Kernel/VTManager/VirtualTerminal.proto.h
+++ b/Source/Kernel/VTManager/VirtualTerminal.proto.h
@@ -25,7 +25,7 @@ class VirtualTerminal : public Ressource {
u32int writeDecSC(u32int, u32int);
u32int writeSC(u32int);
u32int putSC(u32int);
- u32int readLineSC();
+ u32int readLineSC(u32int);
u32int setColorSC(u32int);
u32int setCursorLineSC(u32int);
u32int setCursorColSC(u32int);
diff --git a/Source/Library/Interface/Process.iface.h b/Source/Library/Interface/Process.iface.h
index 0152947..cdd6e47 100644
--- a/Source/Library/Interface/Process.iface.h
+++ b/Source/Library/Interface/Process.iface.h
@@ -25,4 +25,8 @@
#define PRIF_SETOUTVT 0x29
#define PRIF_SETINVT 0x30
+//Authenticate with password/without password (being in group root)
+#define PRIF_AUTHPW 0x40
+#define PRIF_AUTHNOPW 0x41
+
#endif
diff --git a/Source/Library/Userland/Binding/Process.class.h b/Source/Library/Userland/Binding/Process.class.h
index a3fc569..948d670 100644
--- a/Source/Library/Userland/Binding/Process.class.h
+++ b/Source/Library/Userland/Binding/Process.class.h
@@ -57,6 +57,12 @@ class Process : public RessourceCaller {
void setOutVT(VirtualTerminal vt) {
doCall(PRIF_SETOUTVT, vt.resId());
}
+ bool authenticatePW(String user, String pw) {
+ return (doCall(PRIF_AUTHPW, (u32int)&user, (u32int)&pw) == 1);
+ }
+ bool authenticateNoPW(String user) {
+ return (doCall(PRIF_AUTHNOPW, (u32int)&user) == 1);
+ }
};
#endif
diff --git a/Source/Library/Userland/Binding/VirtualTerminal.class.h b/Source/Library/Userland/Binding/VirtualTerminal.class.h
index 1bfce85..5fd9733 100644
--- a/Source/Library/Userland/Binding/VirtualTerminal.class.h
+++ b/Source/Library/Userland/Binding/VirtualTerminal.class.h
@@ -29,8 +29,8 @@ class VirtualTerminal : public RessourceCaller {
void write(String s) {
doCall(VTIF_WRITE, (u32int)&s);
}
- String readLine() {
- return String::unserialize(doCall(VTIF_READLINE));
+ String readLine(bool show = true) {
+ return String::unserialize(doCall(VTIF_READLINE, (show ? 1 : 0)));
}
void setColor(u8int fg, u8int bg = 0xFF) {
doCall(VTIF_SETCOLOR, (fg << 8) | bg);
diff --git a/Source/Library/Userland/Start.cpp b/Source/Library/Userland/Start.cpp
index 4c5c559..032450d 100644
--- a/Source/Library/Userland/Start.cpp
+++ b/Source/Library/Userland/Start.cpp
@@ -16,10 +16,6 @@ VirtualTerminal invt(0), outvt(0);
int main(const Vector<String>& args);
-void doExit(u32int v) {
- asm volatile("int $66" : : "a"(v));
-}
-
extern "C" void start() {
//Call static constructors
u32int i = 0;
@@ -29,8 +25,8 @@ extern "C" void start() {
heap.create(0x40000000, 0x00040000, 0x00004000); //Initially create a 256ko heap with 16ko index
invt = VirtualTerminal::getIn(); outvt = VirtualTerminal::getOut();
- if (!invt.valid()) doExit(1);
- if (!outvt.valid()) doExit(2);
+ if (!invt.valid()) threadFinishedSyscall(1);
+ if (!outvt.valid()) threadFinishedSyscall(2);
u32int argc = Process::get().argc();
Vector<String> args(argc);
@@ -43,7 +39,7 @@ extern "C" void start() {
((void (*)(void))*call)();
}
- doExit(r);
+ threadFinishedSyscall(r);
}
namespace Mem {
diff --git a/Source/Library/Userland/Syscall/Syscall.wtf.cpp b/Source/Library/Userland/Syscall/Syscall.wtf.cpp
index a28c202..b8d9526 100644
--- a/Source/Library/Userland/Syscall/Syscall.wtf.cpp
+++ b/Source/Library/Userland/Syscall/Syscall.wtf.cpp
@@ -7,6 +7,10 @@ u32int syscall(u32int n, u32int a, u32int b, u32int c, u32int d, u32int e) {
return r;
}
+void threadFinishedSyscall(u32int v) {
+ asm volatile("int $66" : : "a"(v));
+}
+
void putch(char c) {
u32int x = c;
syscall(0xFFFFFF01, x);
diff --git a/Source/Library/Userland/Syscall/Syscall.wtf.h b/Source/Library/Userland/Syscall/Syscall.wtf.h
index 0401a89..5234579 100644
--- a/Source/Library/Userland/Syscall/Syscall.wtf.h
+++ b/Source/Library/Userland/Syscall/Syscall.wtf.h
@@ -8,6 +8,8 @@ void putch(char);
void sleep(u32int);
void write_hex(u32int);
+void threadFinishedSyscall(u32int);
+
u32int syscall(u32int n, u32int a, u32int b = 0, u32int c = 0, u32int d = 0, u32int e = 0);
#endif