Send inn-committers mailing list submissions to inn-committers@lists.isc.org
To subscribe or unsubscribe via the World Wide Web, visit https://lists.isc.org/mailman/listinfo/inn-committers or, via email, send a message with subject or body 'help' to inn-committers-requ...@lists.isc.org You can reach the person managing the list at inn-committers-ow...@lists.isc.org When replying, please edit your Subject line so it is more specific than "Re: Contents of inn-committers digest..." Today's Topics: 1. INN commit: trunk/contrib (Makefile README auth_pass.c) (INN Commit) 2. INN commit: trunk/contrib (newsresp.c) (INN Commit) 3. INN commit: trunk/contrib (reset-cnfs.c) (INN Commit) 4. INN commit: trunk/contrib (expirectl.c) (INN Commit) 5. INN commit: trunk/contrib (Makefile respool.c) (INN Commit) 6. INN commit: trunk (contrib contrib/mlockfile.c contrib/pullart.c) (INN Commit) ---------------------------------------------------------------------- Message: 1 Date: Sun, 21 Sep 2014 05:17:00 -0700 (PDT) From: INN Commit <r...@isc.org> To: inn-committ...@isc.org Subject: INN commit: trunk/contrib (Makefile README auth_pass.c) Message-ID: <20140921121701.07a3267...@hope.eyrie.org> Date: Sunday, September 21, 2014 @ 05:17:00 Author: iulius Revision: 9701 Add compilation rules for contrib/auth_pass.c Use the right socklen_t type, and add crypt.h header if available. Modified: trunk/contrib/Makefile trunk/contrib/README trunk/contrib/auth_pass.c -------------+ Makefile | 4 +++- README | 5 +++++ auth_pass.c | 7 ++++++- 3 files changed, 14 insertions(+), 2 deletions(-) Modified: Makefile =================================================================== --- Makefile 2014-09-21 09:15:25 UTC (rev 9700) +++ Makefile 2014-09-21 12:17:00 UTC (rev 9701) @@ -9,7 +9,8 @@ top = .. CFLAGS = $(GCFLAGS) -ALL = archivegz backlogstat cleannewsgroups delayer expirectl \ +ALL = archivegz auth_pass backlogstat cleannewsgroups \ + delayer expirectl \ findreadgroups makeexpctl makestorconf mlockfile newsresp \ pullart reset-cnfs respool stathist thdexpire \ tunefeed @@ -35,6 +36,7 @@ STORELIBS = $(LIBSTORAGE) $(LIBINN) $(STORAGE_LIBS) $(LIBS) +auth_pass: auth_pass.o ; $(LINK) auth_pass.o $(LIBINN) $(CRYPT_LIBS) expirectl: expirectl.o ; $(LINK) expirectl.o mlockfile: mlockfile.o ; $(LINK) mlockfile.o newsresp: newsresp.o ; $(LINK) newsresp.o $(LIBS) Modified: README =================================================================== --- README 2014-09-21 09:15:25 UTC (rev 9700) +++ README 2014-09-21 12:17:00 UTC (rev 9701) @@ -40,6 +40,11 @@ database. Could also be easily modified to check against any other type of database that Perl's DBI module can talk to. +auth_pass + + A sample authorization program for use with the (deprecated) AUTHINFO + GENERIC command in nnrpd. + backlogstat Prints informations about the current state of innfeed's backlog, if Modified: auth_pass.c =================================================================== --- auth_pass.c 2014-09-21 09:15:25 UTC (rev 9700) +++ auth_pass.c 2014-09-21 12:17:00 UTC (rev 9701) @@ -39,7 +39,12 @@ #include <netdb.h> #include <pwd.h> +#if HAVE_CRYPT_H +# include <crypt.h> +#endif + +int main(int argc, char** argv) /*+ * Abstract: @@ -64,7 +69,7 @@ */ { struct hostent * hp; - int length; + socklen_t length; char password[256]; char peername[1024]; struct passwd * pwd; ------------------------------ Message: 2 Date: Sun, 21 Sep 2014 05:20:43 -0700 (PDT) From: INN Commit <r...@isc.org> To: inn-committ...@isc.org Subject: INN commit: trunk/contrib (newsresp.c) Message-ID: <20140921122043.8c26467...@hope.eyrie.org> Date: Sunday, September 21, 2014 @ 05:20:43 Author: iulius Revision: 9702 Fix build of contrib/newsresp.c Add correct include header files and prototypes. Remove useless variables. punt() now returns a bool instead of an int. ierror() now prints its second argument to stdout. Modified: trunk/contrib/newsresp.c ------------+ newsresp.c | 110 +++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 62 insertions(+), 48 deletions(-) Modified: newsresp.c =================================================================== --- newsresp.c 2014-09-21 12:17:00 UTC (rev 9701) +++ newsresp.c 2014-09-21 12:20:43 UTC (rev 9702) @@ -64,26 +64,35 @@ * 0.1 0.0 <<< 205 . */ -#include <stdio.h> -#include <sys/types.h> -#include <sys/time.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <netdb.h> +#include "clibrary.h" +#include "portable/socket.h" +#include "portable/stdbool.h" + #include <errno.h> +#ifdef HAVE_SYS_TIME_H +# include <sys/time.h> +#endif #define NNTPPORT 119 + +void error(const char *); +void fatal(const char *); +void ierror(const char *, const char *); +void ifatal(const char *, const char *); +unsigned int do_time(unsigned int); +void ptime(void); +void massagebuff(int, char *); +bool punt(int); + struct sockaddr_in sock_in; int sock; char buf[1024]; -main(argc,argv) -int argc; -char *argv[]; +int +main(int argc, char *argv[]) { int errflg = 0, c; - extern char *optarg; - extern int optind; + bool status = true; struct hostent *host; unsigned long temp; unsigned numart = 1; @@ -126,40 +135,46 @@ sock_in.sin_port = htons(NNTPPORT); printf("---------------------------------\n%s is %s port %d\n", *whoP,inet_ntoa(sock_in.sin_addr),ntohs(sock_in.sin_port)); - punt(numart); + status = punt(numart); close(sock); } + if (status) { + exit(0); + } else { + exit(1); + } } -error(what) -char *what; +void +error(const char *what) { - ptime(); fflush(stdout); + ptime(); + fflush(stdout); perror(what); } -fatal(what) -char *what; +void +fatal(const char *what) { error(what); exit(2); } -ierror(how,what) -char *how, *what; +void +ierror(const char *how, const char *what) { - printf("Expected %s, bailing out.\n",how); + printf("Expected %s, received %s; bailing out.\n", how, what); } -ifatal(how,what) -char *how, *what; +void +ifatal(const char *how, const char *what) { - ierror(how,what); + ierror(how, what); exit(1); } -unsigned do_time(start) -unsigned start; +unsigned int +do_time(unsigned int start) { struct timeval now; @@ -167,10 +182,10 @@ return ( now.tv_sec*1000 + now.tv_usec/1000 - start ); } +unsigned int start, elapsed, diff; -unsigned start, elapsed, diff; - -ptime() +void +ptime(void) { diff = elapsed; elapsed = do_time(start); @@ -178,9 +193,8 @@ printf("%5.1f %5.1f ",((float)elapsed)/1000.0,((float)diff)/1000.0); } -massagebuff(bread,buf) -int bread; -char *buf; +void +massagebuff(int bread, char *buf) { char *p; @@ -197,8 +211,8 @@ } } -punt(numart) -int numart; +bool +punt(int numart) { static char ihave[32], dot[] = ".\r\n", @@ -215,42 +229,42 @@ printf("Connecting ...\n"); if ( connect(sock,(struct sockaddr*)&sock_in,sizeof(sock_in)) < 0 ) { error("connect"); - return(-1); + return false; } ptime(); printf("OK, waiting for prompt\n"); if ( (bread=read(sock,buf,sizeof(buf))) < 0 ) { error("read socket"); - return(-1); + return false; } massagebuff(bread,buf); ptime(); printf("<<< %s",buf); if ( strncmp(buf,"200",3) != 0 && strncmp(buf,"201",3) != 0 ) { ierror("200 or 201",buf); - return(-1); + return false; } do { snprintf(ihave,sizeof(ihave),"ihave <%u@a>\r\n",start+numart); ptime(); printf(">>> %s",ihave); - if ( write(sock,ihave,strlen(ihave)) != strlen(ihave) ) { + if ( write(sock,ihave,strlen(ihave)) != (int) strlen(ihave) ) { error("write socket"); - return(-1); + return false; } if ( (bread=read(sock,buf,sizeof(buf))) < 0 ) { error("read socket"); - return(-1); + return false; } massagebuff(bread,buf); ptime(); printf("<<< %s",buf); if ( strncmp(buf,"335",3) != 0 && strncmp(buf,"435",3) != 0 ) { - ierror("335 or 435 ",buf); - return(-1); + ierror("335 or 435",buf); + return false; } if ( strncmp(buf,"335",3) == 0 ) { @@ -258,19 +272,19 @@ printf(">>> %s",dot); if ( write(sock,dot,sizeof(dot)-1) != sizeof(dot)-1 ) { error("write socket"); - return(-1); + return false; } if ( (bread=read(sock,buf,sizeof(buf))) < 0 ) { error("read socket"); - return(-1); + return false; } massagebuff(bread,buf); ptime(); printf("<<< %s",buf); if ( strncmp(buf,"437",3) != 0 && strncmp(buf,"235",3) != 0 ) { ierror("437 or 235",buf); - return(-1); + return false; } } } while ( --numart != 0 ); @@ -279,19 +293,19 @@ printf(">>> %s",quit); if ( write(sock,quit,sizeof(quit)-1) != sizeof(quit)-1 ) { error("write socket"); - return(-1); + return false; } if ( (bread=read(sock,buf,sizeof(buf))) < 0 ) { error("read socket"); - return(-1); + return false; } massagebuff(bread,buf); ptime(); printf("<<< %s",buf); if ( strncmp(buf,"205",3) != 0 ) { ierror("205",buf); - return(-1); + return false; } - return(0); + return true; } ------------------------------ Message: 3 Date: Sun, 21 Sep 2014 05:22:33 -0700 (PDT) From: INN Commit <r...@isc.org> To: inn-committ...@isc.org Subject: INN commit: trunk/contrib (reset-cnfs.c) Message-ID: <20140921122233.9184367...@hope.eyrie.org> Date: Sunday, September 21, 2014 @ 05:22:33 Author: iulius Revision: 9703 Fix build of contrib/reset-cnfs.c Add correct include header files. Use the right DO_LARGEFILES variable instead of LARGE_FILES. Reformat the code (remove tabulations). Properly exit with the right status code. Modified: trunk/contrib/reset-cnfs.c --------------+ reset-cnfs.c | 85 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 37 deletions(-) Modified: reset-cnfs.c =================================================================== --- reset-cnfs.c 2014-09-21 12:20:43 UTC (rev 9702) +++ reset-cnfs.c 2014-09-21 12:22:33 UTC (rev 9703) @@ -1,56 +1,67 @@ /* Quick and Dirty Hack to reset a CNFS buffer without having to DD the * Entire Thing from /dev/zero again. */ -#include <sys/types.h> -#include <sys/stat.h> +#include "config.h" +#include "clibrary.h" +#include "portable/stdbool.h" + #include <errno.h> #include <fcntl.h> +#include <sys/stat.h> -#include <stdio.h> -/* uncomment the below for LARGE_FILES support */ -/* #define LARGE_FILES */ - -int main(int argc, char *argv[]) +int +main(int argc, char *argv[]) { int fd; int i, j; char buf[512]; -#ifdef LARGE_FILES - struct stat64 st; -#else - struct stat st; +#ifdef DO_LARGEFILES + struct stat64 st; +#else + struct stat st; #endif int numwr; + bool status = true; bzero(buf, sizeof(buf)); for (i = 1; i < argc; i++) { -#ifdef LARGE_FILES - if ((fd = open(argv[i], O_LARGEFILE | O_RDWR, 0664)) < 0) -#else - if ((fd = open(argv[i], O_RDWR, 0664)) < 0) +#ifdef DO_LARGEFILES + if ((fd = open(argv[i], O_LARGEFILE | O_RDWR, 0664)) < 0) { +#else + if ((fd = open(argv[i], O_RDWR, 0664)) < 0) { #endif - fprintf(stderr, "Could not open file %s: %s\n", argv[i], strerror(errno)); - else { -#ifdef LARGE_FILES - if (fstat64(fd, &st) < 0) { -#else - if (fstat(fd, &st) < 0) { + fprintf(stderr, "Could not open file %s: %s\n", argv[i], strerror(errno)); + status = false; + } else { +#ifdef DO_LARGEFILES + if (fstat64(fd, &st) < 0) { +#else + if (fstat(fd, &st) < 0) { #endif - fprintf(stderr, "Could not stat file %s: %s\n", argv[i], strerror(errno)); - } else { - /* each bit in the bitfield is 512 bytes of data. Each byte - * has 8 bits, so calculate as 512 * 8 bytes of data, plus - * fuzz. buf has 512 bytes in it, therefore containing data for - * (512 * 8) * 512 bytes of data. */ - numwr = (st.st_size / (512*8) / sizeof(buf)) + 50; - printf("File %s: %u %u\n", argv[i], st.st_size, numwr); - for (j = 0; j < numwr; j++) { - if (!(j % 100)) - printf("\t%d/%d\n", j, numwr); - write(fd, buf, sizeof(buf)); - } - } - close(fd); - } + fprintf(stderr, "Could not stat file %s: %s\n", argv[i], strerror(errno)); + status = false; + } else { + /* Each bit in the bitfield is 512 bytes of data. Each byte + * has 8 bits, so calculate as 512 * 8 bytes of data, plus + * fuzz. buf has 512 bytes in it, therefore containing data + * for (512 * 8) * 512 bytes of data. */ + numwr = (st.st_size / (512*8) / sizeof(buf)) + 50; + printf("File %s: %lu %u\n", argv[i], st.st_size, numwr); + for (j = 0; j < numwr; j++) { + if (!(j % 100)) { + printf("\t%d/%d\n", j, numwr); + } + write(fd, buf, sizeof(buf)); + } + } + close(fd); + status = true; + } } + + if (status) { + exit(0); + } else { + exit(1); + } } ------------------------------ Message: 4 Date: Sun, 21 Sep 2014 05:24:38 -0700 (PDT) From: INN Commit <r...@isc.org> To: inn-committ...@isc.org Subject: INN commit: trunk/contrib (expirectl.c) Message-ID: <20140921122439.052fe67...@hope.eyrie.org> Date: Sunday, September 21, 2014 @ 05:24:38 Author: iulius Revision: 9704 Fix build of contrib/expirectl.c Add correct include header files, and fix a few warnings in printf() calls. Add portability code for statfs/statvfs support. Modified: trunk/contrib/expirectl.c -------------+ expirectl.c | 72 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 55 insertions(+), 17 deletions(-) Modified: expirectl.c =================================================================== --- expirectl.c 2014-09-21 12:22:33 UTC (rev 9703) +++ expirectl.c 2014-09-21 12:24:38 UTC (rev 9704) @@ -31,14 +31,52 @@ * will not really exercise the program for another 14 days or so :-). */ - -#include <sys/types.h> -#include <sys/mount.h> +#include "config.h" +#include "clibrary.h" #include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include <time.h> +/* Following portability code lifted from inndf.c */ +#if HAVE_STATVFS +# include <sys/statvfs.h> +# define df_stat(p, s) (statvfs((p), (s)) == 0) +# define df_declare(s) struct statvfs s +# define df_total(s) ((s).f_blocks) +# define df_avail(s) ((s).f_bavail) +# define df_scale(s) ((s).f_frsize == 0 ? (s).f_bsize : (s).f_frsize) +# define df_files(s) ((s).f_files) +# define df_favail(s) ((s).f_favail) +#elif HAVE_STATFS +# if HAVE_SYS_VFS_H +# include <sys/vfs.h> +# endif +# if HAVE_SYS_PARAM_H +# include <sys/param.h> +# endif +# if HAVE_SYS_MOUNT_H +# include <sys/mount.h> +# endif +# ifdef __ultrix__ +# define df_stat(p, s) (statfs((p), (s)) >= 1) +# define df_declare(s) struct fs_data s +# define df_total(s) ((s).fd_btot) +# define df_avail(s) ((s).fd_bfreen) +# define df_scale(s) 1024 +# define df_files(s) ((s).fd_gtot) +# define df_favail(s) ((s).fd_gfree) +# else +# define df_stat(p, s) (statfs((p), (s)) == 0) +# define df_declare(s) struct statfs s +# define df_total(s) ((s).f_blocks) +# define df_avail(s) ((s).f_bavail) +# define df_scale(s) ((s).f_bsize) +# define df_files(s) ((s).f_files) +# define df_favail(s) ((s).f_ffree) +# endif +#else +# error "Platform not supported. Neither statvfs nor statfs available." +#endif + #define EXPIRE_CTL_DIR "/home/news" #define NEWS_SPOOL "/home/news/spool/news/." @@ -49,7 +87,7 @@ int main(int ac, char **av) { - struct statfs sfs; + df_declare(sfs); long minFree = 100 * 1024 * 1024; long minIFree = 20 * 1024; long expireDays = 2; @@ -104,7 +142,7 @@ } } - if (statfs("/home/news/spool/news/.", &sfs) != 0) { + if (!df_stat("/home/news/spool/news/.", &sfs)) { fprintf(stderr, "expirectl: couldn't fsstat /home/news/spool/news/.\n"); exit(1); } @@ -139,8 +177,8 @@ if (verbose) { printf("spool: %4.2lfM / %3.2lfKinode free\n", - (double)sfs.f_fsize * (double)sfs.f_bavail / (1024.0 * 1024.0), - (double)sfs.f_ffree / 1024.0 + (double)df_scale(sfs) * (double)df_avail(sfs) / (1024.0 * 1024.0), + (double)df_favail(sfs) / 1024.0 ); printf("decrs: %4.2lfM / %3.2lfKinode\n", (double)(minFree) / (double)(1024*1024), @@ -160,8 +198,8 @@ double bytes; long inodes; - bytes = (double)sfs.f_fsize * (double)sfs.f_bavail; - inodes = sfs.f_ffree; + bytes = (double)df_scale(sfs) * (double)df_avail(sfs); + inodes = df_favail(sfs); if (bytes < (double)minFree || inodes < minIFree) { if (--expireDays <= 0) { @@ -170,7 +208,7 @@ } if (modified >= 0) modified = 1; - printf("decrement expiration to %d days\n", expireDays); + printf("decrement expiration to %ld days\n", expireDays); } else if (bytes >= (double)minFree * 2.0 && inodes >= minIFree * 2) { long dt = (long)(time(NULL) - expireIncTime); @@ -179,12 +217,12 @@ expireIncTime = time(NULL); if (modified >= 0) modified = 1; - printf("increment expiration to %d days\n", expireDays); + printf("increment expiration to %ld days\n", expireDays); } else { printf("will increment expiration later\n"); } } else if (verbose) { - printf("expiration unchanged: %d\n", expireDays); + printf("expiration unchanged: %ld\n", expireDays); } } @@ -223,7 +261,7 @@ v = 1; if (v < m) v = m; - sprintf(dptr, "%d", v); + sprintf(dptr, "%ld", v); dptr += strlen(dptr); ++sptr; } @@ -254,7 +292,7 @@ if ((fo = fopen(EXPIRE_DAYS, "w")) != NULL) { fprintf(fo, "time 0x%08lx\n", expireIncTime); - fprintf(fo, "days %d\n", expireDays); + fprintf(fo, "days %ld\n", expireDays); fclose(fo); } else { fprintf(stderr, "unable to create %s\n", EXPIRE_DAYS); ------------------------------ Message: 5 Date: Sun, 21 Sep 2014 05:29:55 -0700 (PDT) From: INN Commit <r...@isc.org> To: inn-committ...@isc.org Subject: INN commit: trunk/contrib (Makefile respool.c) Message-ID: <20140921122955.824d967...@hope.eyrie.org> Date: Sunday, September 21, 2014 @ 05:29:55 Author: iulius Revision: 9705 Fix build of contrib/respool.c Remove an unused variable. Add a link to libhistory. Modified: trunk/contrib/Makefile trunk/contrib/respool.c -----------+ Makefile | 2 +- respool.c | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) Modified: Makefile =================================================================== --- Makefile 2014-09-21 12:24:38 UTC (rev 9704) +++ Makefile 2014-09-21 12:29:55 UTC (rev 9705) @@ -34,7 +34,7 @@ LINK = $(LIBLD) $(LDFLAGS) -o $@ FIX = $(FIXSCRIPT) -STORELIBS = $(LIBSTORAGE) $(LIBINN) $(STORAGE_LIBS) $(LIBS) +STORELIBS = $(LIBSTORAGE) $(LIBHIST) $(LIBINN) $(STORAGE_LIBS) $(LIBS) auth_pass: auth_pass.o ; $(LINK) auth_pass.o $(LIBINN) $(CRYPT_LIBS) expirectl: expirectl.o ; $(LINK) expirectl.o Modified: respool.c =================================================================== --- respool.c 2014-09-21 12:24:38 UTC (rev 9704) +++ respool.c 2014-09-21 12:29:55 UTC (rev 9705) @@ -29,7 +29,6 @@ ARTHANDLE newart; TOKEN token, newtoken; char *arttmp; - time_t arrived; tokenptr = line; @@ -47,7 +46,6 @@ if ((art = SMretrieve(token, RETR_ALL)) == NULL) return; len = art->len; - arrived = art->arrived; arttmp = xmalloc(len); memcpy(arttmp, art->data, len); SMfreearticle(art); ------------------------------ Message: 6 Date: Sun, 21 Sep 2014 05:31:25 -0700 (PDT) From: INN Commit <r...@isc.org> To: inn-committ...@isc.org Subject: INN commit: trunk (contrib contrib/mlockfile.c contrib/pullart.c) Message-ID: <20140921123125.a673767...@hope.eyrie.org> Date: Sunday, September 21, 2014 @ 05:31:25 Author: iulius Revision: 9706 Fix a few warnings, and update svn:ignore for contrib Modified: trunk/contrib/ (properties) trunk/contrib/mlockfile.c trunk/contrib/pullart.c -------------+ mlockfile.c | 2 ++ pullart.c | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) Property changes on: trunk/contrib ___________________________________________________________________ Modified: svn:ignore - .libs archivegz backlogstat cleannewsgroups delayer findreadgroups makeexpctl makestorconf mlockfile newsresp pullart reset-cnfs respool stathist thdexpire tunefeed + .libs archivegz auth_pass backlogstat cleannewsgroups delayer expirectl findreadgroups makeexpctl makestorconf mlockfile newsresp pullart reset-cnfs respool stathist thdexpire tunefeed Modified: contrib/mlockfile.c =================================================================== --- contrib/mlockfile.c 2014-09-21 12:29:55 UTC (rev 9705) +++ contrib/mlockfile.c 2014-09-21 12:31:25 UTC (rev 9706) @@ -27,6 +27,8 @@ size_t length; }; +void inn_lock_files(struct mlock *); + char *progname; int flush = 0; Modified: contrib/pullart.c =================================================================== --- contrib/pullart.c 2014-09-21 12:29:55 UTC (rev 9705) +++ contrib/pullart.c 2014-09-21 12:31:25 UTC (rev 9706) @@ -17,9 +17,7 @@ */ #include "config.h" -#include <stdio.h> -#include <stdlib.h> -#include <string.h> +#include "clibrary.h" #define INFILE 1 #define FILEPREFIX 2 @@ -195,7 +193,7 @@ } - close (Infile); + fclose (Infile); return 0; } @@ -290,7 +288,7 @@ while (n--) fprintf (outfile, "%c", *buff++); - close (outfile); + fclose (outfile); /* Return number of files written */ return 1; ------------------------------ _______________________________________________ inn-committers mailing list inn-committers@lists.isc.org https://lists.isc.org/mailman/listinfo/inn-committers End of inn-committers Digest, Vol 67, Issue 14 **********************************************