#include <config.h>
#endif
-#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/stat.h>
#include <connman/plugin.h>
#include <connman/driver.h>
const char *nameserver = NULL;
struct connman_element *internet;
gchar *cmd;
- int err;
+ int fd, len, err;
DBG("element %p name %s", element, element->name);
if (nameserver == NULL)
return -EINVAL;
- cmd = g_strdup_printf("echo \"nameserver %s\" > /etc/resolv.conf",
- nameserver);
+ fd = open("/etc/resolv.conf", O_RDWR | O_CREAT,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (fd < 0)
+ return errno;
- DBG("%s", cmd);
+ err = ftruncate(fd, 0);
- err = system(cmd);
+ cmd = g_strdup_printf("nameserver %s\n", nameserver);
+
+ len = write(fd, cmd, strlen(cmd));
g_free(cmd);
+ close(fd);
+
internet = connman_element_create();
internet->type = CONNMAN_ELEMENT_TYPE_INTERNET;