Subject: pkg/37158: kdebase3's Kdm Xsession doesn't handle csh or tcsh environments properly
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <jasonb@myjclibrary.org>
List: pkgsrc-bugs
Date: 10/20/2007 20:10:00
>Number:         37158
>Category:       pkg
>Synopsis:       kdebase3's Kdm Xsession doesn't handle csh or tcsh environments properly
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Oct 20 20:10:00 +0000 2007
>Originator:     Jason Boyer
>Release:        3.1
>Organization:
>Environment:
NetBSD janus.local 3.1 NetBSD 3.1 (GENERIC.MPACPI) #0: Tue Oct 31 04:47:22 UTC 2006  builds@b0.netbsd.org:/home/builds/ab/netbsd-3-1-RELEASE/i386/200610302053Z-obj/home/builds/ab/netbsd-3-1-RELEASE/src/sys/arch/i386/compile/GENERIC.MPACPI i386

>Description:
Line 35 of /usr/pkg/share/kde/config/kdm/Xsession reads like so:

    $SHELL -c "if (-f /etc/csh.login) source /etc/csh.login; if (-f ~/.login) source ~/.login; /bin/sh -c export > $xsess_tmp"

$xsess_tmp is then sourced into the Xsession /bin/sh script.

Note the "/bin/sh -c export" part. Since there's no -p and /bin/sh isn't bash (which ignores -p), the values of the env variables aren't given, and ~/.xsession-errors starts out with a long list of "{SOMEVAR} not found" as it tries to execute your env vars. Thus, none of your environment is preserved if you use csh or tcsh as your shell. Annoying.
>How-To-Repeat:
Change your shell to csh or tcsh
Make certain that /bin/sh isn't bash (obviously the case on NetBSD)
Start KDE
Wonder why none of your environment is still set.
>Fix:
The Xsession file is created from kdebase-3.5.7/kdm/kfrontend/genkdmconf.c on line 676. Changing "/bin/sh -c export" to just "env" works fine for both /usr/pkg/bin/tcsh and /bin/csh, and as a bonus, cuts out a wasteful extra shell invocation.