version 1.2, 2002/10/20 23:38:12 |
version 1.5, 2002/10/28 00:38:32 |
|
|
/* |
/* |
$OpenXM: OpenXM/src/kxx/oxd.c,v 1.1 2002/10/20 13:13:35 takayama Exp $ |
$OpenXM: OpenXM/src/kxx/oxd.c,v 1.4 2002/10/27 10:39:33 takayama Exp $ |
*/ |
*/ |
|
|
#include <stdio.h> |
#include <stdio.h> |
|
|
#include "ox_kan.h" |
#include "ox_kan.h" |
#include "serversm.h" |
#include "serversm.h" |
|
|
|
/* #define DEBUG */ |
|
|
char *getTag(char *s); |
char *getTag(char *s); |
char *getKeyValue(char *s,char *key); |
char *getKeyValue(char *s,char *key); |
char *getBody(char *s); |
char *getBody(char *s); |
Line 34 static void couldNotFind(char *s); |
|
Line 36 static void couldNotFind(char *s); |
|
#if defined(__CYGWIN__) |
#if defined(__CYGWIN__) |
int errno; |
int errno; |
#endif |
#endif |
|
#define NOBODY 65534 |
|
|
main(int argc, char *argv[]) { |
main(int argc, char *argv[]) { |
char sname[1024]; |
char sname[1024]; |
Line 43 main(int argc, char *argv[]) { |
|
Line 46 main(int argc, char *argv[]) { |
|
extern int Serial; |
extern int Serial; |
int result; |
int result; |
int fd; |
int fd; |
|
int uid; |
|
|
strcpy(sname,"localhost"); |
strcpy(sname,"localhost"); |
i = 1; |
i = 1; |
Line 59 main(int argc, char *argv[]) { |
|
Line 63 main(int argc, char *argv[]) { |
|
i++; |
i++; |
} |
} |
|
|
|
uid = getuid(); |
|
if (uid == 0) { |
|
/* If I'm a super user, then change uid to nobody. */ |
|
if (setuid(NOBODY) != 0) { |
|
oxdError("Failed to change uid to nobody (%d)\n",NOBODY); |
|
} |
|
fprintf(stderr,"uid is changed to nobody (%d).\n",NOBODY); |
|
} |
|
|
if (LocalMode) { |
if (LocalMode) { |
if (portControl != -1) { |
if (portControl != -1) { |
Line 124 childServerMain(int fd) { |
|
Line 136 childServerMain(int fd) { |
|
char ccc[SIZE*3]; |
char ccc[SIZE*3]; |
extern int Serial; |
extern int Serial; |
char *openxm; |
char *openxm; |
|
int resultCode; |
/* Starting oxd session */ |
/* Starting oxd session */ |
signal(SIGALRM,exitServer); |
signal(SIGALRM,exitServer); |
alarm(60); |
alarm(60); |
Line 178 childServerMain(int fd) { |
|
Line 191 childServerMain(int fd) { |
|
openxm = getOpenXMpath(); |
openxm = getOpenXMpath(); |
sprintf(ccc,"%s %s",openxm,body); |
sprintf(ccc,"%s %s",openxm,body); |
fprintf(stderr,"Serial=%d : Executing command=%s\n",Serial,ccc); |
fprintf(stderr,"Serial=%d : Executing command=%s\n",Serial,ccc); |
|
/* Old code. |
fprintf(fp,"<bye/>\n"); fflush(NULL); |
fprintf(fp,"<bye/>\n"); fflush(NULL); |
fclose(fp); /* close the connection */ |
fclose(fp); |
system(ccc); |
system(ccc); |
fprintf(stderr,"Serial=%d : The following command is finished : %s\n",Serial,ccc); |
fprintf(stderr,"Serial=%d : The following command is finished : %s\n",Serial,ccc); |
|
*/ |
|
/* New code. It requires ox with -finish option. */ |
|
resultCode = system(ccc); |
|
fprintf(stderr,"Serial=%d : The following command is finished : %s, resultCode=%d\n",Serial,ccc,resultCode); |
|
if (resultCode == 0) { |
|
fprintf(fp,"<suceeded/>\n"); |
|
}else{ |
|
fprintf(fp,"<failed code=\"%d\"/>\n",resultCode); |
|
} |
|
|
|
GET_COMMAND /* expect <login/> */ |
|
|
|
fclose(fp); /* close the connection */ |
|
exit(0); |
} |
} |
|
|
char *getOpenXMpath() { |
char *getOpenXMpath() { |