aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2007-12-07 00:26:24 +0000
committerRuss Allbery <rra@stanford.edu>2007-12-07 00:26:24 +0000
commit5a6775be4fdbee0523a573af960568ca21f38c49 (patch)
treea8c0ed31e880143825f8760bc59e27babbe966a7
parentb21e806902b9d9342c5990e7b42cbe99e98af704 (diff)
Allow the empty string in wallet-backend arguments.
When writing to a file in the wallet client program, remove an old backup file before creating a new backup and don't fail if the backup already exists.
-rw-r--r--NEWS6
-rw-r--r--client/file.c6
-rwxr-xr-xserver/wallet-backend2
-rw-r--r--tests/client/basic-t.in15
-rw-r--r--tests/server/backend-t.in9
5 files changed, 32 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index ce9a03a..0a53e35 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@
wallet 0.5 (unreleased)
+ Allow the empty string in wallet-backend arguments.
+
Load the Perl modules for ACL verifiers and object types dynamically
now that we're reading the class from the database.
@@ -9,6 +11,10 @@ wallet 0.5 (unreleased)
containing periods. Otherwise, it's hard to manage host keytabs. Add
a missing test suite for that method.
+ When writing to a file in the wallet client program, remove an old
+ backup file before creating a new backup and don't fail if the backup
+ already exists.
+
wallet 0.4 (2007-12-05)
Maintain a global cache of ACL verifiers in Wallet::ACL and reuse them
diff --git a/client/file.c b/client/file.c
index 5002d01..8e16103 100644
--- a/client/file.c
+++ b/client/file.c
@@ -40,9 +40,13 @@ write_file(const char *name, const void *data, size_t length)
die("write to %s truncated", temp);
if (close(fd) < 0)
sysdie("close of %s failed (file probably truncated)", temp);
- if (access(name, F_OK) == 0)
+ if (access(name, F_OK) == 0) {
+ if (access(backup, F_OK) == 0)
+ if (unlink(backup) < 0)
+ sysdie("unlink of old backup %s failed", backup);
if (link(name, backup) < 0)
sysdie("link of %s to %s failed", name, backup);
+ }
if (rename(temp, name) < 0)
sysdie("rename of %s to %s failed", temp, name);
free(temp);
diff --git a/server/wallet-backend b/server/wallet-backend
index c2be5e7..4af7490 100755
--- a/server/wallet-backend
+++ b/server/wallet-backend
@@ -120,7 +120,7 @@ sub check_args {
my %exclude = map { $_ => 1 } @$exclude;
for (my $i = 1; $i <= @args; $i++) {
next if $exclude{$i};
- unless ($args[$i - 1] =~ m,^[\w_/.-]+\z,) {
+ unless ($args[$i - 1] =~ m,^[\w_/.-]*\z,) {
error "invalid characters in argument: $args[$i - 1]";
}
}
diff --git a/tests/client/basic-t.in b/tests/client/basic-t.in
index 4d9b796..8f7632c 100644
--- a/tests/client/basic-t.in
+++ b/tests/client/basic-t.in
@@ -54,7 +54,7 @@ runfailure () {
}
# Print the number of tests.
-echo 17
+echo 20
# Find the client program.
if [ -f ../data/test.keytab ] ; then
@@ -65,7 +65,7 @@ else
fi
fi
if [ ! -f data/test.keytab ] || [ -z "@REMCTLD@" ] ; then
- for n in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 ; do
+ for n in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ; do
echo ok $n \# skip -- no Kerberos configuration
done
exit 0
@@ -136,6 +136,17 @@ if [ -f keytab.bak ] || [ -f keytab.new ] ; then
else
printcount "ok"
fi
+runsuccess "" -c fake-wallet get keytab -f keytab service/fake-test
+if cmp keytab data/fake-data >/dev/null 2>&1 ; then
+ printcount "ok"
+else
+ printcount "not ok"
+fi
+if [ -f keytab.new ] || [ ! -f keytab.bak ] ; then
+ printcount "not ok"
+else
+ printcount "ok"
+fi
runsuccess "" -c fake-wallet get keytab -f keytab -S srvtab service/fake-srvtab
if cmp keytab data/fake-keytab >/dev/null 2>&1 ; then
printcount "ok"
diff --git a/tests/server/backend-t.in b/tests/server/backend-t.in
index 8509177..0c02598 100644
--- a/tests/server/backend-t.in
+++ b/tests/server/backend-t.in
@@ -9,7 +9,7 @@
use strict;
use IO::String;
-use Test::More tests => 1222;
+use Test::More tests => 1224;
# Create a dummy class for Wallet::Server that prints what method was called
# with its arguments and returns data for testing.
@@ -434,7 +434,12 @@ for my $command (sort keys %flag_commands) {
}
# Almost done. All that remains is to test the robustness of the bad
-# character checks against every possible character.
+# character checks against every possible character and test permitting the
+# empty argument.
+($out, $err) = run_backend ('show', 'type', '');
+is ($err, '', 'Allowed the empty argument');
+is ($OUTPUT, "command show type from admin (1.2.3.4) succeeded\n",
+ ' and success logged');
my $ok = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_/.-';
($out, $err) = run_backend ('show', 'type', $ok);
is ($err, '', 'Allowed all valid characters');