added hook_as_emperor_setns

This commit is contained in:
Unbit
2014-08-11 10:14:49 +02:00
parent 33f463284c
commit fc6f125d17
2 changed files with 17 additions and 1 deletions
+15 -1
View File
@@ -748,8 +748,22 @@ void uwsgi_hooks_setns_run(struct uwsgi_string_list *l, pid_t pid, uid_t uid, gi
}
// now run the action and then exit
exit(0);
action++;
char *colon = strchr(action, ':');
if (!colon) {
uwsgi_log("invalid hook syntax must be action:arg\n");
exit(1);
}
*colon = 0;
struct uwsgi_hook *uh = uwsgi_hook_by_name(action);
if (!uh) {
uwsgi_log("hook action not found: %s\n", action);
exit(1);
}
*colon = ':';
uwsgi_log("running \"%s\" (setns)...\n", usl->value);
exit(uh->func(colon+1));
}
else {
uwsgi_error("uwsgi_hooks_setns_run()/fork()");
+2
View File
@@ -425,6 +425,8 @@ static struct uwsgi_option uwsgi_base_options[] = {
{"hook-as-emperor-before-vassal", required_argument, 0, "run the specified hook before the new vassal is spawned", uwsgi_opt_add_string_list, &uwsgi.hook_as_emperor_before_vassal, 0},
{"hook-as-vassal-before-drop", required_argument, 0, "run the specified hook into vassal, before dropping its privileges", uwsgi_opt_add_string_list, &uwsgi.hook_as_vassal_before_drop, 0},
{"hook-as-emperor-setns", required_argument, 0, "run the specified hook in the emperor entering vassal namespace", uwsgi_opt_add_string_list, &uwsgi.hook_as_emperor_setns, 0},
{"hook-as-mule", required_argument, 0, "run the specified hook in each mule", uwsgi_opt_add_string_list, &uwsgi.hook_as_mule, 0},
{"hook-as-gateway", required_argument, 0, "run the specified hook in each gateway", uwsgi_opt_add_string_list, &uwsgi.hook_as_gateway, 0},