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:
parent
0cd6342912
commit
dfa439467d
1 changed files with 19 additions and 0 deletions
|
@ -53,6 +53,8 @@ class del_user:
|
||||||
anim('\t' + args)
|
anim('\t' + args)
|
||||||
try:
|
try:
|
||||||
login, home = args.split(',')
|
login, home = args.split(',')
|
||||||
|
homesplit = home.split("/")
|
||||||
|
symlink = "/home-adh/%s" % (homesplit[-1],)
|
||||||
if not login or not home:
|
if not login or not home:
|
||||||
raise ValueError('Argument invalide')
|
raise ValueError('Argument invalide')
|
||||||
if home.startswith('/home/') and hostname == "zbee":
|
if home.startswith('/home/') and hostname == "zbee":
|
||||||
|
@ -66,6 +68,9 @@ class del_user:
|
||||||
# La 512 est si un des paths n'exite pas.
|
# La 512 est si un des paths n'exite pas.
|
||||||
raise OSError(output)
|
raise OSError(output)
|
||||||
if os.path.isdir(home) and os.stat(home)[4] >= 500:
|
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)
|
shutil.rmtree(home)
|
||||||
else:
|
else:
|
||||||
warn += '%s incorrect\n' % home
|
warn += '%s incorrect\n' % home
|
||||||
|
@ -111,11 +116,19 @@ class home:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
home, uid, login = args.split(',')
|
home, uid, login = args.split(',')
|
||||||
mail_redirect = None
|
mail_redirect = None
|
||||||
|
homesplit = home.split("/")
|
||||||
|
symlink = "/home-adh/%s" % (homesplit[-1],)
|
||||||
### Home
|
### Home
|
||||||
if not os.path.exists(home):
|
if not os.path.exists(home):
|
||||||
# Le home n'existe pas
|
# Le home n'existe pas
|
||||||
os.mkdir(home, 0755)
|
os.mkdir(home, 0755)
|
||||||
os.chown(home, int(uid), config.gid)
|
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):
|
elif os.path.isdir(home):
|
||||||
# Il y un répertoire existant
|
# Il y un répertoire existant
|
||||||
# Bon UID ?
|
# Bon UID ?
|
||||||
|
@ -123,6 +136,12 @@ class home:
|
||||||
if stat[4] != int(uid) or stat[5] != config.gid:
|
if stat[4] != int(uid) or stat[5] != config.gid:
|
||||||
# Le home n'est pas pas à la bonne personne
|
# Le home n'est pas pas à la bonne personne
|
||||||
raise OSError('home existant')
|
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
|
### Quota
|
||||||
status, output = commands.getstatusoutput('/usr/sbin/edquota -p 4539 %s' % uid )
|
status, output = commands.getstatusoutput('/usr/sbin/edquota -p 4539 %s' % uid )
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue