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

zhihai xu commented on YARN-2701:
---------------------------------

thanks [~xgong],  I want to discuss about check_permission:

Do we need to check the directory permission?
Before YARN-2161 patch was committed, the code didn't check the permission.
{code}
   if (mkdirat(cwd, token, perm) != 0) {
      if (errno != EEXIST) {
        fprintf(LOGFILE, "Can't create directory %s in %s - %s\n", 
                token, path, strerror(errno));
        close(cwd);
        free(buffer);
        return -1;
      }
    }
{code}

If we want to check permission, Can we change the permission if the permission 
doesn't match?
{code}
int check_permission(char* path, mode_t filePerm, mode_t desired) {
  int filePermInt = filePerm & (S_IRWXU | S_IRWXG | S_IRWXO);
  int desiredInt = desired & (S_IRWXU | S_IRWXG | S_IRWXO);
  if (filePermInt != desiredInt) {
      if (chmod(path, desiredInt | (filePerm & (S_ISUID | S_ISGID | S_ISVTX))) 
!= 0) {
        return -1;
    }
  }
  return 0;
}
{code}


> Potential race condition in startLocalizer when using LinuxContainerExecutor  
> ------------------------------------------------------------------------------
>
>                 Key: YARN-2701
>                 URL: https://issues.apache.org/jira/browse/YARN-2701
>             Project: Hadoop YARN
>          Issue Type: Bug
>            Reporter: Xuan Gong
>            Assignee: Xuan Gong
>            Priority: Blocker
>         Attachments: YARN-2701.1.patch, YARN-2701.2.patch, YARN-2701.3.patch
>
>
> When using LinuxContainerExecutor do startLocalizer, we are using native code 
> container-executor.c. 
> {code}
>      if (stat(npath, &sb) != 0) {
>        if (mkdir(npath, perm) != 0) {
> {code}
> We are using check and create method to create the appDir under /usercache. 
> But if there are two containers trying to do this at the same time, race 
> condition may happen.



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

Reply via email to