fix log numbering

This commit is contained in:
fram3d 2024-04-05 15:48:10 +02:00
parent 3818419cae
commit 2b8c5ea453
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
1 changed files with 25 additions and 13 deletions

View File

@ -181,7 +181,10 @@ class LUSER():
# Add new user to log
attributes['description'] = 'ADD'
rcode2 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', objectClass, attributes)
if rcode1:
rcode2 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', objectClass, attributes)
else:
return False
if rcode2:
self.setlastlog(lastlog)
@ -213,16 +216,19 @@ class LUSER():
lastlog = self.getlastlog() + 1
rcode1 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', OBJECTCLASSES, userdata['attributes'])
chpassbool = self.ldapconnection.modify(f'uid={user},{self.base}', {'userPassword': (MODIFY_REPLACE,[newpass])})
chlastchangebool = self.ldapconnection.modify(f'uid={user},{self.base}', {'shadowLastChange' : (MODIFY_REPLACE,[self.lastpwchangenow()])})
if rcode1:
self.setlastlog(lastlog)
chpassbool = self.ldapconnection.modify(f'uid={user},{self.base}', {'userPassword': (MODIFY_REPLACE,[newpass])})
if chpassbool and chlastchangebool:
rcode1 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', OBJECTCLASSES, userdata['attributes'])
chlastchangebool = self.ldapconnection.modify(f'uid={user},{self.base}', {'shadowLastChange' : (MODIFY_REPLACE,[self.lastpwchangenow()])})
# Return True only if changing of both password and time of last password change was successful
return chpassbool and chlastchangebool
if rcode1:
self.setlastlog(lastlog)
return True
else:
return False
else:
return False
def delete(self, user):
'''
@ -242,13 +248,19 @@ class LUSER():
lastlog = self.getlastlog() + 1
rcode1 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', OBJECTCLASSES, userdata['attributes'])
rcode1 = self.ldapconnection.delete(f'uid={user},{self.base}')
if rcode1:
self.setlastlog(lastlog)
rcode2 = self.ldapconnection.delete(f'uid={user},{self.base}')
rcode2 = self.ldapconnection.add(f'uid={lastlog},{self.logbase}', OBJECTCLASSES, userdata['attributes'])
return rcode1 and rcode2
if rcode2:
self.setlastlog(lastlog)
return True
else:
return False
else:
return False
def getpassword(self, user):
'''