290 |
*/ |
*/ |
291 |
int create_homedir(void) |
int create_homedir(void) |
292 |
{ |
{ |
293 |
char *hdname = ".imapfilter"; |
char *hdn = ".imapfilter"; |
294 |
|
|
295 |
if (home) |
if (home) |
296 |
if (chdir(home)) |
if (chdir(home)) |
297 |
error("imapfilter: could not change directory; %s\n", |
error("imapfilter: could not change directory; %s\n", |
298 |
strerror(errno)); |
strerror(errno)); |
299 |
|
|
300 |
create_dir(hdname, S_IRUSR | S_IWUSR | S_IXUSR); |
create_dir(hdn, S_IRUSR | S_IWUSR | S_IXUSR); |
301 |
|
|
302 |
return 0; |
return 0; |
303 |
} |
} |
304 |
|
|
350 |
{ |
{ |
351 |
int fd = 0; |
int fd = 0; |
352 |
|
|
353 |
if (!exists_file(fname)) |
if (!exists_file(fname)) { |
354 |
fd = creat(fname, mode); |
fd = open(fname, O_CREAT | O_WRONLY | O_TRUNC, mode); |
355 |
if (fd == -1) { |
if (fd == -1) { |
356 |
error("imapfilter: could not create file %s; %s\n", fname, |
error("imapfilter: could not create file %s; %s\n", fname, |
357 |
strerror(errno)); |
strerror(errno)); |
358 |
return ERROR_FILE_OPEN; |
return ERROR_FILE_OPEN; |
359 |
} |
} |
360 |
close(fd); |
close(fd); |
361 |
|
} |
362 |
|
|
363 |
return 0; |
return 0; |
364 |
} |
} |
431 |
} |
} |
432 |
#endif |
#endif |
433 |
|
|
434 |
|
|
435 |
|
|