Commit 5a7cf39a authored by Dan Williams's avatar Dan Williams

libnm-util: add secret flags for each secret describing how the secret is stored

This allows the necessary flexibility when handling secrets; otherwise
it wouldn't be known when NM should save secrets returned from agents
to backing storage, or when the agents should store the secrets. We
can't simply use lack of a secret in persistent storage as the indicator
of this, as (for example) when creating a new connection without
secrets the storage method would be abmiguous.

At the same time, fold in "always ask" functionality for OTP tokens
so user agents don't have to store that attribute themselves out-of-band.
parent 12908c8a
......@@ -46,6 +46,7 @@ global:
nm_setting_802_1x_get_identity;
nm_setting_802_1x_get_num_eap_methods;
nm_setting_802_1x_get_password;
nm_setting_802_1x_get_password_flags;
nm_setting_802_1x_get_phase1_fast_provisioning;
nm_setting_802_1x_get_phase1_peaplabel;
nm_setting_802_1x_get_phase1_peapver;
......@@ -69,6 +70,7 @@ global:
nm_setting_802_1x_get_phase2_private_key_format;
nm_setting_802_1x_set_phase2_private_key_from_file;
nm_setting_802_1x_get_phase2_private_key_password;
nm_setting_802_1x_get_phase2_private_key_password_flags;
nm_setting_802_1x_get_phase2_private_key_path;
nm_setting_802_1x_get_phase2_private_key_scheme;
nm_setting_802_1x_get_phase2_private_key_type;
......@@ -79,11 +81,11 @@ global:
nm_setting_802_1x_get_private_key_format;
nm_setting_802_1x_set_private_key_from_file;
nm_setting_802_1x_get_private_key_password;
nm_setting_802_1x_get_private_key_password_flags;
nm_setting_802_1x_get_private_key_path;
nm_setting_802_1x_get_private_key_scheme;
nm_setting_802_1x_get_private_key_type;
nm_setting_802_1x_set_private_key;
nm_setting_802_1x_get_psk;
nm_setting_802_1x_get_system_ca_certs;
nm_setting_802_1x_get_type;
nm_setting_802_1x_new;
......@@ -101,6 +103,7 @@ global:
nm_setting_cdma_get_number;
nm_setting_cdma_get_username;
nm_setting_cdma_get_password;
nm_setting_cdma_get_password_flags;
nm_setting_clear_secrets;
nm_setting_compare;
nm_setting_connection_error_get_type;
......@@ -130,13 +133,13 @@ global:
nm_setting_gsm_get_number;
nm_setting_gsm_get_username;
nm_setting_gsm_get_password;
nm_setting_gsm_get_password_flags;
nm_setting_gsm_get_apn;
nm_setting_gsm_get_network_id;
nm_setting_gsm_get_network_type;
nm_setting_gsm_get_allowed_bands;
nm_setting_gsm_get_band;
nm_setting_gsm_get_pin;
nm_setting_gsm_get_puk;
nm_setting_gsm_get_pin_flags;
nm_setting_gsm_get_home_only;
nm_setting_ip4_config_error_get_type;
nm_setting_ip4_config_error_quark;
......@@ -255,6 +258,7 @@ global:
nm_setting_pppoe_get_service;
nm_setting_pppoe_get_username;
nm_setting_pppoe_get_password;
nm_setting_pppoe_get_password_flags;
nm_setting_serial_error_get_type;
nm_setting_serial_error_quark;
nm_setting_serial_get_type;
......@@ -268,20 +272,22 @@ global:
nm_setting_to_string;
nm_setting_update_secrets;
nm_setting_verify;
nm_setting_vpn_add_data_item;
nm_setting_vpn_add_secret;
nm_setting_vpn_error_get_type;
nm_setting_vpn_error_quark;
nm_setting_vpn_get_type;
nm_setting_vpn_new;
nm_setting_vpn_get_service_type;
nm_setting_vpn_get_user_name;
nm_setting_vpn_add_data_item;
nm_setting_vpn_foreach_data_item;
nm_setting_vpn_get_data_item;
nm_setting_vpn_remove_data_item;
nm_setting_vpn_add_secret;
nm_setting_vpn_foreach_secret;
nm_setting_vpn_get_data_item;
nm_setting_vpn_get_secret;
nm_setting_vpn_get_secret_flags;
nm_setting_vpn_get_service_type;
nm_setting_vpn_get_type;
nm_setting_vpn_get_user_name;
nm_setting_vpn_new;
nm_setting_vpn_remove_data_item;
nm_setting_vpn_remove_secret;
nm_setting_vpn_set_secret_flags;
nm_setting_wimax_error_get_type;
nm_setting_wimax_error_quark;
nm_setting_wimax_get_type;
......@@ -338,14 +344,17 @@ global:
nm_setting_wireless_security_get_key_mgmt;
nm_setting_wireless_security_get_leap_username;
nm_setting_wireless_security_get_leap_password;
nm_setting_wireless_security_get_leap_password_flags;
nm_setting_wireless_security_get_num_groups;
nm_setting_wireless_security_get_num_pairwise;
nm_setting_wireless_security_get_num_protos;
nm_setting_wireless_security_get_pairwise;
nm_setting_wireless_security_get_proto;
nm_setting_wireless_security_get_psk;
nm_setting_wireless_security_get_psk_flags;
nm_setting_wireless_security_get_type;
nm_setting_wireless_security_get_wep_key;
nm_setting_wireless_security_get_wep_key_flags;
nm_setting_wireless_security_get_wep_key_type;
nm_setting_wireless_security_get_wep_tx_keyidx;
nm_setting_wireless_security_new;
......
This diff is collapsed.
......@@ -81,11 +81,15 @@ GQuark nm_setting_802_1x_error_quark (void);
#define NM_SETTING_802_1X_PHASE2_CA_PATH "phase2-ca-path"
#define NM_SETTING_802_1X_PHASE2_CLIENT_CERT "phase2-client-cert"
#define NM_SETTING_802_1X_PASSWORD "password"
#define NM_SETTING_802_1X_PASSWORD_FLAGS "password-flags"
#define NM_SETTING_802_1X_PRIVATE_KEY "private-key"
#define NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD "private-key-password"
#define NM_SETTING_802_1X_PRIVATE_KEY_PASSWORD_FLAGS "private-key-password-flags"
#define NM_SETTING_802_1X_PHASE2_PRIVATE_KEY "phase2-private-key"
#define NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD "phase2-private-key-password"
#define NM_SETTING_802_1X_PHASE2_PRIVATE_KEY_PASSWORD_FLAGS "phase2-private-key-password-flags"
#define NM_SETTING_802_1X_PIN "pin"
#define NM_SETTING_802_1X_PIN_FLAGS "pin-flags"
#define NM_SETTING_802_1X_SYSTEM_CA_CERTS "system-ca-certs"
/* PRIVATE KEY NOTE: when setting PKCS#12 private keys directly via properties
......@@ -101,15 +105,17 @@ GQuark nm_setting_802_1x_error_quark (void);
*
* When setting OpenSSL-derived "traditional" format (ie S/MIME style, not
* PKCS#8) RSA and DSA keys directly via properties with the "blob" scheme, they
* must passed to NetworkManager completely decrypted because the OpenSSL
* "traditional" format is non-standard and is not complete enough for all
* crypto libraries to use. Thus, for OpenSSL "traditional" format keys, the
* private key password is not passed to NetworkManager (because the data is
* already decrypted by the client), and the appropriate "client-cert" (or
* "phase2-client-cert") property of the NMSetting8021x object must be a valid
* client certificate. When using the "path" scheme, just set the private-key
* and client-cert properties to the paths to their respective objects, and
* set the private-key password correctly.
* should be passed to NetworkManager in PEM format with the "DEK-Info" and
* "Proc-Type" tags intact, or in decrypted binary DER format (not recommended,
* as this may allow unprivileged users to read the decrypted private key).
* When decryped keys are used (again, not recommended) the private key password
* should not be set. The recommended method for passing private keys to
* NetworkManager is via the "path" scheme with encrypted private keys, and a
* private key password.
*
* When using the "path" scheme, just set the private-key and client-cert
* properties to the paths to their respective objects, and set the private-key
* password correctly.
*/
typedef struct {
......@@ -191,8 +197,10 @@ gboolean nm_setting_802_1x_set_phase2_client_cert (NMSett
GError **error);
const char * nm_setting_802_1x_get_password (NMSetting8021x *setting);
NMSettingSecretFlags nm_setting_802_1x_get_password_flags (NMSetting8021x *setting);
const char * nm_setting_802_1x_get_pin (NMSetting8021x *setting);
NMSettingSecretFlags nm_setting_802_1x_get_pin_flags (NMSetting8021x *setting);
NMSetting8021xCKScheme nm_setting_802_1x_get_private_key_scheme (NMSetting8021x *setting);
const GByteArray * nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting);
......@@ -204,6 +212,7 @@ gboolean nm_setting_802_1x_set_private_key (NMSett
NMSetting8021xCKFormat *out_format,
GError **error);
const char * nm_setting_802_1x_get_private_key_password (NMSetting8021x *setting);
NMSettingSecretFlags nm_setting_802_1x_get_private_key_password_flags (NMSetting8021x *setting);
NMSetting8021xCKFormat nm_setting_802_1x_get_private_key_format (NMSetting8021x *setting);
......@@ -217,6 +226,7 @@ gboolean nm_setting_802_1x_set_phase2_private_key (NMSett
NMSetting8021xCKFormat *out_format,
GError **error);
const char * nm_setting_802_1x_get_phase2_private_key_password (NMSetting8021x *setting);
NMSettingSecretFlags nm_setting_802_1x_get_phase2_private_key_password_flags (NMSetting8021x *setting);
NMSetting8021xCKFormat nm_setting_802_1x_get_phase2_private_key_format (NMSetting8021x *setting);
......
......@@ -18,7 +18,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2011 Red Hat, Inc.
*/
#include <string.h>
......@@ -87,6 +87,7 @@ typedef struct {
char *number; /* For dialing, duh */
char *username;
char *password;
NMSettingSecretFlags password_flags;
} NMSettingCdmaPrivate;
enum {
......@@ -94,6 +95,7 @@ enum {
PROP_NUMBER,
PROP_USERNAME,
PROP_PASSWORD,
PROP_PASSWORD_FLAGS,
LAST_PROP
};
......@@ -153,6 +155,20 @@ nm_setting_cdma_get_password (NMSettingCdma *setting)
return NM_SETTING_CDMA_GET_PRIVATE (setting)->password;
}
/**
* nm_setting_cdma_get_password_flags:
* @setting: the #NMSettingCdma
*
* Returns: the #NMSettingSecretFlags pertaining to the #NMSettingCdma:password
**/
NMSettingSecretFlags
nm_setting_cdma_get_password_flags (NMSettingCdma *setting)
{
g_return_val_if_fail (NM_IS_SETTING_CDMA (setting), NM_SETTING_SECRET_FLAG_SYSTEM_OWNED);
return NM_SETTING_CDMA_GET_PRIVATE (setting)->password_flags;
}
static gint
find_setting_by_name (gconstpointer a, gconstpointer b)
{
......@@ -264,6 +280,9 @@ set_property (GObject *object, guint prop_id,
g_free (priv->password);
priv->password = g_value_dup_string (value);
break;
case PROP_PASSWORD_FLAGS:
priv->password_flags = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -286,6 +305,9 @@ get_property (GObject *object, guint prop_id,
case PROP_PASSWORD:
g_value_set_string (value, nm_setting_cdma_get_password (setting));
break;
case PROP_PASSWORD_FLAGS:
g_value_set_uint (value, nm_setting_cdma_get_password_flags (setting));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -360,4 +382,18 @@ nm_setting_cdma_class_init (NMSettingCdmaClass *setting_class)
"a password or accept any password.",
NULL,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
/**
* NMSettingCdma:password-flags:
*
* Flags indicating how to handle #NMSettingCdma:password:.
**/
g_object_class_install_property (object_class, PROP_PASSWORD_FLAGS,
g_param_spec_uint (NM_SETTING_CDMA_PASSWORD_FLAGS,
"Password Flags",
"Flags indicating how to handle the CDMA password.",
NM_SETTING_SECRET_FLAG_SYSTEM_OWNED,
NM_SETTING_SECRET_FLAG_LAST,
NM_SETTING_SECRET_FLAG_SYSTEM_OWNED,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
}
......@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2011 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
......@@ -53,9 +53,10 @@ GType nm_setting_cdma_error_get_type (void);
#define NM_SETTING_CDMA_ERROR nm_setting_cdma_error_quark ()
GQuark nm_setting_cdma_error_quark (void);
#define NM_SETTING_CDMA_NUMBER "number"
#define NM_SETTING_CDMA_USERNAME "username"
#define NM_SETTING_CDMA_PASSWORD "password"
#define NM_SETTING_CDMA_NUMBER "number"
#define NM_SETTING_CDMA_USERNAME "username"
#define NM_SETTING_CDMA_PASSWORD "password"
#define NM_SETTING_CDMA_PASSWORD_FLAGS "password-flags"
typedef struct {
NMSetting parent;
......@@ -77,6 +78,7 @@ NMSetting *nm_setting_cdma_new (void);
const char *nm_setting_cdma_get_number (NMSettingCdma *setting);
const char *nm_setting_cdma_get_username (NMSettingCdma *setting);
const char *nm_setting_cdma_get_password (NMSettingCdma *setting);
NMSettingSecretFlags nm_setting_cdma_get_password_flags (NMSettingCdma *setting);
G_END_DECLS
......
......@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2011 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
......@@ -73,6 +73,7 @@ typedef struct {
char *number; /* For dialing, duh */
char *username;
char *password;
NMSettingSecretFlags password_flags;
char *apn; /* NULL for dynamic */
char *network_id; /* for manual registration or NULL for automatic */
......@@ -80,6 +81,7 @@ typedef struct {
guint32 allowed_bands; /* A bitfield of NM_SETTING_GSM_BAND_* */
char *pin;
NMSettingSecretFlags pin_flags;
gboolean home_only;
} NMSettingGsmPrivate;
......@@ -89,10 +91,12 @@ enum {
PROP_NUMBER,
PROP_USERNAME,
PROP_PASSWORD,
PROP_PASSWORD_FLAGS,
PROP_APN,
PROP_NETWORK_ID,
PROP_NETWORK_TYPE,
PROP_PIN,
PROP_PIN_FLAGS,
PROP_ALLOWED_BANDS,
PROP_HOME_ONLY,
......@@ -138,6 +142,20 @@ nm_setting_gsm_get_password (NMSettingGsm *setting)
return NM_SETTING_GSM_GET_PRIVATE (setting)->password;
}
/**
* nm_setting_gsm_get_password_flags:
* @setting: the #NMSettingGsm
*
* Returns: the #NMSettingSecretFlags pertaining to the #NMSettingGsm:password
**/
NMSettingSecretFlags
nm_setting_gsm_get_password_flags (NMSettingGsm *setting)
{
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NM_SETTING_SECRET_FLAG_SYSTEM_OWNED);
return NM_SETTING_GSM_GET_PRIVATE (setting)->password_flags;
}
const char *
nm_setting_gsm_get_apn (NMSettingGsm *setting)
{
......@@ -178,6 +196,20 @@ nm_setting_gsm_get_pin (NMSettingGsm *setting)
return NM_SETTING_GSM_GET_PRIVATE (setting)->pin;
}
/**
* nm_setting_gsm_get_pin_flags:
* @setting: the #NMSettingGsm
*
* Returns: the #NMSettingSecretFlags pertaining to the #NMSettingGsm:pin
**/
NMSettingSecretFlags
nm_setting_gsm_get_pin_flags (NMSettingGsm *setting)
{
g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NM_SETTING_SECRET_FLAG_SYSTEM_OWNED);
return NM_SETTING_GSM_GET_PRIVATE (setting)->pin_flags;
}
gboolean
nm_setting_gsm_get_home_only (NMSettingGsm *setting)
{
......@@ -342,6 +374,9 @@ set_property (GObject *object, guint prop_id,
g_free (priv->password);
priv->password = g_value_dup_string (value);
break;
case PROP_PASSWORD_FLAGS:
priv->password_flags = g_value_get_uint (value);
break;
case PROP_APN:
g_free (priv->apn);
priv->apn = NULL;
......@@ -366,6 +401,9 @@ set_property (GObject *object, guint prop_id,
g_free (priv->pin);
priv->pin = g_value_dup_string (value);
break;
case PROP_PIN_FLAGS:
priv->pin_flags = g_value_get_uint (value);
break;
case PROP_HOME_ONLY:
priv->home_only = g_value_get_boolean (value);
break;
......@@ -391,6 +429,9 @@ get_property (GObject *object, guint prop_id,
case PROP_PASSWORD:
g_value_set_string (value, nm_setting_gsm_get_password (setting));
break;
case PROP_PASSWORD_FLAGS:
g_value_set_uint (value, nm_setting_gsm_get_password_flags (setting));
break;
case PROP_APN:
g_value_set_string (value, nm_setting_gsm_get_apn (setting));
break;
......@@ -406,6 +447,9 @@ get_property (GObject *object, guint prop_id,
case PROP_PIN:
g_value_set_string (value, nm_setting_gsm_get_pin (setting));
break;
case PROP_PIN_FLAGS:
g_value_set_uint (value, nm_setting_gsm_get_pin_flags (setting));
break;
case PROP_HOME_ONLY:
g_value_set_boolean (value, nm_setting_gsm_get_home_only (setting));
break;
......@@ -486,6 +530,20 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
NULL,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
/**
* NMSettingGsm:password-flags:
*
* Flags indicating how to handle #NMSettingGsm:password:.
**/
g_object_class_install_property (object_class, PROP_PASSWORD_FLAGS,
g_param_spec_uint (NM_SETTING_GSM_PASSWORD_FLAGS,
"Password Flags",
"Flags indicating how to handle the GSM password.",
NM_SETTING_SECRET_FLAG_SYSTEM_OWNED,
NM_SETTING_SECRET_FLAG_LAST,
NM_SETTING_SECRET_FLAG_SYSTEM_OWNED,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingGsm:apn:
*
......@@ -605,6 +663,20 @@ nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
NULL,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
/**
* NMSettingGsm:pin-flags:
*
* Flags indicating how to handle #NMSettingGsm:pin:.
**/
g_object_class_install_property (object_class, PROP_PIN_FLAGS,
g_param_spec_uint (NM_SETTING_GSM_PIN_FLAGS,
"PIN Flags",
"Flags indicating how to handle the GSM SIM PIN.",
NM_SETTING_SECRET_FLAG_SYSTEM_OWNED,
NM_SETTING_SECRET_FLAG_LAST,
NM_SETTING_SECRET_FLAG_SYSTEM_OWNED,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
/**
* NMSettingGsm:home-only:
*
......
......@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2011 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
......@@ -53,15 +53,17 @@ GType nm_setting_gsm_error_get_type (void);
#define NM_SETTING_GSM_ERROR nm_setting_gsm_error_quark ()
GQuark nm_setting_gsm_error_quark (void);
#define NM_SETTING_GSM_NUMBER "number"
#define NM_SETTING_GSM_USERNAME "username"
#define NM_SETTING_GSM_PASSWORD "password"
#define NM_SETTING_GSM_APN "apn"
#define NM_SETTING_GSM_NETWORK_ID "network-id"
#define NM_SETTING_GSM_NETWORK_TYPE "network-type"
#define NM_SETTING_GSM_ALLOWED_BANDS "allowed-bands"
#define NM_SETTING_GSM_PIN "pin"
#define NM_SETTING_GSM_HOME_ONLY "home-only"
#define NM_SETTING_GSM_NUMBER "number"
#define NM_SETTING_GSM_USERNAME "username"
#define NM_SETTING_GSM_PASSWORD "password"
#define NM_SETTING_GSM_PASSWORD_FLAGS "password-flags"
#define NM_SETTING_GSM_APN "apn"
#define NM_SETTING_GSM_NETWORK_ID "network-id"
#define NM_SETTING_GSM_NETWORK_TYPE "network-type"
#define NM_SETTING_GSM_ALLOWED_BANDS "allowed-bands"
#define NM_SETTING_GSM_PIN "pin"
#define NM_SETTING_GSM_PIN_FLAGS "pin-flags"
#define NM_SETTING_GSM_HOME_ONLY "home-only"
typedef enum {
NM_SETTING_GSM_NETWORK_TYPE_ANY = -1,
......@@ -115,6 +117,9 @@ guint32 nm_setting_gsm_get_allowed_bands (NMSettingGsm *setting);
const char *nm_setting_gsm_get_pin (NMSettingGsm *setting);
gboolean nm_setting_gsm_get_home_only (NMSettingGsm *setting);
NMSettingSecretFlags nm_setting_gsm_get_pin_flags (NMSettingGsm *setting);
NMSettingSecretFlags nm_setting_gsm_get_password_flags (NMSettingGsm *setting);
G_END_DECLS
#endif /* NM_SETTING_GSM_H */
......@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2011 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
......@@ -71,6 +71,7 @@ typedef struct {
char *service;
char *username;
char *password;
NMSettingSecretFlags password_flags;
} NMSettingPPPOEPrivate;
enum {
......@@ -78,6 +79,7 @@ enum {
PROP_SERVICE,
PROP_USERNAME,
PROP_PASSWORD,
PROP_PASSWORD_FLAGS,
LAST_PROP
};
......@@ -112,6 +114,20 @@ nm_setting_pppoe_get_password (NMSettingPPPOE *setting)
return NM_SETTING_PPPOE_GET_PRIVATE (setting)->password;
}
/**
* nm_setting_pppoe_get_password_flags:
* @setting: the #NMSettingPPPOE
*
* Returns: the #NMSettingSecretFlags pertaining to the #NMSettingPPPOE:password
**/
NMSettingSecretFlags
nm_setting_pppoe_get_password_flags (NMSettingPPPOE *setting)
{
g_return_val_if_fail (NM_IS_SETTING_PPPOE (setting), NM_SETTING_SECRET_FLAG_SYSTEM_OWNED);
return NM_SETTING_PPPOE_GET_PRIVATE (setting)->password_flags;
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
......@@ -182,6 +198,9 @@ set_property (GObject *object, guint prop_id,
g_free (priv->password);
priv->password = g_value_dup_string (value);
break;
case PROP_PASSWORD_FLAGS:
priv->password_flags = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -204,6 +223,9 @@ get_property (GObject *object, guint prop_id,
case PROP_PASSWORD:
g_value_set_string (value, nm_setting_pppoe_get_password (setting));
break;
case PROP_PASSWORD_FLAGS:
g_value_set_uint (value, nm_setting_pppoe_get_password_flags (setting));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
......@@ -271,4 +293,18 @@ nm_setting_pppoe_class_init (NMSettingPPPOEClass *setting_class)
"Password used to authenticate with the PPPoE service.",
NULL,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE | NM_SETTING_PARAM_SECRET));
/**
* NMSettingPPPOE:password-flags:
*
* Flags indicating how to handle #NMSettingPPPOE:password:.
**/
g_object_class_install_property (object_class, PROP_PASSWORD_FLAGS,
g_param_spec_uint (NM_SETTING_PPPOE_PASSWORD_FLAGS,
"Password Flags",
"Flags indicating how to handle the PPPoE password.",
NM_SETTING_SECRET_FLAG_SYSTEM_OWNED,
NM_SETTING_SECRET_FLAG_LAST,
NM_SETTING_SECRET_FLAG_SYSTEM_OWNED,
G_PARAM_READWRITE | NM_SETTING_PARAM_SERIALIZE));
}
......@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2008 Red Hat, Inc.
* (C) Copyright 2007 - 2011 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
......@@ -53,9 +53,10 @@ GType nm_setting_pppoe_error_get_type (void);
#define NM_SETTING_PPPOE_ERROR nm_setting_pppoe_error_quark ()
GQuark nm_setting_pppoe_error_quark (void);
#define NM_SETTING_PPPOE_SERVICE "service"
#define NM_SETTING_PPPOE_USERNAME "username"
#define NM_SETTING_PPPOE_PASSWORD "password"
#define NM_SETTING_PPPOE_SERVICE "service"
#define NM_SETTING_PPPOE_USERNAME "username"
#define NM_SETTING_PPPOE_PASSWORD "password"
#define NM_SETTING_PPPOE_PASSWORD_FLAGS "password-flags"
typedef struct {
NMSetting parent;
......@@ -77,6 +78,7 @@ NMSetting *nm_setting_pppoe_new (void);
const char *nm_setting_pppoe_get_service (NMSettingPPPOE *setting);
const char *nm_setting_pppoe_get_username (NMSettingPPPOE *setting);
const char *nm_setting_pppoe_get_password (NMSettingPPPOE *setting);
NMSettingSecretFlags nm_setting_pppoe_get_password_flags (NMSettingPPPOE *setting);
G_END_DECLS
......
......@@ -23,6 +23,8 @@
*/
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <dbus/dbus-glib.h>
#include "nm-setting-vpn.h"
#include "nm-param-spec-specialized.h"
......@@ -227,6 +229,75 @@ nm_setting_vpn_foreach_secret (NMSettingVPN *setting,
(GHFunc) func, user_data);
}
/**
* nm_setting_vpn_get_secret_flags:
* @setting: a #NMSettingVPN
* @secret_name: the secret key name to get flags for
* @out_flags: on success, the flags for the secret @secret_name
*
* For a given VPN secret, retrieves the #NMSettingSecretFlags describing how to
* handle that secret.
*
* Returns: TRUE on success (if the secret flags data item was found), FALSE if
* the secret flags data item was not found
*/
gboolean
nm_setting_vpn_get_secret_flags (NMSettingVPN *setting,
const char *secret_name,
NMSettingSecretFlags *out_flags)
{
char *flags_key;
unsigned long tmp;
gboolean success = FALSE;
gpointer val;
g_return_val_if_fail (NM_IS_SETTING_VPN (setting), FALSE);
g_return_val_if_fail (secret_name != NULL, FALSE);
g_return_val_if_fail (out_flags != NULL, FALSE);
flags_key = g_strdup_printf ("%s-flags", secret_name);
g_assert (flags_key);
if (g_hash_table_lookup_extended (NM_SETTING_VPN_GET_PRIVATE (setting)->data,
flags_key,
NULL,
&val)) {
errno = 0;
tmp = strtoul ((const char *) val, NULL, 10);
if ((errno == 0) && (tmp <= NM_SETTING_SECRET_FLAG_LAST)) {
success = TRUE;
*out_flags = (guint32) tmp;
}
}
g_free (flags_key);
return success;
}
/**
* nm_setting_vpn_set_secret_flags:
* @setting: a #NMSettingVPN
* @secret_name: the secret key name to set flags for
* @flags: the flags for the secret
*
* For a given VPN secret, sets the #NMSettingSecretFlags describing how to
* handle that secret.
*/
void
nm_setting_vpn_set_secret_flags (NMSettingVPN *setting,
const char *secret_name,
NMSettingSecretFlags flags)
{
char *key_name, *str_val;
g_return_if_fail (NM_IS_SETTING_VPN (setting));
g_return_if_fail (secret_name != NULL);
key_name = g_strdup_printf ("%s-flags", secret_name);
g_assert (key_name);
str_val = g_strdup_printf ("%u", flags);
g_assert (str_val);
g_hash_table_insert (NM_SETTING_VPN_GET_PRIVATE (setting)->data, key_name, str_val);
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
......
......@@ -103,6 +103,14 @@ void nm_setting_vpn_foreach_secret (NMSettingVPN *setting,
NMVPNIterFunc func,
gpointer user_data);
gboolean nm_setting_vpn_get_secret_flags (NMSettingVPN *setting,
const char *secret_name,
NMSettingSecretFlags *out_flags);
void nm_setting_vpn_set_secret_flags (NMSettingVPN *setting,
const char *secret_name,
NMSettingSecretFlags flags);
G_END_DECLS
#endif /* NM_SETTING_VPN_H */
......@@ -19,7 +19,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*
* (C) Copyright 2007 - 2010 Red Hat, Inc.
* (C) Copyright 2007 - 2011 Red Hat, Inc.
* (C) Copyright 2007 - 2008 Novell, Inc.
*/
......@@ -82,19 +82,28 @@ G_DEFINE_TYPE (NMSettingWirelessSecurity, nm_setting_wireless_security, NM_TYPE_
typedef struct {
char *key_mgmt;
guint32 wep_tx_keyidx;
char *auth_alg;
GSList *proto; /* GSList of strings */
GSList *pairwise; /* GSList of strings */
GSList *group; /* GSList of strings */
/* LEAP */
char *leap_username;
char *leap_password;
NMSettingSecretFlags leap_password_flags;
/* WEP */
char *wep_key0;
char *wep_key1;
char *wep_key2;
char *wep_key3;
char *psk;
char *leap_password;
NMSettingSecretFlags wep_key_flags;
NMWepKeyType wep_key_type;
guint32 wep_tx_keyidx;
/* WPA-PSK */
char *psk;
NMSettingSecretFlags psk_flags;
} NMSettingWirelessSecurityPrivate;
enum {
......@@ -110,9 +119,12 @@ enum {
PROP_WEP_KEY1,
PROP_WEP_KEY2,
PROP_WEP_KEY3,
PROP_WEP_KEY_FLAGS,
PROP_WEP_KEY_TYPE,
PROP_PSK,
PROP_PSK_FLAGS,
PROP_LEAP_PASSWORD,
PROP_WEP_KEY_TYPE,
PROP_LEAP_PASSWORD_FLAGS,
LAST_PROP
};
......@@ -343,6 +355,21 @@ nm_setting_wireless_security_get_psk (NMSettingWirelessSecurity *setting)
return NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE (setting)->psk;
}