Post by omikron777 » Tue Jan 19, 2021 5:58 pm

Hello,

I have searched the forum many times now, but did not come across a question that seems pretty common to me:
In any normal shared hosting situation, you typically have a user which is the owner of your www home directory, and apache runs as www-data.
It is common practice to have the directory permissions set to 755 or even 750 will work just fine.

Now, the following folders should be allowed by OCmod to be written to:
'admin/controller/extension/',
'admin/language/',
'admin/model/extension/',
'admin/view/image/',
'admin/view/javascript/',
'admin/view/stylesheet/',
'admin/view/template/extension/',
'catalog/controller/extension/',
'catalog/language/',
'catalog/model/extension/',
'catalog/view/javascript/',
'catalog/view/theme/',
'system/config/',
'system/library/',
'image/catalog/'

but it will fail as most of these are only writable by the owner (user), not Apache (www-data group). Changing all of these to 775 is a security threat as all users on the shared host could then write to and modify these folders and also not part of OpenCart's recommended installation.

So how on earth is OCmod supposed to write there ? What obvious piece am I missing ?

Thanks

Newbie

Posts

Joined
Tue Dec 04, 2012 8:06 am

Post by xxvirusxx » Tue Jan 19, 2021 6:10 pm

If you talk about that message when try to install a ocmod.. You dont't have permissions to write bla bla.....

See this extension
https://www.opencart.com/index.php?rout ... n_id=33410

Extensions converted by me | Custom 3.0.3.7 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by omikron777 » Tue Jan 19, 2021 6:14 pm

No, I am not talking about "The directory xxx is not allowed to be written to!" which is an OC restriction of the installer. Please read my post, I am describing how in a typical shared environment, Apache has no write access to these folders as www-data.

Newbie

Posts

Joined
Tue Dec 04, 2012 8:06 am

Post by xxvirusxx » Tue Jan 19, 2021 6:23 pm

omikron777 wrote:
Tue Jan 19, 2021 6:14 pm
No, I am not talking about "The directory xxx is not allowed to be written to!" which is an OC restriction of the installer.
So you mean that restriction doesn't work on shared hosting?

Extensions converted by me | Custom 3.0.3.7 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by sw!tch » Tue Jan 19, 2021 7:29 pm

omikron777 wrote:
Tue Jan 19, 2021 5:58 pm
So how on earth is OCmod supposed to write there ? What obvious piece am I missing ?
Ocmod doesn't write there. It creates a modified file in your storage/modification directory.

For proper permissions you should contact your web host as it can depend on the PHP handler being used.

Typically its
644 for files
755 for folders

But can vary depending on your server setup, best to confirm with your host.

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm
Location - USA

Post by straightlight » Tue Jan 19, 2021 8:14 pm

FAQ (first post) regarding the storage folder: viewtopic.php?f=134&t=215776#p717782 .

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by omikron777 » Wed Jan 20, 2021 1:25 am

Sorry, I did not mention indeed that I don't mean the files that are MODIFIED by OCMod, but the ones that come with extension installers from the marketplace.
So if you have the *.ocmod.zip file, there is the install.xml inside which will write to the oc_storage folder, but also the "upload" folder with custom files from the extension which are uploaded to the main OC file structure, not inside the storage folder.

myextension.ocmod.zip
=> install.xml
=> upload /
======== > admin / controller / extension / extension / myextension.php
======== > admin / language / en-gb / extension / extension / myextension.php

for example. These files will be written by the extension installer into these folders, list of "OC allowed folders" as in my original post.
The point is that PHP / Apache does not have write access to these, because you normally have only the image and oc_storage folders writable by the server.
So the installation does not work as the rename() in install.php fails due missing unix permissions. I don't want to set all these folders to 775 or 770 as any scripts on the shared server can then write there.

I hope I explained myself better now.

Newbie

Posts

Joined
Tue Dec 04, 2012 8:06 am

Post by straightlight » Wed Jan 20, 2021 1:34 am

The point is that PHP / Apache does not have write access to these, because you normally have only the image and oc_storage folders writable by the server.
So the installation does not work as the rename() in install.php fails due missing unix permissions. I don't want to set all these folders to 775 or 770 as any scripts on the shared server can then write there.
Domain permission issues. If these permissions were set recursively on the folders starting from the oc_storage folder to the child folders altogether from the FTP and you're still experiencing issues with CHMOD 0755, then you need to contact your host to resolve this issue.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by omikron777 » Wed Jan 20, 2021 1:44 am

Shall we forget the oc_storage folder as the extension is trying to upload files to the main OC file structure ?
My question is: Can I install extensions (*.ocmod.zip) with something inside the /upload/ folder in the extension without setting all these directories to 775 ?
Apache cannot write to for example /admin/controller/extension etc. as it is not the owner of these folders. I know I can resolve this by making them 775, but I don't want to ! Is that possible ?

Newbie

Posts

Joined
Tue Dec 04, 2012 8:06 am

Post by straightlight » Wed Jan 20, 2021 2:04 am

omikron777 wrote:
Wed Jan 20, 2021 1:44 am
Shall we forget the oc_storage folder as the extension is trying to upload files to the main OC file structure ?
My question is: Can I install extensions (*.ocmod.zip) with something inside the /upload/ folder in the extension without setting all these directories to 775 ?
Apache cannot write to for example /admin/controller/extension etc. as it is not the owner of these folders. I know I can resolve this by making them 775, but I don't want to ! Is that possible ?
That answer was already provided on the above. If you don't want to, then it's not an OC issue at this point but definitely unrelated where this forum does not support.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by omikron777 » Wed Jan 20, 2021 2:46 am

