Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Fedora Advisory Board (http://www.linux-archive.org/fedora-advisory-board/)
-   -   Generate connection UUID in inital ifcfg files created by anaconda (#705328) (http://www.linux-archive.org/fedora-advisory-board/633444-generate-connection-uuid-inital-ifcfg-files-created-anaconda-705328-a.html)

David Cantrell 02-15-2012 05:35 PM

Generate connection UUID in inital ifcfg files created by anaconda (#705328)
 
Ack with one minor nit. If you're going to use a char *, use free(). If
you are going to use g_free(), use a gchar *. Yes, glib falls through to
free() for now, but there's nothing that says it has to. The APIs are
separate for a reason. glib could up and change to a new allocator at
some point and that would be an unwelcome surprise.

On Wed, Feb 15, 2012 at 02:11:16PM +0100, Radek Vykydal wrote:
> Prevents using the same UUIDs for multiple installations when NM creates
> UUID for already existing ifcfg file based on hashing of configuration
> file name.
>
> Resolves: rhbz#705328
> ---
> loader/net.c | 9 +++++++++
> 1 files changed, 9 insertions(+), 0 deletions(-)
>
> diff --git a/loader/net.c b/loader/net.c
> index d755eae..0b0d16d 100644
> --- a/loader/net.c
> +++ b/loader/net.c
> @@ -40,6 +40,7 @@
> #include <glib.h>
> #include <NetworkManager.h>
> #include <nm-client.h>
> +#include <nm-utils.h>
>
> #include "../isys/isys.h"
> #include "../isys/ethtool.h"
> @@ -1219,6 +1220,7 @@ int writeDisabledIfcfgFile(char *device) {
> char *ofile = NULL;
> char *nfile = NULL;
> FILE *fp = NULL;
> + char *uuid = NULL;
>
> checked_asprintf(&ofile, "%s/.ifcfg-%s",
> NETWORK_SCRIPTS_PATH,
> @@ -1234,6 +1236,9 @@ int writeDisabledIfcfgFile(char *device) {
>
> fprintf(fp, "DEVICE=%s
", device);
> fprintf(fp, "HWADDR=%s
", iface_mac2str(device));
> + uuid = nm_utils_uuid_generate();
> + fprintf(fp, "UUID=%s
", uuid);
> + g_free(uuid);
> fprintf(fp, "ONBOOT=no
");
> fprintf(fp, "NM_CONTROLLED=no
");
> /* default for network service, NM assumes it */
> @@ -1275,6 +1280,7 @@ int writeEnabledNetInfo(iface_t *iface) {
> char *ofile = NULL;
> char *nfile = NULL;
> struct utsname kv;
> + char *uuid = NULL;
>
> memset(&buf, '', sizeof(buf));
>
> @@ -1336,6 +1342,9 @@ int writeEnabledNetInfo(iface_t *iface) {
> #if !defined(__s390__) && !defined(__s390x__)
> fprintf(fp, "HWADDR=%s
", iface_mac2str(iface->device));
> #endif
> + uuid = nm_utils_uuid_generate();
> + fprintf(fp, "UUID=%s
", uuid);
> + g_free(uuid);
> fprintf(fp, "ONBOOT=yes
");
> char *str_type = netArpTypeStr(iface);
> if (str_type) fprintf(fp, "TYPE=%s
", str_type);
> --
> 1.7.4
>
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@redhat.com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

--
David Cantrell <dcantrell@redhat.com>
Supervisor, Installer Engineering Team
Red Hat, Inc. | Westford, MA | EST5EDT

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

Radek Vykydal 02-16-2012 06:46 AM

Generate connection UUID in inital ifcfg files created by anaconda (#705328)
 
On 02/15/2012 07:35 PM, David Cantrell wrote:

Ack with one minor nit. If you're going to use a char *, use free(). If
you are going to use g_free(), use a gchar *. Yes, glib falls through to
free() for now, but there's nothing that says it has to. The APIs are
separate for a reason. glib could up and change to a new allocator at
some point and that would be an unwelcome surprise.


nm-utils library reference says use g_free():
http://developer.gnome.org/libnm-util/unstable/libnm-util-nm-utils.html#nm-utils-uuid-generate

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

David Cantrell 02-16-2012 01:10 PM

Generate connection UUID in inital ifcfg files created by anaconda (#705328)
 
On Thu, Feb 16, 2012 at 08:46:59AM +0100, Radek Vykydal wrote:
> On 02/15/2012 07:35 PM, David Cantrell wrote:
> >Ack with one minor nit. If you're going to use a char *, use free(). If
> >you are going to use g_free(), use a gchar *. Yes, glib falls through to
> >free() for now, but there's nothing that says it has to. The APIs are
> >separate for a reason. glib could up and change to a new allocator at
> >some point and that would be an unwelcome surprise.
>
> nm-utils library reference says use g_free():
> http://developer.gnome.org/libnm-util/unstable/libnm-util-nm-utils.html#nm-utils-uuid-generate

Yeah, alright.

--
David Cantrell <dcantrell@redhat.com>
Supervisor, Installer Engineering Team
Red Hat, Inc. | Westford, MA | EST5EDT

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


All times are GMT. The time now is 07:24 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.