You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/01/26 13:55:45 UTC

[tomcat] branch 9.0.x updated: Fix a SpotBugs warning - log an message when permission setting fails

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 9ebeda2  Fix a SpotBugs warning - log an message when permission setting fails
9ebeda2 is described below

commit 9ebeda2df488803d61b371c0cc36db83fe04f197
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Tue Jan 26 13:54:52 2021 +0000

    Fix a SpotBugs warning - log an message when permission setting fails
---
 java/org/apache/tomcat/util/net/LocalStrings.properties |  3 +++
 java/org/apache/tomcat/util/net/NioEndpoint.java        | 12 +++++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties b/java/org/apache/tomcat/util/net/LocalStrings.properties
index bcf697c..257f4bf 100644
--- a/java/org/apache/tomcat/util/net/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
@@ -97,6 +97,9 @@ endpoint.nio.keyProcessingError=Error processing selection key
 endpoint.nio.latchMustBeZero=Latch must be at count zero or null
 endpoint.nio.nullLatch=Latch cannot be null
 endpoint.nio.nullSocketChannel=Invalid null socket channel while processing poller event
+endpoint.nio.perms.execFail=Failed to set execute permissions for Unix domain socket [{0}]
+endpoint.nio.perms.readFail=Failed to set read permissions for Unix domain socket [{0}]
+endpoint.nio.perms.writeFail=Failed to set write permissions for Unix domain socket [{0}]
 endpoint.nio.pollerEventError=Error processing poller event
 endpoint.nio.registerFail=Failed to register socket with selector from poller
 endpoint.nio.selectorCloseFail=Failed to close selector when closing the poller
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java b/java/org/apache/tomcat/util/net/NioEndpoint.java
index 4ccfd4f..86e377d 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -272,9 +272,15 @@ public class NioEndpoint extends AbstractJsseEndpoint<NioChannel,SocketChannel>
                     Files.setAttribute(path, attrs.name(), attrs.value());
                 } else {
                     java.io.File file = path.toFile();
-                    file.setReadable(true, false);
-                    file.setWritable(true, false);
-                    file.setExecutable(false, false);
+                    if (!file.setReadable(true, false)) {
+                        log.warn(sm.getString("endpoint.nio.perms.readFail", path));
+                    }
+                    if (!file.setWritable(true, false)) {
+                        log.warn(sm.getString("endpoint.nio.perms.writeFail", path));
+                    }
+                    if (!file.setExecutable(false, false)) {
+                        log.warn(sm.getString("endpoint.nio.perms.execFail", path));
+                    }
                 }
             }
         } else {


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch 9.0.x updated: Fix a SpotBugs warning - log an message when permission setting fails

Posted by Mark Thomas <ma...@apache.org>.
On 26/01/2021 14:15, Rémy Maucherat wrote:
> On Tue, Jan 26, 2021 at 3:11 PM Mark Thomas <ma...@apache.org> wrote:
> 
>> On 26/01/2021 14:06, Rémy Maucherat wrote:
>>> On Tue, Jan 26, 2021 at 2:56 PM <ma...@apache.org> wrote:
>>>
>>>> This is an automated email from the ASF dual-hosted git repository.
>>>>
>>>> markt pushed a commit to branch 9.0.x
>>>> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>>>>
>>>>
>>>> The following commit(s) were added to refs/heads/9.0.x by this push:
>>>>      new 9ebeda2  Fix a SpotBugs warning - log an message when
>> permission
>>>> setting fails
>>>> 9ebeda2 is described below
>>>>
>>>> commit 9ebeda2df488803d61b371c0cc36db83fe04f197
>>>> Author: Mark Thomas <ma...@apache.org>
>>>> AuthorDate: Tue Jan 26 13:54:52 2021 +0000
>>>>
>>>>     Fix a SpotBugs warning - log an message when permission setting
>> fails
>>>>
>>>
>>> Actually, the "else" seems useless at the moment and should be dropped
>>> altogether.
>>
>> I can do that as I am in the area. Worth logging if attrs is null?
>>
> 
> The result cannot be null, it could only throw an exception. I didn't
> translate the code for the PR very accurately, actually they wanted to set
> the default permissions when getUnixDomainSocketPathPermissions() is null.
> So we'll see later if that is really needed (I think the user could do it
> since it could be sensitive).

