5 * Copyright (C) 2007-2008 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #include <connman/plugin.h>
31 #include <connman/resolver.h>
32 #include <connman/log.h>
36 #define RESOLVCONF "/sbin/resolvconf"
38 static int resolvconf_append(const char *interface, const char *domain,
44 DBG("interface %s server %s", interface, server);
46 if (access(RESOLVCONF, X_OK) < 0)
49 cmd = g_strdup_printf("echo \"nameserver %s\" | %s -a %s",
50 server, RESOLVCONF, interface);
62 static int resolvconf_remove(const char *interface, const char *domain,
68 DBG("interface %s server %s", interface, server);
70 cmd = g_strdup_printf("%s -d %s", RESOLVCONF, interface);
82 static struct connman_resolver resolvconf_resolver = {
84 .priority = CONNMAN_RESOLVER_PRIORITY_DEFAULT,
85 .append = resolvconf_append,
86 .remove = resolvconf_remove,
89 static int resolvconf_init(void)
91 return connman_resolver_register(&resolvconf_resolver);
94 static void resolvconf_exit(void)
96 connman_resolver_unregister(&resolvconf_resolver);
99 CONNMAN_PLUGIN_DEFINE(resolvconf, "Name resolver plugin", VERSION,
100 resolvconf_init, resolvconf_exit)