diff -r -u s-news-0.1.10/config.h.in s-news/config.h.in --- s-news-0.1.10/config.h.in 2002-05-18 20:22:50.000000000 +0100 +++ s-news/config.h.in 2002-10-12 19:23:12.000000000 +0100 @@ -55,6 +55,9 @@ /* Define if you have the header file. */ #undef HAVE_MALLOC_H +/* Define if you have the header file. */ +#undef HAVE_SYS_FILE_H + /* Define if you have the header file. */ #undef HAVE_MEMORY_H diff -r -u s-news-0.1.10/configure s-news/configure --- s-news-0.1.10/configure 2002-05-18 20:25:00.000000000 +0100 +++ s-news/configure 2002-10-12 19:23:12.000000000 +0100 @@ -2370,7 +2370,7 @@ fi -for ac_header in fcntl.h limits.h malloc.h syslog.h unistd.h +for ac_header in fcntl.h limits.h malloc.h syslog.h unistd.h sys/file.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:2376: checking for $ac_header" >&5 diff -r -u s-news-0.1.10/configure.in s-news/configure.in --- s-news-0.1.10/configure.in 2002-05-18 20:22:46.000000000 +0100 +++ s-news/configure.in 2002-10-12 19:23:12.000000000 +0100 @@ -40,7 +40,7 @@ dnl Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(fcntl.h limits.h malloc.h syslog.h unistd.h) +AC_CHECK_HEADERS(fcntl.h limits.h malloc.h syslog.h unistd.h sys/file.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_TYPE_UID_T diff -r -u s-news-0.1.10/qnews.c s-news/qnews.c --- s-news-0.1.10/qnews.c 2002-05-18 20:21:42.000000000 +0100 +++ s-news/qnews.c 2002-10-12 19:23:55.000000000 +0100 @@ -2,6 +2,8 @@ * S-News version 0.1.9 - A Simple News Server * Copyright (C) 1998 Christopher John Purnell * cjp@lost.org.uk + * flock modification (c) 2002 Tony Houghton + * tony@realh.co.uk * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,7 +24,13 @@ #include "config.h" #endif +#include #include +#ifdef HAVE_SYS_FILE_H +#include +#endif +#include + #ifdef HAVE_UNISTD_H #include #endif @@ -79,15 +87,37 @@ if (match_group(ptr->value,line,end)) { FILE *fp; + #ifdef HAVE_SYS_FILE_H + int fd; + #endif sprintf(file,CONFDIR"/suck/%s/outgoing", - ptr->name); + ptr->name); - if (!(fp = fopen(file,"a"))) + #ifdef HAVE_SYS_FILE_H + if ((fd = open(file,O_WRONLY|O_APPEND|O_CREAT, + 0644)) == -1) { - perror(file); - return (1); + perror(file); + return (1); + } + if (flock(fd,LOCK_EX) == -1) + { + perror(file); + return (1); + } + if (!(fp = fdopen(fd,"a"))) + { + perror(file); + return (1); } + #else + if (!(fp = fopen(file,"a"))) + { + perror(file); + return (1); + } + #endif if (fputs(line,fp) < 0 || fputc('\n',fp) < 0) @@ -103,6 +133,9 @@ return (1); } + /* By commenting this break we can post to + * multiple servers instead of stopping after + * first match*/ break; } } @@ -204,7 +237,7 @@ return (0); break; case '[': - if (str>=end) + if (str=end || *str!=c)