lists.arthurdejong.org
RSS feed

nss-pam-ldapd branch master updated. 0.9.7-12-gebc0f76

[Date Prev][Date Next] [Thread Prev][Thread Next]

nss-pam-ldapd branch master updated. 0.9.7-12-gebc0f76



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "nss-pam-ldapd".

The branch, master has been updated
       via  ebc0f7673000e8681ea3d4d7a81bf2cd8c3be509 (commit)
       via  be2651072b8cd77fc335ad8248512099f7d858eb (commit)
      from  becc883693df2ad812cfd7ba4a5dcbd1d1a8fa3f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://arthurdejong.org/git/nss-pam-ldapd/commit/?id=ebc0f7673000e8681ea3d4d7a81bf2cd8c3be509

commit ebc0f7673000e8681ea3d4d7a81bf2cd8c3be509
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Tue Jun 13 22:17:35 2017 +0200

    Switch to HTTPS URLs

diff --git a/README b/README
index f546701..7b25d11 100644
--- a/README
+++ b/README
@@ -11,11 +11,11 @@
    Howard Chu for the OpenLDAP nssov module was integrated. Solaris
    compatibility was developed by Ted C. Cheng of Symas Corporation.
 
-   http://arthurdejong.org/nss-pam-ldapd/
+   https://arthurdejong.org/nss-pam-ldapd/
 
    Copyright (C) 1997-2006 Luke Howard
    Copyright (C) 2006-2007 West Consulting
-   Copyright (C) 2006-2016 Arthur de Jong
+   Copyright (C) 2006-2017 Arthur de Jong
    Copyright (C) 2009 Howard Chu
    Copyright (C) 2010 Symas Corporation
 
