Compare commits

..

10 Commits

Author SHA1 Message Date
William Hubbs
fe86e7691d Update ChangeLog 2017-09-18 17:16:11 -05:00
William Hubbs
038cea416c ignore sigchld when shutting down the supervised process
We need to do this to skip the zombie state for the child process since
we are not easily able to wait() for it.
2017-09-18 17:06:17 -05:00
William Hubbs
e2bd550d13 typo fix 2017-09-18 13:33:19 -05:00
William Hubbs
ac49814607 typo fix 2017-09-18 13:06:52 -05:00
William Hubbs
09fc8fe09c supervise-daemon: code cleanup
Clean up the process for killing an active supervisor when stopping.
2017-09-18 12:28:58 -05:00
William Hubbs
3a2774732a initialize the stop schedule 2017-09-18 11:57:53 -05:00
William Hubbs
dec0722c30 rc-schedules.c: pass the correct pid to rc_find_pids
This is for #163.
2017-09-18 10:28:42 -05:00
Jason Zaman
949daeb68b selinux: fix const qualifier warning
rc-selinux.c: In function ‘selinux_setup’:
rc-selinux.c:361:9: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  curr_t = context_type_get(curr_con);
         ^
2017-09-18 10:28:42 -05:00
Jason Zaman
fbab2affd2 selinux: use openrc contexts path to get contexts
The minimum requirement for libselinux is now >=2.6
The refpolicy and the gentoo policy contain the
contexts since version 2.20170204-r4
2017-09-18 10:28:42 -05:00
William Hubbs
2824905935 version 0.31.2 2017-09-18 09:55:17 -05:00
6 changed files with 115 additions and 22 deletions

View File

@@ -1,3 +1,79 @@
commit 038cea416c0a4cda83872733ab660cf0bb2b5eaf
Author: William Hubbs <w.d.hubbs@gmail.com>
Commit: William Hubbs <w.d.hubbs@gmail.com>
ignore sigchld when shutting down the supervised process
We need to do this to skip the zombie state for the child process since
we are not easily able to wait() for it.
commit e2bd550d13d23ce132650d7e3dc36dc512bf048e
Author: William Hubbs <w.d.hubbs@gmail.com>
Commit: William Hubbs <w.d.hubbs@gmail.com>
typo fix
commit ac498146071636a3fbda4fb48ff64102c244415d
Author: William Hubbs <w.d.hubbs@gmail.com>
Commit: William Hubbs <w.d.hubbs@gmail.com>
typo fix
commit 09fc8fe09c01a347666de66fb11e759de371a873
Author: William Hubbs <w.d.hubbs@gmail.com>
Commit: William Hubbs <w.d.hubbs@gmail.com>
supervise-daemon: code cleanup
Clean up the process for killing an active supervisor when stopping.
commit 3a2774732aa629083bc6395c5c7a8a3040e64b60
Author: William Hubbs <w.d.hubbs@gmail.com>
Commit: William Hubbs <w.d.hubbs@gmail.com>
initialize the stop schedule
commit dec0722c30e41480d300549a69d3672c38e0c15d
Author: William Hubbs <w.d.hubbs@gmail.com>
Commit: William Hubbs <w.d.hubbs@gmail.com>
rc-schedules.c: pass the correct pid to rc_find_pids
This is for #163.
commit 949daeb68b2a39fa1e64f2eb3fa72579f98df09e
Author: Jason Zaman <jason@perfinion.com>
Commit: William Hubbs <w.d.hubbs@gmail.com>
selinux: fix const qualifier warning
rc-selinux.c: In function selinux_setup:
rc-selinux.c:361:9: warning: assignment discards const qualifier from pointer target type [-Wdiscarded-qualifiers]
curr_t = context_type_get(curr_con);
^
commit fbab2affd2d5309ed4b5416e0e239902d77b4232
Author: Jason Zaman <jason@perfinion.com>
Commit: William Hubbs <w.d.hubbs@gmail.com>
selinux: use openrc contexts path to get contexts
The minimum requirement for libselinux is now >=2.6
The refpolicy and the gentoo policy contain the
contexts since version 2.20170204-r4
commit 28249059356d8b611a46c5493574abe9805ab48b
Author: William Hubbs <w.d.hubbs@gmail.com>
Commit: William Hubbs <w.d.hubbs@gmail.com>
version 0.31.2
commit 60eadd5fa2ba2675caab4f977b8627bc07e39e8e
Author: William Hubbs <w.d.hubbs@gmail.com>
Commit: William Hubbs <w.d.hubbs@gmail.com>
Update ChangeLog
commit 2a203b9b6e91e4ed140750eb9223012035870864
Author: William Hubbs <w.d.hubbs@gmail.com>
Commit: William Hubbs <w.d.hubbs@gmail.com>

