Re: Tomcat 9 does not allow to read file in /tmp folder with 777 permission?

2020-01-04 Thread zahid


Actually this is *one of many *punishments following the sin of choosing 
*.nix


and not Microsoft Windows.

Have ever heard of "*chmod*" in windows ?

MS windows trust you with your machine.

You bought it , you paid for it , you own it.


although you have many ways of installing software.

apt , apt-get yum , blah blah.

You need to familiarise yourself with *find  / -name java* *  ,   which 
java*  because you have no idea where the installer installed the 
software you just installed on "your machine",


Have ever heard of *which* or *find* in windows ?


you can be in a directory in one terminal and delete it form another 
terminal .


Is that  linux security  feature ?

can you do the same  in windows  ?

what are others benefits you can enjoy in MS Windows because of this 
particular behaviour is not same in MS Windows ?


After you deleted the directory you are in from somewhere else you will 
end up in trash literally.


why  is this same unique  behaviour in Unix which came after Linux.


you see anything what's wrong with this ? can you see the missing the /r /n

manifest.txt

Main-Class:/classname /

why does manifest.text must have /r {carriage} or  /n {newline}.

Is it because jvm.dll it was written in C. C programming language also 
has the same feature.



why is there three ways to do same thing  ?

java - cp

java - classpath

java - class-path



www.backbutton.co.uk
¯\_(ツ)_/¯
Marry loose with tight
coupling = healthy applications

On 04/01/2020 22:51, Emmanuel Bourg wrote:

Le 04/01/2020 à 16:06, Pham Huu Bang a écrit :


Thanks for this link
https://salsa.debian.org/java-team/tomcat9/blob/master/debian/README.Debian.
But I cannot *read* the file from /tmp (not *write* file to /tmp). The
strange thing is, it can read another file from another location, e.g in
/opt/:

The tomcat9 service is configured with a private /tmp directory (using
the 'PrivateTmp=yes' systemd directive). So Tomcat can't see what other
applications write to /tmp, and temporary files written by Tomcat are
out of reach from the other applications.

This is a security hardening setting that can be overridden as described
in the README file Olaf mentioned.

Emmanuel Bourg

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org


--
www.backbutton.co.uk
¯\_(ツ)_/¯
Marry loose with tight
coupling
= healthy applications



Re: Tomcat 9 does not allow to read file in /tmp folder with 777 permission?

2020-01-04 Thread Emmanuel Bourg
Le 04/01/2020 à 16:06, Pham Huu Bang a écrit :

> Thanks for this link
> https://salsa.debian.org/java-team/tomcat9/blob/master/debian/README.Debian.
> But I cannot *read* the file from /tmp (not *write* file to /tmp). The
> strange thing is, it can read another file from another location, e.g in
> /opt/:

The tomcat9 service is configured with a private /tmp directory (using
the 'PrivateTmp=yes' systemd directive). So Tomcat can't see what other
applications write to /tmp, and temporary files written by Tomcat are
out of reach from the other applications.

This is a security hardening setting that can be overridden as described
in the README file Olaf mentioned.

Emmanuel Bourg

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 9 does not allow to read file in /tmp folder with 777 permission?

2020-01-04 Thread Pham Huu Bang
Hi,

Thanks for this link
https://salsa.debian.org/java-team/tomcat9/blob/master/debian/README.Debian.
But I cannot *read* the file from /tmp (not *write* file to /tmp). The
strange thing is, it can read another file from another location, e.g in
/opt/:

ls -ltr /opt/rasdaman/etc/petascope.properties
-rwxrwxrwx 1 rasdaman rasdaman 13095 Jan  3 16:25
/opt/rasdaman/etc/petascope.properties

+ java code:

 File tempFile = new File("/opt/rasdaman/etc/petascope.properties");
 log.info("WITH FOLDER /tmp Exists: " + tempFile.exists() + ", readable: "
+ tempFile.canRead() + ", writable: " + tempFile.canWrite());

+ with log results:

WITH FOLDER /tmp Exists: true, readable: true, writable: false

On Sat, 4 Jan 2020 at 15:58, Olaf Kock  wrote:

