|
34 | 34 | import org.apache.hadoop.fs.RawLocalFileSystem;
|
35 | 35 | import org.slf4j.Logger;
|
36 | 36 | import org.slf4j.LoggerFactory;
|
| 37 | +import org.apache.hadoop.fs.permission.FsPermission; |
37 | 38 |
|
38 | 39 | public class GlusterVolume extends RawLocalFileSystem{
|
39 | 40 |
|
40 | 41 | static final Logger log = LoggerFactory.getLogger(GlusterFileSystemCRC.class);
|
41 | 42 | public static final URI NAME = URI.create("glusterfs:///");
|
42 | 43 |
|
43 | 44 | protected String root=null;
|
| 45 | + protected String superUser=null; |
44 | 46 |
|
45 | 47 | protected static GlusterFSXattr attr = null;
|
46 | 48 |
|
@@ -79,6 +81,8 @@ public void setConf(Configuration conf){
|
79 | 81 | mkdirs(mapredSysDirectory);
|
80 | 82 | }
|
81 | 83 |
|
| 84 | + superUser = conf.get("gluster.daemon.user", null); |
| 85 | + |
82 | 86 | //volName=conf.get("fs.glusterfs.volname", null);
|
83 | 87 | //remoteGFSServer=conf.get("fs.glusterfs.server", null);
|
84 | 88 |
|
@@ -155,7 +159,36 @@ public long getBlockSize(Path path) throws IOException{
|
155 | 159 |
|
156 | 160 | return blkSz;
|
157 | 161 | }
|
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 | + } |
159 | 192 | public BlockLocation[] getFileBlockLocations(FileStatus file,long start,long len) throws IOException{
|
160 | 193 | File f=pathToFile(file.getPath());
|
161 | 194 | BlockLocation[] result=null;
|
|
0 commit comments