int mbhelp_t::helpindex (void) //************************************************************************* // //************************************************************************* { unsigned int i = 0; if (! helpf) return 0; idxf = s_fopen(idxname, "sw+t"); if (! idxf) return 0; s_fsetopt(idxf, 1); fprintf(idxf, "%ld\n", file_isreg(helpname)); while (fgets(inbuf, LINELEN, helpf)) { if (*inbuf == '\\' && inbuf[1] == '\\') { inbuf[strlen(inbuf) - 1] = 0; // delete newline fprintf(idxf, "%1.37s %ld\n", inbuf + 2, ftell(helpf)); i++; } } rewind(idxf); trace(replog, "helpindex", "%d subjects in %s", i, helpname); return 1; }
void conf_hostname( struct obj_conf *conf, BEN *opts ) { BEN *value = NULL; char *f = NULL; char *p = NULL; /* Hostname from args */ value = ben_searchDictStr( opts, "-a" ); if( value != NULL && ben_str_size( value ) >= 1 ) { snprintf( conf->hostname, BUF_SIZE, "%s", (char *)value->v.s->s ); return; } else { strncpy( conf->hostname, "bulk.p2p", BUF_OFF1 ); } /* Hostname from file */ if( ! file_isreg( CONF_HOSTFILE ) ) { return; } f = (char *) file_load( CONF_HOSTFILE, 0, file_size( CONF_HOSTFILE ) ); if( f == NULL ) { return; } if( ( p = strchr( f, '\n')) != NULL ) { *p = '\0'; } snprintf( conf->hostname, BUF_SIZE, "%s.p2p", f ); myfree( f ); }
void mime_magic( char *filename, char *key ) { struct obj_mime *tuple = NULL; magic_t magic = NULL; const char *mime = NULL; if( ! file_isreg( filename) ) { return; } if( (magic = magic_open( MAGIC_ERROR|MAGIC_MIME)) == NULL ) { return; } if( magic_load( magic,NULL) != 0 ) { magic_close( magic ); return; } if( (mime = magic_file( magic, filename)) == NULL ) { magic_close( magic ); return; } /* Cache mime type in memory */ mutex_block( _main->mime->mutex ); tuple = mime_add( key, mime ); mutex_unblock( _main->mime->mutex ); /* Clear handle */ magic_close( magic ); info( NULL, 0, "New MIME: \"%s\" -> \"%s\"", tuple->key, tuple->val ); }
/* * ctime is not updated for TMPFS files on SunOS * atime is not updated for NFS files */ int file_timeoff(int fd,int created_now) { FileStat st0,st1; int now; if( !file_isreg(fd) ) return 0; if( fstat(fd,&st0) != 0 ) return 0; if( touch_ctime(fd) != 0 ) return 0; now = time(0); if( fstat(fd,&st1) != 0 ) return 0; if( !created_now ) if( st1.st_ctime == st0.st_ctime ){ /* this will not work right after REAL CHANGE */ return 0; } return now - st1.st_ctime; }
int http_filename(char *resource, char *filename) { snprintf(filename, BUF_SIZE, "%s%s", _main->conf->home, resource); if (file_isreg(filename)) { return TRUE; } else if (file_isdir(filename)) { /* There is a index.html file within that directory? */ snprintf(filename, BUF_SIZE, "%s%s/%s", _main->conf->home, resource, _main->conf->file); if (file_isreg(filename)) { return TRUE; } } return FALSE; }
/*FUNCTION*/ int hook_isreg(pExecuteObject pEo, char *pszFileName ){ /*noverbatim CUT*/ int iAccessPermission = HOOK_FILE_ACCESS(pszFileName); if( !(iAccessPermission&1) )return 0; return file_isreg(pszFileName); }
int fromInetd() { int iss0,iss1; if( isatty(0) || isatty(1) || file_isreg(0) || file_isreg(1) ) return 0; if( fromRsh() ) return 0; if( _fromRsh == IS_SSH ){ return 0; } iss0 = file_issock(0); iss1 = file_issock(1); if( 0 < iss0 && 0 < iss1 ){ if( sockPort(1) <= 1 ) return 0; return 1; } return 0; }
int file_issock(int fd) { int ISSOCK; if( isatty(fd) || file_isreg(fd) ) return -1; ISSOCK = file_ISSOCK(fd); if( 0 < ISSOCK ) return ISSOCK; if( 0 < getsocktype(fd) ) return 1; return -1; }
int mbhelp_t::helpopen (char *speech) //************************************************************************* // //************************************************************************* { time_t helptime = 0L; sprintf(helpname, MSGPATH "/help.%s", speech); strlwr(helpname); if ((helpf = s_fopen(helpname, "srt")) != NULL) { sprintf(idxname, MSGPATH "/helpidx.%s", speech); strlwr(idxname); idxf = s_fopen(idxname, "srb"); { if (idxf) { fscanf(idxf, "%ld", &helptime); if (file_isreg(helpname) != helptime) { s_fclose(idxf); idxf = NULL; } } if (! idxf) { if (! helpindex()) // generate index file { s_fclose(helpf); // do not loose filehandles if no correct index helpf = NULL; return 0; } } fgets(inbuf, LINELEN, idxf); // skip the first line containing filetime return 1; } } else return 0; }
static FILE* open_simplefile(const char *file) { FILE *fp; if(!file_isreg(file)) { fprintf(stderr, "file [%s] is not a simple file\n", file); exit(1); } if((fp = fopen(file, "r")) == NULL) { fprintf(stderr, "fopen [%s] error[%s]\n", file, strerror(errno)); exit(1); } return fp; }
int gzipMmap(int do_comp,FILE *in,FILE *out){ double Start = Time(); int ifd,ofd; int iz,izm; unsigned long oz; Byte *ia,*iam; Byte *oa,*oam; int rcode; int ioff; int ooff; ifd = fileno(in); ofd = fileno(out); if( !file_isreg(ifd) || !file_isreg(ofd) ){ syslog_ERROR("--- gzipMmap: not reg-file: %d %d\n",ifd,ofd); return -1; } ioff = lseek(ifd,0,1); ooff = lseek(ofd,0,1); izm = file_size(ifd); iz = izm - ioff; if( do_comp ) oz = 1024+iz; else oz = 1024+iz*20; iam = (Byte*)mmap(0,izm,PROT_READ,MAP_SHARED,ifd,0); if( iam == 0 ){ syslog_ERROR("--- gzipMmap: can't open in mmap(%d)\n",ifd); return -1; } ia = iam + ioff; oa = (Byte*)mmap(0,oz,PROT_READ|PROT_WRITE,MAP_SHARED,ofd,ooff); if( oa == 0 ){ syslog_ERROR("--- gzipMmap: can't open out mmap(%d)\n",ofd); munmap(iam,iz); return -1; } lseek(ofd,oz-1,1); write(ofd,"",1); if( do_comp ){ /* Byte *op = oa; *op++ = 0x1F; *op++ = 0x8B; *op++ = 8; *op++ = 0; *op++ = 0; *op++ = 0; *op++ = 0; *op++ = 0; *op++ = 0; *op++ = 3; rcode = compress2(op,&oz,ia,iz,-1); if( rcode == 0 ){ oz += (op - oa); } */ rcode = compress2(oa,&oz,ia,iz,-1); }else{ rcode = uncompress(oa,&oz,ia,iz); } munmap(iam,izm); munmap(oa,oz); syslog_ERROR("(%.4f)g%szip/mmap(%d) %d -> %d\n", Time()-Start,do_comp?"":"un",rcode,iz,oz); if( rcode == 0 ){ Ftruncate(out,ooff+oz,0); fseek(out,0,0); if( do_comp ) return iz; else return oz; } lseek(ifd,ioff,0); lseek(ofd,ooff,0); Ftruncate(out,0,1); return -1; }
int sysbef (char *befbuf) //************************************************************************* // //************************************************************************* { static char shutdown_reason[23]; char xbuf[20]; static char *beftab[] = { "CONNECT", "LOGIN", "CALL", "OSHELL", #ifdef __DOS16__ #ifdef _TNC "TNC", #endif "W2", "UWIN", "TWIN", #ifdef _AUTOTRCWIN "TRWIN", #endif #endif "RTEXT", "CAT", "RPRG", "WTEXT", "WPRG", "RBIN", "WBIN", "SLR", "CLOG", "REORG", "LIFETIME", "MKBOARD", "RMBOARD", "MVBOARD", "SHUTDOWN", "NEW", "KILL", "TEST", "IMPORT", "DISABLE", "ENABLE", #ifdef DIEBOX_UIMPORT "UIMPORT", #endif #ifdef OLDMAILIMPORT "OLDMAILIMPORT", #endif "SETUSER", "BEACON", "GREP", "TGREP", "TAIL", "BEGIN", "BATCH", "EXPORT", "PWGEN", "POSTFWD", "MONITOR", "NOTE", "MACRO", "CFGFLEX", "ORM", "OMV", "OCP", "OMD", "APPEND", #ifdef DF3VI_EXTRACT "EXTRACT", #endif "HOLD", "SETPW", #ifdef FEATURE_YAPP "WYAPP", "RYAPP", #endif #ifdef FEATURE_DIDADIT "WDIDADIT", "RDIDADIT", #endif #if defined FEATURE_SERIAL || defined _TELEPHONE "TTYINIT", #endif #ifdef _TELEPHONE // JJ "TTYCMD", "TTYDIAL", "TTYHANGUP", "TTYSTATUS", "TTYWIN", "TTYCOUNTERRESET", #endif #ifdef _AUTOFWD "AFWDLIST", #endif #ifdef FEATURE_MDPW "MD2SUM", "MD5SUM", #endif #ifdef FEATURE_EDITOR "EDIT", "FEDIT", "REDIT", #else #ifdef DF3VI_FWD_EDIT "FEDIT", "FWDEDIT", #endif #ifdef DF3VI_REJ_EDIT "REDIT", "REJECTEDIT", #endif #ifdef DF3VI_CONV_EDIT "CEDIT", "CONVEDIT", #endif #endif #ifdef _FILEFWD "FWDIMPORT", "FWDEXPORT", #endif "YMBTEST", "SCMDLIST", // Dies ist immer das letzte Kommando! NULL }; enum befnum { unsinn, connect_, login, call_, oshell_, #ifdef __DOS16__ #ifdef _TNC tnc, #endif w2, uwin, twin, #ifdef _AUTOTRCWIN trwin, #endif #endif rtext, rtext_, rprg, wtext, wprg, rbin, wbin, slr, clog, reorg, life_, mkb, rmb, mvb, shutdown_, new_, kill_, test, import, disable_, enable_, #ifdef DIEBOX_UIMPORT uimport_, #endif #ifdef OLDMAILIMPORT oldmailimport_, #endif setuser, beacon, grep_, tgrep, tail, begin, batch, export_, pwgen, postfwd_, monitor_, note, macro, cfgflex_, orm, omv, ocp, omd, _append, #ifdef DF3VI_EXTRACT extract_, #endif hold, setpw, #ifdef FEATURE_YAPP wyapp, ryapp, #endif #ifdef FEATURE_DIDADIT wdidadit, rdidadit, #endif #if defined FEATURE_SERIAL || defined _TELEPHONE ttyinit, #endif #ifdef _TELEPHONE // JJ ttycmd, ttydial, ttyhangup, ttystatus, ttywin_, ttycounterreset, #endif #ifdef _AUTOFWD afwdlist_, #endif #ifdef FEATURE_MDPW md2sum, md5sum, #endif #ifdef FEATURE_EDITOR edit, fedit, redit, #else #ifdef DF3VI_FWD_EDIT fedit, fwdedit, #endif #ifdef DF3VI_REJ_EDIT redit, rejectedit, #endif #ifdef DF3VI_CONV_EDIT cedit, convedit_, #endif #endif #ifdef _FILEFWD fwdimport, fwdexport, #endif ymbtest, scmdlist // Dies ist immer das letzte Kommando! } cmd = unsinn; befbuf += blkill(befbuf); cmd = (befnum) readcmd(beftab, &befbuf, 0); switch (cmd) { #ifdef FEATURE_YAPP case ryapp: #endif #ifdef FEATURE_DIDADIT case rdidadit: #endif #if defined(FEATURE_YAPP) || defined(FEATURE_DIDADIT) break; #endif default: if (u->lf != 6) putv(LF); leerzeile(); // Sends the number of CRs stored in "ALTER LF" } switch (cmd) { case unsinn: if ( mbinitbef(befbuf, 0) #ifdef _TELEPHONE // JJ || ttyinitbef(befbuf, 0) #endif ) { strcpy(xbuf, "^"); mbparsave(); #ifdef _TELEPHONE // JJ ttyparsave(); #endif strncpy(xbuf + 1, befbuf, 18); xbuf[19] = 0; subst1(xbuf, ' ', 0); subst1(xbuf, '=', 0); grep(MBINITNAME, xbuf, o_i); #ifdef _TELEPHONE // JJ grep(INITTTYNAME, xbuf, o_i); #endif return OK; } else return NO; case note: trace(replog, "note", "%s", befbuf); break; #ifdef DF3VI_EXTRACT case extract_: mbchange(befbuf, w_extract, 1); break; #endif case hold: mbchange(befbuf, w_hold, 1); break; case omv: { char f1[50], f2[50]; befbuf = nexttoken(befbuf, f1, 49); befbuf = nexttoken(befbuf, f2, 49); if (! *f1 || ! *f2 || xrename(f1, f2)) putf(ms(m_error)); else { putf(ms(m_moving)); putf(ms(m_nach), f1, f2); } break; } case ocp: { char f1[50], f2[50]; befbuf = nexttoken(befbuf, f1, 49); befbuf = nexttoken(befbuf, f2, 49); if (! *f1 || ! *f2 || filecopy(f1, f2)) putf(ms(m_error)); else { putf(ms(m_copying)); putf(ms(m_nach), f1, f2); } break; } case orm: { char f1[50]; befbuf = nexttoken(befbuf, f1, 49); if (! *f1 || xunlink(f1)) putf(ms(m_filecantdeleted), f1); else putf(ms(m_filedeleted), f1); break; } case omd: { char f1[50]; befbuf = nexttoken(befbuf, f1, 49); killbackslash(f1); if (! *f1 || xmkdir(f1)) putf(ms(m_directorycantcreated), f1); else putf(ms(m_directorycreated), f1); break; } case _append: { char textline[LINELEN+1]; befbuf = nexttoken(befbuf, textline, LINELEN); if (! *befbuf) { putf("Syntax: APPEND <textline> <filename>\n"); break; } FILE *f = s_fopen(befbuf, "sat"); if (f) { fprintf(f, "%s\n", textline); s_fclose(f); } else putf(ms(m_filenotfound), befbuf); } break; case macro: { mk_start(befbuf); } break; case setuser: { char call[CALLEN+1]; befbuf = nexttoken(befbuf, call, CALLEN+1); strupr(call); if (mbcallok(call) && *befbuf) { trace(report, "setuser", "%s", befbuf); { if (! mbalter(NULL, befbuf, call)) putf(ms(m_isunknown), call); b->msg_loadnum = 0; //reload msg loaduser(b->logincall, u, 1); } } else putf("Syntax: SETUSER <call> <option> <value>\n"); } break; case setpw: //automatisierte Passwort-Vergabe { char call[CALLEN+1]; char passwd[40]; int i, pwline = 0; FILE *upwf; befbuf = nexttoken(befbuf, call, CALLEN+1); strupr(call); pwline = atoi(befbuf); if (! mbcallok(call) || ! pwline) { putf("Syntax: SETPW <call> <number>\n"); break; } if (! loaduser(call, u, 0)) { putf(ms(m_isunknown), call); break; } upwf = s_fopen("userpw.bcm", "sr"); if (! upwf) { putf(ms(m_filenotfound), "userpw.bcm"); break; } for (i = 0; i < pwline && ! feof(upwf); i++) fgets(passwd, sizeof(passwd) - 1, upwf); s_fclose(upwf); if (i < pwline) { putf(ms(m_userpwlines), i - 1); break; } strcpy(u->password, passwd); saveuser(u); pwline = strlen(u->password); putf(ms(m_loginpw), pwtypestr(u->loginpwtype), pwtypestr(u->sfpwtype)); putf(" "); putf(ms(m_pwdlength), pwline); sprintf(passwd, "pw set to %i char", pwline); pwlog(call, b->logincall, passwd); b->msg_loadnum = 0; //reload msg loaduser(b->logincall, u, 1); } break; #ifdef DIEBOX_UIMPORT case uimport_: { putf(ms(m_dieboximport)); uimport(); } break; #endif #ifdef OLDMAILIMPORT case oldmailimport_: { scanoptions(befbuf); formoptions(); befbuf += blkill(befbuf); if (isdir(befbuf)) { putf(ms(m_omi_started), befbuf); putflush(); oldmailimport(befbuf); } else putf(ms(m_dirunknown), befbuf); } break; #endif case disable_: { putf(ms(m_boxdisabled)); m.disable = 1; mbparsave(); } break; case enable_: { putf(ms(m_boxenabled)); m.disable = 0; mbparsave(); } break; case test: { if (*befbuf == 'W') { while (1); } // for testing watchdog else if (*befbuf == 'S') { trace(fatal, "test", "abort"); } else if (*befbuf == 'V') { *(char *)0 = 1; } else mk_start(befbuf); } break; case batch: { runbatch(befbuf); } break; case rtext: case rtext_: { fileio_text fio; fio.usefile(befbuf); fio.tx(); putf("\032\n"); // CTRL-Z } break; case wtext: { fileio_text fio; fio.usefile(befbuf); fio.rx(); } break; case rbin: case rprg: { fileio_abin fio; fio.usefile(befbuf); fio.tx(); } break; case wbin: case wprg: { fileio_abin fio; fio.usefile(befbuf); fio.rx(); } break; #ifdef FEATURE_YAPP case ryapp: { fileio_yapp fio; fio.usefile(befbuf); fio.tx(); } break; case wyapp: { fileio_yapp fio; fio.usefile(befbuf); fio.rx(); } break; #endif // FEATURE_YAPP #ifdef FEATURE_DIDADIT case rdidadit: { fileio_dida fio; fio.usefile(befbuf); fio.tx(); } break; case wdidadit: { fileio_dida fio; if (! *befbuf) fio.usefile("dummy"); else { if (befbuf[strlen(befbuf) - 1] != '/') strcat(befbuf, "/"); strcat(befbuf, "dummy"); fio.usefile(befbuf); } fio.rx(); } break; #endif // FEATURE_DIDADIT case slr: { scanoptions(befbuf); putlog(TRACEPATH "/" SYSLOGRNAME, befbuf); } break; case clog: { scanoptions(befbuf); putlog(TRACEPATH "/" CMDLOGNAME, befbuf); } break; case tail: { scanoptions(befbuf); befbuf += blkill(befbuf); if (b->optplus&o_f && *befbuf) { int a; FILE *f = s_fopen(befbuf, "lrt"); if (f) { fseek(f, 0, SEEK_END); do { while ((a = fgetc(f)) != EOF) putv(a); wdelay(349); } while (! testabbruch()); s_fclose(f); } } else { fileio_text fio; fio.usefile(befbuf); fio.settail(-2000); fio.tx(); } } break; case begin: { fileio_text fio; fio.usefile(befbuf); fio.settail(2000); fio.tx(); } break; case monitor_: { if (*befbuf) { scanoptions(befbuf); b->continous = 1; monitor(atoi(befbuf), b->optplus); } else putf("Syntax: MONITOR [-iords] <task-id>\n"); } break; case tgrep: { char string[61]; char name[40]; scanoptions(befbuf); if (b->optminus & o_i) b->optplus |= o_i; //wenn nicht explizit "-i-", ist "-i" default b->usermail = 0; if (! *befbuf) { putf("Syntax: TGREP [pattern] <fwd-bbs>\n"); break; } befbuf = nexttoken(befbuf, string, 60); if (*befbuf) { sprintf(name, TRACEPATH "/t_%s.bcm", befbuf); grep(name, string, b->optplus); } else { sprintf(name, TRACEPATH "/t_%s.bcm", string); putlog(name, ""); } } break; case grep_: { char string[61]; scanoptions(befbuf); if (b->optminus & o_i) b->optplus |= o_i; //wenn nicht explizit "-i-", ist "-i" default b->usermail = 0; befbuf = nexttoken(befbuf, string, 60); grep(befbuf, string, b->optplus); } break; #ifdef _AUTOFWD case afwdlist_: { afwdlist(befbuf); } break; #endif case life_: { if (*befbuf) { strupr(befbuf); char *life = skip(befbuf); int board = finddir(befbuf, b->sysop); if (board > 0) { board -= 1; if (life && *life) { tree[board].lifetime_max = atoi(life); tree[board].lifetime_min = 1; if (tree[board].lifetime_max > 999) tree[board].lifetime_max = 999; if (tree[board].lifetime_max < 1) tree[board].lifetime_max = 1; char *life_min = skip(life); if (life_min && *life_min) { tree[board].lifetime_min = atoi(life_min); if (tree[board].lifetime_min > 999) tree[board].lifetime_min = 999; if (tree[board].lifetime_min < 1) tree[board].lifetime_min = 1; } mbtreesave(); } putf(ms(m_lifetimestat), b->boardfullname, tree[board].lifetime_max, tree[board].lifetime_min); } else putf(ms(m_notfound), befbuf); } else putf("Syntax: LIFETIME <board> <days_maximum> [<days_minimum>]\n" " (with 1 <= days_maximum/days_minimum <= 999)\n\n"); } break; #ifdef _TNC case tnc: { control_tnc(befbuf); } break; #endif case connect_: { termqso(befbuf); } break; case login: { if (mbcallok(befbuf)) { mblogin(befbuf, login_standard, b->uplink); cmdlog("login changed"); putf(ms(m_loginchanged)); } else putf("Syntax: LOGIN <new logincall>\n"); } break; case call_: { if (mbcallok(befbuf)) { mblogin(befbuf, login_silent, b->uplink); b->msg_loadnum--; //Sonst wird falsche Sprache benutzt cmdlog("call changed"); } else putf("Syntax: CALL <new logincall>\n"); } break; case oshell_: { if (t->input == io_file || t->output == io_file) oshell(befbuf, sh_noinput); else oshell(befbuf, m.dosinput ? sh_forceinput : sh_ifmultitask); } break; case reorg: { if (sema_test("purgereorg") == 1) putf(ms(m_purgeallstarted)); else { putf(ms(m_reorginvoked)); fork(P_BACK | P_MAIL, 0, mbreorg, befbuf); } } break; case postfwd_: { putf(ms(m_postfwdinvoked)); fork(P_BACK | P_MAIL, 0, postfwd, "Postfwd"); } break; #ifdef FEATURE_EDITOR case edit: { fork(P_WIND | P_KEYB, 0, editfile, befbuf); } break; case fedit: { fork(P_WIND | P_KEYB, 0, editfile, FWDLISTNAME); } break; case redit: { fork(P_WIND | P_KEYB, 0, editfile, REJECTNAME); } break; #else #ifdef DF3VI_FWD_EDIT case fedit: //wenn kein editor vorhanden remote-editor aufrufen case fwdedit: { fwdlistedit(befbuf); } break; #endif #ifdef DF3VI_REJ_EDIT case redit: case rejectedit: { rejectlistedit(befbuf); } break; #endif #ifdef DF3VI_CONV_EDIT case cedit: case convedit_: { convedit(befbuf); } break; #endif #endif case new_: { scanoptions(befbuf); mbinit(); initfwdlist(); #ifdef _AUTOFWD initafwdlist(); #endif if (! (b->optplus & o_q)) // skip statistics on "new -q" { b->optplus = o_s | o_f | o_c; putf(ms(m_hadrstat)); browse_hadr(""); } mbcvtload(); #ifdef RUNUTILS read_runfile(); #endif msg_dealloc(1); mk_read_jobs(); } break; case kill_: { if (atoi(befbuf)) { while (atoi(befbuf)) { if (! killtask(nextdez(&befbuf), 1)) putf(ms(m_cantkilltask)); } } else putf("Syntax: KILL <task-id>\n"); } break; #ifdef __DOS16__ case w2: { fork(P_WIND | P_KEYB|P_MAIL, 0, mbwin2, m.sysopcall); } break; case uwin: { fork(P_WIND | P_KEYB|P_MAIL, 0, userwin, "Users"); } break; case twin: { fork(P_WIND | P_MAIL, 0, taskwin, befbuf); } break; #ifdef _AUTOTRCWIN case trwin: { if (*befbuf) fork(P_WIND | P_MAIL, 0, trcwin, befbuf); else putf("Syntax: TRWIN [-iords] <task-id>\n"); } break; #endif #endif //__DOS16__ case mkb: { char mainboard[30]; char newboard[20]; char *slash; befbuf = nexttoken(befbuf, mainboard, 29); befbuf = nexttoken(befbuf, newboard, 19); slash = strchr(mainboard + 1, '/'); if (slash && (! *newboard)) { *slash = 0; strcpy(newboard, slash + 1); } if (! *newboard && *mainboard == '/') { strcpy(newboard, mainboard + 1); mainboard[1] = 0; } if (*mainboard && *newboard) { switch (mkboard(mainboard, newboard, 0)) { case 0: putf(ms(m_boardcreated)); break; case 1: putf(ms(m_mainboardnotfound)); break; case 2: putf(ms(m_toomanyboards)); break; case 3: putf(ms(m_boardnameexist)); break; case 4: putf(ms(m_invalidboardname)); break; } } else putf("Syntax: MKBOARD <mainboard> <subboard>\n"); } break; case rmb: { if (*befbuf) { subst1(befbuf, ' ', '/'); if (*befbuf == '/' && befbuf[1] == '/') befbuf++; switch (rmboard(befbuf)) { case 0: putf(ms(m_boardremoved)); break; case 1: putf(ms(m_boardnotfound)); break; case 2: putf(ms(m_boardnotempty)); break; } } else putf("Syntax: RMBOARD <mainboard> <subboard>\n"); } break; case mvb: { char oldboard[20]; char subboard[20]; char neuboard[20]; befbuf = nexttoken(befbuf, oldboard, 19); befbuf = nexttoken(befbuf, subboard, 19); befbuf = nexttoken(befbuf, neuboard, 19); if (*oldboard && *subboard && *neuboard) { switch (mvboard(oldboard, subboard, neuboard)) { case 0: putf(ms(m_boardmoved)); break; case 1: putf(ms(m_newboardnotfound)); break; case 2: putf(ms(m_toomanyboards)); break; case 4: putf(ms(m_oldboardnotfound)); break; } } else putf("Syntax: MVBOARD <oldboard> <subboard> <newboard>\n"); } break; case shutdown_: { scanoptions(befbuf); #ifdef __DOS16__ if (b->optplus & o_r) atexit((void(*)()) MK_FP(0xffff, 0x0000)); #endif runterfahren = 1; sprintf(shutdown_reason, "shutdown by %s", b->logincall); stopreason = shutdown_reason; } break; case cfgflex_: { if (*befbuf && file_isreg("cfgflex.bcm")) { putf(ms(m_flexstarted)); fork(P_BACK | P_MAIL, 0, cfgflex, befbuf); } else putf("Syntax: CFGFLEX <flexcall> (cfgflex.bcm must exist)\n"); } break; case import: { sysimport(befbuf); } break; case export_: { if (*befbuf) { if ((t->input != io_file || t->output == io_dummy) && t->output != io_file) { char fname[51]; scanoptions(befbuf); befbuf = nexttoken(befbuf, fname, 50); if (b->optplus & o_a) // neue Option -b fuer binaer { if (b->optplus & o_b) b->outputfile = s_fopen(fname, "sab"); else b->outputfile = s_fopen(fname, "sat"); } else { if (b->optplus & o_b) b->outputfile = s_fopen(fname, "swb"); else b->outputfile = s_fopen(fname, "swt"); } if (b->outputfile) { s_fsetopt(b->outputfile, 1); b->oldinput = t->input; b->oldoutput = t->output; t->input = io_dummy; t->output = io_file; b->continous = 1; if (b->optplus & o_u) b->sysop = 0; if (*befbuf) mailbef(befbuf, 0); b->sysop = 1; } else putf(ms(m_filenotopen), fname); } } else putf("Syntax: EXPORT <filename> <box-command>\n"); } break; case beacon: { if (*befbuf) { FILE *f = s_fopen(BEACONNAME, "srt"); unsigned int i = 0; char s[LINELEN+1]; if (f) { while (fgets(s, LINELEN, f)) { if (*s) { s[strlen(s) - 1] = 0; putbeacon_tnc(s, befbuf); i++; } } s_fclose(f); } putf(ms(m_beaconframes), i); } else { fork(P_BACK | P_MAIL, 0, sendmailbake, "Beacon"); putf(ms(m_beaconstarted)); } } break; case pwgen: { FILE *f; if (*befbuf && (f = s_fopen(befbuf, "swt")) != 0) { unsigned int i; int upw; upw = ! stricmp(befbuf, "userpw.bcm"); // file fuer setpw for (i = 0; i < 1620; i++) { char c = 0; while (! isalnum(c)) c = random_max('z'); fputc(c, f); //pw-file fuer setpw erzeugen (81 Zeilen mit je 20 Zeichen) if (upw && (i % 20) == 19) fputc(LF, f); } trace(report, "pwgen", "%s created", befbuf); s_fclose(f); } else //ohne Parameter immer userpw.bcm erzeugen if (! *befbuf && (f = s_fopen("userpw.bcm", "swt")) != 0) { unsigned int i; for (i = 0; i < 1620; i++) { char c = 0; while (! isalnum(c)) c = random_max('z'); fputc(c, f); //pw-file fuer setpw erzeugen (81 Zeilen mit je 20 Zeichen) if ((i % 20) == 19) fputc(LF, f); } trace(report, "pwgen", "userpw.bcm created"); s_fclose(f); } } break; case scmdlist: // DH3MB { unsigned int i = 0; while (beftab[i]) putf("(%02d) %s\n", ++i, beftab[i]); } break; #ifdef FEATURE_MDPW case md2sum: { if (! *befbuf) { putf("Syntax: MD2SUM <filename>\n"); break; } if (! file_isreg(befbuf)) putf(ms(m_filenotfound), befbuf); else { MD2 md2; md2.readfile(befbuf, 0L); md2.gethexdigest(b->line); putf("%s %s\n", b->line, befbuf); } } break; case md5sum: { if (! *befbuf) { putf("Syntax: MD5SUM <filename>\n"); break; } if (! file_isreg(befbuf)) putf(ms(m_filenotfound), befbuf); else { MD5 md5; md5.readfile(befbuf, 0L); md5.gethexdigest(b->line); putf("%s %s\n", b->line, befbuf); } } break; #endif #if defined FEATURE_SERIAL || defined _TELEPHONE case ttyinit: { if (eingelogt("getty", 0, 0)) putf(ms(m_ttyactive)); else init_tty(); } break; #endif #ifdef _TELEPHONE // JJ case ttycmd: { if (*befbuf) { if (m.ttydevice > 1) putf_tty("%s\r", befbuf); else putf(ms(m_nomodem)); } else putf("Syntax: TTYCMD <command>\n"); } break; case ttydial: { strupr(befbuf); char *nummer; char call[8]; nummer = nexttoken(befbuf, call, 8); if (*befbuf && mbcallok(call)) { if (m.ttydevice && (get_ufwd(call)[0] || isforwardpartner(call) >= 0)) { putf(ms(m_startphonefwd), call, nummer); sprintf(befbuf, "%s TTY %s", call, nummer); fork(P_BACK | P_MAIL, 0, fwdsend, befbuf); } else putf(ms(m_nottyactive)); } else putf("Syntax: TTYDIAL <call> <number>\n"); } break; case ttyhangup: { tty_hangup(); putf(ms(m_hangupmodem)); } break; case ttystatus: { tty_statustext(); putv(LF); } break; case ttywin_: { fork(P_WIND | P_MAIL, 0, tty_win, befbuf); } break; case ttycounterreset: { tty_counterreset(); putv(LF); } break; #endif #ifdef _FILEFWD case fwdimport: { if (*befbuf) fwd_import(befbuf); } break; case fwdexport: { if (*befbuf) fwd_export(befbuf); } break; #endif case ymbtest: { #ifdef _USERCOMP if (u->comp == 1) { /* char output[256] = { 0 }; char output2[256] = { 0 }; int i, il = 0; */ putf("//COMP 1\n\n"); putflush(); /* il = comp_sp_stat_huff(befbuf, strlen(befbuf), output); // printf("il: %d strlen: %d\n",il,strlen(befbuf)); // printf("befbuf:\n-%s-\nOut:\n-%s-\n",befbuf,output); //putflush(); for (i = 1; i < il ; i++) bputv(output[i]); putv(LF); putflush(); output[0] = '\0'; strcpy(befbuf, "dies ist noch ein laengerer text 2"); il = comp_sp_stat_huff(befbuf, strlen(befbuf), output); for (i = 1; i < il ; i++) bputv(output[i]); putv(LF); putflush(); output[0] = '\0'; strcpy(befbuf, "dies ist ein noch laengerer text 3"); il = comp_sp_stat_huff(befbuf, strlen(befbuf), output); for (i = 1; i < il ; i++) bputv(output[i]); putv(LF); putflush(); putf("\n"); il = decomp_sp_stat_huff(output, strlen(output), output2); printf("il: %d strlen: %d\n",il,strlen(output)); printf("Out2:\n-%s-\n",output2); */ /* #include "ahuf.h" // TOP-Huffman class AHUF; AHUF *ahuf; ahuf = new AHUF(); il = ahuf->Komprimieren(true, befbuf, output, strlen(befbuf) ); printf("il: %d strlen: %d\n",il,strlen(befbuf)); printf("befbuf:\n-%s-\nOut:\n-%s-\n",befbuf,output); putflush(); putf("%s",output); putflush(); putf("\n"); */ } #endif } break; } return OK;
int relaysxX(RelayCtrl *relayCtrl,int timeout,int sdc,int sdv[][2],int sdx[],int rccs[],IFUNCP funcv[],void *argv[]) { int fi; int pc,pi,pfv[32],pxv[32]; int fds[32],errv[32],rfds[32]; int isreg[32]; int wccs[32]; int sdxb[32]; int cntv[32]; int rcode,rcc,wcc; IFUNCP funcvb[32]; void *argvb[32]; int nready; double Lastin[32],Now,Timeout,Idlest,Time(); double Start; int timeouti; int prepi; int fj; int dobreak; int packs; relayCB cb; int otimeout = timeout; RELAY_stat = 0; if( SILENCE_TIMEOUT ) syslog_ERROR("relays(%d) start: TIMEOUT=io:%ds,silence:%ds\n", sdc,timeout/1000,SILENCE_TIMEOUT); else syslog_ERROR("relays(%d) start: timeout=%dmsec\n",sdc,timeout); if( lMULTIST()){ if( RELAY_threads_timeout ){ syslog_ERROR("relays thread (%d/%d) timeout=%d <= %d\n", actthreads(),numthreads(), RELAY_threads_timeout,timeout/1000); timeout = RELAY_threads_timeout * 1000; } } if( funcv == NULL ){ funcv = funcvb; for( fi = 0; fi < sdc; fi++ ) funcv[fi] = NULL; } if( argv == NULL ){ argv = argvb; for( fi = 0; fi < sdc; fi++ ) argv[fi] = NULL; } Now = Time(); Start = Now; for( fi = 0; fi < sdc; fi++ ){ /* sv1log("#### NODELAY\n"); set_nodelay(sdv[fi][1],1); */ fds[fi] = sdv[fi][0]; isreg[fi] = file_isreg(fds[fi]); errv[fi] = 0; rccs[fi] = 0; cntv[fi] = 0; wccs[fi] = 0; Lastin[fi] = Now; if( funcv[fi] == NULL ) funcv[fi] = (IFUNCP)relay1; /* fcntl(fds[fi],F_SETOWN,getpid()); signal(SIGURG,sigURG); */ if( sdx == NULL ){ sdxb[fi] = 0; if( RELAYS_IGNEOF ){ if( file_issock(sdv[fi][0]) < 0 ) sdxb[fi] |= IGN_EOF; } } } if( sdx == NULL ) sdx = sdxb; RELAY_num_turns = 0; dobreak = 0; prepi = -1; packs = 0; for(;;){ pc = 0; Idlest = Now = Time(); for( fi = 0; fi < sdc; fi++ ){ if( errv[fi] == 0 ){ pfv[pc] = fds[fi]; pxv[pc] = fi; pc++; } if( Lastin[fi] < Idlest ){ Idlest = Lastin[fi]; } } if( pc == 0 ) break; if( lSINGLEP() ){ int nith; /* with no idle threads ... and ready to accept()? */ /* 9.9.7 this restriction became less necessary with http-sp */ if( lMULTIST() && RELAY_threads_timeout ){ /* 9.9.8 for CONNECT/yyshd */ }else if( (nith = idlethreads()) < 3 ){ int ntimeout = (10+nith*2)*1000; nready = PollIns(1,pc,pfv,rfds); if( nready == 0 ) if( ntimeout < timeout ){ syslog_ERROR("shorten timeout %.2f <= %.2f (%d/%d)\n", ntimeout/1000.0,timeout/1000.0, nith,actthreads()); timeout = ntimeout; } } } errno = 0; if( RELAY_idle_cb ){ int cbtime; nready = PollIns(1,pc,pfv,rfds); if( nready ) goto POLLED; if( cb = RELAY_idle_cb ){ cbtime = (*cb)(relayCtrl,Now-Start,RELAY_num_turns); if( cbtime <= 0 ){ nready = 0; syslog_ERROR("## relaysx: idle_cb timeout %d/%.2f %X\n", cbtime,Now-Start,xp2i(RELAY_idle_cb)); }else{ if( timeout < cbtime ) cbtime = timeout; nready = PollIns(cbtime,pc,pfv,rfds); if( nready ){ goto POLLED; } } if( cb = RELAY_idle_cb ){ Now = Time(); (*cb)(relayCtrl,Now-Start,RELAY_num_turns); } } errno = 0; } if( SILENCE_TIMEOUT ){ timeouti = (int)(1000*(SILENCE_TIMEOUT - (Now-Idlest))); if( timeouti <= 0 ) break; if( timeouti <= timeout ){ nready = PollIns(timeouti,pc,pfv,rfds); goto POLLED; } } if(0) if( dobreak ){ /* shorten the timeout of the connection to be broken */ timeouti = 1000*2; if( timeouti <= timeout ){ syslog_ERROR("## EXIT relaysx: shorten timeout %d\n", timeouti); nready = PollIns(timeouti,pc,pfv,rfds); goto POLLED; } } if( 0 <= RELAY_getxfd() ){ int elp,rem,to1; elp = 0; rem = timeout; for( rem = timeout; 0 < rem; rem -= to1 ){ if( 200 < rem ) to1 = 200; else to1 = rem; nready = PollIns(to1,pc,pfv,rfds); if( nready ){ break; } if( inputReady(RELAY_getxfd(),0) ){ if( lCONNECT() ) fprintf(stderr,"--{c} relaysx: xfd ready: %d/%d/%d/%d\n", to1,rem,elp,timeout); if( 400 < rem ){ rem = 400; } } elp += to1; } }else nready = PollIns(timeout,pc,pfv,rfds); /* should ignore EINTR, by SIGSTOP/SIGCONT if( nready < 0 && errno == EINTR ){ continue; } */ POLLED: /* if( nready == 0 && errno == 0 ){ */ if( nready == 0 && errno == 0 || gotOOB(-1) ){ int fi,sync; int oob = 0; if(nready==0) syslog_ERROR("-- relaysx: pc=%d nready==0 errno==%d OOB=%d (%.2f)\n",pc,errno, gotOOB(-1),Time()-Idlest); if( nready == 0 && errno == 0 ){ syslog_ERROR("relaysx: TIMEOUT=io:%.2f (%.2f)\n", timeout/1000.0,Time()-Start); } sync = 0; for( fi = 0; fi < sdc; fi++ ) { if( !isreg[fi] ) if( withOOB(sdv[fi][0]) ) { oob++; sync += relayOOB(sdv[fi][0],sdv[fi][1]); if( sync == 0 && isWindowsCE() ){ /* 9.9.7 no-OOB on WinCE */ int ifd,alv; ifd = sdv[fi][0]; alv = IsAlive(ifd); syslog_ERROR("non-OOB [%d] alive=%d, rdy=%d,err=%d\n",ifd,alv,nready,errno); goto RELAYS; /* to detect EOF */ } } } if( oob ){ if( sync ) continue; Usleep(1); nready = PollIns(1,pc,pfv,rfds); if( 0 < nready ){ syslog_ERROR("## tcprelay: ignore OOB? rdy=%d/%d,oob=%d\n",nready,pc,oob); if( 1 ){ /* 9.9.7 break loop on shutdown socket (FreeBSD8) */ for( fi = 0; fi < sdc; fi++ ){ int ifd = sdv[fi][0]; if( !isreg[fi] && !IsAlive(ifd) ){ syslog_ERROR("non-OOB [%d] Not-alive, rdy=%d,err=%d\n",ifd,nready,errno); goto RELAYS; } } } continue; } } } RELAYS: if( nready <= 0 ) break; if( RELAY_half_dup ){ if( 0 < RELAY_max_paras || 1 < RELAY_concat ){ /* be tolerant about non-half-dup */ }else /* to more strictly checking non-half_dup */ if( nready < pc ){ Usleep(1000); nready = PollIns(1,pc,pfv,rfds); } if( nready == pc ){ if( 2 <= pc && toBeBroken(relayCtrl,pc,pfv) ){ /* syslog_ERROR("## EXIT relaysx: not half_duplex\n"); RELAY_stat = RELAY_NOTHALFDUP; goto EXIT; */ fj = pxv[0<prepi?prepi:0]; syslog_ERROR("## EXIT relaysx: not half_duplex %d[%d] %d/%d\n", RELAY_num_turns,fj,rccs[fj],cntv[fj]); dobreak = 3; } } } for( pi = 0; pi < pc; pi++ ){ if( 0 < rfds[pi] ){ int pushed; int nx = 0; int tl = 0; RELAY1: if( RELAY_half_dup && nready == pc ){ if( pi != prepi ){ /* postpone for serialize, * relay as half-dup as possible */ continue; } } fi = pxv[pi]; if( pi != prepi ){ if( dobreak ){ /* syslog_ERROR("## EXIT relaysx: %d\n",dobreak); */ fj = pxv[0<prepi?prepi:0]; syslog_ERROR("## EXIT relaysx: break=%d %d [%d] %d/%d\n", dobreak,RELAY_num_turns,fj,rccs[fj],cntv[fj]); goto EXIT; } RELAY_num_turns++; packs = 0; } if( RELAY_max_packintvl ){ if( pi == prepi ){ double intvl; intvl = Time() - Lastin[fi]; if( RELAY_max_packintvl < intvl ){ if( RELAY_num_turns <= 5 ){ syslog_ERROR("## %d[%d] max-intvl(%d)<%d\n", RELAY_num_turns,pi,(int)(1000*RELAY_max_packintvl),(int)(1000*intvl)); syslog_ERROR("## %d[%d] max-intvl<%d\n", RELAY_num_turns,pi,(int)(1000*intvl)); }else { RELAY_packintvl = intvl; dobreak = 1; /* syslog_ERROR("## EXIT relaysx: max-intvl<%d\n", (int)(1000*intvl)); */ fj = pxv[0<prepi?prepi:0]; syslog_ERROR("## EXIT relaysx: max-intvl<%d %d [%d] %d/%d\n", (int)(1000*intvl),RELAY_num_turns,fj,rccs[fj],cntv[fj]); } } }else{ if( dobreak ) goto EXIT; } } if( RELAY_max_turns && pi != prepi ){ if( Now-Start < RELAY_thru_time ){ }else if( RELAY_max_turns < RELAY_num_turns ){ syslog_ERROR("## EXIT relaysx: max_turns=%d\n", RELAY_num_turns); goto EXIT; } } prepi = pi; pushed = 0 <= top_fd(sdv[fi][0],0); rcode = (*funcv[fi])(argv[fi],sdv[fi][0],sdv[fi][1],&rcc,&wcc); Lastin[fi] = Time(); /* rccs[fi] += wcc; */ rccs[fi] += rcc; wccs[fi] += wcc; cntv[fi] += 1; packs += 1; if( RELAY_half_dup /* && RELAY_ssl_only */ ){ CStr(spack,32); unsigned char *up = (unsigned char*)lastpack; sprintf(spack,"%2X %2X %2X %2X %2X", up[0],up[1],up[2],up[3],up[4]); syslog_DEBUG("%2d.%d %2d->%2d %4d [%s]\n", RELAY_num_turns,packs, sdv[fi][0],sdv[fi][1],rcc, spack); /* the first packet in the turn of the side * must begin with a heaer of a SSL frame. * (CONNECT for STARTTLS on HTTP might be * allowed...) */ if( RELAY_ssl_peek || RELAY_ssl_only ){ if( RELAY_ssl_peek ){ /* new-140518b */ syslog_ERROR("SSL %2d.%d [%d]->[%d] %4d [%s]\n", RELAY_num_turns,packs, sdv[fi][0],sdv[fi][1],rcc, spack); } if( packs == 1 && 5 <= lastpackLeng ){ /* if( 0x20 < up[0] && up[0] != 0x80 ){ */ if( isSSLrecord(up,spack,lastpackLeng,pfv[fi]) < 0 ){ if( RELAY_ssl_only ){ /* mod-140518a */ syslog_ERROR("## EXIT relaysx: non-SSL [%s]\n", spack); dobreak = 2; } } } lastpackLeng = 0; if( RELAY_half_dup ){ int s1 = sdv[fi][0]; if( concat(relayCtrl,s1,nx,tl,rcode,nready) ){ nx++; tl += rcode; goto RELAY1; } } } } if( pushed && rcode == -1 && errno == EAGAIN ){ syslog_ERROR("## relaysx() pop_fd:%d\n", sdv[fi][0]); }else if( rcode <= 0 ){ syslog_ERROR( "relays[%d]: [%d->EOF] %d(%di+%do)\n", fi,fds[fi],rcode,rcc,wcc); if( sdx == NULL || (sdx[fi] & IGN_EOF) == 0 ) goto EXIT; else errv[fi] = 1; } } } } EXIT: for( fi = 0; fi < sdc; fi++ ) syslog_ERROR("relays[%d]: [%d->%d] %d bytes / %d -> %d\n",fi, sdv[fi][0],sdv[fi][1],rccs[fi],cntv[fi],wccs[fi]); /* syslog_ERROR("relays[%d]: [%d->%d] %d bytes / %d\n",fi, sdv[fi][0],sdv[fi][1],rccs[fi],cntv[fi]); */ return 0; }
int spawnFilter(Connection *Conn,int iomode,int tofil[],int sock,iFUNCP func,PCStr(args)) { CStr(ein,32); int ac; const char *av[256]; /**/ CStr(epath,1024); CStr(logtype,64); CStr(logtype2,64); int fin; /* input at the filter side */ int fout; /* output at the DeleGate side */ int pid; int wcc; int wi; int fio[2]; /* a pipe to inherit Conn. */ FILE *out; SpawnArgs spawnArgs; iLog("--- spawnFilter sock=%d func=%X args=%X",sock,xp2i(func),p2i(args)); fin = tofil[0]; fout = tofil[1]; pipeX(fio,8*1024); out = fdopen(fio[1],"w"); sprintf(ein,"%d/%d/%d/%d %d/%d",fio[0],fio[1],fin,fout, CHILD_SERNO,CHILD_SERNO_MULTI); /* sprintf(ein,"%d/%d/%d/%d",fio[0],fio[1],fin,fout); */ /* sprintf(ein,"%d/%d",fin,fout); */ sprintf(epath,"%s=%s",P_EXEC_PATH,EXEC_PATH); ac = 0; av[ac++] = /*DeleGate1*/ "DeleGate"; av[ac++] = /*FuncFILTER*/ "(Filter)"; av[ac++] = ein; av[ac++] = epath; /* sprintf(logtype,"-L0x%x",LOG_type); */ sprintf(logtype,"-L0x%x/%d",LOG_type,curLogFd()); av[ac++] = logtype; if( LOG_type2 || LOG_bugs ){ sprintf(logtype2,"-L20x%x/%x",LOG_type2,LOG_bugs); av[ac++] = logtype2; } ac += copy_param("f",elnumof(av)-ac,&av[ac],&main_argv[1]); av[ac] = NULL; Conn->fi_func = func; if( args == NULL ) Conn->fi_arglen = 0; else Conn->fi_arglen = strlen(args)+1; Conn->fi_iomode = iomode; Conn->fi_logfd = curLogFd(); if( file_isreg(sock) ){ /* it might be TMPFILE() with CloseOnExec flag set */ clearCloseOnExec(sock); } Conn->fi_topeer = sock; Conn->fi_dupclsock = 0; if( Conn->fi_issock = file_ISSOCK(sock) ){ setclientsock(sock); if( sock == ClientSock || SocketOf(sock) == SocketOf(ClientSock) ) Conn->fi_dupclsock = 1; } /* might be emulating spawn() on Unix */ sigsetmask(sigblock(0) & ~sigmask(SIGHUP) ); pid = Spawnvp("openFilter",EXEC_PATH,av); Verbose("## spawnFilter: %d -> %d\n",getpid(),pid); if( pid <= 0 ){ /* 9.6.3 don't freeze in fwrite() to the pipe ... */ fclose(out); close(fio[0]); daemonlog("F","spawnFilter: FAILED %d\n",pid); porting_dbg("--FATAL: spawnFilter: FAILED spawn %d",pid); putpplog("--FATAL: spawnFilter: FAILED spawn %d\n",pid); return pid; } /* wcc = write(fout,Conn,sizeof(Connection)); if( Conn->cl_reqbuf ) write(fout,Conn->cl_reqbuf,Conn->cl_reqbufsize); if( args != NULL ) write(fout,args,strlen(args)+1); */ close(fio[0]); /* close here to get EPIPE on write(fio[1]) */ if( MountOptions ){ spawnArgs.sa_mountserno = MountSerno(MountOptions); spawnArgs.sa_moptslen = strlen(MountOptions)+1; }else{ spawnArgs.sa_mountserno = 0; spawnArgs.sa_moptslen = 0; } wcc = fwrite(&spawnArgs,1,sizeof(spawnArgs),out); wcc = fwrite(Conn,1,sizeof(Connection),out); if( Conn->cl_reqbuf ) fwrite(Conn->cl_reqbuf,1,Conn->cl_reqbufsize,out); if( args != NULL ) fwrite(args,1,strlen(args)+1,out); if( MountOptions && spawnArgs.sa_moptslen ){ fwrite(MountOptions,1,spawnArgs.sa_moptslen,out); setMountOptions(FL_ARG,Conn,0); } fclose(out); /* If the iomode == READ then * must wait till the client finish to read the written environment * not to read it by myself. * (in the case of FFROMCL, payload data may be ready, but cannot * identify whether or not it is env. data or payload data ...) * If the iomode == WRITE and filter is direct system-command then * must wait not to make buffered data be not passed to the filter. */ /* if( iomode == 0 || iomode != 0 && 0 < PollIn(fin,1) ){ sv1log("## wait the filter finish reading enviroment\n"); msleep(100); } */ return pid; }