homed: Add some missing asserts
These functions expect secrets to be passed in (some even dereference the variables), but fail to assert that they're non-null. So this commit adds some assertions
This commit is contained in:
committed by
Lennart Poettering
parent
e1390da025
commit
e2a40cc7b9
@@ -1323,6 +1323,7 @@ static int home_fixate_internal(
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(secret);
|
||||
assert(IN_SET(for_state, HOME_FIXATING, HOME_FIXATING_FOR_ACTIVATION, HOME_FIXATING_FOR_ACQUIRE));
|
||||
|
||||
r = home_start_work(h, "inspect", h->record, secret);
|
||||
@@ -1343,6 +1344,7 @@ int home_fixate(Home *h, UserRecord *secret, sd_bus_error *error) {
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(secret);
|
||||
|
||||
switch (home_get_state(h)) {
|
||||
case HOME_ABSENT:
|
||||
@@ -1370,6 +1372,7 @@ static int home_activate_internal(Home *h, UserRecord *secret, HomeState for_sta
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(secret);
|
||||
assert(IN_SET(for_state, HOME_ACTIVATING, HOME_ACTIVATING_FOR_ACQUIRE));
|
||||
|
||||
r = home_start_work(h, "activate", h->record, secret);
|
||||
@@ -1384,6 +1387,7 @@ int home_activate(Home *h, UserRecord *secret, sd_bus_error *error) {
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(secret);
|
||||
|
||||
switch (home_get_state(h)) {
|
||||
case HOME_UNFIXATED:
|
||||
@@ -1417,6 +1421,7 @@ static int home_authenticate_internal(Home *h, UserRecord *secret, HomeState for
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(secret);
|
||||
assert(IN_SET(for_state, HOME_AUTHENTICATING, HOME_AUTHENTICATING_WHILE_ACTIVE, HOME_AUTHENTICATING_FOR_ACQUIRE));
|
||||
|
||||
r = home_start_work(h, "inspect", h->record, secret);
|
||||
@@ -1432,6 +1437,7 @@ int home_authenticate(Home *h, UserRecord *secret, sd_bus_error *error) {
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(secret);
|
||||
|
||||
state = home_get_state(h);
|
||||
switch (state) {
|
||||
@@ -1504,6 +1510,7 @@ int home_create(Home *h, UserRecord *secret, sd_bus_error *error) {
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(secret);
|
||||
|
||||
switch (home_get_state(h)) {
|
||||
case HOME_INACTIVE: {
|
||||
@@ -1840,6 +1847,8 @@ int home_passwd(Home *h,
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(new_secret);
|
||||
assert(old_secret);
|
||||
|
||||
if (h->signed_locally <= 0) /* Don't allow changing of records not signed only by us */
|
||||
return sd_bus_error_setf(error, BUS_ERROR_HOME_RECORD_SIGNED, "Home %s is signed and cannot be modified locally.", h->user_name);
|
||||
@@ -1986,6 +1995,7 @@ static int home_unlock_internal(Home *h, UserRecord *secret, HomeState for_state
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(secret);
|
||||
assert(IN_SET(for_state, HOME_UNLOCKING, HOME_UNLOCKING_FOR_ACQUIRE));
|
||||
|
||||
r = home_start_work(h, "unlock", h->record, secret);
|
||||
@@ -1998,7 +2008,9 @@ static int home_unlock_internal(Home *h, UserRecord *secret, HomeState for_state
|
||||
|
||||
int home_unlock(Home *h, UserRecord *secret, sd_bus_error *error) {
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(secret);
|
||||
|
||||
r = home_ratelimit(h, error);
|
||||
if (r < 0)
|
||||
|
||||
@@ -1155,6 +1155,7 @@ int user_record_merge_secret(UserRecord *h, UserRecord *secret) {
|
||||
int r;
|
||||
|
||||
assert(h);
|
||||
assert(secret);
|
||||
|
||||
/* Merges the secrets from 'secret' into 'h'. */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user