diff --git a/gestion/gen_confs/adherents.py b/gestion/gen_confs/adherents.py index 47fc246f..1bcb1060 100644 --- a/gestion/gen_confs/adherents.py +++ b/gestion/gen_confs/adherents.py @@ -117,7 +117,13 @@ class home: try: login, oldLogin, oldHome = args.split(",") if login: - adh = CONN.search("login=%s" % (login,))['adherent'][0] + res = CONN.search("login=%s" % (login,)) + if res['adherent']: + adh = res['adherent'][0] + gid = config.gid + elif res['club']: + adh = res['club'][0] + gid = config.club_gid home = adh.home() uid = adh.uidNumber() mail_redirect = adh.email_exterieur() @@ -130,7 +136,7 @@ class home: if not os.path.exists(home): # Le home n'existe pas os.mkdir(home, 0755) - os.chown(home, int(uid), config.gid) + os.chown(home, int(uid), gid) if homesplit[-2] != "club": if os.path.exists(symlink) and os.path.islink(symlink): os.unlink(symlink) @@ -141,7 +147,7 @@ class home: # Il y un répertoire existant # Bon UID ? stat = os.stat(home) - if stat[4] != int(uid) or stat[5] != config.gid: + if stat[4] != int(uid) or stat[5] != gid: # Le home n'est pas pas à la bonne personne raise OSError('home existant') if homesplit[-2] != "club": @@ -163,7 +169,7 @@ class home: ### Mail if not os.path.exists(home + '/Mail'): os.mkdir(home + '/Mail', 0700) - os.chown(home + '/Mail', int(uid), config.gid) + os.chown(home + '/Mail', int(uid), gid) if not os.path.exists('/home-adh/mail/' + login): os.mkdir('/home-adh/mail/' + login, 0700) os.chown('/home-adh/mail/' + login, int(uid), 8) @@ -171,7 +177,7 @@ class home: ### Redirection if mail_redirect: file(home + '/.forward', 'w').write(mail_redirect + '\n') - os.chown(home + '/.forward', int(uid), config.gid) + os.chown(home + '/.forward', int(uid), gid) os.chmod(home + '/.forward', 0604) ### Owncloud dans le home if not os.path.exists(home + '/OwnCloud'):