Index: usr.sbin/jail/jail.c =================================================================== --- usr.sbin/jail/jail.c (revision 230401) +++ usr.sbin/jail/jail.c (working copy) @@ -508,10 +508,13 @@ static void set_param(const char *name, char *value) { struct jailparam *param; + char *rpath; int i; static int paramlistsize; + rpath = NULL; + /* Separate the name from the value, if not done already. */ if (name == NULL) { name = value; @@ -520,8 +523,15 @@ set_param(const char *name, char *value) } /* jail_set won't chdir along with its chroot, so do it here. */ - if (!strcmp(name, "path") && chdir(value) < 0) - err(1, "chdir: %s", value); + if (!strcmp(name, "path")) { + /* resolve the path with realpath(3) */ + if ((rpath = malloc(PATH_MAX)) == NULL) + errx(1, "malloc"); + if (realpath(value, rpath) != NULL) + value = rpath; + if (chdir(value) < 0) + err(1, "chdir: %s", value); + } /* Check for repeat parameters */ for (i = 0; i < nparams; i++) @@ -552,8 +562,14 @@ set_param(const char *name, char *value) param_values[nparams] = value; param = params + nparams++; if (jailparam_init(param, name) < 0 || - jailparam_import(param, value) < 0) + jailparam_import(param, value) < 0) { + if (rpath != NULL) + free(rpath); errx(1, "%s", jail_errmsg); + } + + if (rpath != NULL) + free(rpath); } static void