forked from pool/tomcat10
Accepting request 1139107 from home:mbussolotto:branches:Java:packages
- Fix server.xml permission (bsc#1217768, bsc#1217402) - remove serverxmltool and use xsltproc OBS-URL: https://build.opensuse.org/request/show/1139107 OBS-URL: https://build.opensuse.org/package/show/Java:packages/tomcat10?expand=0&rev=18
This commit is contained in:
parent
c89623affc
commit
940c0b2f6d
19
allowLinking.xslt
Normal file
19
allowLinking.xslt
Normal file
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
|
||||
<xsl:strip-space elements="*"/>
|
||||
|
||||
<!-- Identity template to copy elements and attributes as they are -->
|
||||
<xsl:template match="@*|node()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@*|node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Add Resources element with allowLinking attribute -->
|
||||
<xsl:template match="Context">
|
||||
<xsl:copy>
|
||||
<Resources allowLinking="true" />
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
@ -1,36 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
JAR=@LIBEXECDIR@/tomcat/serverxmltool.jar
|
||||
SERVERXML=/etc/tomcat/server.xml
|
||||
|
||||
function usage {
|
||||
echo "Usage: <script> file.xslt [arg=value]..."
|
||||
}
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
XSLT="$1"
|
||||
ATTRIBUTE="${@:2}"
|
||||
|
||||
SUFIX=$(date +%H%M%S%N)
|
||||
rm -f ${SERVERXML}.new${SUFIX} ${SERVERXML}.old${SUFIX}
|
||||
|
||||
/usr/bin/java -jar $JAR $XSLT $SERVERXML $ATTRIBUTE > ${SERVERXML}.new${SUFIX}
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
mv $SERVERXML ${SERVERXML}.old${SUFIX}
|
||||
mv ${SERVERXML}.new${SUFIX} $SERVERXML
|
||||
rm ${SERVERXML}.old${SUFIX}
|
||||
if [[ -z "$ATTRIBUTE" ]]; then
|
||||
echo "Use $XSLT with no attribute"
|
||||
else
|
||||
echo "Use $XSLT with attribute $ATTRIBUTE"
|
||||
fi
|
||||
else
|
||||
echo "$SERVERXML was not modified."
|
||||
rm ${SERVERXML}.new${SUFIX}
|
||||
exit 2
|
||||
fi
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:af80c193df6ec80dd931ec4daa730b21d837eaf8862c87533950e213967bc946
|
||||
size 15243
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue Jan 16 09:05:32 UTC 2024 - Michele Bussolotto <michele.bussolotto@suse.com>
|
||||
|
||||
- Fix server.xml permission (bsc#1217768, bsc#1217402)
|
||||
- remove serverxmltool and use xsltproc
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Nov 27 13:14:21 UTC 2023 - Ricardo Mestre <ricardo.mestre@suse.com>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file
|
||||
#
|
||||
# Copyright (c) 2023 SUSE LLC
|
||||
# Copyright (c) 2024 SUSE LLC
|
||||
# Copyright (c) 2000-2009, JPackage Project
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
@ -46,7 +46,6 @@
|
||||
%define tempdir %{cachedir}/temp
|
||||
%define workdir %{cachedir}/work
|
||||
%define tomcatappdir %{_datadir}/%{app_name}/%{app_name}-webapps
|
||||
%define serverxmltool %{_libexecdir}/%{app_name}/serverxml-tool.sh
|
||||
%define javac_target 11
|
||||
#Compat macro for new _fillupdir macro introduced in Nov 2017
|
||||
%if ! %{defined _fillupdir}
|
||||
@ -72,8 +71,8 @@ Source21: %{app_name}-functions
|
||||
Source30: %{app_name}-preamble
|
||||
Source31: %{app_name}-server
|
||||
Source32: %{app_name}-named.service
|
||||
Source33: %{app_name}-serverxml-tool.tar.gz
|
||||
Source34: %{app_name}-serverxml-tool.sh.in
|
||||
Source100: valve.xslt
|
||||
Source101: allowLinking.xslt
|
||||
Source1000: %{app_name}-rpmlintrc
|
||||
Source1001: https://archive.apache.org/dist/%{app_name}/%{app_name}-%{major_version}/v%{version}/src/%{packdname}.tar.gz.asc
|
||||
Source1002: %{app_name}.keyring
|
||||
@ -112,6 +111,7 @@ BuildRequires: jakarta-taglibs-standard >= 1.1
|
||||
BuildRequires: java-devel >= 11
|
||||
BuildRequires: javapackages-local
|
||||
BuildRequires: junit
|
||||
BuildRequires: libxslt-tools
|
||||
BuildRequires: osgi-annotation
|
||||
BuildRequires: osgi-compendium
|
||||
BuildRequires: osgi-core
|
||||
@ -267,7 +267,7 @@ Conflicts: %{app_name}-webapps
|
||||
The ROOT and examples web applications for Apache Tomcat
|
||||
|
||||
%prep
|
||||
%autosetup -p1 -n %{packdname} -b 33
|
||||
%autosetup -p1 -n %{packdname}
|
||||
|
||||
# remove pre-built binaries and windows files
|
||||
find . -type f \( -name "*.bat" -o -name "*.class" -o -name Thumbs.db -o -name "*.gz" -o \
|
||||
@ -335,11 +335,6 @@ jar cf ../../../../../../../../output/build/webapps/docs/appdev/sample/sample.wa
|
||||
popd
|
||||
popd
|
||||
|
||||
pushd %{_builddir}/tomcat-serverxml-tool/src
|
||||
javac -source %{java_minor} -target %{javac_target} com/suse/tcserverxml/ApplyStylesheet.java
|
||||
jar cfe %{_builddir}/tomcat-serverxml-tool/serverxmltool.jar com.suse.tcserverxml.ApplyStylesheet com/suse/tcserverxml/ApplyStylesheet.class com/suse/tcserverxml/add-context.xslt com/suse/tcserverxml/remove-context.xslt com/suse/tcserverxml/add-valve-rotatable-false.xslt
|
||||
popd
|
||||
|
||||
%install
|
||||
# build initial path structure
|
||||
install -d -m 0755 %{buildroot}%{_bindir}
|
||||
@ -367,6 +362,9 @@ install -d -m 0755 %{buildroot}%{_unitdir}
|
||||
install -d -m 0755 %{buildroot}%{_libexecdir}/%{app_name}
|
||||
install -d -m 0755 %{buildroot}%{_fillupdir}
|
||||
|
||||
cp -a %{SOURCE100} %{buildroot}%{confdir}
|
||||
cp -a %{SOURCE101} %{buildroot}%{confdir}
|
||||
|
||||
# move things into place
|
||||
# First copy supporting libs to tomcat lib
|
||||
pushd output/build
|
||||
@ -473,15 +471,6 @@ pushd %{buildroot}%{tomcatappdir}/sample
|
||||
%jar xf %{buildroot}%{tomcatappdir}/docs/appdev/sample/sample.war
|
||||
popd
|
||||
|
||||
# Allow linking for example webapp
|
||||
mkdir -p %{buildroot}%{tomcatappdir}/examples/META-INF
|
||||
pushd %{buildroot}%{tomcatappdir}/examples/META-INF
|
||||
echo '<?xml version="1.0" encoding="UTF-8"?>'>context.xml
|
||||
echo '<Context>'>>context.xml
|
||||
echo ' <Resources allowLinking="true" />'>>context.xml
|
||||
echo '</Context>'>>context.xml
|
||||
popd
|
||||
|
||||
pushd %{buildroot}%{tomcatappdir}/examples/WEB-INF/lib
|
||||
ln -s -f $(build-classpath jakarta-taglibs-core) jstl.jar
|
||||
ln -s -f $(build-classpath jakarta-taglibs-standard) standard.jar
|
||||
@ -588,14 +577,6 @@ ln -s -f %{_sysconfdir}/alternatives/jsp %{buildroot}%{_javadir}/%{app_name}-jsp
|
||||
# It will be changed anyways to the correct symlink by update-alternatives.
|
||||
ln -s -f %{_sysconfdir}/alternatives/servlet.jar %{buildroot}%{_javadir}/servlet.jar
|
||||
|
||||
# Install tool used to edit server.xml
|
||||
pushd %{_builddir}/tomcat-serverxml-tool
|
||||
cat %{SOURCE34} | sed 's#@LIBEXECDIR@#%{_libexecdir}#g' >tomcat-serverxml-tool.sh
|
||||
install -m 0755 tomcat-serverxml-tool.sh \
|
||||
%{buildroot}%{_libexecdir}/%{app_name}/serverxml-tool.sh
|
||||
cp serverxmltool.jar %{buildroot}%{_libexecdir}/%{app_name}/
|
||||
popd
|
||||
|
||||
%pre
|
||||
# add the tomcat user and group
|
||||
getent group tomcat >/dev/null || %{_sbindir}/groupadd -r tomcat
|
||||
@ -677,37 +658,46 @@ rm -f \
|
||||
%{libdir}/\[ecj\].jar >/dev/null 2>&1
|
||||
|
||||
%post webapps
|
||||
%{serverxmltool} add-context.xslt docBase=%{tomcatappdir}/ROOT path=/
|
||||
%{serverxmltool} add-context.xslt docBase=%{tomcatappdir}/sample path=/sample
|
||||
%{serverxmltool} add-context.xslt docBase=%{tomcatappdir}/examples path=/examples
|
||||
xsltproc --output %{tomcatappdir}/ROOT/META-INF/context.xml %{confdir}/allowLinking.xslt %{tomcatappdir}/examples/META-INF/context.xml
|
||||
if [ ! -e %{_datadir}/%{app_name}/webapps/ROOT ]; then
|
||||
ln -sf %{tomcatappdir}/ROOT %{_datadir}/%{app_name}/webapps/ROOT
|
||||
fi
|
||||
xsltproc --output %{tomcatappdir}/examples/META-INF/context.xml %{confdir}/allowLinking.xslt %{tomcatappdir}/examples/META-INF/context.xml
|
||||
if [ ! -e %{_datadir}/%{app_name}/webapps/examples ]; then
|
||||
ln -sf %{tomcatappdir}/examples %{_datadir}/%{app_name}/webapps/examples
|
||||
fi
|
||||
#use the same context.xml for sample war
|
||||
mkdir -p %{tomcatappdir}/webapps/sample/META-INF
|
||||
xsltproc --output %{tomcatappdir}/sample/META-INF/context.xml %{confdir}/allowLinking.xslt %{tomcatappdir}/examples/META-INF/context.xml
|
||||
if [ ! -e %{_datadir}/%{app_name}/webapps/sample ]; then
|
||||
ln -sf %{tomcatappdir}/sample %{_datadir}/%{app_name}/webapps/sample
|
||||
fi
|
||||
|
||||
%postun webapps
|
||||
if [ $1 -eq 0 ]; then # uninstall only
|
||||
%{serverxmltool} remove-context.xslt docBase=%{tomcatappdir}/ROOT path=/
|
||||
%{serverxmltool} remove-context.xslt docBase=%{tomcatappdir}/sample path=/sample
|
||||
%{serverxmltool} remove-context.xslt docBase=%{tomcatappdir}/examples path=/examples
|
||||
rm %{tomcatappdir}/ROOT/META-INF/context.xml
|
||||
rm %{tomcatappdir}/sample/META-INF/context.xml
|
||||
fi
|
||||
|
||||
%post admin-webapps
|
||||
%{serverxmltool} add-context.xslt docBase=%{tomcatappdir}/host-manager path=/host-manager contextXml=%{tomcatappdir}/host-manager/META-INF/context.xml
|
||||
%{serverxmltool} add-context.xslt docBase=%{tomcatappdir}/manager path=/manager contextXml=%{tomcatappdir}/manager/META-INF/context.xml
|
||||
xsltproc --output %{tomcatappdir}/manager/META-INF/context.xml %{confdir}/allowLinking.xslt %{tomcatappdir}/manager/META-INF/context.xml
|
||||
if [ ! -e %{_datadir}/%{app_name}/webapps/manager ]; then
|
||||
ln -sf %{tomcatappdir}/manager %{_datadir}/%{app_name}/webapps/manager
|
||||
fi
|
||||
|
||||
%postun admin-webapps
|
||||
if [ $1 -eq 0 ]; then # uninstall only
|
||||
%{serverxmltool} remove-context.xslt docBase=%{tomcatappdir}/host-manager path=/host-manager
|
||||
%{serverxmltool} remove-context.xslt docBase=%{tomcatappdir}/manager path=/manager
|
||||
xsltproc --output %{tomcatappdir}/host-manager/META-INF/context.xml %{confdir}/allowLinking.xslt %{tomcatappdir}/host-manager/META-INF/context.xml
|
||||
if [ ! -e %{_datadir}/%{app_name}/webapps/host-manager ]; then
|
||||
ln -sf %{tomcatappdir}/host-manager %{_datadir}/%{app_name}/webapps/host-manager
|
||||
fi
|
||||
|
||||
%post docs-webapp
|
||||
%{serverxmltool} add-context.xslt docBase=%{tomcatappdir}/docs path=/docs
|
||||
|
||||
%postun docs-webapp
|
||||
if [ $1 -eq 0 ]; then # uninstall only
|
||||
%{serverxmltool} remove-context.xslt docBase=%{tomcatappdir}/docs path=/docs
|
||||
xsltproc --output %{tomcatappdir}/docs/META-INF/context.xml %{confdir}/allowLinking.xslt %{tomcatappdir}/docs/META-INF/context.xml
|
||||
if [ ! -e %{_datadir}/%{app_name}/webapps/docs ]; then
|
||||
ln -sf %{tomcatappdir}/docs %{_datadir}/%{app_name}/webapps/docs
|
||||
fi
|
||||
|
||||
%posttrans
|
||||
%{serverxmltool} add-valve-rotatable-false.xslt
|
||||
xsltproc --output %{confdir}/server.xml %{confdir}/valve.xslt %{confdir}/server.xml
|
||||
|
||||
%files
|
||||
%doc {LICENSE,NOTICE,RELEASE*}
|
||||
@ -722,8 +712,6 @@ fi
|
||||
%attr(0755,root,root) %{_libexecdir}/%{app_name}/functions
|
||||
%attr(0755,root,root) %{_libexecdir}/%{app_name}/preamble
|
||||
%attr(0755,root,root) %{_libexecdir}/%{app_name}/server
|
||||
%attr(0755,root,root) %{_libexecdir}/%{app_name}/serverxml-tool.sh
|
||||
%attr(0644,root,root) %{_libexecdir}/%{app_name}/serverxmltool.jar
|
||||
#bnc#565901
|
||||
%{bindir}/catalina.sh
|
||||
%attr(0644,root,root) %config(noreplace) %{_sysconfdir}/logrotate.d/%{app_name}10
|
||||
@ -762,6 +750,8 @@ fi
|
||||
%{homedir}/logs
|
||||
%{homedir}/conf
|
||||
%attr(0644,root,tomcat) %{_fillupdir}/sysconfig.%{app_name}
|
||||
%attr(0644,root,tomcat) %{confdir}/allowLinking.xslt
|
||||
%attr(0644,root,tomcat) %{confdir}/valve.xslt
|
||||
|
||||
%files admin-webapps
|
||||
%defattr(0644,root,tomcat,0755)
|
||||
@ -821,6 +811,7 @@ fi
|
||||
#bnc#520532
|
||||
%config(noreplace) %{tomcatappdir}/ROOT
|
||||
%{tomcatappdir}/examples
|
||||
%config(noreplace) %{tomcatappdir}/examples/META-INF/context.xml
|
||||
%{tomcatappdir}/sample
|
||||
|
||||
%files jsvc
|
||||
|
16
valve.xslt
Normal file
16
valve.xslt
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
|
||||
<xsl:strip-space elements="*"/>
|
||||
<xsl:template match="@*|node()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@*|node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
<xsl:template match="Valve[@className='org.apache.catalina.valves.AccessLogValve']">
|
||||
<xsl:copy>
|
||||
<xsl:attribute name="rotatable">false</xsl:attribute>
|
||||
<xsl:apply-templates select="@*|node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
Loading…
Reference in New Issue
Block a user