GNUnet  0.11.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  {
189  LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "readlink", fn);
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 
211 
212 #endif
213 
214 
215 #if DARWIN
216 
223 typedef int (*MyNSGetExecutablePathProto) (char *buf, size_t *bufsize);
224 
225 
231 static char *
232 get_path_from_NSGetExecutablePath ()
233 {
234  static char zero = '\0';
235  char *path;
236  size_t len;
237  MyNSGetExecutablePathProto func;
238 
239  path = NULL;
240  if (NULL ==
241  (func = (MyNSGetExecutablePathProto) dlsym (RTLD_DEFAULT,
242  "_NSGetExecutablePath")))
243  return NULL;
244  path = &zero;
245  len = 0;
246  /* get the path len, including the trailing \0 */
247  (void) func (path, &len);
248  if (0 == len)
249  return NULL;
250  path = GNUNET_malloc (len);
251  if (0 != func (path, &len))
252  {
253  GNUNET_free (path);
254  return NULL;
255  }
256  len = strlen (path);
257  while ((path[len] != '/') && (len > 0))
258  len--;
259  path[len] = '\0';
260  return path;
261 }
262 
263 
269 static char *
270 get_path_from_dyld_image ()
271 {
272  const char *path;
273  char *p;
274  char *s;
275  unsigned int i;
276  int c;
277 
278  c = _dyld_image_count ();
279  for (i = 0; i < c; i++)
280  {
281  if (((const void *) _dyld_get_image_header (i)) !=
282  ((const void *) &_mh_dylib_header))
283  continue;
284  path = _dyld_get_image_name (i);
285  if ((NULL == path) || (0 == strlen (path)))
286  continue;
287  p = GNUNET_strdup (path);
288  s = p + strlen (p);
289  while ((s > p) && ('/' != *s))
290  s--;
291  s++;
292  *s = '\0';
293  return p;
294  }
295  return NULL;
296 }
297 
298 
299 #endif
300 
301 
309 static char *
310 get_path_from_PATH (const char *binary)
311 {
312  char *path;
313  char *pos;
314  char *end;
315  char *buf;
316  const char *p;
317 
318  if (NULL == (p = getenv ("PATH")))
319  return NULL;
320 
321  path = GNUNET_strdup (p); /* because we write on it */
322 
323  buf = GNUNET_malloc (strlen (path) + strlen (binary) + 1 + 1);
324  pos = path;
325  while (NULL != (end = strchr (pos, PATH_SEPARATOR)))
326  {
327  *end = '\0';
328  sprintf (buf, "%s/%s", pos, binary);
329  if (GNUNET_DISK_file_test (buf) == GNUNET_YES)
330  {
331  pos = GNUNET_strdup (pos);
332  GNUNET_free (buf);
333  GNUNET_free (path);
334  return pos;
335  }
336  pos = end + 1;
337  }
338  sprintf (buf, "%s/%s", pos, binary);
339  if (GNUNET_YES == GNUNET_DISK_file_test (buf))
340  {
341  pos = GNUNET_strdup (pos);
342  GNUNET_free (buf);
343  GNUNET_free (path);
344  return pos;
345  }
346  GNUNET_free (buf);
347  GNUNET_free (path);
348  return NULL;
349 }
350 
351 
358 static char *
360 {
361  const char *p;
362 
363  if ((NULL != current_pd->env_varname) &&
364  (NULL != (p = getenv (current_pd->env_varname))))
365  return GNUNET_strdup (p);
366  if ((NULL != current_pd->env_varname_alt) &&
367  (NULL != (p = getenv (current_pd->env_varname_alt))))
368  return GNUNET_strdup (p);
369  return NULL;
370 }
371 
372 
379 static char *
381 {
382  char *ret;
383 
384  if (NULL != (ret = get_path_from_GNUNET_PREFIX ()))
385  return ret;
386 #if LINUX
387  if (NULL != (ret = get_path_from_proc_maps ()))
388  return ret;
389  /* try path *first*, before /proc/exe, as /proc/exe can be wrong */
390  if ((NULL != current_pd->binary_name) &&
391  (NULL != (ret = get_path_from_PATH (current_pd->binary_name))))
392  return ret;
393  if (NULL != (ret = get_path_from_proc_exe ()))
394  return ret;
395 #endif
396 #if DARWIN
397  if (NULL != (ret = get_path_from_dyld_image ()))
398  return ret;
399  if (NULL != (ret = get_path_from_NSGetExecutablePath ()))
400  return ret;
401 #endif
402  if ((NULL != current_pd->binary_name) &&
403  (NULL != (ret = get_path_from_PATH (current_pd->binary_name))))
404  return ret;
405  /* other attempts here */
407  _ (
408  "Could not determine installation path for %s. Set `%s' environment variable.\n"),
409  current_pd->project_dirname,
410  current_pd->env_varname);
411  return NULL;
412 }
413 
414 
419 static char *
421 {
422  char *ret = NULL;
423 
424 #if LINUX
425  if (NULL != (ret = get_path_from_proc_exe ()))
426  return ret;
427 #endif
428 #if DARWIN
429  if (NULL != (ret = get_path_from_NSGetExecutablePath ()))
430  return ret;
431 #endif
432  /* other attempts here */
433  return ret;
434 }
435 
436 
442 char *
444 {
445  size_t n;
446  char *dirname;
447  char *execpath = NULL;
448  char *tmp;
449  char *multiarch;
450  char *libdir;
451  int isbasedir;
452 
453  /* if wanted, try to get the current app's bin/ */
454  if (dirkind == GNUNET_OS_IPK_SELF_PREFIX)
455  execpath = os_get_exec_path ();
456 
457  /* try to get GNUnet's bin/ or lib/, or if previous was unsuccessful some
458  * guess for the current app */
459  if (NULL == execpath)
460  execpath = os_get_gnunet_path ();
461 
462  if (NULL == execpath)
463  return NULL;
464 
465  n = strlen (execpath);
466  if (0 == n)
467  {
468  /* should never happen, but better safe than sorry */
469  GNUNET_free (execpath);
470  return NULL;
471  }
472  /* remove filename itself */
473  while ((n > 1) && (DIR_SEPARATOR == execpath[n - 1]))
474  execpath[--n] = '\0';
475 
476  isbasedir = 1;
477  if ((n > 6) && ((0 == strcasecmp (&execpath[n - 6], "/lib32")) ||
478  (0 == strcasecmp (&execpath[n - 6], "/lib64"))))
479  {
480  if ((GNUNET_OS_IPK_LIBDIR != dirkind) &&
481  (GNUNET_OS_IPK_LIBEXECDIR != dirkind))
482  {
483  /* strip '/lib32' or '/lib64' */
484  execpath[n - 6] = '\0';
485  n -= 6;
486  }
487  else
488  isbasedir = 0;
489  }
490  else if ((n > 4) && ((0 == strcasecmp (&execpath[n - 4], "/bin")) ||
491  (0 == strcasecmp (&execpath[n - 4], "/lib"))))
492  {
493  /* strip '/bin' or '/lib' */
494  execpath[n - 4] = '\0';
495  n -= 4;
496  }
497  multiarch = NULL;
498  if (NULL != (libdir = strstr (execpath, "/lib/")))
499  {
500  /* test for multi-arch path of the form "PREFIX/lib/MULTIARCH/";
501  here we need to re-add 'multiarch' to lib and libexec paths later! */
502  multiarch = &libdir[5];
503  if (NULL == strchr (multiarch, '/'))
504  libdir[0] =
505  '\0'; /* Debian multiarch format, cut of from 'execpath' but preserve in multicarch */
506  else
507  multiarch =
508  NULL; /* maybe not, multiarch still has a '/', which is not OK */
509  }
510  /* in case this was a directory named foo-bin, remove "foo-" */
511  while ((n > 1) && (execpath[n - 1] == DIR_SEPARATOR))
512  execpath[--n] = '\0';
513  switch (dirkind)
514  {
517  dirname = GNUNET_strdup (DIR_SEPARATOR_STR);
518  break;
519 
522  break;
523 
525  if (isbasedir)
526  {
527  GNUNET_asprintf (&tmp,
528  "%s%s%s%s%s%s%s",
529  execpath,
530  DIR_SEPARATOR_STR "lib",
531  (NULL != multiarch) ? DIR_SEPARATOR_STR : "",
532  (NULL != multiarch) ? multiarch : "",
533  DIR_SEPARATOR_STR,
534  current_pd->project_dirname,
535  DIR_SEPARATOR_STR);
537  {
538  GNUNET_free (execpath);
539  return tmp;
540  }
541  GNUNET_free (tmp);
542  tmp = NULL;
543  dirname = NULL;
544  if (4 == sizeof(void *))
545  {
546  GNUNET_asprintf (&dirname,
547  DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR
548  "%s" DIR_SEPARATOR_STR,
549  current_pd->project_dirname);
550  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
551  }
552  if (8 == sizeof(void *))
553  {
554  GNUNET_asprintf (&dirname,
555  DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR
556  "%s" DIR_SEPARATOR_STR,
557  current_pd->project_dirname);
558  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
559  }
560 
561  if ((NULL != tmp) &&
563  {
564  GNUNET_free (execpath);
565  GNUNET_free_non_null (dirname);
566  return tmp;
567  }
568  GNUNET_free (tmp);
569  GNUNET_free_non_null (dirname);
570  }
571  GNUNET_asprintf (&dirname,
572  DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR,
573  current_pd->project_dirname);
574  break;
575 
577  GNUNET_asprintf (&dirname,
578  DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
579  "%s" DIR_SEPARATOR_STR,
580  current_pd->project_dirname);
581  break;
582 
584  dirname = GNUNET_strdup (DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
585  "locale" DIR_SEPARATOR_STR);
586  break;
587 
589  dirname = GNUNET_strdup (DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
590  "icons" DIR_SEPARATOR_STR);
591  break;
592 
594  GNUNET_asprintf (&dirname,
595  DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
596  "doc" DIR_SEPARATOR_STR
597  "%s" DIR_SEPARATOR_STR,
598  current_pd->project_dirname);
599  break;
600 
602  if (isbasedir)
603  {
604  GNUNET_asprintf (&dirname,
605  DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR
606  "libexec" DIR_SEPARATOR_STR,
607  current_pd->project_dirname);
608  GNUNET_asprintf (&tmp,
609  "%s%s%s%s",
610  execpath,
611  DIR_SEPARATOR_STR "lib" DIR_SEPARATOR_STR,
612  (NULL != multiarch) ? multiarch : "",
613  dirname);
615  {
616  GNUNET_free (execpath);
617  GNUNET_free (dirname);
618  return tmp;
619  }
620  GNUNET_free (tmp);
621  tmp = NULL;
622  dirname = NULL;
623  if (4 == sizeof(void *))
624  {
625  GNUNET_asprintf (&dirname,
626  DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR
627  "%s" DIR_SEPARATOR_STR
628  "libexec" DIR_SEPARATOR_STR,
629  current_pd->project_dirname);
630  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
631  }
632  if (8 == sizeof(void *))
633  {
634  GNUNET_asprintf (&dirname,
635  DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR
636  "%s" DIR_SEPARATOR_STR
637  "libexec" DIR_SEPARATOR_STR,
638  current_pd->project_dirname);
639  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
640  }
641  if ((NULL != tmp) &&
643  {
644  GNUNET_free (execpath);
645  GNUNET_free_non_null (dirname);
646  return tmp;
647  }
648  GNUNET_free (tmp);
649  GNUNET_free_non_null (dirname);
650  }
651  GNUNET_asprintf (&dirname,
652  DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR
653  "libexec" DIR_SEPARATOR_STR,
654  current_pd->project_dirname);
655  break;
656 
657  default:
658  GNUNET_free (execpath);
659  return NULL;
660  }
661  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
662  GNUNET_free (dirname);
663  GNUNET_free (execpath);
664  return tmp;
665 }
666 
667 
676 char *
677 GNUNET_OS_get_libexec_binary_path (const char *progname)
678 {
679  static char *cache;
680  char *libexecdir;
681  char *binary;
682 
683  if ((DIR_SEPARATOR == progname[0]) ||
684  (GNUNET_YES ==
685  GNUNET_STRINGS_path_is_absolute (progname, GNUNET_NO, NULL, NULL)))
686  return GNUNET_strdup (progname);
687  if (NULL != cache)
688  libexecdir = cache;
689  else
691  if (NULL == libexecdir)
692  return GNUNET_strdup (progname);
693  GNUNET_asprintf (&binary, "%s%s", libexecdir, progname);
694  cache = libexecdir;
695  return binary;
696 }
697 
698 
711 char *
713  const char *progname)
714 {
715  static char *cache;
716  char *binary = NULL;
717  char *path = NULL;
718  size_t path_len;
719 
720  if (GNUNET_YES ==
721  GNUNET_STRINGS_path_is_absolute (progname, GNUNET_NO, NULL, NULL))
722  {
723  return GNUNET_strdup (progname);
724  }
725  if (NULL != cache)
726  path = cache;
727  else
729  "PATHS",
730  "SUID_BINARY_PATH",
731  &path);
732  if ((NULL == path) || (0 == strlen (path)))
733  return GNUNET_OS_get_libexec_binary_path (progname);
734  path_len = strlen (path);
735  GNUNET_asprintf (&binary,
736  "%s%s%s",
737  path,
738  (path[path_len - 1] == DIR_SEPARATOR) ? ""
740  progname);
741  cache = path;
742  return binary;
743 }
744 
745 
762 int
763 GNUNET_OS_check_helper_binary (const char *binary,
764  int check_suid,
765  const char *params)
766 {
767  struct stat statbuf;
768  char *p;
769  char *pf;
770 
771  if ((GNUNET_YES ==
772  GNUNET_STRINGS_path_is_absolute (binary, GNUNET_NO, NULL, NULL)) ||
773  (0 == strncmp (binary, "./", 2)))
774  {
775  p = GNUNET_strdup (binary);
776  }
777  else
778  {
779  p = get_path_from_PATH (binary);
780  if (NULL != p)
781  {
782  GNUNET_asprintf (&pf, "%s/%s", p, binary);
783  GNUNET_free (p);
784  p = pf;
785  }
786  }
787 
788  if (NULL == p)
789  {
791  _ ("Could not find binary `%s' in PATH!\n"),
792  binary);
793  return GNUNET_SYSERR;
794  }
795  if (0 != access (p, X_OK))
796  {
798  GNUNET_free (p);
799  return GNUNET_SYSERR;
800  }
801 
802  if (0 == getuid ())
803  {
804  /* as we run as root, we don't insist on SUID */
805  GNUNET_free (p);
806  return GNUNET_YES;
807  }
808 
809  if (0 != stat (p, &statbuf))
810  {
812  GNUNET_free (p);
813  return GNUNET_SYSERR;
814  }
815  if (check_suid)
816  {
817  (void) params;
818  if ((0 != (statbuf.st_mode & S_ISUID)) && (0 == statbuf.st_uid))
819  {
820  GNUNET_free (p);
821  return GNUNET_YES;
822  }
824  _ ("Binary `%s' exists, but is not SUID\n"),
825  p);
826  /* binary exists, but not SUID */
827  }
828  GNUNET_free (p);
829  return GNUNET_NO;
830 }
831 
832 
833 /* 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:544
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:89
Return the directory where translations are installed (share/locale/)
Project-specific data used to help the OS subsystem find installation paths.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
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:1108
#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:503
const char * env_varname_alt
Alternative name of an environment variable that can be used to override installation path detection...
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
#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.
#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.
#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:67
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:85
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...