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
33 #define CONNMAN_API_SUBJECT_TO_CHANGE
34 #include <connman/plugin.h>
35 #include <connman/resolver.h>
36 #include <connman/log.h>
40 static int resolvfile_append(const char *interface, const char *domain,
46 DBG("server %s", server);
48 fd = open("/etc/resolv.conf", O_RDWR | O_CREAT,
49 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
53 err = ftruncate(fd, 0);
55 cmd = g_strdup_printf("nameserver %s\n", server);
57 len = write(fd, cmd, strlen(cmd));
66 static int resolvfile_remove(const char *interface, const char *domain,
69 DBG("server %s", server);
74 static struct connman_resolver resolvfile_resolver = {
76 .priority = CONNMAN_RESOLVER_PRIORITY_LOW,
77 .append = resolvfile_append,
78 .remove = resolvfile_remove,
81 static int resolvfile_init(void)
83 return connman_resolver_register(&resolvfile_resolver);
86 static void resolvfile_exit(void)
88 connman_resolver_unregister(&resolvfile_resolver);
91 CONNMAN_PLUGIN_DEFINE(resolvfile, "Name resolver plugin", VERSION,
92 resolvfile_init, resolvfile_exit)