mirror of
https://github.com/systemd/systemd.git
synced 2024-12-26 03:22:00 +03:00
home: Prompt for shell in homectl firstboot
This commit is contained in:
parent
164ca24d74
commit
84edd52121
@ -2608,6 +2608,45 @@ static int create_interactively(void) {
|
||||
return log_error_errno(r, "Failed to set memberOf field: %m");
|
||||
}
|
||||
|
||||
_cleanup_free_ char *shell = NULL;
|
||||
|
||||
for (;;) {
|
||||
shell = mfree(shell);
|
||||
|
||||
r = ask_string(&shell,
|
||||
"%s Please enter the shell to use for user %s (empty to skip): ",
|
||||
special_glyph(SPECIAL_GLYPH_TRIANGULAR_BULLET), username);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to query user for username: %m");
|
||||
|
||||
if (isempty(shell)) {
|
||||
log_info("No data entered, skipping.");
|
||||
break;
|
||||
}
|
||||
|
||||
if (!valid_shell(shell)) {
|
||||
log_notice("Specified shell is not a valid UNIX shell path, try again: %s", shell);
|
||||
continue;
|
||||
}
|
||||
|
||||
r = RET_NERRNO(access(shell, X_OK));
|
||||
if (r >= 0)
|
||||
break;
|
||||
|
||||
if (r != -ENOENT)
|
||||
return log_error_errno(r, "Failed to check if shell %s exists: %m", shell);
|
||||
|
||||
log_notice("Specified shell '%s' is not installed, try another one.", shell);
|
||||
}
|
||||
|
||||
if (shell) {
|
||||
log_info("Selected %s as the shell for user %s", shell, username);
|
||||
|
||||
r = sd_json_variant_set_field_string(&arg_identity_extra, "shell", shell);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set shell field: %m");
|
||||
}
|
||||
|
||||
return create_home_common(/* input= */ NULL);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user