Les homes ont changé de path

* On crée des liens symboliques
 * On les crée en dur au bon endroit.
 * Idem pour les suppressions
This commit is contained in:
Pierre-Elliott Bécue 2014-08-25 20:46:18 +02:00
parent 0cd6342912
commit dfa439467d

View file

@ -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 )