[Bug 61189] New: CGIServlet should be able to set specific environment variables

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 61189] New: CGIServlet should be able to set specific environment variables

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61189

            Bug ID: 61189
           Summary: CGIServlet should be able to set specific environment
                    variables
           Product: Tomcat 9
           Version: 9.0.0.M21
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Catalina
          Assignee: [hidden email]
          Reporter: [hidden email]
  Target Milestone: -----

org.apache.catalina.servlets.CGIServlet has a param 'passShellEnvironment'.
It would give more flexibility to allow for different environment variables per
CGI.

Examples:

- set HOME and HTTP_HOME to the nextcloud directory
- set SQWEBMAIL_MAXMSGSIZE for sqwebmail


For the sqwebmail example this could look for example like

      <init-param>
         <param-name>EnvironmentVariables</param-name>
       
<param-value>SQWEBMAIL_MAXARGSIZE=20000000|SQWEBMAIL_MAXATTSIZE=20000000|SQWEBMAIL_MAXMSGSIZE=20000000</param-value>
      </init-param>

I wrote my own CGI executor servlet for sqwebmail.
And today I need environment variables for Nextcloud.

I don't like to put them in /etc/init.d/tomcat or catalina.sh, because they may
be lost after a Tomcat update.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61189] CGIServlet should be able to set specific environment variables

Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61189

--- Comment #1 from Konstantin Kolinko <[hidden email]> ---
> I don't like to put them in /etc/init.d/tomcat or catalina.sh, because they
> may be lost after a Tomcat update.

The place for custom environment variables in Apache Tomcat is bin/setenv.sh.
This is documented in RUNNING.txt.

http://tomcat.apache.org/tomcat-8.5-doc/RUNNING.txt

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61189] CGIServlet should be able to set specific environment variables

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61189

--- Comment #2 from jm009 <[hidden email]> ---
Created attachment 35291
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35291&action=edit
Allow to configure CGI specific environment variables.

This patch makes configuration of additional environment variables similar to
the configuration of executable-arg-1, executable-arg-2, and so on

   <init-param>
      <param-name>environment-variable-1</param-name>
      <param-value>SQWEBMAIL_MAXARGSIZE=20000000</param-value>
   </init-param>
   <init-param>
      <param-name>nvironment-variable-2</param-name>
      <param-value>SQWEBMAIL_MAXATTSIZE=20000000</param-value>
   </init-param>
   <init-param>
      <param-name>nvironment-variable-3</param-name>
      <param-value>SQWEBMAIL_MAXMSGSIZE=20000000</param-value>
   </init-param>

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61189] CGIServlet should be able to set specific environment variables

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61189

--- Comment #3 from Christopher Schultz <[hidden email]> ---
I don't like the use of unique names that don't have any meaning, like
`environment-variable-N`. Might I suggest one or the other of these schemes:

    <init-param>
      <param-name>environment-variables</param-name>
      <param-value>
        ENV_VAR_1=foo
        ENV_VAR_2=bar
        ...
      </param-value>
    </init-param>

Or:

    <init-param>
        <param-name>environment-variable-ENV_VAR_1</param-name>
        <param-value>foo</param-value>
    </init-param>
    <init-param>
        <param-name>environment-variable-ENV_VAR_2</param-name>
        <param-value>bar</param-value>
    </init-param>
    ...


I think I'd prefer the former over the latter.

Second, I think it makes sense to strip whitespace from around the names and
values of the environment variables. Basically, just add ".trim()" to all of
your .substring() calls. This will solve silly problems like people placing
leading/trailing spaces around names/values/equal signs. XML allows a lot of
optional whitespace, and some editors (and humans) like to be verbose.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61189] CGIServlet should be able to set specific environment variables

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61189

Christopher Schultz <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |PatchAvailable

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61189] CGIServlet should be able to set specific environment variables

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61189

--- Comment #4 from jm009 <[hidden email]> ---
Created attachment 35296
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35296&action=edit
All variable declarations in one <param-value>.

So here is a patch, that would implement your first suggestion.
But, while implementing it, I thought of some inconveniences:

- People may think: Oh, I can put whitespace here, so I will do that somewhere
else too...

(- It is impossible, to put a line break in the variable value, or to put white
space at the beginning or the end of the variable value (its probably not used
very often))

I think I'd prefer your second suggestion...
I'll create a patch for that one too.

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61189] CGIServlet should be able to set specific environment variables

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61189

--- Comment #5 from jm009 <[hidden email]> ---
Created attachment 35297
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=35297&action=edit
Variable name in <param-name>.

This patch implements your second suggestion.
For the moment it is my preferred one.
It also is the patch that adds the least number of lines of code :-)

First and second patch would be fine for me too :-)

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

[Bug 61189] CGIServlet should be able to set specific environment variables

Bugzilla from bugzilla@apache.org
In reply to this post by Bugzilla from bugzilla@apache.org
https://bz.apache.org/bugzilla/show_bug.cgi?id=61189

Mark Thomas <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #6 from Mark Thomas <[hidden email]> ---
Thanks for the patches. I like the second one too.

Fixed in:
- trunk for 9.0.0.M27 onwards
- 8.5.x for 8.5.21 onwards
- 8.0.x for 8.0.47 onwards
- 7.0.x for 7.0.82 onwards

--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]