Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=frugalwareutils.git;a=commitdiff;h=17682ec030163cf00919f39215cc65d02a7b5ce4

commit 17682ec030163cf00919f39215cc65d02a7b5ce4
Author: Miklos Vajna <vmik...@frugalware.org>
Date:   Sat May 21 21:51:06 2011 +0200

netconfig: detach child processes from the user's cgroup

diff --git a/libfwnetconfig/libfwnetconfig.c b/libfwnetconfig/libfwnetconfig.c
index 5b49ef5..843ca0d 100644
--- a/libfwnetconfig/libfwnetconfig.c
+++ b/libfwnetconfig/libfwnetconfig.c
@@ -824,6 +824,22 @@ static char *netaddr(char *ip, char *nm)
return(g_strdup_printf("%d.%d.%d.%d", na[0], na[1], na[2], na[3]));
}

+/** Puts the current process to the cgroup of netconfig
+ * @return 1 on failure, 0 on success
+ */
+int fwnet_cginit(void)
+{
+       FILE *fp;
+
+       mkdir(FWNET_CGPATH, 0755);
+       fp = fopen(FWNET_CGPATH "/tasks", "w");
+       if (!fp)
+               return 1;
+       fprintf(fp, "%d\n", getpid());
+       fclose(fp);
+       return 0;
+}
+
/** Dumps a profile to a text file.
* @param profile the profile to dump
* @param host the hostname (optional)
diff --git a/libfwnetconfig/libfwnetconfig.h b/libfwnetconfig/libfwnetconfig.h
index 6d7e171..4cf841c 100644
--- a/libfwnetconfig/libfwnetconfig.h
+++ b/libfwnetconfig/libfwnetconfig.h
@@ -35,6 +35,8 @@
#define FWNET_PATH "/etc/sysconfig/network"
#define FWNET_LOCK "/var/run/netconfig"
#define FWNET_IFPATH "/sys/class/net"
+#define FWNET_CGPATH "/sys/fs/cgroup/systemd/system/netconfig.service"
+

typedef struct __fwnet_interface_t {
char name[IF_NAMESIZE+1];
@@ -79,6 +81,7 @@ int fwnet_setlastprofile(char* str);
int fwnet_loup(void);
int fwnet_lodown(void);
int fwnet_is_wireless_device(char *dev);
+int fwnet_cginit(void);
int fwnet_writeconfig(fwnet_profile_t *profile, char *host);
int fwnet_ifdesc(const char *iface, char *desc, int size);

diff --git a/netconfig/netconfig.c b/netconfig/netconfig.c
index dd951c0..d92e16f 100644
--- a/netconfig/netconfig.c
+++ b/netconfig/netconfig.c
@@ -283,6 +283,7 @@ int run(int argc, char **argv)
}
}
fwutil_i18ninit(__FILE__);
+       fwnet_cginit();
if(nco_usage)
{
usage();
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to