[ https://issues.apache.org/jira/browse/HADOOP-18145?focusedWorklogId=747798&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-747798 ]
ASF GitHub Bot logged work on HADOOP-18145: ------------------------------------------- Author: ASF GitHub Bot Created on: 25/Mar/22 14:03 Start Date: 25/Mar/22 14:03 Worklog Time Spent: 10m Work Description: steveloughran commented on a change in pull request #4036: URL: https://github.com/apache/hadoop/pull/4036#discussion_r835272119 ########## File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java ########## @@ -677,6 +683,31 @@ public static void unZip(InputStream inputStream, File toDir) } } + public static Set<PosixFilePermission> permissionsFromMode(int mode) { Review comment: 1. can you add some javadocs to say that these only deal with user/group/other and not suid 2. can you make package scoped so it can be called in tests, but not by applications (so we don't have to maintain consistent behaviour forever) ########## File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java ########## @@ -677,6 +683,31 @@ public static void unZip(InputStream inputStream, File toDir) } } + public static Set<PosixFilePermission> permissionsFromMode(int mode) { + EnumSet<PosixFilePermission> permissions = + EnumSet.noneOf(PosixFilePermission.class); + addPermissions(permissions, "OTHERS", (long) mode); + addPermissions(permissions, "GROUP", (long) mode >> 3); + addPermissions(permissions, "OWNER", (long) mode >> 6); + return permissions; + } + + /** Assign the original permissions to the file */ Review comment: 1. add params to javadoc and staqte that only bottom 7 bits are used 2. make package private ########## File path: hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java ########## @@ -677,6 +683,31 @@ public static void unZip(InputStream inputStream, File toDir) } } + public static Set<PosixFilePermission> permissionsFromMode(int mode) { + EnumSet<PosixFilePermission> permissions = + EnumSet.noneOf(PosixFilePermission.class); + addPermissions(permissions, "OTHERS", (long) mode); + addPermissions(permissions, "GROUP", (long) mode >> 3); + addPermissions(permissions, "OWNER", (long) mode >> 6); + return permissions; + } + + /** Assign the original permissions to the file */ + public static void addPermissions( + Set<PosixFilePermission> permissions, + String prefix, + Long mode) { Review comment: nit, should be int -- 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: common-issues-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 747798) Time Spent: 7h 10m (was: 7h) > Fileutil's unzip method causes unzipped files to lose their original > permissions > -------------------------------------------------------------------------------- > > Key: HADOOP-18145 > URL: https://issues.apache.org/jira/browse/HADOOP-18145 > Project: Hadoop Common > Issue Type: Bug > Components: common > Affects Versions: 2.7.2 > Reporter: jingxiong zhong > Priority: Major > Labels: pull-request-available > Time Spent: 7h 10m > Remaining Estimate: 0h > > When Spark decompresses the zip file, if the original file has the executable > permission, but the unzip method of FileUtil is invoked, the decompressed > file loses the executable permission, we should save the original permission -- This message was sent by Atlassian Jira (v8.20.1#820001) --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org