lists.arthurdejong.org
RSS feed

nss-pam-ldapd commit: r1864 - in nss-pam-ldapd: . common nslcd nss pam pynslcd

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

nss-pam-ldapd commit: r1864 - in nss-pam-ldapd: . common nslcd nss pam pynslcd



Author: arthur
Date: Sun Dec 16 16:11:59 2012
New Revision: 1864
URL: http://arthurdejong.org/viewvc/nss-pam-ldapd?revision=1864&view=revision

Log:
switch protocol from host byte order to network byte order and switch use of 
uid_t and gid_t in the protocol to int32

Modified:
   nss-pam-ldapd/common/nslcd-prot.h
   nss-pam-ldapd/nslcd.h
   nss-pam-ldapd/nslcd/common.c
   nss-pam-ldapd/nslcd/ether.c
   nss-pam-ldapd/nslcd/group.c
   nss-pam-ldapd/nslcd/nslcd.c
   nss-pam-ldapd/nslcd/passwd.c
   nss-pam-ldapd/nss/common.h
   nss-pam-ldapd/nss/ethers.c
   nss-pam-ldapd/nss/group.c
   nss-pam-ldapd/nss/networks.c
   nss-pam-ldapd/nss/passwd.c
   nss-pam-ldapd/nss/services.c
   nss-pam-ldapd/pam/common.h
   nss-pam-ldapd/pam/pam.c
   nss-pam-ldapd/pynslcd/group.py
   nss-pam-ldapd/pynslcd/passwd.py
   nss-pam-ldapd/pynslcd/tio.py

Modified: nss-pam-ldapd/common/nslcd-prot.h
==============================================================================
--- nss-pam-ldapd/common/nslcd-prot.h   Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/common/nslcd-prot.h   Sun Dec 16 16:11:59 2012        (r1864)
@@ -23,6 +23,9 @@
 #ifndef COMMON__NSLCD_PROT_H
 #define COMMON__NSLCD_PROT_H 1
 
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
 #include "tio.h"
 
 /* If you use these macros you should define the following macros to
@@ -86,13 +89,10 @@
     ERROR_OUT_WRITEERROR(fp); \
   }
 
-#define WRITE_TYPE(fp,field,type) \
-  WRITE(fp,&(field),sizeof(type))
-
 #define WRITE_INT32(fp,i) \
   DEBUG_PRINT("WRITE_INT32 : var="__STRING(i)" int32=%d",(int)i); \
-  tmpint32=(int32_t)(i); \
-  WRITE_TYPE(fp,tmpint32,int32_t)
+  tmpint32=htonl((int32_t)(i)); \
+  WRITE(fp,&tmpint32,sizeof(int32_t))
 
 #define WRITE_STRING(fp,str) \
   DEBUG_PRINT("WRITE_STRING: var="__STRING(str)" string=\"%s\"",(str)); \
@@ -103,6 +103,7 @@
   else \
   { \
     WRITE_INT32(fp,strlen(str)); \
+    tmpint32=ntohl(tmpint32); \
     if (tmpint32>0) \
       { WRITE(fp,(str),tmpint32); } \
   }
@@ -120,7 +121,7 @@
       /*noting*/ ; \
     /* write number of strings */ \
     DEBUG_PRINT("WRITE_STRLST: var="__STRING(arr)" num=%d",(int)tmp3int32); \
