Could not execute because the specified command or file was not found

Hi,

When I try to start OpenBullet2 as user www-data, I get this error:

root@ob2:/var/www# sudo -u www-data /usr/bin/dotnet /var/www/openbullet2/OpenBullet2
Could not execute because the specified command or file was not found.
Possible reasons for this include:
  * You misspelled a built-in dotnet command.
  * You intended to execute a .NET program, but dotnet-/var/www/openbullet2/OpenBullet2 does not exist.
  * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
root@ob2:/var/www#

But when I run it as root, it executes just fine. How do I fix this issue?

I have made sure that the directory (and subdirectories) is owned by www-data:www-data:

root@ob2:/var/www# ls -l
total 16
drwxr-xr-x  2 www-data www-data  4096 Mar 19 09:07 html
drwxr-xr-x 37 www-data www-data 12288 Mar 19 09:17 openbullet2
root@ob2:/var/www#

Please let me know if more details are needed.

try
sudo -u www-data /usr/bin/dotnet /var/www/openbullet2/OpenBullet2.dll

Right, I forgot about the file extension. Silly me.

But now I’m getting this error:

root@ob2:/etc/nginx# sudo -u www-data /usr/bin/dotnet /var/www/openbullet2/OpenBullet2.dll
Welcome to OpenBullet 2!

----------
DISCLAIMER
----------
Performing attacks on sites you do not own (or you do not have permission to test) is illegal!
The developer will not be held responsible for improper use of this software.

Unhandled exception. System.IO.FileNotFoundException: The configuration file 'appsettings.Release.json' was not found and is not optional. The physical path is '/etc/nginx/appsettings.Release.json'.
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.HandleException(ExceptionDispatchInfo info)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
   at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load()
   at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers)
   at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build()
   at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration()
   at Microsoft.Extensions.Hosting.HostBuilder.Build()
   at OpenBullet2.Program.Main(String[] args) in D:\a\OpenBullet2\OpenBullet2\OpenBullet2\Program.cs:line 34
Aborted
root@ob2:/etc/nginx# 

Should I open a new Issue for this?

Also, I get this whenever I try to login in the interface:

Move the OB2 folder to a folder to which your user has access to.

I have made sure that /var/www/openbullet2 and its subdirectories are owned by www-data:www-data:

root@ob2:/var/www# ls -l | grep openbullet2
drwxr-xr-x 38 www-data www-data 12288 Mar 19 11:56 openbullet2
root@ob2:/var/www#

maybe cd to the openbullet2 directory before starting.

I think i read somewhere that it searches for some files like appsettings.json in the current directory. Idk if you can give it the directory via parameter.

//edit: and for next error you might gonna have: OB2 creates the directory UserData - maybe you don’t have rights for that in your situation. So maybe precreate it. But you’ll see :wink:

Adding another layer of directories (so that it’s now /var/www/openbullet2/OpenBullet2 instead of /var/www/openbullet2) and changing the working directory to /var/www/openbullet2/OpenBullet2 solved this past error, but now there’s another one:

root@ob2:/var/www/openbullet2/OpenBullet2# journalctl -xe
Mar 19 14:00:26 ob2 openbullet2[22240]:          at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<ConfMar 19 14:00:26 ob2 openbullet2[22240]:          at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationMar 19 14:00:26 ob2 openbullet2[22240]: Unhandled exception. Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error Mar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.Data.Sqlite.SqliteException.ThrowExceptionForRC(Int32 rc, sqlite3 db)
Mar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.Data.Sqlite.SqliteCommand.PrepareAndEnumerateStatements(Stopwatch timeMar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.Data.Sqlite.SqliteCommand.GetStatements(Stopwatch timer)+MoveNext()
Mar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
Mar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
Mar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader()
Mar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.Data.Sqlite.SqliteCommand.ExecuteScalar()
Mar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteScalar(RelationalMar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists()
Mar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.Migrate(DatabasMar 19 14:00:26 ob2 openbullet2[22240]:    at OpenBullet2.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) Mar 19 14:00:26 ob2 openbullet2[22240]:    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, SignaMar 19 14:00:26 ob2 openbullet2[22240]:    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Mar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicatiMar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IMar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass15_0.<UseStaMar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplMar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>Mar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken Mar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellaMar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost hoMar 19 14:00:26 ob2 openbullet2[22240]:    at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.Run(IHost host)
Mar 19 14:00:26 ob2 openbullet2[22240]:    at OpenBullet2.Program.Main(String[] args) in D:\a\OpenBullet2\OpenBullet2\OpenBullMar 19 14:00:26 ob2 systemd[1]: openbullet2.service: Main process exited, code=killed, status=6/ABRT
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- An ExecStart= process belonging to unit openbullet2.service has exited.
-- 
-- The process' exit code is 'killed' and its exit status is 6.
Mar 19 14:00:26 ob2 systemd[1]: openbullet2.service: Failed with result 'signal'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
-- 
-- The unit openbullet2.service has entered the 'failed' state with result 'signal'.
:100: 

Also, I also gave the user ownership of the directory, so shouldn’t it be able to create UserData by itself?

I should mention that I am running OpenBullet 2 behind a reverse proxy and with a service.

Here is the systemd service file:

[Unit]
Description=Service for OpenBullet 2 instance

[Service]
WorkingDirectory=/var/www/openbullet2/OpenBullet2
ExecStart=/usr/bin/dotnet /var/www/openbullet2/OpenBullet2/OpenBullet2.dll
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=openbullet2
User=www-data
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false

[Install]
WantedBy=multi-user.target

as I said before, OB2 creates new files in UserData and that you should take care that this is possible concerning the rights.
Since your setup is very unusual, and normally only very advanced users use such things, you must also be able to deal with the possibilities that linux provides for such advanced users.
So for example set the group and the setgid bit correctly to UserData:

sudo chgrp www-data UserData
sudo chmod g+s UserData

I don’t think my setup is as unusual and advanced as you’re saying. All I did was set up a simple Nginx reverse proxy so that I can use my own domain name and port (and HTTPS), and set up a simple systemd service so that I can easily manage and monitor the instance with commands like service restart openbullet2 and service status openbullet2. It’s a very common and effective setup for web applications like this one.

Anyway, as instructed, changing the setgid bit fixed the previous issue (I thought new files in the directory would inherit the new ownership):

However, I still get this error when trying to log in to the interface:

Here is the output from the logs (new error):

    root@ob2:~# systemctl status openbullet2.service 
● openbullet2.service - Service for OpenBullet 2 instance
   Loaded: loaded (/etc/systemd/system/openbullet2.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-03-19 15:35:11 UTC; 1h 13min ago
 Main PID: 28823 (dotnet)
    Tasks: 13 (limit: 1167)
   Memory: 70.5M
   CGroup: /system.slice/openbullet2.service
           └─28823 /usr/bin/dotnet /var/www/openbullet2/OpenBullet2/OpenBullet2.dll

Mar 19 15:35:56 ob2 openbullet2[28823]:          at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleAfterRender.O
Mar 19 15:35:56 ob2 openbullet2[28823]:          at Microsoft.AspNetCore.Components.Rendering.ComponentState.NotifyRenderCompletedAsync()
Mar 19 15:35:56 ob2 openbullet2[28823]: fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
Mar 19 15:35:56 ob2 openbullet2[28823]:       Unhandled exception in circuit 'C-eGWrxU_fuGQxjTdrY96nKEmiDbSw7gBYTupt-W4bg'.
Mar 19 15:35:56 ob2 openbullet2[28823]:       System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an o
Mar 19 15:35:56 ob2 openbullet2[28823]:        ---> System.NullReferenceException: Object reference not set to an instance of an object.
Mar 19 15:35:56 ob2 openbullet2[28823]:          at OpenBullet2.Pages.Index.OnAfterRender(Boolean firstRender) in D:\a\OpenBullet2\OpenBullet2\OpenBul
Mar 19 15:35:56 ob2 openbullet2[28823]:          at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleAfterRender.O
Mar 19 15:35:56 ob2 openbullet2[28823]:          at Microsoft.AspNetCore.Components.Rendering.ComponentState.NotifyRenderCompletedAsync()
Mar 19 15:35:56 ob2 openbullet2[28823]:          --- End of inner exception stack trace ---
lines 1-19/19 (END)

Using a reverse proxy is not that unusual.
Also this with a docker instance combined wouldn’t be that unusal nowadays anymore.
A chroot jail - yep maybe this would be a bit more unusal nowadays.

But starting a complete framework and an app for that via sudo as an very restricted user (www-data) which is already there for a different use and which likely doesn’t even have a shell configured and no own environment and so on) is really not common.
And then even trying to run it as a service within this users context. I don’t think that there are not many people in the world who tried that.

I would bet that there are less than 50 Users in the world who even tried to run such a combination: big software + dotnet framework (maybe even not installed via root and official installer) + www-data user + service

And most would likely have started from top (most rights) and then restrict more and more until they have it working as they want and is possible.

But ye - maybe @Ruri can help on the NRE

For the null reference exception I need to see the whole line (the one that starts with at OpenBullet2.Pages.Index.OnAfterRender(Boolean firstRender) in D:\a\OpenBullet2\OpenBullet2\OpenBul) to see in which file it happened, because it’s cut off in the logs you provided.

Sorry, my terminal cut it off:

● openbullet2.service - Service for OpenBullet 2 instance
   Loaded: loaded (/etc/systemd/system/openbullet2.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2021-03-19 15:35:11 UTC; 2h 3min ago
 Main PID: 28823 (dotnet)
    Tasks: 14 (limit: 1167)
   Memory: 74.4M
   CGroup: /system.slice/openbullet2.service
           └─28823 /usr/bin/dotnet /var/www/openbullet2/OpenBullet2/OpenBullet2.dll

Mar 19 15:35:56 ob2 openbullet2[28823]:          at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleAfterRender.OnAfterRenderAsync()
Mar 19 15:35:56 ob2 openbullet2[28823]:          at Microsoft.AspNetCore.Components.Rendering.ComponentState.NotifyRenderCompletedAsync()
Mar 19 15:35:56 ob2 openbullet2[28823]: fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
Mar 19 15:35:56 ob2 openbullet2[28823]:       Unhandled exception in circuit 'C-eGWrxU_fuGQxjTdrY96nKEmiDbSw7gBYTupt-W4bg'.
Mar 19 15:35:56 ob2 openbullet2[28823]:       System.AggregateException: One or more errors occurred. (Object reference not set to an instance of an object.)
Mar 19 15:35:56 ob2 openbullet2[28823]:        ---> System.NullReferenceException: Object reference not set to an instance of an object.
Mar 19 15:35:56 ob2 openbullet2[28823]:          at OpenBullet2.Pages.Index.OnAfterRender(Boolean firstRender) in D:\a\OpenBullet2\OpenBullet2\OpenBullet2\Pages\Index.razor.cs:line 44
Mar 19 15:35:56 ob2 openbullet2[28823]:          at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleAfterRender.OnAfterRenderAsync()
Mar 19 15:35:56 ob2 openbullet2[28823]:          at Microsoft.AspNetCore.Components.Rendering.ComponentState.NotifyRenderCompletedAsync()
Mar 19 15:35:56 ob2 openbullet2[28823]:          --- End of inner exception stack trace ---

As you can see I get the user’s IP address like this on that particular line

immagine

maybe it’s not working with the reverse proxy, please open an issue on github and I will fix it for next update. Thanks!

1 Like

Alright. Moved into #147.

1 Like