Now creating the default configuration file with correct permissions
[dockapps/wmnotify.git] / src / configfile.c
index f06a166..4bdfb9e 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" );