{"record":{"id":"fff045655e7a99a1","repo":"juicedata/juicefs","slug":"only-superuser-can-do-setowner-action-the-current","errorCode":null,"errorMessage":"Only SuperUser can do setOwner Action, the current user is \" + username","messagePattern":"Only SuperUser can do setOwner Action, the current user is \" \\+ username","errorType":"exception","errorClass":"AccessControlException","httpStatus":null,"severity":"error","filePath":"sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java","lineNumber":1951,"sourceCode":"    if (needCheckPermission() && !checkOwner(p, \"setPermission\")) {\n      superGroupFileSystem.setPermission(p, permission);\n      return;\n    }\n    statistics.incrementWriteOps(1);\n    int r = lib.jfs_chmod(Thread.currentThread().getId(), handle, normalizePath(p), permission.toShort());\n    if (r != 0)\n      throw error(r, p);\n  }\n\n  @Override\n  public void setOwner(Path p, String username, String groupname) throws IOException {\n    if (needCheckPermission()) {\n      if (username == null) {\n        throw new AccessControlException(\n            \"User can not be null\");\n      }\n      if (!superuser.equals(username)) {\n        throw new AccessControlException(\n            \"Only SuperUser can do setOwner Action, the current user is \" + username);\n      }\n      superGroupFileSystem.setOwner(p, username, groupname);\n      return;\n    }\n    statistics.incrementWriteOps(1);\n    int r = lib.jfs_setOwner(Thread.currentThread().getId(), handle, normalizePath(p), username, groupname);\n    if (r != 0)\n      throw error(r, p);\n  }\n\n  @Override\n  public void setTimes(Path p, long mtime, long atime) throws IOException {\n    if (needCheckPermission() && !checkPathAccess(p, FsAction.WRITE, \"setTimes\")) {\n      superGroupFileSystem.setTimes(p, mtime, atime);\n      return;\n    }\n    statistics.incrementWriteOps(1);","sourceCodeStart":1933,"sourceCodeEnd":1969,"githubUrl":"https://github.com/juicedata/juicefs/blob/c9a67b23e8e08ec23ec331aa6f1675e2319e921c/sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java#L1933-L1969","documentation":"Thrown by setOwner in the JuiceFileSystemImpl when the current user is not the super user (the superuser.isSuperUser style check fails) and permission checking is enabled. Ownership changes are restricted to the superuser, so the guard rejects any setOwner call from a regular user.","triggerScenarios":"Thrown at sdk/java/src/main/java/io/juicefs/JuiceFileSystemImpl.java:1951 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the setOwner operation as the configured super user (typically the user who formatted the volume)","Configure the client so permission checks are not enforced locally and ownership is managed elsewhere"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"c9a67b23e8e08ec23ec331aa6f1675e2319e921c","analyzedAt":"2026-09-06T17:55:48.476Z","contentChangedAt":"2026-09-06T17:55:48.476Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}