diff --git a/configure.ac b/configure.ac
index 63f2f19..34d42d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,7 +35,7 @@ configure.ac file for more details.])
 AC_INIT([nss-pam-ldapd],
         [0.9.7],
         [nss-pam-ldapd-users@lists.arthurdejong.org],,
-        [http://arthurdejong.org/nss-pam-ldapd/])
+        [https://arthurdejong.org/nss-pam-ldapd/])
 RELEASE_MONTH="Aug 2016"
 AC_SUBST(RELEASE_MONTH)
 AC_CONFIG_SRCDIR([nslcd.h])
diff --git a/tests/test.ldif b/tests/test.ldif
index 08985a2..0c6c377 100644
--- a/tests/test.ldif
+++ b/tests/test.ldif
@@ -40111,7 +40111,7 @@ shadowInactive: 2
 uidNumber: 1000
 title:: c3V4AAA=
 title: su
-labeledURI: http://arthurdejong.org/ Arthur's homepage
+labeledURI: https://arthurdejong.org/ Arthur's homepage
 mail: arthur@arthurdejong.org
 objectClass: top
 objectClass: posixAccount

https://arthurdejong.org/git/nss-pam-ldapd/commit/?id=be2651072b8cd77fc335ad8248512099f7d858eb

commit be2651072b8cd77fc335ad8248512099f7d858eb
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Tue Jun 13 21:39:29 2017 +0200

    Query ethernet addresses in compact and long format
    
    This ensures that when querying the address 0:18:8a:54:1a:8b both that
    format and 00:18:8a:54:1a:8b is searched for in LDAP.
    
    This was triggerred by the fact that ether_ntoa() on FreeBSD returns the
    long format while glibc uses the compact format.
    
    Since we are no longer using the libc version of ether_ntoa() we can
    also drop the compatibility implementation of ether_ntoa_r().

diff --git a/compat/ether.c b/compat/ether.c
index 7204b9d..bda1718 100644
--- a/compat/ether.c
+++ b/compat/ether.c
@@ -1,7 +1,7 @@
 /*
    ether.c - useful ethernet functions for systems lacking those
 
-   Copyright (C) 2008, 2009, 2010, 2012 Arthur de Jong
+   Copyright (C) 2008-2017 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -35,18 +35,6 @@
 
 /* these functions are not really reentrant */
 
-#ifndef HAVE_ETHER_NTOA_R
-char *ether_ntoa_r(const struct ether_addr *addr, char *buf)
-{
-  char *tmp;
-  tmp = ether_ntoa(addr);
-  if (tmp == NULL)
-    return NULL;
-  strcpy(buf, tmp);
-  return buf;
-}
-#endif /* not HAVE_ETHER_NTOA_R */
-
 #ifndef HAVE_ETHER_ATON_R
 struct ether_addr *ether_aton_r(const char *asc, struct ether_addr *addr)
 {
diff --git a/compat/ether.h b/compat/ether.h
index 4528517..02f6ff4 100644
--- a/compat/ether.h
+++ b/compat/ether.h
@@ -1,7 +1,7 @@
 /*
    ether.h - ethernet definitions for systems lacking those
 
-   Copyright (C) 2008, 2010, 2011, 2012 Arthur de Jong
+   Copyright (C) 2008-2017 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -37,22 +37,10 @@ struct ether_addr {
 };
 #endif /* not HAVE_STRUCT_ETHER_ADDR */
 
-#ifndef HAVE_ETHER_NTOA_R
-char *ether_ntoa_r(const struct ether_addr *addr, char *buf);
-#endif /* not HAVE_ETHER_NTOA_R */
-
 #ifndef HAVE_ETHER_ATON_R
 struct ether_addr *ether_aton_r(const char *asc, struct ether_addr *addr);
 #endif /* not HAVE_ETHER_ATON_R */
 
-#ifdef HAVE_ETHER_NTOA
-#if !HAVE_DECL_ETHER_NTOA
-/* we define ether_ntoa() here because on some platforms the function is
-   undefined */
-extern char *ether_ntoa(const struct ether_addr *e);
-#endif /* not HAVE_DECL_ETHER_NTOA */
-#endif /* HAVE_ETHER_NTOA */
-
 #ifdef HAVE_ETHER_ATON
 #if !HAVE_DECL_ETHER_ATON
 /* we define ether_aton() here because on some platforms the function is
diff --git a/configure.ac b/configure.ac
index e7a37e4..63f2f19 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@
 #
 # Copyright (C) 2006 Luke Howard
 # Copyright (C) 2006 West Consulting
-# Copyright (C) 2006-2016 Arthur de Jong
+# Copyright (C) 2006-2017 Arthur de Jong
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -720,8 +720,8 @@ then
   AC_REPLACE_FUNCS(getopt_long)
   AC_REPLACE_FUNCS(strndup)
 
-  # replace ether_aton_r() and ether_ntoa_r() if they are not found
-  AC_CHECK_FUNCS(ether_aton_r ether_ntoa_r,, [AC_LIBOBJ(ether)])
+  # replace ether_aton_r() if not found
+  AC_CHECK_FUNCS(ether_aton_r,, [AC_LIBOBJ(ether)])
 
   # check to see if struct sockaddr_storage is defined
   AC_CHECK_TYPE(struct sockaddr_storage,,
diff --git a/nslcd/ether.c b/nslcd/ether.c
index ff61dd2..d790e5e 100644
--- a/nslcd/ether.c
+++ b/nslcd/ether.c
@@ -5,7 +5,7 @@
 
    Copyright (C) 1997-2005 Luke Howard
    Copyright (C) 2006 West Consulting
-   Copyright (C) 2006-2014 Arthur de Jong
+   Copyright (C) 2006-2017 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -78,15 +78,28 @@ static int mkfilter_ether_byname(const char *name,
                     ether_filter, attmap_ether_cn, safename);
 }
 
-static int mkfilter_ether_byether(const char *addrstr,
+static void my_ether_ntoa(const u_int8_t *addr, char *buffer, int compact)
+{
+  int i;
+  for (i = 0; i < 6; i++)
+  {
+    if (i > 0)
+      *buffer++ = ':';
+    buffer += sprintf(buffer, compact ? "%x" : "%02x", addr[i]);
+  }
+  *buffer++ = '\0';
+}
+
+static int mkfilter_ether_byether(const struct ether_addr *addr,
                                   char *buffer, size_t buflen)
 {
-  /* Note: this only works if the address in LDAP has the preferred minimal
-     representation (e.g. 1:0:e:...) and not with extra leading zeros
-     (e.g. 01:00:0e:...) */
+  char addrstr1[20], addrstr2[20];
+  my_ether_ntoa((const u_int8_t *)addr, addrstr1, 1);
+  my_ether_ntoa((const u_int8_t *)addr, addrstr2, 0);
   /* there should be no characters that need escaping */
-  return mysnprintf(buffer, buflen, "(&%s(%s=%s))",
-                    ether_filter, attmap_ether_macAddress, addrstr);
+  return mysnprintf(buffer, buflen, "(&%s(|(%s=%s)(%s=%s)))", ether_filter,
+                    attmap_ether_macAddress, addrstr1,
+                    attmap_ether_macAddress, addrstr2);
 }
 
 void ether_init(void)
@@ -172,10 +185,9 @@ NSLCD_HANDLE(
   char addrstr[20];
   char filter[BUFLEN_FILTER];
   READ(fp, &addr, sizeof(uint8_t[6]));
-  if (ether_ntoa_r(&addr, addrstr) == NULL)
-    return -1;
+  my_ether_ntoa((u_int8_t *)&addr, addrstr, 1);
   log_setrequest("ether=%s", addrstr);,
-  mkfilter_ether_byether(addrstr, filter, sizeof(filter)),
+  mkfilter_ether_byether(&addr, filter, sizeof(filter)),
   write_ether(fp, entry, NULL, addrstr)
 )
 
diff --git a/pynslcd/ether.py b/pynslcd/ether.py
index e5060ca..1be7861 100644
--- a/pynslcd/ether.py
+++ b/pynslcd/ether.py
@@ -1,7 +1,7 @@
 
 # ether.py - lookup functions for ethernet addresses
 #
-# Copyright (C) 2010, 2011, 2012, 2013 Arthur de Jong
+# Copyright (C) 2010-2017 Arthur de Jong
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -31,10 +31,11 @@ def ether_aton(ether):
     return struct.pack('BBBBBB', *(int(x, 16) for x in ether.split(':')))
 
 
-def ether_ntoa(ether):
+def ether_ntoa(ether, compact=True):
     """Conversts an ethernet address in network byte order to the string
     representation."""
-    return ':'.join('%x' % x for x in struct.unpack('6B', ether))
+    fmt = '%x' if compact else '%02x'
+    return ':'.join(fmt % x for x in struct.unpack('6B', ether))
 
 
 attmap = common.Attributes(cn='cn', macAddress='macAddress')
@@ -51,7 +52,7 @@ class Search(search.LDAPSearch):
         # we need a custom mk_filter because this is an | query
         if 'macAddress' in self.parameters:
             ether = self.parameters['macAddress']
-            alt_ether = ':'.join('%02x' % int(x, 16) for x in ether.split(':'))
+            alt_ether = ether_ntoa(ether_aton(ether), compact=False)
             return '(&%s(|(%s=%s)(%s=%s)))' % (self.filter,
                       attmap['macAddress'], ether,
                       attmap['macAddress'], alt_ether)

-----------------------------------------------------------------------

Summary of changes:
 README           |  4 ++--
 compat/ether.c   | 14 +-------------
 compat/ether.h   | 14 +-------------
 configure.ac     |  8 ++++----
 nslcd/ether.c    | 32 ++++++++++++++++++++++----------
 pynslcd/ether.py |  9 +++++----
 tests/test.ldif  |  2 +-
 7 files changed, 36 insertions(+), 47 deletions(-)


hooks/post-receive
-- 
nss-pam-ldapd
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
https://lists.arthurdejong.org/nss-pam-ldapd-commits/