12 #define FATAL "install: fatal: "
16 void h(home
,uid
,gid
,mode
)
22 if (mkdir(home
,0700) == -1)
23 if (errno
!= error_exist
)
24 strerr_die4sys(111,FATAL
,"unable to mkdir ",home
,": ");
25 if (chown(home
,uid
,gid
) == -1)
26 strerr_die4sys(111,FATAL
,"unable to chown ",home
,": ");
27 if (chmod(home
,mode
) == -1)
28 strerr_die4sys(111,FATAL
,"unable to chmod ",home
,": ");
31 void d(home
,subdir
,uid
,gid
,mode
)
38 if (chdir(home
) == -1)
39 strerr_die4sys(111,FATAL
,"unable to switch to ",home
,": ");
40 if (mkdir(subdir
,0700) == -1)
41 if (errno
!= error_exist
)
42 strerr_die6sys(111,FATAL
,"unable to mkdir ",home
,"/",subdir
,": ");
43 if (chown(subdir
,uid
,gid
) == -1)
44 strerr_die6sys(111,FATAL
,"unable to chown ",home
,"/",subdir
,": ");
45 if (chmod(subdir
,mode
) == -1)
46 strerr_die6sys(111,FATAL
,"unable to chmod ",home
,"/",subdir
,": ");
49 char inbuf
[BUFFER_INSIZE
];
50 char outbuf
[BUFFER_OUTSIZE
];
54 void c(home
,subdir
,file
,uid
,gid
,mode
)
65 if (fchdir(fdsourcedir
) == -1)
66 strerr_die2sys(111,FATAL
,"unable to switch back to source directory: ");
68 fdin
= open_read(file
);
70 strerr_die4sys(111,FATAL
,"unable to read ",file
,": ");
71 buffer_init(&ssin
,buffer_unixread
,fdin
,inbuf
,sizeof inbuf
);
73 if (chdir(home
) == -1)
74 strerr_die4sys(111,FATAL
,"unable to switch to ",home
,": ");
75 if (chdir(subdir
) == -1)
76 strerr_die6sys(111,FATAL
,"unable to switch to ",home
,"/",subdir
,": ");
78 fdout
= open_trunc(file
);
80 strerr_die6sys(111,FATAL
,"unable to write .../",subdir
,"/",file
,": ");
81 buffer_init(&ssout
,buffer_unixwrite
,fdout
,outbuf
,sizeof outbuf
);
83 switch(buffer_copy(&ssout
,&ssin
)) {
85 strerr_die4sys(111,FATAL
,"unable to read ",file
,": ");
87 strerr_die6sys(111,FATAL
,"unable to write .../",subdir
,"/",file
,": ");
91 if (buffer_flush(&ssout
) == -1)
92 strerr_die6sys(111,FATAL
,"unable to write .../",subdir
,"/",file
,": ");
93 if (fsync(fdout
) == -1)
94 strerr_die6sys(111,FATAL
,"unable to write .../",subdir
,"/",file
,": ");
95 if (close(fdout
) == -1) /* NFS silliness */
96 strerr_die6sys(111,FATAL
,"unable to write .../",subdir
,"/",file
,": ");
98 if (chown(file
,uid
,gid
) == -1)
99 strerr_die6sys(111,FATAL
,"unable to chown .../",subdir
,"/",file
,": ");
100 if (chmod(file
,mode
) == -1)
101 strerr_die6sys(111,FATAL
,"unable to chmod .../",subdir
,"/",file
,": ");
104 void z(home
,subdir
,file
,len
,uid
,gid
,mode
)
115 if (chdir(home
) == -1)
116 strerr_die4sys(111,FATAL
,"unable to switch to ",home
,": ");
117 if (chdir(subdir
) == -1)
118 strerr_die6sys(111,FATAL
,"unable to switch to ",home
,"/",subdir
,": ");
120 fdout
= open_trunc(file
);
122 strerr_die6sys(111,FATAL
,"unable to write .../",subdir
,"/",file
,": ");
123 buffer_init(&ssout
,buffer_unixwrite
,fdout
,outbuf
,sizeof outbuf
);
126 if (buffer_put(&ssout
,"",1) == -1)
127 strerr_die6sys(111,FATAL
,"unable to write .../",subdir
,"/",file
,": ");
129 if (buffer_flush(&ssout
) == -1)
130 strerr_die6sys(111,FATAL
,"unable to write .../",subdir
,"/",file
,": ");
131 if (fsync(fdout
) == -1)
132 strerr_die6sys(111,FATAL
,"unable to write .../",subdir
,"/",file
,": ");
133 if (close(fdout
) == -1) /* NFS silliness */
134 strerr_die6sys(111,FATAL
,"unable to write .../",subdir
,"/",file
,": ");
136 if (chown(file
,uid
,gid
) == -1)
137 strerr_die6sys(111,FATAL
,"unable to chown .../",subdir
,"/",file
,": ");
138 if (chmod(file
,mode
) == -1)
139 strerr_die6sys(111,FATAL
,"unable to chmod .../",subdir
,"/",file
,": ");
144 fdsourcedir
= open_read(".");
145 if (fdsourcedir
== -1)
146 strerr_die2sys(111,FATAL
,"unable to open current directory: ");