=================================================================== RCS file: /home/cvs/OpenXM/src/kxx/oxmain.c,v retrieving revision 1.17 retrieving revision 1.22 diff -u -p -r1.17 -r1.22 --- OpenXM/src/kxx/oxmain.c 2004/03/03 02:31:50 1.17 +++ OpenXM/src/kxx/oxmain.c 2006/02/04 10:44:22 1.22 @@ -1,4 +1,4 @@ -/* $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.16 2004/02/25 23:14:36 takayama Exp $ */ +/* $OpenXM: OpenXM/src/kxx/oxmain.c,v 1.21 2005/02/28 12:53:44 takayama Exp $ */ /* nullserver01 */ #include #include @@ -37,6 +37,7 @@ static void errorToStartEngine(void); static int findOxServer(char *server); static void couldNotFind(char *s); /* gcc -v -c hoge.c */ +static void mywait(); void *sGC_malloc(int n) { return (void *)malloc(n); @@ -55,8 +56,13 @@ main(int argc, char *argv[]) { extern int OpenedSocket; char portfile[1024]; char *pass = NULL; + char *passControl = NULL; + char *passData = NULL; int result; int sleepingTime = 0; + int authEncoding=0; + FILE *fp; + char *stmp; extern int OxTerminateMode; signal(SIGHUP,SIG_IGN); /* ignore x of xterm */ @@ -101,11 +107,29 @@ main(int argc, char *argv[]) { if (i 0 ) parentServerMain(fdControl,fdStream); @@ -196,7 +249,44 @@ main(int argc, char *argv[]) { } } + if (passControl != NULL) { + char *s; int mm; + fprintf(stderr,"passControl\n"); + mm = strlen(passControl); + s = (char *) malloc(mm+1); + if (s == NULL) {fprintf(stderr,"No more memory.\n"); exit(1); } + if (read(fdControl,s,mm+1) < 0) { + fprintf(stderr,"Read error to read passControl\n"); sleep(5); exit(1); + } + s[mm] = 0; + if (strcmp(s,passControl) != 0) { + fprintf(stderr,"s=%s and passControl=%s do not match.\n",s,passControl); sleep(5); exit(1); + } + free(s); + } + if (passData != NULL) { + char *s; int mm; + mm = strlen(passData); + fprintf(stderr,"passData\n"); + s = (char *) malloc(mm+1); + if (s == NULL) {fprintf(stderr,"No more memory.\n"); exit(1); } + if (read(fdStream,s,mm+1) < 0) { + fprintf(stderr,"Read error to read passData\n"); + errorToStartEngine(); + } + if (strcmp(s,passData) != 0) { + fprintf(stderr,"s=%s and passData=%s do not match.\n",s,passData); + errorToStartEngine(); + } + free(s); + } + if ((fdControl < 0) || (fdStream < 0)) { + fprintf(stderr,"Waiting for 10 seconds to show an error.\n"); + sleep(10); + } + + result = 0; if (portControl != -1) { MyServerPid = fork(); @@ -217,20 +307,21 @@ static void errorToStartEngine(void) { If you implement this, set Do_not_use_control_stream_to_tell_no_server to zero. */ - sleep(2); + sleep(10); exit(-1); } oxmainUsage() { fprintf(stderr,"Usage: \n"); fprintf(stderr," ox [-ox serverprogram -host name -data portnum -control portnum -monitor]\n"); - fprintf(stderr," [-insecure -portfile fname -reverse -pass xxxyyyzzz]"); + fprintf(stderr," [-insecure -portfile fname -reverse -passControl xxxyyyzzz -passData pppqqqrrr]"); fprintf(stderr," [-finish]"); fprintf(stderr,"\n"); fprintf(stderr,"-reverse: ox server connects to the client.\n"); - fprintf(stderr," The client must give a one time password to ox server to connect to the client with -pass option.\n"); + fprintf(stderr," The client must give a one time password to ox server to connect to the client with -pass* option.\n"); fprintf(stderr," The one time password can be seen by ps command, so you must not use this one time password system on an untrustful host.\n"); fprintf(stderr," The one time password should be sent by a safe communication line like ssh and the ox server should be started by ssh. Do not use rsh\n"); + fprintf(stderr," (The option -pass is obsolete.)\n"); fprintf(stderr," If -reverse is not given, the client connect to the ox server\n"); fprintf(stderr," See OpenXM/src/SSkan/Doc/ox.sm1, /sm1connectr\n"); fprintf(stderr,"-insecure : \n"); @@ -262,6 +353,7 @@ parentServerMain(int fdControl, int fdStream) { extern OxTerminateMode; extern void myServerExit(); + signal(SIGCHLD,mywait); if (OxTerminateMode) { /* OxTerminateMode cannot be used if you run ox by xterm -exec ox ... @@ -418,5 +510,16 @@ static void couldNotFind(char *s) { } +static void mywait() { + int status; + int pid; + int i,j; + /* signal(SIGCHLD,SIG_IGN); */ + pid = wait(&status); + fprintf(stderr,"Control: child process %d is exiting.\n",pid); + fprintf(stderr,"Control: Shutting down the control server.\n"); + sleep(2); + exit(0); +}