>
> On 04.01.20 15:35, bphamhuu wrote:
> > Hello,
> >
> > I have a java web application by Tomcat 9 servlet container which tries
> to
> > read a file in /tmp folder with 777 permission on Ubuntu 18.04
> >
> > ls -ltr /tmp/test.txt
> > -rwxrwxrwx 1 vagrant vagrant 10 Jan  3 17:03 /tmp/test.txt
> >
> > The java code is:
> >
> > try {
> > result = FileUtils.readFileToString(new File("/tmp/test.txt"));
> > } catch (IOException ex) {
> > log.info("# Cannot read file. Reason: " + ex.getMessage());
> > }
> >
> > But it always show the error
> >
> > # Cannot read file. Reason: File '/tmp/test.txt' does not exist
>
>
> You're running tomcat on Ubuntu, I'm assuming you use the version from
> the Debian repositories, not one that you downloaded from
> tomcat.apache.org.
>
> Debian's tomcat is sandboxed. Read /usr/share/doc/tomcat9/README.Debian
> (or an online version at
> https://salsa.debian.org/java-team/tomcat9/blob/master/debian/README.Debian
> )
> for more information (search for "sandboxed" to find the proper place)
>
> Credits: I keep this under my belt since Emmanuel Bourg answered a
> similar question on this list a while back.
>
> And don't forget to reset the 777 permissions.
>
> Olaf
>
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>

-- 

*Bang Pham Huu *
*-*
*Master of Science - Research Assistant at Field Monitoring Center - 4 F,
E3 BuildingViet Nam - Ha Noi National University - University of
Engineering and Technology*
*Email: a09...@gmail.com  - Tel: +84 164.6339.217*

*“Life is like riding a bicycle. To keep your balance, you must keep
moving.”― Albert Einstein*


Re: Tomcat 9 does not allow to read file in /tmp folder with 777 permission?

2020-01-04 Thread Olaf Kock


On 04.01.20 15:35, bphamhuu wrote:
> Hello,
>
> I have a java web application by Tomcat 9 servlet container which tries to
> read a file in /tmp folder with 777 permission on Ubuntu 18.04
>
> ls -ltr /tmp/test.txt
> -rwxrwxrwx 1 vagrant vagrant 10 Jan  3 17:03 /tmp/test.txt
>
> The java code is:
>
> try {
> result = FileUtils.readFileToString(new File("/tmp/test.txt"));
> } catch (IOException ex) {
> log.info("# Cannot read file. Reason: " + ex.getMessage());
> }
>
> But it always show the error
>
> # Cannot read file. Reason: File '/tmp/test.txt' does not exist


You're running tomcat on Ubuntu, I'm assuming you use the version from
the Debian repositories, not one that you downloaded from tomcat.apache.org.

Debian's tomcat is sandboxed. Read /usr/share/doc/tomcat9/README.Debian
(or an online version at
https://salsa.debian.org/java-team/tomcat9/blob/master/debian/README.Debian)
for more information (search for "sandboxed" to find the proper place)

Credits: I keep this under my belt since Emmanuel Bourg answered a
similar question on this list a while back.

And don't forget to reset the 777 permissions.

Olaf


-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org



Re: Tomcat 9 does not allow to read file in /tmp folder with 777 permission?

2020-01-04 Thread Pham Huu Bang
And here is the full stack trace from my java web application using Spring Boot.

 INFO [2020-01-04 14:42:08] RemoteCoverageUtil@80: # Cannot read
file. Reason: File '/tmp/test.txt' does not exist
java.io.FileNotFoundException: File '/tmp/test.txt' does not exist
at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:254)
at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1641)
at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1659)
at
petascope.wcst.helpers.RemoteCoverageUtil.getRemoteGMLCoverage(RemoteCoverageUtil.java:78)
at
petascope.wcst.handlers.InsertCoverageHandler.handleRemoteCoverageInsert(InsertCoverageHandler.java:120)
at
petascope.wcst.handlers.InsertCoverageHandler.handle(InsertCoverageHandler.java:103)
at
petascope.controller.handler.service.KVPWCSTServiceHandler.handleInsertCoverageRequest(KVPWCSTServiceHandler.java:145)
at
petascope.controller.handler.service.KVPWCSTServiceHandler.handle(KVPWCSTServiceHandler.java:99)
at
petascope.controller.PetascopeController.requestDispatcher(PetascopeController.java:190)
at
petascope.controller.PetascopeController.handleGet(PetascopeController.java:115)
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:564)
at
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
at
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at
org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at
org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:105)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at
org.springframework.boot.web.support.ErrorPageFilter.doFilter(ErrorPageFilter.java:115)
at
org.springframework.boot.web.support.ErrorPageFilter.access$000(ErrorPageFilter.java:59)
at
org.springframework.boot.web.support.ErrorPageFilter$1.doFilterInternal(ErrorPageFilter.java:90)

Re: Tomcat 9 does not allow to read file in /tmp folder with 777 permission?

2020-01-04 Thread Pham Huu Bang
Hi,

The stack trace is short with FileNotFoundException

