[Solved] Shell_exec required for normal operation?

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 24.0.5
Operating system and version (eg, Ubuntu 20.04): LiteSpeed V8.0.1 Cloudlinux 1.3
Apache or nginx version (eg, Apache 2.4.25): 2.4.54
PHP version (eg, 7.4): 7.4 > 8.x

The issue you are facing: shell_exec related errors when accessing Administration > System

Is this the first time you’ve seen this error? (Y/N): Y

Short version: on our shared webhosting the PHP function shell_exec is not enabled and we have no way to enable it for our account. We’re told it is dangerous. My impression is that this function is only used for Administration > System. Is this true? We could live without that.

Many topics on this forum point to Github. A search there reveals that there has been discussion among developers about shell_exec and in the past there have been pull-requests to remove it. But my knowledge of PHP and the Github workflow is insufficient to understand what is going on.

Steps to replicate it:

  1. Update Nextcloud from 24.0.4 to 24.0.5
  2. Access Administration > System (/index.php/settings/admin/serverinfo). No errors there, but the Nework section is incomplete: only the host name is shown.
  3. Check Admin > Logging. This gets flooded with errors like:
 Error: shell_exec() has been disabled for security reasons at /home/<user>/domains/(our domain>/public_html/cloud/apps/serverinfo/lib/OperatingSystems/DefaultOs.php#116

every time I access Access Administration > System.

  1. In DirectAdmin set PHP version from 7.4 to 8.0

Now Administration > System produces an error page:

The server was unable to process your request (...)
    External address: 2a10:3781:15:1:a9f8:900a:ba7:dda9
    Request ID: YxxowmdQRzubW62uI-J4cwAAHxc

and Admin > Logging gets the same errors as above.

  1. In DirectAdmin set PHP version from 8.0 to 8.1

Administration > System results in the same error page as with PHP 8.0

but the output in **Admin > Logging** is different now:
Call to undefined function OCA\ServerInfo\OperatingSystems\shell_exec() in file '/home/<account./domains/<our domain>/public_html/cloud/apps/serverinfo/lib/OperatingSystems/DefaultOs.php' line 227

    /home/<account./domains/<our domain>/public_html/cloud/lib/private/AppFramework/App.php - line 172:

    OC\AppFramework\Http\Dispatcher->dispatch()

    /home/<account./domains/<our domain>/public_html/cloud/lib/private/Route/Router.php - line 298:

    OC\AppFramework\App::main()

    /home/<account./domains/<our domain>/public_html/cloud/lib/base.php - line 1030:

    OC\Route\Router->match()

    /home/<account./domains/<our domain>/public_html/cloud/index.php - line 36:

    OC::handleRequest()

Veroorzaakt door Error: Call to undefined function OCA\ServerInfo\OperatingSystems\shell_exec()

Some more info:

The output of our config.php file in `/path/to/nextcloud` (make sure you remove any identifiable information!):
<?php
$CONFIG = array (
  'instanceid' => '**removed**',
  'passwordsalt' => '**removed**',
  'secret' => '**removed**',
  'trusted_domains' => 
  array (
    0 => 'cloud.<our domain>',
  ),
  'datadirectory' => '/home/<account>/domains/<our domain>/public_html/cloud/data',
  'dbtype' => 'mysql',
  'version' => '24.0.5.1',
  'overwrite.cli.url' => 'https://cloud.<our domain>',
  'dbname' => '<account>_nc',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '<account>_nc',
  'dbpassword' => 'FcrFxEXYX',
  'installed' => true,
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_smtphost' => 'mail.<our domain>',
  'mail_smtpport' => '587',
  'mail_from_address' => 'noreply',
  'mail_domain' => '<our domain>',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'noreply@<our domain>',
  'mail_smtppassword' => '**removed**',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'default_language' => 'nl',
  'default_locale' => 'nl_NL',
  'defaultapp' => 'files',
  'skeletondirectory' => '/home/<account>/domains/<our domain>/public_html/clouddata/skeleton',
  'templatedirectory' => '',
  'updater.secret' => '**removed**',
);

We have no access to Apache/nginx/system log in /var/log/____

Yes, it seems mostly related to the serverinfo app. It shows the state of the system and some commands are obtained by executing commands via the shell command. It would be great if there other ways to obtain that information. It’s not easy and obvious enough that someone just did it.
Other way to solve this, is somehow to detect if the function is usable and if not just not provide this information without throwing errors.

This app is not essential for Nextcloud to work. If you can’t ignore the errors, you can remove the app. Probably only way is to delete the apps/serverinfo folder since it’s a default app that can’t be easily disabled.

1 Like

Thanks @tflidd ! I never realized it was an app. I could disable the “Monitoring” app and now the item System is gone from Administration.

Happy to know that this will not affect other NC components.

1 Like

I’m looking to find out which NextCloud install version do I need for Cloudlinux? Thanks.

@Les You are adding a new and unrelated question to an old topic that is marked as [solved]. On any support forum it is much better or even required to start your own topic.

We used the web installer. I think it automatically detects your server architecture, but I’m not an expert on this.