All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit ba69c7a1 authored by Russ Fish's avatar Russ Fish

Pass project and user arguments in the XML file as an idx, not a name.

parent 68f6ddd6
...@@ -15,7 +15,7 @@ use Data::Dumper; ...@@ -15,7 +15,7 @@ use Data::Dumper;
# #
sub usage() sub usage()
{ {
print("Usage: moduserinfo [-v] <xmlfile>\n"); print("Usage: moduserinfo [-d] [-v] <xmlfile>\n");
exit(-1); exit(-1);
} }
my $optlist = "dv"; my $optlist = "dv";
...@@ -130,7 +130,7 @@ my $SLOT_ADMINONLY = 0x4; # Only admins can set this field. ...@@ -130,7 +130,7 @@ my $SLOT_ADMINONLY = 0x4; # Only admins can set this field.
# #
my %xmlfields = my %xmlfields =
# XML Field Name DB slot name Flags Default # XML Field Name DB slot name Flags Default
("uid" => ["uid", $SLOT_REQUIRED], ("uid" => ["uid_idx", $SLOT_REQUIRED],
# The rest are optional, so we can skip passing ones that are not changing. # The rest are optional, so we can skip passing ones that are not changing.
"usr_name" => ["usr_name", $SLOT_OPTIONAL], "usr_name" => ["usr_name", $SLOT_OPTIONAL],
...@@ -231,7 +231,7 @@ foreach my $key (keys(%{ $xmlparse->{'attribute'} })) { ...@@ -231,7 +231,7 @@ foreach my $key (keys(%{ $xmlparse->{'attribute'} })) {
next; next;
} }
$moduserinfo_args{$dbslot} = $value; $moduserinfo_args{$key} = $value;
} }
UserError() UserError()
if (keys(%errors)); if (keys(%errors));
...@@ -242,7 +242,7 @@ UserError() ...@@ -242,7 +242,7 @@ UserError()
my $target_uid = $moduserinfo_args{"uid"}; my $target_uid = $moduserinfo_args{"uid"};
my $target_user = User->Lookup($target_uid); my $target_user = User->Lookup($target_uid);
if (!defined($target_user)) { if (!defined($target_user)) {
UserError("uid: No such user name"); UserError("uid: No such user ($target_uid)");
} }
if (!$target_user->AccessCheck($this_user, TB_USERINFO_MODIFYINFO())) { if (!$target_user->AccessCheck($this_user, TB_USERINFO_MODIFYINFO())) {
UserError("UserInfo: Not enough permission"); UserError("UserInfo: Not enough permission");
......
...@@ -130,7 +130,7 @@ my $SLOT_ADMINONLY = 0x4; # Only admins can set this field. ...@@ -130,7 +130,7 @@ my $SLOT_ADMINONLY = 0x4; # Only admins can set this field.
# #
my %xmlfields = my %xmlfields =
# XML Field Name DB slot name Flags Default # XML Field Name DB slot name Flags Default
("project" => ["project", $SLOT_REQUIRED], ("project" => ["pid_idx", $SLOT_REQUIRED],
"group_id" => ["group_id", $SLOT_REQUIRED], "group_id" => ["group_id", $SLOT_REQUIRED],
"group_leader" => ["group_leader", $SLOT_REQUIRED], "group_leader" => ["group_leader", $SLOT_REQUIRED],
"group_description"=> ["group_description",$SLOT_OPTIONAL, ""]); "group_description"=> ["group_description",$SLOT_OPTIONAL, ""]);
...@@ -214,7 +214,7 @@ foreach my $key (keys(%{ $xmlparse->{'attribute'} })) { ...@@ -214,7 +214,7 @@ foreach my $key (keys(%{ $xmlparse->{'attribute'} })) {
next; next;
} }
$newgroup_args{$dbslot} = $value; $newgroup_args{$key} = $value;
} }
UserError() UserError()
if (keys(%errors)); if (keys(%errors));
......
...@@ -15,7 +15,7 @@ use Data::Dumper; ...@@ -15,7 +15,7 @@ use Data::Dumper;
# #
sub usage() sub usage()
{ {
print("Usage: newmmlist [-v] <xmlfile>\n"); print("Usage: newmmlist [-d] [-v] <xmlfile>\n");
exit(-1); exit(-1);
} }
my $optlist = "dv"; my $optlist = "dv";
...@@ -131,7 +131,8 @@ my $SLOT_ADMINONLY = 0x4; # Only admins can set this field. ...@@ -131,7 +131,8 @@ my $SLOT_ADMINONLY = 0x4; # Only admins can set this field.
# #
my %xmlfields = my %xmlfields =
# XML Field Name DB slot name Flags Default # XML Field Name DB slot name Flags Default
("pid" => ["pid", $SLOT_REQUIRED], ("project" => ["pid_idx", $SLOT_REQUIRED],
"password1" => ["password1", $SLOT_REQUIRED], "password1" => ["password1", $SLOT_REQUIRED],
"password2" => ["password2", $SLOT_REQUIRED], "password2" => ["password2", $SLOT_REQUIRED],
"listname" => ["listname", $SLOT_REQUIRED], "listname" => ["listname", $SLOT_REQUIRED],
...@@ -216,7 +217,7 @@ foreach my $key (keys(%{ $xmlparse->{'attribute'} })) { ...@@ -216,7 +217,7 @@ foreach my $key (keys(%{ $xmlparse->{'attribute'} })) {
next; next;
} }
$newmmlist_args{$dbslot} = $value; $newmmlist_args{$key} = $value;
} }
UserError() UserError()
if (keys(%errors)); if (keys(%errors));
...@@ -224,9 +225,9 @@ UserError() ...@@ -224,9 +225,9 @@ UserError()
# #
# Now do special checks. # Now do special checks.
# #
my $project = Project->Lookup($newmmlist_args{"pid"}); my $project = Project->Lookup($newmmlist_args{"project"});
if (!defined($project)) { if (!defined($project)) {
UserError("Project: No such project"); UserError("Project: No such project ($project)");
} }
if (!$project->AccessCheck($this_user, TB_PROJECT_READINFO())) { if (!$project->AccessCheck($this_user, TB_PROJECT_READINFO())) {
UserError("Project: Not enough permission"); UserError("Project: Not enough permission");
......
...@@ -15,7 +15,7 @@ use Data::Dumper; ...@@ -15,7 +15,7 @@ use Data::Dumper;
# #
sub usage() sub usage()
{ {
print("Usage: newosid [-v] <xmlfile>\n"); print("Usage: newosid [-d] [-v] <xmlfile>\n");
exit(-1); exit(-1);
} }
my $optlist = "dv"; my $optlist = "dv";
...@@ -223,7 +223,7 @@ foreach my $key (keys(%{ $xmlparse->{'attribute'} })) { ...@@ -223,7 +223,7 @@ foreach my $key (keys(%{ $xmlparse->{'attribute'} })) {
next; next;
} }
$newosid_args{$dbslot} = $value; $newosid_args{$key} = $value;
} }
UserError() UserError()
if (keys(%errors)); if (keys(%errors));
...@@ -231,9 +231,9 @@ UserError() ...@@ -231,9 +231,9 @@ UserError()
# #
# Now do special checks. # Now do special checks.
# #
my $project = Project->Lookup($newosid_args{"pid"}); my $project = Project->Lookup($newosid_args{"project"});
if (!defined($project)) { if (!defined($project)) {
UserError("Project: No such project"); UserError("Project: No such project ($project)");
} }
if (!$project->AccessCheck($this_user, TB_PROJECT_MAKEOSID())) { if (!$project->AccessCheck($this_user, TB_PROJECT_MAKEOSID())) {
UserError("Project: Not enough permission"); UserError("Project: Not enough permission");
...@@ -279,8 +279,8 @@ exit(0) ...@@ -279,8 +279,8 @@ exit(0)
# #
my $osname = $newosid_args{"osname"}; my $osname = $newosid_args{"osname"};
delete($newosid_args{"osname"}); delete($newosid_args{"osname"});
# Ditto the pid. # Ditto the project.
delete($newosid_args{"pid"}); delete($newosid_args{"project"});
my $usrerr; my $usrerr;
my $new_osinfo = OSinfo->Create($project, $this_user, $osname, my $new_osinfo = OSinfo->Create($project, $this_user, $osname,
......
...@@ -567,7 +567,7 @@ REPLACE INTO table_regex VALUES ('experiments','sync_server','text','redirect',' ...@@ -567,7 +567,7 @@ REPLACE INTO table_regex VALUES ('experiments','sync_server','text','redirect','
REPLACE INTO table_regex VALUES ('groups','project','text','redirect','projects:pid',0,0,NULL); REPLACE INTO table_regex VALUES ('groups','project','text','redirect','projects:pid',0,0,NULL);
REPLACE INTO table_regex VALUES ('groups','gid','text','regex','^[a-zA-Z][-\\w]+$',2,12,NULL); REPLACE INTO table_regex VALUES ('groups','gid','text','regex','^[a-zA-Z][-\\w]+$',2,12,NULL);
REPLACE INTO table_regex VALUES ('groups','gid_idx','text','regex','^[\\d]+$',2,12,NULL); REPLACE INTO table_regex VALUES ('groups','gid_idx','text','regex','^[\\d]+$',1,12,NULL);
REPLACE INTO table_regex VALUES ('groups','group_id','text','redirect','groups:gid',2,12,NULL); REPLACE INTO table_regex VALUES ('groups','group_id','text','redirect','groups:gid',2,12,NULL);
REPLACE INTO table_regex VALUES ('groups','group_leader','text','redirect','users:uid',2,8,NULL); REPLACE INTO table_regex VALUES ('groups','group_leader','text','redirect','users:uid',2,8,NULL);
REPLACE INTO table_regex VALUES ('groups','group_description','text','redirect','default:tinytext',0,256,NULL); REPLACE INTO table_regex VALUES ('groups','group_description','text','redirect','default:tinytext',0,256,NULL);
...@@ -593,6 +593,7 @@ REPLACE INTO table_regex VALUES ('projects','URL','text','redirect','default:tin ...@@ -593,6 +593,7 @@ REPLACE INTO table_regex VALUES ('projects','URL','text','redirect','default:tin
REPLACE INTO table_regex VALUES ('reserved','vname','text','redirect','virt_nodes:vname',1,32,NULL); REPLACE INTO table_regex VALUES ('reserved','vname','text','redirect','virt_nodes:vname',1,32,NULL);
REPLACE INTO table_regex VALUES ('users','uid','text','regex','^[a-zA-Z][\\w]+$',2,8,NULL); REPLACE INTO table_regex VALUES ('users','uid','text','regex','^[a-zA-Z][\\w]+$',2,8,NULL);
REPLACE INTO table_regex VALUES ('users','uid_idx','text','regex','^[\\d]+$',1,12,NULL);
REPLACE INTO table_regex VALUES ('users','usr_phone','text','regex','^[-\\d\\(\\)\\+\\.x ]+$',7,64,NULL); REPLACE INTO table_regex VALUES ('users','usr_phone','text','regex','^[-\\d\\(\\)\\+\\.x ]+$',7,64,NULL);
REPLACE INTO table_regex VALUES ('users','usr_name','text','regex','^[-\\w\\. ]+$',4,64,NULL); REPLACE INTO table_regex VALUES ('users','usr_name','text','regex','^[-\\w\\. ]+$',4,64,NULL);
REPLACE INTO table_regex VALUES ('users','usr_email','text','regex','^([-\\w\\+\\.]+)\\@([-\\w\\.]+)$',3,64,NULL); REPLACE INTO table_regex VALUES ('users','usr_email','text','regex','^([-\\w\\+\\.]+)\\@([-\\w\\.]+)$',3,64,NULL);
...@@ -877,7 +878,7 @@ REPLACE INTO table_regex VALUES ('virt_firewalls','fwname','text','redirect','vi ...@@ -877,7 +878,7 @@ REPLACE INTO table_regex VALUES ('virt_firewalls','fwname','text','redirect','vi
REPLACE INTO table_regex VALUES ('virt_firewalls','type','text','regex','^(ipfw|ipfw2|ipchains|ipfw2-vlan)$',0,0,NULL); REPLACE INTO table_regex VALUES ('virt_firewalls','type','text','regex','^(ipfw|ipfw2|ipchains|ipfw2-vlan)$',0,0,NULL);
REPLACE INTO table_regex VALUES ('virt_firewalls','style','text','regex','^(open|closed|basic|emulab)$',0,0,NULL); REPLACE INTO table_regex VALUES ('virt_firewalls','style','text','regex','^(open|closed|basic|emulab)$',0,0,NULL);
REPLACE INTO table_regex VALUES ('mailman_lists','pid','text','redirect','projects:pid',0,0,NULL); REPLACE INTO table_regex VALUES ('mailman_lists','pid_idx','text','redirect','projects:pid_idx',0,0,NULL);
REPLACE INTO table_regex VALUES ('mailman_lists','password1','text','redirect','default:tinytext',0,0,NULL); REPLACE INTO table_regex VALUES ('mailman_lists','password1','text','redirect','default:tinytext',0,0,NULL);
REPLACE INTO table_regex VALUES ('mailman_lists','password2','text','redirect','default:tinytext',0,0,NULL); REPLACE INTO table_regex VALUES ('mailman_lists','password2','text','redirect','default:tinytext',0,0,NULL);
REPLACE INTO table_regex VALUES ('mailman_lists','fullname','text','redirect','users:usr_email',0,0,NULL); REPLACE INTO table_regex VALUES ('mailman_lists','fullname','text','redirect','users:usr_email',0,0,NULL);
......
...@@ -115,7 +115,7 @@ class Group ...@@ -115,7 +115,7 @@ class Group
} }
# Add these. Maybe caller should do this? # Add these. Maybe caller should do this?
$args["project"] = $project->pid(); $args["project"] = $project->pid_idx();
fwrite($fp, "<group>\n"); fwrite($fp, "<group>\n");
foreach ($args as $name => $value) { foreach ($args as $name => $value) {
......
...@@ -329,10 +329,6 @@ if (count($errors)) { ...@@ -329,10 +329,6 @@ if (count($errors)) {
# #
$args = array(); $args = array();
if (isset($formfields["pid"]) &&
$formfields["pid"] != "none" && $formfields["pid"] != "") {
$args["pid"] = $formfields["pid"];
}
if (isset($formfields["password1"]) && $formfields["password1"] != "") { if (isset($formfields["password1"]) && $formfields["password1"] != "") {
$args["password1"] = $formfields["password1"]; $args["password1"] = $formfields["password1"];
} }
...@@ -346,7 +342,7 @@ if (isset($formfields["fullname"]) && $formfields["fullname"] != "") { ...@@ -346,7 +342,7 @@ if (isset($formfields["fullname"]) && $formfields["fullname"] != "") {
$args["fullname"] = $formfields["fullname"]; $args["fullname"] = $formfields["fullname"];
} }
if (! ($result = NewMmList($uid, $args, $errors))) { if (! ($result = NewMmList($uid, $project, $args, $errors))) {
# Always respit the form so that the form fields are not lost. # Always respit the form so that the form fields are not lost.
# I just hate it when that happens so lets not be guilty of it ourselves. # I just hate it when that happens so lets not be guilty of it ourselves.
SPITFORM($formfields, $errors); SPITFORM($formfields, $errors);
...@@ -362,7 +358,7 @@ header("Location: ${MAILMANURL}/admin/${listname}/?adminpw=${formfields["passwor ...@@ -362,7 +358,7 @@ header("Location: ${MAILMANURL}/admin/${listname}/?adminpw=${formfields["passwor
# #
# When there's an MmList class, this will be a Class function to make a new one... # When there's an MmList class, this will be a Class function to make a new one...
# #
function NewMmList($uid, $args, &$errors) { function NewMmList($uid, $project, $args, &$errors) {
global $suexec_output, $suexec_output_array, $TBADMINGROUP; global $suexec_output, $suexec_output_array, $TBADMINGROUP;
# #
...@@ -380,6 +376,9 @@ function NewMmList($uid, $args, &$errors) { ...@@ -380,6 +376,9 @@ function NewMmList($uid, $args, &$errors) {
return null; return null;
} }
# Add these. Maybe caller should do this?
$args["project"] = $project->pid_idx();
fwrite($fp, "<MmList>\n"); fwrite($fp, "<MmList>\n");
foreach ($args as $name => $value) { foreach ($args as $name => $value) {
fwrite($fp, "<attribute name=\"$name\">"); fwrite($fp, "<attribute name=\"$name\">");
......
...@@ -172,7 +172,7 @@ class User ...@@ -172,7 +172,7 @@ class User
} }
# Add these. Maybe caller should do this? # Add these. Maybe caller should do this?
$args["uid"] = $target_user->uid(); $args["uid"] = $target_user->uid_idx();
fwrite($fp, "<userinfo>\n"); fwrite($fp, "<userinfo>\n");
foreach ($args as $name => $value) { foreach ($args as $name => $value) {
......
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