# Cannot read file. Reason: File '/tmp/test.txt' does not exist
java.io.FileNotFoundException: File '/tmp/test.txt' does not exist
at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:254)
at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1641)
at org.apache.commons.io.FileUtils.readFileToString(FileUtils.java:1659)

On Sat, 4 Jan 2020 at 15:38, M. Manna  wrote:

> Hi,
>
> On Sat, 4 Jan 2020 at 14:36, bphamhuu  wrote:
>
> > Hello,
> >
> > I have a java web application by Tomcat 9 servlet container which tries
> to
> > read a file in /tmp folder with 777 permission on Ubuntu 18.04
> >
> > ls -ltr /tmp/test.txt
> > -rwxrwxrwx 1 vagrant vagrant 10 Jan  3 17:03 /tmp/test.txt
> >
> > The java code is:
> >
> > try {
> > result = FileUtils.readFileToString(new File("/tmp/test.txt"));
> > } catch (IOException ex) {
> > log.info("# Cannot read file. Reason: " + ex.getMessage());
> > }
> >
> > But it always show the error
> >
> > # Cannot read file. Reason: File '/tmp/test.txt' does not exist
> >
> > This test file can be opened fine by a normal user on a terminal window
> > (example user: vagrant).
> >
> > vagrant@ras:~$ cat /tmp/test.txt
> > asdasdsad
> >
> > Does anybody know about the problem with Tomcat 9? I'll need the java web
> > application to read this test file as string.
> >
> > Thanks,
> >
> >
> >   What is the full stack trace?
>
> >
> > --
> > Sent from: http://tomcat.10.x6.nabble.com/Tomcat-User-f1968778.html
> >
> > -
> > To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> > For additional commands, e-mail: users-h...@tomcat.apache.org
> >
> >
>


-- 

*Bang Pham Huu *
*-*
*Master of Science - Research Assistant at Field Monitoring Center - 4 F,
E3 BuildingViet Nam - Ha Noi National University - University of
Engineering and Technology*
*Email: a09...@gmail.com  - Tel: +84 164.6339.217*

*“Life is like riding a bicycle. To keep your balance, you must keep
moving.”― Albert Einstein*


Re: Tomcat 9 does not allow to read file in /tmp folder with 777 permission?

2020-01-04 Thread M. Manna
Hi,

On Sat, 4 Jan 2020 at 14:36, bphamhuu  wrote:

> Hello,
>
> I have a java web application by Tomcat 9 servlet container which tries to
> read a file in /tmp folder with 777 permission on Ubuntu 18.04
>
> ls -ltr /tmp/test.txt
> -rwxrwxrwx 1 vagrant vagrant 10 Jan  3 17:03 /tmp/test.txt
>
> The java code is:
>
> try {
> result = FileUtils.readFileToString(new File("/tmp/test.txt"));
> } catch (IOException ex) {
> log.info("# Cannot read file. Reason: " + ex.getMessage());
> }
>
> But it always show the error
>
> # Cannot read file. Reason: File '/tmp/test.txt' does not exist
>
> This test file can be opened fine by a normal user on a terminal window
> (example user: vagrant).
>
> vagrant@ras:~$ cat /tmp/test.txt
> asdasdsad
>
> Does anybody know about the problem with Tomcat 9? I'll need the java web
> application to read this test file as string.
>
> Thanks,
>
>
>   What is the full stack trace?

>
> --
> Sent from: http://tomcat.10.x6.nabble.com/Tomcat-User-f1968778.html
>
> -
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>


Tomcat 9 does not allow to read file in /tmp folder with 777 permission?

2020-01-04 Thread bphamhuu
Hello,

I have a java web application by Tomcat 9 servlet container which tries to
read a file in /tmp folder with 777 permission on Ubuntu 18.04

ls -ltr /tmp/test.txt
-rwxrwxrwx 1 vagrant vagrant 10 Jan  3 17:03 /tmp/test.txt

The java code is:

try {
result = FileUtils.readFileToString(new File("/tmp/test.txt"));
} catch (IOException ex) {
log.info("# Cannot read file. Reason: " + ex.getMessage());
}

But it always show the error

# Cannot read file. Reason: File '/tmp/test.txt' does not exist

This test file can be opened fine by a normal user on a terminal window
(example user: vagrant).

vagrant@ras:~$ cat /tmp/test.txt
asdasdsad

Does anybody know about the problem with Tomcat 9? I'll need the java web
application to read this test file as string.

Thanks,



--
Sent from: http://tomcat.10.x6.nabble.com/Tomcat-User-f1968778.html

-
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org