OK. I'll clean it up on that basis.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch 9.0.x updated: Fix a SpotBugs warning - log an message when permission setting fails

Posted by Rémy Maucherat <re...@apache.org>.
On Tue, Jan 26, 2021 at 3:11 PM Mark Thomas <ma...@apache.org> wrote:

> On 26/01/2021 14:06, Rémy Maucherat wrote:
> > On Tue, Jan 26, 2021 at 2:56 PM <ma...@apache.org> wrote:
> >
> >> This is an automated email from the ASF dual-hosted git repository.
> >>
> >> markt pushed a commit to branch 9.0.x
> >> in repository https://gitbox.apache.org/repos/asf/tomcat.git
> >>
> >>
> >> The following commit(s) were added to refs/heads/9.0.x by this push:
> >>      new 9ebeda2  Fix a SpotBugs warning - log an message when
> permission
> >> setting fails
> >> 9ebeda2 is described below
> >>
> >> commit 9ebeda2df488803d61b371c0cc36db83fe04f197
> >> Author: Mark Thomas <ma...@apache.org>
> >> AuthorDate: Tue Jan 26 13:54:52 2021 +0000
> >>
> >>     Fix a SpotBugs warning - log an message when permission setting
> fails
> >>
> >
> > Actually, the "else" seems useless at the moment and should be dropped
> > altogether.
>
> I can do that as I am in the area. Worth logging if attrs is null?
>

The result cannot be null, it could only throw an exception. I didn't
translate the code for the PR very accurately, actually they wanted to set
the default permissions when getUnixDomainSocketPathPermissions() is null.
So we'll see later if that is really needed (I think the user could do it
since it could be sensitive).

Rémy


