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

Minor nits.

parent 25855415
......@@ -17,10 +17,11 @@ use XML::Simple;
#
sub usage()
{
print "Usage: addpubkeys [-k | -f] [-n | -u <user>] [<keyfile> | <key>]\n";
print " addpubkeys -x <xmlfile>\n";
print " addpubkeys [-i [-r] | -w] <user>\n";
print "Usage: addpubkeys [-d] [-k | -f] [-n | -u <user>] [<keyfile> | <key>]\n";
print " addpubkeys [-d] -X <xmlfile>\n";
print " addpubkeys [-d] [-i [-r] | -w] <user>\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;
}
}
......
......@@ -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
......
......@@ -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);
......
......@@ -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!")
......
......@@ -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)) {
......
......@@ -56,7 +56,7 @@ function SPITFORM($image, $formfields, $errors)
{
global $uid, $isadmin, $types_result, $defaults;
global $TBDB_IMAGEID_IMAGENAMELEN, $TBDB_NODEIDLEN;
if ($errors) {
echo "<table class=nogrid
align=center border=0 cellpadding=6 cellspacing=0>
......@@ -87,7 +87,7 @@ function SPITFORM($image, $formfields, $errors)
<form action='$url' method=post>\n";
#
# Imagename
# Image Name
#
echo "<tr>
<td>ImageID:</td>
......@@ -122,7 +122,8 @@ function SPITFORM($image, $formfields, $errors)
# Description
#
echo "<tr>
<td>Description:</td>
<td>Description:<br>
(a short pithy sentence)</td>
<td class=left>
<input type=text
name=\"formfields[description]\"
......@@ -201,7 +202,7 @@ function SPITFORM($image, $formfields, $errors)
# Path to image.
#
echo "<tr>
<td>Filename</td>
<td>Filename (full path) of Image:</td>
<td class=left>
<input type=text
name=\"formfields[path]\"
......@@ -239,7 +240,8 @@ function SPITFORM($image, $formfields, $errors)
# Shared?
#
echo "<tr>
<td>Shared?:</td>
<td>Shared?:<br>
(available to all subgroups)</td>
<td class=left>". ($defaults["shared"] ? "Yes" : "No") . "</td>
</tr>\n";
......@@ -247,7 +249,8 @@ function SPITFORM($image, $formfields, $errors)
# Global?
#
echo "<tr>
<td>Global?:</td>
<td>Global?:<br>
(available to all projects)</td>
<td class=left>". ($defaults["global"] ? "Yes" : "No") . "</td>
</tr>\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 "<center>
There are other image descriptors that specify the
same OS descriptors for the same node types.<br>
......
<?php
#
# 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.
#
include("defs.php3");
......@@ -22,6 +22,9 @@ $this_user = CheckLoginOrDie();
$uid = $this_user->uid();
$isadmin = ISADMIN();
#
# Verify page arguments.
#
$optargs = OptionalPageArguments("nsdata", PAGEARG_ANYTHING,
"formfields", PAGEARG_ARRAY,
"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