mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
fix postinstall
This commit is contained in:
parent
c16c9160b3
commit
8ca9f69691
2 changed files with 33 additions and 30 deletions
26
yunohost.py
26
yunohost.py
|
@ -277,17 +277,21 @@ class YunoHostLDAP(Singleton):
|
||||||
elif self.pwd:
|
elif self.pwd:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
need_password = True
|
try:
|
||||||
while need_password:
|
with open('/etc/yunohost/passwd') as f:
|
||||||
try:
|
self.pwd = f.read()
|
||||||
self.pwd = getpass.getpass(colorize(_('Admin Password: '), 'yellow'))
|
except IOError:
|
||||||
self.conn.simple_bind_s('cn=admin,' + self.base, self.pwd)
|
need_password = True
|
||||||
except KeyboardInterrupt, EOFError:
|
while need_password:
|
||||||
raise YunoHostError(125, _("Interrupted"))
|
try:
|
||||||
except ldap.INVALID_CREDENTIALS:
|
self.pwd = getpass.getpass(colorize(_('Admin Password: '), 'yellow'))
|
||||||
print(_('Invalid password... Try again'))
|
self.conn.simple_bind_s('cn=admin,' + self.base, self.pwd)
|
||||||
else:
|
except KeyboardInterrupt, EOFError:
|
||||||
need_password = False
|
raise YunoHostError(125, _("Interrupted"))
|
||||||
|
except ldap.INVALID_CREDENTIALS:
|
||||||
|
print(_('Invalid password... Try again'))
|
||||||
|
else:
|
||||||
|
need_password = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.conn.simple_bind_s('cn=admin,' + self.base, self.pwd)
|
self.conn.simple_bind_s('cn=admin,' + self.base, self.pwd)
|
||||||
|
|
33
yunohost.tac
33
yunohost.tac
|
@ -112,24 +112,23 @@ def http_exec(request, **kwargs):
|
||||||
raise YunoHostError(168, _('Function not yet implemented : ') + dict['function'].split('.')[1])
|
raise YunoHostError(168, _('Function not yet implemented : ') + dict['function'].split('.')[1])
|
||||||
|
|
||||||
# Execute requested function
|
# Execute requested function
|
||||||
with YunoHostLDAP(password=request.getPassword()):
|
try:
|
||||||
|
with open('/var/run/yunohost.pid', 'r'):
|
||||||
|
raise YunoHostError(1, _("A YunoHost command is already running"))
|
||||||
|
except IOError:
|
||||||
|
with open('/var/run/yunohost.pid', 'w') as f:
|
||||||
|
f.write('ldap')
|
||||||
|
os.system('chmod 400 /var/run/yunohost.pid')
|
||||||
|
with open('/etc/yunohost/passwd', 'w') as f:
|
||||||
|
f.write(request.getPassword())
|
||||||
|
os.system('chmod 400 /etc/yunohost/passwd')
|
||||||
try:
|
try:
|
||||||
with open('/var/run/yunohost.pid', 'r'):
|
result = func(**validated_args)
|
||||||
raise YunoHostError(1, _("A YunoHost command is already running"))
|
except KeyboardInterrupt, EOFError:
|
||||||
except IOError:
|
raise YunoHostError(125, _("Interrupted"))
|
||||||
with open('/var/run/yunohost.pid', 'w') as f:
|
finally:
|
||||||
f.write('ldap')
|
os.remove('/etc/yunohost/passwd')
|
||||||
os.system('chmod 400 /var/run/yunohost.pid')
|
os.remove('/var/run/yunohost.pid')
|
||||||
with open('/etc/yunohost/passwd', 'w') as f:
|
|
||||||
f.write(request.getPassword())
|
|
||||||
os.system('chmod 400 /etc/yunohost/passwd')
|
|
||||||
try:
|
|
||||||
result = func(**validated_args)
|
|
||||||
except KeyboardInterrupt, EOFError:
|
|
||||||
raise YunoHostError(125, _("Interrupted"))
|
|
||||||
finally:
|
|
||||||
os.remove('/etc/yunohost/passwd')
|
|
||||||
os.remove('/var/run/yunohost.pid')
|
|
||||||
if result is None:
|
if result is None:
|
||||||
result = {}
|
result = {}
|
||||||
if len(yunohost.win) > 0:
|
if len(yunohost.win) > 0:
|
||||||
|
|
Loading…
Add table
Reference in a new issue