Skip to content

Commit fe14eac

Browse files
committed
Multi user fix requiring a 'super user' specification in the core-site.xml. The super user should be used to run the hadoop daemon services.
This user will be granted read access to the DFS for job scheduling purposes.
1 parent 16936d0 commit fe14eac

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

conf/core-site.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@
2424
<value>glusterfs://ambari-3.abrv8.com:gv0<</value>
2525
</property>
2626

27-
27+
<!-- a super user that the hadoop daemons run under. required for multi-user secure clusters -->
28+
<property>
29+
<name>gluster.daemon.user</name>
30+
<value>hadoop</value>
31+
</property>
32+
2833
<!-- this is the default glusterfs hook with no additional integrity checking on files -->
2934
<property>
3035
<name>fs.AbstractFileSystem.glusterfs.impl</name>

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@
3434
import org.apache.hadoop.fs.RawLocalFileSystem;
3535
import org.slf4j.Logger;
3636
import org.slf4j.LoggerFactory;
37+
import org.apache.hadoop.fs.permission.FsPermission;
3738

3839
public class GlusterVolume extends RawLocalFileSystem{
3940

4041
static final Logger log = LoggerFactory.getLogger(GlusterFileSystemCRC.class);
4142
public static final URI NAME = URI.create("glusterfs:///");
4243

4344
protected String root=null;
45+
protected String superUser=null;
4446

4547
protected static GlusterFSXattr attr = null;
4648

@@ -79,6 +81,8 @@ public void setConf(Configuration conf){
7981
mkdirs(mapredSysDirectory);
8082
}
8183

84+
superUser = conf.get("gluster.daemon.user", null);
85+
8286
//volName=conf.get("fs.glusterfs.volname", null);
8387
//remoteGFSServer=conf.get("fs.glusterfs.server", null);
8488

@@ -155,7 +159,36 @@ public long getBlockSize(Path path) throws IOException{
155159

156160
return blkSz;
157161
}
158-
162+
/*
163+
* ensures the 'super user' is given read/write access.
164+
* the ACL drops off after a chmod or chown.
165+
*/
166+
167+
private void updateAcl(Path p){
168+
if(superUser!=null){
169+
File f = pathToFile(p);
170+
String path = f.getAbsolutePath();
171+
String command = "setfacl -m u:" + superUser + ":rwx " + path;
172+
try{
173+
Runtime.getRuntime().exec(command);
174+
}catch(IOException ex){
175+
throw new RuntimeException(ex);
176+
}
177+
}
178+
}
179+
180+
public void setOwner(Path p, String username, String groupname)
181+
throws IOException {
182+
super.setOwner(p,username,groupname);
183+
updateAcl(p);
184+
185+
}
186+
187+
public void setPermission(Path p, FsPermission permission)
188+
throws IOException {
189+
super.setPermission(p,permission);
190+
updateAcl(p);
191+
}
159192
public BlockLocation[] getFileBlockLocations(FileStatus file,long start,long len) throws IOException{
160193
File f=pathToFile(file.getPath());
161194
BlockLocation[] result=null;

0 commit comments

Comments
 (0)