From 55dc710d4edcc8e809857d41c245204de3484208 Mon Sep 17 00:00:00 2001 From: Kload Date: Fri, 1 Mar 2013 18:24:37 +0100 Subject: [PATCH] lemon stuffs --- yunohost_app.py | 26 ++++++++++++++++++++++++++ yunohost_domain.py | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/yunohost_app.py b/yunohost_app.py index 9e8ecbec..ce0d42cc 100644 --- a/yunohost_app.py +++ b/yunohost_app.py @@ -16,6 +16,7 @@ apps_setting_path= '/etc/yunohost/apps/' a2_settings_path = '/etc/yunohost/apache/domains/' install_tmp = '/tmp/yunohost/install' app_tmp_folder = install_tmp + '/from_file' +lemon_tmp_conf = '/tmp/tmplemonconf' def app_listlists(): """ @@ -226,6 +227,31 @@ def app_install(app, domain, path='/', label=None, mode='private'): for line in a2_conf_lines: file.write(line + '\n') + lemon_mode = 'accept' + + if 'access_control' in manifest['yunohost']['webapp']: + if mode == 'public' and 'can_be_public' in manifest['yunohost']['webapp']['access_control'] and (manifest['yunohost']['webapp']['access_control']['can_be_public'] == 'yes' or manifest['yunohost']['webapp']['access_control']['can_be_public'] == 'true'): + lemon_mode = 'skip' + elif mode == 'protected' and 'can_be_protected' in manifest['yunohost']['webapp']['access_control'] and (manifest['yunohost']['webapp']['access_control']['can_be_protected'] == 'yes' or manifest['yunohost']['webapp']['access_control']['can_be_protected'] == 'true'): + lemon_mode = 'unprotect' + else: + raise YunoHostError(22, _("Invalid privacy mode")) + + if os.path.exists(lemon_tmp_conf): os.remove(lemon_tmp_conf) + + lemon_conf_lines = [ + "$tmp->{'locationRules'}->{'"+ domain +"'}->{'(?#"+ unique_app_id +"Z)^"+ path +"'} = '"+ lemon_mode +"';" + ] + + with open(lemon_tmp_conf,'w') as lemon_conf: + for line in lemon_conf_lines: + lemon_conf.write(line + '\n') + + if os.system('/usr/share/lemonldap-ng/bin/lmYnhMoulinette') == 0: + win_msg(_("LemonLDAP configured")) + else: + raise YunoHostError(1, _("An error occured during LemonLDAP configuration")) + # Copy files to the right place try: os.listdir(apps_path) diff --git a/yunohost_domain.py b/yunohost_domain.py index 8be98ca3..f8d182d8 100644 --- a/yunohost_domain.py +++ b/yunohost_domain.py @@ -222,7 +222,7 @@ def _lemon_config(domain): "$tmp->{'locationRules'}->{'"+ domain +"'}->{'(?#logout)^/logout'} = 'logout_app_sso https://"+ domain +"/';", ] - with open(lemon_tmp_conf,'a') as lemon_conf: + with open(lemon_tmp_conf,'w') as lemon_conf: for line in lemon_conf_lines: lemon_conf.write(line + '\n')