#!/bin/sh # SPDX-Version: 3.0 # SPDX-CreationInfo: 2025-06-17; WEIDNER, Marc S.; # SPDX-ExternalRef: GIT https://git.coresecret.dev/msw/CISS.debian.installer.git # SPDX-FileContributor: WEIDNER, Marc S.; Centurion Intelligence Consulting Agency # SPDX-FileCopyrightText: 2024-2025; WEIDNER, Marc S.; # SPDX-FileType: SOURCE # SPDX-License-Identifier: EUPL-1.2 OR LicenseRef-CCLA-1.0 # SPDX-LicenseComment: This file is part of the CISS.debian.installer.secure framework. # SPDX-PackageName: CISS.debian.installer # SPDX-Security-Contact: security@coresecret.eu # shellcheck shell=sh # This file is sourced by login shells via '/etc/profile'. Keep POSIX sh compatible. ### XDG variables (do not override if already set). export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-${HOME}/.config}" export XDG_DATA_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}" export XDG_CACHE_HOME="${XDG_CACHE_HOME:-${HOME}/.cache}" export XDG_STATE_HOME="${XDG_STATE_HOME:-${HOME}/.local/state}" export XDG_CONFIG_DIRS="${XDG_CONFIG_DIRS:-/etc/xdg}" export XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" ### XDG_RUNTIME_DIR is provided by systemd-logind; do not set a persistent path. # shellcheck disable=SC2312 if [ -z "${XDG_RUNTIME_DIR:-}" ] && [ -d "/run/user/$(id -u)" ]; then # shellcheck disable=SC2155 export XDG_RUNTIME_DIR="/run/user/$(id -u)" fi ### Create canonical directories idempotently with 0700. _xdg_umask="$(umask)" umask 077 [ -d "${XDG_CONFIG_HOME}" ] || install -d -m 0700 -- "${XDG_CONFIG_HOME}" [ -d "${XDG_DATA_HOME}" ] || install -d -m 0700 -- "${XDG_DATA_HOME}" [ -d "${XDG_CACHE_HOME}" ] || install -d -m 0700 -- "${XDG_CACHE_HOME}" [ -d "${XDG_STATE_HOME}" ] || install -d -m 0700 -- "${XDG_STATE_HOME}" umask "${_xdg_umask}" unset _xdg_umask ### Optional migrations (controlled via /'etc/default/ciss-xdg-profile'). [ -f /etc/default/ciss-xdg-profile ] && . /etc/default/ciss-xdg-profile ### Bash history -> XDG_STATE_HOME (only if running bash). if [ "${ENABLE_XDG_BASH_HISTORY:-1}" = "1" ] && [ -n "${BASH_VERSION:-}" ]; then [ -d "${XDG_STATE_HOME}/bash" ] || install -d -m 0700 -- "${XDG_STATE_HOME}/bash" export HISTFILE="${XDG_STATE_HOME}/bash/history" fi ### Zsh history -> XDG_STATE_HOME (best-effort; zsh might not read /etc/profile) if [ "${ENABLE_XDG_ZSH_HISTORY:-1}" = "1" ] && [ -n "${ZSH_VERSION:-}" ]; then [ -d "${XDG_STATE_HOME}/zsh" ] || install -d -m 0700 -- "${XDG_STATE_HOME}/zsh" export HISTFILE="${XDG_STATE_HOME}/zsh/history" fi ### Less history -> XDG_STATE_HOME if [ "${ENABLE_XDG_LESS_HISTORY:-1}" = "1" ]; then [ -d "${XDG_STATE_HOME}/less" ] || install -d -m 0700 -- "${XDG_STATE_HOME}/less" export LESSHISTFILE="${XDG_STATE_HOME}/less/history" fi # vim: number et ts=2 sw=2 sts=2 ai tw=128 ft=sh