D-Bus  1.16.2
dbus-sysdeps-unix.h
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-sysdeps-unix.h UNIX-specific wrappers around system/libc features (internal to D-Bus implementation)
3  *
4  * Copyright (C) 2002, 2003, 2006 Red Hat, Inc.
5  * Copyright (C) 2003 CodeFactory AB
6  *
7  * SPDX-License-Identifier: AFL-2.1 OR GPL-2.0-or-later
8  *
9  * Licensed under the Academic Free License version 2.1
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24  *
25  */
26 
27 #ifndef DBUS_SYSDEPS_UNIX_H
28 #define DBUS_SYSDEPS_UNIX_H
29 
30 #include <dbus/dbus-sysdeps.h>
31 
32 #ifdef DBUS_WIN
33 #error "Don't include this on Windows"
34 #endif
35 
37 
45 DBUS_PRIVATE_EXPORT
47 _dbus_close (int fd,
48  DBusError *error);
49 DBUS_PRIVATE_EXPORT
50 int _dbus_dup (int fd,
51  DBusError *error);
52 DBUS_PRIVATE_EXPORT
53 int
54 _dbus_read (int fd,
55  DBusString *buffer,
56  int count);
57 int
58 _dbus_write (int fd,
59  const DBusString *buffer,
60  int start,
61  int len);
62 int
63 _dbus_write_two (int fd,
64  const DBusString *buffer1,
65  int start1,
66  int len1,
67  const DBusString *buffer2,
68  int start2,
69  int len2);
70 
72  DBusError *error);
73 
74 dbus_bool_t _dbus_read_credentials (int client_fd,
75  DBusCredentials *credentials,
76  DBusError *error);
77 dbus_bool_t _dbus_send_credentials (int server_fd,
78  DBusError *error);
79 
81  const char *launchd_env_var,
82  DBusError *error);
83 
85 typedef struct DBusUserInfo DBusUserInfo;
88 
93 {
94  size_t refcount;
99  char *username;
100  char *homedir;
101 };
102 
107 {
108  size_t refcount;
110  char *groupname;
111 };
112 
114  const DBusString *username,
115  DBusError *error);
117  dbus_uid_t uid,
118  DBusError *error);
120 
122  const DBusString *groupname,
123  DBusError *error);
125  dbus_gid_t gid,
126  DBusError *error);
128 
129 DBUS_PRIVATE_EXPORT
131 
132 DBUS_PRIVATE_EXPORT
133 void _dbus_close_all (void);
134 DBUS_PRIVATE_EXPORT
136 DBUS_PRIVATE_EXPORT
137 void _dbus_fd_clear_close_on_exec (int fd);
138 
140  DBusString *address,
141  DBusError *error);
142 
143 DBUS_PRIVATE_EXPORT
144 void _dbus_fd_set_close_on_exec (int fd);
145 
146 typedef enum
147 {
148  DBUS_FORCE_STDIN_NULL = (1 << 0),
149  DBUS_FORCE_STDOUT_NULL = (1 << 1),
150  DBUS_FORCE_STDERR_NULL = (1 << 2)
151 } DBusEnsureStandardFdsFlags;
152 
153 DBUS_PRIVATE_EXPORT
154 dbus_bool_t _dbus_ensure_standard_fds (DBusEnsureStandardFdsFlags flags,
155  const char **error_str_p);
156 
158 typedef void (* DBusSignalHandler) (int sig);
159 
160 void _dbus_set_signal_handler (int sig,
161  DBusSignalHandler handler);
162 
163 dbus_bool_t _dbus_reset_oom_score_adj (const char **error_str_p);
164 
168 
169 #endif /* DBUS_SYSDEPS_UNIX_H */
char * username
Username.
DBUS_PRIVATE_EXPORT void _dbus_close_all(void)
Closes all file descriptors except the first three (i.e.
#define DBUS_BEGIN_DECLS
Macro used prior to declaring functions in the D-Bus header files.
int _dbus_write(int fd, const DBusString *buffer, int start, int len)
Thin wrapper around the write() system call that writes a part of a DBusString and handles EINTR for ...
DBUS_PRIVATE_EXPORT 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 ...
dbus_bool_t _dbus_append_address_from_socket(DBusSocket fd, DBusString *address, DBusError *error)
Read the address from the socket and append it to the string.
dbus_gid_t primary_gid
GID.
DBUS_PRIVATE_EXPORT int _dbus_dup(int fd, DBusError *error)
Duplicates a file descriptor.
char * groupname
Group name.
dbus_bool_t _dbus_user_info_fill(DBusUserInfo *info, const DBusString *username, DBusError *error)
Gets user info for the given username.
void _dbus_set_signal_handler(int sig, DBusSignalHandler handler)
Installs a UNIX signal handler.
Socket interface.
Definition: dbus-sysdeps.h:185
dbus_gid_t * group_ids
Groups IDs, including above primary group.
dbus_bool_t _dbus_lookup_launchd_socket(DBusString *socket_path, const char *launchd_env_var, DBusError *error)
quries launchd for a specific env var which holds the socket path.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Definition: dbus-types.h:37
int n_group_ids
Size of group IDs array.
DBUS_PRIVATE_EXPORT void _dbus_fd_clear_close_on_exec(int fd)
Sets the file descriptor to not be close-on-exec.
int _dbus_listen_systemd_sockets(DBusSocket **fd, DBusError *error)
Acquires one or more sockets passed in from systemd.
dbus_uid_t uid
UID.
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...
void _dbus_group_info_free(DBusGroupInfo *info)
Frees the members of info (but not info itself).
Definition: dbus-userdb.c:121
void _dbus_user_info_free(DBusUserInfo *info)
Frees the members of info (but not info itself)
Definition: dbus-userdb.c:108
DBUS_PRIVATE_EXPORT 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...
Object representing an exception.
Definition: dbus-errors.h:50
DBUS_PRIVATE_EXPORT void _dbus_fd_set_all_close_on_exec(void)
Sets all file descriptors except the first three (i.e.
DBUS_PRIVATE_EXPORT dbus_uid_t _dbus_geteuid(void)
Gets our effective UID.
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...
char * homedir
Home directory.
Information about a UNIX group.
DBUS_PRIVATE_EXPORT void _dbus_fd_set_close_on_exec(int fd)
Sets the file descriptor to be close on exec.
size_t refcount
Reference count.
dbus_bool_t _dbus_user_info_fill_uid(DBusUserInfo *info, dbus_uid_t uid, DBusError *error)
Gets user info for the given user ID.
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_close(int fd, DBusError *error)
Closes a file descriptor.
int _dbus_write_two(int fd, const DBusString *buffer1, int start1, int len1, const DBusString *buffer2, int start2, int len2)
Like _dbus_write() but will use writev() if possible to write both buffers in sequence.
dbus_gid_t gid
GID.
dbus_bool_t _dbus_reset_oom_score_adj(const char **error_str_p)
If the current process has been protected from the Linux OOM killer (the oom_score_adj process parame...
void(* DBusSignalHandler)(int sig)
A UNIX signal handler.
unsigned long dbus_gid_t
A group ID.
Definition: dbus-sysdeps.h:143
unsigned long dbus_uid_t
A user ID.
Definition: dbus-sysdeps.h:141
size_t refcount
Reference count.
Information about a UNIX user.
#define DBUS_END_DECLS
Macro used after declaring functions in the D-Bus header files.