From ea879356a598576953dac377ffc736b8228743dc Mon Sep 17 00:00:00 2001 From: Kayou Date: Sun, 3 Mar 2019 20:45:02 +0100 Subject: [PATCH 1/3] User is used instead of www-data --- conf/systemd.service | 3 ++- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index f7517e1..b489e29 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -6,7 +6,8 @@ After=network.target [Service] Type=simple -User=www-data +User=__APP__ +Group=__APP__ RemainAfterExit=yes Restart=always RestartSec=10 diff --git a/scripts/install b/scripts/install index 6ddf10b..752d45a 100644 --- a/scripts/install +++ b/scripts/install @@ -195,7 +195,7 @@ fi # Configure owner #================================================= -chown -R www-data $final_path +chown -R $app:$app "$final_path" #================================================= # Start lstu diff --git a/scripts/restore b/scripts/restore index ff4b7c1..dca01b3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -91,7 +91,7 @@ ynh_psql_connect_as $db_name $db_pwd $db_name < ./db.sql #================================================= # Restore permissions on app files -chown -R www-data $final_path +chown -R $app:$app "$final_path" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 9ac91ee..2549c05 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -153,7 +153,7 @@ ynh_store_file_checksum "${final_path}/lstu.conf" # SECURING FILES AND DIRECTORIES #================================================= -chown -R www-data $final_path +chown -R $app:$app "$final_path" #================================================= # SETUP SYSTEMD From 4b906ee1c91a6d4956a16940173898a16a8e8b54 Mon Sep 17 00:00:00 2001 From: Kayou Date: Fri, 8 Mar 2019 21:50:41 +0100 Subject: [PATCH 2/3] Fix public/private --- scripts/actions/public_private | 14 ++++++++++---- scripts/change_url | 17 +++++++++++++++++ scripts/install | 16 ++++++++++------ scripts/upgrade | 16 ++++++++++------ 4 files changed, 47 insertions(+), 16 deletions(-) diff --git a/scripts/actions/public_private b/scripts/actions/public_private index 34ea183..b06a9c0 100755 --- a/scripts/actions/public_private +++ b/scripts/actions/public_private @@ -76,10 +76,16 @@ else public_private="public" fi -ynh_app_setting_set $app unprotected_uris "/" -if [ $is_public -eq 0 ]; -then # If the app is private, only the shortened URLs are publics - ynh_app_setting_set $app protected_regex "/login$","/logout$","/api$","/extensions$","/stats$","/d/.*$","/a$","/$" +if [ $is_public -eq 0 ] +then + # If the app is private, only the shortened URLs are publics. + if [ "$path_url" == "/" ]; then + # If the path is /, clear it to prevent any error with the regex. + path_url="" + fi + # Modify the domain to be used in a regex + domain_regex=$(echo "$domain" | sed 's@-@.@g') + ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" else ynh_app_setting_delete $app protected_regex fi diff --git a/scripts/change_url b/scripts/change_url index 86b8c45..ba5ab9d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -127,6 +127,23 @@ ynh_store_file_checksum "${final_path}/lstu.conf" #================================================= # GENERIC FINALISATION +#================================================= +# UPDATE SSOWAT +#================================================= +ynh_print_info "Reconfigure SSOwat" + +if [ $is_public -eq 0 ] +then + # If the app is private, only the shortened URLs are publics. + if [ "$path_url" == "/" ]; then + # If the path is /, clear it to prevent any error with the regex. + path_url="" + fi + # Modify the domain to be used in a regex + domain_regex=$(echo "$domain" | sed 's@-@.@g') + ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" +fi + #================================================= # RESTART LSTU #================================================= diff --git a/scripts/install b/scripts/install index 752d45a..6443ee8 100644 --- a/scripts/install +++ b/scripts/install @@ -182,13 +182,17 @@ yunohost service add $app --log "/var/log/$app.log" --log "/var/www/$app/log/pro #================================================= ynh_print_info "Configuring SSOwat..." -# Make app public or private ynh_app_setting_set $app unprotected_uris "/" -if [ $is_public -eq 0 ]; -then # If the app is private, only the shortened URLs are publics - ynh_app_setting_set $app protected_regex "/login$","/logout$","/api$","/extensions$","/stats$","/d/.*$","/a$","/$" -else - ynh_app_setting_delete $app protected_regex +if [ $is_public -eq 0 ] +then + # If the app is private, only the shortened URLs are publics. + if [ "$path_url" == "/" ]; then + # If the path is /, clear it to prevent any error with the regex. + path_url="" + fi + # Modify the domain to be used in a regex + domain_regex=$(echo "$domain" | sed 's@-@.@g') + ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" fi #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 2549c05..7f92867 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -196,13 +196,17 @@ ynh_systemd_action -n $app -a reload -l "Reloaded Shortened URLs service." -p "s #================================================= ynh_print_info "Upgrading SSOwat configuration..." -# Make app public or private ynh_app_setting_set $app unprotected_uris "/" -if [ $is_public -eq 0 ]; -then # If the app is private, only the shortened URLs are publics - ynh_app_setting_set $app protected_regex "/login$","/logout$","/api$","/extensions$","/stats$","/d/.*$","/a$","/$" -else - ynh_app_setting_delete $app protected_regex +if [ $is_public -eq 0 ] +then + # If the app is private, only the shortened URLs are publics. + if [ "$path_url" == "/" ]; then + # If the path is /, clear it to prevent any error with the regex. + path_url="" + fi + # Modify the domain to be used in a regex + domain_regex=$(echo "$domain" | sed 's@-@.@g') + ynh_app_setting_set $app protected_regex "$domain_regex$path_url/login$","$domain_regex$path_url/logout$","$domain_regex$path_url/api$","$domain_regex$path_url/extensions$","$domain_regex$path_url/stats$","$domain_regex$path_url/d/.*$","$domain_regex$path_url/a$","$domain_regex$path_url/$" fi #================================================= From f358aace5a6fb1174abaf11951f6e2728abcf9a2 Mon Sep 17 00:00:00 2001 From: Kayou Date: Tue, 12 Mar 2019 16:16:17 +0100 Subject: [PATCH 3/3] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index db9b7e8..3c95efc 100644 --- a/manifest.json +++ b/manifest.json @@ -2,7 +2,7 @@ "name": "Lstu", "id": "lstu", "packaging_format": 1, - "version": "0.21-4~ynh3", + "version": "0.21-4~ynh4", "requirements": { "yunohost": ">= 3.0" },