GNUnet  0.17.6
os_installation.c
Go to the documentation of this file.
1 /*
2  This file is part of GNUnet.
3  Copyright (C) 2006-2018, 2022 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 = "gnunet",
72  .gettext_path = NULL,
73  .agpl_url = GNUNET_AGPL_URL,
74 };
75 
81 
87 static const struct GNUNET_OS_ProjectData *gettextinit;
88 
89 
93 const struct GNUNET_OS_ProjectData *
95 {
96  return &default_pd;
97 }
98 
99 
103 const struct GNUNET_OS_ProjectData *
105 {
106  if (current_pd != gettextinit)
107  {
109 
110  if (NULL != path)
111  bindtextdomain (PACKAGE,
112  path);
113  GNUNET_free (path);
115  }
116  return current_pd;
117 }
118 
119 
125 void
127 {
128  GNUNET_assert (NULL != pd);
129  current_pd = pd;
130  if (pd != gettextinit)
131  {
133 
134  if (NULL != path)
135  bindtextdomain (PACKAGE,
136  path);
137  GNUNET_free (path);
138  gettextinit = pd;
139  }
140 }
141 
142 
143 #ifdef __linux__
149 static char *
150 get_path_from_proc_maps (void)
151 {
152  char fn[64];
153  char line[1024];
154  char dir[1024];
155  FILE *f;
156  char *lgu;
157 
158  if (NULL == current_pd->libname)
159  return NULL;
160  GNUNET_snprintf (fn,
161  sizeof(fn),
162  "/proc/%u/maps",
163  getpid ());
164  if (NULL == (f = fopen (fn, "r")))
165  return NULL;
166  while (NULL != fgets (line, sizeof(line), f))
167  {
168  if ((1 == sscanf (line,
169  "%*p-%*p %*c%*c%*c%*c %*x %*x:%*x %*u%*[ ]%1023s",
170  dir)) &&
171  (NULL != (lgu = strstr (dir,
172  current_pd->libname))))
173  {
174  lgu[0] = '\0';
175  fclose (f);
176  return GNUNET_strdup (dir);
177  }
178  }
179  fclose (f);
180  return NULL;
181 }
182 
183 
189 static char *
190 get_path_from_proc_exe (void)
191 {
192  char fn[64];
193  char lnk[1024];
194  ssize_t size;
195  char *lep;
196 
197  GNUNET_snprintf (fn, sizeof(fn), "/proc/%u/exe", getpid ());
198  size = readlink (fn, lnk, sizeof(lnk) - 1);
199  if (size <= 0)
200  {
201  LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "readlink", fn);
202  return NULL;
203  }
204  GNUNET_assert (((size_t) size) < sizeof(lnk));
205  lnk[size] = '\0';
206  while ((lnk[size] != '/') && (size > 0))
207  size--;
208  GNUNET_asprintf (&lep, "/%s/libexec/", current_pd->project_dirname);
209  /* test for being in lib/gnunet/libexec/ or lib/MULTIARCH/gnunet/libexec */
210  if ((((size_t) size) > strlen (lep)) &&
211  (0 == strcmp (lep, &lnk[size - strlen (lep)])))
212  size -= strlen (lep) - 1;
213  GNUNET_free (lep);
214  if ((size < 4) || (lnk[size - 4] != '/'))
215  {
216  /* not installed in "/bin/" -- binary path probably useless */
217  return NULL;
218  }
219  lnk[size] = '\0';
220  return GNUNET_strdup (lnk);
221 }
222 
223 
224 #endif
225 
226 
227 #if DARWIN
235 typedef int (*MyNSGetExecutablePathProto) (char *buf, size_t *bufsize);
236 
237 
243 static char *
244 get_path_from_NSGetExecutablePath (void)
245 {
246  static char zero = '\0';
247  char *path;
248  size_t len;
249  MyNSGetExecutablePathProto func;
250 
251  path = NULL;
252  if (NULL ==
253  (func = (MyNSGetExecutablePathProto) dlsym (RTLD_DEFAULT,
254  "_NSGetExecutablePath")))
255  return NULL;
256  path = &zero;
257  len = 0;
258  /* get the path len, including the trailing \0 */
259  (void) func (path, &len);
260  if (0 == len)
261  return NULL;
262  path = GNUNET_malloc (len);
263  if (0 != func (path, &len))
264  {
265  GNUNET_free (path);
266  return NULL;
267  }
268  len = strlen (path);
269  while ((path[len] != '/') && (len > 0))
270  len--;
271  path[len] = '\0';
272  return path;
273 }
274 
275 
281 static char *
282 get_path_from_dyld_image (void)
283 {
284  const char *path;
285  char *p;
286  char *s;
287  unsigned int i;
288  int c;
289 
290  c = _dyld_image_count ();
291  for (i = 0; i < c; i++)
292  {
293  if (((const void *) _dyld_get_image_header (i)) !=
294  ((const void *) &_mh_dylib_header))
295  continue;
296  path = _dyld_get_image_name (i);
297  if ((NULL == path) || (0 == strlen (path)))
298  continue;
299  p = GNUNET_strdup (path);
300  s = p + strlen (p);
301  while ((s > p) && ('/' != *s))
302  s--;
303  s++;
304  *s = '\0';
305  return p;
306  }
307  return NULL;
308 }
309 
310 
311 #endif
312 
313 
321 static char *
322 get_path_from_PATH (const char *binary)
323 {
324  char *path;
325  char *pos;
326  char *end;
327  char *buf;
328  const char *p;
329 
330  if (NULL == (p = getenv ("PATH")))
331  return NULL;
332 
333  path = GNUNET_strdup (p); /* because we write on it */
334 
335  buf = GNUNET_malloc (strlen (path) + strlen (binary) + 1 + 1);
336  pos = path;
337  while (NULL != (end = strchr (pos, PATH_SEPARATOR)))
338  {
339  *end = '\0';
340  sprintf (buf, "%s/%s", pos, binary);
342  {
343  pos = GNUNET_strdup (pos);
344  GNUNET_free (buf);
345  GNUNET_free (path);
346  return pos;
347  }
348  pos = end + 1;
349  }
350  sprintf (buf, "%s/%s", pos, binary);
352  {
353  pos = GNUNET_strdup (pos);
354  GNUNET_free (buf);
355  GNUNET_free (path);
356  return pos;
357  }
358  GNUNET_free (buf);
359  GNUNET_free (path);
360  return NULL;
361 }
362 
363 
370 static char *
372 {
373  const char *p;
374 
375  if ((NULL != current_pd->env_varname) &&
376  (NULL != (p = getenv (current_pd->env_varname))))
377  return GNUNET_strdup (p);
378  if ((NULL != current_pd->env_varname_alt) &&
379  (NULL != (p = getenv (current_pd->env_varname_alt))))
380  return GNUNET_strdup (p);
381  return NULL;
382 }
383 
384 
391 static char *
393 {
394  char *ret;
395 
396  if (NULL != (ret = get_path_from_GNUNET_PREFIX ()))
397  return ret;
398 #ifdef __linux__
399  if (NULL != (ret = get_path_from_proc_maps ()))
400  return ret;
401  /* try path *first*, before /proc/exe, as /proc/exe can be wrong */
402  if ((NULL != current_pd->binary_name) &&
403  (NULL != (ret = get_path_from_PATH (current_pd->binary_name))))
404  return ret;
405  if (NULL != (ret = get_path_from_proc_exe ()))
406  return ret;
407 #endif
408 #if DARWIN
409  if (NULL != (ret = get_path_from_dyld_image ()))
410  return ret;
411  if (NULL != (ret = get_path_from_NSGetExecutablePath ()))
412  return ret;
413 #endif
414  if ((NULL != current_pd->binary_name) &&
415  (NULL != (ret = get_path_from_PATH (current_pd->binary_name))))
416  return ret;
417  /* other attempts here */
419  _ (
420  "Could not determine installation path for %s. Set `%s' environment variable.\n"),
423  return NULL;
424 }
425 
426 
431 static char *
433 {
434  char *ret = NULL;
435 
436 #ifdef __linux__
437  if (NULL != (ret = get_path_from_proc_exe ()))
438  return ret;
439 #endif
440 #if DARWIN
441  if (NULL != (ret = get_path_from_NSGetExecutablePath ()))
442  return ret;
443 #endif
444  /* other attempts here */
445  return ret;
446 }
447 
448 
454 char *
456 {
457  size_t n;
458  char *dirname;
459  char *execpath = NULL;
460  char *tmp;
461  char *multiarch;
462  char *libdir;
463  int isbasedir;
464 
465  /* if wanted, try to get the current app's bin/ */
466  if (dirkind == GNUNET_OS_IPK_SELF_PREFIX)
467  execpath = os_get_exec_path ();
468 
469  /* try to get GNUnet's bin/ or lib/, or if previous was unsuccessful some
470  * guess for the current app */
471  if (NULL == execpath)
472  execpath = os_get_gnunet_path ();
473  if (NULL == execpath)
474  return NULL;
475 
476  n = strlen (execpath);
477  if (0 == n)
478  {
479  /* should never happen, but better safe than sorry */
480  GNUNET_free (execpath);
481  return NULL;
482  }
483  /* remove filename itself */
484  while ((n > 1) && (DIR_SEPARATOR == execpath[n - 1]))
485  execpath[--n] = '\0';
486 
487  isbasedir = 1;
488  if ((n > 6) && ((0 == strcasecmp (&execpath[n - 6], "/lib32")) ||
489  (0 == strcasecmp (&execpath[n - 6], "/lib64"))))
490  {
491  if ((GNUNET_OS_IPK_LIBDIR != dirkind) &&
492  (GNUNET_OS_IPK_LIBEXECDIR != dirkind))
493  {
494  /* strip '/lib32' or '/lib64' */
495  execpath[n - 6] = '\0';
496  n -= 6;
497  }
498  else
499  isbasedir = 0;
500  }
501  else if ((n > 4) && ((0 == strcasecmp (&execpath[n - 4], "/bin")) ||
502  (0 == strcasecmp (&execpath[n - 4], "/lib"))))
503  {
504  /* strip '/bin' or '/lib' */
505  execpath[n - 4] = '\0';
506  n -= 4;
507  }
508  multiarch = NULL;
509  if (NULL != (libdir = strstr (execpath, "/lib/")))
510  {
511  /* test for multi-arch path of the form "PREFIX/lib/MULTIARCH/";
512  here we need to re-add 'multiarch' to lib and libexec paths later! */
513  multiarch = &libdir[5];
514  if (NULL == strchr (multiarch, '/'))
515  libdir[0] =
516  '\0'; /* Debian multiarch format, cut of from 'execpath' but preserve in multicarch */
517  else
518  multiarch =
519  NULL; /* maybe not, multiarch still has a '/', which is not OK */
520  }
521  /* in case this was a directory named foo-bin, remove "foo-" */
522  while ((n > 1) && (execpath[n - 1] == DIR_SEPARATOR))
523  execpath[--n] = '\0';
524  switch (dirkind)
525  {
528  dirname = GNUNET_strdup (DIR_SEPARATOR_STR);
529  break;
530 
533  break;
534 
536  if (isbasedir)
537  {
538  GNUNET_asprintf (&tmp,
539  "%s%s%s%s%s%s%s",
540  execpath,
541  DIR_SEPARATOR_STR "lib",
542  (NULL != multiarch) ? DIR_SEPARATOR_STR : "",
543  (NULL != multiarch) ? multiarch : "",
548  {
549  GNUNET_free (execpath);
550  return tmp;
551  }
552  GNUNET_free (tmp);
553  tmp = NULL;
554  dirname = NULL;
555  if (4 == sizeof(void *))
556  {
557  GNUNET_asprintf (&dirname,
559  "%s" DIR_SEPARATOR_STR,
561  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
562  }
563  if (8 == sizeof(void *))
564  {
565  GNUNET_asprintf (&dirname,
567  "%s" DIR_SEPARATOR_STR,
569  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
570  }
571 
572  if ((NULL != tmp) &&
574  {
575  GNUNET_free (execpath);
576  GNUNET_free (dirname);
577  return tmp;
578  }
579  GNUNET_free (tmp);
580  GNUNET_free (dirname);
581  }
582  GNUNET_asprintf (&dirname,
585  break;
586 
588  GNUNET_asprintf (&dirname,
590  "%s" DIR_SEPARATOR_STR,
592  break;
593 
596  "locale" DIR_SEPARATOR_STR);
597  break;
598 
601  "icons" DIR_SEPARATOR_STR);
602  break;
603 
605  GNUNET_asprintf (&dirname,
607  "doc" DIR_SEPARATOR_STR
608  "%s" DIR_SEPARATOR_STR,
610  break;
611 
613  if (isbasedir)
614  {
615  GNUNET_asprintf (&dirname,
617  "libexec" DIR_SEPARATOR_STR,
619  GNUNET_asprintf (&tmp,
620  "%s%s%s%s",
621  execpath,
623  (NULL != multiarch) ? multiarch : "",
624  dirname);
625  GNUNET_free (dirname);
627  {
628  GNUNET_free (execpath);
629  return tmp;
630  }
631  GNUNET_free (tmp);
632  tmp = NULL;
633  dirname = NULL;
634  if (4 == sizeof(void *))
635  {
636  GNUNET_asprintf (&dirname,
638  "%s" DIR_SEPARATOR_STR
639  "libexec" DIR_SEPARATOR_STR,
641  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
642  }
643  if (8 == sizeof(void *))
644  {
645  GNUNET_asprintf (&dirname,
647  "%s" DIR_SEPARATOR_STR
648  "libexec" DIR_SEPARATOR_STR,
650  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
651  }
652  if ((NULL != tmp) &&
654  {
655  GNUNET_free (execpath);
656  GNUNET_free (dirname);
657  return tmp;
658  }
659  GNUNET_free (tmp);
660  GNUNET_free (dirname);
661  }
662  GNUNET_asprintf (&dirname,
664  "libexec" DIR_SEPARATOR_STR,
666  break;
667 
668  default:
669  GNUNET_free (execpath);
670  return NULL;
671  }
672  GNUNET_asprintf (&tmp, "%s%s", execpath, dirname);
673  GNUNET_free (dirname);
674  GNUNET_free (execpath);
675  return tmp;
676 }
677 
678 
687 char *
688 GNUNET_OS_get_libexec_binary_path (const char *progname)
689 {
690  static char *cache;
691  char *libexecdir;
692  char *binary;
693 
694  if ((DIR_SEPARATOR == progname[0]) ||
695  (GNUNET_YES ==
696  GNUNET_STRINGS_path_is_absolute (progname, GNUNET_NO, NULL, NULL)))
697  return GNUNET_strdup (progname);
698  if (NULL != cache)
699  libexecdir = cache;
700  else
702  if (NULL == libexecdir)
703  return GNUNET_strdup (progname);
704  GNUNET_asprintf (&binary, "%s%s", libexecdir, progname);
705  cache = libexecdir;
706  return binary;
707 }
708 
709 
722 char *
724  const char *progname)
725 {
726  static char *cache;
727  char *binary = NULL;
728  char *path = NULL;
729  size_t path_len;
730 
731  if (GNUNET_YES ==
732  GNUNET_STRINGS_path_is_absolute (progname, GNUNET_NO, NULL, NULL))
733  {
734  return GNUNET_strdup (progname);
735  }
736  if (NULL != cache)
737  path = cache;
738  else
740  "PATHS",
741  "SUID_BINARY_PATH",
742  &path);
743  if ((NULL == path) || (0 == strlen (path)))
744  {
745  if (NULL != path)
746  GNUNET_free (path);
747  cache = NULL;
748  return GNUNET_OS_get_libexec_binary_path (progname);
749  }
750  path_len = strlen (path);
751  GNUNET_asprintf (&binary,
752  "%s%s%s",
753  path,
754  (path[path_len - 1] == DIR_SEPARATOR) ? ""
756  progname);
757  cache = path;
758  return binary;
759 }
760 
761 
763 GNUNET_OS_check_helper_binary (const char *binary,
764  bool 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 */
char * getenv()
#define bindtextdomain(Domainname, Dirname)
Definition: gettext.h:57
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static char * dir
Set to the directory where runtime files are stored.
Definition: gnunet-arm.c:89
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
static char * line
Desired phone line (string to be converted to a hash).
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static const struct GNUNET_IDENTITY_PrivateKey zero
Public key of all zeros.
static struct GNUNET_CONTAINER_MultiHashMap32 * cache
Hashmap to maintain cache.
static char buf[2048]
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-uri.c:37
#define GNUNET_AGPL_URL
NOTE: You MUST adjust this URL to point to the location of a publicly accessible repository (or TGZ) ...
enum GNUNET_GenericReturnValue 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.
enum GNUNET_GenericReturnValue 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:482
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_test(const char *fil, int is_readable)
Test if fil is a directory and listable.
Definition: disk.c:404
#define GNUNET_log(kind,...)
GNUNET_GenericReturnValue
Named constants for return values.
Definition: gnunet_common.h:96
@ GNUNET_YES
@ GNUNET_NO
Definition: gnunet_common.h:98
@ GNUNET_SYSERR
Definition: gnunet_common.h:97
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_INFO
int int GNUNET_asprintf(char **buf, const char *format,...) __attribute__((format(printf
Like asprintf, just portable.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
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.
#define GNUNET_malloc(size)
Wrapper around malloc.
#define GNUNET_free(ptr)
Wrapper around free.
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 ...
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 ...
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_default(void)
Return default project data used by 'libgnunetutil' for GNUnet.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_get()
enum GNUNET_GenericReturnValue GNUNET_OS_check_helper_binary(const char *binary, bool check_suid, const char *params)
Check whether an executable exists and possibly if the suid bit is set on the file.
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,...
void GNUNET_OS_init(const struct GNUNET_OS_ProjectData *pd)
Setup OS subsystem with project data.
GNUNET_OS_InstallationPathKind
Possible installation paths to request.
@ GNUNET_OS_IPK_SELF_PREFIX
Return the installation directory of this application, not the one of the overall GNUnet installation...
@ GNUNET_OS_IPK_ICONDIR
Return the prefix of the path with application icons (share/icons/).
@ GNUNET_OS_IPK_DATADIR
Return the directory where data is installed (share/gnunet/)
@ GNUNET_OS_IPK_DOCDIR
Return the prefix of the path with documentation files, including the license (share/doc/gnunet/).
@ GNUNET_OS_IPK_LOCALEDIR
Return the directory where translations are installed (share/locale/)
@ GNUNET_OS_IPK_LIBDIR
Return the directory where libraries are installed.
@ GNUNET_OS_IPK_PREFIX
Return the "PREFIX" directory given to configure.
@ GNUNET_OS_IPK_BINDIR
Return the directory where the program binaries are installed.
@ GNUNET_OS_IPK_LIBEXECDIR
Return the directory where helper binaries are installed (lib/gnunet/libexec/)
enum GNUNET_GenericReturnValue 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's an URI.
Definition: strings.c:959
static char * get_path_from_PATH(const char *binary)
Return the actual path to a file found in the current PATH environment variable.
static char * os_get_gnunet_path(void)
get the path to GNUnet bin/ or lib/, preferring the lib/ path
static const struct GNUNET_OS_ProjectData * gettextinit
PD for which gettext has been initialized last.
static char * os_get_exec_path()
get the path to current app's bin/
#define LOG_STRERROR_FILE(kind, syscall, filename)
static const struct GNUNET_OS_ProjectData default_pd
Default project data used for installation path detection for GNUnet (core).
static char * get_path_from_GNUNET_PREFIX(void)
Try to obtain the installation path using the "GNUNET_PREFIX" environment variable.
static const struct GNUNET_OS_ProjectData * current_pd
Which project data do we currently use for installation path detection? Never NULL.
#define LOG(kind,...)
static unsigned int size
Size of the "table".
Definition: peer.c:67
#define DIR_SEPARATOR
Definition: platform.h:164
#define DIR_SEPARATOR_STR
Definition: platform.h:165
#define PATH_SEPARATOR
Definition: platform.h:166
#define _(String)
GNU gettext support macro.
Definition: platform.h:177
Project-specific data used to help the OS subsystem find installation paths.
const char * binary_name
Name of a project-specific binary that should be in "$PREFIX/bin/".
const char * env_varname
Name of an environment variable that can be used to override installation path detection,...
const char * env_varname_alt
Alternative name of an environment variable that can be used to override installation path detection,...
const char * libname
Name of a library that is installed in the "lib/" directory of the project, such as "libgnunetutil".
const char * project_dirname
Name of the project that is used in the "libexec" prefix, For example, "gnunet".