mirror of
https://github.com/troglobit/finit.git
synced 2026-10-27 12:20:54 +00:00
Add basic support for runlevels and bugfix FIFO I/O plugins
Like most other init implementations do, when entering runlevel 1, finit creates the file /etc/nologin to prevent users from logging in during single-user mode, this file is then removed upon leaving runlevel 1. Also, bugfix how FIFO I/O plugins are handled in finit. A FIFO will need to be reopened by the server side when the client closes the pipe. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
ec95243dad
commit
c3b76fdccf
7 files changed
+237
-57
No files matched your search
@@ -35,14 +35,16 @@
|
||||
#include "sig.h"
|
||||
#include "lite.h"
|
||||
|
||||
int debug = 0;
|
||||
int verbose = 1;
|
||||
char *sdown = NULL;
|
||||
char *network = NULL;
|
||||
char *username = NULL;
|
||||
char *hostname = NULL;
|
||||
char *rcsd = NULL;
|
||||
char *console = NULL;
|
||||
int debug = 0;
|
||||
int verbose = 1;
|
||||
int runlevel = 3;
|
||||
int prevlevel = 1;
|
||||
char *sdown = NULL;
|
||||
char *network = NULL;
|
||||
char *username = NULL;
|
||||
char *hostname = NULL;
|
||||
char *rcsd = NULL;
|
||||
char *console = NULL;
|
||||
|
||||
static void parse_kernel_cmdline(void)
|
||||
{
|
||||
@@ -63,6 +65,37 @@ static void parse_kernel_cmdline(void)
|
||||
}
|
||||
}
|
||||
|
||||
static int client(int argc, char *argv[])
|
||||
{
|
||||
int fd;
|
||||
struct init_request rq = {
|
||||
.magic = INIT_MAGIC,
|
||||
.cmd = INIT_CMD_RUNLVL,
|
||||
};
|
||||
|
||||
if (!fexist(FINIT_FIFO)) {
|
||||
fprintf(stderr, "/sbin/init does not support %s!\n", FINIT_FIFO);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "Missing argument.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
fd = open(FINIT_FIFO, O_WRONLY);
|
||||
if (-1 == fd) {
|
||||
perror("Failed opening " FINIT_FIFO);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rq.runlevel = (int)argv[1][0];
|
||||
write(fd, &rq, sizeof(rq));
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int run_loop(void)
|
||||
{
|
||||
while (1) {
|
||||
@@ -82,8 +115,11 @@ static void banner(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(int UNUSED(args), char* UNUSED(argv[]))
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
if (getpid() != 1)
|
||||
return client(argc, argv);
|
||||
|
||||
/*
|
||||
* Initial setup of signals, ignore all until we're up.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user