diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2012-12-16 15:11:59 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2012-12-16 15:11:59 +0000 |
commit | 5f55781beb8bfc84412127b3777e1d1d126459b6 (patch) | |
tree | 59c221d593ded0dab58832bb793f7f2e22370536 /pynslcd | |
parent | 99933fd3561df12ed81304eaf444c1d7d1060f38 (diff) |
switch protocol from host byte order to network byte order and switch use of uid_t and gid_t in the protocol to int32
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1864 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'pynslcd')
-rw-r--r-- | pynslcd/group.py | 4 | ||||
-rw-r--r-- | pynslcd/passwd.py | 6 | ||||
-rw-r--r-- | pynslcd/tio.py | 20 |
3 files changed, 6 insertions, 24 deletions
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) |