diff --git a/usr.sbin/jail/jail.8 b/usr.sbin/jail/jail.8 index d44b7f66a64eda..a9b076b79d9655 100644 --- a/usr.sbin/jail/jail.8 +++ b/usr.sbin/jail/jail.8 @@ -105,7 +105,9 @@ Exhibit a list of all configured non-wildcard jails and their parameters. No jail creation, modification or removal performed if this option is used. The .Ar separator -string is used to separate parameters. +string is used to separate parameters. If the separator string is empty ('' +or "") then each parameter will be followed by a NUL byte, with one additional +NUL byte at end of each jail's parameters. Use .Xr jls 8 utility to list running jails. diff --git a/usr.sbin/jail/jail.c b/usr.sbin/jail/jail.c index 46cabf76ae110c..50cc6fb562bd3a 100644 --- a/usr.sbin/jail/jail.c +++ b/usr.sbin/jail/jail.c @@ -978,6 +978,7 @@ print_jail(FILE *fp, struct cfjail *j, int oldcl, int running) #endif fputs(separator, fp); print_param(fp, j->intparams[IP_COMMAND], ' ', 0); + putc('\n', fp); } else { printsep = 0; if (running) { @@ -987,13 +988,18 @@ print_jail(FILE *fp, struct cfjail *j, int oldcl, int running) TAILQ_FOREACH(p, &j->params, tq) if (strcmp(p->name, "jid")) { if (printsep) - fputs(separator, fp); + *separator ? fputs(separator, fp) : putc(0, fp); else printsep = 1; - print_param(fp, p, ',', 1); + print_param(fp, p, *separator ? ',' : '\n', 1); } + if (*separator) + putc('\n', fp); + else { + putc(0, fp); // end of value line + putc(0, fp); // end of this jail + } } - putc('\n', fp); } /* @@ -1038,6 +1044,19 @@ quoted_print(FILE *fp, char *str) int c, qc; char *p = str; +/* + * In NUL-delimited mode, output the string as-is with + * no quoting or escaping of any characters. + */ + + if (*separator == 0) { + fputs( str, fp ); + return; + } + +/* + * Otherwise, process it the way we always do: + */ qc = !*p ? '"' : strchr(p, '\'') ? '"' : strchr(p, '"') ? '\''