mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-25 07:40:12 +01:00
directory write ability check for some piler binaries
This commit is contained in:
parent
c8a4c3c358
commit
d26b3a7e74
@ -14,7 +14,7 @@
|
||||
|
||||
#define VERSION "1.1.1-pre"
|
||||
|
||||
#define BUILD 889
|
||||
#define BUILD 890
|
||||
|
||||
#define HOSTID "mailarchiver"
|
||||
|
||||
|
18
src/misc.c
18
src/misc.c
@ -560,6 +560,24 @@ void *get_in_addr(struct sockaddr *sa){
|
||||
}
|
||||
|
||||
|
||||
int can_i_write_current_directory(){
|
||||
int fd;
|
||||
char filename[SMALLBUFSIZE];
|
||||
|
||||
snprintf(filename, sizeof(filename)-1, "__piler_%d", getpid());
|
||||
|
||||
fd = open(filename, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR|S_IRGRP);
|
||||
if(fd == -1){
|
||||
return 0;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
unlink(filename);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
char *strcasestr(const char *s, const char *find){
|
||||
char c, sc;
|
||||
|
@ -42,6 +42,8 @@ void strtolower(char *s);
|
||||
|
||||
void *get_in_addr(struct sockaddr *sa);
|
||||
|
||||
int can_i_write_current_directory();
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
char *strcasestr(const char *s, const char *find);
|
||||
#endif
|
||||
|
@ -351,6 +351,8 @@ int main(int argc, char **argv){
|
||||
|
||||
regfree(®exp);
|
||||
|
||||
if(!can_i_write_current_directory()) __fatal("cannot write current directory!");
|
||||
|
||||
(void) openlog("pilerexport", LOG_PID, LOG_MAIL);
|
||||
|
||||
if(exportall == 1){
|
||||
|
@ -647,6 +647,8 @@ int main(int argc, char **argv){
|
||||
|
||||
if(!mbox[0] && !mboxdir && !emlfile && !directory && !imapserver && !pop3server && import_from_gui == 0) usage();
|
||||
|
||||
if(!can_i_write_current_directory()) __fatal("cannot write current directory!");
|
||||
|
||||
cfg = read_config(configfile);
|
||||
|
||||
/* make sure we don't discard messages without a valid Message-Id when importing manually */
|
||||
|
@ -205,6 +205,7 @@ int main(int argc, char **argv){
|
||||
|
||||
if(all == 0 && (from_id <= 0 || to_id <= 0) ) usage();
|
||||
|
||||
if(!can_i_write_current_directory()) __fatal("cannot write current directory!");
|
||||
|
||||
(void) openlog("reindex", LOG_PID, LOG_MAIL);
|
||||
|
||||
|
@ -32,6 +32,8 @@ int main(int argc, char **argv){
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(!can_i_write_current_directory()) __fatal("cannot write current directory!");
|
||||
|
||||
if(stat(argv[1], &st) != 0){
|
||||
fprintf(stderr, "%s is not found\n", argv[1]);
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user