Skip to content
Snippets Groups Projects
Commit 54705b2b authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Several fixes/changes:

* The unix group and gid are actuallt part of the group structure, not
  the project. So, when we load a project, load its default group as
  well, and have the routines for the name/gid hand off to the group.

* Change Lookup() to allow either a new idx or an old pid by looking
  at the format of the token. This will make it easier to transition
  to the new order of things.

* Part of the uncommitted uid changes is the addition of head_idx to
  replace head_uid. This code change is okay to commit now, since for
  the time being idx will shadow uid in all tables.
parent 47925cee
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/perl -wT #!/usr/bin/perl -wT
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2005, 2006 University of Utah and the Flux Group. # Copyright (c) 2005, 2006, 2007 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
package Project; package Project;
...@@ -47,25 +47,43 @@ sub mysystem($) ...@@ -47,25 +47,43 @@ sub mysystem($)
# #
sub Lookup($$) sub Lookup($$)
{ {
my ($class, $pid_idx) = @_; my ($class, $token) = @_;
my $query_result;
# Look in cache first # Look in cache first
return $projects{"$pid_idx"} return $projects{"$token"}
if (exists($projects{"$pid_idx"})); if (exists($projects{"$token"}));
#
# For backwards compatability, look to see if the token is numeric
# or alphanumeric. If numeric, assumes its an idx, otherwise a name.
#
if ($token =~ /^\d*$/) {
$query_result =
DBQueryWarn("select * from projects where pid_idx='$token'");
}
elsif ($token =~ /^\w*$/) {
$query_result =
DBQueryWarn("select * from projects where pid='$token'");
}
else {
return undef;
}
my $query_result =
DBQueryWarn("select * from projects where pid_idx=$pid_idx");
return undef return undef
if (!$query_result || !$query_result->numrows); if (!$query_result || !$query_result->numrows);
my $self = {}; my $self = {};
$self->{'PROJECT'} = $query_result->fetchrow_hashref(); $self->{'PROJECT'} = $query_result->fetchrow_hashref();
$self->{'GROUP'} = Group->Lookup($self->{'PROJECT'}->{'pid_idx'});
return undef
if (!defined($self->{'GROUP'}));
bless($self, $class); bless($self, $class);
# Add to cache. # Add to cache.
$projects{"$pid_idx"} = $self; $projects{$self->{'PROJECT'}->{'pid_idx'}} = $self;
return $self; return $self;
} }
...@@ -74,17 +92,20 @@ sub field($$) { return ((! ref($_[0])) ? -1 : $_[0]->{'PROJECT'}->{$_[1]}); } ...@@ -74,17 +92,20 @@ sub field($$) { return ((! ref($_[0])) ? -1 : $_[0]->{'PROJECT'}->{$_[1]}); }
sub pid($) { return field($_[0], "pid"); } sub pid($) { return field($_[0], "pid"); }
sub gid($) { return field($_[0], "gid"); } sub gid($) { return field($_[0], "gid"); }
sub pid_idx($) { return field($_[0], "pid_idx"); } sub pid_idx($) { return field($_[0], "pid_idx"); }
sub gid_idx($) { return field($_[0], "gid_idx"); } sub gid_idx($) { return field($_[0], "pid_idx"); }
sub leader($) { return field($_[0], "leader"); } sub head_uid($) { return field($_[0], "head_uid"); }
sub head_idx($) { return field($_[0], "head_idx"); }
sub created($) { return field($_[0], "created"); } sub created($) { return field($_[0], "created"); }
sub description($) { return field($_[0], "description"); } sub description($) { return field($_[0], "description"); }
sub unix_gid($) { return field($_[0], "unix_gid"); }
sub unix_name($) { return field($_[0], "unix_name"); }
sub expt_count($) { return field($_[0], "expt_count"); } sub expt_count($) { return field($_[0], "expt_count"); }
sub expt_last($) { return field($_[0], "expt_last"); } sub expt_last($) { return field($_[0], "expt_last"); }
sub wikiname($) { return field($_[0], "wikiname"); } sub wikiname($) { return field($_[0], "wikiname"); }
sub mailman_password($) { return field($_[0], "mailman_password"); } sub mailman_password($) { return field($_[0], "mailman_password"); }
# These come from the group not the project.
sub unix_gid($) { return $_[0]->{'GROUP'}->unix_gid(); }
sub unix_name($) { return $_[0]->{'GROUP'}->unix_name(); }
# #
# Lookup given pid For backwards compat. # Lookup given pid For backwards compat.
# #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment