Skip to content

Commit 4a2ca73

Browse files
author
Matthew Farrellee
committed
Make the getfattrCmd configurable, via fs.glusterfs.getfattrcmd, in GlusterFSXattr
To use this, 0. create a setuid program that a. takes a filename (with path) as argv[1] b. retrieves trusted.glusterfs.pathinfo with getxattr(2) c. prints it to stdout via printf("trusted.glusterfs.pathinfo=\"%s\"\n", ...) 1. provide it as the value to the fs.glusterfs.getfattrcmd property Signed-off-by: Matthew Farrellee <[email protected]>
1 parent 039cdbb commit 4a2ca73

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/main/java/org/apache/hadoop/fs/glusterfs/GlusterFSXattr.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.ArrayList;
2929
import java.util.Iterator;
3030

31+
import org.apache.hadoop.conf.Configuration;
3132
import org.apache.hadoop.fs.BlockLocation;
3233

3334
public class GlusterFSXattr{
@@ -42,7 +43,11 @@ public enum CMD {
4243

4344
private static String hostname;
4445

45-
public GlusterFSXattr(){
46+
private String getFattrCmdBase;
47+
48+
public GlusterFSXattr(Configuration conf) {
49+
getFattrCmdBase=conf.get("fs.glusterfs.getfattrcmd",
50+
"getfattr -m . -n trusted.glusterfs.pathinfo");
4651
}
4752

4853
public String brick2host(String brick) throws IOException{
@@ -135,7 +140,7 @@ public HashMap<String, ArrayList<String>> execGetFattr(String filename,HashMap<S
135140

136141
HashMap<String, ArrayList<String>> vol=new HashMap<String, ArrayList<String>>();
137142

138-
getfattrCmd="getfattr -m . -n trusted.glusterfs.pathinfo "+filename;
143+
getfattrCmd=this.getFattrCmdBase + " " + filename;
139144

140145
p=Runtime.getRuntime().exec(getfattrCmd);
141146
brInput=new BufferedReader(new InputStreamReader(p.getInputStream()));

src/main/java/org/apache/hadoop/fs/glusterfs/GlusterFileSystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void initialize(URI uri,Configuration conf) throws IOException{
140140
this.workingDir=new Path(glusterMount);
141141
this.uri=URI.create(uri.getScheme()+"://"+uri.getAuthority());
142142

143-
this.xattr=new GlusterFSXattr();
143+
this.xattr=new GlusterFSXattr(conf);
144144

145145
InetAddress addr=InetAddress.getLocalHost();
146146
this.hostname=addr.getHostName();

0 commit comments

Comments
 (0)