YunoHost-Apps / dokuwiki_ynh

Dokuwiki package for YunoHost
https://www.dokuwiki.org/dokuwiki
GNU General Public License v3.0
11 stars 16 forks source link

Permissions #64

Closed Gofannon closed 3 years ago

Gofannon commented 4 years ago

Problem

Solution

PR Status

Validation


When the PR is marked as ready to merge, you have to wait for 3 days before really merging it.

Gofannon commented 4 years ago

Error while upgrade is because of this on the CI: Warning: yunohost.hook <lambda> - [1188.1] rm: cannot remove 'vendor/easybook/geshi': Directory not empty

Piece of code related is here: https://github.com/YunoHost-Apps/dokuwiki_ynh/blob/testing/scripts/upgrade#L222

The file deleted.files can be found on the dokuwiki repo and there is a folder to remove vendor/easybook/geshi, not just files.

That's why rm complains. I will change rmoptions

So back to this comment I guess https://github.com/YunoHost-Apps/dokuwiki_ynh/pull/47/files/d884f346183ac63695ceee343266a2ac4ed5f776..dc6168a0e305ccceb9c8958ee1242ae923dba8c3#diff-44cb16c778719320333118c04d509a7c

maniackcrudelis commented 4 years ago

Maybe that helper may help you https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_secure_remove_regex/ynh_secure_remove_regex

Gofannon commented 4 years ago

After trying different permutations, I cannot make it run with ynh_secure_remove.


With this kind of code:

cd $final_path

#grep --extended-regexp --invert-match '^($|#)' data/deleted.files | xargs --max-args=1 rm --verbose --force --dir 2>&1 || true

grep --extended-regexp --invert-match '^($|#)' data/deleted.files | xargs --max-args=1 ynh_secure_remove --file 2>&1

#grep --null --extended-regexp --invert-match '^($|#)' data/deleted.files > toto.list
#xargs --null --verbose --max-args=1 --arg-file=toto.list ynh_secure_remove 2>&1

I always end up in the upgrade logs

2020-08-25 12:26:42,156: INFO - [##########+++.......] > Upgrading dokuwiki...
2020-08-25 12:26:42,157: DEBUG - + cd /var/www/dokuwiki
2020-08-25 12:26:42,158: DEBUG - + grep --extended-regexp --invert-match '^($|#)' data/deleted.files
2020-08-25 12:26:42,159: DEBUG - + xargs --max-args=1 ynh_secure_remove --file
2020-08-25 12:26:42,260: DEBUG - xargs: ynh_secure_remove: Aucun fichier ou dossier de ce type
2020-08-25 12:26:42,261: DEBUG - + ynh_exit_properly
2020-08-25 12:26:42,263: DEBUG - + local exit_code=127
2020-08-25 12:26:42,264: DEBUG - + '[' 127 -eq 0 ']'

Extract of man xargs

   xargs exits with the following status:
   0 if it succeeds
   123 if any invocation of the command exited with status 1-125
   124 if the command exited with status 255
   125 if the command is killed by a signal
   126 if the command cannot be run
   127 if the command is not found
   1 if some other error occurred.

After searching, I found this : https://github.com/koalaman/shellcheck/wiki/SC2033

So, I guess, i's not possible to do it easily ?

I'm out of ideas and will switch back to rm -rf. As the input list is provided by DokuWiki itself, it should be trusted IMO.

( I spent too much time on this... )

Gofannon commented 4 years ago

Can be reviewed

Test passed on https://ci-apps-dev.yunohost.org/jenkins/job/dokuwiki_ynh%20(gofannon)/2/console which is running debian buster

Gofannon commented 4 years ago

After discussing with Alex, the way to manage the new permissions is not ready yet. PR on hold until decision has been made