-    WRITE_TYPE(fp,tmp3int32,int32_t); \
+    WRITE_INT32(fp,tmp3int32); \
     /* write strings */ \
     for (tmp2int32=0;tmp2int32<tmp3int32;tmp2int32++) \
     { \
@@ -136,7 +137,7 @@
       tmp3int32++; \
   /* write number of strings (mius one because we intend to skip one) */ \
   DEBUG_PRINT("WRITE_STRLST: var="__STRING(arr)" num=%d",(int)tmp3int32); \
-  WRITE_TYPE(fp,tmp3int32,int32_t); \
+  WRITE_INT32(fp,tmp3int32); \
   /* write strings */ \
   for (tmp2int32=0;(arr)[tmp2int32]!=NULL;tmp2int32++) \
   { \
@@ -163,18 +164,16 @@
   DEBUG_PRINT("READ       : var="__STRING(ptr)" size=%d",(int)size); \
   DEBUG_DUMP(ptr,size);
 
-#define READ_TYPE(fp,field,type) \
-  READ(fp,&(field),sizeof(type))
-
 #define READ_INT32(fp,i) \
-  READ_TYPE(fp,tmpint32,int32_t); \
-  i=tmpint32; \
+  READ(fp,&tmpint32,sizeof(int32_t)); \
+  i=ntohl(tmpint32); \
   DEBUG_PRINT("READ_INT32 : var="__STRING(i)" int32=%d",(int)i);
 
 /* read a string in a fixed-size "normal" buffer */
 #define READ_STRING(fp,buffer) \
   /* read the size of the string */ \
-  READ_TYPE(fp,tmpint32,int32_t); \
+  READ(fp,&tmpint32,sizeof(int32_t)); \
+  tmpint32=ntohl(tmpint32); \
   DEBUG_PRINT("READ_STRING: var="__STRING(buffer)" strlen=%d",tmpint32); \
   /* check if read would fit */ \
   if (((size_t)tmpint32)>=sizeof(buffer)) \
@@ -252,7 +251,8 @@
    and store the actual location of the string in field */
 #define READ_BUF_STRING(fp,field) \
   /* read the size of the string */ \
-  READ_TYPE(fp,tmpint32,int32_t); \
+  READ(fp,&tmpint32,sizeof(int32_t)); \
+  tmpint32=ntohl(tmpint32); \
   DEBUG_PRINT("READ_BUF_STRING: var="__STRING(field)" strlen=%d",tmpint32); \
   /* check if read would fit */ \
   BUF_CHECK(fp,tmpint32+1); \
@@ -270,7 +270,8 @@
    array list (size for the array is allocated) */
 #define READ_BUF_STRINGLIST(fp,arr) \
   /* read the number of entries */ \
-  READ_TYPE(fp,tmp3int32,int32_t); \
+  READ(fp,&tmp3int32,sizeof(int32_t)); \
+  tmp3int32=ntohl(tmp3int32); \
   DEBUG_PRINT("READ_STRLST: var="__STRING(arr)" num=%d",(int)tmp3int32); \
   /* allocate room for *char[num+1] */ \
   BUF_ALLOC(fp,arr,char *,tmp3int32+1); \
@@ -298,7 +299,8 @@
 /* read a string from the stream but don't do anything with the result */
 #define SKIP_STRING(fp) \
   /* read the size of the string */ \
-  READ_TYPE(fp,tmpint32,int32_t); \
+  READ(fp,&tmpint32,sizeof(int32_t)); \
+  tmpint32=ntohl(tmpint32); \
   DEBUG_PRINT("READ_STRING: skip %d bytes",(int)tmpint32); \
   /* read (skip) the specified number of bytes */ \
   SKIP(fp,tmpint32);
@@ -306,7 +308,8 @@
 /* skip a list of strings */
 #define SKIP_STRINGLIST(fp) \
   /* read the number of entries */ \
-  READ_TYPE(fp,tmp3int32,int32_t); \
+  READ(fp,&tmp3int32,sizeof(int32_t)); \
+  tmp3int32=ntohl(tmp3int32); \
   DEBUG_PRINT("READ_STRLST: skip %d strings",(int)tmp3int32); \
   /* read all entries */ \
   for (tmp2int32=0;tmp2int32<tmp3int32;tmp2int32++) \
@@ -340,18 +343,21 @@
     ERROR_OUT_WRITEERROR(fp); \
   } \
   /* read and check response version number */ \
-  READ_TYPE(fp,tmpint32,int32_t); \
+  READ(fp,&tmpint32,sizeof(int32_t)); \
+  tmpint32=ntohl(tmpint32); \
   if (tmpint32!=(int32_t)NSLCD_VERSION) \
     { ERROR_OUT_READERROR(fp) } \
   /* read and check response request number */ \
-  READ_TYPE(fp,tmpint32,int32_t); \
+  READ(fp,&tmpint32,sizeof(int32_t)); \
+  tmpint32=ntohl(tmpint32); \
   if (tmpint32!=(int32_t)(action)) \
     { ERROR_OUT_READERROR(fp) }
 
 /* Read the response code (the result code of the query) from
    the stream. */
 #define READ_RESPONSE_CODE(fp) \
-  READ_TYPE(fp,tmpint32,int32_t); \
+  READ(fp,&tmpint32,sizeof(int32_t)); \
+  tmpint32=ntohl(tmpint32); \
   if (tmpint32!=(int32_t)NSLCD_RESULT_BEGIN) \
     { ERROR_OUT_NOSUCCESS(fp) }
 

Modified: nss-pam-ldapd/nslcd.h
==============================================================================
--- nss-pam-ldapd/nslcd.h       Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/nslcd.h       Sun Dec 16 16:11:59 2012        (r1864)
@@ -59,17 +59,15 @@
    Furthermore the ADDRESS compound data type is defined as:
      INT32  type of address: e.g. AF_INET or AF_INET6
      INT32  lenght of address
-     RAW    the address itself in network byte order
+     RAW    the address itself
    With the ADDRESSLIST using the same construct as with STRINGLIST.
 
-   The protocol uses host-byte order for all types (except in the raw
-   address above).
+   The protocol uses network byte order for all types.
 */
 
-/* The current version of the protocol. Note that version 1
-   is experimental and this version will be used until a
-   1.0 release of nss-pam-ldapd is made. */
-#define NSLCD_VERSION 1
+/* The current version of the protocol. This protocol should only be
+   updated with major backwards-incompatible changes. */
+#define NSLCD_VERSION 2
 
 /* Get a NSLCD configuration option. There is one request parameter:
     INT32   NSLCD_CONFIG_*
@@ -100,7 +98,7 @@
    for a single entry are:
      STRING       group name
      STRING       group password
-     TYPE(gid_t)  group id
+     INT32        group id
      STRINGLIST   members (usernames) of the group
      (not that the BYMEMER call returns an emtpy members list) */
 #define NSLCD_ACTION_GROUP_BYNAME       5001
@@ -142,8 +140,8 @@
 /* User account (/etc/passwd) NSS requests. Result values are:
      STRING       user name
      STRING       user password
-     TYPE(uid_t)  user id
-     TYPE(gid_t)  group id
+     INT32        user id
+     INT32        group id
      STRING       gecos information
      STRING       home directory
      STRING       login shell */

Modified: nss-pam-ldapd/nslcd/common.c
==============================================================================
--- nss-pam-ldapd/nslcd/common.c        Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/nslcd/common.c        Sun Dec 16 16:11:59 2012        (r1864)
@@ -165,7 +165,7 @@
     /* write the address length */
     WRITE_INT32(fp,sizeof(struct in_addr));
     /* write the address itself (in network byte order) */
-    WRITE_TYPE(fp,ipv4addr,struct in_addr);
+    WRITE(fp,&ipv4addr,sizeof(struct in_addr));
   }
   else if (inet_pton(AF_INET6,addr,&ipv6addr)>0)
   {
@@ -174,7 +174,7 @@
     /* write the address length */
     WRITE_INT32(fp,sizeof(struct in6_addr));
     /* write the address itself (in network byte order) */
-    WRITE_TYPE(fp,ipv6addr,struct in6_addr);
+    WRITE(fp,&ipv6addr,sizeof(struct in6_addr));
   }
   else
   {

Modified: nss-pam-ldapd/nslcd/ether.c
==============================================================================
--- nss-pam-ldapd/nslcd/ether.c Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/nslcd/ether.c Sun Dec 16 16:11:59 2012        (r1864)
@@ -109,7 +109,7 @@
 /* TODO: check for errors in aton() */
 #define WRITE_ETHER(fp,addr) \
   ether_aton_r(addr,&tmpaddr); \
-  WRITE_TYPE(fp,tmpaddr,uint8_t[6]);
+  WRITE(fp,&tmpaddr,sizeof(uint8_t[6]));
 
 static int write_ether(TFILE *fp,MYLDAP_ENTRY *entry,
                        const char *reqname,const char *reqether)
@@ -173,7 +173,7 @@
   struct ether_addr addr;
   char addrstr[20];
   char filter[4096];
-  READ_TYPE(fp,addr,uint8_t[6]);
+  READ(fp,&addr,sizeof(uint8_t[6]));
   if (ether_ntoa_r(&addr,addrstr)==NULL)
     return -1;
   log_setrequest("ether=%s",addrstr);,

Modified: nss-pam-ldapd/nslcd/group.c
==============================================================================
--- nss-pam-ldapd/nslcd/group.c Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/nslcd/group.c Sun Dec 16 16:11:59 2012        (r1864)
@@ -194,7 +194,7 @@
         WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
         WRITE_STRING(fp,names[i]);
         WRITE_STRING(fp,passwd);
-        WRITE_TYPE(fp,gids[j],gid_t);
+        WRITE_INT32(fp,gids[j]);
         WRITE_STRINGLIST(fp,members);
       }
     }
