You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-commits@hadoop.apache.org by tu...@apache.org on 2014/05/30 18:49:12 UTC
svn commit: r1598668 - in /hadoop/common/trunk/hadoop-hdfs-project:
hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/service/hadoop/
hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/
hadoop-hdfs/
Author: tucu
Date: Fri May 30 16:49:11 2014
New Revision: 1598668
URL: http://svn.apache.org/r1598668
Log:
HDFS-6404. HttpFS should use a 000 umask for mkdir and create operations. (yoderme via tucu)
Modified:
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/service/hadoop/FileSystemAccessService.java
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java
hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/service/hadoop/FileSystemAccessService.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/service/hadoop/FileSystemAccessService.java?rev=1598668&r1=1598667&r2=1598668&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/service/hadoop/FileSystemAccessService.java (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/main/java/org/apache/hadoop/lib/service/hadoop/FileSystemAccessService.java Fri May 30 16:49:11 2014
@@ -23,6 +23,7 @@ import org.apache.hadoop.conf.Configurat
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.lib.server.BaseService;
import org.apache.hadoop.lib.server.ServiceException;
import org.apache.hadoop.lib.service.FileSystemAccess;
@@ -395,6 +396,10 @@ public class FileSystemAccessService ext
Configuration conf = new Configuration(true);
ConfigurationUtils.copy(serviceHadoopConf, conf);
conf.setBoolean(FILE_SYSTEM_SERVICE_CREATED, true);
+
+ // Force-clear server-side umask to make HttpFS match WebHDFS behavior
+ conf.set(FsPermission.UMASK_LABEL, "000");
+
return conf;
}
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java?rev=1598668&r1=1598667&r2=1598668&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs-httpfs/src/test/java/org/apache/hadoop/fs/http/server/TestHttpFSServer.java Fri May 30 16:49:11 2014
@@ -231,6 +231,105 @@ public class TestHttpFSServer extends HF
reader.close();
}
+ /**
+ * Talks to the http interface to create a file.
+ *
+ * @param filename The file to create
+ * @param perms The permission field, if any (may be null)
+ * @throws Exception
+ */
+ private void createWithHttp ( String filename, String perms )
+ throws Exception {
+ String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
+ String pathOps;
+ if ( perms == null ) {
+ pathOps = MessageFormat.format(
+ "/webhdfs/v1/{0}?user.name={1}&op=CREATE",
+ filename, user);
+ } else {
+ pathOps = MessageFormat.format(
+ "/webhdfs/v1/{0}?user.name={1}&permission={2}&op=CREATE",
+ filename, user, perms);
+ }
+ URL url = new URL(TestJettyHelper.getJettyURL(), pathOps);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.addRequestProperty("Content-Type", "application/octet-stream");
+ conn.setRequestMethod("PUT");
+ conn.connect();
+ Assert.assertEquals(HttpURLConnection.HTTP_CREATED, conn.getResponseCode());
+ }
+
+ /**
+ * Talks to the http interface to get the json output of the GETFILESTATUS
+ * command on the given file.
+ *
+ * @param filename The file to query.
+ * @return A string containing the JSON output describing the file.
+ * @throws Exception
+ */
+ private String getFileStatus ( String filename ) throws Exception {
+ String user = HadoopUsersConfTestHelper.getHadoopUsers()[0];
+ String pathOps = MessageFormat.format(
+ "/webhdfs/v1/{0}?user.name={1}&op=GETFILESTATUS",
+ filename, user);
+ URL url = new URL(TestJettyHelper.getJettyURL(), pathOps);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.connect();
+ Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode());
+
+ BufferedReader reader =
+ new BufferedReader(new InputStreamReader(conn.getInputStream()));
+
+ return reader.readLine();
+ }
+
+ /**
+ * Given the JSON output from the GETFILESTATUS call, return the
+ * 'permission' value.
+ *
+ * @param statusJson JSON from GETFILESTATUS
+ * @return The value of 'permission' in statusJson
+ * @throws Exception
+ */
+ private String getPerms ( String statusJson ) throws Exception {
+ JSONParser parser = new JSONParser();
+ JSONObject jsonObject = (JSONObject) parser.parse(statusJson);
+ JSONObject details = (JSONObject) jsonObject.get("FileStatus");
+ return (String) details.get("permission");
+ }
+
+ /**
+ * Validate that files are created with 755 permissions when no
+ * 'permissions' attribute is specified, and when 'permissions'
+ * is specified, that value is honored.
+ */
+ @Test
+ @TestDir
+ @TestJetty
+ @TestHdfs
+ public void testPerms() throws Exception {
+ createHttpFSServer(false);
+
+ FileSystem fs = FileSystem.get(TestHdfsHelper.getHdfsConf());
+ fs.mkdirs(new Path("/perm"));
+
+ createWithHttp("/perm/none", null);
+ String statusJson = getFileStatus("/perm/none");
+ Assert.assertTrue("755".equals(getPerms(statusJson)));
+
+ createWithHttp("/perm/p-777", "777");
+ statusJson = getFileStatus("/perm/p-777");
+ Assert.assertTrue("777".equals(getPerms(statusJson)));
+
+ createWithHttp("/perm/p-654", "654");
+ statusJson = getFileStatus("/perm/p-654");
+ Assert.assertTrue("654".equals(getPerms(statusJson)));
+
+ createWithHttp("/perm/p-321", "321");
+ statusJson = getFileStatus("/perm/p-321");
+ Assert.assertTrue("321".equals(getPerms(statusJson)));
+ }
+
@Test
@TestDir
@TestJetty
Modified: hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt?rev=1598668&r1=1598667&r2=1598668&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt Fri May 30 16:49:11 2014
@@ -620,6 +620,9 @@ Release 2.5.0 - UNRELEASED
HDFS-6462. NFS: fsstat request fails with the secure hdfs (brandonli)
+ HDFS-6404. HttpFS should use a 000 umask for mkdir and create
+ operations. (yoderme via tucu)
+
Release 2.4.1 - UNRELEASED
INCOMPATIBLE CHANGES