Bug 1651310

Summary: FcgidInitialEnv truncates environment variable values to 127 bytes
Product: Red Hat Enterprise Linux 8 Reporter: Petr Pisar <ppisar>
Component: mod_fcgidAssignee: Luboš Uhliarik <luhliari>
Status: CLOSED CURRENTRELEASE QA Contact: Maryna Nalbandian <mnalband>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.0CC: bnater, jorton
Target Milestone: rc   
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: mod_fcgid-2.3.9-13.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1961948 (view as bug list) Environment:
Last Closed: 2019-06-14 00:52:14 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1618477, 1620531, 1961948    

Description Petr Pisar 2018-11-19 16:25:02 UTC
mod_fcgid expunges environment variables for the executed programs. There is FcgidInitialEnv directive to define an environment variable that will be passed to an executed program. However there seems to be a silent truncation of the variable value if it is longer then 127 characters.

Reproducer:

(1) httpd configuration:

FcgidInitialEnv XXX "/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/app-root/src/extlib/bin"
<Location /psgi>
  SetHandler fcgid-script
  Options +ExecCGI
  FcgidWrapper "/usr/local/bin/psgiwrapper" virtual
</Location>

(2) /usr/local/bin/psgiwrapper script dumps the environment to stderr:

#!/usr/bin/perl
use Data::Dumper;
warn Data::Dumper::Dumper(\%ENV);

(3) Retrieve the "/psgi" document:

$ wget -O /dev/null http://localhost/psgi

(4) Check httpd's error_log:

[Mon Nov 19 17:09:10.382047 2018] [core:notice] [pid 13607:tid 139764774131968] AH00094: Command line: 'httpd -D FOREGROUND'
$VAR1 = { 
          'XXX' => '/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/app-root/src/extlib/b',
          'PATH' => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin'
        };
[Mon Nov 19 17:09:14.892883 2018] [fcgid:warn] [pid 13612:tid 139764435437312] (104)Connection reset by peer: [client ::1:35680] mod_fcgid: error reading data from FastCGI server
[Mon Nov 19 17:09:14.892952 2018] [core:error] [pid 13612:tid 139764435437312] [client ::1:35680] End of script output before headers: psgi

Here you can see the XXX variable is missing last 2 characters. It's cut exactly at 128 bytes (including trailing zero).

This seems to be is caused by INITENV_VAL_LEN macro defined to 128 in fcgid_conf.h.

Please increase the length (256 bytes is fine for me). I need it for using mod_fcgid in perl s2i container image.

Affected package: mod_fcgid-2.3.9-12.el8.x86_64.