*

morfik

  • ****
  • 169 posts
Why does Osclass make all the theme/plugin files as executables?
« on: February 14, 2023, 03:43:35 PM »
Looking through the Osclass installation directory, I noticed that for some reason all the files under oc-content/plugins/ and oc-content/themes/  have the exec bit set. Why?

For instance:

Code: [Select]
#  ls -al plugins/qrcode/
razem 28
drwxr-xr-x  4 www-data www-data 4096 02-07 22:16 .
drwxr-xr-x 10 root     www-data 4096 02-14 11:40 ..
-rwxr-xr-x  1 www-data www-data 1921 02-08 23:43 conf.php
-rwxr-xr-x  1 www-data www-data 1053 02-08 23:43 help.php
-rwxr-xr-x  1 www-data www-data 3739 02-08 23:43 index.php
drwxr-xr-x  3 www-data www-data 4096 02-07 22:16 languages
drwxr-xr-x  5 www-data www-data 4096 02-07 22:16 lib


I removed the exec bit for all files (not directories), but for some reason the bit showed up again.

All I can think of is the Market that does this. Any other ideas?

*

MB Themes

Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #1 on: February 14, 2023, 08:11:46 PM »
Do you mean execute permissions (644)?
These are rechecked ie when you doing update.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

morfik

  • ****
  • 169 posts
Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #2 on: February 14, 2023, 10:53:08 PM »
-rwxr-xr-x on php/js/images isn't 644, but 755, And the question is where this comes from? I had to issue the following command to make sure none of the files have exec permissions:

Code: [Select]
# find /var/www/html/osclass/ -name "*" -executable -type f -exec chmod -x {} \;
But when (probably) I used the Market to download/remove plugins, again the execs appeared. So that's why I'm asking. So far I stopped using the Market altogether, and it looks like the exec permissions didn't come back. Or maybe some other functionality of Osclass adds the execs for themes/plugins files?
« Last Edit: February 14, 2023, 10:57:34 PM by morfik »

*

MB Themes

Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #3 on: February 14, 2023, 10:55:20 PM »
Can you set folder permissions on file? Was not aware of it.
Yes download can make permissions to be checked before download starts, so it is possible to deliver file to target place.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

morfik

  • ****
  • 169 posts
Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #4 on: February 14, 2023, 11:00:31 PM »
Can you set folder permissions on file? Was not aware of it.
Yes download can make permissions to be checked before download starts, so it is possible to deliver file to target place.

Yes, I'm in charge of the whole VPS with Debian installed, so it's not an issue, but this is very dangerous to make the files be execs for everyone whenever you install/remove from the Market.
« Last Edit: February 14, 2023, 11:37:17 PM by morfik »

*

morfik

  • ****
  • 169 posts
Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #5 on: February 15, 2023, 08:58:22 AM »
Also uploading images adds execs to them:

Code: [Select]
# ls -al /var/www/html/osclass/oc-content/uploads/0/21*
-rwxr-xr-x 1 www-data www-data   53043 02-15 08:20 /var/www/html/osclass/oc-content/uploads/0/21.jpg
-rwxr-xr-x 1 www-data www-data 2162842 02-15 08:20 /var/www/html/osclass/oc-content/uploads/0/21_original.jpg
-rwxr-xr-x 1 www-data www-data   31195 02-15 08:20 /var/www/html/osclass/oc-content/uploads/0/21_preview.jpg
-rwxr-xr-x 1 www-data www-data   10996 02-15 08:20 /var/www/html/osclass/oc-content/uploads/0/21_thumbnail.jpg

Is there a way to fix this?

*

MB Themes

Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #6 on: February 15, 2023, 10:44:14 AM »
Osclass will set 644 (that does not mean executable) on files and 755 on folders.
You may review function osc_change_permissions that is in utils.php
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

morfik

  • ****
  • 169 posts
Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #7 on: February 15, 2023, 10:49:15 AM »
I'm not a programmer, but Osclass clearly sets 755 on regular files that it creates/modifies.

*

MB Themes

Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #8 on: February 15, 2023, 11:35:34 AM »
Try to go to oc-includes/osclass/utils.php

Find this line:
Code: [Select]
if (!is_writable(osc_replace_double_slash($dir . '/' . $file))) {
And change it to:
Code: [Select]
if (is_dir(osc_replace_double_slash($dir . '/' . $file)) && !is_writable(osc_replace_double_slash($dir . '/' . $file))) {
Then in same file you can also review this function:
function osc_copy($source, $dest, $options = array('folderPermission' => 0755, 'filePermission' => 0755)) {


filePermission you can try 0644, but not sure how it impacts PHP files
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

morfik

  • ****
  • 169 posts
Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #9 on: February 15, 2023, 11:53:30 AM »
Yes, this helped. Osclass now creates 644 in uploads:

Code: [Select]
# ls -al /var/www/html/osclass/oc-content/uploads/0/23*
-rw-r--r-- 1 www-data www-data 2865525 02-15 11:50 /var/www/html/osclass/oc-content/uploads/0/23_original.png
-rw-r--r-- 1 www-data www-data  619644 02-15 11:50 /var/www/html/osclass/oc-content/uploads/0/23.png
-rw-r--r-- 1 www-data www-data  347548 02-15 11:50 /var/www/html/osclass/oc-content/uploads/0/23_preview.png
-rw-r--r-- 1 www-data www-data  105179 02-15 11:50 /var/www/html/osclass/oc-content/uploads/0/23_thumbnail.png

Quote
filePermission you can try 0644, but not sure how it impacts PHP files
PHP/JS/IMAGE files shouldn't be exec.

I haven't testet the market yet. Should it be the same for it, or something else should be changed?
« Last Edit: February 15, 2023, 11:58:10 AM by morfik »

*

MB Themes

Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #10 on: February 15, 2023, 12:10:03 PM »
Which one helped?
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

morfik

  • ****
  • 169 posts
Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #11 on: February 15, 2023, 12:12:26 PM »
Which one helped?

I changed both, but I think the second would suffice. I'll check it in a moment.

*

morfik

  • ****
  • 169 posts
Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #12 on: February 15, 2023, 12:15:39 PM »
Yes, the second one alone does the job.

So basically it should be:

Quote
function osc_copy($source, $dest, $options = array('folderPermission' => 0755, 'filePermission' => 0644)) {

*

MB Themes

Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #13 on: February 15, 2023, 03:26:54 PM »
@morfik
Cool ;)
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

dsf

  • *****
  • 261 posts
Re: Why does Osclass make all the theme/plugin files as executables?
« Reply #14 on: February 15, 2023, 04:49:28 PM »
Indeed all uploads are show as 755. Good catch.

Edit: actually not all. Some are 755 for some reason (=uploads after Osclasspoint update) and others correctly 644 (probably old uploads before Osclasspoint release)
« Last Edit: February 15, 2023, 05:07:02 PM by dsf »