Nc-who fails with "include(/config.php): Failed to open stream: No such file or directory"

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 30.0.4
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 22.04

Summary of the issue you are facing:

Newly downloaded version of nc-who, installed this way:

sudo wget -qO /usr/local/bin/nc-who https://global-social.net/script/nc-who
sudo chmod +x /usr/local/bin/nc-who
nc-who

When I run nc-who, I first get:

  This script has to be run as user 'www-data' or as 'root'!
    sudo -u www-data nc-who monitor
  /usr/local/bin/nc-who: line 60: /tmp/ebtb-logfiles/nc-who.log.lock: Permission denied

When I run as www-data, as suggested above, I get:

/usr/local/bin/nc-who: line 60: /tmp/ebtb-logfiles/nc-who.log.lock: Permission denied
.. loading modules - nc/nextcloud/dev/fd/61: line 67: /usr/local/include/ebtb/prod/fp: Permission denied

When I finally run as root, I get:

.. loading modules - nc/nextcloudPHP Warning:  include(/config.php): Failed to open stream: No such file or directory in Standard input code on line 5
PHP Warning:  include(): Failed opening '/config.php' for inclusion (include_path='.:/usr/share/php') in Standard input code on line 5
PHP Warning:  Undefined variable $CONFIG in Standard input code on line 6
PHP Warning:  foreach() argument must be of type array|object, null given in Standard input code on line 6

The nc-who.log shows the following:

1738275810-(2025-01-30_14:23_PST) - nc-who-1738164268 - run2 root: 
1738275813-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ binaries
1738275814-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ basics
1738275815-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ awksed
1738275816-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ tempfile
1738275817-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ ansi
1738275818-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ button
1738275819-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ exit
1738275820-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ anykey
1738275821-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ line
1738275821-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ array
1738275822-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ sudo
1738275823-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ dependency
1738275824-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ ask
1738275825-(2025-01-30_14:23_PST) - nc-who-1738164268 - REQ prefix
1738275827-(2025-01-30_14:23_PST) - nc-who-1738164268 - :68232:REQ vdir
1738275828-(2025-01-30_14:23_PST) - nc-who-1738164268 - :68232:REQ integrity
1738275829-(2025-01-30_14:23_PST) - nc-who-1738164268 - :68232:REQ nc/nextcloud
1738275830-(2025-01-30_14:23_PST) - nc-who-1738164268 - :68232:REQ php/version
1738275832-(2025-01-30_14:23_PST) - nc-who-1738164268 - :68232:REQ nc/nextcloud_db
1738275833-(2025-01-30_14:23_PST) - nc-who-1738164268 - :68232:REQ nc-who/help
1738275833-(2025-01-30_14:23_PST) - nc-who-1738164268 - :68232:REQ nc/nextcloud_logo
1738275834-(2025-01-30_14:23_PST) - nc-who-1738164268 - :68232:REQ nc-who/last
1738275835-(2025-01-30_14:23_PST) - nc-who-1738164268 - :68232:REQ nc-who/monitor
1738275838-(2025-01-30_14:23_PST) - nc-who-1738164268 - :68232:AIO = false - DOCKER = false
1738275839-(2025-01-30_14:23_PST) - nc-who-1738164268 - :68232:pid1: systemd
1738275872-(2025-01-30_14:24_PST) - nc-who-1738164268 - root: 
1738276101-(2025-01-30_14:28_PST) - nc-who-1738164268 - root: 
1738276109-(2025-01-30_14:28_PST) - nc-who-1738164268 - root: 
1738276114-(2025-01-30_14:28_PST) - nc-who-1738164268 - :68232:REQ httpd
1738276134-(2025-01-30_14:28_PST) - nc-who-1738164268 - run2 root: 
1738276135-(2025-01-30_14:28_PST) - nc-who-1738164268 - :68232:vdir: /var/www/cloud
1738276195-(2025-01-30_14:29_PST) - nc-who-1738164268 - root: monitor
1738276304-(2025-01-30_14:31_PST) - nc-who-1738164268 - root: 
1738276317-(2025-01-30_14:31_PST) - nc-who-1738164268 - root: monitor
1738276345-(2025-01-30_14:32_PST) - nc-who-1738164268 - root: monitor
1738280571-(2025-01-30_15:42_PST) - nc-who-1738164268 - root: monitor
1738280580-(2025-01-30_15:43_PST) - nc-who-1738164268 - :68232:AIO = false - DOCKER = false
1738280581-(2025-01-30_15:43_PST) - nc-who-1738164268 - :68232:pid1: systemd
/tmp/ebtb-logfiles/nc-who.log (END)

The nextcloud config file is where is should be in “cloud/config/config.php”. I don’t know what other config.php the script may be looking for.

Hi @CameronS,

thank you for your feedback and sorry for the late response. You didn’t respond in the thread belonging to this script, so I wasn’t notified right away.

