Bug 228418

Summary: www/tomcat[7|8|85]: Remove start_precmd from rcfile
Product: Ports & Packages Reporter: Michael Osipov <michael.osipov>
Component: Individual Port(s)Assignee: Danilo G. Baio <dbaio>
Status: Closed FIXED    
Severity: Affects Many People CC: dbaio, vvd
Priority: --- Flags: vvd: maintainer-feedback+
Version: Latest   
Hardware: Any   
OS: Any   
URL: https://reviews.freebsd.org/D16499
Attachments:
Description Flags
drop start_precmd from tomcat85.in vvd: maintainer-approval+

Description Michael Osipov 2018-05-22 09:03:02 UTC
The start_precmd with the setenv.sh has no effect and shall be dropped for these reasons:

1. It has been designed to be sourced by catalina.sh, we aren't using it. We use jsvc (which could probably have been done with daemon(8))
2. None of the variables are available to the jsvc process when started with service(8) verified with:

> @Override
> protected void doGet(HttpServletRequest req, HttpServletResponse resp)
> 		throws ServletException, IOException {
> 
> 	PrintWriter w = resp.getWriter();
> 
> 	for (Map.Entry<String, String> prop : System.getenv().entrySet()) {
> 		w.print(prop.getKey());
> 		w.print(" = ");
> 		w.println(prop.getValue());
> 	}
> 
> 	for (Map.Entry<Object, Object> prop : System.getProperties().entrySet()) {
> 		w.print(prop.getKey());
> 		w.print(" = ");
> 		w.println(prop.getValue());
> 	}
> 
> }

For service(8) it must be exported first, this isn't required by catalina.sh and not documented by pkg-message.

At best, the start_precmd is dropped altogether. Users can always use ${name}_env to pass vars. This works for me.

This issue likely applies to all other Tomcat ports.
Comment 1 Michael Osipov 2018-05-22 09:03:46 UTC
The only thing available to the jvsc process is:

