From b309ccfdfd4593f3aecbdf1dafaed2f2c9d4a779 Mon Sep 17 00:00:00 2001 From: Hugo Villeneuve Date: Sat, 25 May 2013 18:49:47 -0400 Subject: [PATCH] Now creating the default configuration file with correct permissions --- doc/wmnotify.man | 3 ++- src/configfile.c | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) 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" ); -- 2.20.1