18void h(
char *
home,
char *queue,
int uid,
int gid,
int mode)
20 if (mkdir(
home,0700) == -1)
22 logmsg(
WHO,111,FATAL,B(
"unable to mkdir: ",
home));
24 logmsg(
WHO,111,FATAL,B(
"unable to chown: ",
home));
25 if (chmod(
home,mode) == -1)
26 logmsg(
WHO,111,FATAL,B(
"unable to chmod: ",
home));
28 if (mkdir(queue,0700) == -1) {
30 logmsg(
WHO,111,FATAL,B(
"unable to mkdir: ",queue));
32 if (chown(queue,
uid,gid) == -1)
33 logmsg(
WHO,111,FATAL,B(
"unable to chown: ",queue));
34 if (chmod(queue,mode) == -1)
35 logmsg(
WHO,111,FATAL,B(
"unable to chmod: ",queue));
39void d(
char *
home,
char *subdir,
int uid,
int gid,
int mode)
41 if (chdir(
home) == -1)
42 logmsg(
WHO,110,FATAL,B(
"unable to switch to: ",
home));
43 if (mkdir(subdir,0700) == -1)
45 logmsg(
WHO,111,FATAL,B(
"unable to mkdir: ",
home,
"/",subdir));
46 if (chown(subdir,
uid,gid) == -1)
47 logmsg(
WHO,111,FATAL,B(
"unable to chown: ",
home,
"/",subdir));
48 if (chmod(subdir,mode) == -1)
49 logmsg(
WHO,111,FATAL,B(
"unable to chmod: ",
home,
"/",subdir));
52void p(
char *queue,
char *fifo,
int uid,
int gid,
int mode)
54 if (chdir(queue) == -1)
55 logmsg(
WHO,110,FATAL,B(
"unable to switch to: ",queue,
"/queue"));
58 logmsg(
WHO,111,FATAL,B(
"unable to mkfifo: ",queue,
"/queue/",fifo));
59 if (chown(fifo,
uid,gid) == -1)
60 logmsg(
WHO,111,FATAL,B(
"unable to chown: ",queue,
"/queue/",fifo));
61 if (chmod(fifo,mode) == -1)
62 logmsg(
WHO,111,FATAL,B(
"unable to chmod: ",queue,
"/queue/",fifo));
76 logmsg(
WHO,110,FATAL,
"unable to switch back to source directory: ");
80 logmsg(
WHO,111,FATAL,B(
"unable to read: ",
file));
83 if (chdir(
home) == -1)
84 logmsg(
WHO,110,FATAL,B(
"unable to switch to: ",
home));
85 if (chdir(subdir) == -1)
86 logmsg(
WHO,110,FATAL,B(
"unable to switch to: ",
home,
"/",subdir));
90 logmsg(
WHO,111,FATAL,B(
"unable to write .../",subdir,
"/",
file));
93 switch (buffer_copy(&
bo,&
bi)) {
95 logmsg(
WHO,111,FATAL,B(
"unable to read: ",
file));
97 logmsg(
WHO,111,FATAL,B(
"unable to write .../",subdir,
"/",
file));
101 if (buffer_flush(&
bo) == -1)
102 logmsg(
WHO,111,FATAL,B(
"unable to write .../",subdir,
"/",
file));
103 if (fsync(
fdout) == -1)
104 logmsg(
WHO,111,FATAL,B(
"unable to write .../",subdir,
"/",
file));
105 if (close(
fdout) == -1)
106 logmsg(
WHO,111,FATAL,B(
"unable to write .../",subdir,
"/",
file));
109 logmsg(
WHO,111,FATAL,B(
"unable to chown .../",subdir,
"/",
file));
110 if (chmod(
file,mode) == -1)
111 logmsg(
WHO,111,FATAL,B(
"unable to chmod .../",subdir,
"/",
file));
118 if (chdir(
home) == -1)
119 logmsg(
WHO,110,FATAL,B(
"unable to switch to: ",
home));
123 logmsg(
WHO,111,FATAL,B(
"unable to write: ",
home,
"/",
file));
127 if (buffer_put(&
bo,
"",1) == -1)
128 logmsg(
WHO,111,FATAL,B(
"unable to write: ",
home,
"/",
file));
130 if (buffer_flush(&
bo) == -1)
131 logmsg(
WHO,111,FATAL,B(
"unable to write: ",
home,
"/",
file));
132 if (fsync(
fdout) == -1)
133 logmsg(
WHO,111,FATAL,B(
"unable to write: ",
home,
"/",
file));
134 if (close(
fdout) == -1)
135 logmsg(
WHO,111,FATAL,B(
"unable to write: ",
home,
"/",
file));
138 logmsg(
WHO,111,FATAL,B(
"unable to chown: ",
home,
"/",
file));
139 if (chmod(
file,mode) == -1)
140 logmsg(
WHO,111,FATAL,B(
"unable to chmod: ",
home,
"/",
file));
143int main(
int argc,
char *
const argv[])
147 logmsg(
WHO,110,FATAL,
"unable to open current directory: ");
150 if (argc == 2 && !str_diffn(argv[1],
"qmq",3))
qmq_hier();
151 if (argc == 2 && !str_diffn(argv[1],
"ldap",4))
ldap_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)