confd: Fix unchecked return codes

Fix coverity CIDS:
- 464651
- 464652
- 464655
- 507413
- 507414
This commit is contained in:
Tobias Waldekranz
2025-02-16 10:55:03 +01:00
parent 46d5e750d7
commit 7e252ba941
3 changed files with 17 additions and 5 deletions
+2 -1
View File
@@ -289,7 +289,8 @@ static void del(const char *subnet, struct lyd_node *cfg)
fclose(next);
/* Replace old leases file */
rename(DNSMASQ_LEASES"+", DNSMASQ_LEASES);
if (rename(DNSMASQ_LEASES"+", DNSMASQ_LEASES))
ERRNO("Failed switching to new %s", DNSMASQ_LEASES);
}
static int change(sr_session_ctx_t *session, uint32_t sub_id, const char *module,
+3 -1
View File
@@ -136,6 +136,8 @@ int bridge_mcd_gen(struct lyd_node *cifs)
}
out_remove:
remove("/etc/mc.d/bridges.conf.next");
if (remove("/etc/mc.d/bridges.conf.next"))
ERRNO("Failed removing /etc/mc.d/bridges.conf.next");
return err;
}
+12 -3
View File
@@ -349,7 +349,8 @@ static int lldp_change(sr_session_ctx_t *session, uint32_t sub_id, const char *m
if (erase(LLDP_CONFIG))
ERRNO("Failed to remove old %s", LLDP_CONFIG);
rename(LLDP_CONFIG_NEXT, LLDP_CONFIG);
if (rename(LLDP_CONFIG_NEXT, LLDP_CONFIG))
ERRNO("Failed switching to new %s", LLDP_CONFIG);
}
else
if (erase(LLDP_CONFIG))
@@ -531,7 +532,10 @@ static int change_keystore_cb(sr_session_ctx_t *session, uint32_t sub_id, const
if(rmrf(SSH_HOSTKEYS)) {
ERRNO("Failed to remove old SSH hostkeys: %d", errno);
}
rename(SSH_HOSTKEYS_NEXT, SSH_HOSTKEYS);
if (rename(SSH_HOSTKEYS_NEXT, SSH_HOSTKEYS))
ERRNO("Failed switching to new %s", SSH_HOSTKEYS);
svc_change(session, event, "/infix-services:ssh", "ssh", "sshd");
}
return SR_ERR_OK;
@@ -564,7 +568,12 @@ static int change_keystore_cb(sr_session_ctx_t *session, uint32_t sub_id, const
}
private_key = lydx_get_cattr(change, "cleartext-private-key");
public_key = lydx_get_cattr(change, "public-key");
mkdir(SSH_HOSTKEYS_NEXT, 0600);
if (mkdir(SSH_HOSTKEYS_NEXT, 0600) && (errno != EEXIST)) {
ERRNO("Failed creating %s", SSH_HOSTKEYS_NEXT);
rc = SR_ERR_INTERNAL;
}
if(systemf("/usr/libexec/infix/mksshkey %s %s %s %s", name, SSH_HOSTKEYS_NEXT, public_key, private_key))
rc = SR_ERR_INTERNAL;
}