Compare commits

...

7 Commits
0.47 ... 0.41.2

Author SHA1 Message Date
William Hubbs
882c6bf3bc version 0.41.2 2019-02-25 19:18:51 -06:00
William Hubbs
91e14acf98 Update ChangeLog 2019-02-25 19:15:48 -06:00
William Hubbs
238042d28b 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.
2019-02-25 19:12:23 -06:00
William Hubbs
8d6370d469 version 0.41.1 2019-02-23 18:06:00 -06:00
William Hubbs
75ce3addd2 update ChangeLog 2019-02-23 18:03:28 -06:00
William Hubbs
d818be6e2b librc: fix potential buffer overflow in pid_is_argv
This fixes #299.
2019-02-23 18:00:08 -06:00
William Hubbs
b812524303 Revert "src/librc/librc-daemon.c: fix buffer overrun in pid_is_argv"
This reverts commit 084877eb52.
The mentioned commit caused some systems to have some services reported
as crashed.

This fixes #297.
This fixes #298.
2019-02-23 18:00:08 -06:00
4 changed files with 88 additions and 86 deletions

View File

@@ -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
Author: 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>
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

View File

@@ -1,3 +1,3 @@
NAME= openrc
VERSION= 0.41
VERSION= 0.41.2
PKG= ${NAME}-${VERSION}

View File

@@ -48,40 +48,34 @@ pid_is_exec(pid_t pid, const char *exec)
static bool
pid_is_argv(pid_t pid, const char *const *argv)
{
char *buffer = NULL;
char *cmdline = NULL;
int fd;
char buffer[PATH_MAX];
char *p;
size_t bytes;
bool rc;
ssize_t bytes;
xasprintf(&cmdline, "/proc/%u/cmdline", pid);
if (!rc_getfile(cmdline, &buffer, &bytes)) {
if ((fd = open(cmdline, O_RDONLY)) < 0) {
free(cmdline);
return false;
}
bytes = read(fd, buffer, sizeof(buffer) - 1);
close(fd);
free(cmdline);
if (bytes <= 0) {
if (buffer)
free(buffer);
if (bytes == -1)
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++;
p += strlen(p) + 1;
if ((unsigned)(p - buffer) >= bytes) {
rc = false;
break;
}
if ((unsigned)(p - buffer) > sizeof(buffer))
return false;
}
free(buffer);
return rc;
return true;
}
RC_PIDLIST *

View File

@@ -43,40 +43,45 @@
static const char *path_default = "/sbin:/usr/sbin:/bin:/usr/bin";
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;
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();
switch (pid) {
case -1:
perror("fork");
exit(1);
break;
case 0:
setsid();
/* unblock all signals */
sigemptyset(&signals);
sigprocmask(SIG_SETMASK, &signals, NULL);
sigprocmask(SIG_UNBLOCK, &all_signals, NULL);
printf("Starting %s runlevel\n", runlevel);
execlp("openrc", "openrc", runlevel, NULL);
perror("exec");
exit(1);
break;
default:
/* restore our signal mask */
sigprocmask(SIG_SETMASK, &our_signals, NULL);
while (waitpid(pid, NULL, 0) != pid)
if (errno == ECHILD)
break;
break;
}
return pid;
}
static void init(const char *default_runlevel)
{
const char *runlevel = NULL;
pid_t pid;
pid = do_openrc("sysinit");
waitpid(pid, NULL, 0);
pid = do_openrc("boot");
waitpid(pid, NULL, 0);
do_openrc("sysinit");
do_openrc("boot");
if (default_runlevel)
runlevel = default_runlevel;
else
@@ -87,8 +92,7 @@ static void init(const char *default_runlevel)
printf("%s is an invalid runlevel\n", runlevel);
runlevel = rc_default_runlevel;
}
pid = do_openrc(runlevel);
waitpid(pid, NULL, 0);
do_openrc(runlevel);
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)
{
pid_t pid;
struct timespec ts;
pid = do_openrc(runlevel);
while (waitpid(pid, NULL, 0) != pid);
do_openrc(runlevel);
printf("Sending the final term signal\n");
kill(-1, SIGTERM);
ts.tv_sec = 3;
@@ -118,10 +120,7 @@ static void handle_shutdown(const char *runlevel, int cmd)
static void handle_single(void)
{
pid_t pid;
pid = do_openrc("single");
while (waitpid(pid, NULL, 0) != pid);
do_openrc("single");
}
static void reap_zombies(void)