summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorespie <espie@openbsd.org>2014-01-23 12:28:48 +0000
committerespie <espie@openbsd.org>2014-01-23 12:28:48 +0000
commit97985d0935f95dbf326edc4a75f5c4ace72ced04 (patch)
tree98273b4898cded3b7e0a05432ff9783b8373aa77
parentseparate pkg_sign documentation. Option description becomes MUCH saner. (diff)
downloadwireguard-openbsd-97985d0935f95dbf326edc4a75f5c4ace72ced04.tar.xz
wireguard-openbsd-97985d0935f95dbf326edc4a75f5c4ace72ced04.zip
check parameters better.
create -o directory if necessary
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PkgSign.pm17
1 files changed, 12 insertions, 5 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgSign.pm b/usr.sbin/pkg_add/OpenBSD/PkgSign.pm
index 05293928720..9d6bafeb548 100644
--- a/usr.sbin/pkg_add/OpenBSD/PkgSign.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PkgSign.pm
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: PkgSign.pm,v 1.1 2014/01/23 11:45:22 espie Exp $
+# $OpenBSD: PkgSign.pm,v 1.2 2014/01/23 12:28:48 espie Exp $
#
# Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org>
#
@@ -33,9 +33,6 @@ sub handle_options
'o' =>
sub {
$state->{output_dir} = shift;
- if (!-d $state->{output_dir}) {
- $state->usage("no such dir");
- }
},
'S' =>
sub {
@@ -46,7 +43,14 @@ sub handle_options
'[-v] [-D name[=value]]',
'[-s [x509 -s cert|signify] -s priv] [-o dir]',
'[-S source|pkg-name...]');
-
+ if (!defined $state->{signer}) {
+ $state->usage("Can't invoke command without valid signing parameters");
+ }
+ if (!-d $state->{output_dir}) {
+ require File::Path;
+ File::Path::make_path($state->{output_dir})
+ or $state->usage("can't create dir");
+ }
}
package OpenBSD::PackingElement;
@@ -187,6 +191,9 @@ sub parse_and_run
my $state = OpenBSD::PkgSign::State->new($cmd);
$state->handle_options;
$state->{wantntogo} = $state->config->istrue("ntogo");
+ if (!defined $state->{source} && @ARGV == 0) {
+ $state->usage("Nothing to sign");
+ }
if (defined $state->{source}) {
$self->sign_existing_repository($state,
$state->{source});