summaryrefslogtreecommitdiffstats
path: root/scripts/certs/cert-import
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/certs/cert-import')
-rwxr-xr-xscripts/certs/cert-import33
1 files changed, 24 insertions, 9 deletions
diff --git a/scripts/certs/cert-import b/scripts/certs/cert-import
index ecf8b76..7e23d32 100755
--- a/scripts/certs/cert-import
+++ b/scripts/certs/cert-import
@@ -4,10 +4,7 @@
#
# jpokorny@redhat.com
#
-# TODO: fix exit code
-
-set -u
-set +e
+# TODO: fix exit code, remove unneeded subshells? ( '()' -> '{}' )
source cert-check
@@ -40,18 +37,20 @@ cert_import_firefox() {
}
cert_import() {
- local homebundle=0 firefox=0 mutt=0 crl=1
+ local homebundle=0 firefox=0 mutt=0 crl=1 spec=0
while true; do
case $1 in
homebundle) homebundle=1;;
firefox) firefox=1;;
mutt) mutt=1;;
all) homebundle=1; firefox=1; mutt=1;;
- --) ;;
- *) break;;
+ --|*) break;;
esac
+ spec=1
shift
done
+ [ $spec -eq 0 ] \
+ && echo "run me without arguments to get usage help" && return
[ "$1" = "-nocrl" ] && shift && crl=0
(
(cert_pick "$@" | cert_check $crl) \
@@ -62,8 +61,24 @@ cert_import() {
) |& colorize 1
}
+setup() {
+ set -u
+ RESTOREUMASK=$(umask -p)
+ umask 077
+}
+
+teardown() {
+ ${RESTOREUMASK}
+ unset RESTOREUMASK
+ return $1
+}
+
[[ "${BASH_SOURCE[0]}" != "${0}" ]] || \
[ $# -lt 1 ] \
- && echo "usage: $0 (homebundle|mutt|firefox|all)* [-nocrl] file-or-server [port=443]" \
- || ( cert_import "$@" && set +u || ( ret=$?; set +u; pseudo_return $ret ))
+ && echo "usage: $0" \
+ "(homebundle|mutt|firefox|all)*" \
+ "[-nocrl] file-or-server [port=443]" \
+ || ( setup
+ cert_import "$@"
+ teardown $? )