nss-pam-ldapd commit: r1528 - in nss-pam-ldapd: . nslcd
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
nss-pam-ldapd commit: r1528 - in nss-pam-ldapd: . nslcd
- From: Commits of the nss-pam-ldapd project <nss-pam-ldapd-commits [at] lists.arthurdejong.org>
- To: nss-pam-ldapd-commits [at] lists.arthurdejong.org
- Reply-to: nss-pam-ldapd-users [at] lists.arthurdejong.org
- Subject: nss-pam-ldapd commit: r1528 - in nss-pam-ldapd: . nslcd
- Date: Mon, 29 Aug 2011 22:57:38 +0200 (CEST)
Author: arthur
Date: Mon Aug 29 22:57:37 2011
New Revision: 1528
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?view=rev&revision=1528
Log:
implement and use a strtoui() function if uid_t or gid_t is of size unsigned
int (thanks Jakub Hrozek)
Modified:
nss-pam-ldapd/configure.ac
nss-pam-ldapd/nslcd/common.c
nss-pam-ldapd/nslcd/common.h
Modified: nss-pam-ldapd/configure.ac
==============================================================================
--- nss-pam-ldapd/configure.ac Mon Aug 29 21:18:21 2011 (r1527)
+++ nss-pam-ldapd/configure.ac Mon Aug 29 22:57:37 2011 (r1528)
@@ -289,7 +289,7 @@
AC_CHECK_FUNCS([sigaction snprintf])
AC_CHECK_FUNCS(gethostbyname)
AC_SEARCH_LIBS(socket,socket)
-AC_CHECK_FUNCS([strcasecmp strncasecmp strchr strcspn strspn strtol])
+AC_CHECK_FUNCS([strcasecmp strncasecmp strchr strcspn strspn strtol strtoul
strtoull])
AC_CHECK_FUNCS([malloc realloc])
AC_FUNC_FORK
AC_CHECK_FUNCS(__assert_fail)
@@ -303,6 +303,7 @@
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
+AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long int)
AC_CHECK_SIZEOF(unsigned long long int)
AC_CHECK_SIZEOF(uid_t)
Modified: nss-pam-ldapd/nslcd/common.c
==============================================================================
--- nss-pam-ldapd/nslcd/common.c Mon Aug 29 21:18:21 2011 (r1527)
+++ nss-pam-ldapd/nslcd/common.c Mon Aug 29 22:57:37 2011 (r1528)
@@ -269,3 +269,20 @@
return (((long int)binsid[i])&0xff)|((((long int)binsid[i+1])&0xff)<<8)|
((((long int)binsid[i+2])&0xff)<<16)|((((long
int)binsid[i+3])&0xff)<<24);
}
+
+#ifdef WANT_STRTOUI
+/* provide a strtoui() implementation, similar to strtoul() but returning
+ an range-checked unsigned int instead */
+unsigned int strtoui(const char *nptr,char **endptr,int base)
+{
+ unsigned long val;
+ val=strtoul(nptr,endptr,base);
+ if (val>UINT_MAX)
+ {
+ errno=ERANGE;
+ return UINT_MAX;
+ }
+ /* If errno was set by strtoull, we'll pass it back as-is */
+ return (unsigned int)val;
+}
+#endif /* WANT_STRTOUI */
Modified: nss-pam-ldapd/nslcd/common.h
==============================================================================
--- nss-pam-ldapd/nslcd/common.h Mon Aug 29 21:18:21 2011 (r1527)
+++ nss-pam-ldapd/nslcd/common.h Mon Aug 29 22:57:37 2011 (r1528)
@@ -138,6 +138,9 @@
#define strtouid (uid_t)strtoul
#elif SIZEOF_UID_T == SIZEOF_UNSIGNED_LONG_LONG_INT
#define strtouid (uid_t)strtoull
+#elif SIZEOF_UID_T == SIZEOF_UNSIGNED_INT
+#define WANT_STRTOUI 1
+#define strtouid (uid_t)strtoui
#else
#error unable to find implementation for strtouid()
#endif
@@ -147,10 +150,20 @@
#define strtogid (gid_t)strtoul
#elif SIZEOF_GID_T == SIZEOF_UNSIGNED_LONG_LONG_INT
#define strtogid (gid_t)strtoull
+#elif SIZEOF_GID_T == SIZEOF_UNSIGNED_INT
+#ifndef WANT_STRTOUI
+#define WANT_STRTOUI 1
+#endif
+#define strtogid (uid_t)strtoui
#else
#error unable to find implementation for strtogid()
#endif
+#ifdef WANT_STRTOUI
+/* provide a strtoui() if it is needed */
+unsigned int strtoui(const char *nptr,char **endptr,int base);
+#endif /* WANT_STRTOUI */
+
/* these are the functions for initialising the database specific
modules */
void alias_init(void);
--
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits
- nss-pam-ldapd commit: r1528 - in nss-pam-ldapd: . nslcd,
Commits of the nss-pam-ldapd project