chiark / gitweb /
logind: unify how we cast between uid_t and pointers for hashmap keys
[elogind.git] / src / sysusers / sysusers.c
index 685bbefd8db4155d3ab872a22f27d57bbc46e61c..f25ece06748c7d932240e14458510b8fb9b82969 100644 (file)
@@ -39,6 +39,7 @@
 #include "label.h"
 #include "fileio-label.h"
 #include "uid-range.h"
+#include "selinux-util.h"
 
 typedef enum ItemType {
         ADD_USER = 'u',
@@ -76,16 +77,10 @@ static Hashmap *members = NULL;
 static Hashmap *database_uid = NULL, *database_user = NULL;
 static Hashmap *database_gid = NULL, *database_group = NULL;
 
-static uid_t search_uid = (uid_t) -1;
+static uid_t search_uid = UID_INVALID;
 static UidRange *uid_range = NULL;
 static unsigned n_uid_range = 0;
 
-#define UID_TO_PTR(u) (ULONG_TO_PTR(u+1))
-#define PTR_TO_UID(u) ((uid_t) (PTR_TO_ULONG(u)-1))
-
-#define GID_TO_PTR(g) (ULONG_TO_PTR(g+1))
-#define PTR_TO_GID(g) ((gid_t) (PTR_TO_ULONG(g)-1))
-
 #define fix_root(x) (arg_root ? strappenda(arg_root, x) : x)
 
 static int load_user_database(void) {
@@ -215,7 +210,7 @@ static int make_backup(const char *target, const char *x) {
         if (r < 0)
                 return r;
 
-        r = copy_bytes(src, fileno(dst), (off_t) -1);
+        r = copy_bytes(src, fileno(dst), (off_t) -1, true);
         if (r < 0)
                 goto fail;