make the dest field with -b optional am: 8f0665b0ce
am: e9c91403fd
Change-Id: Ic295bb2ddaad6fa9299099b0dc030085774cbe5f
diff --git a/minijail0.1 b/minijail0.1
index 0ebfe6e..cf2ccee 100644
--- a/minijail0.1
+++ b/minijail0.1
@@ -12,9 +12,10 @@
Run using the alternate syscall table named \fItable\fR. Only available on kernels
and architectures that support the \fBPR_ALT_SYSCALL\fR option of \fBprctl\fR(2).
.TP
-\fB-b <src>,<dest>[,<writeable>]
+\fB-b <src>[,<dest>[,<writeable>]]
Bind-mount \fIsrc\fR into the chroot directory at \fIdest\fR, optionally writeable.
The \fIsrc\fR path must be an absolute path.
+If \fIdest\fR is not specified, it will default to \fIsrc\fR.
If the destination does not exist, it will be created as a file or directory
based on the \fIsrc\fR type.
.TP
diff --git a/minijail0.c b/minijail0.c
index b0daed2..32995ab 100644
--- a/minijail0.c
+++ b/minijail0.c
@@ -95,10 +95,12 @@
char *src = strtok(arg, ",");
char *dest = strtok(NULL, ",");
char *flags = strtok(NULL, ",");
- if (!src || !dest) {
+ if (!src) {
fprintf(stderr, "Bad binding: %s %s\n", src, dest);
exit(1);
}
+ if (!dest)
+ dest = src;
if (minijail_bind(j, src, dest, flags ? atoi(flags) : 0)) {
fprintf(stderr, "minijail_bind failed.\n");
exit(1);
@@ -294,7 +296,7 @@
/* clang-format off */
printf("Usage: %s [-dGhHiIKlLnNprRstUvyYz]\n"
" [-a <table>]\n"
- " [-b <src>,<dest>[,<writeable>]] [-k <src>,<dest>,<type>[,<flags>][,<data>]]\n"
+ " [-b <src>[,<dest>[,<writeable>]]] [-k <src>,<dest>,<type>[,<flags>][,<data>]]\n"
" [-c <caps>] [-C <dir>] [-P <dir>] [-e[file]] [-f <file>] [-g <group>]\n"
" [-m[<uid> <loweruid> <count>]*] [-M[<gid> <lowergid> <count>]*] [--profile <name>]\n"
" [-R <type,cur,max>] [-S <file>] [-t[size]] [-T <type>] [-u <user>] [-V <file>]\n"