Unable to uninstall plugins

Unable to uninstall plugins

by Keith Blundy -
Number of replies: 25

I'm having a really weird issue I have a plugin I need to uninstall in this case it's the navbuttons plugin.

When I initiate an uninstall via Admin>plugins>plugin overview I get this error:

Forbidden

You don't have permission to access this resource.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

Any ideas about what is going on? Is this a server-side issue - if so what do I need to look at changing?
Any help or pointers would be greatly appreciated.

Keith

Average of ratings: -
In reply to Keith Blundy

Re: Unable to uninstall plugins

by Ken Task -
Picture of Particularly helpful Moodlers

What are ownerships and permissions on the navbuttons directory in the 'blocks' directory?   For that matter what are ownerships/permissions on 'blocks'?

If you can't un-install via web interface, do you have any access or tool to browse files?

If you do, you could check ownerships/permissions with that tool as well as possibly erase the directory.   Then go visit Plugins area Addons ... should see 'missing from disk' and if you click 'Upgrade database' that should remove related tables or rows in config tables for the addon.

'SoS', Ken

 

In reply to Ken Task

Re: Unable to uninstall plugins

by Keith Blundy -
Thanks Ken - folders are 755 and files 644 across the install. Still can't uninstall anything.
In reply to Keith Blundy

Re: Unable to uninstall plugins

by Ken Task -
Picture of Particularly helpful Moodlers

So you have no other access to your site other than moodle that would/could browse files and have ability to change ownerships/permissions?  cPanel file browser?  or cPanel Terminal?

755 means read and execute access for everyone and also write access for the owner of the file
644 - owner can read/write, group/others can read only.

So who (what user) owns the plugin directory?

For you to be able to use web interface, to work with installing and un-installing plugins, that web interface user must have permissions to do so.

'SoS', Ken

In reply to Ken Task

Re: Unable to uninstall plugins

by Keith Blundy -
HI Ken - the permissions were checked with the file manager inside my cpanel as I host the moodle platform
On Moodle, I am the System Administrator. The issue isn't just with that one plugin - although it was the one I discovered it with. I can't uninstall anything.
In reply to Ken Task

Re: Unable to uninstall plugins

by aziz vefa -
Hi. I'm having the same problem because of Reengagement Plugin.
I'm using 3.11 and installed Reengagement 3.6.5
It caused some problems so first I disabled it. Then I deleted the activity from my course but it still seems in the course completion list even if it's not in the course completion settings.
Now, I'm trying to uninstall it but the system returns the error below.
Forbidden
You don't have permission to access this resource.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

I try that with the admin role but it doesn't let me remove it. I deleted the folder via file manager, under the moodle installation, then the course completion settings were affected and I couldn't see any user status.
What should I do?
Thank you.
In reply to aziz vefa

Re: Unable to uninstall plugins

by Ken Task -
Picture of Particularly helpful Moodlers

@aziz vefa

Probably not a good idea to piggyback even if the issue sounds the same ... in a general sense, might be, but not ... much depends upon hosting and access.

Having said that ...

What directory did you manually remove from code?
Go to: /admin/plugins.php?updatesonly=0&contribonly=1
is it listed still?   Say missing from disk?

If you see an update database button, go ahead and click it! smile

Take it that's where you are trying to un-install.
The directory 'reengagement' is in mod when installed.
What are ownerships/permissions on the mod directory, recursively?

'SoS', Ken


In reply to aziz vefa

Re: Unable to uninstall plugins

by Ken Task -
Picture of Particularly helpful Moodlers

Follow up for @aziz

If one cannot remove the plugin via web interface the alt is to manually remove ... you've done the code directory removal, but not the DB ... which is normally done by clicking that 'update' button.

This is risky ... so make a backup of your DB before using phpMyAdmin to manually remove references to the reengagement plugin..

There are 2 tables in DB
mdl_reengagement
mdl_reengagement_inprogress

Plus there are listings in
mdl_config_plugins

Might want to see what's in mdl_reengagement_inprogress first as that has course ID's in it.

Risky fix:

drop the 2 tables related.

remove the rows in mdl_config_plugins that reference the plugin.

