Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
882c6bf3bc | ||
|
|
91e14acf98 | ||
|
|
238042d28b | ||
|
|
8d6370d469 | ||
|
|
75ce3addd2 | ||
|
|
d818be6e2b | ||
|
|
b812524303 |
97
ChangeLog
97
ChangeLog
@@ -1,3 +1,56 @@
|
|||||||
|
commit 238042d28b85277a4b5f19c3d13c4331b1325662
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
openrc-init: fix waitpid checks
|
||||||
|
|
||||||
|
The do_openrc() function was not waiting properly for the child process
|
||||||
|
which started the runlevel to return. We need to repeatedly call
|
||||||
|
waitpid() until its return value matches the pid of the child process or
|
||||||
|
the child process does not exist.
|
||||||
|
|
||||||
|
This fixes #216.
|
||||||
|
This fixes #300.
|
||||||
|
|
||||||
|
commit 8d6370d4693f6f8397b808059e5fe436c8dc8993
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
version 0.41.1
|
||||||
|
|
||||||
|
commit 75ce3addd2be964ce271858af08e7f750365916a
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
update ChangeLog
|
||||||
|
|
||||||
|
commit d818be6e2bc00c790f6f4aeb2670f007951b2ab3
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
librc: fix potential buffer overflow in pid_is_argv
|
||||||
|
|
||||||
|
This fixes #299.
|
||||||
|
|
||||||
|
commit b812524303ae42bf7f61a642c45e8be39aa222e5
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
Revert "src/librc/librc-daemon.c: fix buffer overrun in pid_is_argv"
|
||||||
|
|
||||||
|
This reverts commit 084877eb52971faf8f52c780ddd08ed9af140eb6.
|
||||||
|
The mentioned commit caused some systems to have some services reported
|
||||||
|
as crashed.
|
||||||
|
|
||||||
|
This fixes #297.
|
||||||
|
This fixes #298.
|
||||||
|
|
||||||
|
commit 56c006ebd68d572e303c01c38291a1f5f4fc1c30
|
||||||
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
|
Update ChangeLog
|
||||||
|
|
||||||
commit 067088bbff42ca2fb9106acf309f1d9ce3e78ada
|
commit 067088bbff42ca2fb9106acf309f1d9ce3e78ada
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
Author: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
@@ -1428,47 +1481,3 @@ Author: William Hubbs <w.d.hubbs@gmail.com>
|
|||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
||||||
|
|
||||||
openrc-init: convert execl calls to execlp
|
openrc-init: convert execl calls to execlp
|
||||||
|
|
||||||
commit f383fd87b121492a04362ca9041f686d981718f1
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
kill_all: change execl call to execlp
|
|
||||||
|
|
||||||
commit cfded513cd9b7febe4b7cf39a80411e4303f0655
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
openrc-init: set a default path
|
|
||||||
|
|
||||||
The default path provided by the system if one isn't set only includes
|
|
||||||
"/bin:/usr/bin". This adds the default path setting from sysvinit.
|
|
||||||
|
|
||||||
commit 16ff3cd8df6169f73e3d7cf00758a4703f62cbf0
|
|
||||||
Author: Christian Brauner <christian.brauner@ubuntu.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
check whether /sys/fs/cgroup is a mountpoint
|
|
||||||
|
|
||||||
The current check only tries to detect whether /sys/fs/cgroup exists and
|
|
||||||
whether it is writable or not. But when the init system doesn't mount
|
|
||||||
cgroups then /sys/fs/cgroup will just be an empty directory. When paired
|
|
||||||
with unprivileged containers that mount sysfs this will cause misleading
|
|
||||||
errors to be printed since /sys/fs/cgroup will be owned by user
|
|
||||||
nobody:nogroup in this case. Independent of this specific problem this
|
|
||||||
check will also be misleading when the /sys/fs/cgroup exists and is in
|
|
||||||
fact writable by the init system but isn't actually a mountpoint.
|
|
||||||
|
|
||||||
Note from William. "grep -qs" doesn't need to redirect output to
|
|
||||||
/dev/null since it is completely silent.
|
|
||||||
|
|
||||||
This fixes #209.
|
|
||||||
|
|
||||||
commit 38032626a6c2f8e869197999f32ac3634667cc86
|
|
||||||
Author: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
Commit: William Hubbs <w.d.hubbs@gmail.com>
|
|
||||||
|
|
||||||
improve cgroup configuration checks
|
|
||||||
|
|
||||||
make the base/controller functions return successfully if cgroups v1/v2
|
|
||||||
are not configured in the kernel
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
NAME= openrc
|
NAME= openrc
|
||||||
VERSION= 0.41
|
VERSION= 0.41.2
|
||||||
PKG= ${NAME}-${VERSION}
|
PKG= ${NAME}-${VERSION}
|
||||||
|
|||||||
@@ -48,40 +48,34 @@ pid_is_exec(pid_t pid, const char *exec)
|
|||||||
static bool
|
static bool
|
||||||
pid_is_argv(pid_t pid, const char *const *argv)
|
pid_is_argv(pid_t pid, const char *const *argv)
|
||||||
{
|
{
|
||||||
char *buffer = NULL;
|
|
||||||
char *cmdline = NULL;
|
char *cmdline = NULL;
|
||||||
|
int fd;
|
||||||
|
char buffer[PATH_MAX];
|
||||||
char *p;
|
char *p;
|
||||||
size_t bytes;
|
ssize_t bytes;
|
||||||
bool rc;
|
|
||||||
|
|
||||||
xasprintf(&cmdline, "/proc/%u/cmdline", pid);
|
xasprintf(&cmdline, "/proc/%u/cmdline", pid);
|
||||||
if (!rc_getfile(cmdline, &buffer, &bytes)) {
|
if ((fd = open(cmdline, O_RDONLY)) < 0) {
|
||||||
free(cmdline);
|
free(cmdline);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
bytes = read(fd, buffer, sizeof(buffer) - 1);
|
||||||
|
close(fd);
|
||||||
free(cmdline);
|
free(cmdline);
|
||||||
if (bytes <= 0) {
|
if (bytes == -1)
|
||||||
if (buffer)
|
|
||||||
free(buffer);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
p = buffer;
|
|
||||||
rc = true;
|
|
||||||
while (*argv) {
|
|
||||||
if (strcmp(*argv, p) != 0) {
|
|
||||||
rc = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
buffer[bytes] = '\0';
|
||||||
|
p = buffer;
|
||||||
|
while (*argv) {
|
||||||
|
if (strcmp(*argv, p) != 0)
|
||||||
|
return false;
|
||||||
argv++;
|
argv++;
|
||||||
p += strlen(p) + 1;
|
p += strlen(p) + 1;
|
||||||
if ((unsigned)(p - buffer) >= bytes) {
|
if ((unsigned)(p - buffer) > sizeof(buffer))
|
||||||
rc = false;
|
return false;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
free(buffer);
|
|
||||||
return rc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RC_PIDLIST *
|
RC_PIDLIST *
|
||||||
|
|||||||
@@ -43,40 +43,45 @@
|
|||||||
static const char *path_default = "/sbin:/usr/sbin:/bin:/usr/bin";
|
static const char *path_default = "/sbin:/usr/sbin:/bin:/usr/bin";
|
||||||
static const char *rc_default_runlevel = "default";
|
static const char *rc_default_runlevel = "default";
|
||||||
|
|
||||||
static pid_t do_openrc(const char *runlevel)
|
static void do_openrc(const char *runlevel)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
sigset_t signals;
|
sigset_t all_signals;
|
||||||
|
sigset_t our_signals;
|
||||||
|
|
||||||
|
sigfillset(&all_signals);
|
||||||
|
/* block all signals */
|
||||||
|
sigprocmask(SIG_BLOCK, &all_signals, &our_signals);
|
||||||
pid = fork();
|
pid = fork();
|
||||||
switch (pid) {
|
switch (pid) {
|
||||||
case -1:
|
case -1:
|
||||||
perror("fork");
|
perror("fork");
|
||||||
|
exit(1);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
setsid();
|
setsid();
|
||||||
/* unblock all signals */
|
/* unblock all signals */
|
||||||
sigemptyset(&signals);
|
sigprocmask(SIG_UNBLOCK, &all_signals, NULL);
|
||||||
sigprocmask(SIG_SETMASK, &signals, NULL);
|
|
||||||
printf("Starting %s runlevel\n", runlevel);
|
printf("Starting %s runlevel\n", runlevel);
|
||||||
execlp("openrc", "openrc", runlevel, NULL);
|
execlp("openrc", "openrc", runlevel, NULL);
|
||||||
perror("exec");
|
perror("exec");
|
||||||
|
exit(1);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
/* restore our signal mask */
|
||||||
|
sigprocmask(SIG_SETMASK, &our_signals, NULL);
|
||||||
|
while (waitpid(pid, NULL, 0) != pid)
|
||||||
|
if (errno == ECHILD)
|
||||||
|
break;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return pid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init(const char *default_runlevel)
|
static void init(const char *default_runlevel)
|
||||||
{
|
{
|
||||||
const char *runlevel = NULL;
|
const char *runlevel = NULL;
|
||||||
pid_t pid;
|
do_openrc("sysinit");
|
||||||
|
do_openrc("boot");
|
||||||
pid = do_openrc("sysinit");
|
|
||||||
waitpid(pid, NULL, 0);
|
|
||||||
pid = do_openrc("boot");
|
|
||||||
waitpid(pid, NULL, 0);
|
|
||||||
if (default_runlevel)
|
if (default_runlevel)
|
||||||
runlevel = default_runlevel;
|
runlevel = default_runlevel;
|
||||||
else
|
else
|
||||||
@@ -87,8 +92,7 @@ static void init(const char *default_runlevel)
|
|||||||
printf("%s is an invalid runlevel\n", runlevel);
|
printf("%s is an invalid runlevel\n", runlevel);
|
||||||
runlevel = rc_default_runlevel;
|
runlevel = rc_default_runlevel;
|
||||||
}
|
}
|
||||||
pid = do_openrc(runlevel);
|
do_openrc(runlevel);
|
||||||
waitpid(pid, NULL, 0);
|
|
||||||
log_wtmp("reboot", "~~", 0, RUN_LVL, "~~");
|
log_wtmp("reboot", "~~", 0, RUN_LVL, "~~");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,11 +104,9 @@ static void handle_reexec(char *my_name)
|
|||||||
|
|
||||||
static void handle_shutdown(const char *runlevel, int cmd)
|
static void handle_shutdown(const char *runlevel, int cmd)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
pid = do_openrc(runlevel);
|
do_openrc(runlevel);
|
||||||
while (waitpid(pid, NULL, 0) != pid);
|
|
||||||
printf("Sending the final term signal\n");
|
printf("Sending the final term signal\n");
|
||||||
kill(-1, SIGTERM);
|
kill(-1, SIGTERM);
|
||||||
ts.tv_sec = 3;
|
ts.tv_sec = 3;
|
||||||
@@ -118,10 +120,7 @@ static void handle_shutdown(const char *runlevel, int cmd)
|
|||||||
|
|
||||||
static void handle_single(void)
|
static void handle_single(void)
|
||||||
{
|
{
|
||||||
pid_t pid;
|
do_openrc("single");
|
||||||
|
|
||||||
pid = do_openrc("single");
|
|
||||||
while (waitpid(pid, NULL, 0) != pid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reap_zombies(void)
|
static void reap_zombies(void)
|
||||||
|
|||||||
Reference in New Issue
Block a user