D-Bus  1.13.12
dbus-sysdeps-util-unix.c
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-sysdeps-util-unix.c Would be in dbus-sysdeps-unix.c, but not used in libdbus
3  *
4  * Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc.
5  * Copyright (C) 2003 CodeFactory AB
6  *
7  * Licensed under the Academic Free License version 2.1
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 #include <config.h>
26 #include "dbus-sysdeps.h"
27 #include "dbus-sysdeps-unix.h"
28 #include "dbus-internals.h"
29 #include "dbus-list.h"
30 #include "dbus-pipe.h"
31 #include "dbus-protocol.h"
32 #include "dbus-string.h"
33 #define DBUS_USERDB_INCLUDES_PRIVATE 1
34 #include "dbus-userdb.h"
35 #include "dbus-test.h"
36 
37 #include <sys/types.h>
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <string.h>
41 #include <signal.h>
42 #include <unistd.h>
43 #include <stdio.h>
44 #include <errno.h>
45 #include <fcntl.h>
46 #include <sys/stat.h>
47 #ifdef HAVE_SYS_RESOURCE_H
48 #include <sys/resource.h>
49 #endif
50 #include <grp.h>
51 #include <sys/socket.h>
52 #include <dirent.h>
53 #include <sys/un.h>
54 
55 #ifdef HAVE_SYS_PRCTL_H
56 #include <sys/prctl.h>
57 #endif
58 
59 #ifdef HAVE_SYS_SYSLIMITS_H
60 #include <sys/syslimits.h>
61 #endif
62 
63 #ifdef HAVE_SYSTEMD
64 #include <systemd/sd-daemon.h>
65 #endif
66 
67 #ifndef O_BINARY
68 #define O_BINARY 0
69 #endif
70 
88  DBusPipe *print_pid_pipe,
89  DBusError *error,
90  dbus_bool_t keep_umask)
91 {
92  const char *s;
93  pid_t child_pid;
94  DBusEnsureStandardFdsFlags flags;
95 
96  _dbus_verbose ("Becoming a daemon...\n");
97 
98  _dbus_verbose ("chdir to /\n");
99  if (chdir ("/") < 0)
100  {
102  "Could not chdir() to root directory");
103  return FALSE;
104  }
105 
106  _dbus_verbose ("forking...\n");
107 
108  /* Make sure our output buffers aren't redundantly printed by both the
109  * parent and the child */
110  fflush (stdout);
111  fflush (stderr);
112 
113  switch ((child_pid = fork ()))
114  {
115  case -1:
116  _dbus_verbose ("fork failed\n");
117  dbus_set_error (error, _dbus_error_from_errno (errno),
118  "Failed to fork daemon: %s", _dbus_strerror (errno));
119  return FALSE;
120  break;
121 
122  case 0:
123  _dbus_verbose ("in child, closing std file descriptors\n");
124 
125  flags = DBUS_FORCE_STDIN_NULL | DBUS_FORCE_STDOUT_NULL;
126  s = _dbus_getenv ("DBUS_DEBUG_OUTPUT");
127 
128  if (s == NULL || *s == '\0')
129  flags |= DBUS_FORCE_STDERR_NULL;
130  else
131  _dbus_verbose ("keeping stderr open due to DBUS_DEBUG_OUTPUT\n");
132 
133  if (!_dbus_ensure_standard_fds (flags, &s))
134  {
135  _dbus_warn ("%s: %s", s, _dbus_strerror (errno));
136  _exit (1);
137  }
138 
139  if (!keep_umask)
140  {
141  /* Get a predictable umask */
142  _dbus_verbose ("setting umask\n");
143  umask (022);
144  }
145 
146  _dbus_verbose ("calling setsid()\n");
147  if (setsid () == -1)
148  _dbus_assert_not_reached ("setsid() failed");
149 
150  break;
151 
152  default:
153  if (!_dbus_write_pid_to_file_and_pipe (pidfile, print_pid_pipe,
154  child_pid, error))
155  {
156  _dbus_verbose ("pid file or pipe write failed: %s\n",
157  error->message);
158  kill (child_pid, SIGTERM);
159  return FALSE;
160  }
161 
162  _dbus_verbose ("parent exiting\n");
163  _exit (0);
164  break;
165  }
166 
167  return TRUE;
168 }
169 
170 
179 static dbus_bool_t
180 _dbus_write_pid_file (const DBusString *filename,
181  unsigned long pid,
182  DBusError *error)
183 {
184  const char *cfilename;
185  int fd;
186  FILE *f;
187 
188  cfilename = _dbus_string_get_const_data (filename);
189 
190  fd = open (cfilename, O_WRONLY|O_CREAT|O_EXCL|O_BINARY, 0644);
191 
192  if (fd < 0)
193  {
194  dbus_set_error (error, _dbus_error_from_errno (errno),
195  "Failed to open \"%s\": %s", cfilename,
196  _dbus_strerror (errno));
197  return FALSE;
198  }
199 
200  if ((f = fdopen (fd, "w")) == NULL)
201  {
202  dbus_set_error (error, _dbus_error_from_errno (errno),
203  "Failed to fdopen fd %d: %s", fd, _dbus_strerror (errno));
204  _dbus_close (fd, NULL);
205  return FALSE;
206  }
207 
208  if (fprintf (f, "%lu\n", pid) < 0)
209  {
210  dbus_set_error (error, _dbus_error_from_errno (errno),
211  "Failed to write to \"%s\": %s", cfilename,
212  _dbus_strerror (errno));
213 
214  fclose (f);
215  return FALSE;
216  }
217 
218  if (fclose (f) == EOF)
219  {
220  dbus_set_error (error, _dbus_error_from_errno (errno),
221  "Failed to close \"%s\": %s", cfilename,
222  _dbus_strerror (errno));
223  return FALSE;
224  }
225 
226  return TRUE;
227 }
228 
242  DBusPipe *print_pid_pipe,
243  dbus_pid_t pid_to_write,
244  DBusError *error)
245 {
246  if (pidfile)
247  {
248  _dbus_verbose ("writing pid file %s\n", _dbus_string_get_const_data (pidfile));
249  if (!_dbus_write_pid_file (pidfile,
250  pid_to_write,
251  error))
252  {
253  _dbus_verbose ("pid file write failed\n");
254  _DBUS_ASSERT_ERROR_IS_SET(error);
255  return FALSE;
256  }
257  }
258  else
259  {
260  _dbus_verbose ("No pid file requested\n");
261  }
262 
263  if (print_pid_pipe != NULL && _dbus_pipe_is_valid (print_pid_pipe))
264  {
265  DBusString pid;
266  int bytes;
267 
268  _dbus_verbose ("writing our pid to pipe %d\n",
269  print_pid_pipe->fd);
270 
271  if (!_dbus_string_init (&pid))
272  {
273  _DBUS_SET_OOM (error);
274  return FALSE;
275  }
276 
277  if (!_dbus_string_append_int (&pid, pid_to_write) ||
278  !_dbus_string_append (&pid, "\n"))
279  {
280  _dbus_string_free (&pid);
281  _DBUS_SET_OOM (error);
282  return FALSE;
283  }
284 
285  bytes = _dbus_string_get_length (&pid);
286  if (_dbus_pipe_write (print_pid_pipe, &pid, 0, bytes, error) != bytes)
287  {
288  /* _dbus_pipe_write sets error only on failure, not short write */
289  if (error != NULL && !dbus_error_is_set(error))
290  {
292  "Printing message bus PID: did not write enough bytes\n");
293  }
294  _dbus_string_free (&pid);
295  return FALSE;
296  }
297 
298  _dbus_string_free (&pid);
299  }
300  else
301  {
302  _dbus_verbose ("No pid pipe to write to\n");
303  }
304 
305  return TRUE;
306 }
307 
315 _dbus_verify_daemon_user (const char *user)
316 {
317  DBusString u;
318 
319  _dbus_string_init_const (&u, user);
320 
322 }
323 
324 
325 /* The HAVE_LIBAUDIT case lives in selinux.c */
326 #ifndef HAVE_LIBAUDIT
327 
335 _dbus_change_to_daemon_user (const char *user,
336  DBusError *error)
337 {
338  dbus_uid_t uid;
339  dbus_gid_t gid;
340  DBusString u;
341 
342  _dbus_string_init_const (&u, user);
343 
344  if (!_dbus_get_user_id_and_primary_group (&u, &uid, &gid))
345  {
347  "User '%s' does not appear to exist?",
348  user);
349  return FALSE;
350  }
351 
352  /* setgroups() only works if we are a privileged process,
353  * so we don't return error on failure; the only possible
354  * failure is that we don't have perms to do it.
355  *
356  * not sure this is right, maybe if setuid()
357  * is going to work then setgroups() should also work.
358  */
359  if (setgroups (0, NULL) < 0)
360  _dbus_warn ("Failed to drop supplementary groups: %s",
361  _dbus_strerror (errno));
362 
363  /* Set GID first, or the setuid may remove our permission
364  * to change the GID
365  */
366  if (setgid (gid) < 0)
367  {
368  dbus_set_error (error, _dbus_error_from_errno (errno),
369  "Failed to set GID to %lu: %s", gid,
370  _dbus_strerror (errno));
371  return FALSE;
372  }
373 
374  if (setuid (uid) < 0)
375  {
376  dbus_set_error (error, _dbus_error_from_errno (errno),
377  "Failed to set UID to %lu: %s", uid,
378  _dbus_strerror (errno));
379  return FALSE;
380  }
381 
382  return TRUE;
383 }
384 #endif /* !HAVE_LIBAUDIT */
385 
386 #ifdef HAVE_SETRLIMIT
387 
388 /* We assume that if we have setrlimit, we also have getrlimit and
389  * struct rlimit.
390  */
391 
392 struct DBusRLimit {
393  struct rlimit lim;
394 };
395 
396 DBusRLimit *
397 _dbus_rlimit_save_fd_limit (DBusError *error)
398 {
399  DBusRLimit *self;
400 
401  self = dbus_new0 (DBusRLimit, 1);
402 
403  if (self == NULL)
404  {
405  _DBUS_SET_OOM (error);
406  return NULL;
407  }
408 
409  if (getrlimit (RLIMIT_NOFILE, &self->lim) < 0)
410  {
411  dbus_set_error (error, _dbus_error_from_errno (errno),
412  "Failed to get fd limit: %s", _dbus_strerror (errno));
413  dbus_free (self);
414  return NULL;
415  }
416 
417  return self;
418 }
419 
420 /* Enough fds that we shouldn't run out, even if several uids work
421  * together to carry out a denial-of-service attack. This happens to be
422  * the same number that systemd < 234 would normally use. */
423 #define ENOUGH_FDS 65536
424 
426 _dbus_rlimit_raise_fd_limit (DBusError *error)
427 {
428  struct rlimit old, lim;
429 
430  if (getrlimit (RLIMIT_NOFILE, &lim) < 0)
431  {
432  dbus_set_error (error, _dbus_error_from_errno (errno),
433  "Failed to get fd limit: %s", _dbus_strerror (errno));
434  return FALSE;
435  }
436 
437  old = lim;
438 
439  if (getuid () == 0)
440  {
441  /* We are privileged, so raise the soft limit to at least
442  * ENOUGH_FDS, and the hard limit to at least the desired soft
443  * limit. This assumes we can exercise CAP_SYS_RESOURCE on Linux,
444  * or other OSs' equivalents. */
445  if (lim.rlim_cur != RLIM_INFINITY &&
446  lim.rlim_cur < ENOUGH_FDS)
447  lim.rlim_cur = ENOUGH_FDS;
448 
449  if (lim.rlim_max != RLIM_INFINITY &&
450  lim.rlim_max < lim.rlim_cur)
451  lim.rlim_max = lim.rlim_cur;
452  }
453 
454  /* Raise the soft limit to match the hard limit, which we can do even
455  * if we are unprivileged. In particular, systemd >= 240 will normally
456  * set rlim_cur to 1024 and rlim_max to 512*1024, recent Debian
457  * versions end up setting rlim_cur to 1024 and rlim_max to 1024*1024,
458  * and older and non-systemd Linux systems would typically set rlim_cur
459  * to 1024 and rlim_max to 4096. */
460  if (lim.rlim_max == RLIM_INFINITY || lim.rlim_cur < lim.rlim_max)
461  lim.rlim_cur = lim.rlim_max;
462 
463  /* Early-return if there is nothing to do. */
464  if (lim.rlim_max == old.rlim_max &&
465  lim.rlim_cur == old.rlim_cur)
466  return TRUE;
467 
468  if (setrlimit (RLIMIT_NOFILE, &lim) < 0)
469  {
470  dbus_set_error (error, _dbus_error_from_errno (errno),
471  "Failed to set fd limit to %lu: %s",
472  (unsigned long) lim.rlim_cur,
473  _dbus_strerror (errno));
474  return FALSE;
475  }
476 
477  return TRUE;
478 }
479 
481 _dbus_rlimit_restore_fd_limit (DBusRLimit *saved,
482  DBusError *error)
483 {
484  if (setrlimit (RLIMIT_NOFILE, &saved->lim) < 0)
485  {
486  dbus_set_error (error, _dbus_error_from_errno (errno),
487  "Failed to restore old fd limit: %s",
488  _dbus_strerror (errno));
489  return FALSE;
490  }
491 
492  return TRUE;
493 }
494 
495 #else /* !HAVE_SETRLIMIT */
496 
497 static void
498 fd_limit_not_supported (DBusError *error)
499 {
501  "cannot change fd limit on this platform");
502 }
503 
504 DBusRLimit *
505 _dbus_rlimit_save_fd_limit (DBusError *error)
506 {
507  fd_limit_not_supported (error);
508  return NULL;
509 }
510 
512 _dbus_rlimit_raise_fd_limit (DBusError *error)
513 {
514  fd_limit_not_supported (error);
515  return FALSE;
516 }
517 
519 _dbus_rlimit_restore_fd_limit (DBusRLimit *saved,
520  DBusError *error)
521 {
522  fd_limit_not_supported (error);
523  return FALSE;
524 }
525 
526 #endif
527 
528 void
529 _dbus_rlimit_free (DBusRLimit *lim)
530 {
531  dbus_free (lim);
532 }
533 
539 void
541  DBusSignalHandler handler)
542 {
543  struct sigaction act;
544  sigset_t empty_mask;
545 
546  sigemptyset (&empty_mask);
547  act.sa_handler = handler;
548  act.sa_mask = empty_mask;
549  act.sa_flags = 0;
550  sigaction (sig, &act, NULL);
551 }
552 
559 _dbus_file_exists (const char *file)
560 {
561  return (access (file, F_OK) == 0);
562 }
563 
571 _dbus_user_at_console (const char *username,
572  DBusError *error)
573 {
574 #ifdef DBUS_CONSOLE_AUTH_DIR
575  DBusString u, f;
576  dbus_bool_t result;
577 
578  result = FALSE;
579  if (!_dbus_string_init (&f))
580  {
581  _DBUS_SET_OOM (error);
582  return FALSE;
583  }
584 
585  if (!_dbus_string_append (&f, DBUS_CONSOLE_AUTH_DIR))
586  {
587  _DBUS_SET_OOM (error);
588  goto out;
589  }
590 
591  _dbus_string_init_const (&u, username);
592 
593  if (!_dbus_concat_dir_and_file (&f, &u))
594  {
595  _DBUS_SET_OOM (error);
596  goto out;
597  }
598 
599  result = _dbus_file_exists (_dbus_string_get_const_data (&f));
600 
601  out:
602  _dbus_string_free (&f);
603 
604  return result;
605 #else
606  return FALSE;
607 #endif
608 }
609 
610 
619 {
620  if (_dbus_string_get_length (filename) > 0)
621  return _dbus_string_get_byte (filename, 0) == '/';
622  else
623  return FALSE;
624 }
625 
635 _dbus_stat (const DBusString *filename,
636  DBusStat *statbuf,
637  DBusError *error)
638 {
639  const char *filename_c;
640  struct stat sb;
641 
642  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
643 
644  filename_c = _dbus_string_get_const_data (filename);
645 
646  if (stat (filename_c, &sb) < 0)
647  {
648  dbus_set_error (error, _dbus_error_from_errno (errno),
649  "%s", _dbus_strerror (errno));
650  return FALSE;
651  }
652 
653  statbuf->mode = sb.st_mode;
654  statbuf->nlink = sb.st_nlink;
655  statbuf->uid = sb.st_uid;
656  statbuf->gid = sb.st_gid;
657  statbuf->size = sb.st_size;
658  statbuf->atime = sb.st_atime;
659  statbuf->mtime = sb.st_mtime;
660  statbuf->ctime = sb.st_ctime;
661 
662  return TRUE;
663 }
664 
665 
670 {
671  DIR *d;
673 };
674 
684  DBusError *error)
685 {
686  DIR *d;
687  DBusDirIter *iter;
688  const char *filename_c;
689 
690  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
691 
692  filename_c = _dbus_string_get_const_data (filename);
693 
694  d = opendir (filename_c);
695  if (d == NULL)
696  {
697  dbus_set_error (error, _dbus_error_from_errno (errno),
698  "Failed to read directory \"%s\": %s",
699  filename_c,
700  _dbus_strerror (errno));
701  return NULL;
702  }
703  iter = dbus_new0 (DBusDirIter, 1);
704  if (iter == NULL)
705  {
706  closedir (d);
708  "Could not allocate memory for directory iterator");
709  return NULL;
710  }
711 
712  iter->d = d;
713 
714  return iter;
715 }
716 
732  DBusString *filename,
733  DBusError *error)
734 {
735  struct dirent *ent;
736  int err;
737 
738  _DBUS_ASSERT_ERROR_IS_CLEAR (error);
739 
740  again:
741  errno = 0;
742  ent = readdir (iter->d);
743 
744  if (!ent)
745  {
746  err = errno;
747 
748  if (err != 0)
749  dbus_set_error (error,
751  "%s", _dbus_strerror (err));
752 
753  return FALSE;
754  }
755  else if (ent->d_name[0] == '.' &&
756  (ent->d_name[1] == '\0' ||
757  (ent->d_name[1] == '.' && ent->d_name[2] == '\0')))
758  goto again;
759  else
760  {
761  _dbus_string_set_length (filename, 0);
762  if (!_dbus_string_append (filename, ent->d_name))
763  {
765  "No memory to read directory entry");
766  return FALSE;
767  }
768  else
769  {
770  return TRUE;
771  }
772  }
773 }
774 
778 void
780 {
781  closedir (iter->d);
782  dbus_free (iter);
783 }
784 
785 static dbus_bool_t
786 fill_user_info_from_group (struct group *g,
787  DBusGroupInfo *info,
788  DBusError *error)
789 {
790  _dbus_assert (g->gr_name != NULL);
791 
792  info->gid = g->gr_gid;
793  info->groupname = _dbus_strdup (g->gr_name);
794 
795  /* info->members = dbus_strdupv (g->gr_mem) */
796 
797  if (info->groupname == NULL)
798  {
800  return FALSE;
801  }
802 
803  return TRUE;
804 }
805 
806 static dbus_bool_t
807 fill_group_info (DBusGroupInfo *info,
808  dbus_gid_t gid,
809  const DBusString *groupname,
810  DBusError *error)
811 {
812  const char *group_c_str;
813 
814  _dbus_assert (groupname != NULL || gid != DBUS_GID_UNSET);
815  _dbus_assert (groupname == NULL || gid == DBUS_GID_UNSET);
816 
817  if (groupname)
818  group_c_str = _dbus_string_get_const_data (groupname);
819  else
820  group_c_str = NULL;
821 
822  /* For now assuming that the getgrnam() and getgrgid() flavors
823  * always correspond to the pwnam flavors, if not we have
824  * to add more configure checks.
825  */
826 
827 #if defined (HAVE_POSIX_GETPWNAM_R) || defined (HAVE_NONPOSIX_GETPWNAM_R)
828  {
829  struct group *g;
830  int result;
831  size_t buflen;
832  char *buf;
833  struct group g_str;
834  dbus_bool_t b;
835 
836  /* retrieve maximum needed size for buf */
837  buflen = sysconf (_SC_GETGR_R_SIZE_MAX);
838 
839  /* sysconf actually returns a long, but everything else expects size_t,
840  * so just recast here.
841  * https://bugs.freedesktop.org/show_bug.cgi?id=17061
842  */
843  if ((long) buflen <= 0)
844  buflen = 1024;
845 
846  result = -1;
847  while (1)
848  {
849  buf = dbus_malloc (buflen);
850  if (buf == NULL)
851  {
853  return FALSE;
854  }
855 
856  g = NULL;
857 #ifdef HAVE_POSIX_GETPWNAM_R
858  if (group_c_str)
859  result = getgrnam_r (group_c_str, &g_str, buf, buflen,
860  &g);
861  else
862  result = getgrgid_r (gid, &g_str, buf, buflen,
863  &g);
864 #else
865  g = getgrnam_r (group_c_str, &g_str, buf, buflen);
866  result = 0;
867 #endif /* !HAVE_POSIX_GETPWNAM_R */
868  /* Try a bigger buffer if ERANGE was returned:
869  https://bugs.freedesktop.org/show_bug.cgi?id=16727
870  */
871  if (result == ERANGE && buflen < 512 * 1024)
872  {
873  dbus_free (buf);
874  buflen *= 2;
875  }
876  else
877  {
878  break;
879  }
880  }
881 
882  if (result == 0 && g == &g_str)
883  {
884  b = fill_user_info_from_group (g, info, error);
885  dbus_free (buf);
886  return b;
887  }
888  else
889  {
890  dbus_set_error (error, _dbus_error_from_errno (errno),
891  "Group %s unknown or failed to look it up\n",
892  group_c_str ? group_c_str : "???");
893  dbus_free (buf);
894  return FALSE;
895  }
896  }
897 #else /* ! HAVE_GETPWNAM_R */
898  {
899  /* I guess we're screwed on thread safety here */
900  struct group *g;
901 
902  g = getgrnam (group_c_str);
903 
904  if (g != NULL)
905  {
906  return fill_user_info_from_group (g, info, error);
907  }
908  else
909  {
910  dbus_set_error (error, _dbus_error_from_errno (errno),
911  "Group %s unknown or failed to look it up\n",
912  group_c_str ? group_c_str : "???");
913  return FALSE;
914  }
915  }
916 #endif /* ! HAVE_GETPWNAM_R */
917 }
918 
930  const DBusString *groupname,
931  DBusError *error)
932 {
933  return fill_group_info (info, DBUS_GID_UNSET,
934  groupname, error);
935 
936 }
937 
949  dbus_gid_t gid,
950  DBusError *error)
951 {
952  return fill_group_info (info, gid, NULL, error);
953 }
954 
965  dbus_uid_t *uid_p)
966 {
967  return _dbus_get_user_id (username, uid_p);
968 
969 }
970 
981  dbus_gid_t *gid_p)
982 {
983  return _dbus_get_group_id (groupname, gid_p);
984 }
985 
998  dbus_gid_t **group_ids,
999  int *n_group_ids)
1000 {
1001  return _dbus_groups_from_uid (uid, group_ids, n_group_ids);
1002 }
1003 
1015  DBusError *error)
1016 {
1017  return _dbus_is_console_user (uid, error);
1018 
1019 }
1020 
1030 {
1031  return uid == _dbus_geteuid ();
1032 }
1033 
1042 _dbus_windows_user_is_process_owner (const char *windows_sid)
1043 {
1044  return FALSE;
1045 }
1046  /* End of DBusInternalsUtils functions */
1048 
1062  DBusString *dirname)
1063 {
1064  int sep;
1065 
1066  _dbus_assert (filename != dirname);
1067  _dbus_assert (filename != NULL);
1068  _dbus_assert (dirname != NULL);
1069 
1070  /* Ignore any separators on the end */
1071  sep = _dbus_string_get_length (filename);
1072  if (sep == 0)
1073  return _dbus_string_append (dirname, "."); /* empty string passed in */
1074 
1075  while (sep > 0 && _dbus_string_get_byte (filename, sep - 1) == '/')
1076  --sep;
1077 
1078  _dbus_assert (sep >= 0);
1079 
1080  if (sep == 0)
1081  return _dbus_string_append (dirname, "/");
1082 
1083  /* Now find the previous separator */
1084  _dbus_string_find_byte_backward (filename, sep, '/', &sep);
1085  if (sep < 0)
1086  return _dbus_string_append (dirname, ".");
1087 
1088  /* skip multiple separators */
1089  while (sep > 0 && _dbus_string_get_byte (filename, sep - 1) == '/')
1090  --sep;
1091 
1092  _dbus_assert (sep >= 0);
1093 
1094  if (sep == 0 &&
1095  _dbus_string_get_byte (filename, 0) == '/')
1096  return _dbus_string_append (dirname, "/");
1097  else
1098  return _dbus_string_copy_len (filename, 0, sep - 0,
1099  dirname, _dbus_string_get_length (dirname));
1100 } /* DBusString stuff */
1102 
1103 static void
1104 string_squash_nonprintable (DBusString *str)
1105 {
1106  unsigned char *buf;
1107  int i, len;
1108 
1109  buf = _dbus_string_get_udata (str);
1110  len = _dbus_string_get_length (str);
1111 
1112  /* /proc/$pid/cmdline is a sequence of \0-terminated words, but we
1113  * want a sequence of space-separated words, with no extra trailing
1114  * space:
1115  * "/bin/sleep" "\0" "60" "\0"
1116  * -> "/bin/sleep" "\0" "60"
1117  * -> "/bin/sleep" " " "60"
1118  *
1119  * so chop off the trailing NUL before cleaning up unprintable
1120  * characters. */
1121  if (len > 0 && buf[len - 1] == '\0')
1122  {
1123  _dbus_string_shorten (str, 1);
1124  len--;
1125  }
1126 
1127  for (i = 0; i < len; i++)
1128  {
1129  unsigned char c = (unsigned char) buf[i];
1130  if (c == '\0')
1131  buf[i] = ' ';
1132  else if (c < 0x20 || c > 127)
1133  buf[i] = '?';
1134  }
1135 }
1136 
1151 dbus_bool_t
1152 _dbus_command_for_pid (unsigned long pid,
1153  DBusString *str,
1154  int max_len,
1155  DBusError *error)
1156 {
1157  /* This is all Linux-specific for now */
1158  DBusString path;
1159  DBusString cmdline;
1160  int fd;
1161 
1162  if (!_dbus_string_init (&path))
1163  {
1164  _DBUS_SET_OOM (error);
1165  return FALSE;
1166  }
1167 
1168  if (!_dbus_string_init (&cmdline))
1169  {
1170  _DBUS_SET_OOM (error);
1171  _dbus_string_free (&path);
1172  return FALSE;
1173  }
1174 
1175  if (!_dbus_string_append_printf (&path, "/proc/%ld/cmdline", pid))
1176  goto oom;
1177 
1178  fd = open (_dbus_string_get_const_data (&path), O_RDONLY);
1179  if (fd < 0)
1180  {
1181  dbus_set_error (error,
1182  _dbus_error_from_errno (errno),
1183  "Failed to open \"%s\": %s",
1184  _dbus_string_get_const_data (&path),
1185  _dbus_strerror (errno));
1186  goto fail;
1187  }
1188 
1189  if (!_dbus_read (fd, &cmdline, max_len))
1190  {
1191  dbus_set_error (error,
1192  _dbus_error_from_errno (errno),
1193  "Failed to read from \"%s\": %s",
1194  _dbus_string_get_const_data (&path),
1195  _dbus_strerror (errno));
1196  _dbus_close (fd, NULL);
1197  goto fail;
1198  }
1199 
1200  if (!_dbus_close (fd, error))
1201  goto fail;
1202 
1203  string_squash_nonprintable (&cmdline);
1204 
1205  if (!_dbus_string_copy (&cmdline, 0, str, _dbus_string_get_length (str)))
1206  goto oom;
1207 
1208  _dbus_string_free (&cmdline);
1209  _dbus_string_free (&path);
1210  return TRUE;
1211 oom:
1212  _DBUS_SET_OOM (error);
1213 fail:
1214  _dbus_string_free (&cmdline);
1215  _dbus_string_free (&path);
1216  return FALSE;
1217 }
1218 
1229 {
1230  return TRUE;
1231 }
1232 
1233 static dbus_bool_t
1234 ensure_owned_directory (const char *label,
1235  const DBusString *string,
1236  dbus_bool_t create,
1237  DBusError *error)
1238 {
1239  const char *dir = _dbus_string_get_const_data (string);
1240  struct stat buf;
1241 
1242  if (create && !_dbus_ensure_directory (string, error))
1243  return FALSE;
1244 
1245  /*
1246  * The stat()-based checks in this function are to protect against
1247  * mistakes, not malice. We are working in a directory that is meant
1248  * to be trusted; but if a user has used `su` or similar to escalate
1249  * their privileges without correctly clearing the environment, the
1250  * XDG_RUNTIME_DIR in the environment might still be the user's
1251  * and not root's. We don't want to write root-owned files into that
1252  * directory, so just warn and don't provide support for transient
1253  * services in that case.
1254  *
1255  * In particular, we use stat() and not lstat() so that if we later
1256  * decide to use a different directory name for transient services,
1257  * we can drop in a compatibility symlink without breaking older
1258  * libdbus.
1259  */
1260 
1261  if (stat (dir, &buf) != 0)
1262  {
1263  int saved_errno = errno;
1264 
1265  dbus_set_error (error, _dbus_error_from_errno (saved_errno),
1266  "%s \"%s\" not available: %s", label, dir,
1267  _dbus_strerror (saved_errno));
1268  return FALSE;
1269  }
1270 
1271  if (!S_ISDIR (buf.st_mode))
1272  {
1273  dbus_set_error (error, DBUS_ERROR_FAILED, "%s \"%s\" is not a directory",
1274  label, dir);
1275  return FALSE;
1276  }
1277 
1278  if (buf.st_uid != geteuid ())
1279  {
1281  "%s \"%s\" is owned by uid %ld, not our uid %ld",
1282  label, dir, (long) buf.st_uid, (long) geteuid ());
1283  return FALSE;
1284  }
1285 
1286  /* This is just because we have the stat() results already, so we might
1287  * as well check opportunistically. */
1288  if ((S_IWOTH | S_IWGRP) & buf.st_mode)
1289  {
1291  "%s \"%s\" can be written by others (mode 0%o)",
1292  label, dir, buf.st_mode);
1293  return FALSE;
1294  }
1295 
1296  return TRUE;
1297 }
1298 
1299 #define DBUS_UNIX_STANDARD_SESSION_SERVICEDIR "/dbus-1/services"
1300 #define DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR "/dbus-1/system-services"
1301 
1311  DBusError *error)
1312 {
1313  const char *xdg_runtime_dir;
1314  DBusString services;
1315  DBusString dbus1;
1316  DBusString xrd;
1317  dbus_bool_t ret = FALSE;
1318  char *data = NULL;
1319 
1320  if (!_dbus_string_init (&dbus1))
1321  {
1322  _DBUS_SET_OOM (error);
1323  return FALSE;
1324  }
1325 
1326  if (!_dbus_string_init (&services))
1327  {
1328  _dbus_string_free (&dbus1);
1329  _DBUS_SET_OOM (error);
1330  return FALSE;
1331  }
1332 
1333  if (!_dbus_string_init (&xrd))
1334  {
1335  _dbus_string_free (&dbus1);
1336  _dbus_string_free (&services);
1337  _DBUS_SET_OOM (error);
1338  return FALSE;
1339  }
1340 
1341  xdg_runtime_dir = _dbus_getenv ("XDG_RUNTIME_DIR");
1342 
1343  /* Not an error, we just can't have transient session services */
1344  if (xdg_runtime_dir == NULL)
1345  {
1346  _dbus_verbose ("XDG_RUNTIME_DIR is unset: transient session services "
1347  "not available here\n");
1348  ret = TRUE;
1349  goto out;
1350  }
1351 
1352  if (!_dbus_string_append (&xrd, xdg_runtime_dir) ||
1353  !_dbus_string_append_printf (&dbus1, "%s/dbus-1",
1354  xdg_runtime_dir) ||
1355  !_dbus_string_append_printf (&services, "%s/dbus-1/services",
1356  xdg_runtime_dir))
1357  {
1358  _DBUS_SET_OOM (error);
1359  goto out;
1360  }
1361 
1362  if (!ensure_owned_directory ("XDG_RUNTIME_DIR", &xrd, FALSE, error) ||
1363  !ensure_owned_directory ("XDG_RUNTIME_DIR subdirectory", &dbus1, TRUE,
1364  error) ||
1365  !ensure_owned_directory ("XDG_RUNTIME_DIR subdirectory", &services,
1366  TRUE, error))
1367  goto out;
1368 
1369  if (!_dbus_string_steal_data (&services, &data) ||
1370  !_dbus_list_append (dirs, data))
1371  {
1372  _DBUS_SET_OOM (error);
1373  goto out;
1374  }
1375 
1376  _dbus_verbose ("Transient service directory is %s\n", data);
1377  /* Ownership was transferred to @dirs */
1378  data = NULL;
1379  ret = TRUE;
1380 
1381 out:
1382  _dbus_string_free (&dbus1);
1383  _dbus_string_free (&services);
1384  _dbus_string_free (&xrd);
1385  dbus_free (data);
1386  return ret;
1387 }
1388 
1408 {
1409  const char *xdg_data_home;
1410  const char *xdg_data_dirs;
1411  DBusString servicedir_path;
1412 
1413  if (!_dbus_string_init (&servicedir_path))
1414  return FALSE;
1415 
1416  xdg_data_home = _dbus_getenv ("XDG_DATA_HOME");
1417  xdg_data_dirs = _dbus_getenv ("XDG_DATA_DIRS");
1418 
1419  if (xdg_data_home != NULL)
1420  {
1421  if (!_dbus_string_append (&servicedir_path, xdg_data_home))
1422  goto oom;
1423  }
1424  else
1425  {
1426  const DBusString *homedir;
1427  DBusString local_share;
1428 
1429  if (!_dbus_homedir_from_current_process (&homedir))
1430  goto oom;
1431 
1432  if (!_dbus_string_append (&servicedir_path, _dbus_string_get_const_data (homedir)))
1433  goto oom;
1434 
1435  _dbus_string_init_const (&local_share, "/.local/share");
1436  if (!_dbus_concat_dir_and_file (&servicedir_path, &local_share))
1437  goto oom;
1438  }
1439 
1440  if (!_dbus_string_append (&servicedir_path, ":"))
1441  goto oom;
1442 
1443  if (xdg_data_dirs != NULL)
1444  {
1445  if (!_dbus_string_append (&servicedir_path, xdg_data_dirs))
1446  goto oom;
1447 
1448  if (!_dbus_string_append (&servicedir_path, ":"))
1449  goto oom;
1450  }
1451  else
1452  {
1453  if (!_dbus_string_append (&servicedir_path, "/usr/local/share:/usr/share:"))
1454  goto oom;
1455  }
1456 
1457  /*
1458  * add configured datadir to defaults
1459  * this may be the same as an xdg dir
1460  * however the config parser should take
1461  * care of duplicates
1462  */
1463  if (!_dbus_string_append (&servicedir_path, DBUS_DATADIR))
1464  goto oom;
1465 
1466  if (!_dbus_split_paths_and_append (&servicedir_path,
1467  DBUS_UNIX_STANDARD_SESSION_SERVICEDIR,
1468  dirs))
1469  goto oom;
1470 
1471  _dbus_string_free (&servicedir_path);
1472  return TRUE;
1473 
1474  oom:
1475  _dbus_string_free (&servicedir_path);
1476  return FALSE;
1477 }
1478 
1479 
1500 {
1501  /*
1502  * DBUS_DATADIR may be the same as one of the standard directories. However,
1503  * the config parser should take care of the duplicates.
1504  *
1505  * Also, append /lib as counterpart of /usr/share on the root
1506  * directory (the root directory does not know /share), in order to
1507  * facilitate early boot system bus activation where /usr might not
1508  * be available.
1509  */
1510  static const char standard_search_path[] =
1511  "/usr/local/share:"
1512  "/usr/share:"
1513  DBUS_DATADIR ":"
1514  "/lib";
1515  DBusString servicedir_path;
1516 
1517  _dbus_string_init_const (&servicedir_path, standard_search_path);
1518 
1519  return _dbus_split_paths_and_append (&servicedir_path,
1520  DBUS_UNIX_STANDARD_SYSTEM_SERVICEDIR,
1521  dirs);
1522 }
1523 
1534 {
1535  _dbus_assert (_dbus_string_get_length (str) == 0);
1536 
1537  return _dbus_string_append (str, DBUS_SYSTEM_CONFIG_FILE);
1538 }
1539 
1548 {
1549  _dbus_assert (_dbus_string_get_length (str) == 0);
1550 
1551  return _dbus_string_append (str, DBUS_SESSION_CONFIG_FILE);
1552 }
1553 
1558 void
1560 {
1561 #ifdef HAVE_SYSTEMD
1562  sd_notify (0, "READY=1");
1563 #endif
1564 }
1565 
1570 void
1572 {
1573 #ifdef HAVE_SYSTEMD
1574  sd_notify (0, "RELOADING=1");
1575 #endif
1576 }
1577 
1582 void
1584 {
1585 #ifdef HAVE_SYSTEMD
1586  /* For systemd, this is the same code */
1588 #endif
1589 }
1590 
1595 void
1597 {
1598 #ifdef HAVE_SYSTEMD
1599  sd_notify (0, "STOPPING=1");
1600 #endif
1601 }
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
Definition: dbus-string.c:959
dbus_bool_t _dbus_split_paths_and_append(DBusString *dirs, const char *suffix, DBusList **dir_list)
Split paths into a list of char strings.
Definition: dbus-sysdeps.c:236
const char * message
public error message field
Definition: dbus-errors.h:51
#define NULL
A null pointer, defined appropriately for C or C++.
dbus_bool_t _dbus_become_daemon(const DBusString *pidfile, DBusPipe *print_pid_pipe, DBusError *error, dbus_bool_t keep_umask)
Does the chdir, fork, setsid, etc.
dbus_bool_t _dbus_unix_user_is_at_console(dbus_uid_t uid, DBusError *error)
Checks to see if the UNIX user ID is at the console.
dbus_bool_t _dbus_group_info_fill_gid(DBusGroupInfo *info, dbus_gid_t gid, DBusError *error)
Initializes the given DBusGroupInfo struct with information about the given group ID...
dbus_bool_t _dbus_string_get_dirname(const DBusString *filename, DBusString *dirname)
Get the directory name from a complete filename.
dbus_bool_t _dbus_ensure_directory(const DBusString *filename, DBusError *error)
Creates a directory; succeeds if the directory is created or already existed.
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
Definition: dbus-memory.c:703
dbus_bool_t _dbus_path_is_absolute(const DBusString *filename)
Checks whether the filename is an absolute path.
Portable struct with stat() results.
Definition: dbus-sysdeps.h:546
dbus_bool_t _dbus_ensure_standard_fds(DBusEnsureStandardFdsFlags flags, const char **error_str_p)
Ensure that the standard file descriptors stdin, stdout and stderr are open, by opening /dev/null if ...
#define DBUS_ERROR_NOT_SUPPORTED
Requested operation isn&#39;t supported (like ENOSYS on UNIX).
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_string_append_int(DBusString *str, long value)
Appends an integer to a DBusString.
Definition: dbus-sysdeps.c:363
dbus_bool_t _dbus_groups_from_uid(dbus_uid_t uid, dbus_gid_t **group_ids, int *n_group_ids)
Gets all groups corresponding to the given UID.
dbus_bool_t _dbus_parse_unix_group_from_config(const DBusString *groupname, dbus_gid_t *gid_p)
Parse a UNIX group from the bus config file.
void _dbus_directory_close(DBusDirIter *iter)
Closes a directory iteration.
dbus_bool_t _dbus_is_console_user(dbus_uid_t uid, DBusError *error)
Checks to see if the UID sent in is the console user.
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
dbus_bool_t _dbus_directory_get_next_file(DBusDirIter *iter, DBusString *filename, DBusError *error)
Get next file in the directory.
unsigned long atime
Access time.
Definition: dbus-sysdeps.h:553
dbus_bool_t _dbus_get_standard_session_servicedirs(DBusList **dirs)
Returns the standard directories for a session bus to look for service activation files...
dbus_bool_t _dbus_concat_dir_and_file(DBusString *dir, const DBusString *next_component)
Appends the given filename to the given directory.
DBusDirIter * _dbus_directory_open(const DBusString *filename, DBusError *error)
Open a directory to iterate over.
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
Definition: dbus-string.c:182
dbus_bool_t _dbus_command_for_pid(unsigned long pid, DBusString *str, int max_len, DBusError *error)
Get a printable string describing the command used to execute the process with pid.
dbus_bool_t _dbus_get_system_config_file(DBusString *str)
Get the absolute path of the system.conf file (there is no system bus on Windows so this can just ret...
void _dbus_string_shorten(DBusString *str, int length_to_remove)
Makes a string shorter by the given number of bytes.
Definition: dbus-string.c:804
dbus_bool_t _dbus_string_copy(const DBusString *source, int start, DBusString *dest, int insert_at)
Like _dbus_string_move(), but does not delete the section of the source string that&#39;s copied to the d...
Definition: dbus-string.c:1307
char * groupname
Group name.
const char * _dbus_error_from_errno(int error_number)
Converts a UNIX errno, or Windows errno or WinSock error value into a DBusError name.
Definition: dbus-sysdeps.c:599
Internals of directory iterator.
unsigned long mode
File mode.
Definition: dbus-sysdeps.h:548
unsigned long dbus_pid_t
A process ID.
Definition: dbus-sysdeps.h:132
dbus_bool_t _dbus_get_user_id_and_primary_group(const DBusString *username, dbus_uid_t *uid_p, dbus_gid_t *gid_p)
Gets user ID and primary group given username.
dbus_bool_t _dbus_change_to_daemon_user(const char *user, DBusError *error)
Changes the user and group the bus is running as.
DIR * d
The DIR* from opendir()
void * dbus_malloc(size_t bytes)
Allocates the given number of bytes, as with standard malloc().
Definition: dbus-memory.c:463
dbus_gid_t gid
Group owning file.
Definition: dbus-sysdeps.h:551
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
Definition: dbus-memory.h:58
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:35
void _dbus_string_init_const(DBusString *str, const char *value)
Initializes a constant string.
Definition: dbus-string.c:197
dbus_bool_t _dbus_get_session_config_file(DBusString *str)
Get the absolute path of the session.conf file.
void _dbus_daemon_report_stopping(void)
Report to a service manager that the daemon calling this function is shutting down.
void _dbus_warn(const char *format,...)
Prints a warning message to stderr.
dbus_bool_t _dbus_list_append(DBusList **list, void *data)
Appends a value to the list.
Definition: dbus-list.c:271
int _dbus_read(int fd, DBusString *buffer, int count)
Thin wrapper around the read() system call that appends the data it reads to the DBusString buffer...
dbus_bool_t _dbus_string_append_printf(DBusString *str, const char *format,...)
Appends a printf-style formatted string to the DBusString.
Definition: dbus-string.c:1138
dbus_bool_t _dbus_group_info_fill(DBusGroupInfo *info, const DBusString *groupname, DBusError *error)
Initializes the given DBusGroupInfo struct with information about the given group name...
dbus_bool_t _dbus_get_group_id(const DBusString *groupname, dbus_gid_t *gid)
Gets group ID given groupname.
Object representing an exception.
Definition: dbus-errors.h:48
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
Definition: dbus-errors.c:354
dbus_bool_t _dbus_unix_groups_from_uid(dbus_uid_t uid, dbus_gid_t **group_ids, int *n_group_ids)
Gets all groups corresponding to the given UNIX user ID.
unsigned long ctime
Creation time.
Definition: dbus-sysdeps.h:555
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init(), and fills it with the same contents as #_DBUS_STRING_I...
Definition: dbus-string.c:271
#define DBUS_GID_UNSET
an invalid GID used to represent an uninitialized dbus_gid_t field
Definition: dbus-sysdeps.h:143
dbus_uid_t _dbus_geteuid(void)
Gets our effective UID.
dbus_bool_t _dbus_file_exists(const char *file)
Checks if a file exists.
#define TRUE
Expands to "1".
unsigned long nlink
Number of hard links.
Definition: dbus-sysdeps.h:549
#define _dbus_assert_not_reached(explanation)
Aborts with an error message if called.
dbus_bool_t _dbus_write_pid_to_file_and_pipe(const DBusString *pidfile, DBusPipe *print_pid_pipe, dbus_pid_t pid_to_write, DBusError *error)
Writes the given pid_to_write to a pidfile (if non-NULL) and/or to a pipe (if non-NULL).
dbus_uid_t uid
User owning file.
Definition: dbus-sysdeps.h:550
#define DBUS_ERROR_FAILED
A generic error; "something went wrong" - see the error message for more.
dbus_bool_t _dbus_verify_daemon_user(const char *user)
Verify that after the fork we can successfully change to this user.
dbus_bool_t _dbus_string_find_byte_backward(const DBusString *str, int start, unsigned char byte, int *found)
Find the given byte scanning backward from the given start.
dbus_bool_t _dbus_homedir_from_current_process(const DBusString **homedir)
Gets homedir of user owning current process.
Definition: dbus-userdb.c:402
Information about a UNIX group.
dbus_bool_t _dbus_stat(const DBusString *filename, DBusStat *statbuf, DBusError *error)
stat() wrapper.
dbus_bool_t _dbus_get_user_id(const DBusString *username, dbus_uid_t *uid)
Gets user ID given username.
void _dbus_set_signal_handler(int sig, DBusSignalHandler handler)
Installs a UNIX signal handler.
A node in a linked list.
Definition: dbus-list.h:34
dbus_bool_t _dbus_unix_user_is_process_owner(dbus_uid_t uid)
Checks to see if the UNIX user ID matches the UID of the process.
void _dbus_daemon_report_ready(void)
Report to a service manager that the daemon calling this function is ready for use.
dbus_bool_t _dbus_replace_install_prefix(DBusString *path)
Replace the DBUS_PREFIX in the given path, in-place, by the current D-Bus installation directory...
dbus_bool_t _dbus_user_at_console(const char *username, DBusError *error)
Checks if user is at the console.
void _dbus_daemon_report_reloaded(void)
Report to a service manager that the daemon calling this function is reloading configuration.
dbus_bool_t _dbus_windows_user_is_process_owner(const char *windows_sid)
Checks to see if the Windows user SID matches the owner of the process.
dbus_bool_t _dbus_set_up_transient_session_servicedirs(DBusList **dirs, DBusError *error)
Returns the standard directories for a session bus to look for transient service activation files...
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
dbus_bool_t _dbus_close(int fd, DBusError *error)
Closes a file descriptor.
#define FALSE
Expands to "0".
unsigned long mtime
Modify time.
Definition: dbus-sysdeps.h:554
dbus_bool_t _dbus_string_set_length(DBusString *str, int length)
Sets the length of a string.
Definition: dbus-string.c:826
void _dbus_daemon_report_reloading(void)
Report to a service manager that the daemon calling this function is reloading configuration.
dbus_bool_t _dbus_string_copy_len(const DBusString *source, int start, int len, DBusString *dest, int insert_at)
Like _dbus_string_copy(), but can copy a segment from the middle of the source string.
Definition: dbus-string.c:1399
dbus_bool_t _dbus_string_steal_data(DBusString *str, char **data_return)
Like _dbus_string_get_data(), but removes the gotten data from the original string.
Definition: dbus-string.c:665
dbus_gid_t gid
GID.
void(* DBusSignalHandler)(int sig)
A UNIX signal handler.
unsigned long dbus_gid_t
A group ID.
Definition: dbus-sysdeps.h:136
unsigned long size
Size of file.
Definition: dbus-sysdeps.h:552
dbus_bool_t _dbus_parse_unix_user_from_config(const DBusString *username, dbus_uid_t *uid_p)
Parse a UNIX user from the bus config file.
char * _dbus_strdup(const char *str)
Duplicates a string.
const char * _dbus_getenv(const char *varname)
Wrapper for getenv().
Definition: dbus-sysdeps.c:195
unsigned long dbus_uid_t
A user ID.
Definition: dbus-sysdeps.h:134
dbus_bool_t _dbus_get_standard_system_servicedirs(DBusList **dirs)
Returns the standard directories for a system bus to look for service activation files.
dbus_bool_t dbus_error_is_set(const DBusError *error)
Checks whether an error occurred (the error is set).
Definition: dbus-errors.c:329