Patchs divers + mise jour de l'annuaire
darcs-hash:20040902051057-d1718-2e5bc8684bcff38b4e56318930da345f0b58f6b4.gz
This commit is contained in:
parent
1ec186d9dd
commit
a2411248dc
5 changed files with 128 additions and 76 deletions
|
@ -312,8 +312,12 @@ class crans_ldap :
|
|||
args=map(tr,args)
|
||||
|
||||
if new in serv.keys() :
|
||||
if args not in serv[new] :
|
||||
modlist = ldap.modlist.modifyModlist({ 'args' : serv[new] }, { 'args' : serv[new] + args })
|
||||
new_args = []
|
||||
for arg in args :
|
||||
if arg not in serv[new] :
|
||||
new_args.append(arg)
|
||||
if new_args :
|
||||
modlist = ldap.modlist.modifyModlist({ 'args' : serv[new] }, { 'args' : serv[new] + new_args })
|
||||
self.conn.modify_s(serv_dn,modlist)
|
||||
# else rien à faire
|
||||
else :
|
||||
|
@ -931,14 +935,14 @@ class base_proprietaire(base_classes_crans) :
|
|||
if m.ipsec() and not 'conf_wifi' in serv :
|
||||
self.services_to_restart('conf_wifi')
|
||||
elif not self.chbre() in serv :
|
||||
self.services_to_restart('chbre',[self.chbre()])
|
||||
self.services_to_restart('switch',[self.chbre()])
|
||||
if self.machines() :
|
||||
for s in ['dhcp', 'dns', 'firewall' ] :
|
||||
if s not in serv :
|
||||
serv.append(s)
|
||||
|
||||
# Vérification si changement de bât, ce qui obligerai un changement d'IP
|
||||
if 'chbre' in self.modifs :
|
||||
if 'chbre' in self.modifs and self.chbre()!='????' :
|
||||
# Verif si machines avec bonnes ip
|
||||
err = 0
|
||||
for m in self.machines() :
|
||||
|
@ -956,10 +960,7 @@ class base_proprietaire(base_classes_crans) :
|
|||
ret += "\nChangement d'IP machine %s : " % m.nom()
|
||||
try :
|
||||
ret += "%s -> %s" % ( ip, m.ip('<automatique>') )
|
||||
se, r = m.save()
|
||||
for s in se :
|
||||
if s not in serv :
|
||||
serv.append(s)
|
||||
r = m.save()
|
||||
except c :
|
||||
ret += coul(u'ERREUR : %s' % c.args[0], rouge)
|
||||
err = 1
|
||||
|
@ -1093,6 +1094,10 @@ class adherent(base_proprietaire) :
|
|||
|
||||
self._set('chbre',['EXT'])
|
||||
return 'EXT'
|
||||
elif new.upper() == '????' :
|
||||
# On ne sait pas ou est l'adhérent
|
||||
self._set('chbre',['????'])
|
||||
return '????'
|
||||
|
||||
new = new.capitalize()
|
||||
bat = new[0].lower()
|
||||
|
@ -1102,7 +1107,7 @@ class adherent(base_proprietaire) :
|
|||
chbres = annuaires.chbre_prises[bat].keys()
|
||||
if new[1:] not in chbres or len(new)<4 or not new[1:4].isdigit() :
|
||||
chbres.sort()
|
||||
aide = u"Chambre inconnue dans le bâtiment, les chambres valides sont :"
|
||||
aide = u"Chambre inconnue dans le batiment, les chambres valides sont :"
|
||||
a=0
|
||||
for c in chbres :
|
||||
if len(c)>=3 and not c[:3].isdigit() :
|
||||
|
@ -1120,8 +1125,16 @@ class adherent(base_proprietaire) :
|
|||
raise ValueError(u'Bâtiment inconnu.')
|
||||
|
||||
# La chambre est valide, est-elle déja occupée ?
|
||||
if self.exist('chbre=%s' % new) :
|
||||
raise ValueError(u'Chambre déjà occupée.')
|
||||
test = self.exist('chbre=%s' % new)
|
||||
if test :
|
||||
search = test[0].split(',')[0]
|
||||
if search.split('=')[0]!='aid' :
|
||||
raise ValueError(u'Chambre déjà occupée.')
|
||||
adh = self.search(search,self._modifiable)['adherent']
|
||||
if len(adh) != 1 :
|
||||
raise ValueError(u'Chambre déjà occupée.')
|
||||
else :
|
||||
raise ValueError(u'Chambre déjà occupée.',adh[0])
|
||||
|
||||
# Lock de la chambre
|
||||
self._locks.append(self.lock('chbre',new))
|
||||
|
@ -1279,10 +1292,13 @@ class adherent(base_proprietaire) :
|
|||
if login[0]=='-' :
|
||||
raise ValueError(u"- interdit en première position.")
|
||||
|
||||
|
||||
if mailexist(login) :
|
||||
raise ValueError(u"Login existant ou correspondant à un alias mail.",1)
|
||||
|
||||
|
||||
home = '/home/' + login
|
||||
if os.path.exists(home) :
|
||||
raise ValueError(u'Création du compte impossible : home existant',1)
|
||||
|
||||
# Lock du mail
|
||||
self._locks.append(self.lock('mail',login))
|
||||
|
||||
|
@ -1321,10 +1337,6 @@ class adherent(base_proprietaire) :
|
|||
self._data['uidNumber']= [ str(uidNumber) ]
|
||||
self._data['gidNumber']=[ str(config.gid) ]
|
||||
|
||||
home = '/home/' + login
|
||||
if os.path.exists(home) :
|
||||
raise RuntimeError(u'Création du compte impossible : home existant')
|
||||
|
||||
self._data['homeDirectory']=[ preattr(home)[1] ]
|
||||
self._data['gecos'] = [ preattr(self.Nom())[1] + ',,,' ]
|
||||
|
||||
|
@ -1535,9 +1547,13 @@ class machine(base_classes_crans) :
|
|||
self.__typ = typ
|
||||
self._modifiable = 'w'
|
||||
|
||||
if self.__proprietaire.chbre() == 'EXT' and typ == 'fixe' :
|
||||
chbre = self.__proprietaire.chbre()
|
||||
if chbre == 'EXT' and typ == 'fixe' :
|
||||
raise ValueError(u'Il faut une chambre pour pouvoir posséder une machine fixe')
|
||||
|
||||
if chbre == '????' :
|
||||
raise ValueError(u'ERREUR : la chambre du propriétaire est inconnue')
|
||||
|
||||
if typ == 'wifi' :
|
||||
# Génération de la clef IPsec
|
||||
self.ipsec(1)
|
||||
|
@ -1740,8 +1756,6 @@ class machine(base_classes_crans) :
|
|||
if not self.conn : self.connect()
|
||||
|
||||
res = self.conn.search_s(','.join(self.dn.split(',')[1:]),0)
|
||||
if len(res) != 1 : njoqmf
|
||||
|
||||
if 'adherent' in res[0][1]['objectClass'] :
|
||||
self.__proprietaire = adherent(res[0],self._modifiable,self.conn)
|
||||
elif 'club' in res[0][1]['objectClass'] :
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue