You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by om...@apache.org on 2011/03/04 05:34:15 UTC
svn commit: r1077599 - in
/hadoop/common/branches/branch-0.20-security-patches/src/test/system:
aop/org/apache/hadoop/test/system/ java/org/apache/hadoop/test/system/
Author: omalley
Date: Fri Mar 4 04:34:15 2011
New Revision: 1077599
URL: http://svn.apache.org/viewvc?rev=1077599&view=rev
Log:
commit 6377aa71324aa9146c0df1283f42ff6aa1fbfe84
Author: Vinay Kumar Thota <vi...@yahoo-inc.com>
Date: Tue Jul 27 05:01:59 2010 +0000
HADOOP:6869 from https://issues.apache.org/jira/secure/attachment/12450561/6869-ydist-security.patch
Modified:
hadoop/common/branches/branch-0.20-security-patches/src/test/system/aop/org/apache/hadoop/test/system/DaemonProtocolAspect.aj
hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonClient.java
hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/DaemonProtocol.java
Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/system/aop/org/apache/hadoop/test/system/DaemonProtocolAspect.aj
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/system/aop/org/apache/hadoop/test/system/DaemonProtocolAspect.aj?rev=1077599&r1=1077598&r2=1077599&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/system/aop/org/apache/hadoop/test/system/DaemonProtocolAspect.aj (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/system/aop/org/apache/hadoop/test/system/DaemonProtocolAspect.aj Fri Mar 4 04:34:15 2011
@@ -34,6 +34,8 @@ import org.apache.hadoop.util.Shell.Shel
import org.apache.hadoop.util.Shell;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.permission.FsAction;
+import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.Configuration;
@@ -53,6 +55,10 @@ public aspect DaemonProtocolAspect {
new HashMap<Object, List<ControlAction>>();
private static final Log LOG = LogFactory.getLog(
DaemonProtocolAspect.class.getName());
+
+ private static FsPermission defaultPermission = new FsPermission(
+ FsAction.READ_WRITE, FsAction.READ_WRITE, FsAction.READ_WRITE);
+
/**
* Set if the daemon process is ready or not, concrete daemon protocol should
* implement pointcuts to determine when the daemon is ready and use the
@@ -127,6 +133,50 @@ public aspect DaemonProtocolAspect {
return cloneFileStatus(fileStatus);
}
+ /**
+ * Create a file with given permissions in a file system.
+ * @param path - source path where the file has to create.
+ * @param fileName - file name.
+ * @param permission - file permissions.
+ * @param local - identifying the path whether its local or not.
+ * @throws IOException - if an I/O error occurs.
+ */
+ public void DaemonProtocol.createFile(String path, String fileName,
+ FsPermission permission, boolean local) throws IOException {
+ Path p = new Path(path);
+ FileSystem fs = getFS(p, local);
+ Path filePath = new Path(path, fileName);
+ fs.create(filePath);
+ if (permission == null) {
+ fs.setPermission(filePath, defaultPermission);
+ } else {
+ fs.setPermission(filePath, permission);
+ }
+ fs.close();
+ }
+
+ /**
+ * Create a folder with given permissions in a file system.
+ * @param path - source path where the file has to be creating.
+ * @param folderName - folder name.
+ * @param permission - folder permissions.
+ * @param local - identifying the path whether its local or not.
+ * @throws IOException - if an I/O error occurs.
+ */
+ public void DaemonProtocol.createFolder(String path, String folderName,
+ FsPermission permission, boolean local) throws IOException {
+ Path p = new Path(path);
+ FileSystem fs = getFS(p, local);
+ Path folderPath = new Path(path, folderName);
+ fs.mkdirs(folderPath);
+ if (permission == null) {
+ fs.setPermission(folderPath, defaultPermission);
+ } else {
+ fs.setPermission(folderPath, permission);
+ }
+ fs.close();
+ }
+
public FileStatus[] DaemonProtocol.listStatus(String path, boolean local)
throws IOException {
Path p = new Path(path);
Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonClient.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonClient.java?rev=1077599&r1=1077598&r2=1077599&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonClient.java (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/AbstractDaemonClient.java Fri Mar 4 04:34:15 2011
@@ -27,6 +27,8 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.test.system.process.RemoteProcess;
/**
* Abstract class which encapsulates the DaemonClient which is used in the
@@ -166,6 +168,56 @@ public abstract class AbstractDaemonClie
}
/**
+ * Create a file with full permissions in a file system.
+ * @param path - source path where the file has to create.
+ * @param fileName - file name
+ * @param local - identifying the path whether its local or not.
+ * @throws IOException - if an I/O error occurs.
+ */
+ public void createFile(String path, String fileName,
+ boolean local) throws IOException {
+ getProxy().createFile(path, fileName, null, local);
+ }
+
+ /**
+ * Create a file with given permissions in a file system.
+ * @param path - source path where the file has to create.
+ * @param fileName - file name.
+ * @param permission - file permissions.
+ * @param local - identifying the path whether its local or not.
+ * @throws IOException - if an I/O error occurs.
+ */
+ public void createFile(String path, String fileName,
+ FsPermission permission, boolean local) throws IOException {
+ getProxy().createFile(path, fileName, permission, local);
+ }
+
+ /**
+ * Create a folder with default permissions in a file system.
+ * @param path - source path where the file has to be creating.
+ * @param folderName - folder name.
+ * @param local - identifying the path whether its local or not.
+ * @throws IOException - if an I/O error occurs.
+ */
+ public void createFolder(String path, String folderName,
+ boolean local) throws IOException {
+ getProxy().createFolder(path, folderName, null, local);
+ }
+
+ /**
+ * Create a folder with given permissions in a file system.
+ * @param path - source path where the file has to be creating.
+ * @param folderName - folder name.
+ * @param permission - folder permissions.
+ * @param local - identifying the path whether its local or not.
+ * @throws IOException - if an I/O error occurs.
+ */
+ public void createFolder(String path, String folderName,
+ FsPermission permission, boolean local) throws IOException {
+ getProxy().createFolder(path, folderName, permission, local);
+ }
+
+ /**
* List the statuses of the files/directories in the given path if the path is
* a directory.
*
Modified: hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/DaemonProtocol.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/DaemonProtocol.java?rev=1077599&r1=1077598&r2=1077599&view=diff
==============================================================================
--- hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/DaemonProtocol.java (original)
+++ hadoop/common/branches/branch-0.20-security-patches/src/test/system/java/org/apache/hadoop/test/system/DaemonProtocol.java Fri Mar 4 04:34:15 2011
@@ -23,8 +23,10 @@ import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.io.Writable;
import org.apache.hadoop.ipc.VersionedProtocol;
+import org.apache.hadoop.fs.permission.FsPermission;
/**
* RPC interface of a given Daemon.
@@ -77,6 +79,28 @@ public interface DaemonProtocol extends
FileStatus getFileStatus(String path, boolean local) throws IOException;
/**
+ * Create a file with given permissions in a file system.
+ * @param path - source path where the file has to create.
+ * @param fileName - file name.
+ * @param permission - file permissions.
+ * @param local - identifying the path whether its local or not.
+ * @throws IOException - if an I/O error occurs.
+ */
+ void createFile(String path, String fileName,
+ FsPermission permission, boolean local) throws IOException;
+
+ /**
+ * Create a folder with given permissions in a file system.
+ * @param path - source path where the file has to be creating.
+ * @param folderName - folder name.
+ * @param permission - folder permissions.
+ * @param local - identifying the path whether its local or not.
+ * @throws IOException - if an I/O error occurs.
+ */
+ public void createFolder(String path, String folderName,
+ FsPermission permission, boolean local) throws IOException;
+
+ /**
* List the statuses of the files/directories in the given path if the path is
* a directory.
*