Have a feeling that other completion tables might reference the reengaement ... those tables are:

| mdl_course_completion_aggr_methd   |
| mdl_course_completion_crit_compl   |
| mdl_course_completion_criteria     |
| mdl_course_completion_defaults     |
| mdl_course_completions             |
| mdl_course_modules_completion

You might have to be very careful and remove rows in one or more of the tables. mdl_course_modules_completion might be a good place to start.

Have to say this ... not responsible for a 'train wreck' that might occur as a result of this advice!   Sorry! sad

Comment: back when it started to give you issues, removal at that time (rather than hiding) might have been easier than now.   Think it always a good site admin policy not to keep addons you don't use as they could bite on updates/upgrades, etc. in future.   And, always a good idea to have a development instance of your moodle for tinkering purposes ... so you could try out 'risky' things there first!

'SoS', Ken

Average of ratings: Useful (1)
In reply to aziz vefa

Re: Unable to uninstall plugins

by Wynand Louw -
I had the same issue. In the end, we found a Modsecurity rule was blocking these uninstall requests and the VPS provider has whitelisted the domain for my Moodle hosting site on the VPS.
Average of ratings: Useful (2)
In reply to Wynand Louw

Re: Unable to uninstall plugins

by Ken Task -
Picture of Particularly helpful Moodlers

@Wynand ...

What is meant by 'whitelisted the domain for my Moodle hosting site on the VPS'?    Does that mean no traffic headed to your moodle is checked by mod_security?

Hope you have installed moodle and maintain moodle with Git as that would allow you to acquire updates/fixes which are not only code fixes but security updates as well.

Just a few minutes ago git updated a 3.11 to highest

3.11.11+ (Build: 20221229)

mod_security could also run in detection mode only
meaning it will log but not block/prohibit.

What it logs then one can see the rule tripped and allow the rule for that domain and then allow an exeception for that rule.

mod_security log showed no complaints.

I also installed then un-installed mod_reengagement.   mod_security did not complain there either.   Did notice, however, that during the un-install, the warning about 'must manually remove the mod_reengagement directory or moodle would try to reinstall it'.

Now a days ... probably a good idea to purge all caches when performing many admin activities/things.

@Keith's screen is an apache error screen ... and strongly suggest ownerships/permissions issue.   While mod_security could have a false redirect for the tripped rule that showed access denied many times it's just a loop back.

@aziz has attempted to un-install manually which could then lead to manual manipulation of the tables related.

And this thread is yet again an example as to why it's not always a good idea to 'piggy back' .. similar problem doesn't always have same resolution and a thread like this could confuse folks!

Anyhoo ... my 2 cents?

'SoS', Ken

In reply to Ken Task

Re: Unable to uninstall plugins

by aziz vefa -
Hi Ken,
Thank you for your support but I don't have enough knowledge to do such things.
I hope uninstalling the plugin via server support fixed the problem.
Regards,
Happy new year to all.
In reply to Ken Task

Re: Unable to uninstall plugins

by Wynand Louw -
Ken, it was an issue in a different discussion https://moodle.org/mod/forum/discuss.php?d=419453#p1744754

The suggestion was the VPS provider did not have Modsecurity activated on the server. Which was exactly the issue that resolved the problem.

They had to whitelist the domain that has moodle installed to enable Modsecurity to work for the uninstall since as admin I could install plugins but not uninstall plugins.
In reply to Wynand Louw

Re: Unable to uninstall plugins

by Ken Task -
Picture of Particularly helpful Moodlers

I see you linked to one of my responses.    Knew I had done that, but couldn't remember where ... specifically! :|

But ... I don't get it ...

"They had to whitelist the domain that has moodle installed to enable Modsecurity to work for the uninstall since as admin I could install plugins but not uninstall plugins."

Doesn't that seem kinda weird ... can install but cannot uninstall.

Am thinking then that 'malware' has potential to get installed.   If admin discovers, admin cannot un-install???1!!

 Ok, guess it's just my faulty logic ...

'SoS', Ken

In reply to Wynand Louw

Re: Unable to uninstall plugins

by aziz vefa -
Hi Wynand,

