Riccardo Annolfi
|
Porting of a web gui from QNX 6.3.2 to QNX 6.4.1 using Slinger Web Server
|
Riccardo Annolfi
03/31/2010 11:33 AM
post50972
|
Porting of a web gui from QNX 6.3.2 to QNX 6.4.1 using Slinger Web Server
Hi,
i'm making a porting of a web gui from QNX 6.3.2 to QNX 6.4.1 using Slinger Web Server and C CGI Scripts running on it
and i've found a problem.
I'm not using the SSI token in the shtml files, but C programs (C CGI Scripts) that create dinamycally html pages.
Working on QNX 6.4.1 ,when i make a system() call, from a C CGI Scripts, the system launchs the command and executes it
correctly, but the return value is -1 and the results of the command is displayed on the web window, while, on QNX 6.3.2
the return value is 0 and the results of the command is not displayed on the web window.
If the same C CGI Scripts is launched from command line, it works always correctly.
If i make change the user that execute the C CGI via Slinger, from Slinger user, that is root -2 (with uid 4294967294 ),
to user.users, it fails the same.
While, from shell, if i execute it with Slinger user, setting uid at 4294967294, it works always correctly. So it seems
that does not depends on the user.
The same happens if, instead of a system(), i use a spawn() or a spawnl() or a execl() or a execvp(). Also if i use a
fork() with an execl(). If i test waitpid(), its return value is always -1.
The WIFEXITED(sysStatus) and WEXITSTATUS( sysStatus ) macros confirm the error, that is always: errno = 10 and
strerror(errno)="No child processes".
I've implemented the QNX 6.4.1 system() code, calling it "mysystem()" and adding some logs inside to see what happens. I
discovered that, when the QNX 6.4.1 system() tests the waitpid() return value, being it always -1, the system() returns
always -1 too.
Analyzing it with "pidin fam sig" command, it seems that when i launch from Slinger a C CGI Scripts, with his own PID,
and this C CGI Scripts 'spawns' a process, with his own PID, the parent-child relationship between them is no more
present.
And so, the C CGI Scripts wrongly thinks that has no wait for any child processes.
How can i resolve this problem?
Below there is the Slinger launch command script:
/home/user/riccardoa# cat /etc/rc.d/rc.www
#!/bin/sh
#ifdef __USAGE
#
#%C
#
# It starts http server for this system
#
#endif
export HTTPD_ROOT_DIR=/lsu/www/current
export HTTPD_ROOT_DOC=index.html
export HTTPD_SCRIPTALIAS=/lsu/www/current/cgi
slay -Q slinger
slinger -d -c -e -s
# eof
Below there are the Slinger launch command script privileges:
/home/user/riccardoa# ls -la /etc/rc.d/rc.www
-rwxr-xr-x 1 root root 253 Mar 16 2006 /etc/rc.d/rc.www
Below there is a simple C CGI Scripts example that works on QNX 6.3.2, but doesn't on QNX 6.4.1:
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/wait.h>
int main (int argc, char *argv[])
{
int sysStatus = 0;
printf("Content-type: text/html;\n\n");
sysStatus = system( "/usr/bin/id " );
if( sysStatus == -1 ) {
printf( "<!-- shell could not be run -->\n" );
} else {
printf( "<!-- OK result of the system() is %d -->\n", WEXITSTATUS( sysStatus ) );
}
return 0;
}
Below there are the C CGI Scripts example privileges:
-rwsr-sr-x 1 root root 5255 Mar 31 18:00 cgiTestSystemCall-1.0
Best regards.
Riccardo Annolfi
|
|
|