@@ -334,7 +334,7 @@
   group,bygid,
   gid_t gid;
   char filter[4096];
-  READ_TYPE(fp,gid,gid_t);
+  READ_INT32(fp,gid);
   log_setrequest("group=%lu",(unsigned long int)gid);,
   NSLCD_ACTION_GROUP_BYGID,
   mkfilter_group_bygid(gid,filter,sizeof(filter)),

Modified: nss-pam-ldapd/nslcd/nslcd.c
==============================================================================
--- nss-pam-ldapd/nslcd/nslcd.c Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/nslcd/nslcd.c Sun Dec 16 16:11:59 2012        (r1864)
@@ -372,15 +372,16 @@
 static int read_header(TFILE *fp,int32_t *action)
 {
   int32_t tmpint32;
+  int32_t protocol;
   /* read the protocol version */
-  READ_TYPE(fp,tmpint32,int32_t);
-  if (tmpint32 != (int32_t)NSLCD_VERSION)
+  READ_INT32(fp,protocol);
+  if (protocol!=(int32_t)NSLCD_VERSION)
   {
-    log_log(LOG_DEBUG,"wrong nslcd version id (%d)",(int)tmpint32);
+    log_log(LOG_DEBUG,"wrong nslcd version id (%d)",(int)protocol);
     return -1;
   }
   /* read the request type */
-  READ(fp,action,sizeof(int32_t));
+  READ_INT32(fp,*action);
   return 0;
 }
 
