return 0;
}
+static int find_shell(const char *path, const char *root) {
+ int r;
+
+ assert(path);
+
+ if (!valid_shell(path))
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "%s is not a valid shell", path);
+
+ r = chase_symlinks(path, root, CHASE_PREFIX_ROOT, NULL, NULL);
+ if (r < 0) {
+ const char *p;
+ p = prefix_roota(root, path);
+ return log_error_errno(r, "Failed to resolve shell %s: %m", p);
+ }
+
+ return 0;
+}
+
static int prompt_root_shell(void) {
int r;
break;
}
- if (!valid_shell(s)) {
- log_error("Specified shell invalid.");
+ r = find_shell(s, arg_root);
+ if (r < 0)
continue;
- }
arg_root_shell = TAKE_PTR(s);
break;
if (errno != ENOENT)
return -errno;
- r = fchmod(fileno(passwd), 0000);
+ r = fchmod(fileno(passwd), 0644);
if (r < 0)
return -errno;
break;
case ARG_ROOT_SHELL:
- if (!valid_shell(optarg))
- return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
- "%s is not a valid shell path", optarg);
+ r = find_shell(optarg, arg_root);
+ if (r < 0)
+ return r;
r = free_and_strdup(&arg_root_shell, optarg);
if (r < 0)