From: Hugo Villeneuve Date: Sat, 25 May 2013 22:49:47 +0000 (-0400) Subject: Now creating the default configuration file with correct permissions X-Git-Tag: v0.3.2~5 X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=b309ccfdfd4593f3aecbdf1dafaed2f2c9d4a779;hp=244e5e599c40ea9005b1de0d91a4c0f6adec5258;p=dockapps%2Fwmnotify.git Now creating the default configuration file with correct permissions --- diff --git a/doc/wmnotify.man b/doc/wmnotify.man index 17a9c38..92a4930 100644 --- a/doc/wmnotify.man +++ b/doc/wmnotify.man @@ -37,7 +37,8 @@ an option in the configuration file to adjust the volume of the sound file. .B wmnotify reads your mail account settings and preferences from the specified configuration file. This option overrides the use of the default config file, -.IR "$HOME/.wmnotifyrc". +.IR "$HOME/.wmnotifyrc". Make sure that the alternate configuration file has +correct permissions (normally 0400) to protect your email account informations. .TP \fB\-d\fR diff --git a/src/configfile.c b/src/configfile.c index f06a166..4bdfb9e 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -8,6 +8,7 @@ #include #include +#include #include #if STDC_HEADERS @@ -42,7 +43,14 @@ CreateDefaultConfigurationFile( char *file ) fprintf( stderr, "%s: Can't create file \"%s\"\n", PACKAGE, file ); exit( EXIT_FAILURE ); } - + + /* Changing permissions so that only the user can read/modify the file. */ + status = chmod( file, S_IRUSR | S_IWUSR ); + if( status < 0 ) { + fprintf( stderr, "%s: Can't set permission bits on file \"%s\"\n", PACKAGE, file ); + exit( EXIT_FAILURE ); + } + fprintf( fp, "# ~/.wmnotifyrc -- Default configuration file for wmnotify\n\n" ); fprintf( fp, "# Replace all 'xxxxxxxx' fields with your own settings.\n\n" ); fprintf( fp, "# Parameters preceded by a '#' character are optional.\n" );