gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r1727 - in GNUnet: . src/applications/session src/conf


From: grothoff
Subject: [GNUnet-SVN] r1727 - in GNUnet: . src/applications/session src/conf
Date: Wed, 17 Aug 2005 20:51:58 -0700 (PDT)

Author: grothoff
Date: 2005-08-17 20:51:56 -0700 (Wed, 17 Aug 2005)
New Revision: 1727

Modified:
   GNUnet/README.debian
   GNUnet/src/applications/session/connect.c
   GNUnet/src/conf/gconf.h
   GNUnet/src/conf/mconf.c
   GNUnet/src/conf/wizard.c
   GNUnet/src/conf/wizard_curs.c
   GNUnet/todo
Log:
fixing warnings, more defensive programming

Modified: GNUnet/README.debian
===================================================================
--- GNUnet/README.debian        2005-08-18 03:22:00 UTC (rev 1726)
+++ GNUnet/README.debian        2005-08-18 03:51:56 UTC (rev 1727)
@@ -24,6 +24,7 @@
 libgtk2.0-dev
 libsqlite3-dev
 libmysqlclient14-dev
+libncurses5-dev
 # libextractor1-dev (not in sarge)
 
 

Modified: GNUnet/src/applications/session/connect.c
===================================================================
--- GNUnet/src/applications/session/connect.c   2005-08-18 03:22:00 UTC (rev 
1726)
+++ GNUnet/src/applications/session/connect.c   2005-08-18 03:51:56 UTC (rev 
1727)
@@ -653,27 +653,35 @@
  *         NO if we're going to try to establish one asynchronously
  */
 static int tryConnect(const PeerIdentity * peer) {
+#if DEBUG_SESSION
   EncName enc;
 
   IFLOG(LOG_DEBUG,
        hash2enc(&peer->hashPubKey,
                 &enc));
+#endif
   if ( (topology != NULL) &&
        (topology->allowConnectionFrom(peer) == SYSERR) ) {
+#if DEBUG_SESSION
     LOG(LOG_DEBUG,
        "Topology rejected connecting to '%s'.\n",
        &enc);
+#endif
     return SYSERR;
   }
   if (coreAPI->queryBPMfromPeer(peer) != 0) {
+#if DEBUG_SESSION
     LOG(LOG_DEBUG,
        "Connection to '%s' already up (have BPM limit)\n",
        &enc);
+#endif
     return YES; /* trivial case */
   }
+#if DEBUG_SESSION
   LOG(LOG_DEBUG,
       "Trying to exchange key with '%s'.\n",
       &enc);
+#endif
   if (OK == exchangeKey(peer, NULL, NULL))
     return NO;
   else

Modified: GNUnet/src/conf/gconf.h
===================================================================
--- GNUnet/src/conf/gconf.h     2005-08-18 03:22:00 UTC (rev 1726)
+++ GNUnet/src/conf/gconf.h     2005-08-18 03:51:56 UTC (rev 1727)
@@ -25,8 +25,8 @@
  * @author Nils Durner
  */
 
-#ifndef GCONF_H
-#define GCONF_H
+#ifndef GNUNET_SETUP_GCONF_H
+#define GNUNET_SETUP_GCONF_H
 
 int gconf_main(void);
 

Modified: GNUnet/src/conf/mconf.c
===================================================================
--- GNUnet/src/conf/mconf.c     2005-08-18 03:22:00 UTC (rev 1726)
+++ GNUnet/src/conf/mconf.c     2005-08-18 03:51:56 UTC (rev 1727)
@@ -33,6 +33,7 @@
 
 #include "platform.h"
 #include "gnunet_util.h"
+#include "confdata.h"
 
 #ifndef MINGW
 #include <sys/ioctl.h>

Modified: GNUnet/src/conf/wizard.c
===================================================================
--- GNUnet/src/conf/wizard.c    2005-08-18 03:22:00 UTC (rev 1726)
+++ GNUnet/src/conf/wizard.c    2005-08-18 03:51:56 UTC (rev 1727)
@@ -51,7 +51,8 @@
 
 int doOpenEnhConfigurator = 0;
 int doAutoStart = 0;
-char *user_name = NULL, *group_name = NULL;
+char * user_name = NULL;
+char * group_name = NULL;
 static int nic_item_count = 0;
 
 void insert_nic(char *name, int defaultNIC)
@@ -209,6 +210,8 @@
 {
   struct symbol *sym;
   GtkWidget *vbox18, *frame8, *vbox19, *table3, *entUser, *entGroup;
+  const char * uname;
+  const char * gname;
 
   vbox18 = lookup_widget(curwnd, "vbox18");
   frame8 = lookup_widget(vbox18, "frame8");
@@ -217,44 +220,67 @@
   entUser = lookup_widget(table3, "entUser");
   entGroup = lookup_widget(table3, "entGroup");
 
-  if (! user_name)
+  if (NULL != user_name)
   {
     sym = sym_find("USER", "GNUNETD");
     if (sym)
     {
       sym_calc_value_ext(sym, 1);
-      user_name = sym_get_string_value(sym);
+      uname = sym_get_string_value(sym);
     }
   }
 
-  if (! group_name)
+  if (NULL != group_name)
   {
     sym = sym_find("GROUP", "GNUNETD");
     if (sym)
     {
       sym_calc_value_ext(sym, 1);
-      group_name = sym_get_string_value(sym);
+      gname = sym_get_string_value(sym);
     }
   }
 
 #ifndef MINGW
-  if(NULL == user_name || strlen(user_name) == 0)
+  if (NULL == uname || strlen(uname) == 0)
   {
     if((geteuid() == 0) || (NULL != getpwnam("gnunet")))
       user_name = STRDUP("gnunet");
-    else
-      user_name = STRDUP(getenv("USER"));
+    else {
+      uname = getenv("USER");
+      if (uname != NULL)
+       user_name = STRDUP(uname);
+      else
+       user_name = NULL;
+    }
+  } else {
+    user_name = STRDUP(uname);
   }
-  if(NULL == group_name)
+  if(NULL == gname || strlen(gname) == 0)
   {
+    struct group * grp;
     if((geteuid() == 0) || (NULL != getgrnam("gnunet")))
       group_name = STRDUP("gnunet");
-    else
-      group_name = STRDUP(getgrgid(getegid())->gr_name);
+    else {
+      grp = getgrgid(getegid());
+      if ( (grp != NULL) &&
+          (grp->gr_name != NULL) )
+       group_name = STRDUP(grp->gr_name);    
+      else
+       group_name = NULL;
+    }
+  } else {
+    group_name = STRDUP(gname);
   }
+    
 #else
-  if (NULL == user_name || strlen(user_name) == 0)
+  if (NULL == uname || strlen(uname) == 0)
     user_name = STRDUP("");
+  else
+    user_name = STRDUP(uname);
+  if (NULL == gname || strlen(gname) == 0)
+    group_name = STRDUP("");
+  else
+    group_name = STRDUP(gname);
 #endif
 
   if(user_name)

Modified: GNUnet/src/conf/wizard_curs.c
===================================================================
--- GNUnet/src/conf/wizard_curs.c       2005-08-18 03:22:00 UTC (rev 1726)
+++ GNUnet/src/conf/wizard_curs.c       2005-08-18 03:51:56 UTC (rev 1727)
@@ -74,7 +74,7 @@
        item = malloc(sizeof(struct dialog_list_item));
        memset(item, 0, sizeof(struct dialog_list_item));
        nic_items[nic_item_count-1] = item;
-       item->name = strdup(name);
+       item->name = STRDUP(name);
        item->namelen = strlen(name);
   item->selected = wiz_is_nic_default(name, defaultNIC);
 }
@@ -85,9 +85,14 @@
   int idx, ret, autostart = 0, adv = 0;
   struct symbol *sym;
   char *defval;
-  const char *user_name = NULL, *group_name = NULL;
+  char * user_name = NULL;
+  char * group_name = NULL;
   char *confFile;
   char * filename;
+  char *defuser;
+  const char *confUser;
+  char *defgroup;
+  const char *confGroup;  
 
   filename = getConfigurationString("GNUNET-SETUP",
                                   "FILENAME");
@@ -401,247 +406,256 @@
   else
     sym_set_tristate_value(sym, !ret); /* ret is inverted */
 
-       dialog_clear();
-
-       /* Quota */
-       if ((sym = sym_find("QUOTA", "FS"))) {
-               sym_calc_value_ext(sym, 1);
-               defval = (char *) sym_get_string_value(sym);
-       }
-       else
-               defval = NULL;
-
-       while(true) {
-               ret = dialog_inputbox(_("GNUnet configuration"), _("What's the 
maximum "
-                       "datastore size in MB?\n\nThe GNUnet datastore contains 
all data that "
-                       "GNUnet generates (index data, inserted and migrated 
content)."),
-                       rows, cols - 5, defval ? defval : "");
-               
-               if (ret == 1) {
-                       /* Help - not available */
-               }
-               else if (ret <= 0)
-                       break;
-       }
-       
-       if (ret == -1)
-               goto end;
-
-       sym_set_string_value(sym, dialog_input_result);
-
-       dialog_clear();
-
-       /* Autostart */
-       if (isOSAutostartCapable()) {
-               while(true) {
-                       ret = dialog_yesno(_("GNUnet configuration"), _("Do you 
want to launch "
-                                       "GNUnet as a system service?"
-                                       "\n\nIf you say \"yes\" here, the 
GNUnet background process will be "
-                                       "automatically started when you turn on 
your computer. If you say \"no\""
-                                       " here, you have to launch GNUnet 
yourself each time you want to use it."),
-                                       rows, cols - 5);
-                                       
-                       if (ret != -2)
-                               break;
-               }
-       
-               if (ret == -1)
-                       goto end;
-               else
-                       autostart = !ret; /* ret is inverted */
-       
-               dialog_clear();
-       }
-       
-       /* User */
-       if (isOSUserAddCapable()) {
-               while(true) {
-      char *defuser;
-      const char *confUser;
+  dialog_clear();
+  
+  /* Quota */
+  if ((sym = sym_find("QUOTA", "FS"))) {
+    sym_calc_value_ext(sym, 1);
+    defval = (char *) sym_get_string_value(sym);
+  }
+  else
+    defval = NULL;
+  
+  while(true) {
+    ret = dialog_inputbox(_("GNUnet configuration"), 
+                         _("What's the maximum "
+                           "datastore size in MB?\n\nThe GNUnet datastore 
contains all data that "
+                           "GNUnet generates (index data, inserted and 
migrated content)."),
+                         rows, cols - 5, defval ? defval : "");
+    
+    if (ret == 1) {
+      /* Help - not available */
+    }
+    else if (ret <= 0)
+      break;
+  }
+  
+  if (ret == -1)
+    goto end;
+  
+  sym_set_string_value(sym, dialog_input_result);
+  
+  dialog_clear();
+  
+  /* Autostart */
+  if (isOSAutostartCapable()) {
+    while(true) {
+      ret = dialog_yesno(_("GNUnet configuration"),
+                        _("Do you want to launch "
+                          "GNUnet as a system service?"
+                          "\n\nIf you say \"yes\" here, the GNUnet background 
process will be "
+                          "automatically started when you turn on your 
computer. If you say \"no\""
+                          " here, you have to launch GNUnet yourself each time 
you want to use it."),
+                        rows, cols - 5);
       
+      if (ret != -2)
+       break;
+    }
+    
+    if (ret == -1)
+      goto end;
+    else
+      autostart = !ret; /* ret is inverted */
+    
+    dialog_clear();
+  }
+  
+  /* User */
+  if (isOSUserAddCapable()) {
+    while(true) {
+      
       sym = sym_find("USER", "GNUNETD");
       if (sym)
-      {
-        sym_calc_value_ext(sym, 1);
-        confUser = sym_get_string_value(sym);
-      }
+       {
+         sym_calc_value_ext(sym, 1);
+         confUser = sym_get_string_value(sym);
+       }
       else
         confUser = NULL;
       
 #ifndef MINGW
-      if(NULL == confUser || strlen(confUser) == 0)
-      {
-        if((geteuid() == 0) || (NULL != getpwnam("gnunet")))
-          defuser = STRDUP("gnunet");
-        else
-          defuser = STRDUP(getenv("USER"));
-      }
+      if ((NULL == confUser) || (strlen(confUser) == 0))
+       {
+         if((geteuid() == 0) || (NULL != getpwnam("gnunet")))
+           defuser = STRDUP("gnunet");
+         else {
+           confUser = getenv("USER");
+           if (confUser != NULL)
+             defuser = STRDUP(confUser);
+           else
+             defuser = NULL;
+         }
+       }
       else
         defuser = STRDUP(confUser);
 #else
       if (NULL == confUser || strlen(confUser) == 0)
         defuser = STRDUP("");
       else
-        defuser = STRDUP(user_name);
+        defuser = STRDUP(confUser);
 #endif
       
-                       ret = dialog_inputbox(_("GNUnet configuration"),
-                               _("Define the user owning the GNUnet 
service.\n\n"
-                                       "For security reasons, it is a good 
idea to let this setup create "
-                                       "a new user account under which the 
GNUnet service is started "
-                                       "at system startup.\n\n"
-                                       "However, GNUnet may not be able to 
access files other than its own. "
-                                       "This includes files you want to 
publish in GNUnet. You'll have to "
-                                       "grant read permissions to the user 
specified below.\n\n"
-                                       "Leave the fields empty to run GNUnet 
with system privileges.\n\n"
-                                       "GNUnet user:"), rows, cols - 5, 
defuser);
+      ret = dialog_inputbox(_("GNUnet configuration"),
+                           _("Define the user owning the GNUnet service.\n\n"
+                             "For security reasons, it is a good idea to let 
this setup create "
+                             "a new user account under which the GNUnet 
service is started "
+                             "at system startup.\n\n"
+                             "However, GNUnet may not be able to access files 
other than its own. "
+                             "This includes files you want to publish in 
GNUnet. You'll have to "
+                             "grant read permissions to the user specified 
below.\n\n"
+                             "Leave the fields empty to run GNUnet with system 
privileges.\n\n"
+                             "GNUnet user:"), rows, cols - 5, defuser);
       FREE(defuser);
-                       
-                       if (ret == 1) {
-                               /* Help */
-                       }
-                       else if (ret <= 0) {
-                               user_name = strdup(dialog_input_result);
-                               break;
-                       }
-               }
-               
-               if (ret == -1)
-                       goto end;
-
-               dialog_clear();
-
-               /* Group */
-               if (isOSGroupAddCapable()) {
-      char *defgroup;
-      const char *confGroup;
       
-                       while(true) {
+      if (ret == 1) {
+       /* Help */
+      } else if (ret <= 0) {
+       user_name = STRDUP(dialog_input_result);
+       break;
+      }
+    }
+    
+    if (ret == -1)
+      goto end;
+    
+    dialog_clear();
+    
+    /* Group */
+    if (isOSGroupAddCapable()) {
+      while(true) {
         sym = sym_find("GROUP", "GNUNETD");
         if (sym)
-        {
-          sym_calc_value_ext(sym, 1);
-          confGroup = sym_get_string_value(sym);
-        }
+         {
+           sym_calc_value_ext(sym, 1);
+           confGroup = sym_get_string_value(sym);
+         }
         else
           confGroup = NULL;
-
+       
 #ifndef MINGW
-        if(NULL == confGroup || strlen(confGroup) == 0)
-        {
-          if((geteuid() == 0) || (NULL != getgrnam("gnunet")))
-            defgroup = STRDUP("gnunet");
-          else
-            defgroup = STRDUP(getgrgid(getegid())->gr_name);
-        }
+        if((NULL == confGroup) || (strlen(confGroup) == 0))
+         {
+           if((geteuid() == 0) || (NULL != getgrnam("gnunet")))
+             defgroup = STRDUP("gnunet");
+           else {
+             struct group * grp;
+             grp = getgrgid(getegid());
+             if ( (grp != NULL) &&
+                  (grp->gr_name != NULL) )
+               defgroup = STRDUP(grp->gr_name);
+             else
+               defgroup = NULL;
+           }
+         }
         else
           defgroup = STRDUP(confGroup);
 #else
-        if (NULL == group_name || strlen(group_name) == 0)
+        if ( (NULL == defgroup) || 
+            (strlen(defgroup) == 0) )
           defgroup = STRDUP("");
         else
-          defgroup = STRDUP(confUser);
+          defgroup = STRDUP(defgroup);
 #endif
-        
-                               ret = dialog_inputbox(_("GNUnet configuration"),
-                                       _("Define the group owning the GNUnet 
service.\n\n"
-                                               "For security reasons, it is a 
good idea to let this setup create "
-                                               "a new group for the chosen 
user account.\n\n"
-                                               "You can also specify a already 
existant group here.\n\n"
-                                               "Only members of this group 
will be allowed to start and stop the "
-                                               "the GNUnet server and have 
access to GNUnet server data.\n\n"
-                                               "GNUnet group:"),
-                                       rows, cols - 5, defgroup);
+       
+       ret = dialog_inputbox(_("GNUnet configuration"),
+                             _("Define the group owning the GNUnet 
service.\n\n"
+                               "For security reasons, it is a good idea to let 
this setup create "
+                               "a new group for the chosen user account.\n\n"
+                               "You can also specify a already existant group 
here.\n\n"
+                               "Only members of this group will be allowed to 
start and stop the "
+                               "the GNUnet server and have access to GNUnet 
server data.\n\n"
+                               "GNUnet group:"),
+                             rows, cols - 5, defgroup);
         FREE(defgroup);
-                               
-                               if (ret == 1) {
-                                       /* Help */
-                               }
-                               else if (ret <= 0) {
-                                       group_name = 
strdup(dialog_input_result);
-                                       break;
-                               }
-                       }
-               
-                       if (ret == -1)
-                               goto end;
        
-                       dialog_clear();
-               }
+       if (ret == 1) {
+         /* Help */
        }
-
-       dialog_clear();
-
-       /* Advanced */
-       while(true) {
-               ret = dialog_yesno(_("GNUnet configuration"), _("If you are an 
experienced "
-                               "user, you may want to tweak your GNUnet 
installation using the enhanced "
-                               "configurator.\n\nDo you want to start it after 
saving your configuration?"),
-                               rows, cols - 5);
-                               
-               if (ret != -2)
-                       break;
+       else if (ret <= 0) {
+         group_name = STRDUP(dialog_input_result);
+         break;
        }
-       
-       if (ret == -1)
-               goto end;
-       else
-               adv = !ret;
-
-       dialog_clear();
+      }
+      
+      if (ret == -1)
+       goto end;
+      
+      dialog_clear();
+    }
+  }
+  
+  dialog_clear();
+  
+  /* Advanced */
+  while(true) {
+    ret = dialog_yesno(_("GNUnet configuration"), 
+                      _("If you are an experienced "
+                        "user, you may want to tweak your GNUnet installation 
using the enhanced "
+                        "configurator.\n\nDo you want to start it after saving 
your configuration?"),
+                      rows, cols - 5);
+    
+    if (ret != -2)
+      break;
+  }
+  
+  if (ret == -1)
+    goto end;
+  else
+    adv = !ret;
+  
+  dialog_clear();
   end_dialog();
-
-       /* Save config */
-       if (user_name && strlen(user_name) > 0)
-               if (!isOSUserAddCapable(group_name, user_name))
-                       showCursErr(_("Unable to create user account:"), 
STRERROR(errno));
-       
-       if (!isOSAutostartCapable())
-               showCursErr(_("Unable to change startup process:"), 
STRERROR(errno));
-
-       init_dialog();
-       dialog_clear();
-       
-       while(true) {
+  
+  /* Save config */
+  if ( (user_name != NULL) && 
+       (strlen(user_name) > 0) )
+    if (!isOSUserAddCapable(group_name, user_name))
+      showCursErr(_("Unable to create user account:"), STRERROR(errno));
+  
+  if (!isOSAutostartCapable())
+    showCursErr(_("Unable to change startup process:"), STRERROR(errno));
+  
+  init_dialog();
+  dialog_clear();
+  
+  while(true) {
     confFile = getConfigurationString("GNUNET-SETUP",
-                "FILENAME");
-               if (conf_write(confFile) != 0) {
-                 char * err;
-                 const char * prefix;
-                 const char * strerr;
-                       
-                 prefix = _("Unable to save configuration file %s: %s.\n\nTry 
again?");
-                 strerr = STRERROR(errno);
-                       
-                 err = malloc(strlen(confFile) + strlen(prefix) + 
strlen(strerr) + 1);
-                 sprintf(err, prefix, confFile, strerr);
-                       
-                 ret = dialog_yesno(_("GNUnet configuration"),
-                                    err, 
-                                    rows, 
-                                    cols - 5);
-
-                 free(err);
-               } 
-               else
-                 ret = 1;
-                       
-               if (ret == 1 || ret == -1)
-                       break;
-       }
-       
+                                     "FILENAME");
+    if (conf_write(confFile) != 0) {
+      char * err;
+      const char * prefix;
+      const char * strerr;
+      
+      prefix = _("Unable to save configuration file %s: %s.\n\nTry again?");
+      strerr = STRERROR(errno);
+      
+      err = malloc(strlen(confFile) + strlen(prefix) + strlen(strerr) + 1);
+      sprintf(err, prefix, confFile, strerr);
+      
+      ret = dialog_yesno(_("GNUnet configuration"),
+                        err, 
+                        rows, 
+                        cols - 5);
+      
+      free(err);
+    } 
+    else
+      ret = 1;
+    
+    if (ret == 1 || ret == -1)
+      break;
+  }
+  
 end:
   end_dialog();
   
-  if (user_name)
-       free(user_name);
-  if (group_name)
-       free(group_name);
-
-       if (adv) {
-               mconf_main();
-       }
-
+  FREENONNULL(user_name);
+  FREENONNULL(group_name);
+  
+  if (adv) {
+    mconf_main();
+  }
+  
   return 0;
 }
 

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2005-08-18 03:22:00 UTC (rev 1726)
+++ GNUnet/todo 2005-08-18 03:51:56 UTC (rev 1727)
@@ -2,7 +2,6 @@
 - gnunet-setup:
   * gconfig: fix focus changes [ Nils ]
   * #852,#853 (gnunet-setup nitpicks) [Nils / Christian]
-- test remote search/download
   
 
 0.7.0 [8'05?] (aka "compatibility? what's that?"):





reply via email to

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