@@ -456,7 +457,7 @@
     case NSLCD_ACTION_PAM_SESS_C:       (void)nslcd_pam_sess_c(fp,session); 
break;
     case NSLCD_ACTION_PAM_PWMOD:        (void)nslcd_pam_pwmod(fp,session,uid); 
break;
     default:
-      log_log(LOG_WARNING,"invalid request id: %d",(int)action);
+      log_log(LOG_WARNING,"invalid request id: %ud",(unsigned int)action);
       break;
   }
   /* we're done with the request */

Modified: nss-pam-ldapd/nslcd/passwd.c
==============================================================================
--- nss-pam-ldapd/nslcd/passwd.c        Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/nslcd/passwd.c        Sun Dec 16 16:11:59 2012        (r1864)
@@ -531,8 +531,8 @@
             WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
             WRITE_STRING(fp,usernames[i]);
             WRITE_STRING(fp,passwd);
-            WRITE_TYPE(fp,uids[j],uid_t);
-            WRITE_TYPE(fp,gid,gid_t);
+            WRITE_INT32(fp,uids[j]);
+            WRITE_INT32(fp,gid);
             WRITE_STRING(fp,gecos);
             WRITE_STRING(fp,homedir);
             WRITE_STRING(fp,shell);
@@ -563,7 +563,7 @@
   passwd,byuid,
   uid_t uid;
   char filter[4096];
-  READ_TYPE(fp,uid,uid_t);
+  READ_INT32(fp,uid);
   log_setrequest("passwd=%lu",(unsigned long int)uid);
   if (uid<nslcd_cfg->ldc_nss_min_uid)
   {

Modified: nss-pam-ldapd/nss/common.h
==============================================================================
--- nss-pam-ldapd/nss/common.h  Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/nss/common.h  Sun Dec 16 16:11:59 2012        (r1864)
@@ -133,11 +133,6 @@
   NSS_BYGEN(action,WRITE_STRING(fp,name),readfn)
 
 /* This macro can be used to generate a get..by..() function
-   body where the value that is the key has the specified type. */
-#define NSS_BYTYPE(action,val,type,readfn) \
-  NSS_BYGEN(action,WRITE_TYPE(fp,val,type),readfn)
-
-/* This macro can be used to generate a get..by..() function
    body where the value should be passed as an int32_t. */
 #define NSS_BYINT32(action,val,readfn) \
   NSS_BYGEN(action,WRITE_INT32(fp,val),readfn)

Modified: nss-pam-ldapd/nss/ethers.c
==============================================================================
--- nss-pam-ldapd/nss/ethers.c  Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/nss/ethers.c  Sun Dec 16 16:11:59 2012        (r1864)
@@ -39,7 +39,7 @@
   size_t bufptr=0;
   memset(result,0,sizeof(struct etherent));
   READ_BUF_STRING(fp,result->e_name);
-  READ_TYPE(fp,result->e_addr,uint8_t[6]);
+  READ(fp,&(result->e_addr),sizeof(uint8_t[6]));
   return NSS_STATUS_SUCCESS;
 }
 
