From 8602bb013b3b2abcc4da26f01fd9b4091a586f49 Mon Sep 17 00:00:00 2001 From: Russ Fish Date: Tue, 23 Oct 2007 22:13:11 +0000 Subject: [PATCH] Minor nits. --- account/addpubkey.in | 26 +++++++++++++++++--------- backend/editexp.in | 4 ++++ backend/editimageid.in | 3 +-- backend/newimageid.in | 20 ++++++++++---------- db/Group.pm.in | 11 ++++++----- www/editimageid.php3 | 22 +++++++++++----------- www/nscheck.php3 | 5 ++++- 7 files changed, 53 insertions(+), 38 deletions(-) diff --git a/account/addpubkey.in b/account/addpubkey.in index 6f58ec74d..8c95270cd 100644 --- a/account/addpubkey.in +++ b/account/addpubkey.in @@ -17,10 +17,11 @@ use XML::Simple; # sub usage() { - print "Usage: addpubkeys [-k | -f] [-n | -u ] [ | ]\n"; - print " addpubkeys -x \n"; - print " addpubkeys [-i [-r] | -w] \n"; + print "Usage: addpubkeys [-d] [-k | -f] [-n | -u ] [ | ]\n"; + print " addpubkeys [-d] -X \n"; + print " addpubkeys [-d] [-i [-r] | -w] \n"; print "Options:\n"; + print " -d Turn on debugging\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 " -n Verify key format only; do not enter into into DB\n"; @@ -30,7 +31,7 @@ sub usage() print " -r Force a regenerate of initial key for user\n"; exit(-1); } -my $optlist = "kniwfu:rX:"; +my $optlist = "dkniwfu:rX:"; my $iskey = 0; my $verify = 0; my $initmode = 0; @@ -62,6 +63,7 @@ my $user_name; my $user_email; my $user_dbid; my $user_uid; +my $debug = 0; # # Testbed Support libraries @@ -77,7 +79,7 @@ use libtestbed; sub ParseKey($); sub InitUser(); sub GenerateKeyFile(); -sub ParseXmlArgs($$$$$); +sub ParseXmlArgs($$$$$$); sub fatal($); my $HOMEDIR = USERROOT(); @@ -129,6 +131,9 @@ if ($UID == 0) { if (! getopts($optlist, \%options)) { usage(); } +if (defined($options{"d"})) { + $debug = 1; +} if (defined($options{"k"})) { $iskey = 1; } @@ -155,7 +160,8 @@ if (defined($options{"X"})) { my %xmlargs = (); my %errors = (); - ParseXmlArgs($xmlfile, "user_pubkeys", \%xmlfields, \%xmlargs, \%errors); + ParseXmlArgs($xmlfile, "user_pubkeys", \%xmlfields, $debug, + \%xmlargs, \%errors); if (keys(%errors)) { foreach my $key (keys(%errors)) { my $val = $errors{$key}; @@ -581,13 +587,15 @@ sub GenerateKeyFile() return 0; } -sub ParseXmlArgs($$$$$) { - my ($xmlfile, $table_name, $fields_ref, $args_ref, $errs_ref) = @_; +sub ParseXmlArgs($$$$$$) { + my ($xmlfile, $table_name, $fields_ref, $debug, + $args_ref, $errs_ref) = @_; # # Input args: # $xmlfile - XML file path. # $table_name - table_regex table_name for low-level checking patterns. # $fields_ref - xmlfields specification (hash reference.) + # $debug # # Output args: # $args_ref - Parsed argument values (hash reference.) @@ -662,7 +670,7 @@ sub ParseXmlArgs($$$$$) { next; } - $args_ref->{$dbslot} = $value; + $args_ref->{$key} = $value; } } diff --git a/backend/editexp.in b/backend/editexp.in index 9dd5a475f..e375f2108 100644 --- a/backend/editexp.in +++ b/backend/editexp.in @@ -251,6 +251,10 @@ if ((exists($editexp_args{"description"}) ? $experiment->description() eq "")) { UserError("Description: Missing Field"); } +if (exists($editexp_args{"description"})) { + $editexp_args{"description"} = + escapeshellarg($editexp_args{"description"}); +} # # Swappable/Idle Ignore diff --git a/backend/editimageid.in b/backend/editimageid.in index 22dd3058a..b6127b676 100644 --- a/backend/editimageid.in +++ b/backend/editimageid.in @@ -318,7 +318,7 @@ if (!$isadmin && exists($editimageid_args{"path"})) { # # See what node types this image will work on. Must be at least one! 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)); @@ -396,7 +396,6 @@ if ($query_result->numrows) { " and make the necessary changes!\n $msg"); } - exit(0) if ($verify); diff --git a/backend/newimageid.in b/backend/newimageid.in index 6283e3bdd..f453898c9 100644 --- a/backend/newimageid.in +++ b/backend/newimageid.in @@ -11,7 +11,7 @@ use XML::Simple; use Data::Dumper; # -# Back-end script to create new Image descriptors. +# Back-end script to create new Image descriptors (Long Form.) # sub usage() { @@ -132,7 +132,7 @@ my $SLOT_ADMINONLY = 0x4; # Only admins can set this field. # my %xmlfields = # XML Field Name DB slot name Flags Default - ("imagename" => ["imagename" , $SLOT_REQUIRED], + ("imagename" => ["imagename", $SLOT_REQUIRED], "pid" => ["pid", $SLOT_REQUIRED], "gid" => ["gid", $SLOT_OPTIONAL], "description" => ["description", $SLOT_REQUIRED], @@ -143,12 +143,12 @@ my %xmlfields = "part3_osid" => ["part3_osid", $SLOT_OPTIONAL], "part4_osid" => ["part4_osid", $SLOT_OPTIONAL], "default_osid" => ["default_osid", $SLOT_REQUIRED], - "path" => ["path", $SLOT_OPTIONAL, ""], - "mtype_*" => ["mtype", $SLOT_OPTIONAL], - "node_id" => ["node_id", $SLOT_OPTIONAL, ""], - "shared", => ["shared", $SLOT_OPTIONAL, 0], - "global", => ["global", $SLOT_ADMINONLY, 0], - "makedefault", => ["makedefault", $SLOT_ADMINONLY, 0], + "path" => ["path", $SLOT_OPTIONAL, ""], + "mtype_*" => ["mtype", $SLOT_OPTIONAL], + "node_id" => ["node_id", $SLOT_OPTIONAL, ""], + "shared", => ["shared", $SLOT_OPTIONAL, 0], + "global", => ["global", $SLOT_ADMINONLY, 0], + "makedefault", => ["makedefault", $SLOT_ADMINONLY, 0], ); # @@ -530,8 +530,8 @@ exit(0) delete($newimageid_args{"imagename"}); my $usrerr; -my $new_image = Image->Create($project, $group, $this_user, $imagename, - \%newimageid_args, \$usrerr); +my $new_image = Image->Create($project, $group, $this_user, $imagename, 0, + \%newimageid_args, \$usrerr); UserError($usrerr) if (defined($usrerr)); fatal("Could not create new Image!") diff --git a/db/Group.pm.in b/db/Group.pm.in index 102e899a7..31bf61af0 100644 --- a/db/Group.pm.in +++ b/db/Group.pm.in @@ -23,7 +23,7 @@ use Data::Dumper; use File::Basename; use overload ('""' => 'Stringify'); use vars qw($MEMBERLIST_FLAGS_UIDSONLY $MEMBERLIST_FLAGS_ALLUSERS - $MEMBERLIST_FLAGS_GETTRUST); + $MEMBERLIST_FLAGS_GETTRUST $MEMBERLIST_FLAGS_EXCLUDE_LEADER); # Configure variables my $TB = "@prefix@"; @@ -41,9 +41,10 @@ my %groups = (); my $debug = 0; # MemberList flags. -$MEMBERLIST_FLAGS_UIDSONLY = 0x01; -$MEMBERLIST_FLAGS_ALLUSERS = 0x02; -$MEMBERLIST_FLAGS_GETTRUST = 0x04; +$MEMBERLIST_FLAGS_UIDSONLY = 0x01; +$MEMBERLIST_FLAGS_ALLUSERS = 0x02; +$MEMBERLIST_FLAGS_GETTRUST = 0x04; +$MEMBERLIST_FLAGS_EXCLUDE_LEADER = 0x08; # Little helper and debug function. sub mysystem($) @@ -1116,7 +1117,6 @@ sub LeaderMailList($) sub MemberList($$;$$) { my ($self, $prval, $flags, $desired_trust) = @_; - my $exclude_leader = 1; # Could be controlled by a flag. my $leader = $self->GetLeader(); my $leader_idx = $leader->uid_idx(); @@ -1132,6 +1132,7 @@ sub MemberList($$;$$) my @result = (); my $uids_only = ($flags & $MEMBERLIST_FLAGS_UIDSONLY ? 1 : 0); my $gettrust = ($flags & $MEMBERLIST_FLAGS_GETTRUST ? 1 : 0); + my $exclude_leader = ($flags & $MEMBERLIST_FLAGS_EXCLUDE_LEADER ? 1 : 0); my $trust_clause; if (defined($desired_trust)) { diff --git a/www/editimageid.php3 b/www/editimageid.php3 index 6fb80b468..8277033e8 100644 --- a/www/editimageid.php3 +++ b/www/editimageid.php3 @@ -56,7 +56,7 @@ function SPITFORM($image, $formfields, $errors) { global $uid, $isadmin, $types_result, $defaults; global $TBDB_IMAGEID_IMAGENAMELEN, $TBDB_NODEIDLEN; - + if ($errors) { echo " @@ -87,7 +87,7 @@ function SPITFORM($image, $formfields, $errors) \n"; # - # Imagename + # Image Name # echo " @@ -122,7 +122,8 @@ function SPITFORM($image, $formfields, $errors) # Description # echo " - + + + \n"; @@ -247,7 +249,8 @@ function SPITFORM($image, $formfields, $errors) # Global? # echo " - + \n"; @@ -299,7 +302,7 @@ $defaults = $image->DBData(); # # On first load, display a virgin form and exit. # -if (! isset($submit)) { +if (!isset($submit)) { # Generate the current types array for the form. foreach ($image->Types() as $type) { $defaults["mtype_${type}"] = "Yep"; @@ -347,7 +350,6 @@ if (! count($mtypes_array)) { $errors["Node Types"] = "Must select at least one type"; } - # # Build up argument array to pass along. # @@ -407,7 +409,7 @@ for ($i = 1; $i < count($mtypes_array); $i++) { } unset($osidclause); - +$osid_array = array(); for ($i = 1; $i <= 4; $i++) { # Local variable dynamically created. $foo = "part${i}_osid"; @@ -423,7 +425,6 @@ for ($i = 1; $i <= 4; $i++) { } DBQueryFatal("lock tables images write, os_info write, osidtoimageid write"); - $query_result = DBQueryFatal("select osidtoimageid.*,images.pid,images.imagename ". " from osidtoimageid ". @@ -434,7 +435,6 @@ $query_result = DBQueryFatal("unlock tables"); if (mysql_num_rows($query_result)) { - echo "
There are other image descriptors that specify the same OS descriptors for the same node types.
diff --git a/www/nscheck.php3 b/www/nscheck.php3 index 2b3f788ac..b428ada38 100644 --- a/www/nscheck.php3 +++ b/www/nscheck.php3 @@ -1,7 +1,7 @@ uid(); $isadmin = ISADMIN(); +# +# Verify page arguments. +# $optargs = OptionalPageArguments("nsdata", PAGEARG_ANYTHING, "formfields", PAGEARG_ARRAY, "fromform", PAGEARG_BOOLEAN); -- GitLab
ImageID:
Description:Description:
+ (a short pithy sentence)
- FilenameFilename (full path) of Image: - Shared?:Shared?:
+ (available to all subgroups)
". ($defaults["shared"] ? "Yes" : "No") . "
Global?:Global?:
+ (available to all projects)
". ($defaults["global"] ? "Yes" : "No") . "