I don't know where on the above the answer was provided... I wouldn't insist if I had an answer.

It is definitely OC related, because the OCMod "Zip file extension installation" system was invented by OC and needs write permissions to it's folder structure.
If that is a requirement of OC, that is fine, I thought at least somebody would acknowledge that.

Newbie

Posts

Joined
Tue Dec 04, 2012 8:06 am

Post by EvolveWebHosting » Fri Jan 22, 2021 1:20 am

Which version of OC are you using and have you checked with your hosting provider to get the exact recommended permissions? Sometimes a hosting provider will configure things that don't follow the 'standard' configurations.

Image
50% Off SSD Shared Hosting w/ cPanel
Detailed guide on how to install Opencart


User avatar
Active Member

Posts

Joined
Fri Mar 27, 2015 11:13 pm
Location - Denver, Colorado, USA

Post by omikron777 » Fri Jan 22, 2021 7:53 am

I run my own server at the moment using Apache virtualhosts, opencart version 3.0.2.0. The recommended permissions are that Apache has read&write access to the following folders:

system/storage/cache/
system/storage/download/
system/storage/logs/
system/storage/modification/
system/storage/session/
system/storage/upload/
system/storage/vendor/
image/
image/cache/
image/catalog/

However, in order for extensions to upload correctly (myextension.ocmod.zip) WITH files in the /upload/ folder inside, the whole Opencart folder structure must be writeable by Apache, not only the above folders. I know how to do that, that is not my point. I was surprised to find out this requirement and was wondering if it was me that did not understand something or Opencart's instructions do not allow the extension installer to work correctly.

Code: Select all

						
if (is_dir($file) && !is_dir($path)) {
	if (mkdir($path, 0777)) {
		$this->model_setting_extension->addExtensionPath($extension_install_id, $destination);
	}
}
	
if (is_file($file)) {
	if (rename($file, $path)) {
		$this->model_setting_extension->addExtensionPath($extension_install_id, $destination);
	}
}
This stuff fails (lines 212 onwards of /admin/controller/marketplace/install.php) if Apache does not have write access to most of opencart folders.

Newbie

Posts

Joined
Tue Dec 04, 2012 8:06 am

Post by by mona » Fri Jan 22, 2021 8:04 am

It was an intentional introduction not to allow OCMOD to write to all files and folders

'admin/controller/extension/',
'admin/language/',
'admin/model/extension/',
'admin/view/image/',
'admin/view/javascript/',
'admin/view/stylesheet/',
'admin/view/template/extension/',
'catalog/controller/extension/',
'catalog/language/',
'catalog/model/extension/',
'catalog/view/javascript/',
'catalog/view/theme/',
'system/config/',
'system/library/',
'image/catalog/'

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by mikeinterserv » Fri Jan 22, 2021 8:24 am

apache runs as user www-data, group www-data that needs to write to those folders
when the server is set up correctly and OC installed, www-data WILL have write access to those folders for installing extensions. So if you have locked down your server with restrictions then that's up to you. Its not a problem of opencart.
On shared hosting its better to have seperate user accounts per virtual host, that what big clustered hosting companies do, the user has the same as www-data but ONLY for that particular virtualhost.
Last edited by mikeinterserv on Fri Jan 22, 2021 10:23 am, edited 1 time in total.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by mikeinterserv » Fri Jan 22, 2021 8:27 am

by mona wrote:
Fri Jan 22, 2021 8:04 am
It was an intentional introduction not to allow OCMOD to write to all files and folders

'admin/controller/extension/',
'admin/language/',
'admin/model/extension/',
'admin/view/image/',
'admin/view/javascript/',
'admin/view/stylesheet/',
'admin/view/template/extension/',
'catalog/controller/extension/',
'catalog/language/',
'catalog/model/extension/',
'catalog/view/javascript/',
'catalog/view/theme/',
'system/config/',
'system/library/',
'image/catalog/'
So do any extensions or OCMOD require files to be installed in any of those locations

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by by mona » Fri Jan 22, 2021 9:10 am

the opposite - only those are allowed

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by mikeinterserv » Fri Jan 22, 2021 9:32 am

by mona wrote:
Fri Jan 22, 2021 9:10 am
the opposite - only those are allowed
I know, but your post reads like a list of disallowed folders :-)
or might at least be confusing

The upshot is, if the server is set up correctly and OC installed correctly there shouldn't be a problem.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales

Post by by mona » Fri Jan 22, 2021 9:55 am

Actually, I just copied and pasted the OPs comment from the top to check there was not something wrong and forgot to delete it.

but thank you for yet again feeling the need to pull me down for you own satisfaction, maybe a post count, who knows, who cares.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


Spinning Social : Links : Menus : Payments : Socials : Ads : Screen Backgrounds : Galleries : Headers : Banners : Promos


Active Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by mikeinterserv » Fri Jan 22, 2021 10:01 am

Nothing to do with YOU
Just more to point out what's writable, what's not, what OC controls and what the apache user has access to, as the OP is clearly confused by some OC documentation.

Active Member

Posts

Joined
Thu May 28, 2020 6:55 am
Location - Wales
Who is online

Users browsing this forum: ventienda and 6 guests