GNUnet  0.10.x
os_installation.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2006-2018 GNUnet e.V.
4 
5  GNUnet is free software: you can redistribute it and/or modify it
6  under the terms of the GNU Affero General Public License as published
7  by the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  GNUnet is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Affero General Public License for more details.
14 
15  You should have received a copy of the GNU Affero General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  SPDX-License-Identifier: AGPL3.0-or-later
19  */
20 
31 #include <sys/stat.h>
32 #include <stdlib.h>
33 #include <string.h>
34 #include <unistd.h>
35 #include <unistr.h> /* for u16_to_u8 */
36 
37 #include "platform.h"
38 #include "gnunet_util_lib.h"
39 #if DARWIN
40 #include <mach-o/ldsyms.h>
41 #include <mach-o/dyld.h>
42 #endif
43 
44 
45 #define LOG(kind, ...) \
46  GNUNET_log_from(kind, "util-os-installation", __VA_ARGS__)
47 
48 #define LOG_STRERROR_FILE(kind, syscall, filename) \
49  GNUNET_log_from_strerror_file(kind, \
50  "util-os-installation", \
51  syscall, \
52  filename)
53 
54 
59 static const struct GNUNET_OS_ProjectData default_pd = {
60  .libname = "libgnunetutil",
61  .project_dirname = "gnunet",
62  .binary_name = "gnunet-arm",
63  .version = PACKAGE_VERSION " " VCS_VERSION,
64  .env_varname = "GNUNET_PREFIX",
65  .base_config_varname = "GNUNET_BASE_CONFIG",
66  .bug_email = "gnunet-developers@gnu.org",
67  .homepage = "http://www.gnu.org/s/gnunet/",
68  .config_file = "gnunet.conf",
69  .user_config_file = "~/.config/gnunet.conf",
70  .is_gnu = 1,
71  .gettext_domain = PACKAGE,
72  .gettext_path = NULL,
73 };
74 
80 
86 static int gettextinit = 0;
87 
91 const struct GNUNET_OS_ProjectData *
93 {
94  return &default_pd;
95 }
96 
97 
101 const struct GNUNET_OS_ProjectData *
103 {
104  if (0 == gettextinit)
105  {
107  if (NULL != path)
108  bindtextdomain(PACKAGE, path);
109  GNUNET_free(path);
110  gettextinit = 1;
111  }
112  return current_pd;
113 }
114 
115 
121 void
123 {
124  if (0 == gettextinit)
125  {
127  if (NULL != path)
128  bindtextdomain(PACKAGE, path);
129  GNUNET_free(path);
130  gettextinit = 1;
131  }
132  GNUNET_assert(NULL != pd);
133  current_pd = pd;
134 }
135 
136 
137 #if LINUX
138 
143 static char *
144 get_path_from_proc_maps()
145 {
146  char fn[64];
147  char line[1024];
148  char dir[1024];
149  FILE *f;
150  char *lgu;
151 
152  GNUNET_snprintf(fn, sizeof(fn), "/proc/%u/maps", getpid());
153  if (NULL == (f = fopen(fn, "r")))
154  return NULL;
155  while (NULL != fgets(line, sizeof(line), f))
156  {
157  if ((1 == sscanf(line,
158  "%*x-%*x %*c%*c%*c%*c %*x %*2x:%*2x %*u%*[ ]%1023s",
159  dir)) &&
160  (NULL != (lgu = strstr(dir, current_pd->libname))))
161  {
162  lgu[0] = '\0';
163  fclose(f);
164  return GNUNET_strdup(dir);
165  }
166  }
167  fclose(f);
168  return NULL;
169 }
170 
171 
177 static char *
178 get_path_from_proc_exe()
179 {
180  char fn[64];
181  char lnk[1024];
182  ssize_t size;
183  char *lep;
184 
185  GNUNET_snprintf(fn, sizeof(fn), "/proc/%u/exe", getpid());
186  size = readlink(fn, lnk, sizeof(lnk) - 1);
187  if (size <= 0)
188  {
190  return NULL;
191  }
192  GNUNET_assert(((size_t)size) < sizeof(lnk));
193  lnk[size] = '\0';
194  while ((lnk[size] != '/') && (size > 0))
195  size--;
196  GNUNET_asprintf(&lep, "/%s/libexec/", current_pd->project_dirname);
197  /* test for being in lib/gnunet/libexec/ or lib/MULTIARCH/gnunet/libexec */
198  if ((((size_t)size) > strlen(lep)) &&
199  (0 == strcmp(lep, &lnk[size - strlen(lep)])))
200  size -= strlen(lep) - 1;
201  GNUNET_free(lep);
202  if ((size < 4) || (lnk[size - 4] != '/'))
203  {
204  /* not installed in "/bin/" -- binary path probably useless */
205  return NULL;
206  }
207  lnk[size] = '\0';
208  return GNUNET_strdup(lnk);
209 }
210 #endif
211 
212 
213 #if DARWIN
214 
221 typedef int (*MyNSGetExecutablePathProto) (char *buf, size_t *bufsize);
222 
223 
229 static char *
230 get_path_from_NSGetExecutablePath()
231 {
232  static char zero = '\0';
233  char *path;
234  size_t len;
235  MyNSGetExecutablePathProto func;
236 
237  path = NULL;
238  if (NULL ==
239  (func = (MyNSGetExecutablePathProto)dlsym(RTLD_DEFAULT,
240  "_NSGetExecutablePath")))
241  return NULL;
242  path = &zero;
243  len = 0;
244  /* get the path len, including the trailing \0 */
245  (void)func(path, &len);
246  if (0 == len)
247  return NULL;
248  path = GNUNET_malloc(len);
249  if (0 != func(path, &len))
250  {
251  GNUNET_free(path);
252  return NULL;
253  }
254  len = strlen(path);
255  while ((path[len] != '/') && (len > 0))
256  len--;
257  path[len] = '\0';
258  return path;
259 }
260 
261 
267 static char *
268 get_path_from_dyld_image()
269 {
270  const char *path;
271  char *p;
272  char *s;
273  unsigned int i;
274  int c;
275 
276  c = _dyld_image_count();
277  for (i = 0; i < c; i++)
278  {
279  if (((const void *)_dyld_get_image_header(i)) !=
280  ((const void *)&_mh_dylib_header))
281  continue;
282  path = _dyld_get_image_name(i);
283  if ((NULL == path) || (0 == strlen(path)))
284  continue;
285  p = GNUNET_strdup(path);
286  s = p + strlen(p);
287  while ((s > p) && ('/' != *s))
288  s--;
289  s++;
290  *s = '\0';
291  return p;
292  }
293  return NULL;
294 }
295 #endif
296 
297 
305 static char *
306 get_path_from_PATH(const char *binary)
307 {
308  char *path;
309  char *pos;
310  char *end;
311  char *buf;
312  const char *p;
313 
314  if (NULL == (p = getenv("PATH")))
315  return NULL;
316 
317  path = GNUNET_strdup(p); /* because we write on it */
318 
319  buf = GNUNET_malloc(strlen(path) + strlen(binary) + 1 + 1);
320  pos = path;
321  while (NULL != (end = strchr(pos, PATH_SEPARATOR)))
322  {
323  *end = '\0';
324  sprintf(buf, "%s/%s", pos, binary);
325  if (GNUNET_DISK_file_test(buf) == GNUNET_YES)
326  {
327  pos = GNUNET_strdup(pos);
328  GNUNET_free(buf);
329  GNUNET_free(path);
330  return pos;
331  }
332  pos = end + 1;
333  }
334  sprintf(buf, "%s/%s", pos, binary);
335  if (GNUNET_YES == GNUNET_DISK_file_test(buf))
336  {
337  pos = GNUNET_strdup(pos);
338  GNUNET_free(buf);
339  GNUNET_free(path);
340  return pos;
341  }
342  GNUNET_free(buf);
343  GNUNET_free(path);
344  return NULL;
345 }
346 
347 
354 static char *
356 {
357  const char *p;
358 
359  if ((NULL != current_pd->env_varname) &&
360  (NULL != (p = getenv(current_pd->env_varname))))
361  return GNUNET_strdup(p);
362  if ((NULL != current_pd->env_varname_alt) &&
363  (NULL != (p = getenv(current_pd->env_varname_alt))))
364  return GNUNET_strdup(p);
365  return NULL;
366 }
367 
368 
375 static char *
377 {
378  char *ret;
379 
380  if (NULL != (ret = get_path_from_GNUNET_PREFIX()))
381  return ret;
382 #if LINUX
383  if (NULL != (ret = get_path_from_proc_maps()))
384  return ret;
385  /* try path *first*, before /proc/exe, as /proc/exe can be wrong */
386  if ((NULL != current_pd->binary_name) &&
387  (NULL != (ret = get_path_from_PATH(current_pd->binary_name))))
388  return ret;
389  if (NULL != (ret = get_path_from_proc_exe()))
390  return ret;
391 #endif
392 #if DARWIN
393  if (NULL != (ret = get_path_from_dyld_image()))
394  return ret;
395  if (NULL != (ret = get_path_from_NSGetExecutablePath()))
396  return ret;
397 #endif
398  if ((NULL != current_pd->binary_name) &&
399  (NULL != (ret = get_path_from_PATH(current_pd->binary_name))))
400  return ret;
401  /* other attempts here */
403  _(
404  "Could not determine installation path for %s. Set `%s' environment variable.\n"),
405  current_pd->project_dirname,
406  current_pd->env_varname);
407  return NULL;
408 }
409 
410 
415 static char *
417 {
418  char *ret = NULL;
419 
420 #if LINUX
421  if (NULL != (ret = get_path_from_proc_exe()))
422  return ret;
423 #endif
424 #if DARWIN
425  if (NULL != (ret = get_path_from_NSGetExecutablePath()))
426  return ret;
427 #endif
428  /* other attempts here */
429  return ret;
430 }
431 
432 
438 char *
440 {
441  size_t n;
442  char *dirname;
443  char *execpath = NULL;
444  char *tmp;
445  char *multiarch;
446  char *libdir;
447  int isbasedir;
448 
449  /* if wanted, try to get the current app's bin/ */
450  if (dirkind == GNUNET_OS_IPK_SELF_PREFIX)
451  execpath = os_get_exec_path();
452 
453  /* try to get GNUnet's bin/ or lib/, or if previous was unsuccessful some
454  * guess for the current app */
455  if (NULL == execpath)
456  execpath = os_get_gnunet_path();
457 
458  if (NULL == execpath)
459  return NULL;
460 
461  n = strlen(execpath);
462  if (0 == n)
463  {
464  /* should never happen, but better safe than sorry */
465  GNUNET_free(execpath);
466  return NULL;
467  }
468  /* remove filename itself */
469  while ((n > 1) && (DIR_SEPARATOR == execpath[n - 1]))
470  execpath[--n] = '\0';
471 
472  isbasedir = 1;
473  if ((n > 6) && ((0 == strcasecmp(&execpath[n - 6], "/lib32")) ||
474  (0 == strcasecmp(&execpath[n - 6], "/lib64"))))
475  {
476  if ((GNUNET_OS_IPK_LIBDIR != dirkind) &&
477  (GNUNET_OS_IPK_LIBEXECDIR != dirkind))
478  {
479  /* strip '/lib32' or '/lib64' */
480  execpath[n - 6] = '\0';
481  n -= 6;
482  }
483  else
484  isbasedir = 0;
485  }
486  else if ((n > 4) && ((0 == strcasecmp(&execpath[n - 4], "/bin")) ||
487  (0 == strcasecmp(&execpath[n - 4], "/lib"))))
488  {
489  /* strip '/bin' or '/lib' */
490  execpath[n - 4] = '\0';
491  n -= 4;
492  }
493  multiarch = NULL;
494  if (NULL != (libdir = strstr(execpath, "/lib/")))
495  {
496  /* test for multi-arch path of the form "PREFIX/lib/MULTIARCH/";
497  here we need to re-add 'multiarch' to lib and libexec paths later! */
498  multiarch = &libdir[5];
499  if (NULL == strchr(multiarch, '/'))
500  libdir[0] =
501  '\0'; /* Debian multiarch format, cut of from 'execpath' but preserve in multicarch */
502  else
503  multiarch =
504  NULL; /* maybe not, multiarch still has a '/', which is not OK */
505  }
506  /* in case this was a directory named foo-bin, remove "foo-" */
507  while ((n > 1) && (execpath[n - 1] == DIR_SEPARATOR))
508  execpath[--n] = '\0';
509  switch (dirkind)
510  {
513  dirname = GNUNET_strdup(DIR_SEPARATOR_STR);
514  break;
515 
518  break;
519 
521  if (isbasedir)
522  {
523  GNUNET_asprintf(&tmp,
524  "%s%s%s%s%s%s%s",
525  execpath,
526  DIR_SEPARATOR_STR "lib",
527  (NULL != multiarch) ? DIR_SEPARATOR_STR : "",
528  (NULL != multiarch) ? multiarch : "",
529  DIR_SEPARATOR_STR,
530  current_pd->project_dirname,
531  DIR_SEPARATOR_STR);
533  {
534  GNUNET_free(execpath);
535  return tmp;
536  }
537  GNUNET_free(tmp);
538  tmp = NULL;
539  dirname = NULL;
540  if (4 == sizeof(void *))
541  {
542  GNUNET_asprintf(&dirname,
543  DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR
544  "%s" DIR_SEPARATOR_STR,
545  current_pd->project_dirname);
546  GNUNET_asprintf(&tmp, "%s%s", execpath, dirname);
547  }
548  if (8 == sizeof(void *))
549  {
550  GNUNET_asprintf(&dirname,
551  DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR
552  "%s" DIR_SEPARATOR_STR,
553  current_pd->project_dirname);
554  GNUNET_asprintf(&tmp, "%s%s", execpath, dirname);
555  }
556 
557  if ((NULL != tmp) &&
559  {
560  GNUNET_free(execpath);
561  GNUNET_free_non_null(dirname);
562  return tmp;
563  }
564  GNUNET_free(tmp);
565  GNUNET_free_non_null(dirname);
566  }
567  GNUNET_asprintf(&dirname,
568  DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR,
569  current_pd->project_dirname);
570  break;
571 
573  GNUNET_asprintf(&dirname,
574  DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
575  "%s" DIR_SEPARATOR_STR,
576  current_pd->project_dirname);
577  break;
578 
580  dirname = GNUNET_strdup(DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
581  "locale" DIR_SEPARATOR_STR);
582  break;
583 
585  dirname = GNUNET_strdup(DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
586  "icons" DIR_SEPARATOR_STR);
587  break;
588 
590  GNUNET_asprintf(&dirname,
591  DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
592  "doc" DIR_SEPARATOR_STR
593  "%s" DIR_SEPARATOR_STR,
594  current_pd->project_dirname);
595  break;
596 
598  if (isbasedir)
599  {
600  GNUNET_asprintf(&dirname,
601  DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR
602  "libexec" DIR_SEPARATOR_STR,
603  current_pd->project_dirname);
604  GNUNET_asprintf(&tmp,
605  "%s%s%s%s",
606  execpath,
607  DIR_SEPARATOR_STR "lib" DIR_SEPARATOR_STR,
608  (NULL != multiarch) ? multiarch : "",
609  dirname);
611  {
612  GNUNET_free(execpath);
613  GNUNET_free(dirname);
614  return tmp;
615  }
616  GNUNET_free(tmp);
617  tmp = NULL;
618  dirname = NULL;
619  if (4 == sizeof(void *))
620  {
621  GNUNET_asprintf(&dirname,
622  DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR
623  "%s" DIR_SEPARATOR_STR
624  "libexec" DIR_SEPARATOR_STR,
625  current_pd->project_dirname);
626  GNUNET_asprintf(&tmp, "%s%s", execpath, dirname);
627  }
628  if (8 == sizeof(void *))
629  {
630  GNUNET_asprintf(&dirname,
631  DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR
632  "%s" DIR_SEPARATOR_STR
633  "libexec" DIR_SEPARATOR_STR,
634  current_pd->project_dirname);
635  GNUNET_asprintf(&tmp, "%s%s", execpath, dirname);
636  }
637  if ((NULL != tmp) &&
639  {
640  GNUNET_free(execpath);
641  GNUNET_free_non_null(dirname);
642  return tmp;
643  }
644  GNUNET_free(tmp);
645  GNUNET_free_non_null(dirname);
646  }
647  GNUNET_asprintf(&dirname,
648  DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR
649  "libexec" DIR_SEPARATOR_STR,
650  current_pd->project_dirname);
651  break;
652 
653  default:
654  GNUNET_free(execpath);
655  return NULL;
656  }
657  GNUNET_asprintf(&tmp, "%s%s", execpath, dirname);
658  GNUNET_free(dirname);
659  GNUNET_free(execpath);
660  return tmp;
661 }
662 
663 
672 char *
674 {
675  static char *cache;
676  char *libexecdir;
677  char *binary;
678 
679  if ((DIR_SEPARATOR == progname[0]) ||
680  (GNUNET_YES ==
681  GNUNET_STRINGS_path_is_absolute(progname, GNUNET_NO, NULL, NULL)))
682  return GNUNET_strdup(progname);
683  if (NULL != cache)
684  libexecdir = cache;
685  else
687  if (NULL == libexecdir)
688  return GNUNET_strdup(progname);
689  GNUNET_asprintf(&binary, "%s%s", libexecdir, progname);
690  cache = libexecdir;
691  return binary;
692 }
693 
694 
707 char *
709  const char *progname)
710 {
711  static char *cache;
712  char *binary = NULL;
713  char *path = NULL;
714  size_t path_len;
715 
716  if (GNUNET_YES ==
717  GNUNET_STRINGS_path_is_absolute(progname, GNUNET_NO, NULL, NULL))
718  {
719  return GNUNET_strdup(progname);
720  }
721  if (NULL != cache)
722  path = cache;
723  else
725  "PATHS",
726  "SUID_BINARY_PATH",
727  &path);
728  if ((NULL == path) || (0 == strlen(path)))
729  return GNUNET_OS_get_libexec_binary_path(progname);
730  path_len = strlen(path);
731  GNUNET_asprintf(&binary,
732  "%s%s%s",
733  path,
734  (path[path_len - 1] == DIR_SEPARATOR) ? ""
736  progname);
737  cache = path;
738  return binary;
739 }
740 
741 
758 int
759 GNUNET_OS_check_helper_binary(const char *binary,
760  int check_suid,
761  const char *params)
762 {
763  struct stat statbuf;
764  char *p;
765  char *pf;
766 
767  if ((GNUNET_YES ==
768  GNUNET_STRINGS_path_is_absolute(binary, GNUNET_NO, NULL, NULL)) ||
769  (0 == strncmp(binary, "./", 2)))
770  {
771  p = GNUNET_strdup(binary);
772  }
773  else
774  {
775  p = get_path_from_PATH(binary);
776  if (NULL != p)
777  {
778  GNUNET_asprintf(&pf, "%s/%s", p, binary);
779  GNUNET_free(p);
780  p = pf;
781  }
782  }
783 
784  if (NULL == p)
785  {
787  _("Could not find binary `%s' in PATH!\n"),
788  binary);
789  return GNUNET_SYSERR;
790  }
791  if (0 != access(p, X_OK))
792  {
794  GNUNET_free(p);
795  return GNUNET_SYSERR;
796  }
797 
798  if (0 == getuid())
799  {
800  /* as we run as root, we don't insist on SUID */
801  GNUNET_free(p);
802  return GNUNET_YES;
803  }
804 
805  if (0 != stat(p, &statbuf))
806  {
808  GNUNET_free(p);
809  return GNUNET_SYSERR;
810  }
811  if (check_suid)
812  {
813  (void)params;
814  if ((0 != (statbuf.st_mode & S_ISUID)) && (0 == statbuf.st_uid))
815  {
816  GNUNET_free(p);
817  return GNUNET_YES;
818  }
820  _("Binary `%s' exists, but is not SUID\n"),
821  p);
822  /* binary exists, but not SUID */
823  }
824  GNUNET_free(p);
825  return GNUNET_NO;
826 }
827 
828 
829 /* end of os_installation.c */
static const struct GNUNET_CRYPTO_EcdsaPrivateKey zero
Public key of all zeros.
int GNUNET_DISK_file_test(const char *fil)
Check that fil corresponds to a filename (of a file that exists and that is not a directory)...
Definition: disk.c:541
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:84
Return the directory where translations are installed (share/locale/)
Project-specific data used to help the OS subsystem find installation paths.
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
Like snprintf, just aborts if the buffer is of insufficient size.
Return the directory where libraries are installed.
const char * project_dirname
Name of the project that is used in the "libexec" prefix, For example, "gnunet".
int GNUNET_STRINGS_path_is_absolute(const char *filename, int can_be_uri, int *r_is_uri, char **r_uri_scheme)
Check whether filename is absolute or not, and if it&#39;s an URI.
Definition: strings.c:1109
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static char * os_get_gnunet_path()
get the path to GNUnet bin/ or lib/, prefering the lib/ path
int GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition: disk.c:500
const char * env_varname_alt
Alternative name of an environment variable that can be used to override installation path detection...
#define GNUNET_NO
Definition: gnunet_common.h:78
#define bindtextdomain(Domainname, Dirname)
Definition: gettext.h:57
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_default(void)
Return default project data used by &#39;libgnunetutil&#39; for GNUnet.
#define GNUNET_free_non_null(ptr)
Free the memory pointed to by ptr if ptr is not NULL.
int GNUNET_OS_check_helper_binary(const char *binary, int check_suid, const char *params)
Check whether an executable exists and possibly if the suid bit is set on the file.
static int ret
Final status code.
Definition: gnunet-arm.c:89
#define PATH_SEPARATOR
Definition: platform.h:169
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define _(String)
GNU gettext support macro.
Definition: platform.h:181
Return the "PREFIX" directory given to configure.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf, just portable.
const char * env_varname
Name of an environment variable that can be used to override installation path detection, for example "GNUNET_PREFIX".
#define LOG(kind,...)
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static char * line
Desired phone line (string to be converted to a hash).
Return the prefix of the path with documentation files, including the license (share/doc/gnunet/).
const char * libname
Name of a library that is installed in the "lib/" directory of the project, such as "libgnunetutil"...
static char * fn
Filename of the unique file.
#define DIR_SEPARATOR_STR
Definition: platform.h:168
char * GNUNET_OS_installation_get_path(enum GNUNET_OS_InstallationPathKind dirkind)
get the path to a specific GNUnet installation directory or, with GNUNET_OS_IPK_SELF_PREFIX, the current running apps installation directory
static const struct GNUNET_OS_ProjectData default_pd
Default project data used for installation path detection for GNUnet (core).
static char buf[2048]
const char * binary_name
Name of a project-specific binary that should be in "$PREFIX/bin/".
char * GNUNET_OS_get_suid_binary_path(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *progname)
Given the name of a helper, service or daemon binary construct the full path to the binary using the ...
Return the directory where helper binaries are installed (lib/gnunet/libexec/)
GNUNET_OS_InstallationPathKind
Possible installation paths to request.
int GNUNET_CONFIGURATION_get_value_string(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, char **value)
Get a configuration value that should be a string.
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:104
#define DIR_SEPARATOR
Definition: platform.h:167
static char * os_get_exec_path()
get the path to current app&#39;s bin/
#define GNUNET_SYSERR
Definition: gnunet_common.h:76
static unsigned int size
Size of the "table".
Definition: peer.c:66
char * getenv()
static const struct GNUNET_OS_ProjectData * current_pd
Which project data do we currently use for installation path detection? Never NULL.
Return the installation directory of this application, not the one of the overall GNUnet installation...
static int gettextinit
Wether or not gettext has been initialized for the library.
#define LOG_STRERROR_FILE(kind, syscall, filename)
Return the directory where the program binaries are installed.
static char * get_path_from_PATH(const char *binary)
Return the actual path to a file found in the current PATH environment variable.
static struct GNUNET_CONTAINER_MultiHashMap32 * cache
Hashmap to maintain cache.
configuration data
Definition: configuration.c:83
static char * get_path_from_GNUNET_PREFIX()
Try to obtain the installation path using the "GNUNET_PREFIX" environment variable.
#define GNUNET_log(kind,...)
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get()
char * GNUNET_OS_get_libexec_binary_path(const char *progname)
Given the name of a gnunet-helper, gnunet-service or gnunet-daemon binary, try to prefix it with the ...
void GNUNET_OS_init(const struct GNUNET_OS_ProjectData *pd)
Setup OS subsystem with project data.
#define GNUNET_YES
Definition: gnunet_common.h:77
Return the prefix of the path with application icons (share/icons/).
#define GNUNET_malloc(size)
Wrapper around malloc.
Return the directory where data is installed (share/gnunet/)
#define GNUNET_free(ptr)
Wrapper around free.
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...