chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
core/cgroup: fix embarrassing typo
[elogind.git]
/
src
/
sysusers
/
sysusers.c
diff --git
a/src/sysusers/sysusers.c
b/src/sysusers/sysusers.c
index 3a56b6b482a4aeae9f44c8429cb2818af5f0e58e..f25ece06748c7d932240e14458510b8fb9b82969 100644
(file)
--- a/
src/sysusers/sysusers.c
+++ b/
src/sysusers/sysusers.c
@@
-39,6
+39,7
@@
#include "label.h"
#include "fileio-label.h"
#include "uid-range.h"
#include "label.h"
#include "fileio-label.h"
#include "uid-range.h"
+#include "selinux-util.h"
typedef enum ItemType {
ADD_USER = 'u',
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 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;
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) {
#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;
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;
if (r < 0)
goto fail;
@@
-226,15
+221,15
@@
static int make_backup(const char *target, const char *x) {
/* Copy over the access mask */
if (fchmod(fileno(dst), st.st_mode & 07777) < 0)
/* Copy over the access mask */
if (fchmod(fileno(dst), st.st_mode & 07777) < 0)
- log_warning
(
"Failed to change mode on %s: %m", backup);
+ log_warning
_errno(errno,
"Failed to change mode on %s: %m", backup);
if (fchown(fileno(dst), st.st_uid, st.st_gid)< 0)
if (fchown(fileno(dst), st.st_uid, st.st_gid)< 0)
- log_warning
(
"Failed to change ownership of %s: %m", backup);
+ log_warning
_errno(errno,
"Failed to change ownership of %s: %m", backup);
ts[0] = st.st_atim;
ts[1] = st.st_mtim;
if (futimens(fileno(dst), ts) < 0)
ts[0] = st.st_atim;
ts[1] = st.st_mtim;
if (futimens(fileno(dst), ts) < 0)
- log_warning
(
"Failed to fix access and modification time of %s: %m", backup);
+ log_warning
_errno(errno,
"Failed to fix access and modification time of %s: %m", backup);
if (rename(temp, backup) < 0)
goto fail;
if (rename(temp, backup) < 0)
goto fail;
@@
-898,10
+893,8
@@
static int add_user(Item *i) {
i->description = strdup(p->pw_gecos);
return 0;
}
i->description = strdup(p->pw_gecos);
return 0;
}
- if (!IN_SET(errno, 0, ENOENT)) {
- log_error("Failed to check if user %s already exists: %m", i->name);
- return -errno;
- }
+ if (!IN_SET(errno, 0, ENOENT))
+ return log_error_errno(errno, "Failed to check if user %s already exists: %m", i->name);
/* And shadow too, just to be sure */
errno = 0;
/* And shadow too, just to be sure */
errno = 0;
@@
-910,10
+903,8
@@
static int add_user(Item *i) {
log_error("User %s already exists in shadow database, but not in user database.", i->name);
return -EBADMSG;
}
log_error("User %s already exists in shadow database, but not in user database.", i->name);
return -EBADMSG;
}
- if (!IN_SET(errno, 0, ENOENT)) {
- log_error("Failed to check if user %s already exists in shadow database: %m", i->name);
- return -errno;
- }
+ if (!IN_SET(errno, 0, ENOENT))
+ return log_error_errno(errno, "Failed to check if user %s already exists in shadow database: %m", i->name);
}
/* Try to use the suggested numeric uid */
}
/* Try to use the suggested numeric uid */
@@
-1056,10
+1047,8
@@
static int add_group(Item *i) {
i->gid_set = true;
return 0;
}
i->gid_set = true;
return 0;
}
- if (!IN_SET(errno, 0, ENOENT)) {
- log_error("Failed to check if group %s already exists: %m", i->name);
- return -errno;
- }
+ if (!IN_SET(errno, 0, ENOENT))
+ return log_error_errno(errno, "Failed to check if group %s already exists: %m", i->name);
}
/* Try to use the suggested numeric gid */
}
/* Try to use the suggested numeric gid */
@@
-1709,8
+1698,7
@@
static int read_config_file(const char *fn, bool ignore_enoent) {
if (ignore_enoent && r == -ENOENT)
return 0;
if (ignore_enoent && r == -ENOENT)
return 0;
- log_error_errno(r, "Failed to open '%s', ignoring: %m", fn);
- return r;
+ return log_error_errno(r, "Failed to open '%s', ignoring: %m", fn);
}
f = rf;
}
f = rf;
@@
-1732,7
+1720,7
@@
static int read_config_file(const char *fn, bool ignore_enoent) {
}
if (ferror(f)) {
}
if (ferror(f)) {
- log_error
(
"Failed to read from file %s: %m", fn);
+ log_error
_errno(errno,
"Failed to read from file %s: %m", fn);
if (r == 0)
r = -EIO;
}
if (r == 0)
r = -EIO;
}