Bug 18446: Keep umask for session bus
[platform/upstream/dbus.git] / dbus / dbus-sysdeps.h
index 0cb92c6..469b5e5 100644 (file)
@@ -1,4 +1,4 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 /* dbus-sysdeps.h Wrappers around system/libc features (internal to D-Bus implementation)
  * 
  * Copyright (C) 2002, 2003  Red Hat, Inc.
  * stuff straight out of string.h, so have this here for now.
  */
 #include <string.h>
-
-/* and it would just be annoying to abstract this */
-#include <errno.h>
-
 #include <stdarg.h>
 
+/* AIX sys/poll.h does #define events reqevents, and other
+ * wonderousness, so must include sys/poll before declaring
+ * DBusPollFD
+ */ 
+#ifdef HAVE_POLL
+#include <sys/poll.h>
+#endif
+
 DBUS_BEGIN_DECLS
 
 #ifdef DBUS_WIN
@@ -95,6 +100,8 @@ void _dbus_abort (void) _DBUS_GNUC_NORETURN;
 const char* _dbus_getenv (const char *varname);
 dbus_bool_t _dbus_setenv (const char *varname,
                          const char *value);
+dbus_bool_t _dbus_clearenv (void);
+char **     _dbus_get_environment (void);
 
 /** A process ID */
 typedef unsigned long dbus_pid_t;
@@ -147,11 +154,14 @@ int         _dbus_write_socket_two (int               fd,
                                     int               start2,
                                     int               len2);
 int _dbus_connect_tcp_socket  (const char     *host,
-                               dbus_uint32_t   port,
+                               const char     *port,
+                               const char     *family,
                                DBusError      *error);
 int _dbus_listen_tcp_socket   (const char     *host,
-                               dbus_uint32_t  *port,
-                               dbus_bool_t     inaddr_any,
+                               const char     *port,
+                               const char     *family,
+                               DBusString     *retport,
+                               int           **fds_p,
                                DBusError      *error);
 int _dbus_accept              (int             listen_fd);
 
