[Mcntp-discussion] Patches fuer mcntp
Brought to you by:
pilhuhn
From: Joerg D. <jd...@eu...> - 2001-12-07 16:43:26
|
Hallo Heiko, ich habe mcntp auf meiner Kiste grundsaetzlich zum laufen gebracht. Die notwendigen patches haengen untendran. Kommentare folgen. Passiert mit dem project auf sourceforge eigentlich etwas? Die mailinglisten scheinen sehr ruhig zu sein. Wenn es aktiv ist, wuerde ich gerne mitentwickeln. (CVS z.B. waere etwas feines.) Auch wenn mcntp jetzt erst mal hauptsache laeuft, reizt es mich zu weiteren patches. Vor allem umstellen der cryptoroutinen auf openssl und zusaetzliche verschluesselung. Laut openssl rsa manpage sollte das nicht allzuschwer sein. Mit diesen Patches laeuft mcntp grundsaetzlich auf einer Kiste mit etwas, dass mal auf slackware basierte, Kernel version 2.2.17 und inn 2.3.1. Zu den Patches: - Ein problem war die articlegroesse. Diese wurde nur bei zugriff uebers Dateisystem aufgefuellt, nicht uber storageapi. Daneben enden alle artikel mit .\r\n (auch die, die im tradspool auf der platte liegen) Der Patch kuerzt blind die letzten 3 Zeichen. mcrcv fuegt automatisch den schluss wieder an. (Ich habe Fehlermeldungen bekommen "bad_command: ." wegen des . zuviel) Daneben wird die Artikelgroesse jetzt auch beim Zugriff ueber storageapi ausgefuellt. (mcxmit kann artikel der groesse 0 verschicken, aber daran verschluckt sich mcrcv) Dann wurde beim zugriff ueber storageapi etwas geschlossen, das gar nicht auf war. Ohne storageapi gab es kein munmap fuer ein mmap. - yawgmoth fork sich jetzt in den Hintergrund, wenn es ohne -d aufgerufen wird. Ausserdem hat select() unter Linux die angewohnheit, den timeout zu veraendern. Laut manpage ist die portabelst Annahme, dass die struktur anschliessend undefiniert ist. Ich initialisiere sie jetzt jedesmal explizit. Tschau, Joerg diff -urN --exclude-from exclude mcntp-1.2pre2/mcxmit/mcxmit.c mcntp-1.2pre2.worksforme/mcxmit/mcxmit.c --- mcntp-1.2pre2/mcxmit/mcxmit.c Wed Nov 14 16:44:43 2001 +++ mcntp-1.2pre2.worksforme/mcxmit/mcxmit.c Fri Dec 7 16:36:59 2001 @@ -242,6 +242,7 @@ char linebuf[1024]; char fs_path[MAXPATHLEN]; char *artbuf,*c,*artbuf2; + unsigned long artsize; #ifndef DONTWANTZLIB char *cobuf=NULL; unsigned long co_len,col2; @@ -323,6 +324,7 @@ #else res=read(fd,artbuf,ART_MAXSIZE-1); #endif + artsize=a_stat.st_size; } else { read_error = 1; } @@ -346,6 +348,7 @@ if (arthndl) { artbuf = arthndl->data; + artsize=arthndl->len; } else { read_error = 1; } @@ -354,15 +357,20 @@ if (!read_error) { + /* our articles end with .\r\n, remove it */ + artsize-=3; + artbuf[artsize]=0; + art.olen=htonl(artsize); + yg->accepted++; - yg->art_bytes+=a_stat.st_size; + yg->art_bytes+=artsize; art.offset=MCPLEN; art.comp=0; #ifndef DONTWANTZLIB if(do_compress==1){ col2=co_len; - res=compress(cobuf, &col2, artbuf, a_stat.st_size); + res=compress(cobuf, &col2, artbuf, artsize); art.comp=1; if(res!=Z_OK) { output(debug,"Compress failed"); @@ -375,8 +383,6 @@ artbuf=(mcs->crypt_fun)(artbuf,0); */ - art.olen=htonl(a_stat.st_size); - /* Insert system id here into packet */ kl=strlen(key->id); memcpy(artbuf2+MCPLEN,key->id,kl); @@ -394,7 +400,7 @@ /* append the article to the header */ /* and sign it */ if(do_compress==0) { - res=sign_buffer(artbuf,(unsigned long)a_stat.st_size, + res=sign_buffer(artbuf,artsize, artbuf2+art.offset, &nsize,key); } #ifndef DONTWANTZLIB @@ -412,7 +418,12 @@ send_to(mcs,artbuf2,ab2len); yg->tot_bytes+=ab2len; - close(fd); + if (use_storageapi == 0) { +#ifdef HAVE_MMAP + munmap(artbuf,artsize+3); /* we substracted it above */ +#endif + close(fd); + } } gettimeofday(&tv2,NULL); @@ -425,7 +436,7 @@ (yg->proc_time / yg->received )); } #ifdef HAVE_MMAP - munmap(artbuf,a_stat.st_size); + munmap(artbuf,artsize+3); /* we substracted it above */ #endif } diff -urN --exclude-from exclude mcntp-1.2pre2/yawgmoth/yawgmoth.c mcntp-1.2pre2.worksforme/yawgmoth/yawgmoth.c --- mcntp-1.2pre2/yawgmoth/yawgmoth.c Tue Sep 25 11:08:55 2001 +++ mcntp-1.2pre2.worksforme/yawgmoth/yawgmoth.c Thu Dec 6 11:48:15 2001 @@ -129,18 +129,29 @@ } - if (debug==0) { /* detach from controlling tty */ - for (i=0;i<3;++i) - close(i); - open("/",O_RDONLY); - dup2(0,1); - dup2(0,2); - - i=open("/dev/tty",O_RDWR); - if (i>=0) { - ioctl(i,TIOCNOTTY,0); - close(i); - } + if (debug==0) { + switch(fork()) { + case -1: + perror("Can't fork()"); + exit(1); + break; + case 0: /* child */ + for (i=0;i<1024;++i) + close(i); + open("/dev/null",O_RDONLY); + dup2(0,1); + dup2(0,2); + /* detach from controlling tty */ + i=open("/dev/tty",O_RDWR); + if (i>=0) { + ioctl(i,TIOCNOTTY,0); + close(i); + } + break; + default: /* parent */ + exit(0); + break; + } } /* open syslog */ #ifndef NeXT @@ -201,9 +212,6 @@ yg=NULL; - tv.tv_usec=0; - tv.tv_sec=MINUTE; - maxfd=rcs->fd; signal(SIGINT,sig_hdl); @@ -215,6 +223,8 @@ while(should_quit==0) { FD_SET(serv,&rmask); merke=rmask; + tv.tv_usec=0; + tv.tv_sec=MINUTE; res=select(maxfd+1,(fd_set*)&rmask,NULL,NULL,&tv); if(res<0) { perror("select: "); |