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