@@ -60,9 +60,9 @@
         const struct ether_addr *addr,struct etherent *result,
         char *buffer,size_t buflen,int *errnop)
 {
-  NSS_BYTYPE(NSLCD_ACTION_ETHER_BYETHER,
-             *addr,uint8_t[6],
-             read_etherent(fp,result,buffer,buflen,errnop));
+  NSS_BYGEN(NSLCD_ACTION_ETHER_BYETHER,
+            WRITE(fp,addr,sizeof(uint8_t[6])),
+            read_etherent(fp,result,buffer,buflen,errnop));
 }
 
 /* thread-local file pointer to an ongoing request */

Modified: nss-pam-ldapd/nss/group.c
==============================================================================
--- nss-pam-ldapd/nss/group.c   Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/nss/group.c   Sun Dec 16 16:11:59 2012        (r1864)
@@ -41,7 +41,7 @@
   memset(result,0,sizeof(struct group));
   READ_BUF_STRING(fp,result->gr_name);
   READ_BUF_STRING(fp,result->gr_passwd);
-  READ_TYPE(fp,result->gr_gid,gid_t);
+  READ_INT32(fp,result->gr_gid);
   READ_BUF_STRINGLIST(fp,result->gr_mem);
   return NSS_STATUS_SUCCESS;
 }
@@ -67,7 +67,7 @@
     /* skip passwd entry */
     SKIP_STRING(fp);
     /* read gid */
-    READ_TYPE(fp,gid,gid_t);
+    READ_INT32(fp,gid);
     /* skip members */
     SKIP_STRINGLIST(fp);
     /* only add the group to the list if it is not the specified group */
@@ -108,7 +108,7 @@
     /* read next response code
       (don't bail out on not success since we just want to build
       up a list) */
-    READ_TYPE(fp,res,int32_t);
+    READ_INT32(fp,res);
   }
   /* return the proper status code */
   return NSS_STATUS_SUCCESS;
@@ -131,9 +131,9 @@
         gid_t gid,struct group *result,
         char *buffer,size_t buflen,int *errnop)
 {
-  NSS_BYTYPE(NSLCD_ACTION_GROUP_BYGID,
-             gid,gid_t,
-             read_group(fp,result,buffer,buflen,errnop));
+  NSS_BYINT32(NSLCD_ACTION_GROUP_BYGID,
+              gid,
+              read_group(fp,result,buffer,buflen,errnop));
 }
 
 /* thread-local file pointer to an ongoing request */

Modified: nss-pam-ldapd/nss/networks.c
==============================================================================
--- nss-pam-ldapd/nss/networks.c        Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/nss/networks.c        Sun Dec 16 16:11:59 2012        (r1864)
@@ -78,7 +78,7 @@
   READ_BUF_STRINGLIST(fp,result->n_aliases);
   result->n_addrtype=AF_INET;
   /* read number of addresses to follow */