The error message actually indicates that the config directory was not passed on correctly.
The only explanation I can think of is that it has something to do with the rights problems you described.
Yes, it’s true, the script should actually be run completely as root the first time so that the path to the nextcloud installation can be written into the script. That is logged here:

I assume that’s where it went wrong.
Could you please check this output:

grep 'declare $vdirname' /usr/local/bin/nc-who

it should look like this:

declare $vdirname="/var/www/cloud" # <-- don't change this!

If it does not show the path to your nextcloud installation, then run this step again:

and start again from scratch as root:

sudo nc-who

Your feedback provides valuable information that shows me where improvements are still needed.
I wanted to make the script run with unprivileged rights if possible. However, since I have implemented a lot of security features like lock files and such, switching from root to unprivileged is no longer as easy as before. So I still have to make some improvements so that it really works on all systems.

I am sory for that. I will fix that soon, so that log- and lockfiles wil no longer be shared between users and to make it clear, that the first “installation” run must be done as root.


EDIT:
It is fixed now and running

as an unpriviliged user (www-data) should now be possible without any restrictions.

Please test ist.


Much and good luck,
ernolf

ernolf,

No, it’s still not working. What’s the next step?

$ sudo wget -qO /usr/local/bin/nc-who https://global-social.net/script/nc-who
$ sudo nc-who
.. loading modules - integrity
     First run, checking integrity:
     ===========================================================================
gpg:                using RSA key 3EE43A84D2BA635A94E1033B0B145139A170715C
gpg: Good signature from "[ernolf] Raphael Gradenwitz (codesigning) <raphael.gradenwitz@googlemail.com>" [unknown]
     ---------------------------------------------------------------------------
     Integrity check passed. The script is authentic.
     ===========================================================================

 - Integrity check passed. Please start script again
$ sudo nc-who

  This step is required once after a new installation or sometimes after an update:

  Hello, this is the first run wizard of "nc-who"
  nextcloud installation detected in /var/www/cloud

  - first run wizard completed successfully. Please start script again
  - No further root rights are required to use the script except for updating.

$ nc-who
.. loading modules - nc/nextcloudPHP Warning:  include(/config.php): Failed to open stream: No such file or directory in Standard input code on line 5
PHP Warning:  include(): Failed opening '/config.php' for inclusion (include_path='.:/usr/share/php') in Standard input code on line 5
PHP Warning:  Undefined variable $CONFIG in Standard input code on line 6
PHP Warning:  foreach() argument must be of type array|object, null given in Standard input code on line 6


  This script has to be run as user 'www-data' or as 'root'!
    sudo -u www-data nc-who 
  mkdir: cannot create directory ‘/var/www/.ebtb’: Permission denied
.. loading modules - binariesmkdir: cannot create directory ‘/var/www/.ebtb’: Permission denied


 - Failed to load required module 'binaries'
   this can happen if the module server is down e.g. for maintenance
   try again later or run

     sudo wget -O /usr/local/bin/nc-who https://global-social.net/script/nc-who

   and start the script again.

rm: cannot remove '/var/www/.ebtb/modules/prod': No such file or directory
Terminated
$ sudo nc-who
.. loading modules - nc/nextcloudPHP Warning:  include(/config.php): Failed to open stream: No such file or directory in Standard input code on line 5
PHP Warning:  include(): Failed opening '/config.php' for inclusion (include_path='.:/usr/share/php') in Standard input code on line 5
PHP Warning:  Undefined variable $CONFIG in Standard input code on line 6
PHP Warning:  foreach() argument must be of type array|object, null given in Standard input code on line 6

                                                                                    
                                                                                    
                                    ,cWNXXXXNNNo,                                   
                                .NKOkxdddddddddxk0Xk                                
                              X0xddddddddddddddddddxkKc                             
         ,sHNNNNWln,        OOddddddddddddddddddddddddxK,         .WNNNNW;          
       XKOxddddddxk0Xl    .0xddddddo°           °dddddddxk    .N0kxddddddxk0X;      
     Kkddddddddddddddx0c 'kddddddc                .ddddddxk  XkddddddddddddddxK,    
   'OddddddddddddddddddxOOdddddd.                   odddddxKOddddddddddddddddddxd   
   Odddddd;'     'ddddddddddddd;                     ddddddddddddd'      'ddddddx:  
  ;dddddd;         dddddddddddd.                     cddddddddddd'        .ddddddd  
  ,dddddd:         xddddddddddd.                     cddddddddddd,        .ddddddo  
   ddddddkc      ¸Oddddddddddddc                     kdddddddddddO,      ¸0dddddd,  
   .ddddddx0nwwnXOddddddoddddddk'                   kdddddddddddddxKnwwnkkddddddc   
     dddddddddddddddddd; .ddddddkd                 Kxdddddl .dddddddddddddddddd'    
       dddddddddddddd;    .ddddddx0K¸           ,Xkddddddl    .dddddddddddddd'      
          'ddddddo'         odddddddk0XnweoxwnKOxddddddd'         'ddddddo'         
                              dddddddddddddddddddddddd'                             
                                'ddddddddddddddddddo                                
                                     oddddÇÇdddo                                    
                                                                                    
                                                                                    

 =================================================================================
  This is the help page of nc-who
 =================================================================================

  Feedback and suggestions for improvements/additions are always welcome!
  You can write me here:
  https://help.nextcloud.com/t/script-nc-who-similar-to-unix-who-follow-live-who-is-logged-in/164972

  Future versions of this script may offer to complete much more steps for you.
  This script will update itself automatically, so no need to reinstall it.

  Good luck!
  ernolf

  PayPal:  ernolf<at>global-social.net

 =================================================================================

  nc-who - Version 2025-02-02 20:05 (latest version)

  This utility is similar to the Unix `who` command, allowing you to monitor
  live user logins and activities on your nextcloud server-instance.

  Usage:
    nc-who -h|--help
    nc-who monitor
    nc-who last
    nc-who integrity_check

  Options:

    -h|--help       Display this help message.

    monitor     Monitor live user logins, ordered by last activity at an
                adjustable refresh rate.
                * Login status is only available for cookie-based sessions
                  on a web frontend.
                * Last activity is shown for all clients.

    last        List users sorted by their last login time. This is equivalent
                to the output of `occ user:lastseen --all`
                * `--all` is actually not available for that occ command.

    integrity_check
                verify the integrity of this script with signature


