HDFS-15312. Apply umask when creating directory by WebHDFS (#2096)

This commit is contained in:
Ye Ni 2020-07-06 19:01:46 -07:00 committed by GitHub
parent dc0626b5f2
commit f77bbc2123
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 0 deletions

View File

@ -416,9 +416,38 @@
$(this).prop('disabled', true);
$(this).button('complete');
// Get umask from the configuration
var umask, oldUmask, actualUmask;
$.ajax({'url': '/conf', 'dataType': 'xml', 'async': false}).done(
function(d) {
var $xml = $(d);
$xml.find('property').each(function(idx,v) {
// Current umask config
if ($(v).find('name').text() === 'fs.permissions.umask-mode') {
umask = $(v).find('value').text();
}
// Deprecated umask config
if ($(v).find('name').text() === 'dfs.umask') {
oldUmask = $(v).find('value').text();
}
});
});
var url = '/webhdfs/v1' + encode_path(append_path(current_directory,
$('#new_directory').val())) + '?op=MKDIRS';
if (oldUmask) {
actualUmask = 777 - oldUmask;
} else if (umask) {
actualUmask = 777 - umask;
}
if (actualUmask) {
url = url + '&permission=' + actualUmask;
}
$.ajax(url, { type: 'PUT' }
).done(function(data) {
browse_directory(current_directory);

View File

@ -416,9 +416,38 @@
$(this).prop('disabled', true);
$(this).button('complete');
// Get umask from the configuration
var umask, oldUmask, actualUmask;
$.ajax({'url': '/conf', 'dataType': 'xml', 'async': false}).done(
function(d) {
var $xml = $(d);
$xml.find('property').each(function(idx,v) {
// Current umask config
if ($(v).find('name').text() === 'fs.permissions.umask-mode') {
umask = $(v).find('value').text();
}
// Deprecated umask config
if ($(v).find('name').text() === 'dfs.umask') {
oldUmask = $(v).find('value').text();
}
});
});
var url = '/webhdfs/v1' + encode_path(append_path(current_directory,
$('#new_directory').val())) + '?op=MKDIRS';
if (oldUmask) {
actualUmask = 777 - oldUmask;
} else if (umask) {
actualUmask = 777 - umask;
}
if (actualUmask) {
url = url + '&permission=' + actualUmask;
}
$.ajax(url, { type: 'PUT' }
).done(function(data) {
browse_directory(current_directory);