gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: Allow applications to change ProjectData


From: gnunet
Subject: [gnunet] branch master updated: Allow applications to change ProjectData with only some fields
Date: Sun, 11 Oct 2020 10:37:51 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 77339944c Allow applications to change ProjectData with only some 
fields
77339944c is described below

commit 77339944c9605919a035744df1a839a6e5793a37
Author: Alessio Vanni <vannilla@firemail.cc>
AuthorDate: Sat Oct 10 17:19:53 2020 +0200

    Allow applications to change ProjectData with only some fields
    
    Some simple applications (e.g. thin clients) might want to change the
    ProjectData structure (e.g. for gettext), but might not meet all the
    requirements needed to fill it out completely.
    
    A thin client might not provide any library, making the `libname' field
    useless.  More importantly, not every application requires a configuration:
    some of them, especially clients, might simply use command line options to
    drive their behaviour.
---
 src/util/configuration_loader.c |  3 ++-
 src/util/os_installation.c      |  2 ++
 src/util/program.c              | 25 +++++++++++++++----------
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/util/configuration_loader.c b/src/util/configuration_loader.c
index b9e5cb67f..51af24a9f 100644
--- a/src/util/configuration_loader.c
+++ b/src/util/configuration_loader.c
@@ -47,7 +47,8 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle 
*cfg,
 
   base_config_varname = GNUNET_OS_project_data_get ()->base_config_varname;
 
-  if (NULL != (baseconfig = getenv (base_config_varname)))
+  if (NULL != base_config_varname
+      && NULL != (baseconfig = getenv (base_config_varname)))
   {
     baseconfig = GNUNET_strdup (baseconfig);
   }
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
index 34b88d761..1f2dd2e5b 100644
--- a/src/util/os_installation.c
+++ b/src/util/os_installation.c
@@ -150,6 +150,8 @@ get_path_from_proc_maps ()
   FILE *f;
   char *lgu;
 
+  if (NULL == current_pd->libname)
+    return NULL;
   GNUNET_snprintf (fn, sizeof(fn), "/proc/%u/maps", getpid ());
   if (NULL == (f = fopen (fn, "r")))
     return NULL;
diff --git a/src/util/program.c b/src/util/program.c
index 8bda34b4f..b5484855c 100644
--- a/src/util/program.c
+++ b/src/util/program.c
@@ -232,15 +232,20 @@ GNUNET_PROGRAM_run2 (int argc,
          sizeof(struct GNUNET_GETOPT_CommandLineOption),
          &cmd_sorter);
   loglev = NULL;
-  xdg = getenv ("XDG_CONFIG_HOME");
-  if (NULL != xdg)
-    GNUNET_asprintf (&cfg_fn,
-                     "%s%s%s",
-                     xdg,
-                     DIR_SEPARATOR_STR,
-                     pd->config_file);
+  if (NULL != pd->config_file && NULL != pd->user_config_file)
+  {
+    xdg = getenv ("XDG_CONFIG_HOME");
+    if (NULL != xdg)
+      GNUNET_asprintf (&cfg_fn,
+                       "%s%s%s",
+                       xdg,
+                       DIR_SEPARATOR_STR,
+                       pd->config_file);
+    else
+      cfg_fn = GNUNET_strdup (pd->user_config_file);
+  }
   else
-    cfg_fn = GNUNET_strdup (pd->user_config_file);
+    cfg_fn = NULL;
   lpfx = GNUNET_strdup (binaryName);
   if (NULL != (spc = strstr (lpfx, " ")))
     *spc = '\0';
@@ -269,7 +274,7 @@ GNUNET_PROGRAM_run2 (int argc,
   }
   else
   {
-    if (GNUNET_YES == GNUNET_DISK_file_test (cfg_fn))
+    if (NULL != cfg_fn && GNUNET_YES == GNUNET_DISK_file_test (cfg_fn))
     {
       if (GNUNET_SYSERR == GNUNET_CONFIGURATION_load (cfg, cfg_fn))
       {
@@ -284,7 +289,7 @@ GNUNET_PROGRAM_run2 (int argc,
         goto cleanup;
       }
     }
-    else
+    else if (NULL != cfg_fn)
     {
       GNUNET_free (cfg_fn);
       cfg_fn = NULL;

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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