Commit c9444a4e authored by Leigh Stoller's avatar Leigh Stoller

Some fixes for creating geni experiments in subgroups.

parent 26a5fa07
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# Copyright (c) 2005-2016 University of Utah and the Flux Group. # Copyright (c) 2005-2017 University of Utah and the Flux Group.
# #
# {{{EMULAB-LICENSE # {{{EMULAB-LICENSE
# #
...@@ -1872,9 +1872,21 @@ sub GList($$) ...@@ -1872,9 +1872,21 @@ sub GList($$)
# of the list Order matters here, or we won't pick up all the groups # of the list Order matters here, or we won't pick up all the groups
# we need. # we need.
# #
my @glist = grep {$_ != $default} split(/\s/, $glist); if (ref($default)) {
$glist = $default . " " . $default . " @glist"; #
# If we got an actual group object, we want the project unix gid
# at the beginning and the group unix gid next.
#
my $pid_gid = $default->GetProject()->unix_gid();
my $gid_gid = $default->unix_gid();
my @glist = grep {$_ != $pid_gid && $_ != $gid_gid} split(/\s/, $glist);
$glist = "$pid_gid $pid_gid $gid_gid @glist";
}
else {
my @glist = grep {$_ != $default} split(/\s/, $glist);
$glist = $default . " " . $default . " @glist";
}
return $glist; return $glist;
} }
...@@ -1914,7 +1926,7 @@ sub UnixGroupList($$) ...@@ -1914,7 +1926,7 @@ sub UnixGroupList($$)
# #
sub FlipTo($$) sub FlipTo($$)
{ {
my ($self, $default_gid) = @_; my ($self, $default_group) = @_;
# Must be a real reference. # Must be a real reference.
return -1 return -1
...@@ -1924,10 +1936,13 @@ sub FlipTo($$) ...@@ -1924,10 +1936,13 @@ sub FlipTo($$)
# to flip to a different user in the case we already flipped. # to flip to a different user in the case we already flipped.
$EUID = 0; $EUID = 0;
my $glist = $self->GList($default_gid); my $glist = $self->GList($default_group);
return -1 return -1
if (!defined($glist)); if (!defined($glist));
my @tmp = split(/\s/, $glist);
my $default_gid = $tmp[0];
$GID = $default_gid; $GID = $default_gid;
$EGID = $glist; $EGID = $glist;
$EUID = $UID = $self->unix_uid(); $EUID = $UID = $self->unix_uid();
......
...@@ -6947,7 +6947,7 @@ sub GeniExperiment($;$) ...@@ -6947,7 +6947,7 @@ sub GeniExperiment($;$)
# a member. That means we have to run as the local user. # a member. That means we have to run as the local user.
# #
if ($project->IsLocal()) { if ($project->IsLocal()) {
$creator->FlipTo($group->unix_gid()); $creator->FlipTo($group);
} }
elsif (defined($group)) { elsif (defined($group)) {
GeniUtil::FlipToGeniUser($group->unix_gid()); GeniUtil::FlipToGeniUser($group->unix_gid());
...@@ -7042,7 +7042,7 @@ sub FlipToUser($$) ...@@ -7042,7 +7042,7 @@ sub FlipToUser($$)
} }
flip: flip:
return undef return undef
if ($user->FlipTo($group->unix_gid())); if ($user->FlipTo($group));
return $user; return $user;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment