2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
26 /// @todo this should be "/bin/sh" (when symlinks work)
27 #define DEFAULT_SHELL "/boot/bin/sh"
33 console
= fopen("/dev/console","rw");
34 return console
!=NULL
?0:-1;
37 char *input(int hide
) {
38 static char buf
[LOGIN_NAME_MAX
];
40 for (i
=0;i
<LOGIN_NAME_MAX
-1 && (buf
[i
] = fgetc(console
))!='\n';i
++) fputc(hide
?'*':buf
[i
],console
);
49 struct passwd
*passwd
;
52 fputs("User: ",console
);
55 passwd
= getpwnam(user
);
57 fputs("User does not exist.\n",console
);
60 /// @todo Check password
61 /*fputs("Password: ",console);
66 setreuid(passwd
->pw_uid
);
67 setregid(passwd
->pw_gid
);
68 chdir(passwd
->pw_dir
);
69 return passwd
->pw_shell
;
73 void shell_run(char *shell
) {
74 pid_t pid
= execute(shell
,NULL
,NULL
,NULL
,NULL
);
78 int main(int argc
,char *argv
[]) {
80 if (init_input()==-1) abort();
81 while (1) shell_run(login());
83 shell_run(DEFAULT_SHELL
);
85 printf("TODO %s:%d: Run shutdown\n",__FILE__
,__LINE__
);