mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-22 13:33:56 +03:00
commit
7b5ed18779
@ -81,11 +81,7 @@ static int macsec_receive_association_new_static(MACsec *s, const char *filename
|
||||
|
||||
security_association_init(&c->sa);
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&s->receive_associations_by_section, &network_config_hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = ordered_hashmap_put(s->receive_associations_by_section, c->section, c);
|
||||
r = ordered_hashmap_ensure_put(&s->receive_associations_by_section, &network_config_hash_ops, c->section, c);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -157,11 +153,7 @@ static int macsec_receive_channel_new_static(MACsec *s, const char *filename, un
|
||||
|
||||
c->section = TAKE_PTR(n);
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&s->receive_channels_by_section, &network_config_hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = ordered_hashmap_put(s->receive_channels_by_section, c->section, c);
|
||||
r = ordered_hashmap_ensure_put(&s->receive_channels_by_section, &network_config_hash_ops, c->section, c);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -216,11 +208,7 @@ static int macsec_transmit_association_new_static(MACsec *s, const char *filenam
|
||||
|
||||
security_association_init(&a->sa);
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&s->transmit_associations_by_section, &network_config_hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = ordered_hashmap_put(s->transmit_associations_by_section, a->section, a);
|
||||
r = ordered_hashmap_ensure_put(&s->transmit_associations_by_section, &network_config_hash_ops, a->section, a);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -1028,11 +1016,9 @@ static int macsec_receive_channel_verify(ReceiveChannel *c) {
|
||||
"Ignoring [MACsecReceiveChannel] section from line %u",
|
||||
c->section->filename, c->section->line);
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&c->macsec->receive_channels, &uint64_hash_ops);
|
||||
if (r < 0)
|
||||
r = ordered_hashmap_ensure_put(&c->macsec->receive_channels, &uint64_hash_ops, &c->sci.as_uint64, c);
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
|
||||
r = ordered_hashmap_put(c->macsec->receive_channels, &c->sci.as_uint64, c);
|
||||
if (r == -EEXIST)
|
||||
return log_netdev_error_errno(netdev, r,
|
||||
"%s: Multiple [MACsecReceiveChannel] sections have same SCI, "
|
||||
@ -1120,11 +1106,9 @@ static int macsec_receive_association_verify(ReceiveAssociation *a) {
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&a->macsec->receive_channels, &uint64_hash_ops);
|
||||
if (r < 0)
|
||||
r = ordered_hashmap_ensure_put(&a->macsec->receive_channels, &uint64_hash_ops, &new_channel->sci.as_uint64, new_channel);
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
|
||||
r = ordered_hashmap_put(a->macsec->receive_channels, &new_channel->sci.as_uint64, new_channel);
|
||||
if (r < 0)
|
||||
return log_netdev_error_errno(netdev, r,
|
||||
"%s: Failed to store receive channel at hashmap, "
|
||||
|
@ -94,11 +94,7 @@ static int address_new_static(Network *network, const char *filename, unsigned s
|
||||
address->network = network;
|
||||
address->section = TAKE_PTR(n);
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&network->addresses_by_section, &network_config_hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = ordered_hashmap_put(network->addresses_by_section, address->section, address);
|
||||
r = ordered_hashmap_ensure_put(&network->addresses_by_section, &network_config_hash_ops, address->section, address);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -499,15 +499,11 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
|
||||
/* Ignore .network files that do not match the conditions. */
|
||||
return 0;
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(networks, &string_hash_ops);
|
||||
r = ordered_hashmap_ensure_put(networks, &string_hash_ops, network->name, network);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = ordered_hashmap_put(*networks, network->name, network);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
network = NULL;
|
||||
TAKE_PTR(network);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1041,10 +1041,6 @@ static int install_info_add(
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&c->will_process, &string_hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
i = new(UnitFileInstallInfo, 1);
|
||||
if (!i)
|
||||
return -ENOMEM;
|
||||
@ -1068,7 +1064,7 @@ static int install_info_add(
|
||||
}
|
||||
}
|
||||
|
||||
r = ordered_hashmap_put(c->will_process, i->name, i);
|
||||
r = ordered_hashmap_ensure_put(&c->will_process, &string_hash_ops, i->name, i);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
|
@ -1043,13 +1043,15 @@ static int add_user(Item *i) {
|
||||
i->uid = search_uid;
|
||||
}
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&todo_uids, NULL);
|
||||
if (r < 0)
|
||||
r = ordered_hashmap_ensure_put(&todo_uids, NULL, UID_TO_PTR(i->uid), i);
|
||||
if (r == -EEXIST)
|
||||
return log_error_errno(r, "Requested user %s with uid " UID_FMT " and gid" GID_FMT " to be created is duplicated "
|
||||
"or conflicts with another user.", i->name, i->uid, i->gid);
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
|
||||
r = ordered_hashmap_put(todo_uids, UID_TO_PTR(i->uid), i);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
return log_error_errno(r, "Failed to store user %s with uid " UID_FMT " and gid " GID_FMT " to be created: %m",
|
||||
i->name, i->uid, i->gid);
|
||||
|
||||
i->todo_user = true;
|
||||
log_info("Creating user %s (%s) with uid " UID_FMT " and gid " GID_FMT ".", i->name, strna(i->description), i->uid, i->gid);
|
||||
@ -1212,13 +1214,13 @@ static int add_group(Item *i) {
|
||||
i->gid = search_uid;
|
||||
}
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&todo_gids, NULL);
|
||||
if (r < 0)
|
||||
r = ordered_hashmap_ensure_put(&todo_gids, NULL, GID_TO_PTR(i->gid), i);
|
||||
if (r == -EEXIST)
|
||||
return log_error_errno(r, "Requested group %s with gid "GID_FMT " to be created is duplicated or conflicts with another user.", i->name, i->gid);
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
|
||||
r = ordered_hashmap_put(todo_gids, GID_TO_PTR(i->gid), i);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
return log_error_errno(r, "Failed to store group %s with gid " GID_FMT " to be created: %m", i->name, i->gid);
|
||||
|
||||
i->todo_group = true;
|
||||
log_info("Creating group %s with gid " GID_FMT ".", i->name, i->gid);
|
||||
|
@ -1977,15 +1977,16 @@ static int udev_rule_apply_token_to_event(
|
||||
if (token->op == OP_ASSIGN)
|
||||
ordered_hashmap_clear_free_free(event->seclabel_list);
|
||||
|
||||
r = ordered_hashmap_ensure_allocated(&event->seclabel_list, NULL);
|
||||
if (r < 0)
|
||||
r = ordered_hashmap_ensure_put(&event->seclabel_list, NULL, name, label);
|
||||
if (r == -ENOMEM)
|
||||
return log_oom();
|
||||
if (r < 0)
|
||||
return log_rule_error_errno(dev, rules, r, "Failed to store SECLABEL{%s}='%s': %m", name, label);;
|
||||
|
||||
r = ordered_hashmap_put(event->seclabel_list, name, label);
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
log_rule_debug(dev, rules, "SECLABEL{%s}='%s'", name, label);
|
||||
name = label = NULL;
|
||||
|
||||
TAKE_PTR(name);
|
||||
TAKE_PTR(label);
|
||||
break;
|
||||
}
|
||||
case TK_A_ENV: {
|
||||
|
Loading…
Reference in New Issue
Block a user