PostgreSQL Source Code  git master
exec.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * exec.c
4  * Functions for finding and validating executable files
5  *
6  *
7  * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  *
11  * IDENTIFICATION
12  * src/common/exec.c
13  *
14  *-------------------------------------------------------------------------
15  */
16 
17 #ifndef FRONTEND
18 #include "postgres.h"
19 #else
20 #include "postgres_fe.h"
21 #endif
22 
23 #include <signal.h>
24 #include <sys/stat.h>
25 #include <sys/wait.h>
26 #include <unistd.h>
27 
28 #ifdef EXEC_BACKEND
29 #if defined(HAVE_SYS_PERSONALITY_H)
30 #include <sys/personality.h>
31 #elif defined(HAVE_SYS_PROCCTL_H)
32 #include <sys/procctl.h>
33 #endif
34 #endif
35 
36 /* Inhibit mingw CRT's auto-globbing of command line arguments */
37 #if defined(WIN32) && !defined(_MSC_VER)
38 extern int _CRT_glob = 0; /* 0 turns off globbing; 1 turns it on */
39 #endif
40 
41 /*
42  * Hacky solution to allow expressing both frontend and backend error reports
43  * in one macro call. First argument of log_error is an errcode() call of
44  * some sort (ignored if FRONTEND); the rest are errmsg_internal() arguments,
45  * i.e. message string and any parameters for it.
46  *
47  * Caller must provide the gettext wrapper around the message string, if
48  * appropriate, so that it gets translated in the FRONTEND case; this
49  * motivates using errmsg_internal() not errmsg(). We handle appending a
50  * newline, if needed, inside the macro, so that there's only one translatable
51  * string per call not two.
52  */
53 #ifndef FRONTEND
54 #define log_error(errcodefn, ...) \
55  ereport(LOG, (errcodefn, errmsg_internal(__VA_ARGS__)))
56 #else
57 #define log_error(errcodefn, ...) \
58  (fprintf(stderr, __VA_ARGS__), fputc('\n', stderr))
59 #endif
60 
61 #ifdef _MSC_VER
62 #define getcwd(cwd,len) GetCurrentDirectory(len, cwd)
63 #endif
64 
65 static int resolve_symlinks(char *path);
66 
67 #ifdef WIN32
68 static BOOL GetTokenUser(HANDLE hToken, PTOKEN_USER *ppTokenUser);
69 #endif
70 
71 /*
72  * validate_exec -- validate "path" as an executable file
73  *
74  * returns 0 if the file is found and no error is encountered.
75  * -1 if the regular file "path" does not exist or cannot be executed.
76  * -2 if the file is otherwise valid but cannot be read.
77  */
78 int
79 validate_exec(const char *path)
80 {
81  struct stat buf;
82  int is_r;
83  int is_x;
84 
85 #ifdef WIN32
86  char path_exe[MAXPGPATH + sizeof(".exe") - 1];
87 
88  /* Win32 requires a .exe suffix for stat() */
89  if (strlen(path) >= strlen(".exe") &&
90  pg_strcasecmp(path + strlen(path) - strlen(".exe"), ".exe") != 0)
91  {
92  strlcpy(path_exe, path, sizeof(path_exe) - 4);
93  strcat(path_exe, ".exe");
94  path = path_exe;
95  }
96 #endif
97 
98  /*
99  * Ensure that the file exists and is a regular file.
100  *
101  * XXX if you have a broken system where stat() looks at the symlink
102  * instead of the underlying file, you lose.
103  */
104  if (stat(path, &buf) < 0)
105  return -1;
106 
107  if (!S_ISREG(buf.st_mode))
108  return -1;
109 
110  /*
111  * Ensure that the file is both executable and readable (required for
112  * dynamic loading).
113  */
114 #ifndef WIN32
115  is_r = (access(path, R_OK) == 0);
116  is_x = (access(path, X_OK) == 0);
117 #else
118  is_r = buf.st_mode & S_IRUSR;
119  is_x = buf.st_mode & S_IXUSR;
120 #endif
121  return is_x ? (is_r ? 0 : -2) : -1;
122 }
123 
124 
125 /*
126  * find_my_exec -- find an absolute path to a valid executable
127  *
128  * argv0 is the name passed on the command line
129  * retpath is the output area (must be of size MAXPGPATH)
130  * Returns 0 if OK, -1 if error.
131  *
132  * The reason we have to work so hard to find an absolute path is that
133  * on some platforms we can't do dynamic loading unless we know the
134  * executable's location. Also, we need a full path not a relative
135  * path because we will later change working directory. Finally, we want
136  * a true path not a symlink location, so that we can locate other files
137  * that are part of our installation relative to the executable.
138  */
139 int
140 find_my_exec(const char *argv0, char *retpath)
141 {
142  char cwd[MAXPGPATH],
143  test_path[MAXPGPATH];
144  char *path;
145 
146  if (!getcwd(cwd, MAXPGPATH))
147  {
149  _("could not identify current directory: %m"));
150  return -1;
151  }
152 
153  /*
154  * If argv0 contains a separator, then PATH wasn't used.
155  */
156  if (first_dir_separator(argv0) != NULL)
157  {
158  if (is_absolute_path(argv0))
159  strlcpy(retpath, argv0, MAXPGPATH);
160  else
161  join_path_components(retpath, cwd, argv0);
162  canonicalize_path(retpath);
163 
164  if (validate_exec(retpath) == 0)
165  return resolve_symlinks(retpath);
166 
167  log_error(errcode(ERRCODE_WRONG_OBJECT_TYPE),
168  _("invalid binary \"%s\""), retpath);
169  return -1;
170  }
171 
172 #ifdef WIN32
173  /* Win32 checks the current directory first for names without slashes */
174  join_path_components(retpath, cwd, argv0);
175  if (validate_exec(retpath) == 0)
176  return resolve_symlinks(retpath);
177 #endif
178 
179  /*
180  * Since no explicit path was supplied, the user must have been relying on
181  * PATH. We'll search the same PATH.
182  */
183  if ((path = getenv("PATH")) && *path)
184  {
185  char *startp = NULL,
186  *endp = NULL;
187 
188  do
189  {
190  if (!startp)
191  startp = path;
192  else
193  startp = endp + 1;
194 
195  endp = first_path_var_separator(startp);
196  if (!endp)
197  endp = startp + strlen(startp); /* point to end */
198 
199  strlcpy(test_path, startp, Min(endp - startp + 1, MAXPGPATH));
200 
201  if (is_absolute_path(test_path))
202  join_path_components(retpath, test_path, argv0);
203  else
204  {
205  join_path_components(retpath, cwd, test_path);
206  join_path_components(retpath, retpath, argv0);
207  }
208  canonicalize_path(retpath);
209 
210  switch (validate_exec(retpath))
211  {
212  case 0: /* found ok */
213  return resolve_symlinks(retpath);
214  case -1: /* wasn't even a candidate, keep looking */
215  break;
216  case -2: /* found but disqualified */
217  log_error(errcode(ERRCODE_WRONG_OBJECT_TYPE),
218  _("could not read binary \"%s\""),
219  retpath);
220  break;
221  }
222  } while (*endp);
223  }
224 
225  log_error(errcode(ERRCODE_UNDEFINED_FILE),
226  _("could not find a \"%s\" to execute"), argv0);
227  return -1;
228 }
229 
230 
231 /*
232  * resolve_symlinks - resolve symlinks to the underlying file
233  *
234  * Replace "path" by the absolute path to the referenced file.
235  *
236  * Returns 0 if OK, -1 if error.
237  *
238  * Note: we are not particularly tense about producing nice error messages
239  * because we are not really expecting error here; we just determined that
240  * the symlink does point to a valid executable.
241  */
242 static int
243 resolve_symlinks(char *path)
244 {
245 #ifdef HAVE_READLINK
246  struct stat buf;
247  char orig_wd[MAXPGPATH],
248  link_buf[MAXPGPATH];
249  char *fname;
250 
251  /*
252  * To resolve a symlink properly, we have to chdir into its directory and
253  * then chdir to where the symlink points; otherwise we may fail to
254  * resolve relative links correctly (consider cases involving mount
255  * points, for example). After following the final symlink, we use
256  * getcwd() to figure out where the heck we're at.
257  *
258  * One might think we could skip all this if path doesn't point to a
259  * symlink to start with, but that's wrong. We also want to get rid of
260  * any directory symlinks that are present in the given path. We expect
261  * getcwd() to give us an accurate, symlink-free path.
262  */
263  if (!getcwd(orig_wd, MAXPGPATH))
264  {
266  _("could not identify current directory: %m"));
267  return -1;
268  }
269 
270  for (;;)
271  {
272  char *lsep;
273  int rllen;
274 
275  lsep = last_dir_separator(path);
276  if (lsep)
277  {
278  *lsep = '\0';
279  if (chdir(path) == -1)
280  {
282  _("could not change directory to \"%s\": %m"), path);
283  return -1;
284  }
285  fname = lsep + 1;
286  }
287  else
288  fname = path;
289 
290  if (lstat(fname, &buf) < 0 ||
291  !S_ISLNK(buf.st_mode))
292  break;
293 
294  errno = 0;
295  rllen = readlink(fname, link_buf, sizeof(link_buf));
296  if (rllen < 0 || rllen >= sizeof(link_buf))
297  {
299  _("could not read symbolic link \"%s\": %m"), fname);
300  return -1;
301  }
302  link_buf[rllen] = '\0';
303  strcpy(path, link_buf);
304  }
305 
306  /* must copy final component out of 'path' temporarily */
307  strlcpy(link_buf, fname, sizeof(link_buf));
308 
309  if (!getcwd(path, MAXPGPATH))
310  {
312  _("could not identify current directory: %m"));
313  return -1;
314  }
315  join_path_components(path, path, link_buf);
316  canonicalize_path(path);
317 
318  if (chdir(orig_wd) == -1)
319  {
321  _("could not change directory to \"%s\": %m"), orig_wd);
322  return -1;
323  }
324 #endif /* HAVE_READLINK */
325 
326  return 0;
327 }
328 
329 
330 /*
331  * Find another program in our binary's directory,
332  * then make sure it is the proper version.
333  */
334 int
335 find_other_exec(const char *argv0, const char *target,
336  const char *versionstr, char *retpath)
337 {
338  char cmd[MAXPGPATH];
339  char line[MAXPGPATH];
340 
341  if (find_my_exec(argv0, retpath) < 0)
342  return -1;
343 
344  /* Trim off program name and keep just directory */
345  *last_dir_separator(retpath) = '\0';
346  canonicalize_path(retpath);
347 
348  /* Now append the other program's name */
349  snprintf(retpath + strlen(retpath), MAXPGPATH - strlen(retpath),
350  "/%s%s", target, EXE);
351 
352  if (validate_exec(retpath) != 0)
353  return -1;
354 
355  snprintf(cmd, sizeof(cmd), "\"%s\" -V", retpath);
356 
357  if (!pipe_read_line(cmd, line, sizeof(line)))
358  return -1;
359 
360  if (strcmp(line, versionstr) != 0)
361  return -2;
362 
363  return 0;
364 }
365 
366 
367 /*
368  * Execute a command in a pipe and read the first line from it.
369  */
370 char *
371 pipe_read_line(char *cmd, char *line, int maxsize)
372 {
373  FILE *pgver;
374 
375  /* flush output buffers in case popen does not... */
376  fflush(stdout);
377  fflush(stderr);
378 
379  errno = 0;
380  if ((pgver = popen(cmd, "r")) == NULL)
381  {
382  perror("popen failure");
383  return NULL;
384  }
385 
386  errno = 0;
387  if (fgets(line, maxsize, pgver) == NULL)
388  {
389  if (feof(pgver))
390  fprintf(stderr, "no data was returned by command \"%s\"\n", cmd);
391  else
392  perror("fgets failure");
393  pclose(pgver); /* no error checking */
394  return NULL;
395  }
396 
397  if (pclose_check(pgver))
398  return NULL;
399 
400  return line;
401 }
402 
403 
404 /*
405  * pclose() plus useful error reporting
406  */
407 int
408 pclose_check(FILE *stream)
409 {
410  int exitstatus;
411  char *reason;
412 
413  exitstatus = pclose(stream);
414 
415  if (exitstatus == 0)
416  return 0; /* all is well */
417 
418  if (exitstatus == -1)
419  {
420  /* pclose() itself failed, and hopefully set errno */
421  log_error(errcode(ERRCODE_SYSTEM_ERROR),
422  _("%s() failed: %m"), "pclose");
423  }
424  else
425  {
426  reason = wait_result_to_str(exitstatus);
427  log_error(errcode(ERRCODE_SYSTEM_ERROR),
428  "%s", reason);
429  pfree(reason);
430  }
431  return exitstatus;
432 }
433 
434 /*
435  * set_pglocale_pgservice
436  *
437  * Set application-specific locale and service directory
438  *
439  * This function takes the value of argv[0] rather than a full path.
440  *
441  * (You may be wondering why this is in exec.c. It requires this module's
442  * services and doesn't introduce any new dependencies, so this seems as
443  * good as anyplace.)
444  */
445 void
446 set_pglocale_pgservice(const char *argv0, const char *app)
447 {
448  char path[MAXPGPATH];
449  char my_exec_path[MAXPGPATH];
450 
451  /* don't set LC_ALL in the backend */
452  if (strcmp(app, PG_TEXTDOMAIN("postgres")) != 0)
453  {
454  setlocale(LC_ALL, "");
455 
456  /*
457  * One could make a case for reproducing here PostmasterMain()'s test
458  * for whether the process is multithreaded. Unlike the postmaster,
459  * no frontend program calls sigprocmask() or otherwise provides for
460  * mutual exclusion between signal handlers. While frontends using
461  * fork(), if multithreaded, are formally exposed to undefined
462  * behavior, we have not witnessed a concrete bug. Therefore,
463  * complaining about multithreading here may be mere pedantry.
464  */
465  }
466 
467  if (find_my_exec(argv0, my_exec_path) < 0)
468  return;
469 
470 #ifdef ENABLE_NLS
472  bindtextdomain(app, path);
473  textdomain(app);
474  /* set for libpq to use, but don't override existing setting */
475  setenv("PGLOCALEDIR", path, 0);
476 #endif
477 
478  if (getenv("PGSYSCONFDIR") == NULL)
479  {
480  get_etc_path(my_exec_path, path);
481  /* set for libpq to use */
482  setenv("PGSYSCONFDIR", path, 0);
483  }
484 }
485 
486 #ifdef EXEC_BACKEND
487 /*
488  * For the benefit of PostgreSQL developers testing EXEC_BACKEND on Unix
489  * systems (code paths normally exercised only on Windows), provide a way to
490  * disable address space layout randomization, if we know how on this platform.
491  * Otherwise, backends may fail to attach to shared memory at the fixed address
492  * chosen by the postmaster. (See also the macOS-specific hack in
493  * sysv_shmem.c.)
494  */
495 int
496 pg_disable_aslr(void)
497 {
498 #if defined(HAVE_SYS_PERSONALITY_H)
499  return personality(ADDR_NO_RANDOMIZE);
500 #elif defined(HAVE_SYS_PROCCTL_H) && defined(PROC_ASLR_FORCE_DISABLE)
501  int data = PROC_ASLR_FORCE_DISABLE;
502 
503  return procctl(P_PID, 0, PROC_ASLR_CTL, &data);
504 #else
505  errno = ENOSYS;
506  return -1;
507 #endif
508 }
509 #endif
510 
511 #ifdef WIN32
512 
513 /*
514  * AddUserToTokenDacl(HANDLE hToken)
515  *
516  * This function adds the current user account to the restricted
517  * token used when we create a restricted process.
518  *
519  * This is required because of some security changes in Windows
520  * that appeared in patches to XP/2K3 and in Vista/2008.
521  *
522  * On these machines, the Administrator account is not included in
523  * the default DACL - you just get Administrators + System. For
524  * regular users you get User + System. Because we strip Administrators
525  * when we create the restricted token, we are left with only System
526  * in the DACL which leads to access denied errors for later CreatePipe()
527  * and CreateProcess() calls when running as Administrator.
528  *
529  * This function fixes this problem by modifying the DACL of the
530  * token the process will use, and explicitly re-adding the current
531  * user account. This is still secure because the Administrator account
532  * inherits its privileges from the Administrators group - it doesn't
533  * have any of its own.
534  */
535 BOOL
536 AddUserToTokenDacl(HANDLE hToken)
537 {
538  int i;
539  ACL_SIZE_INFORMATION asi;
540  ACCESS_ALLOWED_ACE *pace;
541  DWORD dwNewAclSize;
542  DWORD dwSize = 0;
543  DWORD dwTokenInfoLength = 0;
544  PACL pacl = NULL;
545  PTOKEN_USER pTokenUser = NULL;
546  TOKEN_DEFAULT_DACL tddNew;
547  TOKEN_DEFAULT_DACL *ptdd = NULL;
548  TOKEN_INFORMATION_CLASS tic = TokenDefaultDacl;
549  BOOL ret = FALSE;
550 
551  /* Figure out the buffer size for the DACL info */
552  if (!GetTokenInformation(hToken, tic, (LPVOID) NULL, dwTokenInfoLength, &dwSize))
553  {
554  if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
555  {
556  ptdd = (TOKEN_DEFAULT_DACL *) LocalAlloc(LPTR, dwSize);
557  if (ptdd == NULL)
558  {
559  log_error(errcode(ERRCODE_OUT_OF_MEMORY),
560  _("out of memory"));
561  goto cleanup;
562  }
563 
564  if (!GetTokenInformation(hToken, tic, (LPVOID) ptdd, dwSize, &dwSize))
565  {
566  log_error(errcode(ERRCODE_SYSTEM_ERROR),
567  "could not get token information: error code %lu",
568  GetLastError());
569  goto cleanup;
570  }
571  }
572  else
573  {
574  log_error(errcode(ERRCODE_SYSTEM_ERROR),
575  "could not get token information buffer size: error code %lu",
576  GetLastError());
577  goto cleanup;
578  }
579  }
580 
581  /* Get the ACL info */
582  if (!GetAclInformation(ptdd->DefaultDacl, (LPVOID) &asi,
583  (DWORD) sizeof(ACL_SIZE_INFORMATION),
584  AclSizeInformation))
585  {
586  log_error(errcode(ERRCODE_SYSTEM_ERROR),
587  "could not get ACL information: error code %lu",
588  GetLastError());
589  goto cleanup;
590  }
591 
592  /* Get the current user SID */
593  if (!GetTokenUser(hToken, &pTokenUser))
594  goto cleanup; /* callee printed a message */
595 
596  /* Figure out the size of the new ACL */
597  dwNewAclSize = asi.AclBytesInUse + sizeof(ACCESS_ALLOWED_ACE) +
598  GetLengthSid(pTokenUser->User.Sid) - sizeof(DWORD);
599 
600  /* Allocate the ACL buffer & initialize it */
601  pacl = (PACL) LocalAlloc(LPTR, dwNewAclSize);
602  if (pacl == NULL)
603  {
604  log_error(errcode(ERRCODE_OUT_OF_MEMORY),
605  _("out of memory"));
606  goto cleanup;
607  }
608 
609  if (!InitializeAcl(pacl, dwNewAclSize, ACL_REVISION))
610  {
611  log_error(errcode(ERRCODE_SYSTEM_ERROR),
612  "could not initialize ACL: error code %lu", GetLastError());
613  goto cleanup;
614  }
615 
616  /* Loop through the existing ACEs, and build the new ACL */
617  for (i = 0; i < (int) asi.AceCount; i++)
618  {
619  if (!GetAce(ptdd->DefaultDacl, i, (LPVOID *) &pace))
620  {
621  log_error(errcode(ERRCODE_SYSTEM_ERROR),
622  "could not get ACE: error code %lu", GetLastError());
623  goto cleanup;
624  }
625 
626  if (!AddAce(pacl, ACL_REVISION, MAXDWORD, pace, ((PACE_HEADER) pace)->AceSize))
627  {
628  log_error(errcode(ERRCODE_SYSTEM_ERROR),
629  "could not add ACE: error code %lu", GetLastError());
630  goto cleanup;
631  }
632  }
633 
634  /* Add the new ACE for the current user */
635  if (!AddAccessAllowedAceEx(pacl, ACL_REVISION, OBJECT_INHERIT_ACE, GENERIC_ALL, pTokenUser->User.Sid))
636  {
637  log_error(errcode(ERRCODE_SYSTEM_ERROR),
638  "could not add access allowed ACE: error code %lu",
639  GetLastError());
640  goto cleanup;
641  }
642 
643  /* Set the new DACL in the token */
644  tddNew.DefaultDacl = pacl;
645 
646  if (!SetTokenInformation(hToken, tic, (LPVOID) &tddNew, dwNewAclSize))
647  {
648  log_error(errcode(ERRCODE_SYSTEM_ERROR),
649  "could not set token information: error code %lu",
650  GetLastError());
651  goto cleanup;
652  }
653 
654  ret = TRUE;
655 
656 cleanup:
657  if (pTokenUser)
658  LocalFree((HLOCAL) pTokenUser);
659 
660  if (pacl)
661  LocalFree((HLOCAL) pacl);
662 
663  if (ptdd)
664  LocalFree((HLOCAL) ptdd);
665 
666  return ret;
667 }
668 
669 /*
670  * GetTokenUser(HANDLE hToken, PTOKEN_USER *ppTokenUser)
671  *
672  * Get the users token information from a process token.
673  *
674  * The caller of this function is responsible for calling LocalFree() on the
675  * returned TOKEN_USER memory.
676  */
677 static BOOL
678 GetTokenUser(HANDLE hToken, PTOKEN_USER *ppTokenUser)
679 {
680  DWORD dwLength;
681 
682  *ppTokenUser = NULL;
683 
684  if (!GetTokenInformation(hToken,
685  TokenUser,
686  NULL,
687  0,
688  &dwLength))
689  {
690  if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
691  {
692  *ppTokenUser = (PTOKEN_USER) LocalAlloc(LPTR, dwLength);
693 
694  if (*ppTokenUser == NULL)
695  {
696  log_error(errcode(ERRCODE_OUT_OF_MEMORY),
697  _("out of memory"));
698  return FALSE;
699  }
700  }
701  else
702  {
703  log_error(errcode(ERRCODE_SYSTEM_ERROR),
704  "could not get token information buffer size: error code %lu",
705  GetLastError());
706  return FALSE;
707  }
708  }
709 
710  if (!GetTokenInformation(hToken,
711  TokenUser,
712  *ppTokenUser,
713  dwLength,
714  &dwLength))
715  {
716  LocalFree(*ppTokenUser);
717  *ppTokenUser = NULL;
718 
719  log_error(errcode(ERRCODE_SYSTEM_ERROR),
720  "could not get token information: error code %lu",
721  GetLastError());
722  return FALSE;
723  }
724 
725  /* Memory in *ppTokenUser is LocalFree():d by the caller */
726  return TRUE;
727 }
728 
729 #endif
static void cleanup(void)
Definition: bootstrap.c:697
#define Min(x, y)
Definition: c.h:986
#define PG_TEXTDOMAIN(domain)
Definition: c.h:1212
int find_my_exec(const char *argv0, char *retpath)
Definition: exec.c:140
#define log_error(errcodefn,...)
Definition: exec.c:54
int validate_exec(const char *path)
Definition: exec.c:79
char * pipe_read_line(char *cmd, char *line, int maxsize)
Definition: exec.c:371
int pclose_check(FILE *stream)
Definition: exec.c:408
void set_pglocale_pgservice(const char *argv0, const char *app)
Definition: exec.c:446
int find_other_exec(const char *argv0, const char *target, const char *versionstr, char *retpath)
Definition: exec.c:335
static int resolve_symlinks(char *path)
Definition: exec.c:243
int errcode_for_file_access(void)
Definition: elog.c:716
int errcode(int sqlerrcode)
Definition: elog.c:693
#define _(x)
Definition: elog.c:89
char my_exec_path[MAXPGPATH]
Definition: globals.c:76
int i
Definition: isn.c:73
static void const char fflush(stdout)
void pfree(void *pointer)
Definition: mcxt.c:1175
#define MAXPGPATH
const void * data
static char * argv0
Definition: pg_ctl.c:97
static char * buf
Definition: pg_test_fsync.c:67
void get_locale_path(const char *my_exec_path, char *ret_path)
Definition: path.c:888
void join_path_components(char *ret_path, const char *head, const char *tail)
Definition: path.c:219
char * last_dir_separator(const char *filename)
Definition: path.c:139
#define is_absolute_path(filename)
Definition: port.h:89
char * first_dir_separator(const char *filename)
Definition: path.c:104
int pg_strcasecmp(const char *s1, const char *s2)
Definition: pgstrcasecmp.c:36
void canonicalize_path(char *path)
Definition: path.c:264
void get_etc_path(const char *my_exec_path, char *ret_path)
Definition: path.c:834
char * first_path_var_separator(const char *pathlist)
Definition: path.c:121
#define snprintf
Definition: port.h:225
#define fprintf
Definition: port.h:229
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:45
#define EXE
Definition: port.h:150
char * wait_result_to_str(int exitstatus)
Definition: wait_error.c:32
#define stat
Definition: win32_port.h:283
#define lstat(path, sb)
Definition: win32_port.h:284
BOOL AddUserToTokenDacl(HANDLE hToken)
#define S_IRUSR
Definition: win32_port.h:288
#define setenv(x, y, z)
Definition: win32_port.h:507
#define readlink(path, buf, size)
Definition: win32_port.h:236
#define S_ISREG(m)
Definition: win32_port.h:327
#define setlocale(a, b)
Definition: win32_port.h:446
#define S_IXUSR
Definition: win32_port.h:294