17void h(
char *
home,
char *queue,
int uid,
int gid,
int mode)
19 if (mkdir(
home,0700) == -1)
21 logmsg(
WHO,111,FATAL,B(
"unable to mkdir: ",
home));
23 logmsg(
WHO,111,FATAL,B(
"unable to chown: ",
home));
24 if (chmod(
home,mode) == -1)
25 logmsg(
WHO,111,FATAL,B(
"unable to chmod: ",
home));
27 if (mkdir(queue,0700) == -1) {
29 logmsg(
WHO,111,FATAL,B(
"unable to mkdir: ",queue));
31 if (chown(queue,
uid,gid) == -1)
32 logmsg(
WHO,111,FATAL,B(
"unable to chown: ",queue));
33 if (chmod(queue,mode) == -1)
34 logmsg(
WHO,111,FATAL,B(
"unable to chmod: ",queue));
38void d(
char *
home,
char *subdir,
int uid,
int gid,
int mode)
40 if (chdir(
home) == -1)
41 logmsg(
WHO,110,FATAL,B(
"unable to switch to: ",
home));
42 if (mkdir(subdir,0700) == -1)
44 logmsg(
WHO,111,FATAL,B(
"unable to mkdir: ",
home,
"/",subdir));
45 if (chown(subdir,
uid,gid) == -1)
46 logmsg(
WHO,111,FATAL,B(
"unable to chown: ",
home,
"/",subdir));
47 if (chmod(subdir,mode) == -1)
48 logmsg(
WHO,111,FATAL,B(
"unable to chmod: ",
home,
"/",subdir));
51void p(
char *queue,
char *fifo,
int uid,
int gid,
int mode)
53 if (chdir(queue) == -1)
54 logmsg(
WHO,110,FATAL,B(
"unable to switch to: ",queue,
"/queue"));
57 logmsg(
WHO,111,FATAL,B(
"unable to mkfifo: ",queue,
"/queue/",fifo));
58 if (chown(fifo,
uid,gid) == -1)
59 logmsg(
WHO,111,FATAL,B(
"unable to chown: ",queue,
"/queue/",fifo));
60 if (chmod(fifo,mode) == -1)
61 logmsg(
WHO,111,FATAL,B(
"unable to chmod: ",queue,
"/queue/",fifo));
75 logmsg(
WHO,110,FATAL,
"unable to switch back to source directory: ");
79 logmsg(
WHO,111,FATAL,B(
"unable to read: ",
file));
82 if (chdir(
home) == -1)
83 logmsg(
WHO,110,FATAL,B(
"unable to switch to: ",
home));
84 if (chdir(subdir) == -1)
85 logmsg(
WHO,110,FATAL,B(
"unable to switch to: ",
home,
"/",subdir));
89 logmsg(
WHO,111,FATAL,B(
"unable to write .../",subdir,
"/",
file));
92 switch (buffer_copy(&
bo,&
bi)) {
94 logmsg(
WHO,111,FATAL,B(
"unable to read: ",
file));
96 logmsg(
WHO,111,FATAL,B(
"unable to write .../",subdir,
"/",
file));
100 if (buffer_flush(&
bo) == -1)
101 logmsg(
WHO,111,FATAL,B(
"unable to write .../",subdir,
"/",
file));
102 if (fsync(
fdout) == -1)
103 logmsg(
WHO,111,FATAL,B(
"unable to write .../",subdir,
"/",
file));
104 if (close(
fdout) == -1)
105 logmsg(
WHO,111,FATAL,B(
"unable to write .../",subdir,
"/",
file));
108 logmsg(
WHO,111,FATAL,B(
"unable to chown .../",subdir,
"/",
file));
109 if (chmod(
file,mode) == -1)
110 logmsg(
WHO,111,FATAL,B(
"unable to chmod .../",subdir,
"/",
file));
117 if (chdir(
home) == -1)
118 logmsg(
WHO,110,FATAL,B(
"unable to switch to: ",
home));
122 logmsg(
WHO,111,FATAL,B(
"unable to write: ",
home,
"/",
file));
126 if (buffer_put(&
bo,
"",1) == -1)
127 logmsg(
WHO,111,FATAL,B(
"unable to write: ",
home,
"/",
file));
129 if (buffer_flush(&
bo) == -1)
130 logmsg(
WHO,111,FATAL,B(
"unable to write: ",
home,
"/",
file));
131 if (fsync(
fdout) == -1)
132 logmsg(
WHO,111,FATAL,B(
"unable to write: ",
home,
"/",
file));
133 if (close(
fdout) == -1)
134 logmsg(
WHO,111,FATAL,B(
"unable to write: ",
home,
"/",
file));
137 logmsg(
WHO,111,FATAL,B(
"unable to chown: ",
home,
"/",
file));
138 if (chmod(
file,mode) == -1)
139 logmsg(
WHO,111,FATAL,B(
"unable to chmod: ",
home,
"/",
file));
142int main(
int argc,
char *
const argv[])
146 logmsg(
WHO,110,FATAL,
"unable to open current directory: ");
149 if (argc == 2 && !str_diffn(argv[1],
"qmq",3))
qmq_hier();
int fifo_make(char *fn, int mode)
void c(char *, char *, char *, int, int, int)
char inbuf[BUFFER_INSIZE]
void p(char *queue, char *fifo, int uid, int gid, int mode)
void z(char *home, char *file, int len, int uid, int gid, int mode)
char outbuf[BUFFER_OUTSIZE]
void h(char *home, char *queue, int uid, int gid, int mode)