backends: add a function reading systemwide IPv6 Privacy Extensions configuration

It is distro-specific, but mostly it's net.ipv6.conf.default.use_tempaddr
in /etc/sysctl.conf
This commit is contained in:
Jiří Klimeš 2012-02-16 12:20:37 +01:00
parent 88dc641e6e
commit 96378dfa82
15 changed files with 125 additions and 14 deletions

View file

@ -28,7 +28,7 @@
*
* (C) Copyright 2004 Tom Parker
* (C) Copyright 2004 Matthew Garrett
* (C) Copyright 2004 Red Hat, Inc.
* (C) Copyright 2004 - 2012 Red Hat, Inc.
*/
#ifdef HAVE_CONFIG_H
@ -53,3 +53,8 @@ void nm_backend_update_dns (void)
nm_spawn_process ("/etc/rc.d/nscd restart");
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}

View file

@ -21,7 +21,7 @@
*
* (C) Copyright 2004 Tom Parker
* (C) Copyright 2004 Matthew Garrett
* (C) Copyright 2004 Red Hat, Inc.
* (C) Copyright 2004 - 2012 Red Hat, Inc.
*/
#ifdef HAVE_CONFIG_H
@ -50,3 +50,8 @@ void nm_backend_update_dns (void)
}
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}

View file

@ -18,7 +18,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2004 Red Hat, Inc.
* (C) Copyright 2004 - 2012 Red Hat, Inc.
* (C) Copyright 2004 Dan Willemsen
* (C) Copyright 2004 Robert Paskowitz
*/
@ -47,3 +47,8 @@ void nm_backend_update_dns (void)
}
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}

View file

@ -36,3 +36,8 @@ void nm_backend_update_dns (void)
/* I'm not running nscd */
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}

View file

@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2004 - 2010 Red Hat, Inc.
* (C) Copyright 2004 - 2012 Red Hat, Inc.
* (C) Copyright 2006 Timothee Lecomte <timothee.lecomte@ens.fr>
*/
@ -113,6 +113,51 @@ void nm_generic_update_dns (void)
{
}
/*
* nm_generic_ipv6_use_tempaddr
*
* Get net.ipv6.conf.default.use_tempaddr value from /etc/sysctl.conf or
* /lib/sysctl.d/sysctl.conf
*
*/
int nm_generic_ipv6_use_tempaddr (void)
{
char *contents = NULL;
gsize len = 0;
const char *group_name = "[forged_group]\n";
char *sysctl_data = NULL;
GKeyFile *keyfile;
GError *error = NULL;
int tmp, ret = -1;
/* Read file contents to a string. */
if (!g_file_get_contents ("/etc/sysctl.conf", &contents, &len, NULL))
if (!g_file_get_contents ("/lib/sysctl.d/sysctl.conf", &contents, &len, NULL))
return -1;
/* Prepend a group so that we can use GKeyFile parser. */
sysctl_data = g_strdup_printf ("%s%s", group_name, contents);
keyfile = g_key_file_new ();
if (keyfile == NULL)
goto done;
if (!g_key_file_load_from_data (keyfile, sysctl_data, len + strlen (group_name), G_KEY_FILE_NONE, NULL))
goto done;
tmp = g_key_file_get_integer (keyfile, "forged_group", "net.ipv6.conf.default.use_tempaddr", &error);
if (error == NULL)
ret = tmp;
done:
g_free (contents);
g_free (sysctl_data);
g_clear_error (&error);
g_key_file_free (keyfile);
return ret;
}
#ifdef TARGET_GENERIC
void nm_backend_enable_loopback (void)
{
@ -123,5 +168,10 @@ void nm_backend_update_dns (void)
{
nm_generic_update_dns ();
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}
#endif

View file

@ -18,7 +18,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2004 - 2011 Red Hat, Inc.
* (C) Copyright 2004 - 2012 Red Hat, Inc.
*/
#ifndef NM_GENERIC_H
@ -28,5 +28,6 @@
void nm_generic_enable_loopback (void);
void nm_generic_update_dns (void);
int nm_generic_ipv6_use_tempaddr (void);
#endif /* NM_GENERIC_H */

View file

@ -18,7 +18,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2004 Red Hat, Inc.
* (C) Copyright 2004 - 2012 Red Hat, Inc.
* (C) Copyright 2004 Dan Willemsen
* (C) Copyright 2004 Robert Paskowitz
*/
@ -75,3 +75,8 @@ void nm_backend_update_dns (void)
}
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}

View file

@ -21,7 +21,7 @@
*
* (C) Copyright 2004 Tom Parker
* (C) Copyright 2004 Matthew Garrett
* (C) Copyright 2004 Red Hat, Inc.
* (C) Copyright 2004 - 2012 Red Hat, Inc.
*/
#ifdef HAVE_CONFIG_H
@ -46,4 +46,8 @@ void nm_backend_update_dns (void)
}
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}

View file

@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2004 Red Hat, Inc.
* (C) Copyright 2004 - 2012 Red Hat, Inc.
* (C) Copyright 2008 Per Øyvind Karlsen
*/
@ -42,3 +42,8 @@ void nm_backend_update_dns (void)
}
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}

View file

@ -18,7 +18,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2004 Red Hat, Inc.
* (C) Copyright 2004 - 2012 Red Hat, Inc.
* (C) Copyright 2006 Jürg Billeter
*/
@ -44,3 +44,8 @@ void nm_backend_update_dns (void)
}
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}

View file

@ -16,7 +16,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2004 RedHat, Inc.
* (C) Copyright 2004 - 2012 RedHat, Inc.
* (C) Copyright 2009 TUBITAK/UEKAE
*/
@ -35,3 +35,8 @@ void nm_backend_update_dns (void)
{
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}

View file

@ -16,7 +16,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2004 - 2011 Red Hat, Inc.
* (C) Copyright 2004 - 2012 Red Hat, Inc.
*/
#ifdef HAVE_CONFIG_H
@ -40,3 +40,8 @@ void nm_backend_update_dns (void)
}
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}

View file

@ -16,7 +16,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2004 RedHat, Inc.
* (C) Copyright 2004 - 2012 RedHat, Inc.
* (C) Copyright 2004 Narayan Newton
*/
@ -35,3 +35,8 @@ void nm_backend_update_dns (void)
{
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}

View file

@ -19,7 +19,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* (C) Copyright 2004 Red Hat, Inc.
* (C) Copyright 2004 - 2012 Red Hat, Inc.
* (C) Copyright 2005-2006 SuSE GmbH
*/
@ -45,3 +45,8 @@ void nm_backend_update_dns (void)
}
}
int nm_backend_ipv6_use_tempaddr (void)
{
return nm_generic_ipv6_use_tempaddr ();
}

View file

@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2011 Red Hat, Inc.
* Copyright (C) 2011 - 2012 Red Hat, Inc.
*/
#ifndef NM_BACKEND_H
@ -25,5 +25,6 @@
void nm_backend_enable_loopback (void);
void nm_backend_update_dns (void);
int nm_backend_ipv6_use_tempaddr (void);
#endif /* NM_BACKEND_H */