Compare commits

...

8 Commits

Author SHA1 Message Date
Anita Zhang 279be556f8
Merge pull request #14721 from yuwata/home-tiny-fixes
homed,nspawn,userdb: trivial tiny fixes
2020-01-31 12:02:51 -08:00
Yu Watanabe 020313b213 test: also check the result of merge_gid_lists()
Fixes CID#1412354.
2020-01-31 23:31:23 +09:00
Yu Watanabe 4af8ab2cab user-util: fix use after free() on error path
Fixes CID#1412356.
2020-01-31 23:23:44 +09:00
Yu Watanabe b44b735a78 userdbd: fix memleak
Fixes CID#1412416.
2020-01-31 23:20:52 +09:00
Yu Watanabe 9610210d32 nspawn: voidify umount_verbose()
Fixes CID#1415122.
2020-01-31 23:10:29 +09:00
Yu Watanabe 02cec15629 user-record-util: add missing error check
Fixes CID#1415123.
2020-01-31 23:08:59 +09:00
Yu Watanabe 00c7b071ac homework: fix errno in log_error_errno()
Fixes CID#1415124.
2020-01-31 23:07:15 +09:00
Yu Watanabe 852640f8a2 home: add missing variable initialization
Fixes CID#1415126.
2020-01-31 23:04:43 +09:00
7 changed files with 13 additions and 10 deletions

View File

@ -496,11 +496,9 @@ int getgroups_alloc(gid_t** gids) {
free(allocated);
allocated = new(gid_t, ngroups);
p = allocated = new(gid_t, ngroups);
if (!allocated)
return -ENOMEM;
p = allocated;
}
*gids = TAKE_PTR(p);

View File

@ -314,7 +314,7 @@ static int manager_add_home_by_record(
const char *fname) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
_cleanup_(user_record_unrefp) UserRecord *hr;
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
unsigned line, column;
int r, is_signed;
Home *h;

View File

@ -17,9 +17,6 @@ int home_prepare_cifs(
bool already_activated,
HomeSetup *setup) {
char **pw;
int r;
assert(h);
assert(setup);
assert(user_record_storage(h) == USER_CIFS);
@ -28,6 +25,8 @@ int home_prepare_cifs(
setup->root_fd = open(user_record_home_directory(h), O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOFOLLOW);
else {
bool mounted = false;
char **pw;
int r;
r = home_unshare_and_mount(NULL, NULL, false);
if (r < 0)
@ -92,7 +91,7 @@ int home_prepare_cifs(
setup->root_fd = open("/run/systemd/user-home-mount", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOFOLLOW);
}
if (setup->root_fd < 0)
return log_error_errno(r, "Failed to open home directory: %m");
return log_error_errno(errno, "Failed to open home directory: %m");
return 0;
}

View File

@ -737,6 +737,8 @@ int user_record_make_hashed_password(UserRecord *h, char **secret, bool extend)
return r;
r = json_variant_set_field(&priv, "hashedPassword", new_array);
if (r < 0)
return r;
}
r = json_variant_set_field(&h->json, "privileged", priv);

View File

@ -906,7 +906,7 @@ static int mount_inaccessible(const char *dest, CustomMount *m) {
r = mount_verbose(m->graceful ? LOG_DEBUG : LOG_ERR, NULL, where, NULL, MS_BIND|MS_RDONLY|MS_REMOUNT, NULL);
if (r < 0) {
umount_verbose(where);
(void) umount_verbose(where);
return m->graceful ? 0 : r;
}

View File

@ -310,15 +310,19 @@ static void test_gid_lists_ops(void) {
int nresult;
nresult = merge_gid_lists(l2, ELEMENTSOF(l2), l3, ELEMENTSOF(l3), &res1);
assert_se(nresult >= 0);
assert_se(memcmp_nn(res1, nresult, result1, ELEMENTSOF(result1)) == 0);
nresult = merge_gid_lists(NULL, 0, l2, ELEMENTSOF(l2), &res2);
assert_se(nresult >= 0);
assert_se(memcmp_nn(res2, nresult, l2, ELEMENTSOF(l2)) == 0);
nresult = merge_gid_lists(l1, ELEMENTSOF(l1), l1, ELEMENTSOF(l1), &res3);
assert_se(nresult >= 0);
assert_se(memcmp_nn(l1, ELEMENTSOF(l1), res3, nresult) == 0);
nresult = merge_gid_lists(l1, ELEMENTSOF(l1), l4, ELEMENTSOF(l4), &res4);
assert_se(nresult >= 0);
assert_se(memcmp_nn(result2, ELEMENTSOF(result2), res4, nresult) == 0);
nresult = getgroups_alloc(&gids);

View File

@ -77,7 +77,7 @@ static int on_sigusr2(sd_event_source *s, const struct signalfd_siginfo *si, voi
}
int manager_new(Manager **ret) {
Manager *m;
_cleanup_(manager_freep) Manager *m = NULL;
int r;
m = new(Manager, 1);