-  READ_TYPE(fp,numaddr,int32_t);
+  READ_INT32(fp,numaddr);
   /* go through the address list and filter on af */
   while (--numaddr>=0)
   {
@@ -88,8 +88,7 @@
     if ((readaf==AF_INET)&&(tmp2int32==4))
     {
       /* read address and translate to host byte order */
-      READ_TYPE(fp,tmpint32,int32_t);
-      result->n_net=ntohl((uint32_t)tmpint32);
+      READ_INT32(fp,result->n_net);
       /* signal that we've read a proper entry */
       retv=NSS_STATUS_SUCCESS;
       /* don't return here to not upset the stream */
@@ -109,7 +108,7 @@
 #define WRITE_ADDRESS(fp,addr) \
   WRITE_INT32(fp,AF_INET); \
   WRITE_INT32(fp,4); \
-  WRITE_INT32(fp,htonl(addr));
+  WRITE_INT32(fp,addr);
 
 #ifdef NSS_FLAVOUR_GLIBC
 

Modified: nss-pam-ldapd/nss/passwd.c
==============================================================================
--- nss-pam-ldapd/nss/passwd.c  Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/nss/passwd.c  Sun Dec 16 16:11:59 2012        (r1864)
@@ -40,8 +40,8 @@
   memset(result,0,sizeof(struct passwd));
   READ_BUF_STRING(fp,result->pw_name);
   READ_BUF_STRING(fp,result->pw_passwd);
-  READ_TYPE(fp,result->pw_uid,uid_t);
-  READ_TYPE(fp,result->pw_gid,gid_t);
+  READ_INT32(fp,result->pw_uid);
+  READ_INT32(fp,result->pw_gid);
   READ_BUF_STRING(fp,result->pw_gecos);
   READ_BUF_STRING(fp,result->pw_dir);
   READ_BUF_STRING(fp,result->pw_shell);
@@ -69,9 +69,9 @@
         uid_t uid,struct passwd *result,
         char *buffer,size_t buflen,int *errnop)
 {
-  NSS_BYTYPE(NSLCD_ACTION_PASSWD_BYUID,
-             uid,uid_t,
-             read_passwd(fp,result,buffer,buflen,errnop));
+  NSS_BYINT32(NSLCD_ACTION_PASSWD_BYUID,
+              uid,
+              read_passwd(fp,result,buffer,buflen,errnop));
 }
 
 /* thread-local file pointer to an ongoing request */

Modified: nss-pam-ldapd/nss/services.c
==============================================================================
--- nss-pam-ldapd/nss/services.c        Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/nss/services.c        Sun Dec 16 16:11:59 2012        (r1864)
@@ -41,8 +41,8 @@
   READ_BUF_STRING(fp,result->s_name);
   READ_BUF_STRINGLIST(fp,result->s_aliases);
   /* store port number in network byte order */
-  READ_TYPE(fp,tmpint32,int32_t);
-  result->s_port=htons((uint16_t)tmpint32);
+  READ_INT32(fp,tmp2int32);
+  result->s_port=htons((uint16_t)tmp2int32);;
   READ_BUF_STRING(fp,result->s_proto);
   /* we're done */
   return NSS_STATUS_SUCCESS;
@@ -65,8 +65,10 @@
         int port,const char *protocol,struct servent *result,
         char *buffer,size_t buflen,int *errnop)
 {
+  /* port is already in network byte order */
   NSS_BYGEN(NSLCD_ACTION_SERVICE_BYNUMBER,
-            WRITE_INT32(fp,ntohs(port));WRITE_STRING(fp,protocol),
+            tmpint32=ntohs(port);
+            WRITE_INT32(fp,tmpint32);WRITE_STRING(fp,protocol),
             read_servent(fp,result,buffer,buflen,errnop));
 }
 

Modified: nss-pam-ldapd/pam/common.h
==============================================================================
--- nss-pam-ldapd/pam/common.h  Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/pam/common.h  Sun Dec 16 16:11:59 2012        (r1864)
@@ -94,7 +94,7 @@
 /* helper macro to read PAM status code (auto-translated from NSLCD PAM
    status code */
 #define READ_PAM_CODE(fp,i) \
-  READ_TYPE(fp,tmpint32,int32_t); \
-  i=nslcd2pam_rc(pamh,tmpint32);
+  READ(fp,&tmpint32,sizeof(int32_t)); \
+  (i)=nslcd2pam_rc(pamh,ntohl(tmpint32));
 
 #endif /* not PAM__COMMON_H */