@@ -162,18 +172,11 @@ dbus_bool_t _dbus_read_credentials_socket (int               client_fd,
 dbus_bool_t _dbus_send_credentials_socket (int              server_fd,
                                            DBusError       *error);
 
-dbus_bool_t _dbus_credentials_add_from_username        (DBusCredentials  *credentials,
+dbus_bool_t _dbus_credentials_add_from_user            (DBusCredentials  *credentials,
                                                         const DBusString *username);
 dbus_bool_t _dbus_credentials_add_from_current_process (DBusCredentials  *credentials);
-dbus_bool_t _dbus_credentials_parse_and_add_desired    (DBusCredentials  *credentials,
-                                                        const DBusString *desired_identity);
-
-dbus_bool_t _dbus_username_from_current_process (const DBusString **username);
-dbus_bool_t _dbus_append_desired_identity       (DBusString *str);
+dbus_bool_t _dbus_append_user_from_current_process     (DBusString        *str);
 
-dbus_bool_t _dbus_homedir_from_current_process  (const DBusString **homedir);
-dbus_bool_t _dbus_homedir_from_username         (const DBusString  *username,
-                                                 DBusString        *homedir);
 dbus_bool_t _dbus_parse_unix_user_from_config   (const DBusString  *username,
                                                  dbus_uid_t        *uid_p);
 dbus_bool_t _dbus_parse_unix_group_from_config  (const DBusString  *groupname,
@@ -186,6 +189,8 @@ dbus_bool_t _dbus_unix_user_is_at_console       (dbus_uid_t         uid,
 dbus_bool_t _dbus_unix_user_is_process_owner    (dbus_uid_t         uid);
 dbus_bool_t _dbus_windows_user_is_process_owner (const char        *windows_sid);
 
+dbus_bool_t _dbus_append_keyring_directory_for_credentials (DBusString      *directory,
+                                                            DBusCredentials *credentials);
 
 /** Opaque type representing an atomically-modifiable integer
  * that can be used from multiple threads.
@@ -204,9 +209,36 @@ struct DBusAtomic
 #endif
 };
 
+/* The value we get from autofoo is in the form of a cpp expression;
+ * convert that to a conventional defined/undef switch. (We can't get
+ * the conventional defined/undef because of multiarch builds only running
+ * ./configure once, on Darwin.) */
+#if DBUS_HAVE_ATOMIC_INT_COND
+#   define DBUS_HAVE_ATOMIC_INT 1
+#else
+#   undef DBUS_HAVE_ATOMIC_INT
+#endif
+
 dbus_int32_t _dbus_atomic_inc (DBusAtomic *atomic);
 dbus_int32_t _dbus_atomic_dec (DBusAtomic *atomic);
 
+
+/* AIX uses different values for poll */
+
+#ifdef _AIX
+/** There is data to read */
+#define _DBUS_POLLIN      0x0001
+/** There is urgent data to read */
+#define _DBUS_POLLPRI     0x0004
+/** Writing now will not block */
+#define _DBUS_POLLOUT     0x0002
+/** Error condition */
+#define _DBUS_POLLERR     0x4000
+/** Hung up */
+#define _DBUS_POLLHUP     0x2000
+/** Invalid request: fd not open */
+#define _DBUS_POLLNVAL    0x8000
+#else
 /** There is data to read */
 #define _DBUS_POLLIN      0x0001
 /** There is urgent data to read */
@@ -219,6 +251,7 @@ dbus_int32_t _dbus_atomic_dec (DBusAtomic *atomic);
 #define _DBUS_POLLHUP     0x0010
 /** Invalid request: fd not open */
 #define _DBUS_POLLNVAL    0x0020
+#endif
 
 /**
  * A portable struct pollfd wrapper. 
@@ -269,6 +302,10 @@ dbus_bool_t _dbus_string_get_dirname  (const DBusString *filename,
 dbus_bool_t _dbus_path_is_absolute    (const DBusString *filename);
 
 dbus_bool_t _dbus_get_standard_session_servicedirs (DBusList **dirs);
+dbus_bool_t _dbus_get_standard_system_servicedirs (DBusList **dirs);
+
+dbus_bool_t _dbus_append_system_config_file  (DBusString *str);
+dbus_bool_t _dbus_append_session_config_file (DBusString *str);
 
 typedef struct {
   int fd_or_handle;
@@ -320,6 +357,13 @@ dbus_bool_t _dbus_generate_random_ascii        (DBusString *str,
 
 const char* _dbus_error_from_errno (int error_number);
 
+void        _dbus_set_errno_to_zero                  (void);
+dbus_bool_t _dbus_get_is_errno_nonzero               (void);
+dbus_bool_t _dbus_get_is_errno_eagain_or_ewouldblock (void);
+dbus_bool_t _dbus_get_is_errno_enomem                (void);
+dbus_bool_t _dbus_get_is_errno_eintr                 (void);
+const char* _dbus_strerror_from_errno                (void);
+
 void _dbus_disable_sigpipe (void);
 
 
@@ -356,14 +400,18 @@ void        _dbus_print_backtrace  (void);
 
 dbus_bool_t _dbus_become_daemon   (const DBusString *pidfile,
                                    DBusPipe         *print_pid_pipe,
-                                   DBusError        *error);
-dbus_bool_t _dbus_write_pid_file  (const DBusString *filename,
-                                   unsigned long     pid,
-                                   DBusError        *error);
+                                   DBusError        *error,
+                                   dbus_bool_t       keep_umask);
+
 dbus_bool_t _dbus_verify_daemon_user    (const char *user);
 dbus_bool_t _dbus_change_to_daemon_user (const char *user,
                                          DBusError  *error);
 
+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);
+
 /** A UNIX signal handler */
 typedef void (* DBusSignalHandler) (int sig);