gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r1631 - in GNUnet: contrib src/conf src/include src/util


From: durner
Subject: [GNUnet-SVN] r1631 - in GNUnet: contrib src/conf src/include src/util
Date: Mon, 8 Aug 2005 13:00:18 -0700 (PDT)

Author: durner
Date: 2005-08-08 13:00:10 -0700 (Mon, 08 Aug 2005)
New Revision: 1631

Modified:
   GNUnet/contrib/config-daemon.in
   GNUnet/contrib/gnunet.root
   GNUnet/src/conf/confdata.c
   GNUnet/src/include/gnunet_util.h
   GNUnet/src/util/configuration.c
   GNUnet/src/util/generate
Log:


Modified: GNUnet/contrib/config-daemon.in
===================================================================
--- GNUnet/contrib/config-daemon.in     2005-08-08 19:23:05 UTC (rev 1630)
+++ GNUnet/contrib/config-daemon.in     2005-08-08 20:00:10 UTC (rev 1631)
@@ -48,7 +48,7 @@
 menu "General settings" "GNUNETD"
   config GNUNETD_HOME
   string "Full pathname of GNUnet HOME directory"
-  default "/var/lib/GNUnet"
+  default ""
   help
                This gives the root-directory of the GNUnet installation. Make
                sure there is some space left in that directory. :-)  Users 
inserting

Modified: GNUnet/contrib/gnunet.root
===================================================================
--- GNUnet/contrib/gnunet.root  2005-08-08 19:23:05 UTC (rev 1630)
+++ GNUnet/contrib/gnunet.root  2005-08-08 20:00:10 UTC (rev 1631)
@@ -20,7 +20,7 @@
 # General settings
 #
 [GNUNETD]
-GNUNETD_HOME = "/var/lib/GNUnet"
+GNUNETD_HOME = ""
 HELLOEXPIRES = 1440
 LOGLEVEL = "WARNING"
 LOGFILE = "$GNUNETD_HOME/logs"

Modified: GNUnet/src/conf/confdata.c
===================================================================
--- GNUnet/src/conf/confdata.c  2005-08-08 19:23:05 UTC (rev 1630)
+++ GNUnet/src/conf/confdata.c  2005-08-08 20:00:10 UTC (rev 1631)
@@ -121,6 +121,42 @@
        *setting = line + idx;
 }
 
+/**
+ * @brief Set default for GNUNETD_HOME if needed
+ */
+void checkGNUNETDHome(const struct symbol *sym)
+{
+       if (strcmp(sym->name, "GNUNETD_HOME") == 0)
+       {
+               char *val;
+               
+               sym_calc_value_ext(sym, 1);
+               val = sym_get_string_value(sym);
+               
+               /* only empty if gnunet-setup is run for the first time */
+               if (!val || !strlen(val))
+               {
+                       /* GNUNETD_HOME isn't set yet. Let's choose a sane 
default */
+                       struct stat buf;
+                       int var = 0;
+                       if (STAT("/var/lib/GNUnet", &buf) != 0)
+                       {
+                               /* /var/lib/GNUnet doesn't exist. Do we have 
write permissions to /var? */
+                               if (ACCESS("/var", W_OK) == 0)
+                                       var = 1;
+                       }
+                       else
+                       {
+                               /* /var/lib/GNUnet is there, do we have write 
permissions? */
+                               if (ACCESS("/var/lib/GNUnet", W_OK) == 0)
+                                       var = 1;
+                       }
+                       
+                       sym_set_string_value(sym, var ? "/var/lib/GNUnet" : 
"~/.gnunet");
+               }
+       }
+}
+
 int conf_read(const char *name)
 {
        char *val;
@@ -175,7 +211,9 @@
                                                setConfigurationString("FILES",
                                                                       
"gnunet.conf",
                                                                       key);
-                                               readConfiguration();
+                                               
setConfigurationString("GNUNETD", "_MAGIC_",
+                                                       strcmp(fn, 
"config-daemon.in") == 0 ? "YES" : "NO");
+                                               readConfigFile(key);
                                        }
                                }
                                free(key);
