[ldap_crans] On améliore les locks.
This commit is contained in:
parent
7eb8dd7692
commit
90875b1faf
1 changed files with 11 additions and 6 deletions
|
@ -14,6 +14,7 @@ import smtplib, re, os, random, string, time, sys, pwd
|
|||
import ldap, ldap.modlist, ldap_passwd
|
||||
import netaddr
|
||||
|
||||
import time
|
||||
import annuaires_pg as annuaires
|
||||
import config, config.impression, iptools, ip6tools, cPickle, config_mail
|
||||
from chgpass import chgpass
|
||||
|
@ -497,7 +498,7 @@ class CransLdap:
|
|||
return True
|
||||
|
||||
lock_dn = '%s=%s,%s' % (item, valeur, self.base_lock)
|
||||
lockid = '%s-%s' % (hostname, os.getpid())
|
||||
lockid = '%s-%s-%s' % (hostname, os.getpid(), time.time())
|
||||
modlist = ldap.modlist.addModlist({ 'objectClass': 'lock',
|
||||
'lockid': lockid,
|
||||
item: valeur })
|
||||
|
@ -513,7 +514,7 @@ class CransLdap:
|
|||
if l != lockid:
|
||||
# C'est locké par un autre process que le notre
|
||||
# il tourne encore ?
|
||||
if l.split('-')[0] == hostname and os.system('ps %s > /dev/null 2>&1' % l.split('-')[1] ):
|
||||
if (l.split('-')[0] == hostname and os.system('ps %s > /dev/null 2>&1' % l.split('-')[1] )) or time.time() - 600 >= l.split('-')[2]:
|
||||
# Il ne tourne plus
|
||||
self.remove_lock(res[0]) # delock
|
||||
return self.lock(item, valeur) # relock
|
||||
|
@ -1210,7 +1211,7 @@ class BaseClasseCrans(CransLdap):
|
|||
for champ in ['droits', 'controle', 'paiement', 'carteEtudiant',
|
||||
'mailAlias', 'hostAlias', 'exempt', 'nvram',
|
||||
'portTCPin', 'portTCPout', 'portUDPin', 'portUDPout',
|
||||
'homepageAlias', 'imprimeurClub', 'gpgFingerprint', 'sshFingerprint']:
|
||||
'homepageAlias', 'imprimeurClub', 'gpgFingerprint']:
|
||||
if champ in self.modifs:
|
||||
if champ == 'controle':
|
||||
# Ce n'est pas pareil que self._init_data.get('controle', [''])
|
||||
|
@ -1228,6 +1229,10 @@ class BaseClasseCrans(CransLdap):
|
|||
diff += ''.join([ '-%s' % decode(d) for d in ancien if d not in nouveau ])
|
||||
modif[champ] = champ + diff
|
||||
|
||||
for champ in ['sshFingerprint']:
|
||||
if champ in self.modifs:
|
||||
modif[champ] = champ
|
||||
|
||||
# On recolle tous les morceaux
|
||||
liste_historique = []
|
||||
for champ in self.modifs.keys():
|
||||
|
@ -1307,7 +1312,7 @@ class BaseClasseCrans(CransLdap):
|
|||
modlist = ldap.modlist.addModlist(self._data)
|
||||
self.conn.add_s(self.dn, modlist)
|
||||
break
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# On logge
|
||||
syslog("ldap_crans: exception: %s" % e)
|
||||
raise
|
||||
|
@ -2868,8 +2873,8 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3)
|
|||
self.ipv6(ip6tools.mac_to_ipv6(net, netaddr.EUI(mac)))
|
||||
else:
|
||||
self.ipv6(config.ipv6_machines_speciales[int(self.rid())])
|
||||
except:
|
||||
raise ValueError('La correspondance MAC <-> EUID64 a planté. Tapez PEB et son entourage. (net : %s, mac : %s, ' % (net, mac))
|
||||
except Exception as e:
|
||||
raise ValueError('La correspondance MAC <-> EUID64 a planté. Tapez PEB et son entourage. (net : %s, mac : %s, exception levée : %s)' % (net, mac, e))
|
||||
return mac
|
||||
|
||||
def __host_alias(self, champ, new):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue