B4J Question JServer Log file limited permissions

avalle

Active Member
Licensed User
Longtime User
I have my B4J server app based on jServer running on a Linux Ubuntu 18.
The JAR is executed with the usual nohup command:
sudo nohup java -jar myServer.jar > nohup.out &

The Jetty Web server creates its "logs" folder where all the Web requests to the server are logged in daily files.
I have an issue with the file permissions: they get created with "rw-r-----" permissions.
The creator is root so my SSH client cannot read the files as it runs will non-admin permissions.

I'd like to change the permissions to "rw-r--r--" but I have no idea where this should be configured.
Note that the logs folder has generous permissions (rwxr-xr-x), so it does not seem like the permission set is inherited from the parent folder.

Thanks
Andrea
 

amykonio

Active Member
Licensed User
Longtime User
I have my B4J server app based on jServer running on a Linux Ubuntu 18.
The JAR is executed with the usual nohup command:


The Jetty Web server creates its "logs" folder where all the Web requests to the server are logged in daily files.
I have an issue with the file permissions: they get created with "rw-r-----" permissions.
The creator is root so my SSH client cannot read the files as it runs will non-admin permissions.
I believe this is an expected behaviour as you are running your command using sudo. The file is created under that command and will take the appropriate permissions. Nohup should use append to the output file. So I guess when your file exists (it should be created only when you first run your application) you can run a command like sudo chmod 744 <your file>.

Andreas.
 
Upvote 0

avalle

Active Member
Licensed User
Longtime User
Thanks for the suggestion but I'm talking about the log files generated daily by the Jetty server in the logs folder, not the nohup.out file which is ok
 
Upvote 0

avalle

Active Member
Licensed User
Longtime User
Good question... I thought it was required to run jServer apps with sudo. If I don't, and run the server using the ssh user (not admin) I get the following exceptions:

2021-11-28 11:49:41.531:INFO:eek:ejs.Server:main: jetty-9.4.z-SNAPSHOT; built: 2018-05-03T15:56:21.710Z; git: daa59876e6f384329b122929e70a80934569428c; jvm 11.0.11+9-Ubuntu-0ubuntu2.18.04
2021-11-28 11:49:41.595:INFO:eek:ejs.session:main: DefaultSessionIdManager workerName=node0
2021-11-28 11:49:41.596:INFO:eek:ejs.session:main: No SessionScavenger set, using defaults
2021-11-28 11:49:41.598:INFO:eek:ejs.session:main: node0 Scavenging every 600000ms
2021-11-28 11:49:41.609:INFO:eek:ejsh.ContextHandler:main: Started o.e.j.s.ServletContextHandler@add0edd{/,file:///home/ubuntu/www/,AVAILABLE}
2021-11-28 11:49:41.619:INFO:eek:ejs.AbstractNCSARequestLog:main: Opened /home/ubuntu/logs/b4j-2021_11_28.request.log
main._appstart (java line: 127)
MultiException[java.net.SocketException: Permission denied, java.net.SocketException: Permission denied]
at org.eclipse.jetty.server.Server.doStart(Server.java:383)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:220)
at b4j.example.main._appstart(main.java:127)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
at b4j.example.main.main(main.java:28)
Suppressed: java.net.SocketException: Permission denied
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:455)
at java.base/sun.nio.ch.Net.bind(Net.java:447)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:340)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:398)
... 10 more
Caused by: java.net.SocketException: Permission denied
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:455)
at java.base/sun.nio.ch.Net.bind(Net.java:447)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:340)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:398)
... 10 more

main.main (java line: 28)
java.lang.RuntimeException: MultiException[java.net.SocketException: Permission denied, java.net.SocketException: Permission denied]
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:138)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
at b4j.example.main.main(main.java:28)
Caused by: MultiException[java.net.SocketException: Permission denied, java.net.SocketException: Permission denied]
at org.eclipse.jetty.server.Server.doStart(Server.java:383)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at anywheresoftware.b4j.object.ServerWrapper.Start(ServerWrapper.java:220)
at b4j.example.main._appstart(main.java:127)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
... 2 more
Suppressed: java.net.SocketException: Permission denied
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:455)
at java.base/sun.nio.ch.Net.bind(Net.java:447)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:340)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:398)
... 10 more
Caused by: java.net.SocketException: Permission denied
at java.base/sun.nio.ch.Net.bind0(Native Method)
at java.base/sun.nio.ch.Net.bind(Net.java:455)
at java.base/sun.nio.ch.Net.bind(Net.java:447)
at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:227)
at java.base/sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:80)
at org.eclipse.jetty.server.ServerConnector.openAcceptChannel(ServerConnector.java:340)
at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:308)
at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:244)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.server.Server.doStart(Server.java:398)
... 10 more
 
Last edited:
Upvote 0
Top