mirror of
https://github.com/armbian/build.git
synced 2026-09-08 23:59:54 +08:00
armbian-firstlogin: fix rcfile ownership when creating ~/.bashrc and ~/.xsessionrc
When firstlogin (running as root) appends locale exports to a user's ~/.bashrc or ~/.xsessionrc and the file does not yet exist, the redirection creates it as root:root. The user's subsequent login shell cannot read it cleanly under strict modes and ownership is wrong. Create the file first with touch + chown to the target user before appending. If the file already exists, leave ownership alone — the user may have customized it. Addresses PR #9954 review discussion r3443078088.
This commit is contained in:
@@ -511,6 +511,12 @@ set_timezone_and_locales() {
|
||||
|
||||
# setting detected locales only for user (idempotent)
|
||||
for rcfile in /home/"$RealUserName"/.bashrc /home/"$RealUserName"/.xsessionrc; do
|
||||
if [[ ! -e "$rcfile" ]]; then
|
||||
# Create empty file with proper ownership before appending; leave
|
||||
# ownership alone if the file already exists (user may have customized).
|
||||
touch -- "$rcfile"
|
||||
chown -- "$RealUserName":"$RealUserName" "$rcfile"
|
||||
fi
|
||||
if ! grep -q "^export LC_ALL=$LOCALES" "$rcfile" 2>/dev/null; then
|
||||
{
|
||||
echo "export LC_ALL=$LOCALES"
|
||||
|
||||
Reference in New Issue
Block a user