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

Steve Loughran commented on HADOOP-6566:
----------------------------------------

When I start up daemons I do create the directories on demand, code does the 
following
# extracts a list of directories from the deployment config info
# goes through trying to create them, logging ones it can't
# fails if there aren't any with a useful error message that even lists the dirs
# returns that list of dirs in a format that can then be handled by normal Conf 
parsers
# add that attr to the live graph of system state.

This lets me set up the directories on the fly and publishes that information. 
Reviewing my code I see that I am not doing enough checks that the dirs really 
are of type "directory", I must be assuming that the stuff later on can handle 
that. Which they seem to, but their error messages don't include the directory 
listings in " java.io.IOException: All specified directories are not accessible 
or do not exist", which is a shame

{code}
   /**
     * Run through the directories, create all that are there
     *
     * @param dirs       list of directories
     * @param createDirs create the directories?
     * @return the directories all converted to a list split by commas
     */
    public static String createDirectoryList(Vector<String> dirs, boolean 
createDirs) 
      throws FileNotFoundException {
        StringBuilder path = new StringBuilder();
        int failureCount = 0;
        StringBuilder failureText = new StringBuilder();
        for (String dir : dirs) {
            File directory = new File(dir);
            if (createDirs) {
                if(!directory.mkdirs() && !directory.exists()) {
                    String message = "Failed to create directory " + directory;
                    LogFactory.getLog(HadoopComponentImpl.class.getName())
                            .warn(message);
                    failureCount++;
                    failureText.append(message).append("\n");
                }
            }
            if (path.length() > 0) {
                path.append(',');
            }
            path.append(directory.getAbsolutePath());
        }
        if (failureCount == dirs.size()) {
            throw new FileNotFoundException("Failed to create any of " + 
path.toString());
        }
        return path.toString();
    }
{code}

> Hadoop daemons should not start up if the ownership/permissions on the 
> directories used at runtime are misconfigured
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-6566
>                 URL: https://issues.apache.org/jira/browse/HADOOP-6566
>             Project: Hadoop Common
>          Issue Type: New Feature
>          Components: security
>            Reporter: Devaraj Das
>             Fix For: 0.22.0
>
>
> The Hadoop daemons (like datanode, namenode) should refuse to start up if the 
> ownership/permissions on directories they use at runtime are misconfigured or 
> they are not as expected. For example, the local directory where the 
> filesystem image is stored should be owned by the user running the namenode 
> process and should be only readable by that user. We can provide this feature 
> in common and HDFS and MapReduce can use the same.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to