lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1427 - in nss-pam-ldapd: . compat nslcd

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

nss-pam-ldapd commit: r1427 - in nss-pam-ldapd: . compat nslcd



Author: arthur
Date: Fri Apr 15 23:20:40 2011
New Revision: 1427
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1427

Log:
provide replacement implementation for strndup() for systems that don't have it

Added:
   nss-pam-ldapd/compat/strndup.c
   nss-pam-ldapd/compat/strndup.h
Modified:
   nss-pam-ldapd/compat/Makefile.am
   nss-pam-ldapd/configure.ac
   nss-pam-ldapd/nslcd/group.c
   nss-pam-ldapd/nslcd/passwd.c

Modified: nss-pam-ldapd/compat/Makefile.am
==============================================================================
--- nss-pam-ldapd/compat/Makefile.am    Fri Apr 15 23:20:06 2011        (r1426)
+++ nss-pam-ldapd/compat/Makefile.am    Fri Apr 15 23:20:40 2011        (r1427)
@@ -1,6 +1,6 @@
 # Makefile.am - use automake to generate Makefile.in
 #
-# Copyright (C) 2008, 2009, 2010 Arthur de Jong
+# Copyright (C) 2008, 2009, 2010, 2011 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
@@ -25,6 +25,7 @@
 EXTRA_DIST = getopt_long.c getopt_long.h \
              daemon.c daemon.h \
              ether.c ether.h \
+             strndup.c strndup.h \
              nss_compat.h \
              ldap_compat.h pagectrl.c ldap_passwd_s.c ldap_initialize.c \
              pam_compat.h pam_get_authtok.c pam_prompt.c

Added: nss-pam-ldapd/compat/strndup.c
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ nss-pam-ldapd/compat/strndup.c      Fri Apr 15 23:20:40 2011        (r1427)
@@ -0,0 +1,41 @@
+/*
+   strndup.c - implementation of strndup() for systems that lack it
+
+   Copyright (C) 2011 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
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301 USA
+*/
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "strndup.h"
+
+/* this is a strndup() replacement for systems that don't have it
+   (strndup() is in POSIX 2008 now) */
+char *strndup(const char *s,size_t size)
+{
+  char *result;
+  result=(char *)malloc(size+1);
+  if (result!=NULL)
+  {
+    strncpy(result,s,size);
+    result[size]='\0';
+  }
+  return result;
+}

Added: nss-pam-ldapd/compat/strndup.h
==============================================================================
--- /dev/null   00:00:00 1970   (empty, because file is newly added)
+++ nss-pam-ldapd/compat/strndup.h      Fri Apr 15 23:20:40 2011        (r1427)
@@ -0,0 +1,33 @@
+/*
+   strndup.h - definition of strndup() for systems that lack it
+
+   Copyright (C) 2011 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
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301 USA
+*/
+
+#ifndef COMPAT__STRNDUP_H
+#define COMPAT__STRNDUP_H 1
+
+#ifndef HAVE_STRNDUP
+
+/* this is a strndup() replacement for systems that don't have it
+   (strndup() is in POSIX 2008 now) */
+char *strndup(const char *s,size_t size);
+
+#endif /* not HAVE_STRNDUP */
+
+#endif /* COMPAT__STRNDUP_H */

Modified: nss-pam-ldapd/configure.ac
==============================================================================
--- nss-pam-ldapd/configure.ac  Fri Apr 15 23:20:06 2011        (r1426)
+++ nss-pam-ldapd/configure.ac  Fri Apr 15 23:20:40 2011        (r1427)
@@ -566,8 +566,9 @@
   AC_CHECK_FUNCS(dlopen dlsym dlerror)
   AC_CHECK_FUNCS(regcomp regexec regerror)
 
-  # replace getopt_long() function if it is not on the system
+  # replace some functions if they are not on the system
   AC_REPLACE_FUNCS(getopt_long)
+  AC_REPLACE_FUNCS(strndup)
 
   # replace daemon() function if it is not on the system
   AC_SEARCH_LIBS(daemon,bsd)

Modified: nss-pam-ldapd/nslcd/group.c
==============================================================================
--- nss-pam-ldapd/nslcd/group.c Fri Apr 15 23:20:06 2011        (r1426)
+++ nss-pam-ldapd/nslcd/group.c Fri Apr 15 23:20:40 2011        (r1427)
@@ -37,6 +37,7 @@
 #include "myldap.h"
 #include "cfg.h"
 #include "attmap.h"
+#include "compat/strndup.h"
 
 /* ( nisSchema.2.2 NAME 'posixGroup' SUP top STRUCTURAL
  *   DESC 'Abstraction of a group of accounts'

Modified: nss-pam-ldapd/nslcd/passwd.c
==============================================================================
--- nss-pam-ldapd/nslcd/passwd.c        Fri Apr 15 23:20:06 2011        (r1426)
+++ nss-pam-ldapd/nslcd/passwd.c        Fri Apr 15 23:20:40 2011        (r1427)
@@ -38,6 +38,7 @@
 #include "cfg.h"
 #include "attmap.h"
 #include "common/dict.h"
+#include "compat/strndup.h"
 
 /* ( nisSchema.2.0 NAME 'posixAccount' SUP top AUXILIARY
  *   DESC 'Abstraction of an account with POSIX attributes'
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits