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  .agpl_url = GNUNET_AGPL_URL,
74 };
75 
81 
87 static int gettextinit = 0;
88 
92 const struct GNUNET_OS_ProjectData *
94 {
95  return &default_pd;
96 }
97 
98 
102 const struct GNUNET_OS_ProjectData *
104 {
105  if (0 == gettextinit)
106  {
108  if (NULL != path)
109  bindtextdomain (PACKAGE, path);
110  GNUNET_free (path);
111  gettextinit = 1;
112  }
113  return current_pd;
114 }
115 
116 
122 void
124 {
125  if (0 == gettextinit)
126  {
128  if (NULL != path)
129  bindtextdomain (PACKAGE, path);
130  GNUNET_free (path);
131  gettextinit = 1;
132  }
133  GNUNET_assert (NULL != pd);
134  current_pd = pd;
135 }
136 
137 
138 #ifdef __linux__
139 
144 static char *
145 get_path_from_proc_maps ()
146 {
147  char fn[64];
148  char line[1024];
149  char dir[1024];
150  FILE *f;
151  char *lgu;
152 
153  if (NULL == current_pd->libname)
154  return NULL;
155  GNUNET_snprintf (fn, sizeof(fn), "/proc/%u/maps", getpid ());
156  if (NULL == (f = fopen (fn, "r")))
157  return NULL;
158  while (NULL != fgets (line, sizeof(line), f))
159  {
160  if ((1 == sscanf (line,
161  "%*x-%*x %*c%*c%*c%*c %*x %*2x:%*2x %*u%*[ ]%1023s",
162  dir)) &&
163  (NULL != (lgu = strstr (dir, current_pd->libname))))
164  {
165  lgu[0] = '\0';
166  fclose (f);
167  return GNUNET_strdup (dir);
168  }
169  }
170  fclose (f);
171  return NULL;
172 }
173 
174 
180 static char *
181 get_path_from_proc_exe ()
182 {
183  char fn[64];
184  char lnk[1024];
185  ssize_t size;
186  char *lep;
187 
188  GNUNET_snprintf (fn, sizeof(fn), "/proc/%u/exe", getpid ());
189  size = readlink (fn, lnk, sizeof(lnk) - 1);
190  if (size <= 0)
191  {
192  LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "readlink", fn);
193  return NULL;
194  }
195  GNUNET_assert (((size_t) size) < sizeof(lnk));
196  lnk[size] = '\0';
197  while ((lnk[size] != '/') && (size > 0))
198  size--;
199  GNUNET_asprintf (&lep, "/%s/libexec/", current_pd->project_dirname);
200  /* test for being in lib/gnunet/libexec/ or lib/MULTIARCH/gnunet/libexec */
201  if ((((size_t) size) > strlen (lep)) &&
202  (0 == strcmp (lep, &lnk[size - strlen (lep)])))
203  size -= strlen (lep) - 1;
204  GNUNET_free (lep);
205  if ((size < 4) || (lnk[size - 4] != '/'))
206  {
207  /* not installed in "/bin/" -- binary path probably useless */
208  return NULL;
209  }
210  lnk[size] = '\0';
211  return GNUNET_strdup (lnk);
212 }
213 
214 
215 #endif
216 
217 
218 #if DARWIN
219 
226 typedef int (*MyNSGetExecutablePathProto) (char *buf, size_t *bufsize);
227 
228 
234 static char *
235 get_path_from_NSGetExecutablePath ()
236 {
237  static char zero = '\0';
238  char *path;
239  size_t len;
240  MyNSGetExecutablePathProto func;
241 
242  path = NULL;
243  if (NULL ==
244  (func = (MyNSGetExecutablePathProto) dlsym (RTLD_DEFAULT,
245  "_NSGetExecutablePath")))
246  return NULL;
247  path = &zero;
248  len = 0;
249  /* get the path len, including the trailing \0 */
250  (void) func (path, &len);
251  if (0 == len)
252  return NULL;
253  path = GNUNET_malloc (len);
254  if (0 != func (path, &len))
255  {
256  GNUNET_free (path);
257  return NULL;
258  }
259  len = strlen (path);
260  while ((path[len] != '/') && (len > 0))
261  len--;
262  path[len] = '\0';
263  return path;
264 }
265 
266 
272 static char *
273 get_path_from_dyld_image ()
274 {
275  const char *path;
276  char *p;
277  char *s;
278  unsigned int i;
279  int c;
280 
281  c = _dyld_image_count ();
282  for (i = 0; i < c; i++)
283  {
284  if (((const void *) _dyld_get_image_header (i)) !=
285  ((const void *) &_mh_dylib_header))
286  continue;
287  path = _dyld_get_image_name (i);
288  if ((NULL == path) || (0 == strlen (path)))
289  continue;
290  p = GNUNET_strdup (path);
291  s = p + strlen (p);
292  while ((s > p) && ('/' != *s))
293  s--;
294  s++;
295  *s = '\0';
296  return p;
297  }
298  return NULL;
299 }
300 
301 
302 #endif
303 
304 
312 static char *
313 get_path_from_PATH (const char *binary)
314 {
315  char *path;
316  char *pos;
317  char *end;
318  char *buf;
319  const char *p;
320 
321  if (NULL == (p = getenv ("PATH")))
322  return NULL;
323 
324  path = GNUNET_strdup (p); /* because we write on it */
325 
326  buf = GNUNET_malloc (strlen (path) + strlen (binary) + 1 + 1);
327  pos = path;
328  while (NULL != (end = strchr (pos, PATH_SEPARATOR)))
329  {
330  *end = '\0';
331  sprintf (buf, "%s/%s", pos, binary);
332  if (GNUNET_DISK_file_test (buf) == GNUNET_YES)
333  {
334  pos = GNUNET_strdup (pos);
335  GNUNET_free (buf);
336  GNUNET_free (path);
337  return pos;
338  }
339  pos = end + 1;
340  }
341  sprintf (buf, "%s/%s", pos, binary);
342  if (GNUNET_YES == GNUNET_DISK_file_test (buf))
343  {
344  pos = GNUNET_strdup (pos);
345  GNUNET_free (buf);
346  GNUNET_free (path);
347  return pos;
348  }
349  GNUNET_free (buf);
350  GNUNET_free (path);
351  return NULL;
352 }
353 
354 
361 static char *
363 {
364  const char *p;
365 
366  if ((NULL != current_pd->env_varname) &&
367  (NULL != (p = getenv (current_pd->env_varname))))
368  return GNUNET_strdup (p);
369  if ((NULL != current_pd->env_varname_alt) &&
370  (NULL != (p = getenv (current_pd->env_varname_alt))))
371  return GNUNET_strdup (p);
372  return NULL;
373 }
374 
375 
382 static char *
384 {
385  char *ret;
386 
387  if (NULL != (ret = get_path_from_GNUNET_PREFIX ()))
388  return ret;
389 #ifdef __linux__
390  if (NULL != (ret = get_path_from_proc_maps ()))
391  return ret;
392  /* try path *first*, before /proc/exe, as /proc/exe can be wrong */
393  if ((NULL != current_pd->binary_name) &&
394  (NULL != (ret = get_path_from_PATH (current_pd->binary_name))))
395  return ret;
396  if (NULL != (ret = get_path_from_proc_exe ()))
397  return ret;
398 #endif
399 #if DARWIN
400  if (NULL != (ret = get_path_from_dyld_image ()))
401  return ret;
402  if (NULL != (ret = get_path_from_NSGetExecutablePath ()))
403  return ret;
404 #endif
405  if ((NULL != current_pd->binary_name) &&
406  (NULL != (ret = get_path_from_PATH (current_pd->binary_name))))
407  return ret;
408  /* other attempts here */
410  _ (
411  "Could not determine installation path for %s. Set `%s' environment variable.\n"),
412  current_pd->project_dirname,
413  current_pd->env_varname);
414  return NULL;
415 }
416 
417 
422 static char *
424 {
425  char *ret = NULL;
426 
427 #ifdef __linux__
428  if (NULL != (ret = get_path_from_proc_exe ()))
429  return ret;
430 #endif
431 #if DARWIN
432  if (NULL != (ret = get_path_from_NSGetExecutablePath ()))
433  return ret;
434 #endif
435  /* other attempts here */
436  return ret;
437 }
438 
439 
445 char *
447 {
448  size_t n;
449  char *dirname;
450  char *execpath = NULL;
451  char *tmp;
452  char *multiarch;
453  char *libdir;
454  int isbasedir;
455 
456  /* if wanted, try to get the current app's bin/ */
457  if (dirkind == GNUNET_OS_IPK_SELF_PREFIX)
458  execpath = os_get_exec_path ();
459 
460  /* try to get GNUnet's bin/ or lib/, or if previous was unsuccessful some
461  * guess for the current app */
462  if (NULL == execpath)
463  execpath = os_get_gnunet_path ();
464 
465  if (NULL == execpath)
466  return NULL;
467 
468  n = strlen (execpath);
469  if (0 == n)
470  {
471  /* should never happen, but better safe than sorry */
472  GNUNET_free (execpath);
473  return NULL;
474  }
475  /* remove filename itself */
476  while ((n > 1) && (DIR_SEPARATOR == execpath[n - 1]))
477  execpath[--n] = '\0';
478 
479  isbasedir = 1;
480  if ((n > 6) && ((0 == strcasecmp (&execpath[n - 6], "/lib32")) ||
481  (0 == strcasecmp (&execpath[n - 6], "/lib64"))))
482  {
483  if ((GNUNET_OS_IPK_LIBDIR != dirkind) &&
484  (GNUNET_OS_IPK_LIBEXECDIR != dirkind))
485  {
486  /* strip '/lib32' or '/lib64' */
487  execpath[n - 6] = '\0';
488  n -= 6;
489  }
490  else
491  isbasedir = 0;
492  }
493  else if ((n > 4) && ((0 == strcasecmp (&execpath[n - 4], "/bin")) ||
494  (0 == strcasecmp (&execpath[n - 4], "/lib"))))
495  {
496  /* strip '/bin' or '/lib' */
497  execpath[n - 4] = '\0';
498  n -= 4;
499  }
500  multiarch = NULL;
501  if (NULL != (libdir = strstr (execpath, "/lib/")))
502  {
503  /* test for multi-arch path of the form "PREFIX/lib/MULTIARCH/";
504  here we need to re-add 'multiarch' to lib and libexec paths later! */
505  multiarch = &libdir[5];
506  if (NULL == strchr (multiarch, '/'))
507  libdir[0] =
508  '\0'; /* Debian multiarch format, cut of from 'execpath' but preserve in multicarch */
509  else
510  multiarch =
511  NULL; /* maybe not, multiarch still has a '/', which is not OK */
512  }
513  /* in case this was a directory named foo-bin, remove "foo-" */
514  while ((n > 1) && (execpath[n - 1] == DIR_SEPARATOR))
515  execpath[--n] = '\0';
516  switch (dirkind)
517  {
520  dirname = GNUNET_strdup (DIR_SEPARATOR_STR);
521  break;
522 
525  break;
526 
528  if (isbasedir)
529  {
530  GNUNET_asprintf (&tmp,
531  "%s%s%s%s%s%s%s",
532  execpath,
533  DIR_SEPARATOR_STR "lib",
534  (NULL != multiarch) ? DIR_SEPARATOR_STR : "",
535  (NULL != multiarch) ? multiarch : "",
536  DIR_SEPARATOR_STR,
537  current_pd->project_dirname,
538  DIR_SEPARATOR_STR);
540  {
541  GNUNET_free (execpath);
542  return tmp;
543  }
544  GNUNET_free (tmp);
545  tmp = NULL;
546  dirname = NULL;
547  if (4 == sizeof(void *))
548  {
549  GNUNET_asprintf (&dirname,
550  DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR
551  "%s" DIR_SEPARATOR_STR,
552  current_pd->project_dirname);
553  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
554  }
555  if (8 == sizeof(void *))
556  {
557  GNUNET_asprintf (&dirname,
558  DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR
559  "%s" DIR_SEPARATOR_STR,
560  current_pd->project_dirname);
561  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
562  }
563 
564  if ((NULL != tmp) &&
566  {
567  GNUNET_free (execpath);
568  GNUNET_free (dirname);
569  return tmp;
570  }
571  GNUNET_free (tmp);
572  GNUNET_free (dirname);
573  }
574  GNUNET_asprintf (&dirname,
575  DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR,
576  current_pd->project_dirname);
577  break;
578 
580  GNUNET_asprintf (&dirname,
581  DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
582  "%s" DIR_SEPARATOR_STR,
583  current_pd->project_dirname);
584  break;
585 
587  dirname = GNUNET_strdup (DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
588  "locale" DIR_SEPARATOR_STR);
589  break;
590 
592  dirname = GNUNET_strdup (DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
593  "icons" DIR_SEPARATOR_STR);
594  break;
595 
597  GNUNET_asprintf (&dirname,
598  DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR
599  "doc" DIR_SEPARATOR_STR
600  "%s" DIR_SEPARATOR_STR,
601  current_pd->project_dirname);
602  break;
603 
605  if (isbasedir)
606  {
607  GNUNET_asprintf (&dirname,
608  DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR
609  "libexec" DIR_SEPARATOR_STR,
610  current_pd->project_dirname);
611  GNUNET_asprintf (&tmp,
612  "%s%s%s%s",
613  execpath,
614  DIR_SEPARATOR_STR "lib" DIR_SEPARATOR_STR,
615  (NULL != multiarch) ? multiarch : "",
616  dirname);
617  GNUNET_free (dirname);
619  {
620  GNUNET_free (execpath);
621  return tmp;
622  }
623  GNUNET_free (tmp);
624  tmp = NULL;
625  dirname = NULL;
626  if (4 == sizeof(void *))
627  {
628  GNUNET_asprintf (&dirname,
629  DIR_SEPARATOR_STR "lib32" DIR_SEPARATOR_STR
630  "%s" DIR_SEPARATOR_STR
631  "libexec" DIR_SEPARATOR_STR,
632  current_pd->project_dirname);
633  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
634  }
635  if (8 == sizeof(void *))
636  {
637  GNUNET_asprintf (&dirname,
638  DIR_SEPARATOR_STR "lib64" DIR_SEPARATOR_STR
639  "%s" DIR_SEPARATOR_STR
640  "libexec" DIR_SEPARATOR_STR,
641  current_pd->project_dirname);
642  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
643  }
644  if ((NULL != tmp) &&
646  {
647  GNUNET_free (execpath);
648  GNUNET_free (dirname);
649  return tmp;
650  }
651  GNUNET_free (tmp);
652  GNUNET_free (dirname);
653  }
654  GNUNET_asprintf (&dirname,
655  DIR_SEPARATOR_STR "%s" DIR_SEPARATOR_STR
656  "libexec" DIR_SEPARATOR_STR,
657  current_pd->project_dirname);
658  break;
659 
660  default:
661  GNUNET_free (execpath);
662  return NULL;
663  }
664  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
665  GNUNET_free (dirname);
666  GNUNET_free (execpath);
667  return tmp;
668 }
669 
670 
679 char *
680 GNUNET_OS_get_libexec_binary_path (const char *progname)
681 {
682  static char *cache;
683  char *libexecdir;
684  char *binary;
685 
686  if ((DIR_SEPARATOR == progname[0]) ||
687  (GNUNET_YES ==
688  GNUNET_STRINGS_path_is_absolute (progname, GNUNET_NO, NULL, NULL)))
689  return GNUNET_strdup (progname);
690  if (NULL != cache)
691  libexecdir = cache;
692  else
694  if (NULL == libexecdir)
695  return GNUNET_strdup (progname);
696  GNUNET_asprintf (&binary, "%s%s", libexecdir, progname);
697  cache = libexecdir;
698  return binary;
699 }
700 
701 
714 char *
716  const char *progname)
717 {
718  static char *cache;
719  char *binary = NULL;
720  char *path = NULL;
721  size_t path_len;
722 
723  if (GNUNET_YES ==
724  GNUNET_STRINGS_path_is_absolute (progname, GNUNET_NO, NULL, NULL))
725  {
726  return GNUNET_strdup (progname);
727  }
728  if (NULL != cache)
729  path = cache;
730  else
732  "PATHS",
733  "SUID_BINARY_PATH",
734  &path);
735  if ((NULL == path) || (0 == strlen (path)))
736  return GNUNET_OS_get_libexec_binary_path (progname);
737  path_len = strlen (path);
738  GNUNET_asprintf (&binary,
739  "%s%s%s",
740  path,
741  (path[path_len - 1] == DIR_SEPARATOR) ? ""
743  progname);
744  cache = path;
745  return binary;
746 }
747 
748 
765 int
766 GNUNET_OS_check_helper_binary (const char *binary,
767  int check_suid,
768  const char *params)
769 {
770  struct stat statbuf;
771  char *p;
772  char *pf;
773 
774  if ((GNUNET_YES ==
775  GNUNET_STRINGS_path_is_absolute (binary, GNUNET_NO, NULL, NULL)) ||
776  (0 == strncmp (binary, "./", 2)))
777  {
778  p = GNUNET_strdup (binary);
779  }
780  else
781  {
782  p = get_path_from_PATH (binary);
783  if (NULL != p)
784  {
785  GNUNET_asprintf (&pf, "%s/%s", p, binary);
786  GNUNET_free (p);
787  p = pf;
788  }
789  }
790 
791  if (NULL == p)
792  {
794  _ ("Could not find binary `%s' in PATH!\n"),
795  binary);
796  return GNUNET_SYSERR;
797  }
798  if (0 != access (p, X_OK))
799  {
801  GNUNET_free (p);
802  return GNUNET_SYSERR;
803  }
804 
805  if (0 == getuid ())
806  {
807  /* as we run as root, we don't insist on SUID */
808  GNUNET_free (p);
809  return GNUNET_YES;
810  }
811 
812  if (0 != stat (p, &statbuf))
813  {
815  GNUNET_free (p);
816  return GNUNET_SYSERR;
817  }
818  if (check_suid)
819  {
820  (void) params;
821  if ((0 != (statbuf.st_mode & S_ISUID)) && (0 == statbuf.st_uid))
822  {
823  GNUNET_free (p);
824  return GNUNET_YES;
825  }
827  _ ("Binary `%s' exists, but is not SUID\n"),
828  p);
829  /* binary exists, but not SUID */
830  }
831  GNUNET_free (p);
832  return GNUNET_NO;
833 }
834 
835 
836 /* end of os_installation.c */
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
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:1130
#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/, preferring 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 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.
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:172
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define _(String)
GNU gettext support macro.
Definition: platform.h:184
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.
Return the "PREFIX" directory given to configure.
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:171
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 int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
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:170
static char * os_get_exec_path()
get the path to current app&#39;s bin/
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
Whether 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 const struct GNUNET_IDENTITY_PrivateKey zero
Public key of all zeros.
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:84
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()
#define GNUNET_AGPL_URL
NOTE: You MUST adjust this URL to point to the location of a publicly accessible repository (or TGZ) ...
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.
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...