With the advent of Apache 2 on Netware CGI programming on Netware has become as easy as on other apache platforms. Apache 2 for netware can be downloaded for free from http://www.apache.org/ and required Netware 5.1 or later.
A simple CGI in C might be as simple as:
#include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { printf("content-type: text/plain\n"); printf("\n"); printf("Hello CGI-World!\n"); return EXIT_SUCCESS; }
To compile the CGI program, just use the command:
i386-netware-gcc -o excgi.nlm excgi.c
To run the CGI on your netware server, install Apache 2 (Apache 1.x will not do!). In the following example we assume you are copying the example execcgi.nlm CGI to the directory sys:/cgi/ on your netware test server. You need to tell apache, that this directory needs special treatment for CGI execution. To do so you need to modify the apache configuration file sys:/apache/config/httpd.conf and add the following lines:
# Configure an alias from http://server/cgi/ to sys:/cgi Alias /cgi sys:/cgi <Directory sys:/cgi> AddHandler cgi-script .nlm Options ExecCGI </Directory>
Next you need to restart apache so it will notice the config file change, you might want to enter the following commands in the system console:
unload apache load protected address space=apache sys:/apache2/apache
You may now start execution of the CGI using the URL http://servername/cgi/excgi.nlm.
CGI programs are executed without prior authentication. Writing code that is to be executed on behalf of an unauthenticated user requires consequent considerations on security issues, since erroneous parameter handling on the CGI side might give attackers access to the server. This is especially critical on Netware, since CGI programs are executed with full system access, not limited to a certain user profile as known from other operating systems.
You should prevent unauthorized users from writing to any directory that can execute CGIs. Even AllowOverride All on a directory is sufficient to get full control on the Netware Server.