@@ -192,7 +230,7 @@
                            setConfigurationString("FILES",
                                                   "gnunet.conf",
                                                   name);
-                           readConfiguration();
+                           readConfigFile(name);
                            i = 1;
                            break;
                          }
@@ -204,7 +242,7 @@
                setConfigurationString("FILES",
                                       "gnunet.conf",
                                       name);
-               readConfiguration();
+               readConfigFile(name);
        }
 
        if (!i)
@@ -213,6 +251,8 @@
        for_all_symbols(i, sym) {
          sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
                sym->flags &= ~SYMBOL_VALID;
+
+               checkGNUNETDHome(sym);
                
                if (isConfigurationItemSet(sym->sect, sym->name)) {
                val = getConfigurationString(sym->sect, sym->name);             
        

Modified: GNUnet/src/include/gnunet_util.h
===================================================================
--- GNUnet/src/include/gnunet_util.h    2005-08-08 19:23:05 UTC (rev 1630)
+++ GNUnet/src/include/gnunet_util.h    2005-08-08 20:00:10 UTC (rev 1631)
@@ -635,6 +635,14 @@
 void triggerGlobalConfigurationRefresh(void);
 
 /**
+ * @brief Read a specific configuration file. The previous configuration
+ *        will NOT be discarded if this method is invoked twice.
+ * @param fn the file to read
+ * @return YES on success, NO otherwise
+ */ 
+int readConfigFile(const char *fn);
+
+/**
  * Read the specified configuration file. The previous
  * configuration will be discarded if this method is
  * invoked twice. The configuration file that is read

Modified: GNUnet/src/util/configuration.c
===================================================================
--- GNUnet/src/util/configuration.c     2005-08-08 19:23:05 UTC (rev 1630)
+++ GNUnet/src/util/configuration.c     2005-08-08 20:00:10 UTC (rev 1631)
@@ -426,6 +426,23 @@
 void generate_gnunet_conf(FILE * f);
 
 /**
+ * @brief Read a specific configuration file. The previous configuration
+ *        will NOT be discarded if this method is invoked twice.
+ * @param fn the file to read
+ * @return YES on success, NO otherwise
+ */ 
+int readConfigFile(const char *fn) {
+  if (0 != cfg_parse_file(fn))
+       return NO;
+
+  parseConfigInit = YES;
+  
+  setConfigurationString("Meta", "DATADIR", DATADIR);
+  
+  return YES;
+}
+
+/**
  * Read the configuration file.  The previous configuration will be
  * discarded if this method is invoked twice.
  */
@@ -525,13 +542,10 @@
     doneParseConfig();
     parseConfigInit = NO;
   }
-  if (0 != cfg_parse_file(configuration_filename))
+  if (!readConfigFile(configuration_filename))
     errexit("Failed to parse configuration file '%s'.\n",
            configuration_filename);
-  parseConfigInit = YES;
   
-  setConfigurationString("Meta", "DATADIR", DATADIR);
-  
   MUTEX_UNLOCK(&configLock);
 }
 

Modified: GNUnet/src/util/generate
===================================================================
--- GNUnet/src/util/generate    2005-08-08 19:23:05 UTC (rev 1630)
+++ GNUnet/src/util/generate    2005-08-08 20:00:10 UTC (rev 1631)
@@ -5,14 +5,6 @@
 echo "#include <stdio.h>"
 echo "#include <unistd.h>"
 echo "void " $2 "(FILE * f) {"
-if [ $2 = 'generate_gnunetd_conf' ]
-then
- echo "  fprintf(f, \"[GNUNETD]\\n\");";
- echo " if (access(\"/var/lib/GNUnet\", X_OK))";
- echo "  fprintf(f, \"GNUNETD_HOME = ~/.gnunet\\n\");";
- echo " else";
- echo "  fprintf(f, \"GNUNETD_HOME = /var/lib/GNUnet\\n\");";
-fi
 cat $1 | grep -v "GNUNETD_HOME =" | sed \
         -e "s/\"/\\\\\"/g" \
        -e "s/^/ fprintf(f, \"%s\\\\n\",\"/" \





reply via email to

[Prev in Thread] Current Thread [Next in Thread]