#ifndef LOG_OPER_H
#define LOG_OPER_H
-void log_oper(const char *logfilename, const char *str);
+int log_oper(const char *logfilename, const char *str);
#endif /* LOG_OPER_H */
* digest */
#define DIGESTMIMETYPE "digest" /* Which sub-type of multipart to use when
* sending digest mails */
+#define OPLOGFNAME "mlmmj.operation.log" /* logfile to log operations */
struct strlist {
int count;
## Process this file with automake to produce Makefile.in
-
+textlibdir = $(pkgdatadir)/text.skel
dist_textlib_DATA = access bounce-probe listhelp moderation notifysub \
notifysub-digest notifysub-nomail notifyunsub notifyunsub-digest \
notifyunsub-nomail notintocc sub-confirm sub-confirm-digest \
statctrl.c ctrlvalue.c
mlmmj_recieve_SOURCES = mlmmj-recieve.c writen.c random-int.c strgen.c \
- print-version.c log_error.c dumpfd2fd.c memory.c
+ print-version.c log_error.c dumpfd2fd.c memory.c \
+ log_oper.c mylocking.c
mlmmj_process_SOURCES = mlmmj-process.c writen.c find_email_adr.c \
incindexfile.c itoa.c getlistaddr.c chomp.c \
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <string.h>
#include "mlmmj.h"
#include "log_error.h"
#include "log_oper.h"
+#include "strgen.h"
+#include "mylocking.h"
+#include "wrappers.h"
+#include "memory.h"
int log_oper(const char *logfilename, const char *str)
{
+ int fd;
char ct[26], *logstr;
struct stat st;
time_t t;
stat(old, &st);
t = time(NULL);
- if(t - st.st_mtime > age)
+ if(t - st.st_mtime > age) {
if(rename(old, new) < 0)
ret = 0;
else
ret = 1;
+ }
myunlock(fd);
close(fd);
#include "strgen.h"
#include "log_error.h"
#include "memory.h"
+#include "log_oper.h"
extern char *optarg;
{
char *infilename = NULL, *listdir = NULL;
char *randomstr = random_str();
- char *mlmmjprocess, *bindir;
+ char *mlmmjprocess, *bindir, *logstr;
int fd, opt, noprocess = 0, nofork = 0;
struct stat st;
uid_t uid;
fsync(fd);
-#if 0
- log_error(LOG_ARGS, "mlmmj-recieve: wrote %s\n", infilename);
-#endif
+ logstr = concatstr(2, "mlmmj-recieve: wrote ", infilename);
+ log_oper(OPLOGFNAME, logstr);
+ myfree(logstr);
close(fd);
if(noprocess) {
-/* Copyright (C) 2002, 2003 Mads Martin Joergensen <mmj at mmj.dk>
+/* Copyright (C) 2002, 2003, 2005 Mads Martin Joergensen <mmj at mmj.dk>
*
* $Id$
*
#include <unistd.h>
#include <fcntl.h>
+#include <errno.h>
+
#include "mylocking.h"
int myexcllock(int fd)
locktype.l_len = 0;
do {
mylock = fcntl(fd, F_SETLKW, &locktype);
- while(mylock < 0 && errno == EINTR);
+ } while(mylock < 0 && errno == EINTR);
return mylock;
}
locktype.l_type = F_UNLCK;
do {
myunlock = fcntl(fd, F_SETLKW, &locktype);
- while(myunlock < 0 && errno == EINTR)
+ } while(myunlock < 0 && errno == EINTR);
return myunlock;
}