mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 15:48:06 +02:00
2005-05-11 Dan Williams <dcbw@redhat.com>
* vpn-daemons/vpnc/nm-vpnc-service.c - (nm_vpnc_start_vpnc_binary): NULL-ify GError before using it - (nm_vpnc_config_file_generate): Attempt to ensure that the path for the config file exists before trying to write it out. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@619 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
4baaec607b
commit
7d54da0ea8
2 changed files with 34 additions and 4 deletions
|
|
@ -1,3 +1,10 @@
|
||||||
|
2005-05-11 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* vpn-daemons/vpnc/nm-vpnc-service.c
|
||||||
|
- (nm_vpnc_start_vpnc_binary): NULL-ify GError before using it
|
||||||
|
- (nm_vpnc_config_file_generate): Attempt to ensure that the path for the config
|
||||||
|
file exists before trying to write it out.
|
||||||
|
|
||||||
2005-05-10 Dan Williams <dcbw@redhat.com>
|
2005-05-10 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* gnome/applet/applet-dbus-device.c
|
* gnome/applet/applet-dbus-device.c
|
||||||
|
|
|
||||||
|
|
@ -341,7 +341,7 @@ static gboolean nm_vpnc_start_vpnc_binary (NmVpncData *data)
|
||||||
GPid pid;
|
GPid pid;
|
||||||
const char * vpnc_binary;
|
const char * vpnc_binary;
|
||||||
GPtrArray * vpnc_argv;
|
GPtrArray * vpnc_argv;
|
||||||
GError * error;
|
GError * error = NULL;
|
||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
GSource * vpnc_watch;
|
GSource * vpnc_watch;
|
||||||
|
|
||||||
|
|
@ -366,6 +366,7 @@ static gboolean nm_vpnc_start_vpnc_binary (NmVpncData *data)
|
||||||
{
|
{
|
||||||
g_ptr_array_free (vpnc_argv, TRUE);
|
g_ptr_array_free (vpnc_argv, TRUE);
|
||||||
nm_warning ("vpnc failed to start. error: '%s'", error->message);
|
nm_warning ("vpnc failed to start. error: '%s'", error->message);
|
||||||
|
g_error_free(error);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
g_ptr_array_free (vpnc_argv, TRUE);
|
g_ptr_array_free (vpnc_argv, TRUE);
|
||||||
|
|
@ -392,14 +393,36 @@ static gboolean nm_vpnc_start_vpnc_binary (NmVpncData *data)
|
||||||
*/
|
*/
|
||||||
static gboolean nm_vpnc_config_file_generate (const char *user_name, const char *password, const char **data_items, const int num_items)
|
static gboolean nm_vpnc_config_file_generate (const char *user_name, const char *password, const char **data_items, const int num_items)
|
||||||
{
|
{
|
||||||
char *string;
|
char * string;
|
||||||
int out_fd;
|
int out_fd;
|
||||||
int i, x;
|
int i, x;
|
||||||
|
char * dirname;
|
||||||
|
char * cmd;
|
||||||
|
int ret;
|
||||||
|
|
||||||
g_return_val_if_fail (user_name != NULL, FALSE);
|
g_return_val_if_fail (user_name != NULL, FALSE);
|
||||||
g_return_val_if_fail (password != NULL, FALSE);
|
g_return_val_if_fail (password != NULL, FALSE);
|
||||||
g_return_val_if_fail (data_items != NULL, FALSE);
|
g_return_val_if_fail (data_items != NULL, FALSE);
|
||||||
|
|
||||||
|
/* Ensure that the config file's directory exists */
|
||||||
|
dirname = g_path_get_dirname (NM_VPNC_CONFIG_FILE_PATH);
|
||||||
|
if (!dirname || !strlen (dirname))
|
||||||
|
{
|
||||||
|
nm_warning ("Could not get dirname for vpnc config file path '%s'.", NM_VPNC_CONFIG_FILE_PATH);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
cmd = g_strdup_printf ("/bin/mkdir -p -m 700 %s", dirname);
|
||||||
|
ret = system (cmd);
|
||||||
|
if ((ret == -1) || (WEXITSTATUS(ret) != 0))
|
||||||
|
{
|
||||||
|
nm_warning ("Could not create dirname for vpnc config file path '%s'.", NM_VPNC_CONFIG_FILE_PATH);
|
||||||
|
g_free (cmd);
|
||||||
|
g_free (dirname);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
g_free (cmd);
|
||||||
|
|
||||||
unlink (NM_VPNC_CONFIG_FILE_PATH);
|
unlink (NM_VPNC_CONFIG_FILE_PATH);
|
||||||
out_fd = open (NM_VPNC_CONFIG_FILE_PATH, O_WRONLY|O_CREAT|O_TRUNC, 0600);
|
out_fd = open (NM_VPNC_CONFIG_FILE_PATH, O_WRONLY|O_CREAT|O_TRUNC, 0600);
|
||||||
if (out_fd < 0)
|
if (out_fd < 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue