mirror of
https://github.com/troglobit/finit.git
synced 2026-11-06 15:51:03 +00:00
Remove long since deprecated finit.conf: console <DEV> support
All this code did was trigger prctl() to set process name to "console", which you could use as a simple means of figuring out if a process was started from the system console. There are other ways to do this, which Finit should not be involved in. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
51c5f3cbfa
commit
c76a58ef7a
7 files changed
+10
-32
No files matched your search
+1
-8
@@ -197,16 +197,10 @@ Syntax
|
|||||||
service [12345] /bin/sh -l
|
service [12345] /bin/sh -l
|
||||||
```
|
```
|
||||||
|
|
||||||
* `console <DEV>`
|
|
||||||
Use this, along with a matching `tty DEV` line, to mark this TTY as a
|
|
||||||
special "console" port with `prctl()`. Useful in use-cases when
|
|
||||||
all logins except the console must be stopped, e.g. when performing a
|
|
||||||
flash upgrade on an embedded system.
|
|
||||||
|
|
||||||
When running <kbd>make install</kbd> no default `/etc/finit.conf` will
|
When running <kbd>make install</kbd> no default `/etc/finit.conf` will
|
||||||
be installed since system requirements differ too much. Try out the
|
be installed since system requirements differ too much. Try out the
|
||||||
Debian 6.0 example `/usr/share/doc/finit/finit.conf` configuration that
|
Debian 6.0 example `/usr/share/doc/finit/finit.conf` configuration that
|
||||||
is capable of service monitoring SSH, sysklogd, gdm and a console getty!
|
is capable of service monitoring SSH, sysklogd, gdm and getty!
|
||||||
|
|
||||||
Every `run`, `task`, `service`, or `inetd` can also list the privileges
|
Every `run`, `task`, `service`, or `inetd` can also list the privileges
|
||||||
the `/path/to/cmd` should be executed with. Simply prefix the path with
|
the `/path/to/cmd` should be executed with. Simply prefix the path with
|
||||||
@@ -272,7 +266,6 @@ the above `finit.conf` settings described above, only the following:
|
|||||||
- `inetd`
|
- `inetd`
|
||||||
- `rlimit`
|
- `rlimit`
|
||||||
- `tty`
|
- `tty`
|
||||||
- `console`
|
|
||||||
|
|
||||||
**NOTE:*** The `/etc/finit.d` directory was previously the default Finit
|
**NOTE:*** The `/etc/finit.d` directory was previously the default Finit
|
||||||
`runparts` directory. Finit no longer has a default `runparts`, make
|
`runparts` directory. Finit no longer has a default `runparts`, make
|
||||||
|
|||||||
@@ -347,13 +347,6 @@ static void parse_dynamic(char *line, struct timeval *mtime)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Special TTY console powers */
|
|
||||||
if (MATCH_CMD(line, "console ", x)) {
|
|
||||||
if (console) free(console);
|
|
||||||
console = strdup(strip_line(x));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Regular or serial TTYs to run getty */
|
/* Regular or serial TTYs to run getty */
|
||||||
if (MATCH_CMD(line, "tty ", x)) {
|
if (MATCH_CMD(line, "tty ", x)) {
|
||||||
tty_register(strip_line(x), mtime);
|
tty_register(strip_line(x), mtime);
|
||||||
|
|||||||
+5
-7
@@ -235,7 +235,7 @@ int exec_runtask(char *cmd, char *args[])
|
|||||||
return execvp(_PATH_BSHELL, argv);
|
return execvp(_PATH_BSHELL, argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prepare_tty(char *tty, char *procname, int console)
|
static void prepare_tty(char *tty, char *procname)
|
||||||
{
|
{
|
||||||
struct termios term;
|
struct termios term;
|
||||||
|
|
||||||
@@ -256,8 +256,6 @@ static void prepare_tty(char *tty, char *procname, int console)
|
|||||||
/* Set INIT_PROCESS UTMP entry */
|
/* Set INIT_PROCESS UTMP entry */
|
||||||
utmp_set_init(tty, 0);
|
utmp_set_init(tty, 0);
|
||||||
|
|
||||||
if (console)
|
|
||||||
procname = "console";
|
|
||||||
prctl(PR_SET_NAME, procname, 0, 0, 0);
|
prctl(PR_SET_NAME, procname, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,13 +289,13 @@ static int activate_console(int noclear, int nowait)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t run_getty(char *tty, char *speed, char *term, int noclear, int nowait, int console)
|
pid_t run_getty(char *tty, char *speed, char *term, int noclear, int nowait)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (!pid) {
|
if (!pid) {
|
||||||
prepare_tty(tty, "finit-getty", console);
|
prepare_tty(tty, "finit-getty");
|
||||||
if (activate_console(noclear, nowait))
|
if (activate_console(noclear, nowait))
|
||||||
_exit(getty(tty, speed, term, NULL));
|
_exit(getty(tty, speed, term, NULL));
|
||||||
}
|
}
|
||||||
@@ -305,7 +303,7 @@ pid_t run_getty(char *tty, char *speed, char *term, int noclear, int nowait, int
|
|||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
pid_t run_getty2(char *tty, char *cmd, char *args[], int noclear, int nowait, int console)
|
pid_t run_getty2(char *tty, char *cmd, char *args[], int noclear, int nowait)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
@@ -334,7 +332,7 @@ pid_t run_getty2(char *tty, char *cmd, char *args[], int noclear, int nowait, in
|
|||||||
dup2(fd, STDOUT_FILENO);
|
dup2(fd, STDOUT_FILENO);
|
||||||
dup2(fd, STDERR_FILENO);
|
dup2(fd, STDERR_FILENO);
|
||||||
|
|
||||||
prepare_tty(tty, "getty", console);
|
prepare_tty(tty, "getty");
|
||||||
|
|
||||||
if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0)
|
if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0)
|
||||||
_pe("Failed TIOCSCTTY");
|
_pe("Failed TIOCSCTTY");
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ char *network = NULL;
|
|||||||
char *hostname = NULL;
|
char *hostname = NULL;
|
||||||
char *rcsd = FINIT_RCSD;
|
char *rcsd = FINIT_RCSD;
|
||||||
char *runparts = NULL;
|
char *runparts = NULL;
|
||||||
char *console = NULL;
|
|
||||||
|
|
||||||
uev_ctx_t *ctx = NULL; /* Main loop context */
|
uev_ctx_t *ctx = NULL; /* Main loop context */
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ extern char *sdown;
|
|||||||
extern char *network;
|
extern char *network;
|
||||||
extern char *hostname;
|
extern char *hostname;
|
||||||
extern char *runparts;
|
extern char *runparts;
|
||||||
extern char *console;
|
|
||||||
extern uev_ctx_t *ctx;
|
extern uev_ctx_t *ctx;
|
||||||
|
|
||||||
#endif /* FINIT_H_ */
|
#endif /* FINIT_H_ */
|
||||||
|
|||||||
+2
-2
@@ -65,8 +65,8 @@ int complete (char *cmd, int pid);
|
|||||||
int run (char *cmd);
|
int run (char *cmd);
|
||||||
int run_interactive (char *cmd, char *fmt, ...);
|
int run_interactive (char *cmd, char *fmt, ...);
|
||||||
int exec_runtask (char *cmd, char *args[]);
|
int exec_runtask (char *cmd, char *args[]);
|
||||||
pid_t run_getty (char *tty, char *speed, char *term, int noclear, int nowait, int console);
|
pid_t run_getty (char *tty, char *speed, char *term, int noclear, int nowait);
|
||||||
pid_t run_getty2 (char *tty, char *cmd, char *args[], int noclear, int nowait, int console);
|
pid_t run_getty2 (char *tty, char *cmd, char *args[], int noclear, int nowait);
|
||||||
int run_parts (char *dir, char *cmd);
|
int run_parts (char *dir, char *cmd);
|
||||||
|
|
||||||
static inline void create(char *path, mode_t mode, uid_t uid, gid_t gid)
|
static inline void create(char *path, mode_t mode, uid_t uid, gid_t gid)
|
||||||
|
|||||||
@@ -379,7 +379,6 @@ static int tty_exist(char *dev)
|
|||||||
|
|
||||||
void tty_start(finit_tty_t *tty)
|
void tty_start(finit_tty_t *tty)
|
||||||
{
|
{
|
||||||
int is_console = 0;
|
|
||||||
char *dev;
|
char *dev;
|
||||||
|
|
||||||
if (tty->pid) {
|
if (tty->pid) {
|
||||||
@@ -393,18 +392,15 @@ void tty_start(finit_tty_t *tty)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (console && !strcmp(dev, console))
|
|
||||||
is_console = 1;
|
|
||||||
|
|
||||||
if (tty_exist(dev)) {
|
if (tty_exist(dev)) {
|
||||||
_d("%s: Not a valid TTY: %s", dev, strerror(errno));
|
_d("%s: Not a valid TTY: %s", dev, strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tty->cmd)
|
if (!tty->cmd)
|
||||||
tty->pid = run_getty(dev, tty->baud, tty->term, tty->noclear, tty->nowait, is_console);
|
tty->pid = run_getty(dev, tty->baud, tty->term, tty->noclear, tty->nowait);
|
||||||
else
|
else
|
||||||
tty->pid = run_getty2(dev, tty->cmd, tty->args, tty->noclear, tty->nowait, is_console);
|
tty->pid = run_getty2(dev, tty->cmd, tty->args, tty->noclear, tty->nowait);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tty_stop(finit_tty_t *tty)
|
void tty_stop(finit_tty_t *tty)
|
||||||
|
|||||||
Reference in new issue
Block a user