From 83ea53b5998131177ca37009f6dbb06736f39709 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Tue, 22 Jan 2013 18:10:45 +0100 Subject: [PATCH] Patch preventing chmod on /dev/null --- coreapi/lpconfig.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index 8457cf65..4608beec 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -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; -- 2.39.2