Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-15667

Audit log record the unexpected allowed result when delete called

    XMLWordPrintableJSON

Details

    Description

      I met this issue if rm root directory, for remove non-root and non-empty directory, toRemovedBlocks isn't null, its toDeleteList size is 0.

      when will return null?

      Through this screenshot, we can find that if fileRemoved = -1, then toRemovedBlocks = null

      And when deleteAllowed(iip) return false, fileRemoved can be -1,

       private static boolean deleteAllowed(final INodesInPath iip) {
          if (iip.length() < 1 || iip.getLastINode() == null) {
            if (NameNode.stateChangeLog.isDebugEnabled()) {
              NameNode.stateChangeLog.debug(
                  "DIR* FSDirectory.unprotectedDelete: failed to remove "
                      + iip.getPath() + " because it does not exist");
            }
            return false;
          } else if (iip.length() == 1) { // src is the root
            NameNode.stateChangeLog.warn(
                "DIR* FSDirectory.unprotectedDelete: failed to remove " +
                    iip.getPath() + " because the root is not allowed to be deleted");
            return false;
          }
          return true;
        }
      

      Through the code of deleteAllowed, we can find that when src is the root, it can return false.

      So without this PR, when I execute bin/hdfs dfs -rm -r /

      I find the confusing auditlog line like following

      2020-11-05 14:32:53,420 INFO FSNamesystem.audit (FSNamesystem.java:logAuditMessage(8102)) - allowed=true

      Attachments

        1. screenshot-1.png
          275 kB
          Baolong Mao
        2. screenshot-2.png
          73 kB
          Baolong Mao

        Issue Links

          Activity

            People

              maobaolong Baolong Mao
              maobaolong Baolong Mao
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 4h 50m
                  4h 50m