]> sjero.net Git - linphone/commitdiff
Patch preventing chmod on /dev/null
authorGuillaume Beraudo <guillaume.beraudo@belledonne-communications.com>
Tue, 22 Jan 2013 17:10:45 +0000 (18:10 +0100)
committerGuillaume Beraudo <guillaume.beraudo@belledonne-communications.com>
Tue, 22 Jan 2013 17:10:45 +0000 (18:10 +0100)
coreapi/lpconfig.c

index 8457cf65051d704ce57763665ef144b4accd2c0a..4608beecfff09cde860a8d0d3b4b19ec477ab8f4 100644 (file)
@@ -215,14 +215,17 @@ LpConfig * lp_config_new(const char *filename){
                lpconfig->filename=ortp_strdup(filename);
                lpconfig->file=fopen(filename,"rw");
                if (lpconfig->file!=NULL){
+                       struct stat fileStat;
                        lp_config_parse(lpconfig,lpconfig->file);
-                       fclose(lpconfig->file);                 
+                       fclose(lpconfig->file);
 #if !defined(_WIN32_WCE)
-                       /* make existing configuration files non-group/world-accessible */
-                       if (chmod(filename, S_IRUSR | S_IWUSR) == -1)
-                               ms_warning("unable to correct permissions on "
-                                         "configuration file: %s",
-                                          strerror(errno));
+                       if ((stat(filename,&fileStat) == 0) && (S_ISREG(fileStat.st_mode))) {
+                               /* make existing configuration files non-group/world-accessible */
+                               if (chmod(filename, S_IRUSR | S_IWUSR) == -1) {
+                                       ms_warning("unable to correct permissions on "
+                                       "configuration file: %s", strerror(errno));
+                               }
+                       }
 #endif /*_WIN32_WCE*/
                        lpconfig->file=NULL;
                        lpconfig->modified=0;