[PATCH] dns: clean up error paths in dns-manager

2016-01-20 Thread Dan Williams
Specifically for resolvconf, if the write succeeded, but the pclose()
failed error would be left NULL and SR_ERROR would be returned, which
caused a crash in nm_dns_manager_end_updates().
---
 src/dns-manager/nm-dns-manager.c | 126 ++-
 1 file changed, 58 insertions(+), 68 deletions(-)

diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-dns-manager.c
index 01e8bf1..48f44ea 100644
--- a/src/dns-manager/nm-dns-manager.c
+++ b/src/dns-manager/nm-dns-manager.c
@@ -357,7 +357,6 @@ dispatch_netconfig (NMDnsManager *self,
 
if (searches) {
str = g_strjoinv (" ", searches);
-
write_to_netconfig (self, fd, "DNSSEARCH", str);
g_free (str);
}
@@ -405,10 +404,9 @@ write_resolv_conf (FILE *f,
char **options,
GError **error)
 {
-   char *searches_str = NULL;
-   char *nameservers_str = NULL;
-   char *options_str = NULL;
-   gboolean retval = FALSE;
+   gs_free char *searches_str = NULL;
+   gs_free char *nameservers_str = NULL;
+   gs_free char *options_str = NULL;
char *tmp_str;
GString *str;
int i;
@@ -425,12 +423,9 @@ write_resolv_conf (FILE *f,
g_free (tmp_str);
}
 
-   str = g_string_new ("");
-
if (nameservers) {
-   int num = g_strv_length (nameservers);
-
-   for (i = 0; i < num; i++) {
+   str = g_string_new ("");
+   for (i = 0; i < g_strv_length (nameservers); i++) {
if (i == 3) {
g_string_append (str, "# ");
g_string_append (str, _("NOTE: the libc 
resolver may not support more than 3 nameservers."));
@@ -443,28 +438,22 @@ write_resolv_conf (FILE *f,
g_string_append (str, nameservers[i]);
g_string_append_c (str, '\n');
}
+   nameservers_str = g_string_free (str, FALSE);
}
 
-   nameservers_str = g_string_free (str, FALSE);
-
if (fprintf (f, "# Generated by NetworkManager\n%s%s%s",
 searches_str ? searches_str : "",
-nameservers_str,
-options_str ? options_str : "") > 0)
-   retval = TRUE;
-   else {
+nameservers_str ? nameservers_str : "",
+options_str ? options_str : "") < 0) {
g_set_error (error,
 NM_MANAGER_ERROR,
 NM_MANAGER_ERROR_FAILED,
 "Could not write " _PATH_RESCONF ": %s\n",
 g_strerror (errno));
+   return FALSE;
}
 
-   g_free (searches_str);
-   g_free (nameservers_str);
-   g_free (options_str);
-
-   return retval;
+   return TRUE;
 }
 
 static SpawnResult
@@ -474,10 +463,11 @@ dispatch_resolvconf (NMDnsManager *self,
  char **options,
  GError **error)
 {
-   char *cmd;
+   gs_free char *cmd = NULL;
FILE *f;
-   gboolean retval = FALSE;
+   gboolean success = FALSE;
int errnosv, err;
+   GError *local = NULL;
 
if (!g_file_test (RESOLVCONF_PATH, G_FILE_TEST_IS_EXECUTABLE)) {
g_set_error_literal (error,
@@ -487,39 +477,45 @@ dispatch_resolvconf (NMDnsManager *self,
return SR_NOTFOUND;
}
 
-   if (searches || nameservers) {
-   cmd = g_strconcat (RESOLVCONF_PATH, " -a ", "NetworkManager", 
NULL);
-   _LOGI ("Writing DNS information to %s", RESOLVCONF_PATH);
-   if ((f = popen (cmd, "w")) == NULL)
-   g_set_error (error,
-NM_MANAGER_ERROR,
-NM_MANAGER_ERROR_FAILED,
-"Could not write to %s: %s\n",
-RESOLVCONF_PATH,
-g_strerror (errno));
-   else {
-   retval = write_resolv_conf (f, searches, nameservers, 
options, error);
-   err = pclose (f);
-   if (err < 0) {
-   errnosv = errno;
-   g_set_error (error, G_IO_ERROR, 
g_io_error_from_errno (errnosv),
-"Failed to close pipe to 
resolvconf: %d", errnosv);
-   retval = FALSE;
-   } else if (err > 0) {
-   _LOGW ("resolvconf failed with status %d", err);
-   retval = FALSE;
-   }
-   }
-   } else {
-   cmd = g_strconcat (RESOLVCONF_PATH, " -d ", "NetworkManager", 
NULL);
+   if (!searches && !nameservers) {

libnm-* configure check in nm-applet 1.2

2016-01-20 Thread Michael Biebl
Hi,

nm-applet 1.1.90 contains the following configure check:

PKG_CHECK_MODULES(LIBNM_GLIB,
[gio-2.0 >= 2.32
 NetworkManager >= 1.1
 libnm-glib >= 1.1
 libnm-util >= 1.1
 libnm-glib-vpn >= 1.1

This check should be updated to check for libnm >= 1.1 instead.

libnm-glib/libnm-util are still required to build libnm-gtk, which is
now deprecated. Dan suggested to add a configure switch t disable
building libnm-gtk. Checking for libnm-glib/libnm-util should therefor
be done conditional.

He also mentioned that NMA_CFLAGS in configure.ac should probably be
LIBNM_GLIB_CFLAGS


Regards,
Michael

-- 
Why is it that all of the instruments seeking intelligent life in the
universe are pointed away from Earth?



signature.asc
Description: OpenPGP digital signature
___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list


Re: [PATCH] dns: clean up error paths in dns-manager

2016-01-20 Thread Thomas Haller
On Wed, 2016-01-20 at 13:52 -0600, Dan Williams wrote:
> Specifically for resolvconf, if the write succeeded, but the pclose()
> failed error would be left NULL and SR_ERROR would be returned, which
> caused a crash in nm_dns_manager_end_updates().
> ---
>  src/dns-manager/nm-dns-manager.c | 126 ++---
> --
>  1 file changed, 58 insertions(+), 68 deletions(-)
> 
> diff --git a/src/dns-manager/nm-dns-manager.c b/src/dns-manager/nm-
> dns-manager.c
> index 01e8bf1..48f44ea 100644
> --- a/src/dns-manager/nm-dns-manager.c
> +++ b/src/dns-manager/nm-dns-manager.c
> @@ -357,7 +357,6 @@ dispatch_netconfig (NMDnsManager *self,
>  
>   if (searches) {
>   str = g_strjoinv (" ", searches);
> -
>   write_to_netconfig (self, fd, "DNSSEARCH", str);
>   g_free (str);
>   }
> @@ -405,10 +404,9 @@ write_resolv_conf (FILE *f,
> char **options,
> GError **error)
>  {
> - char *searches_str = NULL;
> - char *nameservers_str = NULL;
> - char *options_str = NULL;
> - gboolean retval = FALSE;
> + gs_free char *searches_str = NULL;
> + gs_free char *nameservers_str = NULL;
> + gs_free char *options_str = NULL;
>   char *tmp_str;
>   GString *str;
>   int i;
> @@ -425,12 +423,9 @@ write_resolv_conf (FILE *f,
>   g_free (tmp_str);
>   }
>  
> - str = g_string_new ("");
> -
>   if (nameservers) {
> - int num = g_strv_length (nameservers);
> -
> - for (i = 0; i < num; i++) {
> + str = g_string_new ("");
> + for (i = 0; i < g_strv_length (nameservers); i++) {

for (i = 0; nameservers[i]; i++)

otherwise, the length has to be calculated needlessly and for each
iteration.


>   if (i == 3) {
>   g_string_append (str, "# ");
>   g_string_append (str, _("NOTE: the
> libc resolver may not support more than 3 nameservers."));
> @@ -443,28 +438,22 @@ write_resolv_conf (FILE *f,
>   g_string_append (str, nameservers[i]);
>   g_string_append_c (str, '\n');
>   }
> + nameservers_str = g_string_free (str, FALSE);
>   }
>  
> - nameservers_str = g_string_free (str, FALSE);
> -
>   if (fprintf (f, "# Generated by NetworkManager\n%s%s%s",
>    searches_str ? searches_str : "",
> -  nameservers_str,
> -  options_str ? options_str : "") > 0)
> - retval = TRUE;
> - else {
> +  nameservers_str ? nameservers_str : "",
> +  options_str ? options_str : "") < 0) {
>   g_set_error (error,
>    NM_MANAGER_ERROR,
>    NM_MANAGER_ERROR_FAILED,
>    "Could not write " _PATH_RESCONF ":
> %s\n",
>    g_strerror (errno));
> + return FALSE;
>   }
>  
> - g_free (searches_str);
> - g_free (nameservers_str);
> - g_free (options_str);
> -
> - return retval;
> + return TRUE;
>  }
>  
>  static SpawnResult
> @@ -474,10 +463,11 @@ dispatch_resolvconf (NMDnsManager *self,
>   char **options,
>   GError **error)
>  {
> - char *cmd;
> + gs_free char *cmd = NULL;
>   FILE *f;
> - gboolean retval = FALSE;
> + gboolean success = FALSE;
>   int errnosv, err;
> + GError *local = NULL;
>  
>   if (!g_file_test (RESOLVCONF_PATH,
> G_FILE_TEST_IS_EXECUTABLE)) {
>   g_set_error_literal (error,
> @@ -487,39 +477,45 @@ dispatch_resolvconf (NMDnsManager *self,
>   return SR_NOTFOUND;
>   }
>  
> - if (searches || nameservers) {
> - cmd = g_strconcat (RESOLVCONF_PATH, " -a ",
> "NetworkManager", NULL);
> - _LOGI ("Writing DNS information to %s",
> RESOLVCONF_PATH);
> - if ((f = popen (cmd, "w")) == NULL)
> - g_set_error (error,
> -  NM_MANAGER_ERROR,
> -  NM_MANAGER_ERROR_FAILED,
> -  "Could not write to %s: %s\n",
> -  RESOLVCONF_PATH,
> -  g_strerror (errno));
> - else {
> - retval = write_resolv_conf (f, searches,
> nameservers, options, error);
> - err = pclose (f);
> - if (err < 0) {
> - errnosv = errno;
> - g_set_error (error, G_IO_ERROR,
> g_io_error_from_errno (errnosv),
> -  "Failed to close pipe
> to resolvconf: %d", errnosv);
> - retval = FALSE;
> - } else if (err > 0) {
> - _LOGW ("resolvconf failed with
> status 

Re: Problems with gobi 4000 connecting via QMI

2016-01-20 Thread Harald Jung

Hi,

when another SIM is used, the messages are  "user request" oder "none", 
nm-applet gives a messages
Creating object path 
'/org/freedesktop/NetworkManager/ActiveConnection/1" failed in nm-glib.

But I have no logfile from that test.
Anyway the connection was tried with the installed Windows and it worked 
with any SIM.



Harald

Am 06.01.2016 um 17:14 schrieb Dan Williams:

On Wed, 2016-01-06 at 17:11 +0100, Harald Jung wrote:

Hi Dan,

yeah the sim was tested with a mobile phone and in another notebook.
The SIM also works from the windows installation on the notebook.
ModemManager is version 1.4.10

Do other SIMs work in the same modem?

Dan


Harald

Am 06.01.2016 um 16:57 schrieb Dan Williams:

On Wed, 2016-01-06 at 16:01 +0100, Harald Jung wrote:

Hi,

the "HP lt4112 Gobi 4G Module" can't establish a network
connection.
The device is recognozied by the system, but the IP connection
fails.

Details and logs can be found here: http://www.hjit.de/lt4112.txt


What version of ModemManager?  I see a ModemManager errors there
(like
"ModemManager[2018]: (mm-broadband-modem
-qmi.c:1238):dms_get_ids_ready:
code should not be reached")  but those are recovered.

In any case, your SIM is not provisioned for the operator:
'Couldn't
get MSISDN: QMI protocol error (16): 'NotProvisioned''

Does the SIM work in a different device?

Dan
___
ModemManager-devel mailing list
modemmanager-de...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

!DSPAM:416,568d3d6423792141272438!


___
networkmanager-list mailing list
networkmanager-list@gnome.org
https://mail.gnome.org/mailman/listinfo/networkmanager-list