From 6c5dff88ce60fd4529acf344746d4227f84ce7ed Mon Sep 17 00:00:00 2001 From: Lisa Milne Date: Mon, 18 Dec 2023 12:39:08 +1000 Subject: [PATCH] check for user account during login --- clite/core.js | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/clite/core.js b/clite/core.js index a350592..dc269b8 100644 --- a/clite/core.js +++ b/clite/core.js @@ -296,7 +296,6 @@ EDITOR=/bin/vi root:$-7a1c0437:0:0:root:/root:/bin/sh guest:x:1:1:guest:/usr/home/guest:/bin/sh `; - // TODO: check cookies for a local user n.mode = clite.lib.modestr('-rw-------'); } // /etc/group contains group details @@ -311,7 +310,6 @@ guest:x:1:1:guest:/usr/home/guest:/bin/sh root:x:0:root guest:x:1:guest `; - // TODO: check cookies for a local user n.mode = clite.lib.modestr('-rw-r--r--'); } // /etc/greeting is displayed by the shell after login @@ -543,14 +541,11 @@ license.txt:/etc/license:0:0:-rw-r--r--`; } // check cookies for login clite.log.write('Checking for user session'); - if (clite.user.init(vfsapi)) {// if logged in: - clite.log.write('found user session?'); - // create user session - }else{// if new user: - clite.log.write('Generating guest session'); - clite.user.genGuest(); - // create the login shell - // should really have init/getty exec the shell with the env data etc + clite.user.init(vfsapi); + + { + // create the login environment + // spawns /bin/login on pid 1, optionally with default guest login var env = clite.user.getEnv(0); var io = { pid:0, @@ -565,8 +560,11 @@ license.txt:/etc/license:0:0:-rw-r--r--`; } function init5(env,io) { clite.tty.clear(0); - //clite.proc.setLogin(io.pid,1); - clite.lib.exec('/bin/login',['login','guest'],env,io); + var args = ['login']; + // check for user-created account with password set + if (!clite.user.hasAltLogin()) + args.push('guest'); + clite.lib.exec('/bin/login',args,env,io); } init1(); @@ -1311,8 +1309,16 @@ cat -l /usr/share/introduction }); return d; } + clite.user.hasAltLogin = function() { + data.users.forEach(function(u) { + if (u.name != 'root' && u.pass != 'x') + return true; + }); + return false; + } loadUsers(); + clite.user.genGuest(); return false; },