View File

@@ -1,3 +1,3 @@
NAME= openrc
VERSION= 0.31.1
VERSION= 0.31.2
PKG= ${NAME}-${VERSION}

View File

@@ -56,11 +56,6 @@ typedef struct scheduleitem {
static TAILQ_HEAD(, scheduleitem) schedule;
void initialize_schedulelist(void)
{
TAILQ_INIT(&schedule);
}
void free_schedulelist(void)
{
SCHEDULEITEM *s1 = TAILQ_FIRST(&schedule);
@@ -186,6 +181,7 @@ void parse_schedule(const char *applet, const char *string, int timeout)
size_t len;
SCHEDULEITEM *item;
TAILQ_INIT(&schedule);
if (string)
for (slash = string; *slash; slash++)
if (*slash == '/')
@@ -261,10 +257,10 @@ int do_stop(const char *applet, const char *exec, const char *const *argv,
bool killed;
int nkilled = 0;
if (pid)
if (pid > 0)
pids = rc_find_pids(NULL, NULL, 0, pid);
else
pids = rc_find_pids(exec, argv, uid, pid);
pids = rc_find_pids(exec, argv, uid, 0);
if (!pids)
return 0;

View File

@@ -13,7 +13,6 @@
#ifndef __RC_SCHEDULES_H
#define __RC_SCHEDULES_H
void initialize_schedulelist(void);
void free_schedulelist(void);
int parse_signal(const char *applet, const char *sig);
void parse_schedule(const char *applet, const char *string, int timeout);

View File

@@ -39,7 +39,6 @@
#include "rc-selinux.h"
/* the context files for selinux */
#define RUN_INIT_FILE "run_init_type"
#define INITRC_FILE "initrc_context"
#ifdef HAVE_AUDIT
@@ -299,6 +298,26 @@ static int read_context_file(const char *filename, char **context)
return ret;
}
static int read_run_init_context(char **context)
{
int ret = -1;
RC_STRINGLIST *list;
char *value = NULL;
list = rc_config_list(selinux_openrc_contexts_path());
if (list == NULL)
return ret;
value = rc_config_value(list, "run_init");
if (value != NULL && strlen(value) > 0) {
*context = xstrdup(value);
ret = 0;
}
rc_stringlist_free(list);
return ret;
}
void selinux_setup(char **argv)
{
char *new_context = NULL;
@@ -312,7 +331,7 @@ void selinux_setup(char **argv)
return;
}
if (read_context_file(RUN_INIT_FILE, &run_init_t) != 0) {
if (read_run_init_context(&run_init_t) != 0) {
/* assume a reasonable default, rather than bailing out */
run_init_t = xstrdup("run_init_t");
ewarn("Assuming SELinux run_init type is %s", run_init_t);
@@ -339,14 +358,13 @@ void selinux_setup(char **argv)
goto out;
}
curr_t = context_type_get(curr_con);
curr_t = xstrdup(context_type_get(curr_con));
if (!curr_t) {
context_free(curr_con);
free(curr_context);
goto out;
}
curr_t = xstrdup(curr_t);
/* dont need them anymore so free() now */
context_free(curr_con);
free(curr_context);

View File

@@ -432,6 +432,7 @@ int main(int argc, char **argv)
int respawn_period = 5;
time_t respawn_now= 0;
time_t first_spawn= 0;
struct timespec ts;
struct passwd *pw;
struct group *gr;
FILE *fp;
@@ -658,17 +659,19 @@ int main(int argc, char **argv)
if (stop) {
pid = get_pid(applet, pidfile);
if (pid == -1)
i = pid;
else
if (pid != -1) {
i = kill(pid, SIGTERM);
if (i != 0)
/* We failed to send the signal */
exit(EXIT_FAILURE);
if (i != 0)
/* We failed to send the signal */
exit(EXIT_FAILURE);
/* wait for the supervisor to go down */
while (kill(pid, 0) == 0)
sleep(1);
/* wait for the supervisor to go down */
while (kill(pid, 0) == 0) {
ts.tv_sec = 0;
ts.tv_nsec = 1;
nanosleep(&ts, NULL);
}
}
/* Even if we have not actually killed anything, we should
* remove information about it as it may have unexpectedly
@@ -750,6 +753,7 @@ int main(int argc, char **argv)
while (!exiting) {
wait(&i);
if (exiting) {
signal_setup(SIGCHLD, SIG_IGN);
syslog(LOG_INFO, "stopping %s, pid %d", exec, child_pid);
nkilled = run_stop_schedule(applet, exec, NULL, child_pid,
0, false, false, true);