[ 
https://issues.apache.org/jira/browse/HADOOP-12344?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14723958#comment-14723958
 ] 

Colin Patrick McCabe commented on HADOOP-12344:
-----------------------------------------------

bq. ..the secret of having tests match is to make some of the text (e.g. the 
wiki link) a string constant in the source, with the test using a .contains() 
probe for it. That way, changes in the text are automatically picked up in the 
test
In this case, the string is being generated in the C source and checked in the 
Java tests, so it would be difficult to have a constant shared between the two.

The new text looks fine to me, but the code needs work.

{code}
-  for (check[0] = '/', check[1] = '\0', rest = path, token = "";
+  for (check[0] = '/', check[1] = '\0', rest=strdup(path), rest_free=rest, 
token = "";
{code}
This isn't correctly checking for {{strdup}} returning NULL.

{code}
+      jthr = newIOException(env, "failed to stat a path component: '%s' in 
'%s'.  "
+          "error code %d (%s).  Ensure that the path is configured 
correctly.", check, path, ret, terror(ret));
{code}
More than 80 columns

{code}
+      perm_msg=(char *)malloc(PATH_MAX+200);
{code}
You don't need a typecast here.  You do need to check for NULL if you use 
dynamic allocation (why are you using dynamic allocation anyway?)

{code}
+      snprintf(perm_msg,PATH_MAX+200,"is world-writable. This might help: 
'chmod o-w %s'. ",check);
{code}
PATH_MAX+200 is really gross.  Why don't you just use newIOException, it 
handles all this string manipulation and dynamic allocation for you?

Please fix this stuff before you commit.

> validateSocketPathSecurity0 message could be better
> ---------------------------------------------------
>
>                 Key: HADOOP-12344
>                 URL: https://issues.apache.org/jira/browse/HADOOP-12344
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: net
>            Reporter: Casey Brotherton
>            Assignee: Casey Brotherton
>            Priority: Trivial
>         Attachments: HADOOP-12344.001.patch, HADOOP-12344.002.patch, 
> HADOOP-12344.patch
>
>
> When a socket path does not have the correct permissions, an error is thrown.
> That error just has the failing component of the path and not the entire path 
> of the socket.
> The entire path of the socket could be printed out to allow for a direct 
> check of the permissions of the entire path.
> {code}
> java.io.IOException: the path component: '/' is world-writable.  Its 
> permissions are 0077.  Please fix this or select a different socket path.
>       at 
> org.apache.hadoop.net.unix.DomainSocket.validateSocketPathSecurity0(Native 
> Method)
>       at 
> org.apache.hadoop.net.unix.DomainSocket.bindAndListen(DomainSocket.java:189)
> ...
> {code}
> The error message could also provide the socket path:
> {code}
> java.io.IOException: the path component: '/' is world-writable.  Its 
> permissions are 0077.  Please fix this or select a different socket path than 
> '/var/run/hdfs-sockets/dn'
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to