Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Change my mind a bit:
Browse files Browse the repository at this point in the history
When no -j argument is specified, walk the list to get the most
capable jail technology which can run in the given circumstances.
  • Loading branch information
bsdphk committed Feb 16, 2015
1 parent bb52bd5 commit dec92d3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bin/varnishd/mgt/mgt.h
Expand Up @@ -77,7 +77,7 @@ enum jail_master_e {
JAIL_MASTER_HIGH,
};

typedef void jail_init_f(char **);
typedef int jail_init_f(char **);
typedef void jail_master_f(enum jail_master_e);
typedef void jail_subproc_f(enum jail_subproc_e);

Expand Down
17 changes: 13 additions & 4 deletions bin/varnishd/mgt/mgt_jail.c
Expand Up @@ -44,11 +44,12 @@
* A "none" jail implementation which doesn't do anything.
*/

static void __match_proto__(jail_init_f)
static int __match_proto__(jail_init_f)
vjn_init(char **args)
{
if (*args != NULL)
ARGV_ERR("-Jnone takes no arguments.\n");
return (0);
}

static void __match_proto__(jail_master_f)
Expand Down Expand Up @@ -84,6 +85,7 @@ void
VJ_Init(const char *j_arg)
{
char **av;
int i;

if (j_arg != NULL) {
av = VAV_Parse(j_arg, NULL, ARGV_COMMA);
Expand All @@ -97,10 +99,17 @@ VJ_Init(const char *j_arg)
vjt->init(av + 2);
VAV_Free(av);
} else {
/*
* Go through list of jail technologies until one
* succeeds, falling back to "none".
*/
av = VAV_Parse("", NULL, ARGV_COMMA);
vjt = vj_choice[0].ptr;
CHECK_OBJ_NOTNULL(vjt, JAIL_TECH_MAGIC);
vjt->init(av + 1);
for (i = 0; vj_choice[i].name != NULL; i++) {
vjt = vj_choice[i].ptr;
CHECK_OBJ_NOTNULL(vjt, JAIL_TECH_MAGIC);
if (!vjt->init(av + 1))
break;
}
VAV_Free(av);
}
}
Expand Down

0 comments on commit dec92d3

Please sign in to comment.