Modified: nss-pam-ldapd/pam/pam.c
==============================================================================
--- nss-pam-ldapd/pam/pam.c     Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/pam/pam.c     Sun Dec 16 16:11:59 2012        (r1864)
@@ -258,8 +258,6 @@
 static int nslcd_request_exists(pam_handle_t *pamh,struct pld_ctx *ctx,struct 
pld_cfg *cfg,
                                 const char *username)
 {
-  uid_t dummy_uid;
-  gid_t dummy_gid;
   PAM_REQUEST(NSLCD_ACTION_PASSWD_BYNAME,
     /* log debug message */
     pam_syslog(pamh,LOG_DEBUG,"nslcd account check; user=%s",username),
@@ -268,8 +266,8 @@
     /* read the result entry */
     SKIP_STRING(fp); /* user name */
     SKIP_STRING(fp); /* passwd entry */
-    READ_TYPE(fp,dummy_uid,uid_t);
-    READ_TYPE(fp,dummy_gid,gid_t);
+    SKIP(fp,sizeof(int32_t)); /* uid */
+    SKIP(fp,sizeof(int32_t)); /* gid */
     SKIP_STRING(fp); /* gecos */
     SKIP_STRING(fp); /* home dir */
     SKIP_STRING(fp); /* shell */

Modified: nss-pam-ldapd/pynslcd/group.py
==============================================================================
--- nss-pam-ldapd/pynslcd/group.py      Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/pynslcd/group.py      Sun Dec 16 16:11:59 2012        (r1864)
@@ -89,7 +89,7 @@
     def write(self, name, passwd, gid, members):
         self.fp.write_string(name)
         self.fp.write_string(passwd)
-        self.fp.write_gid_t(gid)
+        self.fp.write_int32(gid)
         self.fp.write_stringlist(members)
 
     def convert(self, dn, attributes, parameters):
@@ -135,7 +135,7 @@
     action = constants.NSLCD_ACTION_GROUP_BYGID
 
     def read_parameters(self, fp):
-        return dict(gidNumber=fp.read_gid_t())
+        return dict(gidNumber=fp.read_int32())
 
 
 class GroupByMemberRequest(GroupRequest):

Modified: nss-pam-ldapd/pynslcd/passwd.py
==============================================================================
--- nss-pam-ldapd/pynslcd/passwd.py     Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/pynslcd/passwd.py     Sun Dec 16 16:11:59 2012        (r1864)
@@ -53,8 +53,8 @@
     def write(self, name, passwd, uid, gid, gecos, home, shell):
         self.fp.write_string(name)
         self.fp.write_string(passwd)
-        self.fp.write_uid_t(uid)
-        self.fp.write_gid_t(gid)
+        self.fp.write_int32(uid)
+        self.fp.write_int32(gid)
         self.fp.write_string(gecos)
         self.fp.write_string(home)
         self.fp.write_string(shell)
@@ -93,7 +93,7 @@
     action = constants.NSLCD_ACTION_PASSWD_BYUID
 
     def read_parameters(self, fp):
-        return dict(uidNumber=fp.read_uid_t())
+        return dict(uidNumber=fp.read_int32())
 
 
 class PasswdAllRequest(PasswdRequest):

Modified: nss-pam-ldapd/pynslcd/tio.py
==============================================================================
--- nss-pam-ldapd/pynslcd/tio.py        Sat Dec 15 12:13:35 2012        (r1863)
+++ nss-pam-ldapd/pynslcd/tio.py        Sun Dec 16 16:11:59 2012        (r1864)
@@ -24,13 +24,7 @@
 
 
 # definition for reading and writing INT32 values
-_int32 = struct.Struct('i')
-
-# FIXME: use something from constants.py to determine the correct size
-_uid_t = struct.Struct('i')
-
-# FIXME: use something from constants.py to determine the correct size
-_gid_t = struct.Struct('i')
+_int32 = struct.Struct('!i')
 
 # FIXME: use something from constants.py to determine the correct size
 _struct_timeval = struct.Struct('ll')
@@ -56,12 +50,6 @@
     def read_int32(self):
         return _int32.unpack(self.read(_int32.size))[0]
 
-    def read_uid_t(self):
-        return _uid_t.unpack(self.read(_uid_t.size))[0]
-
-    def read_gid_t(self):
-        return _gid_t.unpack(self.read(_gid_t.size))[0]
-
     def read_string(self, maxsize=None):
         len = self.read_int32()
         if maxsize and len >= maxsize:
@@ -80,12 +68,6 @@
     def write_int32(self, value):
         self.write(_int32.pack(value))
 
-    def write_uid_t(self, value):
-        self.write(_uid_t.pack(value))
-
-    def write_gid_t(self, value):
-        self.write(_gid_t.pack(value))
-
     def write_string(self, value):
         self.write_int32(len(value))
         self.write(value)
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/