An update.
We experienced the same problem with the package tuptime and I filed a
bug report there[1]. I had some comments from the other bug reports
which led me to do some more testing. Here's what I found.
Three packages have had this issue - spamassassin, sa-compile and tuptime.
The user for spamassassin and sa-compile is debian-spamd whose shell is
set to /bin/sh. The user for tuptime is tuptime whose shell is also set
to /bin/sh. No other users on my system use /bin/sh.
Changing the shell to /bin/bash for tuptime for example, eliminates the
error with using 'su -'.
The aliases in the /etc/profile.d files present no problem. Functions,
depending on how they are written, do.
function somefunction () {....} causes a problem.
function somefunction {....} causes a problem.
somefunction () {....} does not. Using the reserved word 'function'
causes /bin/sh to throw an error. Interestingly, when using the reserved
word function, the presence of () changes the error message.
With the use of ():
-sh: 5: /etc/profile.d/test.sh: Syntax error: "(" unexpected (expecting
"fi")
Without the use of ():
-sh: 5: /etc/profile.d/test.sh: function: not found
Definitely would have been much easier to spot the error had we not used ().
So while calling a login shell caused a problem, ultimately, it's
because /bin/sh does not recognise the reserved word 'function'. I'm not
sure there's a good solution for this. It seems to be such a specific
issue. Had I not created a user with a /bin/sh shell and tried to
recreate the function for that user, I'm not sure I would have twigged
that the reserved word function was causing the problem since the error
kept coming back as the "(" causing the issue. At least you're aware if
this is ever reported again.
I hope this provides some clarification and allows you to reproduce the
issue.
In testing, four things fixed the issue:
1. Setting a user's shell to /bin/bash.
2. Using su without "-"
3. removing the reserved word function from the function
4. Wrapping the function with a test for bash but it behaved strangely.
It worked if no "()" was present but if it was present, we had an error.
Unexpected. We're still testing.
We've chosen to remove the reserved word function so now our functions
are simply somefunction () which solves the issue for us.
Thank you.
--
Terry
LinuxChix System Admins
[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=884955