Commit 8602bb01 authored by Russ Fish's avatar Russ Fish

Minor nits.

parent 25855415
...@@ -17,10 +17,11 @@ use XML::Simple; ...@@ -17,10 +17,11 @@ use XML::Simple;
# #
sub usage() sub usage()
{ {
print "Usage: addpubkeys [-k | -f] [-n | -u <user>] [<keyfile> | <key>]\n"; print "Usage: addpubkeys [-d] [-k | -f] [-n | -u <user>] [<keyfile> | <key>]\n";
print " addpubkeys -x <xmlfile>\n"; print " addpubkeys [-d] -X <xmlfile>\n";
print " addpubkeys [-i [-r] | -w] <user>\n"; print " addpubkeys [-d] [-i [-r] | -w] <user>\n";
print "Options:\n"; print "Options:\n";
print " -d Turn on debugging\n";
print " -k Indicates that key was passed in on the command line\n"; print " -k Indicates that key was passed in on the command line\n";
print " -f Indicates that key was passed in as a filename\n"; print " -f Indicates that key was passed in as a filename\n";
print " -n Verify key format only; do not enter into into DB\n"; print " -n Verify key format only; do not enter into into DB\n";
...@@ -30,7 +31,7 @@ sub usage() ...@@ -30,7 +31,7 @@ sub usage()
print " -r Force a regenerate of initial key for user\n"; print " -r Force a regenerate of initial key for user\n";
exit(-1); exit(-1);
} }
my $optlist = "kniwfu:rX:"; my $optlist = "dkniwfu:rX:";
my $iskey = 0; my $iskey = 0;
my $verify = 0; my $verify = 0;
my $initmode = 0; my $initmode = 0;
...@@ -62,6 +63,7 @@ my $user_name; ...@@ -62,6 +63,7 @@ my $user_name;
my $user_email; my $user_email;
my $user_dbid; my $user_dbid;
my $user_uid; my $user_uid;
my $debug = 0;
# #
# Testbed Support libraries # Testbed Support libraries
...@@ -77,7 +79,7 @@ use libtestbed; ...@@ -77,7 +79,7 @@ use libtestbed;
sub ParseKey($); sub ParseKey($);
sub InitUser(); sub InitUser();
sub GenerateKeyFile(); sub GenerateKeyFile();
sub ParseXmlArgs($$$$$); sub ParseXmlArgs($$$$$$);
sub fatal($); sub fatal($);
my $HOMEDIR = USERROOT(); my $HOMEDIR = USERROOT();
...@@ -129,6 +131,9 @@ if ($UID == 0) { ...@@ -129,6 +131,9 @@ if ($UID == 0) {
if (! getopts($optlist, \%options)) { if (! getopts($optlist, \%options)) {
usage(); usage();
} }
if (defined($options{"d"})) {
$debug = 1;
}
if (defined($options{"k"})) { if (defined($options{"k"})) {
$iskey = 1; $iskey = 1;
} }
...@@ -155,7 +160,8 @@ if (defined($options{"X"})) { ...@@ -155,7 +160,8 @@ if (defined($options{"X"})) {
my %xmlargs = (); my %xmlargs = ();
my %errors = (); my %errors = ();
ParseXmlArgs($xmlfile, "user_pubkeys", \%xmlfields, \%xmlargs, \%errors); ParseXmlArgs($xmlfile, "user_pubkeys", \%xmlfields, $debug,
\%xmlargs, \%errors);
if (keys(%errors)) { if (keys(%errors)) {
foreach my $key (keys(%errors)) { foreach my $key (keys(%errors)) {
my $val = $errors{$key}; my $val = $errors{$key};
...@@ -581,13 +587,15 @@ sub GenerateKeyFile() ...@@ -581,13 +587,15 @@ sub GenerateKeyFile()
return 0; return 0;
} }
sub ParseXmlArgs($$$$$) { sub ParseXmlArgs($$$$$$) {
my ($xmlfile, $table_name, $fields_ref, $args_ref, $errs_ref) = @_; my ($xmlfile, $table_name, $fields_ref, $debug,
$args_ref, $errs_ref) = @_;
# #
# Input args: # Input args:
# $xmlfile - XML file path. # $xmlfile - XML file path.
# $table_name - table_regex table_name for low-level checking patterns. # $table_name - table_regex table_name for low-level checking patterns.
# $fields_ref - xmlfields specification (hash reference.) # $fields_ref - xmlfields specification (hash reference.)
# $debug
# #
# Output args: # Output args:
# $args_ref - Parsed argument values (hash reference.) # $args_ref - Parsed argument values (hash reference.)
...@@ -662,7 +670,7 @@ sub ParseXmlArgs($$$$$) { ...@@ -662,7 +670,7 @@ sub ParseXmlArgs($$$$$) {
next; next;
} }
$args_ref->{$dbslot} = $value; $args_ref->{$key} = $value;
} }
} }
......
...@@ -251,6 +251,10 @@ if ((exists($editexp_args{"description"}) ? ...@@ -251,6 +251,10 @@ if ((exists($editexp_args{"description"}) ?
$experiment->description() eq "")) { $experiment->description() eq "")) {
UserError("Description: Missing Field"); UserError("Description: Missing Field");
} }
if (exists($editexp_args{"description"})) {
$editexp_args{"description"} =
escapeshellarg($editexp_args{"description"});
}
# #
# Swappable/Idle Ignore # Swappable/Idle Ignore
......
...@@ -318,7 +318,7 @@ if (!$isadmin && exists($editimageid_args{"path"})) { ...@@ -318,7 +318,7 @@ if (!$isadmin && exists($editimageid_args{"path"})) {
# #
# See what node types this image will work on. Must be at least one! # See what node types this image will work on. Must be at least one!
if ($#mtypes_array < 0) { if ($#mtypes_array < 0) {
UserError("Node Types: Must select at least one type"); UserError("Node Types: Must have at least one node type");
} }
my $typeclause = join(" or ", map("type='$_'", @mtypes_array)); my $typeclause = join(" or ", map("type='$_'", @mtypes_array));
...@@ -396,7 +396,6 @@ if ($query_result->numrows) { ...@@ -396,7 +396,6 @@ if ($query_result->numrows) {
" and make the necessary changes!\n $msg"); " and make the necessary changes!\n $msg");
} }
exit(0) exit(0)
if ($verify); if ($verify);
......
...@@ -11,7 +11,7 @@ use XML::Simple; ...@@ -11,7 +11,7 @@ use XML::Simple;
use Data::Dumper; use Data::Dumper;
# #
# Back-end script to create new Image descriptors. # Back-end script to create new Image descriptors (Long Form.)
# #
sub usage() sub usage()
{ {
...@@ -132,7 +132,7 @@ my $SLOT_ADMINONLY = 0x4; # Only admins can set this field. ...@@ -132,7 +132,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
("imagename" => ["imagename" , $SLOT_REQUIRED], ("imagename" => ["imagename", $SLOT_REQUIRED],
"pid" => ["pid", $SLOT_REQUIRED], "pid" => ["pid", $SLOT_REQUIRED],
"gid" => ["gid", $SLOT_OPTIONAL], "gid" => ["gid", $SLOT_OPTIONAL],
"description" => ["description", $SLOT_REQUIRED], "description" => ["description", $SLOT_REQUIRED],
...@@ -143,12 +143,12 @@ my %xmlfields = ...@@ -143,12 +143,12 @@ my %xmlfields =
"part3_osid" => ["part3_osid", $SLOT_OPTIONAL], "part3_osid" => ["part3_osid", $SLOT_OPTIONAL],
"part4_osid" => ["part4_osid", $SLOT_OPTIONAL], "part4_osid" => ["part4_osid", $SLOT_OPTIONAL],
"default_osid" => ["default_osid", $SLOT_REQUIRED], "default_osid" => ["default_osid", $SLOT_REQUIRED],
"path" => ["path", $SLOT_OPTIONAL, ""], "path" => ["path", $SLOT_OPTIONAL, ""],
"mtype_*" => ["mtype", $SLOT_OPTIONAL], "mtype_*" => ["mtype", $SLOT_OPTIONAL],
"node_id" => ["node_id", $SLOT_OPTIONAL, ""], "node_id" => ["node_id", $SLOT_OPTIONAL, ""],
"shared", => ["shared", $SLOT_OPTIONAL, 0], "shared", => ["shared", $SLOT_OPTIONAL, 0],
"global", => ["global", $SLOT_ADMINONLY, 0], "global", => ["global", $SLOT_ADMINONLY, 0],
"makedefault", => ["makedefault", $SLOT_ADMINONLY, 0], "makedefault", => ["makedefault", $SLOT_ADMINONLY, 0],
); );
# #
...@@ -530,8 +530,8 @@ exit(0) ...@@ -530,8 +530,8 @@ exit(0)
delete($newimageid_args{"imagename"}); delete($newimageid_args{"imagename"});
my $usrerr; my $usrerr;
my $new_image = Image->Create($project, $group, $this_user, $imagename, my $new_image = Image->Create($project, $group, $this_user, $imagename, 0,
\%newimageid_args, \$usrerr); \%newimageid_args, \$usrerr);
UserError($usrerr) UserError($usrerr)
if (defined($usrerr)); if (defined($usrerr));
fatal("Could not create new Image!") fatal("Could not create new Image!")
......
...@@ -23,7 +23,7 @@ use Data::Dumper; ...@@ -23,7 +23,7 @@ use Data::Dumper;
use File::Basename; use File::Basename;
use overload ('""' => 'Stringify'); use overload ('""' => 'Stringify');
use vars qw($MEMBERLIST_FLAGS_UIDSONLY $MEMBERLIST_FLAGS_ALLUSERS use vars qw($MEMBERLIST_FLAGS_UIDSONLY $MEMBERLIST_FLAGS_ALLUSERS
$MEMBERLIST_FLAGS_GETTRUST); $MEMBERLIST_FLAGS_GETTRUST $MEMBERLIST_FLAGS_EXCLUDE_LEADER);
# Configure variables # Configure variables
my $TB = "@prefix@"; my $TB = "@prefix@";
...@@ -41,9 +41,10 @@ my %groups = (); ...@@ -41,9 +41,10 @@ my %groups = ();
my $debug = 0; my $debug = 0;
# MemberList flags. # MemberList flags.
$MEMBERLIST_FLAGS_UIDSONLY = 0x01; $MEMBERLIST_FLAGS_UIDSONLY = 0x01;
$MEMBERLIST_FLAGS_ALLUSERS = 0x02; $MEMBERLIST_FLAGS_ALLUSERS = 0x02;
$MEMBERLIST_FLAGS_GETTRUST = 0x04; $MEMBERLIST_FLAGS_GETTRUST = 0x04;
$MEMBERLIST_FLAGS_EXCLUDE_LEADER = 0x08;
# Little helper and debug function. # Little helper and debug function.
sub mysystem($) sub mysystem($)
...@@ -1116,7 +1117,6 @@ sub LeaderMailList($) ...@@ -1116,7 +1117,6 @@ sub LeaderMailList($)
sub MemberList($$;$$) sub MemberList($$;$$)
{ {
my ($self, $prval, $flags, $desired_trust) = @_; my ($self, $prval, $flags, $desired_trust) = @_;
my $exclude_leader = 1; # Could be controlled by a flag.
my $leader = $self->GetLeader(); my $leader = $self->GetLeader();
my $leader_idx = $leader->uid_idx(); my $leader_idx = $leader->uid_idx();
...@@ -1132,6 +1132,7 @@ sub MemberList($$;$$) ...@@ -1132,6 +1132,7 @@ sub MemberList($$;$$)
my @result = (); my @result = ();
my $uids_only = ($flags & $MEMBERLIST_FLAGS_UIDSONLY ? 1 : 0); my $uids_only = ($flags & $MEMBERLIST_FLAGS_UIDSONLY ? 1 : 0);
my $gettrust = ($flags & $MEMBERLIST_FLAGS_GETTRUST ? 1 : 0); my $gettrust = ($flags & $MEMBERLIST_FLAGS_GETTRUST ? 1 : 0);
my $exclude_leader = ($flags & $MEMBERLIST_FLAGS_EXCLUDE_LEADER ? 1 : 0);
my $trust_clause; my $trust_clause;
if (defined($desired_trust)) { if (defined($desired_trust)) {
......
...@@ -56,7 +56,7 @@ function SPITFORM($image, $formfields, $errors) ...@@ -56,7 +56,7 @@ function SPITFORM($image, $formfields, $errors)
{ {
global $uid, $isadmin, $types_result, $defaults; global $uid, $isadmin, $types_result, $defaults;
global $TBDB_IMAGEID_IMAGENAMELEN, $TBDB_NODEIDLEN; global $TBDB_IMAGEID_IMAGENAMELEN, $TBDB_NODEIDLEN;
if ($errors) { if ($errors) {
echo "<table class=nogrid echo "<table class=nogrid
align=center border=0 cellpadding=6 cellspacing=0> align=center border=0 cellpadding=6 cellspacing=0>
...@@ -87,7 +87,7 @@ function SPITFORM($image, $formfields, $errors) ...@@ -87,7 +87,7 @@ function SPITFORM($image, $formfields, $errors)
<form action='$url' method=post>\n"; <form action='$url' method=post>\n";
# #
# Imagename # Image Name
# #
echo "<tr> echo "<tr>
<td>ImageID:</td> <td>ImageID:</td>
...@@ -122,7 +122,8 @@ function SPITFORM($image, $formfields, $errors) ...@@ -122,7 +122,8 @@ function SPITFORM($image, $formfields, $errors)
# Description # Description
# #
echo "<tr> echo "<tr>
<td>Description:</td> <td>Description:<br>
(a short pithy sentence)</td>
<td class=left> <td class=left>
<input type=text <input type=text
name=\"formfields[description]\" name=\"formfields[description]\"
...@@ -201,7 +202,7 @@ function SPITFORM($image, $formfields, $errors) ...@@ -201,7 +202,7 @@ function SPITFORM($image, $formfields, $errors)
# Path to image. # Path to image.
# #
echo "<tr> echo "<tr>
<td>Filename</td> <td>Filename (full path) of Image:</td>
<td class=left> <td class=left>
<input type=text <input type=text
name=\"formfields[path]\" name=\"formfields[path]\"
...@@ -239,7 +240,8 @@ function SPITFORM($image, $formfields, $errors) ...@@ -239,7 +240,8 @@ function SPITFORM($image, $formfields, $errors)
# Shared? # Shared?
# #
echo "<tr> echo "<tr>
<td>Shared?:</td> <td>Shared?:<br>
(available to all subgroups)</td>
<td class=left>". ($defaults["shared"] ? "Yes" : "No") . "</td> <td class=left>". ($defaults["shared"] ? "Yes" : "No") . "</td>
</tr>\n"; </tr>\n";
...@@ -247,7 +249,8 @@ function SPITFORM($image, $formfields, $errors) ...@@ -247,7 +249,8 @@ function SPITFORM($image, $formfields, $errors)
# Global? # Global?
# #
echo "<tr> echo "<tr>
<td>Global?:</td> <td>Global?:<br>
(available to all projects)</td>
<td class=left>". ($defaults["global"] ? "Yes" : "No") . "</td> <td class=left>". ($defaults["global"] ? "Yes" : "No") . "</td>
</tr>\n"; </tr>\n";
...@@ -299,7 +302,7 @@ $defaults = $image->DBData(); ...@@ -299,7 +302,7 @@ $defaults = $image->DBData();
# #
# On first load, display a virgin form and exit. # On first load, display a virgin form and exit.
# #
if (! isset($submit)) { if (!isset($submit)) {
# Generate the current types array for the form. # Generate the current types array for the form.
foreach ($image->Types() as $type) { foreach ($image->Types() as $type) {
$defaults["mtype_${type}"] = "Yep"; $defaults["mtype_${type}"] = "Yep";
...@@ -347,7 +350,6 @@ if (! count($mtypes_array)) { ...@@ -347,7 +350,6 @@ if (! count($mtypes_array)) {
$errors["Node Types"] = "Must select at least one type"; $errors["Node Types"] = "Must select at least one type";
} }
# #
# Build up argument array to pass along. # Build up argument array to pass along.
# #
...@@ -407,7 +409,7 @@ for ($i = 1; $i < count($mtypes_array); $i++) { ...@@ -407,7 +409,7 @@ for ($i = 1; $i < count($mtypes_array); $i++) {
} }
unset($osidclause); unset($osidclause);
$osid_array = array();
for ($i = 1; $i <= 4; $i++) { for ($i = 1; $i <= 4; $i++) {
# Local variable dynamically created. # Local variable dynamically created.
$foo = "part${i}_osid"; $foo = "part${i}_osid";
...@@ -423,7 +425,6 @@ for ($i = 1; $i <= 4; $i++) { ...@@ -423,7 +425,6 @@ for ($i = 1; $i <= 4; $i++) {
} }
DBQueryFatal("lock tables images write, os_info write, osidtoimageid write"); DBQueryFatal("lock tables images write, os_info write, osidtoimageid write");
$query_result = $query_result =
DBQueryFatal("select osidtoimageid.*,images.pid,images.imagename ". DBQueryFatal("select osidtoimageid.*,images.pid,images.imagename ".
" from osidtoimageid ". " from osidtoimageid ".
...@@ -434,7 +435,6 @@ $query_result = ...@@ -434,7 +435,6 @@ $query_result =
DBQueryFatal("unlock tables"); DBQueryFatal("unlock tables");
if (mysql_num_rows($query_result)) { if (mysql_num_rows($query_result)) {
echo "<center> echo "<center>
There are other image descriptors that specify the There are other image descriptors that specify the
same OS descriptors for the same node types.<br> same OS descriptors for the same node types.<br>
......
<?php <?php
# #
# EMULAB-COPYRIGHT # EMULAB-COPYRIGHT
# Copyright (c) 2000-2003, 2006, 2007 University of Utah and the Flux Group. # Copyright (c) 2000-2007 University of Utah and the Flux Group.
# All rights reserved. # All rights reserved.
# #
include("defs.php3"); include("defs.php3");
...@@ -22,6 +22,9 @@ $this_user = CheckLoginOrDie(); ...@@ -22,6 +22,9 @@ $this_user = CheckLoginOrDie();
$uid = $this_user->uid(); $uid = $this_user->uid();
$isadmin = ISADMIN(); $isadmin = ISADMIN();
#
# Verify page arguments.
#
$optargs = OptionalPageArguments("nsdata", PAGEARG_ANYTHING, $optargs = OptionalPageArguments("nsdata", PAGEARG_ANYTHING,
"formfields", PAGEARG_ARRAY, "formfields", PAGEARG_ARRAY,
"fromform", PAGEARG_BOOLEAN); "fromform", PAGEARG_BOOLEAN);
......
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