LDM does not use 'Language' from .dmrc

Bug #1480681 reported by Lasse
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
LTSP5
Fix Released
Low
Alkis Georgopoulos

Bug Description

Ubuntu: Trusty
Package: ldm

Problem: LDM does not use Language from .dmrc

How to reproduce:
1. Set up several locales to pick between.
2. Pick a non-default locale and log in. This very first time you will actually get the locale you picked and .dmrc is nicely updated.
3. Log out or reboot
4. Log in again without picking a locale. Now you will get the system default locale and the setting from .dmrc is not used.

Tags: ldm locale ltsp
Revision history for this message
Lasse (lars-engblom) wrote :

I have found the file with the bug: /usr/share/ldm/rc.d/X50-dmrc-processing

When I moved the block for setting LDM_LANGUAGE before setting the session it works. The 'break' in the session setting block prevents the language from being set later.

Revision history for this message
Lasse (lars-engblom) wrote :

# LDM_SESSION may be defined as either a desktop file name:
# LDM_SESSION=LXDE for /usr/share/xsessions/LXDE.desktop
#
# or the backwards compatible mode containing the whole command, e.g.:
# LDM_SESSION="gnome-session --session=gnome-classic"
#
# If it matches the Exec line of xsession.desktop files,
# it writes the to ~/.dmrc corresponding xsession.desktop file name, e.g.
# Session=gnome-classic
# So there's some code overhead for converting between those two.
#
# LDM_FORCE_SESSION is only implemented as desktop file name selection,
# and prevents the user from selecting other sessions.
#
# LDM_SELECT_SESSION should only be exported from ldm directly, and is not
# intended for use in lts.conf, though you could shoot yourself in the foot
# with it if you really wanted.

# for code readability
do_ssh(){
    ssh -S "$LDM_SOCKET" "$LDM_SERVER" "$@" 2>/dev/null
}

# $1 = key, case sensitive
get_dmrc_key() {
    echo "$dmrc" | sed -n "s/^$1=//p"
}

# If the desktop.session file exists, set LDM_SESSION to its Exec line
ldm_session_from_desktop_file() {
    local desktop session_exec
    desktop="$1"

    if [ -n "$desktop" ]; then
        session_exec=$(do_ssh sed -n "s/^Exec=//p" "/usr/share/xsessions/$desktop.desktop")
        if [ -n "$session_exec" ]; then
            LDM_SESSION="$session_exec"
            return 0
        fi
    fi
    return 1
}

# $1 = key, case sensitive
# $2 = value
put_dmrc_key() {
    # Don't do anything if the key already contains that value
    test "$(get_dmrc_key "$1")" = "$2" && return

    dmrc=$(echo "$dmrc" | sed '/\[Desktop\]/d')
    dmrc=$(echo "$dmrc" | sed "/^$1=/d")
    dmrc="[Desktop]
$1=$2
$dmrc"
    changed=true
}

dmrc=$(do_ssh cat .dmrc)

if [ -n "$LDM_FORCE_LANGUAGE" ]; then
    LDM_LANGUAGE="$LDM_FORCE_LANGUAGE"
else
    case "$LDM_LANGUAGE" in
        default|'')
            # If the user has a language stored in his .dmrc, use it
            LDM_LANGUAGE=$(get_dmrc_key "Language")
            ;;
        *)
            put_dmrc_key "Language" "$LDM_LANGUAGE"
            ;;
    esac
fi

if ! ldm_session_from_desktop_file "$LDM_FORCE_SESSION"; then
    case "$LDM_SELECTED_SESSION" in
        failsafe)
            # No need to access the user's .dmrc for failsafe sessions (man Xsession)
            ;;
        default|'')
            ldm_session_from_desktop_file "$(get_dmrc_key "Session")" && break
            ldm_session_from_desktop_file "$LDM_SESSION" && break
            ;;
        *)
            LDM_SESSION="$LDM_SELECTED_SESSION"
            # If there's a corresponding xsession.desktop file, save its name to .dmrc
            dmrc_session=$(do_ssh "grep -lR '^Exec=$LDM_SESSION$' /usr/share/xsessions/ | sed -n '/\/usr\/share\/xsessions\/\(.*\)\.desktop/{s//\1/p;q}'")
            if [ -n "$dmrc_session" ]; then
                put_dmrc_key "Session" "$dmrc_session"
            fi
            ;;
    esac
fi

if [ -n "$changed" ]; then
    do_ssh "echo '$dmrc' > .dmrc"
fi

Revision history for this message
Lasse (lars-engblom) wrote :

The comment above is a working version of /usr/share/ldm/rc.d/X50-dmrc-processing

Revision history for this message
Alkis Georgopoulos (alkisg) wrote :

Hi Lasse, "break" is a syntax error when used inside "case", can you try if this patched script works for you?

http://bazaar.launchpad.net/~ltsp-upstream/ltsp/ldm-trunk/view/head:/rc.d/X50-dmrc-processing

no longer affects: ldm (Ubuntu)
Changed in ltsp:
assignee: nobody → Alkis Georgopoulos (alkisg)
status: New → Incomplete
Revision history for this message
Lasse (lars-engblom) wrote :

Alkis, your patched script does work.

Revision history for this message
Alkis Georgopoulos (alkisg) wrote :

Thanks for the feedback Lasse, fix released in LTSP 5.5.6.

Changed in ltsp:
importance: Undecided → Low
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.