1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! # DBus interface proxy for: `net.openvpn.v3.configuration`
//!
//! This code was generated by `zbus-xmlgen` `3.1.0` from DBus introspection data.
//! Source: `net.openvpn.v3.configuration.xml`.

use crate::log::constants::{LogGroup, LogLevel};

use super::configuration_node::{ConfigurationNodeProxy, ConfigurationNodeProxyBlocking};

use zbus::{dbus_proxy, fdo};

/// Configuration Manager
#[dbus_proxy(
    interface = "net.openvpn.v3.configuration",
    default_service = "net.openvpn.v3.configuration",
    default_path = "/net/openvpn/v3/configuration"
)]
trait Configuration {
    /// FetchAvailableConfigs method
    ///
    /// This method will return an array of object paths to configuration objects the caller is granted access to.
    fn fetch_available_configs(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;

    /// Import method
    ///
    /// This method imports a configuration profile. The configuration must be represented as a string blob containing everything.
    ///
    /// # Arguments
    ///
    /// * `name` - User friendly name of the profile. To be used in user front-ends.
    /// * `config_str` - Content of config file. All files must be embedded inline.
    /// * `single_use` - If set to true, it will be removed from memory on first use.
    /// * `persistent` - If set to true, the configuration will be saved to disk.
    ///
    /// # Returns
    ///
    /// A unique D-Bus object path for the imported VPN configuration profile
    #[dbus_proxy(object = "ConfigurationNode")]
    fn import(&self, name: &str, config_str: &str, single_use: bool, persistent: bool);

    /// LookupConfigName method
    ///
    /// This method will return an array of object paths to configuration objects the caller is granted access with the configuration name provided to the method.
    ///
    /// # Arguments
    ///
    /// * `config_name` - String containing the configuration name for the configuration path lookup.
    ///
    /// # Returns
    ///
    /// An array of object paths to accessible configuration objects
    fn lookup_config_name(
        &self,
        config_name: &str,
    ) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;

    /// TransferOwnership method
    ///
    /// This method transfers the ownership of a configuration profile to the given UID value.
    /// This feature is by design restricted to the root account only and is only expected to be used by `openvpn3-autoload` and similar tools.
    ///
    /// # Arguments
    ///
    /// * `path` - Configuration object path where to modify the owner property.
    /// * `new_owner_uid` - UID value of the new owner of the configuration profile.
    fn transfer_ownership(
        &self,
        path: &zbus::zvariant::ObjectPath<'_>,
        new_owner_uid: u32,
    ) -> fdo::Result<()>;

    /// Log signal
    ///
    /// Whenever the configuration manager wants to log something, it issues a Log signal which carries a log group, log verbosity level and a string with the log message itself.
    /// See the separate [logging documentation](https://github.com/OpenVPN/openvpn3-linux/blob/master/docs/dbus/dbus-logging.md) for details on this signal.
    #[dbus_proxy(signal)]
    fn log(&self, group: LogGroup, level: LogLevel, message: &str) -> fdo::Result<()>;

    /// Version of the currently running service.
    #[dbus_proxy(property, name = "version")]
    fn version(&self) -> zbus::Result<String>;
}