NetworkManager r3869 - in trunk/vpn-daemons/openvpn: . properties
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3869 - in trunk/vpn-daemons/openvpn: . properties
- Date: Tue, 29 Jul 2008 04:53:18 +0000 (UTC)
Author: dcbw
Date: Tue Jul 29 04:53:18 2008
New Revision: 3869
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3869&view=rev
Log:
2008-07-28 Dan Williams <dcbw redhat com>
* properties/auth-helpers.c
- (populate_cipher_combo): don't depend on shell and utils which may not
always be there
Modified:
trunk/vpn-daemons/openvpn/ChangeLog
trunk/vpn-daemons/openvpn/properties/auth-helpers.c
Modified: trunk/vpn-daemons/openvpn/properties/auth-helpers.c
==============================================================================
--- trunk/vpn-daemons/openvpn/properties/auth-helpers.c (original)
+++ trunk/vpn-daemons/openvpn/properties/auth-helpers.c Tue Jul 29 04:53:18 2008
@@ -681,18 +681,26 @@
GtkListStore *store;
GtkTreeIter iter;
const char *openvpn_binary = NULL;
- gchar *cmdline, *tmp, *token;
+ gchar *tmp, **items, **item;
gboolean user_added = FALSE;
+ char *argv[3];
+ GError *error = NULL;
+ gboolean success, found_blank = FALSE;
openvpn_binary = nm_find_openvpn ();
if (!openvpn_binary)
return;
- cmdline = g_strdup_printf("/bin/sh -c \"%s --show-ciphers | /bin/awk '/^[A-Z][A-Z0-9]+-/ { print $1 }'\"", openvpn_binary);
- if (!g_spawn_command_line_sync(cmdline, &tmp, NULL, NULL, NULL))
- goto end;
-
- token = strtok(tmp, "\n");
+ argv[0] = (char *) openvpn_binary;
+ argv[1] = "--show-ciphers";
+ argv[2] = NULL;
+
+ success = g_spawn_sync ("/", argv, NULL, 0, NULL, NULL, &tmp, NULL, NULL, &error);
+ if (!success) {
+ g_warning ("%s: couldn't determine ciphers: %s", __func__, error->message);
+ g_error_free (error);
+ return;
+ }
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
gtk_combo_box_set_model (box, GTK_TREE_MODEL (store));
@@ -703,18 +711,32 @@
TLS_CIPHER_COL_NAME, _("Default"),
TLS_CIPHER_COL_DEFAULT, TRUE, -1);
- while (token) {
- if (strlen (token)) {
+ items = g_strsplit (tmp, "\n", 0);
+ g_free (tmp);
+
+ for (item = items; *item; item++) {
+ char *space = strchr (*item, ' ');
+
+ /* Don't add anything until after the first blank line */
+ if (!found_blank) {
+ if (!strlen (*item))
+ found_blank = TRUE;
+ continue;
+ }
+
+ if (space)
+ *space = '\0';
+
+ if (strlen (*item)) {
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
- TLS_CIPHER_COL_NAME, token,
+ TLS_CIPHER_COL_NAME, *item,
TLS_CIPHER_COL_DEFAULT, FALSE, -1);
- if (user_cipher && !strcmp (token, user_cipher)) {
+ if (user_cipher && !strcmp (*item, user_cipher)) {
gtk_combo_box_set_active_iter (box, &iter);
user_added = TRUE;
}
}
- token = strtok (NULL, "\n");
}
/* Add the user-specified cipher if it exists wasn't found by openvpn */
@@ -731,7 +753,7 @@
g_object_unref (G_OBJECT (store));
end:
- g_free(tmp);
+ g_strfreev (items);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]