]> Untitled Git - dockapps/wmnotify.git/commitdiff
Now creating the default configuration file with correct permissions
authorHugo Villeneuve <hugo@hugovil.com>
Sat, 25 May 2013 22:49:47 +0000 (18:49 -0400)
committerHugo Villeneuve <hugo@hugovil.com>
Sat, 25 May 2013 22:55:30 +0000 (18:55 -0400)
doc/wmnotify.man
src/configfile.c

index 17a9c389b2362be4da54b2a23915137430ebc27e..92a4930f07377e85533559d4f3d71c3ac17258fb 100644 (file)
@@ -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
index f06a16653f8fc1b389995b27f365381c9903dea2..4bdfb9e25918f52dbee7becb0843162fba0c7d2a 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <unistd.h>
 #include <stdio.h>
+#include <sys/stat.h>
 #include <stdlib.h>
 
 #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" );