17void h(
char *home,
int uid,
int gid,
int mode)
19 if (mkdir(home,0700) == -1)
20 if (
errno != error_exist)
21 logmsg(
WHO,111,FATAL,B(
"unable to mkdir: ",home));
22 if (chown(home,uid,gid) == -1)
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));
28void d(
char *home,
char *subdir,
int uid,
int gid,
int mode)
30 if (chdir(home) == -1)
31 logmsg(
WHO,111,FATAL,B(
"unable to switch to: ",home));
32 if (mkdir(subdir,0700) == -1)
33 if (
errno != error_exist)
34 logmsg(
WHO,111,FATAL,B(
"unable to mkdir: ",home,
"/",subdir));
35 if (chown(subdir,uid,gid) == -1)
36 logmsg(
WHO,111,FATAL,B(
"unable to chown: ",home,
"/",subdir));
37 if (chmod(subdir,mode) == -1)
38 logmsg(
WHO,111,FATAL,B(
"unable to chmod ",home,
"/",subdir));
46void c(
char *home,
char *subdir,
char *file,
int uid,
int gid,
int mode)
52 logmsg(
WHO,111,FATAL,
"unable to switch back to source directory: ");
54 fdin = open_read(file);
56 logmsg(
WHO,111,FATAL,B(
"unable to read: ",file));
59 if (chdir(home) == -1)
60 logmsg(
WHO,111,FATAL,B(
"unable to switch to: ",home));
61 if (chdir(subdir) == -1)
62 logmsg(
WHO,111,FATAL,B(
"unable to switch to: ",home,
"/",subdir));
64 fdout = open_trunc(file);
66 logmsg(
WHO,111,FATAL,B(
"unable to write: .../",subdir,
"/",file));
69 switch(buffer_copy(&
bo,&
bi)) {
71 logmsg(
WHO,111,FATAL,B(
"unable to read: ",file));
73 logmsg(
WHO,111,FATAL,B(
"unable to write: .../",subdir,
"/",file));
77 if (buffer_flush(&
bo) == -1)
78 logmsg(
WHO,111,FATAL,B(
"unable to write: .../",subdir,
"/",file));
79 if (fsync(fdout) == -1)
80 logmsg(
WHO,111,FATAL,B(
"unable to write: .../",subdir,
"/",file));
81 if (close(fdout) == -1)
82 logmsg(
WHO,111,FATAL,B(
"unable to write: .../",subdir,
"/",file));
84 if (chown(file,uid,gid) == -1)
85 logmsg(
WHO,111,FATAL,B(
"unable to chown: .../",subdir,
"/",file));
86 if (chmod(file,mode) == -1)
87 logmsg(
WHO,111,FATAL,B(
"unable to chmod: .../",subdir,
"/",file));
90void z(
char *home,
char *subdir,
char *file,
int len,
int uid,
int gid,
int mode)
94 if (chdir(home) == -1)
95 logmsg(
WHO,111,FATAL,B(
"unable to switch to: ",home));
96 if (chdir(subdir) == -1)
97 logmsg(
WHO,111,FATAL,B(
"unable to switch to: ",home,
"/",subdir));
99 fdout = open_trunc(file);
101 logmsg(
WHO,111,FATAL,B(
"unable to write: .../",subdir,
"/",file));
105 if (buffer_put(&
bo,
"",1) == -1)
106 logmsg(
WHO,111,FATAL,B(
"unable to write: .../",subdir,
"/",file));
108 if (buffer_flush(&
bo) == -1)
109 logmsg(
WHO,111,FATAL,B(
"unable to write: .../",subdir,
"/",file));
110 if (fsync(fdout) == -1)
111 logmsg(
WHO,111,FATAL,B(
"unable to write: .../",subdir,
"/",file));
112 if (close(fdout) == -1)
113 logmsg(
WHO,111,FATAL,B(
"unable to write: .../",subdir,
"/",file));
115 if (chown(file,uid,gid) == -1)
116 logmsg(
WHO,111,FATAL,B(
"unable to chow: .../",subdir,
"/",file));
117 if (chmod(file,mode) == -1)
118 logmsg(
WHO,111,FATAL,B(
"unable to chmod .../",subdir,
"/",file));
125 logmsg(
WHO,111,FATAL,
"unable to open current directory: ");
void d(char *home, char *subdir, int uid, int gid, int mode)
void c(char *home, char *subdir, char *file, int uid, int gid, int mode)
char inbuf[BUFFER_INSIZE]
void z(char *home, char *subdir, char *file, int len, int uid, int gid, int mode)
char outbuf[BUFFER_OUTSIZE]