diff --git a/yunohost_app.py b/yunohost_app.py index 26e5e2b6..f407ac02 100644 --- a/yunohost_app.py +++ b/yunohost_app.py @@ -221,6 +221,7 @@ def app_map(app=None, raw=False): 'label': app_settings['label'], 'uid': app_settings['uid'], 'instance': app_settings['instance'], + 'mode': app_settings['mode'], } else: result['https://'+app_settings['domain']+app_settings['path']] = app_settings['label'] @@ -327,12 +328,13 @@ def app_upgrade(app, instance=[], url=None, file=None): ######################################### # TMP: Remove old application - if os.path.exists(app_final_path): shutil.rmtree(app_final_path) + # if os.path.exists(app_final_path): shutil.rmtree(app_final_path) os.system('cp -a "'+ app_tmp_folder +'" "'+ app_final_path +'"') if is_web: - os.system('chown -R www-data: "'+ app_final_path +'"') + if manifest['type'] != 'privileged' and manifest['type'] != 'certified': + os.system('chown -R www-data: "'+ app_final_path +'"') os.system('service apache2 reload') shutil.rmtree(app_final_path + manifest['yunohost']['script_path']) @@ -407,6 +409,9 @@ def app_install(app, domain, path='/', label=None, mode='private'): if app_path in path and app_path.count('/') < path.count('/'): raise YunoHostError(1, _("Unable to install app at this location")) + if path != '/' and lvl(manifest, 'yunohost', 'webapp', 'domain_root_only') and is_true(manifest['yunohost']['domain_root_only']): + raise YunoHostError(1, _("App must be installed to domain root")) + ########################################## # Fetch or extract sources # @@ -511,21 +516,24 @@ def app_install(app, domain, path='/', label=None, mode='private'): ########## # Apache # ########## + + if lvl(manifest,'yunohost','webapp','custom_apache_conf'): + os.system('mv '+app_tmp_folder+'/'+manifest['yunohost']['webapp']['custom_apache_conf']+' '+a2_settings_path +'/'+ domain +'.d/'+ unique_app_id +'.app.conf') + else: + a2_conf_lines = [ 'Alias '+ path +' '+ app_final_path + manifest['launch_path'] ] + if path != '/': + a2_conf_lines.append('Alias '+ path[:len(path)-1] +' '+ app_final_path + manifest['launch_path']) - a2_conf_lines = [ 'Alias '+ path +' '+ app_final_path + manifest['launch_path'] ] - if path != '/': - a2_conf_lines.append('Alias '+ path[:len(path)-1] +' '+ app_final_path + manifest['launch_path']) + a2_conf_lines.append('') - a2_conf_lines.append('') + if lvl(manifest, 'yunohost', 'webapp', 'language') and manifest['yunohost']['webapp']['language'] == 'php': + for line in open(a2_template_path +'/php.conf'): a2_conf_lines.append(line.rstrip()) - if lvl(manifest, 'yunohost', 'webapp', 'language') and manifest['yunohost']['webapp']['language'] == 'php': - for line in open(a2_template_path +'/php.conf'): a2_conf_lines.append(line.rstrip()) + a2_conf_lines.append('') - a2_conf_lines.append('') - - with open(a2_settings_path +'/'+ domain +'.d/'+ unique_app_id +'.app.conf', 'w') as a2_conf: - for line in a2_conf_lines: - a2_conf.write(line + '\n') + with open(a2_settings_path +'/'+ domain +'.d/'+ unique_app_id +'.app.conf', 'w') as a2_conf: + for line in a2_conf_lines: + a2_conf.write(line + '\n') ######################################### @@ -536,12 +544,13 @@ def app_install(app, domain, path='/', label=None, mode='private'): except OSError: os.makedirs(apps_path) # TMP: Remove old application - if os.path.exists(app_final_path): shutil.rmtree(app_final_path) + # if os.path.exists(app_final_path): shutil.rmtree(app_final_path) os.system('cp -a "'+ app_tmp_folder +'" "'+ app_final_path +'"') if is_web: - os.system('chown -R www-data: "'+ app_final_path +'"') + if manifest['type'] != 'privileged' and manifest['type'] != 'certified': + os.system('chown -R www-data: "'+ app_final_path +'"') os.system('service apache2 reload') shutil.rmtree(app_final_path + manifest['yunohost']['script_path']) diff --git a/yunohost_user.py b/yunohost_user.py index 916b409d..3005caf8 100644 --- a/yunohost_user.py +++ b/yunohost_user.py @@ -72,10 +72,11 @@ def user_list(fields=None, filter=None, limit=None, offset=None): entry = { 'Username': user['uid'][0], 'Fullname': user['cn'][0], - 'Mail': user['mail'][0] } - if len(user['mail']) > 1: - entry['Mail Aliases'] = user['mail'][1:] + if 'mail' in user.keys(): + entry['Mail'] = user['mail'][0] + if len(user['mail']) > 1: + entry['Mail Aliases'] = user['mail'][1:] if 'maildrop' in user: entry['Mail Forward'] = user['maildrop'] @@ -194,7 +195,7 @@ def user_update(username, firstname=None, lastname=None, mail=None, change_passw new_attr_dict['cn'] = new_attr_dict['displayName'] = firstname + ' ' + lastname if change_password: - pwd_changed = os.system('echo "'+ password +'\n'+ password +'" | smbldap-passwd '+ username) + pwd_changed = os.system('echo "'+ change_password +'\n'+ change_password +'" | smbldap-passwd '+ username) if pwd_changed > 0: raise YunoHostError(169, _("An error occured during password update"))