summaryrefslogtreecommitdiff
path: root/src/home
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-03-16 22:32:23 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-03-19 08:33:33 +0900
commitde010b0b2e50cf0b3837ce350b116bc92605f67a (patch)
tree226685fbb97461692562035501ebc21a314f718c /src/home
parent80a226b26b5e00a2ef9e85d1321da44cd14d051b (diff)
downloadsystemd-de010b0b2e50cf0b3837ce350b116bc92605f67a.tar.gz
strv: make iterator in STRV_FOREACH() declaread in the loop
This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
Diffstat (limited to 'src/home')
-rw-r--r--src/home/homectl.c11
-rw-r--r--src/home/homed-manager-bus.c1
-rw-r--r--src/home/homed-manager.c1
-rw-r--r--src/home/homed-varlink.c6
-rw-r--r--src/home/homework-cifs.c1
-rw-r--r--src/home/homework-fscrypt.c3
-rw-r--r--src/home/homework-luks.c3
-rw-r--r--src/home/homework-pkcs11.c1
-rw-r--r--src/home/homework.c13
-rw-r--r--src/home/user-record-pwquality.c3
-rw-r--r--src/home/user-record-util.c3
11 files changed, 6 insertions, 40 deletions
diff --git a/src/home/homectl.c b/src/home/homectl.c
index 3c179ca4ae..671d5f5130 100644
--- a/src/home/homectl.c
+++ b/src/home/homectl.c
@@ -557,7 +557,6 @@ static int acquire_passed_secrets(const char *user_name, UserRecord **ret) {
static int activate_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r, ret = 0;
- char **i;
r = acquire_bus(&bus);
if (r < 0)
@@ -606,7 +605,6 @@ static int activate_home(int argc, char *argv[], void *userdata) {
static int deactivate_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r, ret = 0;
- char **i;
r = acquire_bus(&bus);
if (r < 0)
@@ -693,7 +691,7 @@ static int inspect_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_(strv_freep) char **mangled_list = NULL;
int r, ret = 0;
- char **items, **i;
+ char **items;
pager_open(arg_pager_flags);
@@ -777,7 +775,7 @@ static int authenticate_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
_cleanup_(strv_freep) char **mangled_list = NULL;
int r, ret = 0;
- char **i, **items;
+ char **items;
items = mangle_user_list(strv_skip(argv, 1), &mangled_list);
if (!items)
@@ -1087,7 +1085,6 @@ static int add_disposition(JsonVariant **v) {
static int acquire_new_home_record(UserRecord **ret) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL;
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
- char **i;
int r;
assert(ret);
@@ -1370,7 +1367,6 @@ static int create_home(int argc, char *argv[], void *userdata) {
static int remove_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r, ret = 0;
- char **i;
r = acquire_bus(&bus);
if (r < 0)
@@ -1408,7 +1404,6 @@ static int acquire_updated_home_record(
_cleanup_(json_variant_unrefp) JsonVariant *json = NULL;
_cleanup_(user_record_unrefp) UserRecord *hr = NULL;
- char **i;
int r;
assert(ret);
@@ -1858,7 +1853,6 @@ static int resize_home(int argc, char *argv[], void *userdata) {
static int lock_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r, ret = 0;
- char **i;
r = acquire_bus(&bus);
if (r < 0)
@@ -1890,7 +1884,6 @@ static int lock_home(int argc, char *argv[], void *userdata) {
static int unlock_home(int argc, char *argv[], void *userdata) {
_cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL;
int r, ret = 0;
- char **i;
r = acquire_bus(&bus);
if (r < 0)
diff --git a/src/home/homed-manager-bus.c b/src/home/homed-manager-bus.c
index 47eb287aa9..ba5ca42ed3 100644
--- a/src/home/homed-manager-bus.c
+++ b/src/home/homed-manager-bus.c
@@ -39,7 +39,6 @@ static int property_get_auto_login(
HASHMAP_FOREACH(h, m->homes_by_name) {
_cleanup_(strv_freep) char **seats = NULL;
_cleanup_free_ char *home_path = NULL;
- char **s;
r = home_auto_login(h, &seats);
if (r < 0) {
diff --git a/src/home/homed-manager.c b/src/home/homed-manager.c
index dc1bb070dc..9ed1348592 100644
--- a/src/home/homed-manager.c
+++ b/src/home/homed-manager.c
@@ -1551,7 +1551,6 @@ static int manager_load_public_key_one(Manager *m, const char *path) {
static int manager_load_public_keys(Manager *m) {
_cleanup_strv_free_ char **files = NULL;
- char **i;
int r;
assert(m);
diff --git a/src/home/homed-varlink.c b/src/home/homed-varlink.c
index 96a6ea754e..3dd5a14802 100644
--- a/src/home/homed-varlink.c
+++ b/src/home/homed-varlink.c
@@ -282,7 +282,6 @@ int vl_method_get_memberships(Varlink *link, JsonVariant *parameters, VarlinkMet
if (p.user_name) {
const char *last = NULL;
- char **i;
h = hashmap_get(m->homes_by_name, p.user_name);
if (!h)
@@ -335,9 +334,7 @@ int vl_method_get_memberships(Varlink *link, JsonVariant *parameters, VarlinkMet
} else {
const char *last_user_name = NULL, *last_group_name = NULL;
- HASHMAP_FOREACH(h, m->homes_by_name) {
- char **j;
-
+ HASHMAP_FOREACH(h, m->homes_by_name)
STRV_FOREACH(j, h->record->member_of) {
if (last_user_name) {
@@ -353,7 +350,6 @@ int vl_method_get_memberships(Varlink *link, JsonVariant *parameters, VarlinkMet
last_user_name = h->user_name;
last_group_name = *j;
}
- }
if (last_user_name) {
assert(last_group_name);
diff --git a/src/home/homework-cifs.c b/src/home/homework-cifs.c
index ed06d1f221..6d499f76b2 100644
--- a/src/home/homework-cifs.c
+++ b/src/home/homework-cifs.c
@@ -20,7 +20,6 @@ int home_setup_cifs(
HomeSetup *setup) {
_cleanup_free_ char *chost = NULL, *cservice = NULL, *cdir = NULL, *chost_and_service = NULL, *j = NULL;
- char **pw;
int r;
assert(h);
diff --git a/src/home/homework-fscrypt.c b/src/home/homework-fscrypt.c
index f9fef73f75..afa706a1bf 100644
--- a/src/home/homework-fscrypt.c
+++ b/src/home/homework-fscrypt.c
@@ -197,7 +197,6 @@ static int fscrypt_slot_try_many(
const uint8_t match_key_descriptor[static FS_KEY_DESCRIPTOR_SIZE],
void **ret_decrypted, size_t *ret_decrypted_size) {
- char **i;
int r;
STRV_FOREACH(i, passwords) {
@@ -499,7 +498,6 @@ int home_create_fscrypt(
_cleanup_free_ char *d = NULL;
uint32_t nr = 0;
const char *ip;
- char **i;
int r;
assert(h);
@@ -649,7 +647,6 @@ int home_passwd_fscrypt(
size_t volume_key_size = 0;
uint32_t slot = 0;
const char *xa;
- char **p;
int r;
assert(h);
diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c
index 38164fadc3..8b3341c643 100644
--- a/src/home/homework-luks.c
+++ b/src/home/homework-luks.c
@@ -304,7 +304,6 @@ static int luks_try_passwords(
size_t *volume_key_size,
key_serial_t *ret_key_serial) {
- char **pp;
int r;
assert(h);
@@ -1718,7 +1717,6 @@ static int luks_format(
_cleanup_free_ char *text = NULL;
size_t volume_key_size;
int slot = 0, r;
- char **pp;
assert(node);
assert(dm_name);
@@ -3659,7 +3657,6 @@ static int luks_try_resume(
const char *dm_name,
char **password) {
- char **pp;
int r;
assert(cd);
diff --git a/src/home/homework-pkcs11.c b/src/home/homework-pkcs11.c
index 15402b1002..7868fb6064 100644
--- a/src/home/homework-pkcs11.c
+++ b/src/home/homework-pkcs11.c
@@ -20,7 +20,6 @@ int pkcs11_callback(
CK_TOKEN_INFO updated_token_info;
size_t decrypted_key_size;
CK_OBJECT_HANDLE object;
- char **i;
CK_RV rv;
int r;
diff --git a/src/home/homework.c b/src/home/homework.c
index 9fdc74b775..0014a7f598 100644
--- a/src/home/homework.c
+++ b/src/home/homework.c
@@ -97,9 +97,7 @@ int user_record_authenticate(
log_info("None of the supplied plaintext passwords unlock the user record's hashed recovery keys.");
/* Second, test cached PKCS#11 passwords */
- for (size_t n = 0; n < h->n_pkcs11_encrypted_key; n++) {
- char **pp;
-
+ for (size_t n = 0; n < h->n_pkcs11_encrypted_key; n++)
STRV_FOREACH(pp, cache->pkcs11_passwords) {
r = test_password_one(h->pkcs11_encrypted_key[n].hashed_password, *pp);
if (r < 0)
@@ -109,12 +107,9 @@ int user_record_authenticate(
return 1;
}
}
- }
/* Third, test cached FIDO2 passwords */
- for (size_t n = 0; n < h->n_fido2_hmac_salt; n++) {
- char **pp;
-
+ for (size_t n = 0; n < h->n_fido2_hmac_salt; n++)
/* See if any of the previously calculated passwords work */
STRV_FOREACH(pp, cache->fido2_passwords) {
r = test_password_one(h->fido2_hmac_salt[n].hashed_password, *pp);
@@ -125,7 +120,6 @@ int user_record_authenticate(
return 1;
}
}
- }
/* Fourth, let's see if any of the PKCS#11 security tokens are plugged in and help us */
for (size_t n = 0; n < h->n_pkcs11_encrypted_key; n++) {
@@ -1096,7 +1090,6 @@ static int user_record_compile_effective_passwords(
_cleanup_(strv_free_erasep) char **effective = NULL;
size_t n;
- char **i;
int r;
assert(h);
@@ -1116,7 +1109,6 @@ static int user_record_compile_effective_passwords(
STRV_FOREACH(i, h->hashed_password) {
bool found = false;
- char **j;
log_debug("Looking for plaintext password for: %s", *i);
@@ -1144,7 +1136,6 @@ static int user_record_compile_effective_passwords(
for (n = 0; n < h->n_recovery_key; n++) {
bool found = false;
- char **j;
log_debug("Looking for plaintext recovery key for: %s", h->recovery_key[n].hashed_password);
diff --git a/src/home/user-record-pwquality.c b/src/home/user-record-pwquality.c
index 23c3357836..609e620511 100644
--- a/src/home/user-record-pwquality.c
+++ b/src/home/user-record-pwquality.c
@@ -17,7 +17,7 @@ int user_record_quality_check_password(
sd_bus_error *error) {
_cleanup_(sym_pwquality_free_settingsp) pwquality_settings_t *pwq = NULL;
- char buf[PWQ_MAX_ERROR_MESSAGE_LEN], **pp;
+ char buf[PWQ_MAX_ERROR_MESSAGE_LEN];
void *auxerror;
int r;
@@ -37,7 +37,6 @@ int user_record_quality_check_password(
/* Iterate through all new passwords */
STRV_FOREACH(pp, secret->password) {
bool called = false;
- char **old;
r = test_password_many(hr->hashed_password, *pp);
if (r < 0)
diff --git a/src/home/user-record-util.c b/src/home/user-record-util.c
index 6a892d45b5..2b727df533 100644
--- a/src/home/user-record-util.c
+++ b/src/home/user-record-util.c
@@ -563,7 +563,6 @@ int user_record_test_image_path_and_warn(UserRecord *h) {
}
int user_record_test_password(UserRecord *h, UserRecord *secret) {
- char **i;
int r;
assert(h);
@@ -585,7 +584,6 @@ int user_record_test_password(UserRecord *h, UserRecord *secret) {
}
int user_record_test_recovery_key(UserRecord *h, UserRecord *secret) {
- char **i;
int r;
assert(h);
@@ -779,7 +777,6 @@ int user_record_update_last_changed(UserRecord *h, bool with_password) {
int user_record_make_hashed_password(UserRecord *h, char **secret, bool extend) {
_cleanup_(json_variant_unrefp) JsonVariant *priv = NULL;
_cleanup_strv_free_ char **np = NULL;
- char **i;
int r;
assert(h);