V8.00.000.2025.06.17
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -18,6 +18,8 @@ guard_sourcing
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_RUN_RECOVERY
|
||||
# VAR_SETUP_PATH
|
||||
# user_root_shell
|
||||
# Arguments:
|
||||
# None
|
||||
# Returns:
|
||||
@@ -79,4 +81,59 @@ accounts_setup_ciss_root() {
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f accounts_setup_ciss_root
|
||||
|
||||
#######################################
|
||||
# Generates user account skeleton and activates chosen bash / zsh.
|
||||
# Globals:
|
||||
# RECOVERY
|
||||
# TARGET
|
||||
# VAR_RUN_RECOVERY
|
||||
# VAR_SETUP_PATH
|
||||
# Arguments:
|
||||
# 1: var_uid
|
||||
# 2: var_gid
|
||||
# 3: var_username
|
||||
# 4: var_shell
|
||||
# Returns:
|
||||
# 0: on success
|
||||
#######################################
|
||||
accounts_setup_ciss_user() {
|
||||
### Declare Arrays, HashMaps, and Variables.
|
||||
declare -r var_uid="${1}" var_gid="${2}" var_username="${3}" var_shell="${4}"
|
||||
declare var_target="${TARGET}"
|
||||
|
||||
### Check for TARGET / RECOVERY.
|
||||
[[ "${VAR_RUN_RECOVERY}" == "true" ]] && var_target="${RECOVERY}"
|
||||
|
||||
install -d -m 0700 -o "${var_uid}" -g "${var_gid}" "${var_target}/home/${var_username}/.ssh"
|
||||
install -m 0600 -o "${var_uid}" -g "${var_gid}" /dev/null "${var_target}/home/${var_username}/.ssh/authorized_keys"
|
||||
install -m 0600 -o "${var_uid}" -g "${var_gid}" "${VAR_SETUP_PATH}/includes/target/etc/skel/.ciss.bashrc" "${var_target}/home/${var_username}/.bashrc"
|
||||
|
||||
if [[ "${var_shell}" == "/bin/zsh" ]]; then
|
||||
|
||||
if [[ -x "${var_target}${var_shell}" ]]; then
|
||||
|
||||
zsh_omz_installer "${var_username}" "${var_target}"
|
||||
mv "${var_target}/home/${var_username}/.zshrc" "${var_target}/home/${var_username}/.zshrc.bak"
|
||||
install -m 0600 -o "${var_uid}" -g "${var_gid}" "${VAR_SETUP_PATH}/includes/target/etc/skel/.zshrc" "${var_target}/home/${var_username}"
|
||||
|
||||
chroot_exec "${var_target}" chsh -s "${var_shell}" "${var_username}"
|
||||
do_log "info" "file_only" "4520() Shell: '${var_shell}' used for: '${var_username}'."
|
||||
|
||||
else
|
||||
|
||||
chroot_exec "${var_target}" chsh -s /bin/bash "${var_username}"
|
||||
do_log "info" "file_only" "4520() Shell: '${var_shell}' not found for: '${var_username}'. Using '/bin/bash' instead."
|
||||
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
do_log "info" "file_only" "4520() Skeleton: '${var_username}' successfully generated."
|
||||
|
||||
guard_dir && return 0
|
||||
}
|
||||
### Prevents accidental 'unset -f'.
|
||||
# shellcheck disable=SC2034
|
||||
readonly -f accounts_setup_ciss_user
|
||||
# vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh
|
||||
|
||||
Reference in New Issue
Block a user