diff options
-rw-r--r-- | common/nslcd-prot.h | 46 | ||||
-rw-r--r-- | nslcd.h | 18 | ||||
-rw-r--r-- | nslcd/common.c | 4 | ||||
-rw-r--r-- | nslcd/ether.c | 4 | ||||
-rw-r--r-- | nslcd/group.c | 4 | ||||
-rw-r--r-- | nslcd/nslcd.c | 11 | ||||
-rw-r--r-- | nslcd/passwd.c | 6 | ||||
-rw-r--r-- | nss/common.h | 5 | ||||
-rw-r--r-- | nss/ethers.c | 8 | ||||
-rw-r--r-- | nss/group.c | 12 | ||||
-rw-r--r-- | nss/networks.c | 7 | ||||
-rw-r--r-- | nss/passwd.c | 10 | ||||
-rw-r--r-- | nss/services.c | 8 | ||||
-rw-r--r-- | pam/common.h | 4 | ||||
-rw-r--r-- | pam/pam.c | 6 | ||||
-rw-r--r-- | pynslcd/group.py | 4 | ||||
-rw-r--r-- | pynslcd/passwd.py | 6 | ||||
-rw-r--r-- | pynslcd/tio.py | 20 |
18 files changed, 82 insertions, 101 deletions
diff --git a/common/nslcd-prot.h b/common/nslcd-prot.h index 1252158..d462f59 100644 --- a/common/nslcd-prot.h +++ b/common/nslcd-prot.h @@ -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 @@ static void debug_dump(const void *ptr,size_t size) 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 @@ static void debug_dump(const void *ptr,size_t size) else \ { \ WRITE_INT32(fp,strlen(str)); \ + tmpint32=ntohl(tmpint32); \ if (tmpint32>0) \ { WRITE(fp,(str),tmpint32); } \ } @@ -120,7 +121,7 @@ static void debug_dump(const void *ptr,size_t size) /*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 @@ static void debug_dump(const void *ptr,size_t size) 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 @@ static void debug_dump(const void *ptr,size_t size) 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 @@ static void debug_dump(const void *ptr,size_t size) 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 @@ static void debug_dump(const void *ptr,size_t size) 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 @@ static void debug_dump(const void *ptr,size_t size) /* 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 @@ static void debug_dump(const void *ptr,size_t size) /* 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 @@ TFILE *nslcd_client_open(void) 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) } @@ -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 */ diff --git a/nslcd/common.c b/nslcd/common.c index ec20693..37542b9 100644 --- a/nslcd/common.c +++ b/nslcd/common.c @@ -165,7 +165,7 @@ int write_address(TFILE *fp,MYLDAP_ENTRY *entry,const char *attr, /* 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 @@ int write_address(TFILE *fp,MYLDAP_ENTRY *entry,const char *attr, /* 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 { diff --git a/nslcd/ether.c b/nslcd/ether.c index 74312fd..be243ba 100644 --- a/nslcd/ether.c +++ b/nslcd/ether.c @@ -109,7 +109,7 @@ void ether_init(void) /* 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 @@ NSLCD_HANDLE( 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);, diff --git a/nslcd/group.c b/nslcd/group.c index 0096c95..1dfc5f8 100644 --- a/nslcd/group.c +++ b/nslcd/group.c @@ -194,7 +194,7 @@ static int do_write_group( 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 @@ NSLCD_HANDLE( 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)), diff --git a/nslcd/nslcd.c b/nslcd/nslcd.c index a59b640..68312fd 100644 --- a/nslcd/nslcd.c +++ b/nslcd/nslcd.c @@ -372,15 +372,16 @@ static int create_socket(const char *filename) 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 @@ static void handleconnection(int sock,MYLDAP_SESSION *session) 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 */ diff --git a/nslcd/passwd.c b/nslcd/passwd.c index cdeb814..414caed 100644 --- a/nslcd/passwd.c +++ b/nslcd/passwd.c @@ -531,8 +531,8 @@ static int write_passwd(TFILE *fp,MYLDAP_ENTRY *entry,const char *requser, 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 @@ NSLCD_HANDLE_UID( 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) { diff --git a/nss/common.h b/nss/common.h index b75f4a4..6e65c9e 100644 --- a/nss/common.h +++ b/nss/common.h @@ -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) diff --git a/nss/ethers.c b/nss/ethers.c index e494372..e906b51 100644 --- a/nss/ethers.c +++ b/nss/ethers.c @@ -39,7 +39,7 @@ static nss_status_t read_etherent( 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 @@ nss_status_t _nss_ldap_getntohost_r( 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 */ diff --git a/nss/group.c b/nss/group.c index e2f9326..5eb7f8b 100644 --- a/nss/group.c +++ b/nss/group.c @@ -41,7 +41,7 @@ static nss_status_t read_group( 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 @@ static nss_status_t read_gids( /* 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 @@ static nss_status_t read_gids( /* 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 @@ nss_status_t _nss_ldap_getgrgid_r( 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 */ diff --git a/nss/networks.c b/nss/networks.c index 859ef0e..e1fc687 100644 --- a/nss/networks.c +++ b/nss/networks.c @@ -78,7 +78,7 @@ static nss_status_t read_netent( 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 @@ static nss_status_t read_netent( 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 @@ static nss_status_t read_netent( #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 diff --git a/nss/passwd.c b/nss/passwd.c index a5cc3f0..a3e1f7b 100644 --- a/nss/passwd.c +++ b/nss/passwd.c @@ -40,8 +40,8 @@ static nss_status_t read_passwd( 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 @@ nss_status_t _nss_ldap_getpwuid_r( 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 */ diff --git a/nss/services.c b/nss/services.c index 92190b9..c10f4ba 100644 --- a/nss/services.c +++ b/nss/services.c @@ -41,8 +41,8 @@ static nss_status_t read_servent( 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 @@ nss_status_t _nss_ldap_getservbyport_r( 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)); } diff --git a/pam/common.h b/pam/common.h index 73b1df5..9605017 100644 --- a/pam/common.h +++ b/pam/common.h @@ -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 */ @@ -258,8 +258,6 @@ static int nslcd2pam_rc(pam_handle_t *pamh,int rc) 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 @@ static int nslcd_request_exists(pam_handle_t *pamh,struct pld_ctx *ctx,struct pl /* 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 */ diff --git a/pynslcd/group.py b/pynslcd/group.py index 396c2b9..ab07adc 100644 --- a/pynslcd/group.py +++ b/pynslcd/group.py @@ -89,7 +89,7 @@ class GroupRequest(common.Request): 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 @@ class GroupByGidRequest(GroupRequest): 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): diff --git a/pynslcd/passwd.py b/pynslcd/passwd.py index e78ff64..222d3c6 100644 --- a/pynslcd/passwd.py +++ b/pynslcd/passwd.py @@ -53,8 +53,8 @@ class PasswdRequest(common.Request): 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 @@ class PasswdByUidRequest(PasswdRequest): 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): diff --git a/pynslcd/tio.py b/pynslcd/tio.py index 6394acf..9e7f99b 100644 --- a/pynslcd/tio.py +++ b/pynslcd/tio.py @@ -24,13 +24,7 @@ import socket # 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 @@ class TIOStream(object): 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 @@ class TIOStream(object): 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) |