Compare commits

...
Sign in to create a new pull request.

3 commits

Author SHA1 Message Date
Michal Hlavinka
58fe4af631 enforce usage of our c(xx)flags 2012-06-19 15:14:57 +02:00
Michal Hlavinka
57ab21bc3e fix debuginfo 2012-06-19 13:25:15 +02:00
Michal Hlavinka
5a2c4255c1 fix generation of MAC address based uuids (#829532),
patch by Philip Prindeville
2012-06-19 12:13:00 +02:00
3 changed files with 151 additions and 3 deletions

116
uuid-1.6.2-hwaddr.patch Normal file
View file

@ -0,0 +1,116 @@
diff -urN uuid-1.6.2/configure uuid-1.6.2/configure
--- uuid-1.6.2/configure 2008-07-04 15:43:09.000000000 -0600
+++ uuid-1.6.2/configure 2012-06-06 19:19:41.659880386 -0600
@@ -14208,7 +14208,7 @@
-for ac_header in netdb.h ifaddrs.h net/if.h net/if_dl.h net/if_arp.h netinet/in.h arpa/inet.h
+for ac_header in netdb.h ifaddrs.h net/if.h net/if_dl.h net/if_arp.h netinet/in.h arpa/inet.h netpacket/packet.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5
diff -urN uuid-1.6.2/uuid.c uuid-1.6.2/uuid.c
--- uuid-1.6.2/uuid.c 2008-03-07 03:49:59.000000000 -0700
+++ uuid-1.6.2/uuid.c 2012-06-06 15:50:30.060881473 -0600
@@ -72,6 +72,8 @@
/* IEEE 802 MAC address octet length */
#define IEEE_MAC_OCTETS 6
+static unsigned char mac_unset[IEEE_MAC_OCTETS] = {BM_OCTET(1,0,0,0,0,0,0,0), 0x00, 0x00, 0x00, 0x00, 0x00};
+
/* UUID binary representation according to UUID standards */
typedef struct {
uuid_uint32_t time_low; /* bits 0-31 of time field */
@@ -967,7 +969,7 @@
* GENERATE NODE
*/
- if ((mode & UUID_MAKE_MC) || (uuid->mac[0] & BM_OCTET(1,0,0,0,0,0,0,0))) {
+ if ((mode & UUID_MAKE_MC) || !memcmp(uuid->mac, mac_unset, IEEE_MAC_OCTETS)) {
/* generate random IEEE 802 local multicast MAC address */
if (prng_data(uuid->prng, (void *)&(uuid->obj.node), sizeof(uuid->obj.node)) != PRNG_RC_OK)
return UUID_RC_INT;
diff -urN uuid-1.6.2/uuid_mac.c uuid-1.6.2/uuid_mac.c
--- uuid-1.6.2/uuid_mac.c 2008-03-07 03:49:59.000000000 -0700
+++ uuid-1.6.2/uuid_mac.c 2012-06-06 19:30:49.050879930 -0600
@@ -76,6 +76,9 @@
#ifdef HAVE_IFADDRS_H
#include <ifaddrs.h>
#endif
+#ifdef HAVE_NETPACKET_PACKET_H
+#include <netpacket/packet.h>
+#endif
/* own headers (part (1/2) */
#include "uuid_mac.h"
@@ -87,6 +90,10 @@
#define TRUE (/*lint -save -e506*/ !FALSE /*lint -restore*/)
#endif
+#if !defined(min)
+#define min(a,b) ((a) < (b) ? (a) : (b))
+#endif
+
/* return the Media Access Control (MAC) address of
the FIRST network interface card (NIC) */
int mac_address(unsigned char *data_ptr, size_t data_len)
@@ -95,28 +102,41 @@
if (data_ptr == NULL || data_len < MAC_LEN)
return FALSE;
-#if defined(HAVE_IFADDRS_H) && defined(HAVE_NET_IF_DL_H) && defined(HAVE_GETIFADDRS)
+#if defined(HAVE_IFADDRS_H) && (defined(HAVE_NET_IF_DL_H) || defined(HAVE_NETPACKET_PACKET_H)) && defined(HAVE_GETIFADDRS)
/* use getifaddrs(3) on BSD class platforms (xxxBSD, MacOS X, etc) */
{
struct ifaddrs *ifap;
struct ifaddrs *ifap_head;
+#if defined(HAVE_NET_IF_DL_H)
const struct sockaddr_dl *sdl;
unsigned char *ucp;
- int i;
+#else
+ const struct sockaddr_ll *sll;
+#endif
if (getifaddrs(&ifap_head) < 0)
return FALSE;
for (ifap = ifap_head; ifap != NULL; ifap = ifap->ifa_next) {
+#if defined(HAVE_NET_IF_DL_H)
if (ifap->ifa_addr != NULL && ifap->ifa_addr->sa_family == AF_LINK) {
sdl = (const struct sockaddr_dl *)(void *)ifap->ifa_addr;
ucp = (unsigned char *)(sdl->sdl_data + sdl->sdl_nlen);
if (sdl->sdl_alen > 0) {
- for (i = 0; i < MAC_LEN && i < sdl->sdl_alen; i++, ucp++)
- data_ptr[i] = (unsigned char)(*ucp & 0xff);
+ memcpy(data_ptr, ucp, min(sdl->sdl_alen, MAC_LEN));
freeifaddrs(ifap_head);
return TRUE;
}
}
+#else
+ if (ifap->ifa_addr != NULL && ifap->ifa_addr->sa_family == AF_PACKET) {
+ sll = (const struct sockaddr_ll *)(void *)ifap->ifa_addr;
+ if (sll->sll_hatype == ARPHRD_ETHER) {
+ memcpy(data_ptr, sll->sll_addr, min(sll->sll_halen, MAC_LEN));
+ freeifaddrs(ifap_head);
+ return TRUE;
+ }
+ }
+#endif
}
freeifaddrs(ifap_head);
}
diff -urN uuid-1.6.2/config.h.in uuid-1.6.2/config.h.in
--- uuid-1.6.2/config.h.in 2008-07-04 15:43:10.000000000 -0600
+++ uuid-1.6.2/config.h.in 2012-06-06 21:59:03.370227352 -0600
@@ -75,6 +75,9 @@
/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
+/* Define to 1 if you have the <netpacket/packet.h> header file. */
+#undef HAVE_NETPACKET_PACKET_H
+
/* Define to 1 if you have the <net/if_arp.h> header file. */
#undef HAVE_NET_IF_ARP_H

12
uuid-1.6.2-nostrip.patch Normal file
View file

@ -0,0 +1,12 @@
diff -up uuid-1.6.2/Makefile.in.nostrip uuid-1.6.2/Makefile.in
--- uuid-1.6.2/Makefile.in.nostrip 2012-06-19 12:53:47.888028956 +0200
+++ uuid-1.6.2/Makefile.in 2012-06-19 12:53:47.913029142 +0200
@@ -253,7 +253,7 @@ install:
-@if [ ".$(WITH_CXX)" = .yes ]; then \
$(LIBTOOL) --mode=install $(SHTOOL) install -c -m 644 $(CXX_NAME) $(DESTDIR)$(libdir)/; \
fi
- @$(LIBTOOL) --mode=install $(SHTOOL) install -c -s -m 755 uuid $(DESTDIR)$(bindir)/
+ @$(LIBTOOL) --mode=install $(SHTOOL) install -c -m 755 uuid $(DESTDIR)$(bindir)/
$(SHTOOL) install -c -m 644 $(S)/uuid.1 $(DESTDIR)$(mandir)/man1/
-@if [ ".$(WITH_PERL)" = .yes ]; then \
(cd $(S)/perl && $(MAKE) $(MFLAGS) install DESTDIR=$(DESTDIR)); \

View file

@ -3,7 +3,7 @@
Name: uuid
Version: 1.6.2
Release: 6%{?dist}
Release: 9%{?dist}
Summary: Universally Unique Identifier library
License: MIT
Group: System Environment/Libraries
@ -12,6 +12,12 @@ Source0: ftp://ftp.ossp.org/pkg/lib/uuid/uuid-%{version}.tar.gz
Patch0: uuid-1.6.1-ossp.patch
Patch1: uuid-1.6.1-mkdir.patch
# rhbz#829532
Patch3: uuid-1.6.2-hwaddr.patch
# do not strip binaries
Patch4: uuid-1.6.2-nostrip.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: libtool
@ -110,6 +116,8 @@ DCE development headers and libraries for OSSP uuid.
%setup -q
%patch0 -p1
%patch1 -p1
%patch3 -p1 -b .hwaddr
%patch4 -p1 -b .nostrip
%build
# Build the library.
@ -118,6 +126,8 @@ export DCE_NAME=libossp-uuid_dce.la
export CXX_NAME=libossp-uuid++.la
export PHP_NAME=$(pwd)/php/modules/ossp-uuid.so
export PGSQL_NAME=$(pwd)/pgsql/libossp-uuid.so
export CFLAGS="$RPM_OPT_FLAGS"
export CXXFLAGS="$RPM_OPT_FLAGS"
%configure \
--disable-static \
--without-perl \
@ -126,7 +136,7 @@ export PGSQL_NAME=$(pwd)/pgsql/libossp-uuid.so
--with-cxx \
--with-pgsql
make LIBTOOL=/usr/bin/libtool %{?_smp_mflags}
make LIBTOOL=/usr/bin/libtool CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" %{?_smp_mflags}
# Build the Perl module.
pushd perl
@ -141,7 +151,7 @@ export PHP_RPATH=no
phpize
CFLAGS="$RPM_OPT_FLAGS -I.. -L.. -L../.libs"
%configure --enable-uuid
make %{?_smp_mflags}
make CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS" %{?_smp_mflags}
popd
%install
@ -258,6 +268,16 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/libossp-uuid_dce.so
%changelog
* Tue Jun 19 2012 Michal Hlavinka <mhlavink@redhat.com> - 1.6.2-9
- enforce usage of our c(xx)flags
* Tue Jun 19 2012 Michal Hlavinka <mhlavink@redhat.com> - 1.6.2-8
- fix debuginfo
* Tue Jun 19 2012 Michal Hlavinka <mhlavink@redhat.com> - 1.6.2-7
- fix generation of MAC address based uuids (#829532),
patch by Philip Prindeville
* Fri Jun 17 2011 Marcela Mašláňová <mmaslano@redhat.com> - 1.6.2-6
- Perl mass rebuild