I requested the same procedure from my VPS provider, they found the correct rule, disabled it, and uninstalled the plugin. Thank you.
In reply to Keith Blundy

Re: Unable to uninstall plugins

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

What version of Moodle is this? And can you tell us about the web server, is it Apache or something else? Is the server Linux or Microsoft Windows or something else?

Also, when you get the error what's the URL of the page? You don't have to share the full address, just the bit after the first slash. It might be something like /admin/plugins.php?uninstall=block_navbuttons&confirm=0&return=overview.

Is the error is happening immediately after clicking Uninstall? Or do you see the Confirm page first? If it's the former, I don't think it's a permissions problem, Moodle should make the database changes before trying to remove the plugin files. And anyway, if it can't remove them it should tell you to remove them manually.

In reply to Leon Stringer

Re: Unable to uninstall plugins

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Is there some WAF running on the server, such as ModSecurity? This has caused unexpected 403 Forbidden messages for me in the past.

If this is on a managed server you should be able to turn off ModSecurity for your site via cPanel.

In reply to Leon Stringer

Re: Unable to uninstall plugins

by Keith Blundy -
There is nothing like this enabled.
In reply to Keith Blundy

Re: Unable to uninstall plugins

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

Can you share a screenshot of the 403 Forbidden page?

Look in your web server's error log for any entries matching the time when you get the error page. Is there anything that might indicate what's causing this?

In the HTTP headers for your site it's reporting itself as Nginx, not Apache:

$ curl -I https://staging.training.focusonundernutrition.co.uk/ 
HTTP/1.1 200 OK
Server: nginx

So if your web server is Apache there may be something in front of your web server causing this issue, again with some WAF functionality.

In reply to Leon Stringer

Re: Unable to uninstall plugins

by Keith Blundy -
Thanks for this - I will check the log. I have also reported to the hosting company as I don't have higher level access.

Keith
In reply to Leon Stringer

Re: Unable to uninstall plugins

by Keith Blundy -
Hi Leon, thanks for your reply.
I'm on moodle 3.11 running on a linux server running Apache.

The uninstall page for the apps are: https://staging.training.focusonundernutrition.co.uk/admin/plugins.php
The URL of the error page is: https://staging.training.focusonundernutrition.co.uk/admin/plugins.php?uninstall=block_navbuttons&confirm=0&return=overview

The error happens immediately no delay.
Keith
In reply to Keith Blundy

Re: Unable to uninstall plugins

by Alain Raap -
Picture of Particularly helpful Moodlers
Hi Keith, did you try to uninstall the plugin with the cli script uninstall_plugins.php (in [Moodle root]/admin/cli)? If you run this with enough rights on Linux (or as a root user) you should be able to uninstall your plugin.
In reply to Alain Raap

Re: Unable to uninstall plugins

by Keith Blundy -

Hi Alain, thank you for that - I don’t think I can run that script from my cPanel. I have referred it to the hosting company to test.

Any other thoughts on what I can try please?

Keith

In reply to Keith Blundy

Re: Unable to uninstall plugins

by Alain Raap -
Picture of Particularly helpful Moodlers
I guess it's a problem on the filesystem of the webserver, not enough rights to delete the plugin files? I don't know if SELinux is activated on your server? This is an extra security measure on Redhat systems.
In reply to Alain Raap

Re: Unable to uninstall plugins

by Keith Blundy -
Sorry for the delay in replying I have been away on an overseas trip and just getting back to this now.

I can report the following: The URL generated that causes the issue is: https://staging.training.focusonundernutrition.co.uk/admin/plugins.php?uninstall=block_navbuttons&confirm=0&return=overview

That immediately causes the Forbidden 403 error.
If I shorten the URL to: https://staging.training.focusonundernutrition.co.uk/admin/plugins.php?uninstall=block_navbuttons
I am able to proceed and uninstall plugins.

I tried removing the: return=overview leaving the &confirm=0 directive with the same issue of Error 403, removing the &Confirm= directive only solves the problem. Any thoughts on this?

Keith
In reply to Keith Blundy

Re: Unable to uninstall plugins

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Your first URL with error produces:
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

Is it possible that you've configured your web server to produce your own error document? If so, it is hiding the real error.