diff --git a/src/api2/config/network.rs b/src/api2/config/network.rs index 3ff4b1e6..d981d309 100644 --- a/src/api2/config/network.rs +++ b/src/api2/config/network.rs @@ -334,6 +334,19 @@ pub fn reload_network_config() -> Result<(), Error> { Ok(()) } +#[api( + access: { + permission: &Permission::Privilege(&[], PRIV_SYS_MODIFY, false), + }, +)] +/// Revert network configuration (rm /etc/network/interfaces.new). +pub fn revert_network_config() -> Result<(), Error> { + + let _ = std::fs::remove_file(network::NETWORK_INTERFACES_NEW_FILENAME); + + Ok(()) +} + const ITEM_ROUTER: Router = Router::new() .get(&API_METHOD_READ_INTERFACE) .put(&API_METHOD_UPDATE_INTERFACE) @@ -342,4 +355,5 @@ const ITEM_ROUTER: Router = Router::new() pub const ROUTER: Router = Router::new() .get(&API_METHOD_LIST_NETWORK_DEVICES) .put(&API_METHOD_RELOAD_NETWORK_CONFIG) + .delete(&API_METHOD_REVERT_NETWORK_CONFIG) .match_all("name", &ITEM_ROUTER); diff --git a/src/bin/proxmox-backup-manager.rs b/src/bin/proxmox-backup-manager.rs index d7c3126e..f1a63dfb 100644 --- a/src/bin/proxmox-backup-manager.rs +++ b/src/bin/proxmox-backup-manager.rs @@ -340,6 +340,7 @@ fn network_commands() -> CommandLineInterface { .arg_param(&["name"]) .completion_cb("name", config::network::complete_interface_name) ) + .insert("revert", CliCommand::new(&api2::config::network::API_METHOD_REVERT_NETWORK_CONFIG)) .insert( "reload", CliCommand::new(&api2::config::network::API_METHOD_RELOAD_NETWORK_CONFIG)