PATH = /sbin:/bin:/usr/sbin:/usr/bin
RC_PID = 99363
PWD = /
HOME = /
Comment 2 Vladimir Druzenko freebsd_committer freebsd_triage 2018-05-28 06:35:12 UTC
I'm ill now and will look later…
Thanks for report.
Comment 3 Michael Osipov 2018-05-28 07:45:51 UTC
(In reply to VVD from comment #2)

Thanks for getting back to me. Sure, take your time and get well again.
Comment 4 Vladimir Druzenko freebsd_committer freebsd_triage 2018-07-23 00:20:23 UTC
(In reply to Michael Osipov from comment #0)
> Users can always use ${name}_env to pass vars. This works for me.
What do you mean?
There isn't ${name}_env in www/tomcat85/files/tomcat85.in.
Comment 5 Michael Osipov 2018-07-25 09:17:26 UTC
(In reply to VVD from comment #4)

And it does not has to be because this is done by the init system itself for very init script by default. Please see rc.subr(8) manpage.

Please try to set an env var in setenv.sh and check it wether is available in the daemon process, it don't. Therefore, the start_precmd is pointless.
Comment 6 Vladimir Druzenko freebsd_committer freebsd_triage 2018-07-25 13:29:39 UTC
Ok.
I'll make patch after https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229102 commited.
Still waiting somebody with commit bit…
Comment 7 Vladimir Druzenko freebsd_committer freebsd_triage 2018-07-26 17:59:43 UTC
Michael Osipov, check this - is it what you ask:
> --- www/tomcat85.orig/files/tomcat85.in
> +++ www/tomcat85/files/tomcat85.in
> @@ -131,15 +131,4 @@
>         org.apache.catalina.startup.Bootstrap \
>         ${_tomcat_pipe_cmd}"
>  
> -start_precmd="tomcat_prestart"
> -
> -tomcat_prestart()
> -{
> -       if [ -r "${_tomcat_catalina_base}/bin/setenv.sh" ]; then
> -               . "${_tomcat_catalina_base}/bin/setenv.sh"
> -       elif [ -r "${_tomcat_catalina_home}/bin/setenv.sh" ]; then
> -               . "${_tomcat_catalina_home}/bin/setenv.sh"
> -       fi
> -}
> -
>  run_rc_command "$1"
Comment 8 Michael Osipov 2018-07-27 06:20:15 UTC
(In reply to VVD from comment #7)

Exactly! The proper equivalent is $tomcat85_env.
Comment 9 Vladimir Druzenko freebsd_committer freebsd_triage 2018-07-27 14:42:25 UTC
Created attachment 195504 [details]
drop start_precmd from tomcat85.in
Comment 10 Danilo G. Baio freebsd_committer freebsd_triage 2018-07-29 12:16:27 UTC
This should be applied to tomcat7 and tomcat8 as well?
Comment 11 commit-hook freebsd_committer freebsd_triage 2018-07-29 12:46:15 UTC
A commit references this bug:

Author: dbaio
Date: Sun Jul 29 12:45:19 UTC 2018
New revision: 475658
URL: https://svnweb.freebsd.org/changeset/ports/475658

Log:
  www/tomcat85: Remove start_precmd from rcfile

  This is not being used, users can use $tomcat85_env to pass variables.

  PR:		228418
  Submitted by:	VVD <vvd@unislabs.com> (maintainer)
  Reported by:	Michael Osipov <1983-01-06@gmx.net>

Changes:
  head/www/tomcat85/Makefile
  head/www/tomcat85/files/tomcat85.in
Comment 12 Vladimir Druzenko freebsd_committer freebsd_triage 2018-07-29 13:32:57 UTC
(In reply to Danilo G. Baio from comment #10)
> This should be applied to tomcat7 and tomcat8 as well?
Yes. But not for tomcat6.
Comment 13 Danilo G. Baio freebsd_committer freebsd_triage 2018-07-29 13:44:41 UTC
(In reply to VVD from comment #12)

Ok, I'll open a review for ale@.
Thanks.
Comment 14 Michael Osipov 2018-08-06 07:34:17 UTC
Has this already been committed? If so, can we close this?
Comment 15 Danilo G. Baio freebsd_committer freebsd_triage 2018-08-06 22:41:49 UTC
(In reply to Michael Osipov from comment #14)

It was committed on www/tomcat85 only.

Waiting approval for the maintainer of tomcat7 and tomcat8.

Keep this PR open, please.
Comment 16 commit-hook freebsd_committer freebsd_triage 2018-08-25 19:28:52 UTC
A commit references this bug:

Author: dbaio
Date: Sat Aug 25 19:27:58 UTC 2018
New revision: 478084
URL: https://svnweb.freebsd.org/changeset/ports/478084

Log:
  www/tomcat[6|7|8]: Bring improvements from Tomcat[85|9]

  - Add options [1]
    Based on Apache Tomcat documentation guidance, the default web applications
    have varying degrees of risk, these options will permit users to select
    which of the web applications should be installed.

  - Remove start_precmd from rcfile in Tomcat7 and Tomcat8 [2]
    This is not being used, users can use ${name}_env to pass variables

  - Mark additional config files as @sample [3]

  PR:		218865 [1]
  PR:		228418 [2]
  PR:		229102 [3]
  Submitted by:	Matt <fsbruva@yahoo.com> [1]
  Submitted by:	VVD <vvd@unislabs.com> [2] [3]
  Reported by:	Michael Osipov <1983-01-06@gmx.net> [2] [3]
  Approved by:	maintainer timeout (ale, > 3 weeks)
  Differential Revision:	https://reviews.freebsd.org/D16499

Changes:
  head/www/tomcat6/Makefile
  head/www/tomcat6/pkg-plist
  head/www/tomcat7/Makefile
  head/www/tomcat7/files/tomcat7.in
  head/www/tomcat7/pkg-plist
  head/www/tomcat8/Makefile
  head/www/tomcat8/files/tomcat8.in
  head/www/tomcat8/pkg-plist