Caideyipi commented on code in PR #19029:
URL: https://github.com/apache/iotdb/pull/19029#discussion_r4387595996


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/active/ActiveLoadTsFileLoader.java:
##########
@@ -324,6 +338,46 @@ private TSStatus loadTsFile(
     }
   }
 
+  /**
+   * Resolves the user that executes the load of the given file.
+   *
+   * <p>Files handed over by the pipe receiver or by an asynchronous {@code 
LOAD} always carry the
+   * authenticated user in their path, because the receiver never hands over a 
file without a user
+   * attribute directory. A file without any attribute directory can therefore 
only have been placed
+   * into the active listening directory by a local operator, either directly 
or into a sub
+   * directory that names the database of a table model file. Such a load is a 
local operation that
+   * already requires filesystem privileges on the DataNode, so it is executed 
with the default
+   * user. Anything else must not be loaded, otherwise a sender could drop the 
user attribute and be
+   * loaded as a privileged default.
+   *
+   * @return the user that executes the load, or {@code null} if it can not be 
determined
+   */
+  private static String resolveLoadUser(
+      final Map<String, String> attributes, final File tsFile, final File 
pendingDir) {
+    final String userName = attributes.get(ActiveLoadPathHelper.USER_KEY);
+    if (Objects.nonNull(userName) && !userName.isEmpty()) {
+      return userName;
+    }
+    return attributes.isEmpty() && isInsideListeningDir(tsFile, pendingDir)

Review Comment:
   **[P2] Preserve local active-load directories that carry LOAD options**
   
   A locally dropped file can also have recognized attribute directories, e.g. 
`<listeningDir>/verify-false/1-0-0-0.tsfile` or 
`<listeningDir>/database-name-mydb/1-0-0-0.tsfile`. `parseAttributes` returns a 
nonempty map without `user` for these paths, so this condition now returns 
`null` and `loadTsFile` moves the file into the failure directory. The base 
revision loaded these files with the default user. The presence of LOAD options 
does not establish that a file came from a remote sender, and neither new 
identity switch affects this branch. Please distinguish local inputs from 
receiver handoffs when requiring an explicit user, and cover a locally dropped 
file with attributes but no user in a regression test.



##########
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/receiver/IoTDBFileReceiver.java:
##########
@@ -82,8 +80,11 @@ public abstract class IoTDBFileReceiver implements 
IoTDBReceiver {
   // Used to restore the original thread name when the receiver is closed.
   private String originalThreadName;
 
-  protected String username = CONNECTOR_IOTDB_USER_DEFAULT_VALUE;
-  protected String password = CONNECTOR_IOTDB_PASSWORD_DEFAULT_VALUE;
+  // The identity of the sender is only set after a successful handshake or 
taken from a logged in
+  // session. There is deliberately no default user, because a missing 
identity must never degrade
+  // to a privileged one.
+  protected String username;

Review Comment:
   **[P2] Update the legacy receiver tests for the removed default identity**
   
   A successful V1 handshake does not populate `username`, and 
`recordPipeReceiverHandshake` uses this field directly. Removing its default 
changes the reported user from `root` to `Unknown`, but 
`IoTDBShowReceiversIT.hasOldSenderReceiverRuntime` still requires 
`SessionConfig.DEFAULT_USER`. This already causes 
`testOldSenderRuntimeShowsUnknownPipeIdsAndDisappearsAfterClientClose` and 
`testReceiverRuntimeClearedAfterDataNodeRestartAndCanReconnect` to time out in 
the [pipe single-cluster CI 
job](https://github.com/apache/iotdb/actions/runs/40480411004/job/122108993687) 
for `4547a819701`; this path is unchanged in the latest commit. Please update 
the legacy-handshake runtime/test expectations consistently with the new 
identity semantics and rerun those two cases, preserving the removal of 
privileged default credentials.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to