Hi,

Why don't you use the dispatcher? I'm not sure which is the correct
approach. 
To use the dispatcher you have to send more information to it like
nameservers. I didn't have time until now to make a nice support for
it. See
http://mail.gnome.org/archives/networkmanager-list/2008-May/msg00003.html
for more information on my idea. I'll try to make something better soon.

On Tue, 8 Jul 2008 12:14:01 +0200
Alexander Sack <[EMAIL PROTECTED]> wrote:

> On Mon, Jul 07, 2008 at 03:51:22PM -0400, Dan Williams wrote:
> > On Mon, 2008-07-07 at 20:26 +0200, Michael Biebl wrote:
> > > 
> > > 2.) If resolvconf is installed, change NM to not
> > > manage /etc/resolv.conf itself, but only pass the dns information
> > > to resolvconf (which then will write /etc/resolv.conf).
> > > The downside is, that resolvconf might have own dns
> > > configuration. So the resulting /etc/resolv.conf might differ
> > > from what NM expects it to be.
> > > 
> > > I'm leaning towards 2.), but I'm open to other suggestions and
> > > comments.
> > 
> > I'm fine with #2 also; I'll take patches for this upstream.
> > 
> > But I have one question that I pointed out earlier.  If you install
> > resolvconf, does that _necessarily_ imply that it is turned on?
> > i.e. I can install apache, but I don't actually have to run apache
> > even if it's installed.  Does resolvconf have an on/off switch
> > somewhere, or do you have to uninstall it to turn it off?
> 
> 
> Below a first patch introducing basic resolvconf support. I decided to
> not add/delete nameserver entries for individual NMIP4Config's, but
> instead just add/delete _one_ config named "NetworkManager", which is
> based on the merged NMIP4Config that NM uses in rewrite_resolv_conf.
> 
> The code will fall back to normal resolv.conf rewriting if
> resolvconf fails. Further I guarded the new code by #ifdef
> WITH_RESOLVCONF. However, I didnt add a configure flag.
> 
> Comments?
> 
> 
> --- src/named-manager/nm-named-manager.c      2008-06-26 19:33:13
> +0000 +++ src/named-manager/nm-named-manager.c        2008-07-08
> 10:07:08 +0000 @@ -29,25 +29,30 @@
>  #include <glib.h>
>  
>  #include <glib/gi18n.h>
>  
>  #include "nm-named-manager.h"
>  #include "nm-ip4-config.h"
>  #include "nm-utils.h"
>  #include "NetworkManagerSystem.h"
> +#include "NetworkManagerUtils.h"
>  
>  #ifdef HAVE_SELINUX
>  #include <selinux/selinux.h>
>  #endif
>  
>  #ifndef RESOLV_CONF
>  #define RESOLV_CONF "/etc/resolv.conf"
>  #endif
>  
> +#ifndef RESOLV_CONF_PATH
> +#define RESOLV_CONF_PATH "/sbin/resolvconf"
> +#endif
> +
>  G_DEFINE_TYPE(NMNamedManager, nm_named_manager, G_TYPE_OBJECT)
>  
>  #define NM_NAMED_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE
> ((o), \ NM_TYPE_NAMED_MANAGER, \
>                                           NMNamedManagerPrivate))
>  
>  
>  struct NMNamedManagerPrivate {
> @@ -291,23 +296,51 @@ rewrite_resolv_conf (NMNamedManager *mgr
>                                    g_strerror (errno));
>               }
>       }
>  
>       g_free (domain);
>       g_free (searches);
>  
>       if (*error == NULL) {
> -             if (rename (tmp_resolv_conf, RESOLV_CONF) < 0) {
> +             gboolean do_rewrite = TRUE;
> +
> +#ifdef WITH_RESOLVCONF
> +             gint exit_code;
> +             char *cmd;
> +
> +             // delete NM resolvconf
> +             nm_spawn_process(RESOLV_CONF_PATH " -d
> NetworkManager");
> +             cmd = g_strconcat (RESOLV_CONF_PATH " -a nm1 ",
> +                                      tmp_resolv_conf,
> +                                      NULL);
> +             if(cmd)
> +               exit_code = nm_spawn_process(cmd);
> +             else
> +               exit_code = 1;
> +
> +             if(exit_code)
> +                     g_warning("%s failed (%d). "
> +                               "updating /etc/resolv.conf
> directly.",
> +                                       cmd,
> +                               exit_code);
> +             else
> +                     do_rewrite = FALSE;
> +             g_free(cmd);
> +
> +#else        /* WITH_RESOLVCONF */
> +             do_rewrite = TRUE;
> +#endif
> +             if (do_rewrite && rename (tmp_resolv_conf,
> RESOLV_CONF) < 0) { g_set_error (error,
>                                    NM_NAMED_MANAGER_ERROR,
>                                    NM_NAMED_MANAGER_ERROR_SYSTEM,
>                                    "Could not replace "
> RESOLV_CONF ": %s\n", g_strerror (errno));
> -             } else {
> +             } else if (do_rewrite) {
>                       nm_system_update_dns ();
>               }
>       }
>  
>       return *error ? FALSE : TRUE;
>  }
>  
>  gboolean
> 
> 
> 
> 
> 
> 
>  - Alexander
> 
> _______________________________________________
> NetworkManager-list mailing list
> [email protected]
> http://mail.gnome.org/mailman/listinfo/networkmanager-list
_______________________________________________
NetworkManager-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to