Thank you very much for your feedback.

It does not work, because you did not configure your server as it is usualy expected:

This shows, that according to /etc/passwd, /var/www is the home directory of the user www-data:

getent passwd www-data | cut -d: -f6

However www-data does not have write permissions in that directory:

ls -ld /var/www

This can be considered as a misconfiguration of the server or at least as unusual.
But since the server admin is free to configure their system as unusually as they wants and I want to make the scripts as idiot-proof as possible, I have taken this into account.

Please try the newest version. It should now work even if the user cannot write to its own HOME directory.


Much and good luck,
ernolf

Thank you very much for your assistance.

This shows, that according to /etc/passwd, /var/www is the home directory of the user www-data:

getent passwd www-data | cut -d: -f6

However www-data does not have write permissions in that directory:

ls -ld /var/www

That is all correct. Can you tell me, please, how you were able to obtain that data? It would appear that you were running those commands on my server and if that is the case, how were able to do that?

This can be considered as a misconfiguration of the server or at least as unusual.

Could well be… the root ownership I think may have been from the original install, but the group I would have applied later.

I have now changed the ownership of the /var/www folder to www-data. I then ran nc-who, without first upgrading, with no success.

I then ran nc-who again and accepted the offer to upgrade. Again, nc-who would not run:

 - Update was successfull. Please start script again
$ sudo nc-who
.. loading modules - nc/nextcloud
PHP Warning:  include(/config.php): Failed to open stream: No such file or directory in Standard input code on line 5
PHP Warning:  include(): Failed opening '/config.php' for inclusion (include_path='.:/usr/share/php') in Standard input code on line 5
PHP Warning:  Undefined variable $CONFIG in Standard input code on line 6
PHP Warning:  foreach() argument must be of type array|object, null given in Standard input code on line 6

The .ebtb does exist:

ls -la /var/www
total 48
drwxrwxr-x 12 www-data adm      4096 Feb 11 16:35 .
drwxr-xr-x 14 root     root     4096 Nov 22  2023 ..
drwxrwxr-x  3 www-data www-data 4096 Feb 11 16:35 .ebtb

What other info do you need (other than the root password) to figure out what’s going on?

(And “idiot-proof” may not be the most diplomatic term to use, especially when you’re talking to the idiot…)

FWIW, I removed all of the .ebtb directories and removed /usr/local/bin/nc-who.

I then ran the install again, using nc-shares this time, instead of nc-who.

Unsurpisingly, I got the same result:

.. loading modules - nc/nextcloudPHP Warning:  include(/config.php): Failed to open stream: No such file or directory in Standard input code on line 5
PHP Warning:  include(): Failed opening '/config.php' for inclusion (include_path='.:/usr/share/php') in Standard input code on line 5
PHP Warning:  Undefined variable $CONFIG in Standard input code on line 6
PHP Warning:  foreach() argument must be of type array|object, null given in Standard input code on line 6

good morning, unfortunately i’m having the same issue. no matter what I do, it always ends with this error :confused::

root@mj-nextcloud01:~# nc-who
.. loading modules - nc/nextcloudPHP Warning:  include(/config.php): Failed to open stream: No such file or directory in Standard input code on line 5
PHP Warning:  include(): Failed opening '/config.php' for inclusion (include_path='.:/usr/share/php') in Standard input code on line 5
PHP Warning:  Undefined variable $CONFIG in Standard input code on line 6
PHP Warning:  foreach() argument must be of type array|object, null given in Standard input code on line 6

the user www-data definitely has write permissions to its home directory /var/www

the server is:

Linux mj-nextcloud01 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

the nextcloud version is:

nextcloud Hub 10 (31.0.2)

what else can i try?