2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-13 01:40:26 +00:00

updatenode -F not work in hierachy env as the user name is FQDN of MN (#4484)

* updatenode -F not work in hierachy env (#4455)
 - add trace when -V is enabled
 - get the DSH_FROM_USERID from updatenode client

*  - when 'updatenode -F' need to push SN first, using root as non-root does not have permission write to 'SNsyncfiledir'
 - move the set DSH_FROM_USERID code out of the loop, and also cover remote client case.
This commit is contained in:
Bin Xu
2017-12-13 16:52:15 +08:00
committed by yangsong
parent 16f6df67b7
commit eb4fa5fc7a
4 changed files with 35 additions and 3 deletions

View File

@ -835,7 +835,7 @@ sub fork_fanout_dcp
my @target_file = split '/', $$options{'source'};
$rcp_config{'dest-file'} =
"$$options{'target'}/$target_file[$#target_file]._$$target_properties{'hostname'}";
"$$options{'target'}/$target_file[$#target_file]._$$target_properties{'hostname'}";
}
@ -850,6 +850,8 @@ sub fork_fanout_dcp
$$options{'destDir_srcFile'}{$user_target};
}
$dsh_trace
&& ($rcp_config{'trace'} = 1);
#eval "require RemoteShell::$rsh_extension";
eval "require xCAT::$rsh_extension";
my $remoteshell = "xCAT::$rsh_extension";

View File

@ -156,7 +156,11 @@ sub remote_copy_command
$dest_user_host =
"$$config{'dest-user'}@" . "$$config{'dest-host'}";
}
print RSCYCCMDFILE "#!/bin/sh\n";
if ($$config{'trace'}) {
print RSCYCCMDFILE "#!/bin/sh -x\n";
} else {
print RSCYCCMDFILE "#!/bin/sh\n";
}
if ($localhost == 1) { # running to the MN from the MN
print RSCYCCMDFILE
"/bin/mkdir -p $dest_dir_list\n";

View File

@ -686,7 +686,6 @@ sub preprocess_updatenode
}
# Get the MN names
my @MNip = xCAT::NetworkUtils->determinehostname;
my @MNnodeinfo = xCAT::NetworkUtils->determinehostname;
my $MNnodename = pop @MNnodeinfo; # hostname
my @MNnodeipaddr = @MNnodeinfo; # ipaddresses
@ -1695,6 +1694,24 @@ sub updatenodesyncfiles
}
}
my $dhs_from_user_env;
# get the Environment Variables and set DSH_FROM_USERID if possible (From updatenode client)
if (defined($request->{environment})) {
foreach my $envar (@{ $request->{environment} })
{
if ($envar =~ /^DSH_FROM_USERID=/) {
$dhs_from_user_env = $envar;
last;
}
}
}
unless ($dhs_from_user_env) {
# $request->{username} is gotten from CN in client certificate
if (($request->{username}) && defined($request->{username}->[0])) {
$dhs_from_user_env = 'DSH_FROM_USERID=' . $request->{username}->[0];
}
}
my $node_syncfile = xCAT::SvrUtils->getsynclistfile($nodes);
foreach my $node (@$nodes)
{
@ -1745,6 +1762,10 @@ sub updatenodesyncfiles
} else { # else this is updatenode -F
$env = ["DSH_RSYNC_FILE=$synclist"];
}
if ($dhs_from_user_env) {
push $env, $dhs_from_user_env;
}
push @$args, "--nodestatus";
if (defined($::fanout)) { # fanout
push @$args, "-f";
@ -1765,6 +1786,7 @@ sub updatenodesyncfiles
if ($::VERBOSE)
{
push @$args, "-T";
my $rsp = {};
$rsp->{data}->[0] =
" $localhostname: Internal call command: xdcp $nodestring " . join(' ', @$args);

View File

@ -639,6 +639,7 @@ sub process_servicenodes_xdcp
$addreq->{'_xcatdest'} = $::mnname;
$addreq->{node} = \@sn;
$addreq->{noderange} = \@sn;
$addreq->{forceroot}->[0] = 1;
# check input request for --nodestatus
my $args = $req->{arg}; # argument
@ -1215,6 +1216,9 @@ sub process_request
$ENV{DSH_FROM_USERID} = $request->{username}->[0];
}
}
if ($request->{forceroot}) {
$ENV{DSH_FROM_USERID} = 'root';
}
if ($command eq "xdsh")
{
xdsh($nodes, $args, $callback, $command, $request->{noderange}->[0]);