mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
confd: minor adjustments to wifi config file handling
Ensure umask is properly managed around file creation to maintain consistent behavior across the codebase. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
@@ -458,12 +458,14 @@ static int wifi_gen_aps_on_radio(const char *radio_name, struct lyd_node *cifs,
|
||||
char hostapd_conf[256];
|
||||
char **ap_list = NULL;
|
||||
FILE *hostapd = NULL;
|
||||
int ap_count = 0;
|
||||
int rc = SR_ERR_OK;
|
||||
int ap_count = 0;
|
||||
mode_t oldmask;
|
||||
int i;
|
||||
|
||||
wifi_find_radio_aps(cifs, radio_name, &ap_list, &ap_count);
|
||||
oldmask = umask(0077);
|
||||
|
||||
wifi_find_radio_aps(cifs, radio_name, &ap_list, &ap_count);
|
||||
if (ap_count == 0) {
|
||||
DEBUG("No APs found on radio %s", radio_name);
|
||||
goto cleanup;
|
||||
@@ -538,6 +540,8 @@ static int wifi_gen_aps_on_radio(const char *radio_name, struct lyd_node *cifs,
|
||||
fclose(hostapd);
|
||||
|
||||
cleanup:
|
||||
umask(oldmask);
|
||||
|
||||
for (i = 0; i < ap_count; i++)
|
||||
free(ap_list[i]);
|
||||
free(ap_list);
|
||||
|
||||
@@ -61,6 +61,7 @@ static int wifi_gen_station(struct lyd_node *cif)
|
||||
char *security_str = NULL;
|
||||
const char *country;
|
||||
int rc = SR_ERR_OK;
|
||||
mode_t oldmask;
|
||||
|
||||
ifname = lydx_get_cattr(cif, "name");
|
||||
wifi = lydx_get_child(cif, "wifi");
|
||||
@@ -95,6 +96,7 @@ static int wifi_gen_station(struct lyd_node *cif)
|
||||
secret = NULL;
|
||||
}
|
||||
|
||||
oldmask = umask(0077);
|
||||
wpa_supplicant = fopenf("w", WPA_SUPPLICANT_CONF, ifname);
|
||||
if (!wpa_supplicant) {
|
||||
rc = SR_ERR_INTERNAL;
|
||||
@@ -132,6 +134,8 @@ static int wifi_gen_station(struct lyd_node *cif)
|
||||
out:
|
||||
if (wpa_supplicant)
|
||||
fclose(wpa_supplicant);
|
||||
umask(oldmask);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user