Kill several SysV compat functionalities (v258) (#38178)
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.0-or-later */
|
||||
/*
|
||||
* Copyright (C) 1995-2004 Miquel van Smoorenburg
|
||||
* Version: @(#)initreq.h 1.28 31-Mar-2004 MvS
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "forward.h"
|
||||
|
||||
#if defined(__FreeBSD_kernel__)
|
||||
# define INIT_FIFO "/etc/.initctl"
|
||||
#else
|
||||
# define INIT_FIFO "/dev/initctl"
|
||||
#endif
|
||||
|
||||
#define INIT_MAGIC 0x03091969
|
||||
#define INIT_CMD_START 0
|
||||
#define INIT_CMD_RUNLVL 1
|
||||
#define INIT_CMD_POWERFAIL 2
|
||||
#define INIT_CMD_POWERFAILNOW 3
|
||||
#define INIT_CMD_POWEROK 4
|
||||
#define INIT_CMD_BSD 5
|
||||
#define INIT_CMD_SETENV 6
|
||||
#define INIT_CMD_UNSETENV 7
|
||||
|
||||
#define INIT_CMD_CHANGECONS 12345
|
||||
/*
|
||||
* This is what BSD 4.4 uses when talking to init.
|
||||
* Linux doesn't use this right now.
|
||||
*/
|
||||
struct init_request_bsd {
|
||||
char gen_id[8]; /* Beats me.. telnetd uses "fe" */
|
||||
char tty_id[16]; /* Tty name minus /dev/tty */
|
||||
char host[HOST_NAME_MAX]; /* Hostname */
|
||||
char term_type[16]; /* Terminal type */
|
||||
int signal; /* Signal to send */
|
||||
int pid; /* Process to send to */
|
||||
char exec_name[128]; /* Program to execute */
|
||||
char reserved[128]; /* For future expansion. */
|
||||
};
|
||||
|
||||
/*
|
||||
* Because of legacy interfaces, "runlevel" and "sleeptime"
|
||||
* aren't in a separate struct in the union.
|
||||
*
|
||||
* The weird sizes are because init expects the whole
|
||||
* struct to be 384 bytes.
|
||||
*/
|
||||
struct init_request {
|
||||
int magic; /* Magic number */
|
||||
int cmd; /* What kind of request */
|
||||
int runlevel; /* Runlevel to change to */
|
||||
int sleeptime; /* Time between TERM and KILL */
|
||||
union {
|
||||
struct init_request_bsd bsd;
|
||||
char data[368];
|
||||
} i;
|
||||
};
|
||||
@@ -11,44 +11,6 @@
|
||||
#include "time-util.h"
|
||||
#include "utmp-wtmp.h"
|
||||
|
||||
int utmp_get_runlevel(int *runlevel, int *previous) {
|
||||
_unused_ _cleanup_(utxent_cleanup) bool utmpx = false;
|
||||
struct utmpx *found, lookup = { .ut_type = RUN_LVL };
|
||||
const char *e;
|
||||
|
||||
assert(runlevel);
|
||||
|
||||
/* If these values are set in the environment this takes
|
||||
* precedence. Presumably, sysvinit does this to work around a
|
||||
* race condition that would otherwise exist where we'd always
|
||||
* go to disk and hence might read runlevel data that might be
|
||||
* very new and not apply to the current script being executed. */
|
||||
|
||||
e = getenv("RUNLEVEL");
|
||||
if (!isempty(e)) {
|
||||
*runlevel = e[0];
|
||||
if (previous)
|
||||
*previous = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (utmpxname(UTMPX_FILE) < 0)
|
||||
return -errno;
|
||||
|
||||
utmpx = utxent_start();
|
||||
|
||||
found = getutxid(&lookup);
|
||||
if (!found)
|
||||
return -errno;
|
||||
|
||||
*runlevel = found->ut_pid & 0xFF;
|
||||
if (previous)
|
||||
*previous = (found->ut_pid >> 8) & 0xFF;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void init_timestamp(struct utmpx *store, usec_t t) {
|
||||
assert(store);
|
||||
|
||||
@@ -237,33 +199,3 @@ int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
|
||||
|
||||
return write_utmp_wtmp(&store, &store_wtmp);
|
||||
}
|
||||
|
||||
int utmp_put_runlevel(int runlevel, int previous) {
|
||||
struct utmpx store = {};
|
||||
int r;
|
||||
|
||||
assert(runlevel > 0);
|
||||
|
||||
if (previous <= 0) {
|
||||
/* Find the old runlevel automatically */
|
||||
|
||||
r = utmp_get_runlevel(&previous, NULL);
|
||||
if (r < 0) {
|
||||
if (r != -ESRCH)
|
||||
return r;
|
||||
|
||||
previous = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (previous == runlevel)
|
||||
return 0;
|
||||
|
||||
init_entry(&store, 0);
|
||||
|
||||
store.ut_type = RUN_LVL;
|
||||
store.ut_pid = (runlevel & 0xFF) | ((previous & 0xFF) << 8);
|
||||
strncpy(store.ut_user, "runlevel", sizeof(store.ut_user));
|
||||
|
||||
return write_entry_both(&store);
|
||||
}
|
||||
|
||||
@@ -6,11 +6,8 @@
|
||||
#if ENABLE_UTMP
|
||||
#include <utmpx.h>
|
||||
|
||||
int utmp_get_runlevel(int *runlevel, int *previous);
|
||||
|
||||
int utmp_put_shutdown(void);
|
||||
int utmp_put_reboot(usec_t timestamp);
|
||||
int utmp_put_runlevel(int runlevel, int previous);
|
||||
|
||||
int utmp_put_dead_process(const char *id, pid_t pid, int code, int status);
|
||||
int utmp_put_init_process(const char *id, pid_t pid, pid_t sid, const char *line, int ut_type, const char *user);
|
||||
@@ -27,18 +24,12 @@ static inline void utxent_cleanup(bool *initialized) {
|
||||
|
||||
#else /* ENABLE_UTMP */
|
||||
|
||||
static inline int utmp_get_runlevel(int *runlevel, int *previous) {
|
||||
return -ESRCH;
|
||||
}
|
||||
static inline int utmp_put_shutdown(void) {
|
||||
return 0;
|
||||
}
|
||||
static inline int utmp_put_reboot(usec_t timestamp) {
|
||||
return 0;
|
||||
}
|
||||
static inline int utmp_put_runlevel(int runlevel, int previous) {
|
||||
return 0;
|
||||
}
|
||||
static inline int utmp_put_dead_process(const char *id, pid_t pid, int code, int status) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user