Forum

Path variable for CGI

Sachin
30 July 2009, 15:50
Hi Hugo

I am running hiawatha webserver on Linux. Before starting the server I have set the PATH and LD_LIBRARY_PATH shell variables. Hiawatha is running fine.

But I am using CGI. When CGI is executes it does not pick the upadted PATH and LD_LIBRARY_PATH variable and hence report failure. Why this is happening. Should not the CGI handler should pick the enviornment variables of webserver.

Also there is one another doubt. Its been mentioned that size of hiawatha binary is around 130 K. I am using its cross compiled version for ARM. It is showing the size of 300 K

Hiawatha version: 6.14
Operating System: Linux

Regards
Sachin
Hugo Leisink
30 July 2009, 16:11
Hiawatha clears the environment after startup. This is done in order to not have the CGI environment become polluted by root's environment.

Why does your system need the LD_LIBRARY_PATH? Have you tried running 'ldconfig' to update ld.so.conf? If that doesn't help, you can use SetEnv to set environment variables for your CGI applications.

My guess for the bigger binary while cross compiling is that cross compiling requires more libraries to be staticly linked. I guess you already tried stripping the binary?
Sachin
31 July 2009, 09:42
we are mainly interested in PATH variable. We have a binary which CGI call using system command. We dont want to place our binaries in /usr/bin or any such folder. We want to creat a clean package for our application.

About size, no we have not tried the stripping binary. As of libraries part, it requires same libraries no matter if you are cross compiling or not. Its only that in cross compilation libraries are cross compile libraries and cross compiler tool chain.

Regards
Sachin
Sachin
31 July 2009, 09:48
Just one thing .. about

Hiawatha clears the environment after startup. This is done in order to not have the CGI environment become polluted by root's environment.

Well, If we override the env varaibles, CGI will have new vbaraibles. Should not webserver allow the parents enviornment variable to be inherited by child. Otherwise CGI writer have to do the manipulation in his code to pick the env variables.

Please suggest.

Regards
Sachin
Hugo Leisink
31 July 2009, 10:50
The webserver allows parent environment variables to be inherited by the child process. That's how CGI works btw. It's just that Hiawatha needs to be started by root (to bind ports below 1024) and that account might contain environment variables you don't want to be present in every CGI run (security issues). That's way the environment is cleared. To set environment variables for the CGI process, use the SetEnv option.

VirtualHost {
...
SetEnv Path = /usr/local/bin;/usr/local/sbin
}
This topic has been closed.