chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Prep v225: Applying various fixes and changes to src/login that got lost during git...
[elogind.git]
/
src
/
login
/
logind-user.c
diff --git
a/src/login/logind-user.c
b/src/login/logind-user.c
index 294c1e799cdcbf9f00fb1acf2d2dc9be0a0c02cb..987244e27ec1f2cfd5e55e699ca0376dce8ae0a9 100644
(file)
--- a/
src/login/logind-user.c
+++ b/
src/login/logind-user.c
@@
-26,6
+26,7
@@
#include "util.h"
#include "mkdir.h"
#include "util.h"
#include "mkdir.h"
+#include "rm-rf.h"
#include "hashmap.h"
#include "fileio.h"
#include "path-util.h"
#include "hashmap.h"
#include "fileio.h"
#include "path-util.h"
@@
-37,6
+38,7
@@
#include "clean-ipc.h"
#include "logind-user.h"
#include "smack-util.h"
#include "clean-ipc.h"
#include "logind-user.h"
#include "smack-util.h"
+#include "formats-util.h"
User* user_new(Manager *m, uid_t uid, gid_t gid, const char *name) {
User *u;
User* user_new(Manager *m, uid_t uid, gid_t gid, const char *name) {
User *u;
@@
-116,11
+118,11
@@
int user_save(User *u) {
r = mkdir_safe_label("/run/systemd/users", 0755, 0, 0);
if (r < 0)
r = mkdir_safe_label("/run/systemd/users", 0755, 0, 0);
if (r < 0)
- goto f
inish
;
+ goto f
ail
;
r = fopen_temporary(u->state_file, &f, &temp_path);
if (r < 0)
r = fopen_temporary(u->state_file, &f, &temp_path);
if (r < 0)
- goto f
inish
;
+ goto f
ail
;
fchmod(fileno(f), 0644);
fchmod(fileno(f), 0644);
@@
-241,19
+243,24
@@
int user_save(User *u) {
fputc('\n', f);
}
fputc('\n', f);
}
- fflush(f);
+ r = fflush_and_check(f);
+ if (r < 0)
+ goto fail;
- if (
ferror(f) ||
rename(temp_path, u->state_file) < 0) {
+ if (rename(temp_path, u->state_file) < 0) {
r = -errno;
r = -errno;
- unlink(u->state_file);
- unlink(temp_path);
+ goto fail;
}
}
-finish:
- if (r < 0)
- log_error_errno(r, "Failed to save user data %s: %m", u->state_file);
+ return 0;
- return r;
+fail:
+ (void) unlink(u->state_file);
+
+ if (temp_path)
+ (void) unlink(temp_path);
+
+ return log_error_errno(r, "Failed to save user data %s: %m", u->state_file);
}
int user_load(User *u) {
}
int user_load(User *u) {
@@
-376,7
+383,7
@@
static int user_start_slice(User *u) {
char lu[DECIMAL_STR_MAX(uid_t) + 1], *slice;
sprintf(lu, UID_FMT, u->uid);
char lu[DECIMAL_STR_MAX(uid_t) + 1], *slice;
sprintf(lu, UID_FMT, u->uid);
- r = build_subslice(SPECIAL_USER_SLICE, lu, &slice);
+ r =
slice_
build_subslice(SPECIAL_USER_SLICE, lu, &slice);
if (r < 0)
return r;
if (r < 0)
return r;
@@
-409,9
+416,9
@@
static int user_start_service(User *u) {
char lu[DECIMAL_STR_MAX(uid_t) + 1], *service;
sprintf(lu, UID_FMT, u->uid);
char lu[DECIMAL_STR_MAX(uid_t) + 1], *service;
sprintf(lu, UID_FMT, u->uid);
-
service = unit_name_build("user", lu, ".service"
);
- if (
!service
)
- return log_
oom(
);
+
r = unit_name_build("user", lu, ".service", &service
);
+ if (
r < 0
)
+ return log_
error_errno(r, "Failed to build service name: %m"
);
r = manager_start_unit(u->manager, service, &error, &job);
if (r < 0) {
r = manager_start_unit(u->manager, service, &error, &job);
if (r < 0) {
@@
-521,7
+528,7
@@
static int user_remove_runtime_path(User *u) {
if (!u->runtime_path)
return 0;
if (!u->runtime_path)
return 0;
- r = rm_rf(u->runtime_path,
false, false, false
);
+ r = rm_rf(u->runtime_path,
0
);
if (r < 0)
log_error_errno(r, "Failed to remove runtime directory %s: %m", u->runtime_path);
if (r < 0)
log_error_errno(r, "Failed to remove runtime directory %s: %m", u->runtime_path);
@@
-532,7
+539,7
@@
static int user_remove_runtime_path(User *u) {
if (r < 0 && errno != EINVAL && errno != ENOENT)
log_error_errno(errno, "Failed to unmount user runtime directory %s: %m", u->runtime_path);
if (r < 0 && errno != EINVAL && errno != ENOENT)
log_error_errno(errno, "Failed to unmount user runtime directory %s: %m", u->runtime_path);
- r = rm_rf(u->runtime_path,
false, true, false
);
+ r = rm_rf(u->runtime_path,
REMOVE_ROOT
);
if (r < 0)
log_error_errno(r, "Failed to remove runtime directory %s: %m", u->runtime_path);
if (r < 0)
log_error_errno(r, "Failed to remove runtime directory %s: %m", u->runtime_path);