+ shell = xstrdup((pw->pw_shell[0] == '\0') ?
+ _PATH_BSHELL : pw->pw_shell);
+
+ /*
+ * Amend shell if chroot is requested.
+ */
+ if (options.chroot_directory != NULL &&
+ strcasecmp(options.chroot_directory, "none") != 0) {
+ tmp = tilde_expand_filename(options.chroot_directory,
+ pw->pw_uid);
+ chroot_path = percent_expand(tmp, "h", pw->pw_dir,
+ "u", pw->pw_name, (char *)NULL);
+ xfree(tmp);
+ xasprintf(&tmp, "%s/%s", chroot_path, shell);
+ xfree(shell);
+ shell = tmp;
+ free(chroot_path);
+ }