From 1b68e5f5fdbd715937ddbfb6526229651ae9f8b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Mon, 6 Apr 2015 19:28:34 +0200 Subject: [PATCH] =?UTF-8?q?On=20essaie=20de=20pas=20p=C3=A9ter=20la=20comp?= =?UTF-8?q?atibilit=C3=A9=20pour=20la=20cr=C3=A9ation=20de=20home=20des=20?= =?UTF-8?q?clubs.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gestion/gen_confs/adherents.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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'):