Debian Codegraph @

misc/contrib/areafix-0.5.07/areaqueue.c

raw
1 /*
2 A little program that places incoming letters for areafix to a queue.
3 It's only parameter is the full name of the directory where the queue
4 is to reside.
5 The program's executable must be suid and sgid to "fnet" or a similar
6 user in your system to avoid "Permission denied"s.
7 Your MTA's alias 'areafix' must point to the program.
8 Example for sendmail:
9
10 areafix: |"/usr/lib/ifmail/areafix/areaqueue /var/spool/ifmail/aqueue"
11 */
12
13 #include <unistd.h>
14 #include <stdio.h>
15 #include <sys/types.h>
16 #include <sys/stat.h>
17 #include <time.h>
18
19 int main(int argc,char **argv)
20 {
21 int c;
22 FILE *f;
23 char s1[1024],s2[1024],name[32];
24
25 if (argc<2) return 2;
26 sprintf(name,"%d%d",getpid(),time(NULL));
27 sprintf(s1,"%s/%s",argv[1],"tmp");
28 mkdir(s1,0700);
29 sprintf(s1,"%s/%s",s1,name);
30 sprintf(s2,"%s/%s",argv[1],name);
31 umask(007);
32 if ((f=fopen(s1,"w"))==NULL) return 2;
33 while ((c=getchar())!=EOF)
34 putc(c,f);
35 fclose(f);
36 if (rename(s1,s2)==-1) return 2;
37 return 0;
38 }
39