Review Board 1.7.22


HIVE-4741: Add Hive config API to modify the restrict list

Review Request #11905 - Created June 17, 2013 and updated

Prasad Mujumdar
trunk
HIVE-4741
Reviewers
hive
hive-git
Add Hive config API to modify the restrict list
Added new test case for restrict list
common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
Revision 40abb7b New Change
[20] 1114 lines
[+20] [+] private void initialize(Class<?> cls) {
1115
    if (auxJars == null) {
1115
    if (auxJars == null) {
1116
      auxJars = this.get(ConfVars.HIVEAUXJARS.varname);
1116
      auxJars = this.get(ConfVars.HIVEAUXJARS.varname);
1117
    }
1117
    }
1118

    
   
1118

   
1119
    // setup list of conf vars that are not allowed to change runtime
1119
    // setup list of conf vars that are not allowed to change runtime
1120
    String restrictListStr = this.get(ConfVars.HIVE_CONF_RESTRICTED_LIST.toString());
1120
    setupRestrictList();
1121
    if (restrictListStr != null) {
Moved to 1259

   
1122
      for (String entry : restrictListStr.split(",")) {
Moved to 1260

   
1123
        restrictList.add(entry);

   
1124
      }

   
1125
    }

   
1126
    restrictList.add(ConfVars.HIVE_CONF_RESTRICTED_LIST.toString());

   
1127
  }
1121
  }
1128

    
   
1122

   
1129

    
   
1123

   
1130
  /**
1124
  /**
1131
   * Apply system properties to this object if the property name is defined in ConfVars
1125
   * Apply system properties to this object if the property name is defined in ConfVars
[+20] [20] 104 lines
[+20] [+] public static int getPositionFromInternalName(String internalName) {
1236
    } else {
1230
    } else {
1237
      return Integer.parseInt(m.group(1));
1231
      return Integer.parseInt(m.group(1));
1238
    }
1232
    }
1239

    
   
1233

   
1240
  }
1234
  }

    
   
1235

   

    
   
1236
  /**

    
   
1237
   * Append comma separated list of config vars to the restrict List

    
   
1238
   * @param restrictListStr

    
   
1239
   */

    
   
1240
  public void addToRestrictList(String restrictListStr) {

    
   
1241
    if (restrictListStr == null) {

    
   
1242
      return;

    
   
1243
    }

    
   
1244
    String oldList = this.getVar(ConfVars.HIVE_CONF_RESTRICTED_LIST);

    
   
1245
    if (oldList == null || oldList.isEmpty()) {

    
   
1246
      this.setVar(ConfVars.HIVE_CONF_RESTRICTED_LIST, restrictListStr);

    
   
1247
    } else {

    
   
1248
      this.setVar(ConfVars.HIVE_CONF_RESTRICTED_LIST, oldList + "," + restrictListStr);

    
   
1249
    }

    
   
1250
    setupRestrictList();

    
   
1251
  }

    
   
1252

   

    
   
1253
  /**

    
   
1254
   * Add the HIVE_CONF_RESTRICTED_LIST values to restrictList. Include HIVE_CONF_RESTRICTED_LIST itself

    
   
1255
   */

    
   
1256
  private void setupRestrictList() {

    
   
1257
    String restrictListStr = this.getVar(ConfVars.HIVE_CONF_RESTRICTED_LIST);

    
   
1258
    restrictList.clear();
Moved from 1121

    
   
1259
    if (restrictListStr != null) {
Moved from 1122

    
   
1260
      for (String entry : restrictListStr.split(",")) {

    
   
1261
        restrictList.add(entry.trim());

    
   
1262
      }

    
   
1263
    }

    
   
1264
    restrictList.add(ConfVars.HIVE_CONF_RESTRICTED_LIST.toString());

    
   
1265
  }
1241
}
1266
}
ql/src/test/org/apache/hadoop/hive/ql/security/TestConfRestrictList.java
New File
 
  1. common/src/java/org/apache/hadoop/hive/conf/HiveConf.java: Loading...
  2. ql/src/test/org/apache/hadoop/hive/ql/security/TestConfRestrictList.java: Loading...