Author: dhruba Date: Thu Jan 17 12:47:43 2008 New Revision: 612974 URL: http://svn.apache.org/viewvc?rev=612974&view=rev Log: HADOOP-2614. Accesses from the HDFS WebUI are configured to be from the user specified by dfs.web.ugi. (Tsz Wo (Nicholas), SZE via dhruba)
Modified: lucene/hadoop/trunk/CHANGES.txt lucene/hadoop/trunk/conf/hadoop-default.xml lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.java lucene/hadoop/trunk/src/java/org/apache/hadoop/security/UnixUserGroupInformation.java lucene/hadoop/trunk/src/webapps/datanode/browseDirectory.jsp Modified: lucene/hadoop/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?rev=612974&r1=612973&r2=612974&view=diff ============================================================================== --- lucene/hadoop/trunk/CHANGES.txt (original) +++ lucene/hadoop/trunk/CHANGES.txt Thu Jan 17 12:47:43 2008 @@ -489,6 +489,9 @@ HADOOP-2620. Trivial. 'bin/hadoop fs -help' did not list chmod, chown, and chgrp. (Raghu Angadi) + HADOOP-2614. The DFS WebUI accesses are configured to be from the user + specified by dfs.web.ugi. (Tsz Wo (Nicholas), SZE via dhruba) + Release 0.15.3 - 2008-01-18 BUG FIXES Modified: lucene/hadoop/trunk/conf/hadoop-default.xml URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/conf/hadoop-default.xml?rev=612974&r1=612973&r2=612974&view=diff ============================================================================== --- lucene/hadoop/trunk/conf/hadoop-default.xml (original) +++ lucene/hadoop/trunk/conf/hadoop-default.xml Thu Jan 17 12:47:43 2008 @@ -273,6 +273,14 @@ </property> <property> + <name>dfs.web.ugi</name> + <value>webuser,webgroup</value> + <description>The user account used by the web interface. + Syntax: USERNAME,GROUP1,GROUP2, ... + </description> +</property> + +<property> <name>dfs.permissions</name> <value>true</value> <description> Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.java URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.java?rev=612974&r1=612973&r2=612974&view=diff ============================================================================== --- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.java (original) +++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/JspHelper.java Thu Jan 17 12:47:43 2008 @@ -36,8 +36,11 @@ import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.FsShell; import org.apache.hadoop.net.NetUtils; +import org.apache.hadoop.security.*; public class JspHelper { + final static public String WEB_UGI_PROPERTY_NAME = "dfs.web.ugi"; + static FSNamesystem fsn = null; static InetSocketAddress nameNodeAddr; public static Configuration conf = new Configuration(); @@ -55,6 +58,10 @@ nameNodeAddr = new InetSocketAddress(fsn.getDFSNameNodeMachine(), fsn.getDFSNameNodePort()); } + + UnixUserGroupInformation.saveToConf(conf, + UnixUserGroupInformation.UGI_PROPERTY_NAME, + new UnixUserGroupInformation(conf.getStrings(WEB_UGI_PROPERTY_NAME))); } public DatanodeInfo bestNode(LocatedBlock blk) throws IOException { TreeSet<DatanodeInfo> deadNodes = new TreeSet<DatanodeInfo>(); Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/security/UnixUserGroupInformation.java URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/security/UnixUserGroupInformation.java?rev=612974&r1=612973&r2=612974&view=diff ============================================================================== --- lucene/hadoop/trunk/src/java/org/apache/hadoop/security/UnixUserGroupInformation.java (original) +++ lucene/hadoop/trunk/src/java/org/apache/hadoop/security/UnixUserGroupInformation.java Thu Jan 17 12:47:43 2008 @@ -67,7 +67,7 @@ * @exception IllegalArgumentException if the array size is less than 2 * or any element is null. */ - UnixUserGroupInformation(String[] ugi) { + public UnixUserGroupInformation(String[] ugi) { if (ugi==null || ugi.length < 2) { throw new IllegalArgumentException( "Parameter does contain at least "+ "one user name and one group name"); Modified: lucene/hadoop/trunk/src/webapps/datanode/browseDirectory.jsp URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/webapps/datanode/browseDirectory.jsp?rev=612974&r1=612973&r2=612974&view=diff ============================================================================== --- lucene/hadoop/trunk/src/webapps/datanode/browseDirectory.jsp (original) +++ lucene/hadoop/trunk/src/webapps/datanode/browseDirectory.jsp Thu Jan 17 12:47:43 2008 @@ -101,36 +101,21 @@ //Get the location of the first block of the file if (files[i].getPath().toString().endsWith(".crc")) continue; if (!files[i].isDir()) { - List<LocatedBlock> blocks = - dfs.namenode.getBlockLocations(files[i].getPath().toString(), 0, 1).getLocatedBlocks(); - DatanodeInfo [] locations = null; - if (blocks.size() != 0) { - locations = blocks.get(0).getLocations(); - } - if (locations == null || locations.length == 0) { - cols[0] = files[i].getName(); - } else { - String datanodeUrl = req.getRequestURL()+"?dir="+ - URLEncoder.encode(files[i].getPath().toString(), "UTF-8") + - "&namenodeInfoPort=" + namenodeInfoPort; - - cols[0] = "<a href=\""+datanodeUrl+"\">"+files[i].getName()+"</a>"; - } cols[1] = "file"; cols[2] = FsShell.byteDesc(files[i].getLen()); cols[3] = Short.toString(files[i].getReplication()); cols[4] = FsShell.byteDesc(files[i].getBlockSize()); } else { - String datanodeUrl = req.getRequestURL()+"?dir="+ - URLEncoder.encode(files[i].getPath().toString(), "UTF-8") + - "&namenodeInfoPort=" + namenodeInfoPort; - cols[0] = "<a href=\""+datanodeUrl+"\">"+files[i].getName()+"</a>"; cols[1] = "dir"; cols[2] = ""; cols[3] = ""; cols[4] = ""; } + String datanodeUrl = req.getRequestURL()+"?dir="+ + URLEncoder.encode(files[i].getPath().toString(), "UTF-8") + + "&namenodeInfoPort=" + namenodeInfoPort; + cols[0] = "<a href=\""+datanodeUrl+"\">"+files[i].getName()+"</a>"; cols[5] = FsShell.dateForm.format(new Date((files[i].getModificationTime()))); cols[6] = files[i].getPermission().toString(); cols[7] = files[i].getOwner(); @@ -164,7 +149,17 @@ <body onload="document.goto.dir.focus()"> <% - generateDirectoryStructure(out,request,response); + try { + generateDirectoryStructure(out,request,response); + } + catch(IOException ioe) { + String msg = ioe.getLocalizedMessage(); + int i = msg.indexOf("\n"); + if (i >= 0) { + msg = msg.substring(0, i); + } + out.print("<h3>" + msg + "</h3>"); + } %> <hr>