Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion usr.sbin/jail/jail.8
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
25 changes: 22 additions & 3 deletions usr.sbin/jail/jail.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}

/*
Expand Down Expand Up @@ -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, '"') ? '\''
Expand Down