Bug 1221361

Summary: /etc/profile.d/alljava.csh sets JAVA_HOME incorrectly
Product: [openSUSE] openSUSE Distribution Reporter: Peter Keller <pkeller>
Component: BasesystemAssignee: Ruediger Oertel <ro>
Status: NEW --- QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: comes, fstrba, gcomes.obs, pkeller
Version: Leap 15.5   
Target Milestone: ---   
Hardware: x86-64   
OS: openSUSE Leap 15.5   
See Also: https://bugzilla.opensuse.org/show_bug.cgi?id=1107342
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Peter Keller 2024-03-13 17:27:23 UTC
/etc/profile.d/alljava.csh contains the following assignment:

   setenv JAVA_HOME $ALTERNATIVES_JAVAC_LINK:h:h
   setenv JAVA_HOME $JAVA_HOME/bin

This is clearly incorrect, and makes some Java applications fail to start. Looking at the corresponding Bourne-shell file for comparison, the second of these two assignments is obviously intended to be:

   setenv JAVA_BINDIR $JAVA_HOME/bin
Comment 1 Giacomo Comes 2024-03-26 20:23:13 UTC
There is an error in /etc/profile.d/alljava.csh (leap 15.5).
The line:
  set ALTERNATIVES_JAVA_LINK=`realpath /etc/alternatives/java 2> /dev/null`
does not work because the c shell does not support std-error redirection.
The error causes ALTERNATIVES_JAVA_LINK to be empty and that makes also
the variables: JRE_HOME, JAVA_HOME, JDK_HOME and SDK_HOME empty as well.

The bug is present in the file:
  git-47-056fc66c699a8544c7692a03c905fca568f5390b.patch
in the leap 15.5 source package.

Funny enough, the same file in the leap 15.6 source package is without the bug.
Therefore there is no issue on leap 15.6

Tumbleweed instead has incorporated the faulty patch and the file:
  aaa_base-84.87+git20180409.04c9dae/files/etc/profile.d/alljava.csh
in the source tar file: aaa_base-84.87+git20180409.04c9dae.tar.xz
contains the same bug as leap 15.5.
Comment 2 Giacomo Comes 2024-03-26 20:45:18 UTC
I can also confirm the misspelling JAVA_HOME/JAVA_BINDIR
Such misspelling is present in Leap 15.5, 15.6 and tumbleweed.
Comment 3 Ruediger Oertel 2024-04-02 13:58:08 UTC
well, the typo with JAVA_HOME is pretty obvious.

the question is how to handle stderr output from realpath then,
redirecting stderr was added due to bug#1218232

if 15.6 did not have that then this is a build based on an older snapshot of updates and the next milestone will have that same change.
Comment 4 Ruediger Oertel 2024-04-02 14:17:00 UTC
Werner: any good hint how to do the stderr redir for this case we tried so solve bug#1218232 with the lines:

-+if ( -l /etc/alternatives/javac ) then
-+    set ALTERNATIVES_JAVAC_LINK=`realpath /etc/alternatives/javac`
++if ( -l /etc/alternatives/javac && -e /etc/alternatives/javac ) then
++    set ALTERNATIVES_JAVAC_LINK=`realpath /etc/alternatives/javac 2> /dev/null`
Comment 5 Peter Keller 2024-04-02 14:19:45 UTC
Tom Christiansen's classic document "Csh Programming Considered Harmful" explains that this cannot be done in Csh at all. You need to invoke the Bourne Shell something like:

