2021-11-26 06:41:56 +03:00
|
|
|
/**
|
|
|
|
* @brief live-session - Run live CD user session.
|
2018-08-14 11:13:38 +03:00
|
|
|
*
|
|
|
|
* Launches the general session manager as 'local', waits for the
|
|
|
|
* session to end, then launches the login manager.
|
2021-11-26 06:41:56 +03:00
|
|
|
*
|
|
|
|
* @copyright
|
|
|
|
* This file is part of ToaruOS and is released under the terms
|
|
|
|
* of the NCSA / University of Illinois License - see LICENSE.md
|
|
|
|
* Copyright (C) 2018 K. Lange
|
2018-08-14 11:13:38 +03:00
|
|
|
*/
|
2018-05-10 16:33:32 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
#include <toaru/auth.h>
|
2018-08-02 13:13:16 +03:00
|
|
|
#include <toaru/yutani.h>
|
2018-05-19 14:33:41 +03:00
|
|
|
#include <toaru/trace.h>
|
|
|
|
#define TRACE_APP_NAME "live-session"
|
2018-05-10 16:33:32 +03:00
|
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
2018-08-02 13:13:16 +03:00
|
|
|
int pid;
|
|
|
|
|
2018-10-31 04:28:41 +03:00
|
|
|
if (geteuid() != 0) {
|
2018-05-10 16:33:32 +03:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int _session_pid = fork();
|
|
|
|
if (!_session_pid) {
|
2021-08-31 14:46:48 +03:00
|
|
|
toaru_set_credentials(1000);
|
2018-05-10 16:33:32 +03:00
|
|
|
char * args[] = {"/bin/session", NULL};
|
|
|
|
execvp(args[0], args);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2018-08-02 13:13:16 +03:00
|
|
|
/* Dummy session for live-session prevents compositor from killing itself
|
|
|
|
* when the main session dies the first time. */
|
|
|
|
yutani_init();
|
|
|
|
|
2018-05-10 16:33:32 +03:00
|
|
|
do {
|
|
|
|
pid = wait(NULL);
|
|
|
|
} while ((pid > 0 && pid != _session_pid) || (pid == -1 && errno == EINTR));
|
|
|
|
|
2018-05-19 14:33:41 +03:00
|
|
|
TRACE("Live session has ended, launching graphical login.");
|
2018-08-02 13:13:16 +03:00
|
|
|
int _glogin_pid = fork();
|
|
|
|
if (!_glogin_pid) {
|
|
|
|
char * args[] = {"/bin/glogin",NULL};
|
|
|
|
execvp(args[0],args);
|
|
|
|
system("reboot");
|
|
|
|
}
|
2018-05-19 14:33:41 +03:00
|
|
|
|
2018-08-02 13:13:16 +03:00
|
|
|
do {
|
|
|
|
pid = wait(NULL);
|
|
|
|
} while ((pid > 0 && pid != _glogin_pid) || (pid == -1 && errno == EINTR));
|
2018-05-10 16:33:32 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|