mirror of
				https://bitbucket.org/jsuto/piler.git
				synced 2025-11-04 03:22:27 +01:00 
			
		
		
		
	directory write ability check for some piler binaries
This commit is contained in:
		@@ -14,7 +14,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#define VERSION "1.1.1-pre"
 | 
					#define VERSION "1.1.1-pre"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define BUILD 889
 | 
					#define BUILD 890
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define HOSTID "mailarchiver"
 | 
					#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
 | 
					#ifndef _GNU_SOURCE
 | 
				
			||||||
char *strcasestr(const char *s, const char *find){
 | 
					char *strcasestr(const char *s, const char *find){
 | 
				
			||||||
   char c, sc;
 | 
					   char c, sc;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,6 +42,8 @@ void strtolower(char *s);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void *get_in_addr(struct sockaddr *sa);
 | 
					void *get_in_addr(struct sockaddr *sa);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int can_i_write_current_directory();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifndef _GNU_SOURCE
 | 
					#ifndef _GNU_SOURCE
 | 
				
			||||||
   char *strcasestr(const char *s, const char *find);
 | 
					   char *strcasestr(const char *s, const char *find);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -351,6 +351,8 @@ int main(int argc, char **argv){
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
   regfree(®exp);
 | 
					   regfree(®exp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   if(!can_i_write_current_directory()) __fatal("cannot write current directory!");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   (void) openlog("pilerexport", LOG_PID, LOG_MAIL);
 | 
					   (void) openlog("pilerexport", LOG_PID, LOG_MAIL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   if(exportall == 1){
 | 
					   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(!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);
 | 
					   cfg = read_config(configfile);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   /* make sure we don't discard messages without a valid Message-Id when importing manually */
 | 
					   /* 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(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);
 | 
					   (void) openlog("reindex", LOG_PID, LOG_MAIL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,6 +32,8 @@ int main(int argc, char **argv){
 | 
				
			|||||||
      exit(1);
 | 
					      exit(1);
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   if(!can_i_write_current_directory()) __fatal("cannot write current directory!");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   if(stat(argv[1], &st) != 0){
 | 
					   if(stat(argv[1], &st) != 0){
 | 
				
			||||||
      fprintf(stderr, "%s is not found\n", argv[1]);
 | 
					      fprintf(stderr, "%s is not found\n", argv[1]);
 | 
				
			||||||
      return 0;
 | 
					      return 0;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user