>
> Mark
>
> >
> > Rémy
> >
> >
> >> ---
> >>  java/org/apache/tomcat/util/net/LocalStrings.properties |  3 +++
> >>  java/org/apache/tomcat/util/net/NioEndpoint.java        | 12
> +++++++++---
> >>  2 files changed, 12 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties
> >> b/java/org/apache/tomcat/util/net/LocalStrings.properties
> >> index bcf697c..257f4bf 100644
> >> --- a/java/org/apache/tomcat/util/net/LocalStrings.properties
> >> +++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
> >> @@ -97,6 +97,9 @@ endpoint.nio.keyProcessingError=Error processing
> >> selection key
> >>  endpoint.nio.latchMustBeZero=Latch must be at count zero or null
> >>  endpoint.nio.nullLatch=Latch cannot be null
> >>  endpoint.nio.nullSocketChannel=Invalid null socket channel while
> >> processing poller event
> >> +endpoint.nio.perms.execFail=Failed to set execute permissions for Unix
> >> domain socket [{0}]
> >> +endpoint.nio.perms.readFail=Failed to set read permissions for Unix
> >> domain socket [{0}]
> >> +endpoint.nio.perms.writeFail=Failed to set write permissions for Unix
> >> domain socket [{0}]
> >>  endpoint.nio.pollerEventError=Error processing poller event
> >>  endpoint.nio.registerFail=Failed to register socket with selector from
> >> poller
> >>  endpoint.nio.selectorCloseFail=Failed to close selector when closing
> the
> >> poller
> >> diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java
> >> b/java/org/apache/tomcat/util/net/NioEndpoint.java
> >> index 4ccfd4f..86e377d 100644
> >> --- a/java/org/apache/tomcat/util/net/NioEndpoint.java
> >> +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
> >> @@ -272,9 +272,15 @@ public class NioEndpoint extends
> >> AbstractJsseEndpoint<NioChannel,SocketChannel>
> >>                      Files.setAttribute(path, attrs.name(),
> >> attrs.value());
> >>                  } else {
> >>                      java.io.File file = path.toFile();
> >> -                    file.setReadable(true, false);
> >> -                    file.setWritable(true, false);
> >> -                    file.setExecutable(false, false);
> >> +                    if (!file.setReadable(true, false)) {
> >> +
> >> log.warn(sm.getString("endpoint.nio.perms.readFail", path));
> >> +                    }
> >> +                    if (!file.setWritable(true, false)) {
> >> +
> >> log.warn(sm.getString("endpoint.nio.perms.writeFail", path));
> >> +                    }
> >> +                    if (!file.setExecutable(false, false)) {
> >> +
> >> log.warn(sm.getString("endpoint.nio.perms.execFail", path));
> >> +                    }
> >>                  }
> >>              }
> >>          } else {
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: dev-help@tomcat.apache.org
> >>
> >>
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

Re: [tomcat] branch 9.0.x updated: Fix a SpotBugs warning - log an message when permission setting fails

Posted by Mark Thomas <ma...@apache.org>.
On 26/01/2021 14:06, Rémy Maucherat wrote:
> On Tue, Jan 26, 2021 at 2:56 PM <ma...@apache.org> wrote:
> 
>> This is an automated email from the ASF dual-hosted git repository.
>>
>> markt pushed a commit to branch 9.0.x
>> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>>
>>
>> The following commit(s) were added to refs/heads/9.0.x by this push:
>>      new 9ebeda2  Fix a SpotBugs warning - log an message when permission
>> setting fails
>> 9ebeda2 is described below
>>
>> commit 9ebeda2df488803d61b371c0cc36db83fe04f197
>> Author: Mark Thomas <ma...@apache.org>
>> AuthorDate: Tue Jan 26 13:54:52 2021 +0000
>>
>>     Fix a SpotBugs warning - log an message when permission setting fails
>>
> 
> Actually, the "else" seems useless at the moment and should be dropped
> altogether.

I can do that as I am in the area. Worth logging if attrs is null?

Mark

> 
> Rémy
> 
> 
>> ---
>>  java/org/apache/tomcat/util/net/LocalStrings.properties |  3 +++
>>  java/org/apache/tomcat/util/net/NioEndpoint.java        | 12 +++++++++---
>>  2 files changed, 12 insertions(+), 3 deletions(-)
>>
>> diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties
>> b/java/org/apache/tomcat/util/net/LocalStrings.properties
>> index bcf697c..257f4bf 100644
>> --- a/java/org/apache/tomcat/util/net/LocalStrings.properties
>> +++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
>> @@ -97,6 +97,9 @@ endpoint.nio.keyProcessingError=Error processing
>> selection key
>>  endpoint.nio.latchMustBeZero=Latch must be at count zero or null
>>  endpoint.nio.nullLatch=Latch cannot be null
>>  endpoint.nio.nullSocketChannel=Invalid null socket channel while
>> processing poller event
>> +endpoint.nio.perms.execFail=Failed to set execute permissions for Unix
>> domain socket [{0}]
>> +endpoint.nio.perms.readFail=Failed to set read permissions for Unix
>> domain socket [{0}]
>> +endpoint.nio.perms.writeFail=Failed to set write permissions for Unix
>> domain socket [{0}]
>>  endpoint.nio.pollerEventError=Error processing poller event
>>  endpoint.nio.registerFail=Failed to register socket with selector from
>> poller
>>  endpoint.nio.selectorCloseFail=Failed to close selector when closing the
>> poller
>> diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java
>> b/java/org/apache/tomcat/util/net/NioEndpoint.java
>> index 4ccfd4f..86e377d 100644
>> --- a/java/org/apache/tomcat/util/net/NioEndpoint.java
>> +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
>> @@ -272,9 +272,15 @@ public class NioEndpoint extends
>> AbstractJsseEndpoint<NioChannel,SocketChannel>
>>                      Files.setAttribute(path, attrs.name(),
>> attrs.value());
>>                  } else {
>>                      java.io.File file = path.toFile();
>> -                    file.setReadable(true, false);
>> -                    file.setWritable(true, false);
>> -                    file.setExecutable(false, false);
>> +                    if (!file.setReadable(true, false)) {
>> +
>> log.warn(sm.getString("endpoint.nio.perms.readFail", path));
>> +                    }
>> +                    if (!file.setWritable(true, false)) {
>> +
>> log.warn(sm.getString("endpoint.nio.perms.writeFail", path));
>> +                    }
>> +                    if (!file.setExecutable(false, false)) {
>> +
>> log.warn(sm.getString("endpoint.nio.perms.execFail", path));
>> +                    }
>>                  }
>>              }
>>          } else {
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: dev-help@tomcat.apache.org
>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: [tomcat] branch 9.0.x updated: Fix a SpotBugs warning - log an message when permission setting fails

Posted by Rémy Maucherat <re...@apache.org>.
On Tue, Jan 26, 2021 at 2:56 PM <ma...@apache.org> wrote:

> This is an automated email from the ASF dual-hosted git repository.
>
> markt pushed a commit to branch 9.0.x
> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>
>
> The following commit(s) were added to refs/heads/9.0.x by this push:
>      new 9ebeda2  Fix a SpotBugs warning - log an message when permission
> setting fails
> 9ebeda2 is described below
>
> commit 9ebeda2df488803d61b371c0cc36db83fe04f197
> Author: Mark Thomas <ma...@apache.org>
> AuthorDate: Tue Jan 26 13:54:52 2021 +0000
>
>     Fix a SpotBugs warning - log an message when permission setting fails
>

Actually, the "else" seems useless at the moment and should be dropped
altogether.

Rémy


> ---
>  java/org/apache/tomcat/util/net/LocalStrings.properties |  3 +++
>  java/org/apache/tomcat/util/net/NioEndpoint.java        | 12 +++++++++---
>  2 files changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties
> b/java/org/apache/tomcat/util/net/LocalStrings.properties
> index bcf697c..257f4bf 100644
> --- a/java/org/apache/tomcat/util/net/LocalStrings.properties
> +++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
> @@ -97,6 +97,9 @@ endpoint.nio.keyProcessingError=Error processing
> selection key
>  endpoint.nio.latchMustBeZero=Latch must be at count zero or null
>  endpoint.nio.nullLatch=Latch cannot be null
>  endpoint.nio.nullSocketChannel=Invalid null socket channel while
> processing poller event
> +endpoint.nio.perms.execFail=Failed to set execute permissions for Unix
> domain socket [{0}]
> +endpoint.nio.perms.readFail=Failed to set read permissions for Unix
> domain socket [{0}]
> +endpoint.nio.perms.writeFail=Failed to set write permissions for Unix
> domain socket [{0}]
>  endpoint.nio.pollerEventError=Error processing poller event
>  endpoint.nio.registerFail=Failed to register socket with selector from
> poller
>  endpoint.nio.selectorCloseFail=Failed to close selector when closing the
> poller
> diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java
> b/java/org/apache/tomcat/util/net/NioEndpoint.java
> index 4ccfd4f..86e377d 100644
> --- a/java/org/apache/tomcat/util/net/NioEndpoint.java
> +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
> @@ -272,9 +272,15 @@ public class NioEndpoint extends
> AbstractJsseEndpoint<NioChannel,SocketChannel>
>                      Files.setAttribute(path, attrs.name(),
> attrs.value());
>                  } else {
>                      java.io.File file = path.toFile();
> -                    file.setReadable(true, false);
> -                    file.setWritable(true, false);
> -                    file.setExecutable(false, false);
> +                    if (!file.setReadable(true, false)) {
> +
> log.warn(sm.getString("endpoint.nio.perms.readFail", path));
> +                    }
> +                    if (!file.setWritable(true, false)) {
> +
> log.warn(sm.getString("endpoint.nio.perms.writeFail", path));
> +                    }
> +                    if (!file.setExecutable(false, false)) {
> +
> log.warn(sm.getString("endpoint.nio.perms.execFail", path));
> +                    }
>                  }
>              }
>          } else {
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>