set ALTERNATIVES_JAVAC_LINK=`/bin/sh -c 'realpath /etc/alternatives/javac 2>/dev/null'`
Comment 6 Ruediger Oertel 2024-04-02 14:56:36 UTC
well, since I added the "-e ..." at the same time I'm currently thinking about
dropping that stderr redir completely.
Comment 7 Ruediger Oertel 2024-04-02 15:00:06 UTC
https://github.com/openSUSE/aaa_base/pull/147
Comment 8 Dr. Werner Fink 2024-04-03 06:03:17 UTC
(In reply to Ruediger Oertel from comment #4)
> Werner: any good hint how to do the stderr redir for this case we tried so
> solve bug#1218232 with the lines:
> 
> -+if ( -l /etc/alternatives/javac ) then
> -+    set ALTERNATIVES_JAVAC_LINK=`realpath /etc/alternatives/javac`
> ++if ( -l /etc/alternatives/javac && -e /etc/alternatives/javac ) then
> ++    set ALTERNATIVES_JAVAC_LINK=`realpath /etc/alternatives/javac 2>
> /dev/null`

(t)csh can only rediret stdout or both stdout *and* stderr ... means > or >&
Comment 9 Ruediger Oertel 2024-04-03 08:13:43 UTC
yes, but apparently not just discard stderr which is what I wanted to do
when using command output to set a variable.
Comment 12 Giacomo Comes 2024-05-02 11:46:00 UTC
An update for leap 15.5 come out today, so I went to check what is currently
the situation for this bug report:
tumbleweed: both typo and stderr redirection fixed
Leap 15.5: only stderr redirection fixed, typo still present.
Leap 15.6: both typo and stderr redirection present.

While the update for leap 15.6 could be on its way, I find suspicious
that for leap 15.5 only the stderr redirection was fixed but not the typo.
Maybe it was an oversight?
Comment 13 Peter Keller 2024-05-02 12:16:04 UTC
(In reply to Giacomo Comes from comment #12)
> An update for leap 15.5 come out today, so I went to check what is currently
> the situation for this bug report:
> tumbleweed: both typo and stderr redirection fixed
> Leap 15.5: only stderr redirection fixed, typo still present.
> Leap 15.6: both typo and stderr redirection present.
> 
> While the update for leap 15.6 could be on its way, I find suspicious
> that for leap 15.5 only the stderr redirection was fixed but not the typo.
> Maybe it was an oversight?

Good that you checked. The change was definitely merged into master here: https://github.com/openSUSE/aaa_base/commit/e6815bfc5137556aee3b5752f15ca484c88e513b

However, the source of the aaa_base package is the update-sle repo not openSUSE's update-oss. This makes me suspect that fixing the typo failed review by SLE on the basis that enterprise users affected by the issue will have worked around it already. Fixing the problem may break those workarounds.

I would love to be proved wrong, but this seems to be a downside of the tight integration of openSUSE with SLE. I'm looking forward to switching to SlowRoll when the time is right....
Comment 14 Maintenance Automation 2024-05-02 12:30:01 UTC
SUSE-RU-2024:1487-1: An update that has four fixes can now be installed.

Category: recommended (moderate)
Bug References: 1211721, 1221361, 1221407, 1222547
Maintenance Incident: [SUSE:Maintenance:32998](https://smelt.suse.de/incident/32998/)
Sources used:
openSUSE Leap Micro 5.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
openSUSE Leap Micro 5.4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
openSUSE Leap 15.5 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise Micro for Rancher 5.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise Micro 5.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise Micro for Rancher 5.4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise Micro 5.4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise Micro 5.5 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
Basesystem Module 15-SP5 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
Development Tools Module 15-SP5 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise High Performance Computing LTSS 15 SP3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise High Performance Computing ESPOS 15 SP4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise High Performance Computing LTSS 15 SP4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise Desktop 15 SP4 LTSS 15-SP4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise Server 15 SP3 LTSS 15-SP3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise Server 15 SP4 LTSS 15-SP4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise Server for SAP Applications 15 SP3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise Server for SAP Applications 15 SP4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Manager Proxy 4.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Manager Retail Branch Server 4.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Manager Server 4.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Enterprise Storage 7.1 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise Micro 5.2 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
SUSE Linux Enterprise Micro for Rancher 5.2 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3
openSUSE Leap 15.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.17.3

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 15 Ruediger Oertel 2024-05-02 13:53:18 UTC
15.6 is on the same package as 15.5 and both still have the JAVA_HOME vs JAVA_BINDIR typo in the csh variant ...
Comment 16 Ruediger Oertel 2024-05-02 14:02:53 UTC
>However, the source of the aaa_base package is the update-sle repo not 
> openSUSE's update-oss. This makes me suspect that fixing the typo failed review 
> by SLE on the basis that enterprise users affected by the issue will have 
> worked around it already. Fixing the problem may break those workarounds.

no not really, it was my oversight and I tried to find a solution for csh's inability to just silence stderr and when I did not find a clean solution for that just dropped the redirection and then forgot about the typo from the initial comment ... sorry for that.

new maint-request files fixing the typo as well.
Comment 18 Maintenance Automation 2024-05-31 08:30:14 UTC
SUSE-RU-2024:1876-1: An update that has one fix can now be installed.

Category: recommended (moderate)
Bug References: 1221361
Maintenance Incident: [SUSE:Maintenance:33622](https://smelt.suse.de/incident/33622/)
Sources used:
openSUSE Leap 15.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
openSUSE Leap Micro 5.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
openSUSE Leap Micro 5.4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
openSUSE Leap 15.5 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise Micro for Rancher 5.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise Micro 5.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise Micro for Rancher 5.4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise Micro 5.4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise Micro 5.5 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
Basesystem Module 15-SP5 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
Development Tools Module 15-SP5 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise High Performance Computing LTSS 15 SP3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise High Performance Computing ESPOS 15 SP4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise High Performance Computing LTSS 15 SP4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise Desktop 15 SP4 LTSS 15-SP4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise Server 15 SP3 LTSS 15-SP3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise Server 15 SP4 LTSS 15-SP4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise Server for SAP Applications 15 SP3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise Server for SAP Applications 15 SP4 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Manager Proxy 4.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Manager Retail Branch Server 4.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Manager Server 4.3 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Enterprise Storage 7.1 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise Micro 5.2 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
SUSE Linux Enterprise Micro for Rancher 5.2 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 19 Giacomo Comes 2024-05-31 12:45:45 UTC
Today's update for Leap 15.5 finally fixed the issue.
Leap 15.6 thought, is still without fix. And it's final release is just in a couple of weeks.
Comment 20 Maintenance Automation 2024-06-19 12:30:21 UTC
SUSE-RU-2024:1876-2: An update that has one fix can now be installed.

Category: recommended (moderate)
Bug References: 1221361
Maintenance Incident: [SUSE:Maintenance:33622](https://smelt.suse.de/incident/33622/)
Sources used:
openSUSE Leap 15.6 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
Basesystem Module 15-SP6 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1
Development Tools Module 15-SP6 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 21 Maintenance Automation 2024-07-16 12:31:12 UTC
SUSE-RU-2024:1876-3: An update that has one fix can now be installed.

Category: recommended (moderate)
Bug References: 1221361
Maintenance Incident: [SUSE:Maintenance:33622](https://smelt.suse.de/incident/33622/)
Sources used:
SUSE Linux Enterprise Micro 5.5 (src):
 aaa_base-84.87+git20180409.04c9dae-150300.10.20.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.