D-Bus  1.6.8
dbus-sysdeps-unix.h
00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
00002 /* dbus-sysdeps-unix.h UNIX-specific wrappers around system/libc features (internal to D-Bus implementation)
00003  *
00004  * Copyright (C) 2002, 2003, 2006  Red Hat, Inc.
00005  * Copyright (C) 2003 CodeFactory AB
00006  *
00007  * Licensed under the Academic Free License version 2.1
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022  *
00023  */
00024 
00025 #ifndef DBUS_SYSDEPS_UNIX_H
00026 #define DBUS_SYSDEPS_UNIX_H
00027 
00028 #include <dbus/dbus-sysdeps.h>
00029 
00030 #ifdef DBUS_WIN
00031 #error "Don't include this on Windows"
00032 #endif
00033 
00034 DBUS_BEGIN_DECLS
00035 
00043 dbus_bool_t
00044 _dbus_close     (int               fd,
00045                  DBusError        *error);
00046 int _dbus_dup   (int               fd,
00047                  DBusError        *error);
00048 int
00049 _dbus_read      (int               fd,
00050                  DBusString       *buffer,
00051                  int               count);
00052 int
00053 _dbus_write     (int               fd,
00054                  const DBusString *buffer,
00055                  int               start,
00056                  int               len);
00057 int
00058 _dbus_write_two (int               fd,
00059                  const DBusString *buffer1,
00060                  int               start1,
00061                  int               len1,
00062                  const DBusString *buffer2,
00063                  int               start2,
00064                  int               len2);
00065 
00066 int _dbus_connect_unix_socket (const char     *path,
00067                                dbus_bool_t     abstract,
00068                                DBusError      *error);
00069 int _dbus_listen_unix_socket  (const char     *path,
00070                                dbus_bool_t     abstract,
00071                                DBusError      *error);
00072 
00073 int _dbus_connect_exec (const char     *path,
00074                         char *const    argv[],
00075                         DBusError      *error);
00076 
00077 int _dbus_listen_systemd_sockets (int       **fd,
00078                                  DBusError *error);
00079 
00080 dbus_bool_t _dbus_read_credentials (int               client_fd,
00081                                     DBusCredentials  *credentials,
00082                                     DBusError        *error);
00083 dbus_bool_t _dbus_send_credentials (int              server_fd,
00084                                     DBusError       *error);
00085 
00086 dbus_bool_t _dbus_lookup_launchd_socket (DBusString *socket_path,
00087                                          const char *launchd_env_var,
00088                                          DBusError  *error);
00089 
00091 typedef struct DBusUserInfo  DBusUserInfo;
00093 typedef struct DBusGroupInfo DBusGroupInfo;
00094 
00098 struct DBusUserInfo
00099 {
00100   dbus_uid_t  uid;            
00101   dbus_gid_t  primary_gid;    
00102   dbus_gid_t *group_ids;      
00103   int         n_group_ids;    
00104   char       *username;       
00105   char       *homedir;        
00106 };
00107 
00111 struct DBusGroupInfo
00112 {
00113   dbus_gid_t  gid;            
00114   char       *groupname;      
00115 };
00116 
00117 dbus_bool_t _dbus_user_info_fill     (DBusUserInfo     *info,
00118                                       const DBusString *username,
00119                                       DBusError        *error);
00120 dbus_bool_t _dbus_user_info_fill_uid (DBusUserInfo     *info,
00121                                       dbus_uid_t        uid,
00122                                       DBusError        *error);
00123 void        _dbus_user_info_free     (DBusUserInfo     *info);
00124 
00125 dbus_bool_t _dbus_group_info_fill     (DBusGroupInfo    *info,
00126                                        const DBusString *groupname,
00127                                        DBusError        *error);
00128 dbus_bool_t _dbus_group_info_fill_gid (DBusGroupInfo    *info,
00129                                        dbus_gid_t        gid,
00130                                        DBusError        *error);
00131 void        _dbus_group_info_free     (DBusGroupInfo    *info);
00132 
00133 dbus_uid_t    _dbus_getuid (void);
00134 dbus_uid_t    _dbus_geteuid (void);
00135 
00136 dbus_bool_t _dbus_parse_uid (const DBusString  *uid_str,
00137                              dbus_uid_t        *uid);
00138 
00139 void _dbus_close_all (void);
00140 
00143 DBUS_END_DECLS
00144 
00145 #endif /* DBUS_SYSDEPS_UNIX_H */