From 07324cbc85293ef8d9db0c9e906ce9d9f104d8b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 4 Jul 2021 16:03:50 +0200 Subject: [PATCH] 4.8.1 (#15) * 4.8.1 --- .github/ISSUE_TEMPLATE.md | 55 + .github/PULL_REQUEST_TEMPLATE.md | 16 + check_process | 11 +- manifest.json | 2 +- pull_request_template.md | 16 - scripts/install | 29 +- scripts/restore | 27 +- scripts/upgrade | 72 +- sources/root_access_disabled/adminer.php | 1257 +++++++++++----------- sources/with_root_access/index.php | 1257 +++++++++++----------- 10 files changed, 1402 insertions(+), 1340 deletions(-) create mode 100644 .github/ISSUE_TEMPLATE.md create mode 100644 .github/PULL_REQUEST_TEMPLATE.md delete mode 100644 pull_request_template.md diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..2729a6b --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* + - *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +### Describe the bug + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install the_app + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '...'* + 3. *Scroll down to '...'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..ef70e18 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,16 @@ +## Problem + +- *Description of why you made this PR* + +## Solution + +- *And how do you fix that problem* + +## PR Status + +- [ ] Code finished and ready to be reviewed/tested +- [ ] The fix/enhancement were manually tested (if applicable) + +## Automatic tests + +Automatic tests can be triggered on https://ci-apps-dev.yunohost.org/ *after creating the PR*, by commenting "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!". (N.B. : for this to work you need to be a member of the Yunohost-Apps organization) diff --git a/check_process b/check_process index 44c97a8..26f0c64 100644 --- a/check_process +++ b/check_process @@ -1,13 +1,9 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - ;; Test complet ; Manifest - domain="domain.tld" (DOMAIN) - path="/path" (PATH) + domain="domain.tld" + path="/path" root_access=0 - is_public=1 (PUBLIC|public=1|private=0) - + is_public=1 ; Checks pkg_linter=1 setup_sub_dir=1 @@ -18,7 +14,6 @@ upgrade=1 backup_restore=1 multi_instance=1 - port_already_use=0 change_url=1 ;;; Options Email= anmol@datamol.org diff --git a/manifest.json b/manifest.json index 9e8a926..a72a78c 100644 --- a/manifest.json +++ b/manifest.json @@ -21,7 +21,7 @@ "url": "https://github.com/jesuisfol/adminer_ynh" }, "requirements": { - "yunohost": ">= 4.1.7" + "yunohost": ">= 4.2.4" }, "multi_instance": true, "services": [ diff --git a/pull_request_template.md b/pull_request_template.md deleted file mode 100644 index 6c28fc5..0000000 --- a/pull_request_template.md +++ /dev/null @@ -1,16 +0,0 @@ -## Problem -- *Description of why you made this PR* - -## Solution -- *And how do you fix that problem* - -## PR Status -- [ ] Code finished. -- [ ] Tested with Package_check. -- [ ] Fix or enhancement tested. -- [ ] Upgrade from last version tested. -- [ ] Can be reviewed and tested. - -## Package_check results ---- -* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/install b/scripts/install index 0c7f432..667f176 100644 --- a/scripts/install +++ b/scripts/install @@ -45,6 +45,14 @@ ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=root_access --value=$root_access +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." --weight=2 + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -63,23 +71,10 @@ if [[ $root_access -eq 1 ]]; then cp -a ../sources/root_access_disabled/. $final_path fi -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=2 - -# Create a system user -ynh_system_user_create --username=$app - -#================================================= -# GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions to app files -chown -R www-data:www-data $final_path -chmod 755 -R $final_path/adminer.php +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +chmod 755 $final_path/adminer.php #================================================= # NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index 579cde3..16ba223 100644 --- a/scripts/restore +++ b/scripts/restore @@ -46,6 +46,14 @@ test ! -d $final_path \ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -53,21 +61,10 @@ ynh_script_progression --message="Restoring Adminer main directory..." --weight= ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=2 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= - -# Restore permissions to app files -chown -R www-data:www-data $final_path -chmod 755 -R $final_path/adminer.php +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +chmod 755 $final_path/adminer.php #================================================= # RESTORE THE PHP-FPM CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 53faa4c..c3adec7 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,6 +22,26 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) root_access=$(ynh_app_setting_get --app=$app --key=root_access) phpversion=$(ynh_app_setting_get --app=$app --key=phpversion) +#================================================= +# CHECK VERSION +#================================================= + +upgrade_type=$(ynh_check_app_version_changed) + +#================================================= +# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP +#================================================= +ynh_script_progression --message="Backing up Adminer before upgrading (may take a while)..." --weight=3 + +# Backup the current version of the app +ynh_backup_before_upgrade +ynh_clean_setup () { + # restore it if the upgrade fails + ynh_restore_upgradebackup +} +# Exit if an error occurs during the execution of the script +ynh_abort_if_errors + #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= @@ -40,48 +60,38 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up Adminer before upgrading (may take a while)..." --weight=3 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # CREATE DEDICATED USER #================================================= ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 # Create a dedicated user (if not existing) -ynh_system_user_create --username=$app +ynh_system_user_create --username=$app --home_dir="$final_path" -# Copy source files -ynh_secure_remove $final_path +#================================================= +# DOWNLOAD, CHECK AND UNPACK SOURCE +#================================================= -mkdir -p $final_path +if [ "$upgrade_type" == "UPGRADE_APP" ] +then + # Copy source files + ynh_secure_remove $final_path -if [[ $root_access -eq 1 ]]; then -#copy files from with_root_access folder to the final_path - cp -a ../sources/with_root_access/. $final_path - else - #copy files from root_access_disabled folder to the final_path - cp -a ../sources/root_access_disabled/. $final_path + mkdir -p $final_path + + if [[ $root_access -eq 1 ]]; then + #copy files from with_root_access folder to the final_path + cp -a ../sources/with_root_access/. $final_path + else + #copy files from root_access_disabled folder to the final_path + cp -a ../sources/root_access_disabled/. $final_path + fi fi -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= - -# Set permissions to app files -chmod 755 -R $final_path/adminer.php -chown -R www-data:www-data $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R $app:www-data "$final_path" +chmod 755 $final_path/adminer.php #================================================= # NGINX CONFIGURATION diff --git a/sources/root_access_disabled/adminer.php b/sources/root_access_disabled/adminer.php index b9ce4d0..762aaaf 100644 --- a/sources/root_access_disabled/adminer.php +++ b/sources/root_access_disabled/adminer.php @@ -5,56 +5,56 @@ * @copyright 2007 Jakub Vrana * @license https://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0 * @license https://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other) -* @version 4.8.0 +* @version 4.8.1 */function -adminer_errors($Ac,$Cc){return!!preg_match('~^(Trying to access array offset on value of type null|Undefined array key)~',$Cc);}error_reporting(6135);set_error_handler('adminer_errors',2);$Yc=!preg_match('~^(unsafe_raw)?$~',ini_get("filter.default"));if($Yc||ini_get("filter.default_flags")){foreach(array('_GET','_POST','_COOKIE','_SERVER')as$X){$Hi=filter_input_array(constant("INPUT$X"),FILTER_UNSAFE_RAW);if($Hi)$$X=$Hi;}}if(function_exists("mb_internal_encoding"))mb_internal_encoding("8bit");function +adminer_errors($Cc,$Ec){return!!preg_match('~^(Trying to access array offset on value of type null|Undefined array key)~',$Ec);}error_reporting(6135);set_error_handler('adminer_errors',E_WARNING);$ad=!preg_match('~^(unsafe_raw)?$~',ini_get("filter.default"));if($ad||ini_get("filter.default_flags")){foreach(array('_GET','_POST','_COOKIE','_SERVER')as$X){$Ii=filter_input_array(constant("INPUT$X"),FILTER_UNSAFE_RAW);if($Ii)$$X=$Ii;}}if(function_exists("mb_internal_encoding"))mb_internal_encoding("8bit");function connection(){global$g;return$g;}function adminer(){global$b;return$b;}function version(){global$ia;return$ia;}function -idf_unescape($v){$pe=substr($v,-1);return -str_replace($pe.$pe,$pe,substr($v,1,-1));}function +idf_unescape($v){if(!preg_match('~^[`\'"]~',$v))return$v;$qe=substr($v,-1);return +str_replace($qe.$qe,$qe,substr($v,1,-1));}function escape_string($X){return substr(q($X),1,-1);}function number($X){return preg_replace('~[^0-9]+~','',$X);}function number_type(){return'((?$W){unset($sg[$z][$ge]);if(is_array($W)){$sg[$z][stripslashes($ge)]=$W;$sg[]=&$sg[$z][stripslashes($ge)];}else$sg[$z][stripslashes($ge)]=($Yc?$W:stripslashes($W));}}}}function -bracket_escape($v,$Na=false){static$ti=array(':'=>':1',']'=>':2','['=>':3','"'=>':4');return -strtr($v,($Na?array_flip($ti):$ti));}function -min_version($Yi,$Ce="",$h=null){global$g;if(!$h)$h=$g;$mh=$h->server_info;if($Ce&&preg_match('~([\d.]+)-MariaDB~',$mh,$C)){$mh=$C[1];$Yi=$Ce;}return(version_compare($mh,$Yi)>=0);}function +remove_slashes($tg,$ad=false){if(function_exists("get_magic_quotes_gpc")&&get_magic_quotes_gpc()){while(list($z,$X)=each($tg)){foreach($X +as$he=>$W){unset($tg[$z][$he]);if(is_array($W)){$tg[$z][stripslashes($he)]=$W;$tg[]=&$tg[$z][stripslashes($he)];}else$tg[$z][stripslashes($he)]=($ad?$W:stripslashes($W));}}}}function +bracket_escape($v,$Na=false){static$ui=array(':'=>':1',']'=>':2','['=>':3','"'=>':4');return +strtr($v,($Na?array_flip($ui):$ui));}function +min_version($Zi,$De="",$h=null){global$g;if(!$h)$h=$g;$nh=$h->server_info;if($De&&preg_match('~([\d.]+)-MariaDB~',$nh,$C)){$nh=$C[1];$Zi=$De;}return(version_compare($nh,$Zi)>=0);}function charset($g){return(min_version("5.5.3",0,$g)?"utf8mb4":"utf8");}function -script($xh,$si="\n"){return"$xh$si";}function -script_src($Mi){return"\n";}function +script($yh,$ti="\n"){return"$yh$ti";}function +script_src($Ni){return"\n";}function nonce(){return' nonce="'.get_nonce().'"';}function target_blank(){return' target="_blank" rel="noreferrer noopener"';}function h($P){return str_replace("\0","�",htmlspecialchars($P,ENT_QUOTES,'utf-8'));}function nl_br($P){return str_replace("\n","
",$P);}function -checkbox($D,$Y,$db,$le="",$tf="",$hb="",$me=""){$I="".($tf?script("qsl('input').onclick = function () { $tf };",""):"");return($le!=""||$hb?"$I".h($le)."":$I);}function -optionlist($zf,$fh=null,$Qi=false){$I="";foreach($zf -as$ge=>$W){$_f=array($ge=>$W);if(is_array($W)){$I.='';$_f=$W;}foreach($_f -as$z=>$X)$I.=''.h($X);if(is_array($W))$I.='';}return$I;}function -html_select($D,$zf,$Y="",$sf=true,$me=""){if($sf)return"".(is_string($sf)?script("qsl('select').onchange = function () { $sf };",""):"");$I="";foreach($zf +checkbox($D,$Y,$db,$me="",$uf="",$hb="",$ne=""){$I="".($uf?script("qsl('input').onclick = function () { $uf };",""):"");return($me!=""||$hb?"$I".h($me)."":$I);}function +optionlist($_f,$gh=null,$Ri=false){$I="";foreach($_f +as$he=>$W){$Af=array($he=>$W);if(is_array($W)){$I.='';$Af=$W;}foreach($Af +as$z=>$X)$I.=''.h($X);if(is_array($W))$I.='';}return$I;}function +html_select($D,$_f,$Y="",$tf=true,$ne=""){if($tf)return"".(is_string($tf)?script("qsl('select').onchange = function () { $tf };",""):"");$I="";foreach($_f as$z=>$X)$I.="";return$I;}function -select_input($Ia,$zf,$Y="",$sf="",$eg=""){$Xh=($zf?"select":"input");return"<$Xh$Ia".($zf?">