D-Bus: dbus-userdb.c Source File

D-Bus 1.12.20

dbus-userdb.c
1 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
2 /* dbus-userdb.c User database abstraction
3 *
4 * Copyright (C) 2003, 2004 Red Hat, Inc.
5 *
6 * Licensed under the Academic Free License version 2.1
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 */
23 #include <config.h>
24 #define DBUS_USERDB_INCLUDES_PRIVATE 1
25 #include "dbus-userdb.h"
26 #include "dbus-hash.h"
27 #include "dbus-test.h"
28 #include "dbus-internals.h"
29 #include "dbus-protocol.h"
30 #include "dbus-credentials.h"
31 #include <string.h>
32
38 static DBusUserInfo *
39 _dbus_user_info_ref (DBusUserInfo *info)
40 {
41 _dbus_assert (info->refcount > 0);
42 _dbus_assert (info->refcount < SIZE_MAX);
43 info->refcount++;
44 return info;
45 }
46
54 void
55 _dbus_user_info_unref (DBusUserInfo *info)
56 {
57 if (info == NULL) /* hash table will pass NULL */
58 return;
59
60 _dbus_assert (info->refcount > 0);
61 _dbus_assert (info->refcount < SIZE_MAX);
62
63 if (--info->refcount > 0)
64 return;
65
66 _dbus_user_info_free (info);
67 dbus_free (info);
68 }
69
77 void
78 _dbus_group_info_unref (DBusGroupInfo *info)
79 {
80 if (info == NULL) /* hash table will pass NULL */
81 return;
82
83 _dbus_assert (info->refcount > 0);
84 _dbus_assert (info->refcount < SIZE_MAX);
85
86 if (--info->refcount > 0)
87 return;
88
89 _dbus_group_info_free (info);
90 dbus_free (info);
91 }
92
98 void
99 _dbus_user_info_free (DBusUserInfo *info)
100 {
101 dbus_free (info->group_ids);
102 dbus_free (info->username);
103 dbus_free (info->homedir);
104 }
105
111 void
112 _dbus_group_info_free (DBusGroupInfo *info)
113 {
114 dbus_free (info->groupname);
115 }
116
125 dbus_bool_t
126 _dbus_is_a_number (const DBusString *str,
127 unsigned long *num)
128 {
129 int end;
130
131 if (_dbus_string_parse_uint (str, 0, num, &end) &&
132 end == _dbus_string_get_length (str))
133 return TRUE;
134 else
135 return FALSE;
136 }
137
150 const DBusUserInfo *
151 _dbus_user_database_lookup (DBusUserDatabase *db,
152 dbus_uid_t uid,
153 const DBusString *username,
154 DBusError *error)
155 {
156 DBusUserInfo *info;
157
158 _DBUS_ASSERT_ERROR_IS_CLEAR (error);
159 _dbus_assert (uid != DBUS_UID_UNSET || username != NULL);
160
161 /* See if the username is really a number */
162 if (uid == DBUS_UID_UNSET)
163 {
164 unsigned long n;
165
166 if (_dbus_is_a_number (username, &n))
167 uid = n;
168 }
169
170 if (uid != DBUS_UID_UNSET)
171 info = _dbus_hash_table_lookup_uintptr (db->users, uid);
172 else
173 info = _dbus_hash_table_lookup_string (db->users_by_name, _dbus_string_get_const_data (username));
174
175 if (info)
176 {
177 _dbus_verbose ("Using cache for UID "DBUS_UID_FORMAT" information\n",
178 info->uid);
179 return info;
180 }
181 else
182 {
183 if (uid != DBUS_UID_UNSET)
184 _dbus_verbose ("No cache for UID "DBUS_UID_FORMAT"\n",
185 uid);
186 else
187 _dbus_verbose ("No cache for user \"%s\"\n",
188 _dbus_string_get_const_data (username));
189
190 info = dbus_new0 (DBusUserInfo, 1);
191 if (info == NULL)
192 {
193 dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
194 return NULL;
195 }
196 info->refcount = 1;
197
198 if (uid != DBUS_UID_UNSET)
199 {
200 if (!_dbus_user_info_fill_uid (info, uid, error))
201 {
202 _DBUS_ASSERT_ERROR_IS_SET (error);
203 _dbus_user_info_unref (info);
204 return NULL;
205 }
206 }
207 else
208 {
209 if (!_dbus_user_info_fill (info, username, error))
210 {
211 _DBUS_ASSERT_ERROR_IS_SET (error);
212 _dbus_user_info_unref (info);
213 return NULL;
214 }
215 }
216
217 /* be sure we don't use these after here */
218 uid = DBUS_UID_UNSET;
219 username = NULL;
220
221 /* insert into hash */
222 if (_dbus_hash_table_insert_uintptr (db->users, info->uid, info))
223 {
224 _dbus_user_info_ref (info);
225 }
226 else
227 {
228 dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
229 _dbus_user_info_unref (info);
230 return NULL;
231 }
232
233 if (_dbus_hash_table_insert_string (db->users_by_name,
234 info->username,
235 info))
236 {
237 _dbus_user_info_ref (info);
238 }
239 else
240 {
241 _dbus_hash_table_remove_uintptr (db->users, info->uid);
242 dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
243 _dbus_user_info_unref (info);
244 return NULL;
245 }
246
247 _dbus_user_info_unref (info);
248
249 /* Return a borrowed pointer to the DBusUserInfo owned by the
250 * hash tables */
251 return info;
252 }
253 }
254
255 static dbus_bool_t database_locked = FALSE;
256 static DBusUserDatabase *system_db = NULL;
257 static DBusString process_username;
258 static DBusString process_homedir;
259
260 static void
261 shutdown_system_db (void *data)
262 {
263 if (system_db != NULL)
264 _dbus_user_database_unref (system_db);
265 system_db = NULL;
266 _dbus_string_free (&process_username);
267 _dbus_string_free (&process_homedir);
268 }
269
270 static dbus_bool_t
271 init_system_db (void)
272 {
273 _dbus_assert (database_locked);
274
275 if (system_db == NULL)
276 {
277 DBusError error = DBUS_ERROR_INIT;
278 const DBusUserInfo *info;
279
280 system_db = _dbus_user_database_new ();
281 if (system_db == NULL)
282 return FALSE;
283
284 if (!_dbus_user_database_get_uid (system_db,
285 _dbus_getuid (),
286 &info,
287 &error))
288 {
289 _dbus_user_database_unref (system_db);
290 system_db = NULL;
291
292 if (dbus_error_has_name (&error, DBUS_ERROR_NO_MEMORY))
293 {
294 dbus_error_free (&error);
295 return FALSE;
296 }
297 else
298 {
299 /* This really should not happen. */
300 _dbus_warn ("Could not get password database information for UID of current process: %s",
301 error.message);
302 dbus_error_free (&error);
303 return FALSE;
304 }
305 }
306
307 if (!_dbus_string_init (&process_username))
308 {
309 _dbus_user_database_unref (system_db);
310 system_db = NULL;
311 return FALSE;
312 }
313
314 if (!_dbus_string_init (&process_homedir))
315 {
316 _dbus_string_free (&process_username);
317 _dbus_user_database_unref (system_db);
318 system_db = NULL;
319 return FALSE;
320 }
321
322 if (!_dbus_string_append (&process_username,
323 info->username) ||
324 !_dbus_string_append (&process_homedir,
325 info->homedir) ||
326 !_dbus_register_shutdown_func (shutdown_system_db, NULL))
327 {
328 _dbus_string_free (&process_username);
329 _dbus_string_free (&process_homedir);
330 _dbus_user_database_unref (system_db);
331 system_db = NULL;
332 return FALSE;
333 }
334 }
335
336 return TRUE;
337 }
338
342 dbus_bool_t
343 _dbus_user_database_lock_system (void)
344 {
345 if (_DBUS_LOCK (system_users))
346 {
347 database_locked = TRUE;
348 return TRUE;
349 }
350 else
351 {
352 return FALSE;
353 }
354 }
355
359 void
360 _dbus_user_database_unlock_system (void)
361 {
362 database_locked = FALSE;
363 _DBUS_UNLOCK (system_users);
364 }
365
372 DBusUserDatabase*
373 _dbus_user_database_get_system (void)
374 {
375 _dbus_assert (database_locked);
376
377 init_system_db ();
378
379 return system_db;
380 }
381
385 void
386 _dbus_user_database_flush_system (void)
387 {
388 if (!_dbus_user_database_lock_system ())
389 {
390 /* nothing to flush */
391 return;
392 }
393
394 if (system_db != NULL)
395 _dbus_user_database_flush (system_db);
396
397 _dbus_user_database_unlock_system ();
398 }
399
407 dbus_bool_t
408 _dbus_username_from_current_process (const DBusString **username)
409 {
410 if (!_dbus_user_database_lock_system ())
411 return FALSE;
412
413 if (!init_system_db ())
414 {
415 _dbus_user_database_unlock_system ();
416 return FALSE;
417 }
418 *username = &process_username;
419 _dbus_user_database_unlock_system ();
420
421 return TRUE;
422 }
423
431 dbus_bool_t
432 _dbus_homedir_from_current_process (const DBusString **homedir)
433 {
434 if (!_dbus_user_database_lock_system ())
435 return FALSE;
436
437 if (!init_system_db ())
438 {
439 _dbus_user_database_unlock_system ();
440 return FALSE;
441 }
442 *homedir = &process_homedir;
443 _dbus_user_database_unlock_system ();
444
445 return TRUE;
446 }
447
455 dbus_bool_t
456 _dbus_homedir_from_username (const DBusString *username,
457 DBusString *homedir)
458 {
459 DBusUserDatabase *db;
460 const DBusUserInfo *info;
461
462 /* FIXME: this can't distinguish ENOMEM from other errors */
463 if (!_dbus_user_database_lock_system ())
464 return FALSE;
465
466 db = _dbus_user_database_get_system ();
467 if (db == NULL)
468 {
469 _dbus_user_database_unlock_system ();
470 return FALSE;
471 }
472
473 if (!_dbus_user_database_get_username (db, username,
474 &info, NULL))
475 {
476 _dbus_user_database_unlock_system ();
477 return FALSE;
478 }
479
480 if (!_dbus_string_append (homedir, info->homedir))
481 {
482 _dbus_user_database_unlock_system ();
483 return FALSE;
484 }
485
486 _dbus_user_database_unlock_system ();
487 return TRUE;
488 }
489
497 dbus_bool_t
498 _dbus_homedir_from_uid (dbus_uid_t uid,
499 DBusString *homedir)
500 {
501 DBusUserDatabase *db;
502 const DBusUserInfo *info;
503
504 if (uid == _dbus_getuid () && uid == _dbus_geteuid ())
505 {
506 const char *from_environment;
507
508 from_environment = _dbus_getenv ("HOME");
509
510 if (from_environment != NULL)
511 return _dbus_string_append (homedir, from_environment);
512 }
513
514 /* FIXME: this can't distinguish ENOMEM from other errors */
515 if (!_dbus_user_database_lock_system ())
516 return FALSE;
517
518 db = _dbus_user_database_get_system ();
519 if (db == NULL)
520 {
521 _dbus_user_database_unlock_system ();
522 return FALSE;
523 }
524
525 if (!_dbus_user_database_get_uid (db, uid,
526 &info, NULL))
527 {
528 _dbus_user_database_unlock_system ();
529 return FALSE;
530 }
531
532 if (!_dbus_string_append (homedir, info->homedir))
533 {
534 _dbus_user_database_unlock_system ();
535 return FALSE;
536 }
537
538 _dbus_user_database_unlock_system ();
539 return TRUE;
540 }
541
556 dbus_bool_t
557 _dbus_credentials_add_from_user (DBusCredentials *credentials,
558 const DBusString *username)
559 {
560 DBusUserDatabase *db;
561 const DBusUserInfo *info;
562
563 /* FIXME: this can't distinguish ENOMEM from other errors */
564 if (!_dbus_user_database_lock_system ())
565 return FALSE;
566
567 db = _dbus_user_database_get_system ();
568 if (db == NULL)
569 {
570 _dbus_user_database_unlock_system ();
571 return FALSE;
572 }
573
574 if (!_dbus_user_database_get_username (db, username,
575 &info, NULL))
576 {
577 _dbus_user_database_unlock_system ();
578 return FALSE;
579 }
580
581 if (!_dbus_credentials_add_unix_uid(credentials, info->uid))
582 {
583 _dbus_user_database_unlock_system ();
584 return FALSE;
585 }
586
587 _dbus_user_database_unlock_system ();
588 return TRUE;
589 }
590
596 DBusUserDatabase*
597 _dbus_user_database_new (void)
598 {
599 DBusUserDatabase *db;
600
601 db = dbus_new0 (DBusUserDatabase, 1);
602 if (db == NULL)
603 return NULL;
604
605 db->refcount = 1;
606
607 db->users = _dbus_hash_table_new (DBUS_HASH_UINTPTR,
608 NULL, (DBusFreeFunction) _dbus_user_info_unref);
609
610 if (db->users == NULL)
611 goto failed;
612
613 db->groups = _dbus_hash_table_new (DBUS_HASH_UINTPTR,
614 NULL, (DBusFreeFunction) _dbus_group_info_unref);
615
616 if (db->groups == NULL)
617 goto failed;
618
619 db->users_by_name = _dbus_hash_table_new (DBUS_HASH_STRING,
620 NULL, (DBusFreeFunction) _dbus_user_info_unref);
621 if (db->users_by_name == NULL)
622 goto failed;
623
624 db->groups_by_name = _dbus_hash_table_new (DBUS_HASH_STRING,
625 NULL, (DBusFreeFunction) _dbus_group_info_unref);
626 if (db->groups_by_name == NULL)
627 goto failed;
628
629 return db;
630
631 failed:
632 _dbus_user_database_unref (db);
633 return NULL;
634 }
635
639 void
640 _dbus_user_database_flush (DBusUserDatabase *db)
641 {
642 _dbus_hash_table_remove_all(db->users_by_name);
643 _dbus_hash_table_remove_all(db->groups_by_name);
644 _dbus_hash_table_remove_all(db->users);
645 _dbus_hash_table_remove_all(db->groups);
646 }
647
648 #ifdef DBUS_ENABLE_EMBEDDED_TESTS
649
654 DBusUserDatabase *
655 _dbus_user_database_ref (DBusUserDatabase *db)
656 {
657 _dbus_assert (db->refcount > 0);
658
659 db->refcount += 1;
660
661 return db;
662 }
663 #endif /* DBUS_ENABLE_EMBEDDED_TESTS */
664
669 void
670 _dbus_user_database_unref (DBusUserDatabase *db)
671 {
672 _dbus_assert (db->refcount > 0);
673
674 db->refcount -= 1;
675 if (db->refcount == 0)
676 {
677 if (db->users)
678 _dbus_hash_table_unref (db->users);
679
680 if (db->groups)
681 _dbus_hash_table_unref (db->groups);
682
683 if (db->users_by_name)
684 _dbus_hash_table_unref (db->users_by_name);
685
686 if (db->groups_by_name)
687 _dbus_hash_table_unref (db->groups_by_name);
688
689 dbus_free (db);
690 }
691 }
692
703 dbus_bool_t
704 _dbus_user_database_get_uid (DBusUserDatabase *db,
705 dbus_uid_t uid,
706 const DBusUserInfo **info,
707 DBusError *error)
708 {
709 *info = _dbus_user_database_lookup (db, uid, NULL, error);
710 return *info != NULL;
711 }
712
722 dbus_bool_t
723 _dbus_user_database_get_username (DBusUserDatabase *db,
724 const DBusString *username,
725 const DBusUserInfo **info,
726 DBusError *error)
727 {
728 *info = _dbus_user_database_lookup (db, DBUS_UID_UNSET, username, error);
729 return *info != NULL;
730 }
731
734 /* Tests in dbus-userdb-util.c */
_dbus_user_info_fill
dbus_bool_t _dbus_user_info_fill(DBusUserInfo *info, const DBusString *username, DBusError *error)
Gets user info for the given username.
Definition: dbus-sysdeps-unix.c:2678
DBusUserInfo::group_ids
dbus_gid_t * group_ids
Groups IDs, including above primary group.
Definition: dbus-sysdeps-unix.h:111
_dbus_hash_table_insert_uintptr
dbus_bool_t _dbus_hash_table_insert_uintptr(DBusHashTable *table, uintptr_t key, void *value)
Creates a hash entry with the given key and value.
Definition: dbus-hash.c:1299
_dbus_hash_table_unref
void _dbus_hash_table_unref(DBusHashTable *table)
Decrements the reference count for a hash table, freeing the hash table if the count reaches zero.
Definition: dbus-hash.c:361
_dbus_user_info_fill_uid
dbus_bool_t _dbus_user_info_fill_uid(DBusUserInfo *info, dbus_uid_t uid, DBusError *error)
Gets user info for the given user ID.
Definition: dbus-sysdeps-unix.c:2695
_dbus_user_database_get_uid
dbus_bool_t _dbus_user_database_get_uid(DBusUserDatabase *db, dbus_uid_t uid, const DBusUserInfo **info, DBusError *error)
Gets the user information for the given UID, returned user info should not be freed.
Definition: dbus-userdb.c:704
_dbus_getuid
dbus_uid_t _dbus_getuid(void)
Gets our UID.
Definition: dbus-sysdeps-unix.c:2761
_dbus_user_database_unlock_system
void _dbus_user_database_unlock_system(void)
Unlocks global system user database.
Definition: dbus-userdb.c:360
_dbus_string_free
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init().
Definition: dbus-string.c:259
_dbus_group_info_unref
void _dbus_group_info_unref(DBusGroupInfo *info)
Decrements the reference count.
Definition: dbus-userdb.c:78
_dbus_hash_table_lookup_string
void * _dbus_hash_table_lookup_string(DBusHashTable *table, const char *key)
Looks up the value for a given string in a hash table of type DBUS_HASH_STRING.
Definition: dbus-hash.c:1059
_dbus_user_database_unref
void _dbus_user_database_unref(DBusUserDatabase *db)
Decrements refcount of user database.
Definition: dbus-userdb.c:670
DBUS_UID_FORMAT
#define DBUS_UID_FORMAT
an appropriate printf format for dbus_uid_t
Definition: dbus-sysdeps.h:148
DBusFreeFunction
void(* DBusFreeFunction)(void *memory)
Definition: dbus-memory.h:63
_dbus_username_from_current_process
dbus_bool_t _dbus_username_from_current_process(const DBusString **username)
Gets username of user owning current process.
Definition: dbus-userdb.c:408
_dbus_user_database_flush
void _dbus_user_database_flush(DBusUserDatabase *db)
Flush all information out of the user database.
Definition: dbus-userdb.c:640
DBusGroupInfo
Information about a UNIX group.
Definition: dbus-sysdeps-unix.h:121
DBusUserInfo::uid
dbus_uid_t uid
UID.
Definition: dbus-sysdeps-unix.h:109
_dbus_string_init
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
Definition: dbus-string.c:175
DBusUserInfo::refcount
size_t refcount
Reference count.
Definition: dbus-sysdeps-unix.h:108
_DBUS_LOCK
#define _DBUS_LOCK(name)
Definition: dbus-internals.h:372
_dbus_hash_table_new
DBusHashTable * _dbus_hash_table_new(DBusHashType type, DBusFreeFunction key_free_function, DBusFreeFunction value_free_function)
Constructs a new hash table.
Definition: dbus-hash.c:285
TRUE
#define TRUE
DBusGroupInfo::refcount
size_t refcount
Reference count.
Definition: dbus-sysdeps-unix.h:122
_dbus_user_info_free
void _dbus_user_info_free(DBusUserInfo *info)
Frees the members of info (but not info itself)
Definition: dbus-userdb.c:99
DBUS_HASH_STRING
@ DBUS_HASH_STRING
Hash keys are strings.
Definition: dbus-hash.h:69
_dbus_user_database_new
DBusUserDatabase * _dbus_user_database_new(void)
Creates a new user database object used to look up and cache user information.
Definition: dbus-userdb.c:597
dbus_error_has_name
dbus_bool_t dbus_error_has_name(const DBusError *error, const char *name)
Checks whether the error is set and has the given name.
Definition: dbus-errors.c:302
DBusUserInfo::username
char * username
Username.
Definition: dbus-sysdeps-unix.h:113
dbus_free
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
Definition: dbus-memory.c:702
_dbus_user_database_lock_system
dbus_bool_t _dbus_user_database_lock_system(void)
Locks global system user database.
Definition: dbus-userdb.c:343
_dbus_register_shutdown_func
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_register_shutdown_func(DBusShutdownFunction function, void *data)
Register a cleanup function to be called exactly once the next time dbus_shutdown() is called.
Definition: dbus-memory.c:811
DBusString
Definition: dbus-string.h:43
DBusUserInfo::homedir
char * homedir
Home directory.
Definition: dbus-sysdeps-unix.h:114
_dbus_group_info_free
void _dbus_group_info_free(DBusGroupInfo *info)
Frees the members of info (but not info itself).
Definition: dbus-userdb.c:112
DBusCredentials
Definition: dbus-credentials.c:48
_dbus_user_database_get_system
DBusUserDatabase * _dbus_user_database_get_system(void)
Gets the system global user database; must be called with lock held (_dbus_user_database_lock_system(...
Definition: dbus-userdb.c:373
dbus_uid_t
unsigned long dbus_uid_t
A user ID.
Definition: dbus-sysdeps.h:134
FALSE
#define FALSE
_dbus_hash_table_remove_all
void _dbus_hash_table_remove_all(DBusHashTable *table)
Removed all entries from a hash table.
Definition: dbus-hash.c:418
DBUS_ERROR_NO_MEMORY
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
Definition: dbus-protocol.h:357
_dbus_is_a_number
dbus_bool_t _dbus_is_a_number(const DBusString *str, unsigned long *num)
Checks if a given string is actually a number and converts it if it is.
Definition: dbus-userdb.c:126
DBUS_ERROR_INIT
#define DBUS_ERROR_INIT
Definition: dbus-errors.h:62
_dbus_hash_table_lookup_uintptr
void * _dbus_hash_table_lookup_uintptr(DBusHashTable *table, uintptr_t key)
Looks up the value for a given integer in a hash table of type DBUS_HASH_UINTPTR.
Definition: dbus-hash.c:1109
DBUS_UID_UNSET
#define DBUS_UID_UNSET
an invalid UID used to represent an uninitialized dbus_uid_t field
Definition: dbus-sysdeps.h:141
_dbus_getenv
const char * _dbus_getenv(const char *varname)
Wrapper for getenv().
Definition: dbus-sysdeps.c:187
DBUS_HASH_UINTPTR
@ DBUS_HASH_UINTPTR
Hash keys are integer capable to hold a pointer.
Definition: dbus-hash.h:71
_dbus_user_database_get_username
dbus_bool_t _dbus_user_database_get_username(DBusUserDatabase *db, const DBusString *username, const DBusUserInfo **info, DBusError *error)
Gets the user information for the given username.
Definition: dbus-userdb.c:723
_dbus_assert
#define _dbus_assert(condition)
Definition: dbus-internals.h:152
dbus_error_free
void dbus_error_free(DBusError *error)
Frees an error that's been set (or just initialized), then reinitializes the error as in dbus_error_i...
Definition: dbus-errors.c:211
DBusUserInfo
Information about a UNIX user.
Definition: dbus-sysdeps-unix.h:107
_dbus_warn
void _dbus_warn(const char *format,...)
Prints a warning message to stderr.
Definition: dbus-internals.c:230
_dbus_geteuid
dbus_uid_t _dbus_geteuid(void)
Gets our effective UID.
Definition: dbus-sysdeps-unix.c:2770
_dbus_user_database_flush_system
void _dbus_user_database_flush_system(void)
Flushes the system global user database;.
Definition: dbus-userdb.c:386
_dbus_credentials_add_from_user
dbus_bool_t _dbus_credentials_add_from_user(DBusCredentials *credentials, const DBusString *username)
Adds the credentials corresponding to the given username.
Definition: dbus-userdb.c:557
_dbus_user_info_unref
void _dbus_user_info_unref(DBusUserInfo *info)
Decrements the reference count.
Definition: dbus-userdb.c:55
DBusError
Object representing an exception.
Definition: dbus-errors.h:49
_dbus_hash_table_remove_uintptr
dbus_bool_t _dbus_hash_table_remove_uintptr(DBusHashTable *table, uintptr_t key)
Removes the hash entry for the given key.
Definition: dbus-hash.c:1189
dbus_set_error
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_user_database_lookup
const DBusUserInfo * _dbus_user_database_lookup(DBusUserDatabase *db, dbus_uid_t uid, const DBusString *username, DBusError *error)
Looks up a uid or username in the user database.
Definition: dbus-userdb.c:151
_DBUS_UNLOCK
#define _DBUS_UNLOCK(name)
Definition: dbus-internals.h:373
_dbus_string_parse_uint
DBUS_PRIVATE_EXPORT dbus_bool_t _dbus_string_parse_uint(const DBusString *str, int start, unsigned long *value_return, int *end_return)
Parses an unsigned integer contained in a DBusString.
Definition: dbus-sysdeps.c:476
DBusError::message
const char * message
public error message field
Definition: dbus-errors.h:51
_dbus_homedir_from_uid
dbus_bool_t _dbus_homedir_from_uid(dbus_uid_t uid, DBusString *homedir)
Gets the home directory for the given user.
Definition: dbus-userdb.c:498
dbus_new0
#define dbus_new0(type, count)
Definition: dbus-memory.h:58
_dbus_hash_table_insert_string
dbus_bool_t _dbus_hash_table_insert_string(DBusHashTable *table, char *key, void *value)
Creates a hash entry with the given key and value.
Definition: dbus-hash.c:1224
_dbus_homedir_from_username
dbus_bool_t _dbus_homedir_from_username(const DBusString *username, DBusString *homedir)
Gets the home directory for the given user.
Definition: dbus-userdb.c:456
_dbus_homedir_from_current_process
dbus_bool_t _dbus_homedir_from_current_process(const DBusString **homedir)
Gets homedir of user owning current process.
Definition: dbus-userdb.c:432
_dbus_string_append
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:935
DBusGroupInfo::groupname
char * groupname
Group name.
Definition: dbus-sysdeps-unix.h:124
DBusTransport::credentials
DBusCredentials * credentials
Credentials of other end read from the socket.
Definition: dbus-transport-protected.h:92
dbus_bool_t
dbus_uint32_t dbus_bool_t
Definition: dbus-types.h:35
NULL
#define NULL
_dbus_credentials_add_unix_uid
dbus_bool_t _dbus_credentials_add_unix_uid(DBusCredentials *credentials, dbus_uid_t uid)
Add a UNIX user ID to the credentials.
Definition: dbus-credentials.c:167