From dfa439467dc6f6ac53ad62c8a4af9d5b8def3718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre-Elliott=20B=C3=A9cue?= Date: Mon, 25 Aug 2014 20:46:18 +0200 Subject: [PATCH] =?UTF-8?q?Les=20homes=20ont=20chang=C3=A9=20de=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * On crée des liens symboliques * On les crée en dur au bon endroit. * Idem pour les suppressions --- gestion/gen_confs/adherents.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gestion/gen_confs/adherents.py b/gestion/gen_confs/adherents.py index b5f94a86..6cf81858 100644 --- a/gestion/gen_confs/adherents.py +++ b/gestion/gen_confs/adherents.py @@ -53,6 +53,8 @@ class del_user: anim('\t' + args) try: login, home = args.split(',') + homesplit = home.split("/") + symlink = "/home-adh/%s" % (homesplit[-1],) if not login or not home: raise ValueError('Argument invalide') if home.startswith('/home/') and hostname == "zbee": @@ -66,6 +68,9 @@ class del_user: # La 512 est si un des paths n'exite pas. raise OSError(output) if os.path.isdir(home) and os.stat(home)[4] >= 500: + if homesplit[-2] != "club": + if os.path.exists(symlink) and os.path.islink(symlink): + os.unlink(symlink) shutil.rmtree(home) else: warn += '%s incorrect\n' % home @@ -111,11 +116,19 @@ class home: except ValueError: home, uid, login = args.split(',') mail_redirect = None + homesplit = home.split("/") + symlink = "/home-adh/%s" % (homesplit[-1],) ### Home if not os.path.exists(home): # Le home n'existe pas os.mkdir(home, 0755) os.chown(home, int(uid), config.gid) + if homesplit[-2] != "club": + if os.path.exists(symlink) and os.path.islink(symlink): + os.unlink(symlink) + else: + raise OSError("Lien symbolique existant : %s" % (symlink,)) + os.symlink(home, symlink) elif os.path.isdir(home): # Il y un répertoire existant # Bon UID ? @@ -123,6 +136,12 @@ class home: if stat[4] != int(uid) or stat[5] != config.gid: # Le home n'est pas pas à la bonne personne raise OSError('home existant') + if homesplit[-2] != "club": + if os.path.exists(symlink) and os.path.islink(symlink): + os.unlink(symlink) + else: + raise OSError("Lien symbolique existant : %s" % (symlink,)) + os.symlink(home, symlink) ### Quota status, output = commands.getstatusoutput('/usr/sbin/edquota -p 4539 %s' % uid )