Skip to content

Commit a767391

Browse files
Danilo Egea Gondolfoslyon
Danilo Egea Gondolfo
authored andcommitted
dbus: Use the error set by _copy_yaml_state()
_copy_yaml_state() is setting an error when g_copy_file fails but it wasn't used by any callers.
1 parent 2ff1daa commit a767391

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/dbus.c

+12-7
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ _backup_global_state(sd_bus_error *ret_error)
223223
}
224224

225225
/* Copy main *.yaml files from /{etc,run,lib}/netplan/ to GLOBAL backup dir */
226-
_copy_yaml_state(NETPLAN_ROOT, path, ret_error);
227-
return 0;
226+
r = _copy_yaml_state(NETPLAN_ROOT, path, ret_error);
227+
return r;
228228
}
229229

230230
/**
@@ -444,7 +444,8 @@ netplan_try_cancelled_cb(sd_event_source *es, const siginfo_t *si, void* userdat
444444
unlink_glob(NETPLAN_ROOT, "/{etc,run,lib}/netplan/*.yaml");
445445
/* Restore GLOBAL backup config state to main rootdir */
446446
state_dir = g_strdup_printf("%s/run/netplan/config-%s", NETPLAN_ROOT, NETPLAN_GLOBAL_CONFIG);
447-
_copy_yaml_state(state_dir, NETPLAN_ROOT, NULL);
447+
r = _copy_yaml_state(state_dir, NETPLAN_ROOT, NULL);
448+
if (r < 0) return r;
448449

449450
/* Un-invalidate all other current config objects */
450451
if (!g_strcmp0(d->handler_id, d->config_dirty))
@@ -564,7 +565,8 @@ method_config_apply(sd_bus_message *m, void *userdata, sd_bus_error *ret_error)
564565
unlink_glob(NETPLAN_ROOT, "/{etc,run,lib}/netplan/*.yaml");
565566
/* Copy current config state to GLOBAL */
566567
state_dir = g_strdup_printf("%s/run/netplan/config-%s", NETPLAN_ROOT, d->config_id);
567-
_copy_yaml_state(state_dir, NETPLAN_ROOT, ret_error);
568+
r = _copy_yaml_state(state_dir, NETPLAN_ROOT, ret_error);
569+
if (r < 0) return r;
568570
d->handler_id = g_strdup(d->config_id);
569571
}
570572

@@ -639,7 +641,8 @@ method_config_try(sd_bus_message *m, void *userdata, sd_bus_error *ret_error)
639641

640642
/* Copy current config *.yaml state to main rootdir (i.e. /etc/netplan/) */
641643
state_dir = g_strdup_printf("%s/run/netplan/config-%s", NETPLAN_ROOT, d->config_id);
642-
_copy_yaml_state(state_dir, NETPLAN_ROOT, ret_error);
644+
r = _copy_yaml_state(state_dir, NETPLAN_ROOT, ret_error);
645+
if (r < 0) return r;
643646

644647
/* Exec try */
645648
r = method_try(m, userdata, ret_error);
@@ -670,7 +673,8 @@ method_config_cancel(sd_bus_message *m, void *userdata, sd_bus_error *ret_error)
670673
unlink_glob(NETPLAN_ROOT, "/{etc,run,lib}/netplan/*.yaml");
671674
/* Restore GLOBAL backup config state to main rootdir */
672675
state_dir = g_strdup_printf("%s/run/netplan/config-%s", NETPLAN_ROOT, NETPLAN_GLOBAL_CONFIG);
673-
_copy_yaml_state(state_dir, NETPLAN_ROOT, ret_error);
676+
r = _copy_yaml_state(state_dir, NETPLAN_ROOT, ret_error);
677+
if (r < 0) return r;
674678

675679
/* Clear GLOBAL backup and config state */
676680
_clear_tmp_state(NETPLAN_GLOBAL_CONFIG, d);
@@ -754,7 +758,8 @@ method_config(sd_bus_message *m, void *userdata, sd_bus_error *ret_error)
754758
}
755759

756760
/* Copy all *.yaml files from /{etc,run,lib}/netplan/ to temp dir */
757-
_copy_yaml_state(NETPLAN_ROOT, path, ret_error);
761+
r = _copy_yaml_state(NETPLAN_ROOT, path, ret_error);
762+
if (r < 0) return r;
758763

759764
return sd_bus_reply_method_return(m, "o", obj_path);
760765
}

0 commit comments

Comments
 (0)