certmonger-0.79.5/ 0000775 0025364 0001750 00000000000 13152316411 010770 5 0000000 0000000 certmonger-0.79.5/tests/ 0000775 0025364 0001750 00000000000 13152316411 012132 5 0000000 0000000 certmonger-0.79.5/tests/certmonger.conf 0000664 0025364 0001750 00000000110 13152316372 015064 0000000 0000000 [defaults]
notification_method = stdout
[selfsign]
validity_period = 1d
certmonger-0.79.5/tests/functions 0000664 0025364 0001750 00000002423 13152316372 014014 0000000 0000000 #!/bin/bash
function initnssdb() {
dir=`echo "$1" | cut -f2- -d:`
if ! test -d "$dir"/rosubdir ; then
mkdir -m 500 "$dir"/rosubdir
fi
if test -d "$dir"/rwsubdir ; then
chmod u+w "$dir"/rwsubdir/* || true
rm -f "$dir"/rwsubdir/*
else
mkdir -m 700 "$dir"/rwsubdir
fi
echo "" > "$dir"/oldpin
echo "" > "$dir"/oldpin2
echo "" >> "$dir"/oldpin2
echo "$2" > "$dir"/newpin
echo "$2" > "$dir"/newpin2
echo "$2" >> "$dir"/newpin2
certutil -d "$1" -W -f "$dir"/oldpin -@ "$dir"/oldpin2 > /dev/null
certutil -d "$1" -W -f "$dir"/oldpin -@ "$dir"/newpin2 > /dev/null
certutil -d "$1" -W -f "$dir"/newpin -@ "$dir"/newpin2 > /dev/null
certutil -d "$1"/rwsubdir -W -f "$dir"/oldpin -@ "$dir"/oldpin2 > /dev/null
certutil -d "$1"/rwsubdir -W -f "$dir"/oldpin -@ "$dir"/newpin2 > /dev/null
certutil -d "$1"/rwsubdir -W -f "$dir"/newpin -@ "$dir"/newpin2 > /dev/null
chmod u-w "$dir"/rwsubdir/*
}
function run_certutil() {
dd if=/dev/urandom of="$dir"/noise bs=1024 count=1 > /dev/null 2> /dev/null
certutil "$@" -z "$dir"/noise
}
function run_dos2unix() {
dos2unix "$@" 2>&1 | sed -e s,Unix,unix,g -e s,UNIX,unix,g -e s,'format \.\.\.','format...',g
}
function run_unix2dos() {
unix2dos "$@" 2>&1 | sed -e s,Unix,unix,g -e s,UNIX,unix,g -e s,'format \.\.\.','format...',g
}
certmonger-0.79.5/tests/run-tests.sh 0000775 0025364 0001750 00000006147 13152316372 014373 0000000 0000000 #!/bin/bash
tmpfile=`mktemp ${TMPDIR:-/tmp}/runtestsXXXXXX`
if test -z "$tmpfile" ; then
echo Error creating temporary file.
exit 1
else
trap 'rm -f "$tmpfile"' EXIT
fi
tmpdir=`mktemp -d ${TMPDIR:-/tmp}/runtestsXXXXXX`
if test -z "$tmpdir" ; then
echo Error creating temporary directory.
exit 1
else
trap 'rm -f "$tmpfile"; rm -fr "$tmpdir"' EXIT
fi
mkdir -m 500 "$tmpdir"/rosubdir
mkdir -m 700 "$tmpdir"/rwsubdir
trap 'rm -f "$tmpfile"; chmod u+w "$tmpdir"/* ; rm -fr "$tmpdir"' EXIT
unset DBUS_SESSION_BUS_ADDRESS
eval `dbus-launch --sh-syntax`
if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
echo Error launching session bus.
exit 1
else
trap 'rm -f "$tmpfile"; chmod u+w "$tmpdir"/* ; rm -fr "$tmpdir"; kill "$DBUS_SESSION_BUS_PID"' EXIT
fi
srcdir=${srcdir:-`pwd`}
pushd "$srcdir" > /dev/null
srcdir=`pwd`
popd > /dev/null
builddir=${builddir:-`pwd`}
pushd "$builddir" > /dev/null
builddir=`pwd`
popd > /dev/null
toolsdir=${toolsdir:-${builddir}/tools}
export builddir
export srcdir
export toolsdir
export tmpdir
cd "$builddir"
CERTMONGER_CONFIG_DIR=${srcdir}
export CERTMONGER_CONFIG_DIR
stat=0
subdirs=
if test $# -eq 0 ; then
subdirs=`cd "$srcdir"; ls -1 | grep '^[0-9]'`
fi
for testid in "$@" $subdirs ; do
if test -x "$srcdir"/"$testid"/prequal.sh ; then
if ! "$srcdir"/"$testid"/prequal.sh ; then
echo "Skipping test "$testid"."
continue
fi
fi
RUNVALGRIND=${VALGRIND:+valgrind --log-file="$builddir"/"$testid"/valgrind/%p.log --trace-children=yes --track-origins=yes}
if test -n "$RUNVALGRIND" ; then
rm -fr "$builddir"/"$testid"/valgrind
mkdir -p "$builddir"/"$testid"/valgrind
fi
if test -x "$srcdir"/"$testid"/run.sh ; then
pushd "$srcdir"/"$testid" > /dev/null
mkdir -p "$builddir"/"$testid"
rm -fr "$tmpdir"/*
mkdir -m 500 "$tmpdir"/rosubdir
mkdir -m 700 "$tmpdir"/rwsubdir
if test -r ./expected.out ; then
echo -n "Running test "$testid"... "
$RUNVALGRIND ./run.sh "$tmpdir" > "$tmpfile" 2> "$tmpdir"/errors
sed -i "s|${TMPDIR:-/tmp}/runtests....../|\${tmpdir}/|g" "$tmpfile" "$tmpdir/errors"
stat=1
for i in expected.out* ; do
if ! test -s "$i" ; then
break
fi
if cmp -s "$tmpfile" "$i" 2> /dev/null ; then
stat=0
echo "OK"
cp $tmpfile "$builddir"/"$testid"/actual.out
cp "$tmpdir"/errors "$builddir"/"$testid"/actual.err
break
fi
done
if test $stat -eq 1 ; then
echo "FAIL"
diff -u expected.out "$tmpfile" | sed s,"^\+\+\+ $tmpfile","+++ actual",g
cp $tmpfile "$builddir"/"$testid"/actual.out
cp "$tmpdir"/errors "$builddir"/"$testid"/actual.err
fi
else
echo "Running test "$testid"."
$RUNVALGRIND ./run.sh "$tmpdir"
stat=$?
fi
if test -n "$RUNVALGRIND" ; then
echo > $tmpfile
if grep "ERROR SUMMARY" "$builddir"/"$testid"/valgrind/*.log | grep -v '0 errors' | cut -f1 -d: | xargs grep Command: $tmpfile | grep -qv "Command: /usr" ; then
echo valgrind detected errors
fi
fi
for i in "$tmpdir"/core* ; do
if test -s "$i"; then
cp "$i" .
fi
done
popd > /dev/null
if test $stat -ne 0 ; then
break
fi
else
echo "No test defined in "$testid", skipping."
fi
done
exit $stat
certmonger-0.79.5/tests/Makefile.in 0000664 0025364 0001750 00000100151 13152316377 014130 0000000 0000000 # Makefile.in generated by automake 1.15 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2014 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
@HAVE_DBM_NSSDB_TRUE@am__append_1 = \
@HAVE_DBM_NSSDB_TRUE@ 007-certsave-dbm \
@HAVE_DBM_NSSDB_TRUE@ 011-dbinit-dbm \
@HAVE_DBM_NSSDB_TRUE@ 012-dbadd-dbm \
@HAVE_DBM_NSSDB_TRUE@ 013-enckey-dbm \
@HAVE_DBM_NSSDB_TRUE@ 015-lockedkey-dbm \
@HAVE_DBM_NSSDB_TRUE@ 017-notoken-dbm \
@HAVE_DBM_NSSDB_TRUE@ 034-perms-dbm
@HAVE_SQL_NSSDB_TRUE@am__append_2 = \
@HAVE_SQL_NSSDB_TRUE@ 007-certsave-sql \
@HAVE_SQL_NSSDB_TRUE@ 011-dbinit-sql \
@HAVE_SQL_NSSDB_TRUE@ 012-dbadd-sql \
@HAVE_SQL_NSSDB_TRUE@ 013-enckey-sql \
@HAVE_SQL_NSSDB_TRUE@ 015-lockedkey-sql \
@HAVE_SQL_NSSDB_TRUE@ 017-notoken-sql \
@HAVE_SQL_NSSDB_TRUE@ 034-perms-sql
@HAVE_DSA_TRUE@am__append_3 = \
@HAVE_DSA_TRUE@ 001-keyiread-dsa \
@HAVE_DSA_TRUE@ 002-keygen-dsa \
@HAVE_DSA_TRUE@ 003-csrgen-dsa \
@HAVE_DSA_TRUE@ 004-selfsign-dsa
@HAVE_EC_TRUE@am__append_4 = \
@HAVE_EC_TRUE@ 001-keyiread-ec \
@HAVE_EC_TRUE@ 002-keygen-ec \
@HAVE_EC_TRUE@ 003-csrgen-ec \
@HAVE_EC_TRUE@ 004-selfsign-ec
subdir = tests
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \
$(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
$(top_srcdir)/m4/lib-ld.m4 $(top_srcdir)/m4/lib-link.m4 \
$(top_srcdir)/m4/lib-prefix.m4 $(top_srcdir)/m4/nls.m4 \
$(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/src/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
SOURCES =
DIST_SOURCES =
RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
ctags-recursive dvi-recursive html-recursive info-recursive \
install-data-recursive install-dvi-recursive \
install-exec-recursive install-html-recursive \
install-info-recursive install-pdf-recursive \
install-ps-recursive install-recursive installcheck-recursive \
installdirs-recursive pdf-recursive ps-recursive \
tags-recursive uninstall-recursive
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
$(RECURSIVE_TARGETS) \
$(RECURSIVE_CLEAN_TARGETS) \
$(am__extra_recursive_targets)
AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
distdir
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
am__DIST_COMMON = $(srcdir)/Makefile.in
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
am__relativize = \
dir0=`pwd`; \
sed_first='s,^\([^/]*\)/.*$$,\1,'; \
sed_rest='s,^[^/]*/*,,'; \
sed_last='s,^.*/\([^/]*\)$$,\1,'; \
sed_butlast='s,/*[^/]*$$,,'; \
while test -n "$$dir1"; do \
first=`echo "$$dir1" | sed -e "$$sed_first"`; \
if test "$$first" != "."; then \
if test "$$first" = ".."; then \
dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
else \
first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
if test "$$first2" = "$$first"; then \
dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
else \
dir2="../$$dir2"; \
fi; \
dir0="$$dir0"/"$$first"; \
fi; \
fi; \
dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
done; \
reldir="$$dir2"
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CERTMONGER_CFLAGS = @CERTMONGER_CFLAGS@
CERTMONGER_LIBS = @CERTMONGER_LIBS@
CERTMONGER_PVT_ADDRESS_ENV = @CERTMONGER_PVT_ADDRESS_ENV@
CFLAGS = @CFLAGS@
CM_CERTMASTER_CA_NAME = @CM_CERTMASTER_CA_NAME@
CM_DBUS_NAME = @CM_DBUS_NAME@
CM_DEFAULT_CERT_LIFETIME = @CM_DEFAULT_CERT_LIFETIME@
CM_DEFAULT_IDLE_TIMEOUT = @CM_DEFAULT_IDLE_TIMEOUT@
CM_DEFAULT_NOTIFICATION_SYSLOG_PRIORITY = @CM_DEFAULT_NOTIFICATION_SYSLOG_PRIORITY@
CM_DEFAULT_POPULATE_UNIQUE_ID = @CM_DEFAULT_POPULATE_UNIQUE_ID@
CM_DEFAULT_PUBKEY_SIZE = @CM_DEFAULT_PUBKEY_SIZE@
CM_DEFAULT_TTL_LIST = @CM_DEFAULT_TTL_LIST@
CM_HOMEDIR = @CM_HOMEDIR@
CM_IPA_CA_NAME = @CM_IPA_CA_NAME@
CM_LOCAL_CA_NAME = @CM_LOCAL_CA_NAME@
CM_MINIMUM_DSA_KEY_SIZE = @CM_MINIMUM_DSA_KEY_SIZE@
CM_MINIMUM_EC_KEY_SIZE = @CM_MINIMUM_EC_KEY_SIZE@
CM_MINIMUM_RSA_KEY_SIZE = @CM_MINIMUM_RSA_KEY_SIZE@
CM_NOTIFICATION_ENV = @CM_NOTIFICATION_ENV@
CM_SELF_SIGN_CA_NAME = @CM_SELF_SIGN_CA_NAME@
CM_STORE_CAS_DIRECTORY = @CM_STORE_CAS_DIRECTORY@
CM_STORE_CAS_DIRECTORY_ENV = @CM_STORE_CAS_DIRECTORY_ENV@
CM_STORE_CONFIG_DIRECTORY_ENV = @CM_STORE_CONFIG_DIRECTORY_ENV@
CM_STORE_LOCAL_CA_DIRECTORY = @CM_STORE_LOCAL_CA_DIRECTORY@
CM_STORE_LOCAL_CA_DIRECTORY_ENV = @CM_STORE_LOCAL_CA_DIRECTORY_ENV@
CM_STORE_REQUESTS_DIRECTORY = @CM_STORE_REQUESTS_DIRECTORY@
CM_STORE_REQUESTS_DIRECTORY_ENV = @CM_STORE_REQUESTS_DIRECTORY_ENV@
CM_STORE_SYSTEM_LOCK_FILE = @CM_STORE_SYSTEM_LOCK_FILE@
CM_STORE_SYSTEM_LOCK_FILE_ENV = @CM_STORE_SYSTEM_LOCK_FILE_ENV@
CM_TMPDIR = @CM_TMPDIR@
CM_TMPDIR_ENV = @CM_TMPDIR_ENV@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CURL_CFLAGS = @CURL_CFLAGS@
CURL_LIBS = @CURL_LIBS@
CYGPATH_W = @CYGPATH_W@
DBUS_CFLAGS = @DBUS_CFLAGS@
DBUS_LIBS = @DBUS_LIBS@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GETCERT_CFLAGS = @GETCERT_CFLAGS@
GETCERT_LIBS = @GETCERT_LIBS@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMP_CFLAGS = @GMP_CFLAGS@
GMP_LIBS = @GMP_LIBS@
GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@
GREP = @GREP@
IDN_CFLAGS = @IDN_CFLAGS@
IDN_LIBS = @IDN_LIBS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
INTLLIBS = @INTLLIBS@
INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
KRB5_CFLAGS = @KRB5_CFLAGS@
KRB5_CONFIG = @KRB5_CONFIG@
KRB5_LIBS = @KRB5_LIBS@
LDAP_CFLAGS = @LDAP_CFLAGS@
LDAP_LIBS = @LDAP_LIBS@
LDFLAGS = @LDFLAGS@
LIBICONV = @LIBICONV@
LIBINTL = @LIBINTL@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBICONV = @LTLIBICONV@
LTLIBINTL = @LTLIBINTL@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MAN_DSA = @MAN_DSA@
MAN_EC = @MAN_EC@
MKDIR_P = @MKDIR_P@
MSGFMT = @MSGFMT@
MSGFMT_015 = @MSGFMT_015@
MSGMERGE = @MSGMERGE@
NO_MAN_DSA = @NO_MAN_DSA@
NO_MAN_EC = @NO_MAN_EC@
NSS_CFLAGS = @NSS_CFLAGS@
NSS_LIBS = @NSS_LIBS@
OBJEXT = @OBJEXT@
OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
OPENSSL_LIBS = @OPENSSL_LIBS@
OPENSSL_SSL_CFLAGS = @OPENSSL_SSL_CFLAGS@
OPENSSL_SSL_LIBS = @OPENSSL_SSL_LIBS@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
POPT_CFLAGS = @POPT_CFLAGS@
POPT_LIBS = @POPT_LIBS@
POSUB = @POSUB@
RANLIB = @RANLIB@
RESOLV_LIBS = @RESOLV_LIBS@
SED = @SED@
SESSIONBUSSERVICESDIR = @SESSIONBUSSERVICESDIR@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
SYSTEMBUSSERVICESDIR = @SYSTEMBUSSERVICESDIR@
SYSTEMD = @SYSTEMD@
SYSTEMDSYSTEMUNITDIR = @SYSTEMDSYSTEMUNITDIR@
SYSVINIT = @SYSVINIT@
TALLOC_CFLAGS = @TALLOC_CFLAGS@
TALLOC_LIBS = @TALLOC_LIBS@
TEVENT_CFLAGS = @TEVENT_CFLAGS@
TEVENT_LIBS = @TEVENT_LIBS@
TMPFILES = @TMPFILES@
USE_NLS = @USE_NLS@
UUID_CFLAGS = @UUID_CFLAGS@
UUID_LIBS = @UUID_LIBS@
VERSION = @VERSION@
XGETTEXT = @XGETTEXT@
XGETTEXT_015 = @XGETTEXT_015@
XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
XMLRPC_CFLAGS = @XMLRPC_CFLAGS@
XMLRPC_C_CONFIG = @XMLRPC_C_CONFIG@
XMLRPC_LIBS = @XMLRPC_LIBS@
XML_CFLAGS = @XML_CFLAGS@
XML_LIBS = @XML_LIBS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
mybindir = @mybindir@
mylibexecdir = @mylibexecdir@
mysbindir = @mysbindir@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = tools
CLEANFILES = \
001-keyiread/actual.out \
001-keyiread/actual.err \
001-keyiread-dsa/actual.out \
001-keyiread-dsa/actual.err \
001-keyiread-ec/actual.out \
001-keyiread-ec/actual.err \
001-keyiread-rsa/actual.out \
001-keyiread-rsa/actual.err \
002-keygen/actual.out \
002-keygen/actual.err \
002-keygen-dsa/actual.out \
002-keygen-dsa/actual.err \
002-keygen-ec/actual.out \
002-keygen-ec/actual.err \
002-keygen-rsa/actual.out \
002-keygen-rsa/actual.err \
003-csrgen/actual.out \
003-csrgen/actual.err \
003-csrgen-dsa/actual.out \
003-csrgen-dsa/actual.err \
003-csrgen-ec/actual.out \
003-csrgen-ec/actual.err \
003-csrgen-rsa/actual.out \
003-csrgen-rsa/actual.err \
004-selfsign/actual.out \
004-selfsign/actual.err \
004-selfsign-dsa/actual.out \
004-selfsign-dsa/actual.err \
004-selfsign-ec/actual.out \
004-selfsign-ec/actual.err \
004-selfsign-rsa/actual.out \
004-selfsign-rsa/actual.err \
005-dbusm/actual.out \
005-dbusm/actual.err \
006-serial/actual.out \
006-serial/actual.err \
007-certsave/actual.out \
007-certsave/actual.err \
007-certsave-dbm/actual.out \
007-certsave-dbm/actual.err \
007-certsave-sql/actual.out \
007-certsave-sql/actual.err \
008-certread/actual.out \
008-certread/actual.err \
009-oiddict/actual.out \
009-oiddict/actual.err \
010-iterate/actual.out \
010-iterate/actual.err \
011-dbinit/actual.out \
011-dbinit/actual.err \
011-dbinit-dbm/actual.out \
011-dbinit-dbm/actual.err \
011-dbinit-sql/actual.out \
011-dbinit-sql/actual.err \
012-dbadd/actual.out \
012-dbadd/actual.err \
012-dbadd-dbm/actual.out \
012-dbadd-dbm/actual.err \
012-dbadd-sql/actual.out \
012-dbadd-sql/actual.err \
013-enckey/actual.out \
013-enckey/actual.err \
013-enckey-dbm/actual.out \
013-enckey-dbm/actual.err \
013-enckey-sql/actual.out \
013-enckey-sql/actual.err \
014-prefs/actual.out \
014-prefs/actual.err \
015-lockedkey/actual.out \
015-lockedkey/actual.err \
015-lockedkey-dbm/actual.out \
015-lockedkey-dbm/actual.err \
015-lockedkey-sql/actual.out \
015-lockedkey-sql/actual.err \
016-dates/actual.out \
016-dates/actual.err \
017-notoken/actual.out \
017-notoken/actual.err \
017-notoken-dbm/actual.out \
017-notoken-dbm/actual.err \
017-notoken-sql/actual.out \
017-notoken-sql/actual.err \
018-pembase/actual.out \
018-pembase/actual.err \
019-dparse/actual.out \
019-dparse/actual.err \
020-xparse/actual.out \
020-xparse/actual.err \
021-resume/actual.out \
021-resume/actual.err \
022-base64/actual.out \
022-base64/actual.err \
023-cadata/actual.out \
023-cadata/actual.err \
024-citerate/actual.out \
024-citerate/actual.err \
025-casave/actual.out \
025-casave/actual.err \
026-local/actual.out \
026-local/actual.err \
027-hooks/actual.out \
027-hooks/actual.err \
028-dbus/actual.out \
028-dbus/actual.err \
029-canonize/actual.out \
029-canonize/actual.err \
030-rekey/actual.out \
030-rekey/actual.err \
031-pkcs7/actual.out \
031-pkcs7/actual.err \
032-chain/actual.out \
032-chain/actual.err \
033-scep/actual.out \
033-scep/actual.err \
034-perms/actual.out \
034-perms/actual.err \
034-perms-dbm/actual.out \
034-perms-dbm/actual.err \
034-perms-sql/actual.out \
034-perms-sql/actual.err \
035-json/actual.out \
035-json/actual.err \
036-getcert/actual.out \
036-getcert/actual.err \
037-rekey2/actual.out \
037-rekey2/actual.err \
038-ms-v2-template/actual.out \
038-ms-v2-template/actual.err
EXTRA_DIST = \
run-tests.sh functions certmonger.conf tools/cachain.sh \
001-keyiread/run.sh \
001-keyiread/expected.out \
001-keyiread-rsa/run.sh \
001-keyiread-rsa/expected.out \
001-keyiread-dsa/run.sh \
001-keyiread-dsa/expected.out \
001-keyiread-dsa/expected.out.2048 \
001-keyiread-ec/run.sh \
001-keyiread-ec/expected.out \
001-keyiread-ec/expected.out.2 \
001-keyiread-ec/expected.out.3 \
001-keyiread-ec/expected.out.4 \
002-keygen/prequal.sh \
002-keygen/run.sh \
002-keygen/expected.out \
002-keygen-rsa/prequal.sh \
002-keygen-rsa/run.sh \
002-keygen-rsa/expected.out \
002-keygen-dsa/prequal.sh \
002-keygen-dsa/run.sh \
002-keygen-dsa/expected.out \
002-keygen-dsa/expected.out.2 \
002-keygen-dsa/expected.out.3 \
002-keygen-ec/prequal.sh \
002-keygen-ec/run.sh \
002-keygen-ec/expected.out \
002-keygen-ec/expected.out.2 \
002-keygen-ec/expected.out.3 \
002-keygen-ec/expected.out.4 \
003-csrgen/run.sh \
003-csrgen/expected.out \
003-csrgen-rsa/run.sh \
003-csrgen-rsa/expected.out \
003-csrgen-dsa/run.sh \
003-csrgen-dsa/expected.out \
003-csrgen-ec/run.sh \
003-csrgen-ec/expected.out \
004-selfsign/run.sh \
004-selfsign/expected.out \
004-selfsign-rsa/run.sh \
004-selfsign-rsa/expected.out \
004-selfsign-dsa/run.sh \
004-selfsign-dsa/expected.out \
004-selfsign-ec/run.sh \
004-selfsign-ec/expected.out \
005-dbusm/run.sh \
005-dbusm/expected.out \
006-serial/run.sh \
006-serial/expected.out \
007-certsave/prequal.sh \
007-certsave/run.sh \
007-certsave/expected.out \
007-certsave-dbm/prequal.sh \
007-certsave-dbm/run.sh \
007-certsave-dbm/expected.out \
007-certsave-sql/prequal.sh \
007-certsave-sql/run.sh \
007-certsave-sql/expected.out \
008-certread/run.sh \
008-certread/expected.out \
009-oiddict/run.sh \
009-oiddict/expected.out \
010-iterate/run.sh \
010-iterate/expected.out \
011-dbinit/expected.out \
011-dbinit/run.sh \
011-dbinit-dbm/expected.out \
011-dbinit-dbm/run.sh \
011-dbinit-sql/expected.out \
011-dbinit-sql/run.sh \
012-dbadd/expected.out \
012-dbadd/run.sh \
012-dbadd-dbm/expected.out \
012-dbadd-dbm/run.sh \
012-dbadd-sql/expected.out \
012-dbadd-sql/run.sh \
013-enckey/expected.out \
013-enckey/run.sh \
013-enckey-dbm/expected.out \
013-enckey-dbm/run.sh \
013-enckey-sql/expected.out \
013-enckey-sql/run.sh \
014-prefs/expected.out \
014-prefs/run.sh \
015-lockedkey/expected.out \
015-lockedkey/run.sh \
015-lockedkey-dbm/expected.out \
015-lockedkey-dbm/run.sh \
015-lockedkey-sql/expected.out \
015-lockedkey-sql/run.sh \
016-dates/expected.out \
016-dates/run.sh \
017-notoken/expected.out \
017-notoken/run.sh \
017-notoken-dbm/expected.out \
017-notoken-dbm/run.sh \
017-notoken-sql/expected.out \
017-notoken-sql/run.sh \
018-pembase/expected.out \
018-pembase/run.sh \
019-dparse/expected.out \
019-dparse/run.sh \
019-dparse/bad.checkRequest.nosuch \
019-dparse/bad.displayCertFromRequest.incomplete \
019-dparse/bad.displayCertFromRequest.no-such-request \
019-dparse/bad.displayCertFromRequest.rejected \
019-dparse/bad.profileProcess.bad-property \
019-dparse/bad.profileProcess.no-agent-cert \
019-dparse/bad.profileProcess.no-ca-cert \
019-dparse/bad.profileProcess.no-property \
019-dparse/bad.profileProcess.not-pending \
019-dparse/bad.profileReview.no-such-request \
019-dparse/bad.profileReview.unauthorized-cert \
019-dparse/bad.profileReview.wrong-nssdb \
019-dparse/bad.profileSubmit.csr.empty \
019-dparse/bad.profileSubmit.csr.subject-mismatch \
019-dparse/bad.profileSubmit.serial.empty \
019-dparse/bad.profileSubmit.serial.invalid \
019-dparse/bad.profileSubmit.serial.out-of-range \
019-dparse/good.checkRequest.complete \
019-dparse/good.checkRequest.pending \
019-dparse/good.displayCertFromRequest \
019-dparse/good.displayCertFromRequest-extra-line \
019-dparse/good.profileList \
019-dparse/good.profileReview \
019-dparse/good.profileSubmit.issued \
019-dparse/good.profileSubmit.serial.in-range \
020-xparse/certmaster-fault.xml \
020-xparse/certmaster-rep1.xml \
020-xparse/certmaster-rep2.xml \
020-xparse/certmaster-req.xml \
020-xparse/ipa-fault.xml \
020-xparse/ipa-rep-new.xml \
020-xparse/ipa-req.xml \
021-resume/expected.out \
021-resume/run.sh \
022-base64/expected.out \
022-base64/run.sh \
023-cadata/expected.out \
023-cadata/run.sh \
024-citerate/expected.out \
024-citerate/run.sh \
025-casave/expected.out \
025-casave/run.sh \
026-local/expected.out \
026-local/run.sh \
027-hooks/expected.out \
027-hooks/run.sh \
028-dbus/expected.out 028-dbus/expected.out.nodsa \
028-dbus/entry 028-dbus/bogus-entry \
028-dbus/prequal.sh \
028-dbus/run.sh \
028-dbus/runsub.sh \
028-dbus/simpleprop.py \
028-dbus/walk.py \
029-canonize/expected.out \
029-canonize/run.sh \
030-rekey/expected.out \
030-rekey/run.sh \
031-pkcs7/prequal.sh \
031-pkcs7/expected.out \
031-pkcs7/run.sh \
032-chain/expected.out \
032-chain/run.sh \
033-scep/expected.out \
033-scep/run.sh \
034-perms/expected.out \
034-perms/run.sh \
034-perms-dbm/expected.out \
034-perms-dbm/run.sh \
034-perms-sql/expected.out \
034-perms-sql/run.sh \
035-json/expected.out \
035-json/run.sh \
035-json/bad.1 \
035-json/bad.15 \
035-json/bad.1a \
035-json/bad.1b \
035-json/bad.1c \
035-json/bad.1d \
035-json/bad.1e \
035-json/bad.2 \
035-json/bad.3 \
035-json/bad.4 \
035-json/bad.5 \
035-json/bad.6 \
035-json/bad.8 \
035-json/bad.9 \
035-json/good.1 \
035-json/good.10 \
035-json/good.11 \
035-json/good.12 \
035-json/good.13 \
035-json/good.14 \
035-json/good.15 \
035-json/good.16 \
035-json/good.17 \
035-json/good.18 \
035-json/good.19 \
035-json/good.2 \
035-json/good.20 \
035-json/good.21 \
035-json/good.22 \
035-json/good.2a \
035-json/good.2b \
035-json/good.2c \
035-json/good.3 \
035-json/good.4 \
035-json/good.5 \
035-json/good.6 \
035-json/good.7 \
035-json/good.8 \
035-json/good.9 \
036-getcert/expected.out \
036-getcert/run.sh \
037-rekey2/expected.out \
037-rekey2/run.sh \
038-ms-v2-template/expected.out \
038-ms-v2-template/extract-extdata.py \
038-ms-v2-template/run.sh
subdirs = 001-keyiread 001-keyiread-rsa 002-keygen 002-keygen-rsa \
003-csrgen 003-csrgen-rsa 004-selfsign 004-selfsign-rsa \
005-dbusm 006-serial 007-certsave 008-certread 009-oiddict \
010-iterate 011-dbinit 012-dbadd 013-enckey 014-prefs \
015-lockedkey 016-dates 017-notoken 018-pembase 019-dparse \
021-resume 022-base64 023-cadata 024-citerate 025-casave \
026-local 027-hooks 028-dbus 029-canonize 030-rekey 031-pkcs7 \
032-chain 033-scep 034-perms 035-json 036-getcert 037-rekey2 \
038-ms-v2-template $(am__append_1) $(am__append_2) \
$(am__append_3) $(am__append_4)
all: all-recursive
.SUFFIXES:
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign tests/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
# This directory's subdirectories are mostly independent; you can cd
# into them and run 'make' without going through this Makefile.
# To change the values of 'make' variables: instead of editing Makefiles,
# (1) if the variable is set in 'config.status', edit 'config.status'
# (which will cause the Makefiles to be regenerated when you run 'make');
# (2) otherwise, pass the desired values on the 'make' command line.
$(am__recursive_targets):
@fail=; \
if $(am__make_keepgoing); then \
failcom='fail=yes'; \
else \
failcom='exit 1'; \
fi; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-recursive
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-recursive
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-recursive
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
$(am__make_dryrun) \
|| test -d "$(distdir)/$$subdir" \
|| $(MKDIR_P) "$(distdir)/$$subdir" \
|| exit 1; \
dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
$(am__relativize); \
new_distdir=$$reldir; \
dir1=$$subdir; dir2="$(top_distdir)"; \
$(am__relativize); \
new_top_distdir=$$reldir; \
echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
($(am__cd) $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$new_top_distdir" \
distdir="$$new_distdir" \
am__remove_distdir=: \
am__skip_length_check=: \
am__skip_mode_fix=: \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile
installdirs: installdirs-recursive
installdirs-am:
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic mostlyclean-am
distclean: distclean-recursive
-rm -f Makefile
distclean-am: clean-am distclean-generic distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
html-am:
info: info-recursive
info-am:
install-data-am:
install-dvi: install-dvi-recursive
install-dvi-am:
install-exec-am:
install-html: install-html-recursive
install-html-am:
install-info: install-info-recursive
install-info-am:
install-man:
install-pdf: install-pdf-recursive
install-pdf-am:
install-ps: install-ps-recursive
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-generic
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am:
.MAKE: $(am__recursive_targets) install-am install-strip
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am check \
check-am clean clean-generic cscopelist-am ctags ctags-am \
distclean distclean-generic distclean-tags distdir dvi dvi-am \
html html-am info info-am install install-am install-data \
install-data-am install-dvi install-dvi-am install-exec \
install-exec-am install-html install-html-am install-info \
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip installcheck \
installcheck-am installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
pdf-am ps ps-am tags tags-am uninstall uninstall-am
.PRECIOUS: Makefile
check: all
for required in certutil cmsutil pk12util openssl diff cmp mktemp \
dos2unix unix2dos dbus-launch ; do \
which $$required || exit 1; \
done
env srcdir=$(srcdir) \
builddir=$(top_builddir)/tests \
$(srcdir)/run-tests.sh $(subdirs)
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
certmonger-0.79.5/tests/Makefile.am 0000664 0025364 0001750 00000025521 13152316372 014121 0000000 0000000 SUBDIRS = tools
CLEANFILES = \
001-keyiread/actual.out \
001-keyiread/actual.err \
001-keyiread-dsa/actual.out \
001-keyiread-dsa/actual.err \
001-keyiread-ec/actual.out \
001-keyiread-ec/actual.err \
001-keyiread-rsa/actual.out \
001-keyiread-rsa/actual.err \
002-keygen/actual.out \
002-keygen/actual.err \
002-keygen-dsa/actual.out \
002-keygen-dsa/actual.err \
002-keygen-ec/actual.out \
002-keygen-ec/actual.err \
002-keygen-rsa/actual.out \
002-keygen-rsa/actual.err \
003-csrgen/actual.out \
003-csrgen/actual.err \
003-csrgen-dsa/actual.out \
003-csrgen-dsa/actual.err \
003-csrgen-ec/actual.out \
003-csrgen-ec/actual.err \
003-csrgen-rsa/actual.out \
003-csrgen-rsa/actual.err \
004-selfsign/actual.out \
004-selfsign/actual.err \
004-selfsign-dsa/actual.out \
004-selfsign-dsa/actual.err \
004-selfsign-ec/actual.out \
004-selfsign-ec/actual.err \
004-selfsign-rsa/actual.out \
004-selfsign-rsa/actual.err \
005-dbusm/actual.out \
005-dbusm/actual.err \
006-serial/actual.out \
006-serial/actual.err \
007-certsave/actual.out \
007-certsave/actual.err \
007-certsave-dbm/actual.out \
007-certsave-dbm/actual.err \
007-certsave-sql/actual.out \
007-certsave-sql/actual.err \
008-certread/actual.out \
008-certread/actual.err \
009-oiddict/actual.out \
009-oiddict/actual.err \
010-iterate/actual.out \
010-iterate/actual.err \
011-dbinit/actual.out \
011-dbinit/actual.err \
011-dbinit-dbm/actual.out \
011-dbinit-dbm/actual.err \
011-dbinit-sql/actual.out \
011-dbinit-sql/actual.err \
012-dbadd/actual.out \
012-dbadd/actual.err \
012-dbadd-dbm/actual.out \
012-dbadd-dbm/actual.err \
012-dbadd-sql/actual.out \
012-dbadd-sql/actual.err \
013-enckey/actual.out \
013-enckey/actual.err \
013-enckey-dbm/actual.out \
013-enckey-dbm/actual.err \
013-enckey-sql/actual.out \
013-enckey-sql/actual.err \
014-prefs/actual.out \
014-prefs/actual.err \
015-lockedkey/actual.out \
015-lockedkey/actual.err \
015-lockedkey-dbm/actual.out \
015-lockedkey-dbm/actual.err \
015-lockedkey-sql/actual.out \
015-lockedkey-sql/actual.err \
016-dates/actual.out \
016-dates/actual.err \
017-notoken/actual.out \
017-notoken/actual.err \
017-notoken-dbm/actual.out \
017-notoken-dbm/actual.err \
017-notoken-sql/actual.out \
017-notoken-sql/actual.err \
018-pembase/actual.out \
018-pembase/actual.err \
019-dparse/actual.out \
019-dparse/actual.err \
020-xparse/actual.out \
020-xparse/actual.err \
021-resume/actual.out \
021-resume/actual.err \
022-base64/actual.out \
022-base64/actual.err \
023-cadata/actual.out \
023-cadata/actual.err \
024-citerate/actual.out \
024-citerate/actual.err \
025-casave/actual.out \
025-casave/actual.err \
026-local/actual.out \
026-local/actual.err \
027-hooks/actual.out \
027-hooks/actual.err \
028-dbus/actual.out \
028-dbus/actual.err \
029-canonize/actual.out \
029-canonize/actual.err \
030-rekey/actual.out \
030-rekey/actual.err \
031-pkcs7/actual.out \
031-pkcs7/actual.err \
032-chain/actual.out \
032-chain/actual.err \
033-scep/actual.out \
033-scep/actual.err \
034-perms/actual.out \
034-perms/actual.err \
034-perms-dbm/actual.out \
034-perms-dbm/actual.err \
034-perms-sql/actual.out \
034-perms-sql/actual.err \
035-json/actual.out \
035-json/actual.err \
036-getcert/actual.out \
036-getcert/actual.err \
037-rekey2/actual.out \
037-rekey2/actual.err \
038-ms-v2-template/actual.out \
038-ms-v2-template/actual.err
EXTRA_DIST = \
run-tests.sh functions certmonger.conf tools/cachain.sh \
001-keyiread/run.sh \
001-keyiread/expected.out \
001-keyiread-rsa/run.sh \
001-keyiread-rsa/expected.out \
001-keyiread-dsa/run.sh \
001-keyiread-dsa/expected.out \
001-keyiread-dsa/expected.out.2048 \
001-keyiread-ec/run.sh \
001-keyiread-ec/expected.out \
001-keyiread-ec/expected.out.2 \
001-keyiread-ec/expected.out.3 \
001-keyiread-ec/expected.out.4 \
002-keygen/prequal.sh \
002-keygen/run.sh \
002-keygen/expected.out \
002-keygen-rsa/prequal.sh \
002-keygen-rsa/run.sh \
002-keygen-rsa/expected.out \
002-keygen-dsa/prequal.sh \
002-keygen-dsa/run.sh \
002-keygen-dsa/expected.out \
002-keygen-dsa/expected.out.2 \
002-keygen-dsa/expected.out.3 \
002-keygen-ec/prequal.sh \
002-keygen-ec/run.sh \
002-keygen-ec/expected.out \
002-keygen-ec/expected.out.2 \
002-keygen-ec/expected.out.3 \
002-keygen-ec/expected.out.4 \
003-csrgen/run.sh \
003-csrgen/expected.out \
003-csrgen-rsa/run.sh \
003-csrgen-rsa/expected.out \
003-csrgen-dsa/run.sh \
003-csrgen-dsa/expected.out \
003-csrgen-ec/run.sh \
003-csrgen-ec/expected.out \
004-selfsign/run.sh \
004-selfsign/expected.out \
004-selfsign-rsa/run.sh \
004-selfsign-rsa/expected.out \
004-selfsign-dsa/run.sh \
004-selfsign-dsa/expected.out \
004-selfsign-ec/run.sh \
004-selfsign-ec/expected.out \
005-dbusm/run.sh \
005-dbusm/expected.out \
006-serial/run.sh \
006-serial/expected.out \
007-certsave/prequal.sh \
007-certsave/run.sh \
007-certsave/expected.out \
007-certsave-dbm/prequal.sh \
007-certsave-dbm/run.sh \
007-certsave-dbm/expected.out \
007-certsave-sql/prequal.sh \
007-certsave-sql/run.sh \
007-certsave-sql/expected.out \
008-certread/run.sh \
008-certread/expected.out \
009-oiddict/run.sh \
009-oiddict/expected.out \
010-iterate/run.sh \
010-iterate/expected.out \
011-dbinit/expected.out \
011-dbinit/run.sh \
011-dbinit-dbm/expected.out \
011-dbinit-dbm/run.sh \
011-dbinit-sql/expected.out \
011-dbinit-sql/run.sh \
012-dbadd/expected.out \
012-dbadd/run.sh \
012-dbadd-dbm/expected.out \
012-dbadd-dbm/run.sh \
012-dbadd-sql/expected.out \
012-dbadd-sql/run.sh \
013-enckey/expected.out \
013-enckey/run.sh \
013-enckey-dbm/expected.out \
013-enckey-dbm/run.sh \
013-enckey-sql/expected.out \
013-enckey-sql/run.sh \
014-prefs/expected.out \
014-prefs/run.sh \
015-lockedkey/expected.out \
015-lockedkey/run.sh \
015-lockedkey-dbm/expected.out \
015-lockedkey-dbm/run.sh \
015-lockedkey-sql/expected.out \
015-lockedkey-sql/run.sh \
016-dates/expected.out \
016-dates/run.sh \
017-notoken/expected.out \
017-notoken/run.sh \
017-notoken-dbm/expected.out \
017-notoken-dbm/run.sh \
017-notoken-sql/expected.out \
017-notoken-sql/run.sh \
018-pembase/expected.out \
018-pembase/run.sh \
019-dparse/expected.out \
019-dparse/run.sh \
019-dparse/bad.checkRequest.nosuch \
019-dparse/bad.displayCertFromRequest.incomplete \
019-dparse/bad.displayCertFromRequest.no-such-request \
019-dparse/bad.displayCertFromRequest.rejected \
019-dparse/bad.profileProcess.bad-property \
019-dparse/bad.profileProcess.no-agent-cert \
019-dparse/bad.profileProcess.no-ca-cert \
019-dparse/bad.profileProcess.no-property \
019-dparse/bad.profileProcess.not-pending \
019-dparse/bad.profileReview.no-such-request \
019-dparse/bad.profileReview.unauthorized-cert \
019-dparse/bad.profileReview.wrong-nssdb \
019-dparse/bad.profileSubmit.csr.empty \
019-dparse/bad.profileSubmit.csr.subject-mismatch \
019-dparse/bad.profileSubmit.serial.empty \
019-dparse/bad.profileSubmit.serial.invalid \
019-dparse/bad.profileSubmit.serial.out-of-range \
019-dparse/good.checkRequest.complete \
019-dparse/good.checkRequest.pending \
019-dparse/good.displayCertFromRequest \
019-dparse/good.displayCertFromRequest-extra-line \
019-dparse/good.profileList \
019-dparse/good.profileReview \
019-dparse/good.profileSubmit.issued \
019-dparse/good.profileSubmit.serial.in-range \
020-xparse/certmaster-fault.xml \
020-xparse/certmaster-rep1.xml \
020-xparse/certmaster-rep2.xml \
020-xparse/certmaster-req.xml \
020-xparse/ipa-fault.xml \
020-xparse/ipa-rep-new.xml \
020-xparse/ipa-req.xml \
021-resume/expected.out \
021-resume/run.sh \
022-base64/expected.out \
022-base64/run.sh \
023-cadata/expected.out \
023-cadata/run.sh \
024-citerate/expected.out \
024-citerate/run.sh \
025-casave/expected.out \
025-casave/run.sh \
026-local/expected.out \
026-local/run.sh \
027-hooks/expected.out \
027-hooks/run.sh \
028-dbus/expected.out 028-dbus/expected.out.nodsa \
028-dbus/entry 028-dbus/bogus-entry \
028-dbus/prequal.sh \
028-dbus/run.sh \
028-dbus/runsub.sh \
028-dbus/simpleprop.py \
028-dbus/walk.py \
029-canonize/expected.out \
029-canonize/run.sh \
030-rekey/expected.out \
030-rekey/run.sh \
031-pkcs7/prequal.sh \
031-pkcs7/expected.out \
031-pkcs7/run.sh \
032-chain/expected.out \
032-chain/run.sh \
033-scep/expected.out \
033-scep/run.sh \
034-perms/expected.out \
034-perms/run.sh \
034-perms-dbm/expected.out \
034-perms-dbm/run.sh \
034-perms-sql/expected.out \
034-perms-sql/run.sh \
035-json/expected.out \
035-json/run.sh \
035-json/bad.1 \
035-json/bad.15 \
035-json/bad.1a \
035-json/bad.1b \
035-json/bad.1c \
035-json/bad.1d \
035-json/bad.1e \
035-json/bad.2 \
035-json/bad.3 \
035-json/bad.4 \
035-json/bad.5 \
035-json/bad.6 \
035-json/bad.8 \
035-json/bad.9 \
035-json/good.1 \
035-json/good.10 \
035-json/good.11 \
035-json/good.12 \
035-json/good.13 \
035-json/good.14 \
035-json/good.15 \
035-json/good.16 \
035-json/good.17 \
035-json/good.18 \
035-json/good.19 \
035-json/good.2 \
035-json/good.20 \
035-json/good.21 \
035-json/good.22 \
035-json/good.2a \
035-json/good.2b \
035-json/good.2c \
035-json/good.3 \
035-json/good.4 \
035-json/good.5 \
035-json/good.6 \
035-json/good.7 \
035-json/good.8 \
035-json/good.9 \
036-getcert/expected.out \
036-getcert/run.sh \
037-rekey2/expected.out \
037-rekey2/run.sh \
038-ms-v2-template/expected.out \
038-ms-v2-template/extract-extdata.py \
038-ms-v2-template/run.sh
subdirs = \
001-keyiread \
001-keyiread-rsa \
002-keygen \
002-keygen-rsa \
003-csrgen \
003-csrgen-rsa \
004-selfsign \
004-selfsign-rsa \
005-dbusm \
006-serial \
007-certsave \
008-certread \
009-oiddict \
010-iterate \
011-dbinit \
012-dbadd \
013-enckey \
014-prefs \
015-lockedkey \
016-dates \
017-notoken \
018-pembase \
019-dparse \
021-resume \
022-base64 \
023-cadata \
024-citerate \
025-casave \
026-local \
027-hooks \
028-dbus \
029-canonize \
030-rekey \
031-pkcs7 \
032-chain \
033-scep \
034-perms \
035-json \
036-getcert \
037-rekey2 \
038-ms-v2-template
if HAVE_DBM_NSSDB
subdirs += \
007-certsave-dbm \
011-dbinit-dbm \
012-dbadd-dbm \
013-enckey-dbm \
015-lockedkey-dbm \
017-notoken-dbm \
034-perms-dbm
endif
if HAVE_SQL_NSSDB
subdirs += \
007-certsave-sql \
011-dbinit-sql \
012-dbadd-sql \
013-enckey-sql \
015-lockedkey-sql \
017-notoken-sql \
034-perms-sql
endif
if HAVE_DSA
subdirs += \
001-keyiread-dsa \
002-keygen-dsa \
003-csrgen-dsa \
004-selfsign-dsa
endif
if HAVE_EC
subdirs += \
001-keyiread-ec \
002-keygen-ec \
003-csrgen-ec \
004-selfsign-ec
endif
check: all
for required in certutil cmsutil pk12util openssl diff cmp mktemp \
dos2unix unix2dos dbus-launch ; do \
which $$required || exit 1; \
done
env srcdir=$(srcdir) \
builddir=$(top_builddir)/tests \
$(srcdir)/run-tests.sh $(subdirs)
certmonger-0.79.5/tests/tools/ 0000775 0025364 0001750 00000000000 13152316411 013272 5 0000000 0000000 certmonger-0.79.5/tests/tools/submit.c 0000664 0025364 0001750 00000010744 13152316372 014675 0000000 0000000 /*
* Copyright (C) 2009,2011 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/log.h"
#include "../../src/store-int.h"
#include "../../src/store.h"
#include "../../src/submit.h"
#include "../../src/submit-e.h"
#include "../../src/submit-u.h"
#include "tools.h"
static void
wait_to_read(int fd)
{
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
select(fd + 1, &rfds, NULL, NULL, &tv);
}
int
main(int argc, char **argv)
{
struct cm_submit_state *state;
struct cm_store_ca *ca;
struct cm_store_entry *entry;
int fd, ret, i;
void *parent;
char *p;
#ifdef HAVE_UUID
cm_submit_uuid_fixed_for_testing = 1; /* use fixed UUIDs */
#endif
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
cm_set_fips_from_env();
parent = talloc_new(NULL);
if (argc > 2) {
ca = cm_store_files_ca_read(parent, argv[1]);
if (ca == NULL) {
printf("Error reading %s: %s.\n", argv[1],
strerror(errno));
return -1;
}
entry = cm_store_files_entry_read(parent, argv[2]);
if (entry == NULL) {
printf("Error reading %s: %s.\n", argv[2],
strerror(errno));
return -1;
}
} else {
printf("Specify a CA file and an entry file as the two "
"arguments.\n");
return -1;
}
state = cm_submit_start(ca, entry);
if (state != NULL) {
for (;;) {
fd = cm_submit_get_fd(state);
if (fd != -1) {
wait_to_read(fd);
} else {
sleep(1);
}
if (cm_submit_ready(state) == 0) {
break;
}
}
if (cm_submit_issued(state) == 0) {
while (strlen(entry->cm_cert) > 0) {
i = strlen(entry->cm_cert) - 1;
if (entry->cm_cert[i] == '\n') {
entry->cm_cert[i] = '\0';
} else {
break;
}
}
p = talloc_asprintf(entry, "%s\n", entry->cm_cert);
talloc_free(entry->cm_cert);
entry->cm_cert = p;
printf("%s", entry->cm_cert);
ret = CM_SUBMIT_STATUS_ISSUED;
} else
if (cm_submit_save_ca_cookie(state) == 0) {
printf("Certificate not issued, saved a cookie.\n");
ret = CM_SUBMIT_STATUS_WAIT;
} else
if (cm_submit_rejected(state) == 0) {
if (entry->cm_ca_error != NULL) {
printf("Request rejected: %s.\n",
entry->cm_ca_error);
} else {
printf("Request rejected.\n");
}
ret = CM_SUBMIT_STATUS_REJECTED;
} else
if (cm_submit_unreachable(state) == 0) {
if (entry->cm_ca_error != NULL) {
printf("CA was unreachable: %s.\n",
entry->cm_ca_error);
} else {
printf("CA was unreachable.\n");
}
ret = CM_SUBMIT_STATUS_UNREACHABLE;
} else
if (cm_submit_unconfigured(state) == 0) {
if (entry->cm_ca_error != NULL) {
printf("CA helper was un- or "
"under-configured: %s.\n",
entry->cm_ca_error);
} else {
printf("CA helper was un- or "
"under-configured.\n");
}
ret = CM_SUBMIT_STATUS_UNCONFIGURED;
} else
if (cm_submit_need_scep_messages(state) == 0) {
if (entry->cm_ca_error != NULL) {
printf("CA helper needs SCEP "
"messages: %s.\n",
entry->cm_ca_error);
} else {
printf("CA helper needs SCEP "
"messages.\n");
}
ret = CM_SUBMIT_STATUS_NEED_SCEP_MESSAGES;
} else
if (cm_submit_need_rekey(state) == 0) {
if (entry->cm_ca_error != NULL) {
printf("CA helper says we need to "
"rekey: %s.\n",
entry->cm_ca_error);
} else {
printf("CA helper says we need to "
"rekey.\n");
}
ret = CM_SUBMIT_STATUS_NEED_REKEY;
} else {
printf("Can't explain what happened.\n");
ret = -1;
}
cm_submit_done(state);
} else {
printf("Failed to start.\n");
ret = -1;
}
cm_store_entry_save(entry);
cm_store_ca_save(ca);
talloc_free(parent);
return ret;
}
certmonger-0.79.5/tests/tools/srv.c 0000664 0025364 0001750 00000002653 13152316372 014204 0000000 0000000 /*
* Copyright (C) 2014,2015,2017 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#ifdef HAVE_INTTYPES_H
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include "../../src/srvloc.h"
int
main(int argc, char **argv)
{
int i;
struct cm_srvloc *results;
for (i = 2; i < argc; i++) {
if (cm_srvloc_resolve(NULL, argv[i], argv[1], &results) != 0) {
printf("Error resolving \"%s.%s\".\n", argv[i],
argv[1]);
continue;
}
while (results != NULL) {
printf("%s.%s: %s:%d (%d,%d)\n", argv[i], argv[1],
results->host, results->port,
results->priority, results->weight);
results = results->next;
}
}
return 0;
}
certmonger-0.79.5/tests/tools/scepgen.c 0000664 0025364 0001750 00000006747 13152316372 015026 0000000 0000000 /*
* Copyright (C) 2015 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/log.h"
#include "../../src/scepgen.h"
#include "../../src/store.h"
#include "../../src/store-int.h"
#include "../../src/submit-u.h"
#include "tools.h"
static void
wait_to_read(int fd)
{
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
select(fd + 1, &rfds, NULL, NULL, &tv);
}
int
main(int argc, char **argv)
{
struct cm_scepgen_state *state;
struct cm_store_ca *ca;
struct cm_store_entry *entry;
int fd, ret;
void *parent;
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
cm_set_fips_from_env();
parent = talloc_new(NULL);
if (argc > 2) {
ca = cm_store_files_ca_read(parent, argv[1]);
if (ca == NULL) {
printf("Error reading %s: %s.\n", argv[1],
strerror(errno));
return -1;
}
entry = cm_store_files_entry_read(parent, argv[2]);
if (entry == NULL) {
printf("Error reading %s: %s.\n", argv[2],
strerror(errno));
return 1;
}
} else {
printf("Specify a CA file and an entry file as the two "
"arguments.\n");
return 1;
}
state = cm_scepgen_start(ca, entry);
if (state != NULL) {
for (;;) {
fd = cm_scepgen_get_fd(state);
if (fd != -1) {
wait_to_read(fd);
} else {
sleep(1);
}
if (cm_scepgen_ready(state) == 0) {
break;
}
}
if (cm_scepgen_save_scep(state) == 0) {
if (entry->cm_minicert != NULL) {
printf("minicert:%s\n", entry->cm_minicert);
}
if (entry->cm_scep_tx != NULL) {
printf("tx:%s\n", entry->cm_scep_tx);
}
if (entry->cm_scep_nonce != NULL) {
printf("nonce:%s\n", entry->cm_scep_nonce);
}
if (entry->cm_scep_req != NULL) {
printf("req:%s\n",
cm_submit_u_base64_from_text(entry->cm_scep_req));
}
if (entry->cm_scep_gic != NULL) {
printf("gic:%s\n",
cm_submit_u_base64_from_text(entry->cm_scep_gic));
}
if (entry->cm_scep_req_next != NULL) {
printf("req(next):%s\n",
cm_submit_u_base64_from_text(entry->cm_scep_req_next));
}
if (entry->cm_scep_gic_next != NULL) {
printf("gic(next):%s\n",
cm_submit_u_base64_from_text(entry->cm_scep_gic_next));
}
ret = 0;
} else {
printf("Failed to save.\n");
if (cm_scepgen_need_token(state) == 0) {
printf("(Need token.)\n");
} else
if (cm_scepgen_need_pin(state) == 0) {
printf("(Need PIN.)\n");
} else
if (cm_scepgen_need_encryption_certs(state) == 0) {
printf("(Need server certificates.)\n");
}
ret = 1;
}
cm_scepgen_done(state);
} else {
printf("Failed to start.\n");
ret = 1;
}
cm_store_entry_save(entry);
talloc_free(parent);
return ret;
}
certmonger-0.79.5/tests/tools/printenv.c 0000664 0025364 0001750 00000002016 13152316372 015230 0000000 0000000 /*
* Copyright (C) 2015 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
int
main(int argc, char **argv)
{
int i, result = 0;
char *value;
for (i = 1; i < argc; i++) {
value = getenv(argv[i]);
if (value == NULL) {
result = ENOENT;
} else {
printf("%s\n", value);
}
}
return result;
}
certmonger-0.79.5/tests/tools/prefs.c 0000664 0025364 0001750 00000005057 13152316372 014512 0000000 0000000 /*
* Copyright (C) 2010 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include "../../src/prefs.h"
#include "../../src/store-int.h"
int
main(int argc, char **argv)
{
const char *dest;
const time_t *ttls;
unsigned int i, n_ttls;
switch (cm_prefs_preferred_cipher()) {
case cm_prefs_aes128:
printf("cipher: AES128\n");
break;
case cm_prefs_aes256:
printf("cipher: AES256\n");
break;
case cm_prefs_des:
printf("cipher: DES\n");
break;
case cm_prefs_des3:
printf("cipher: DES3\n");
break;
}
switch (cm_prefs_preferred_digest()) {
case cm_prefs_md5:
printf("digest: MD5\n");
break;
case cm_prefs_sha1:
printf("digest: SHA1\n");
break;
case cm_prefs_sha256:
printf("digest: SHA256\n");
break;
case cm_prefs_sha384:
printf("digest: SHA384\n");
break;
case cm_prefs_sha512:
printf("digest: SHA512\n");
break;
}
if (cm_prefs_notify_ttls(&ttls, &n_ttls) == 0) {
printf("notify_ttls: ");
for (i = 0; i < n_ttls; i++) {
printf("%s%llu", ((i > 0) ? ", " : ""),
(unsigned long long) ttls[i]);
}
printf("\n");
}
if (cm_prefs_enroll_ttls(&ttls, &n_ttls) == 0) {
printf("enroll_ttls: ");
for (i = 0; i < n_ttls; i++) {
printf("%s%llu", ((i > 0) ? ", " : ""),
(unsigned long long) ttls[i]);
}
printf("\n");
}
dest = cm_prefs_notification_destination();
switch (cm_prefs_notification_method()) {
case cm_notification_unspecified:
printf("notification: UNSPECIFIED:%s\n", dest);
break;
case cm_notification_none:
printf("notification: NONE\n");
break;
case cm_notification_syslog:
printf("notification: SYSLOG:%s\n", dest);
break;
case cm_notification_email:
printf("notification: MAILTO:%s\n", dest);
break;
case cm_notification_stdout:
printf("notification: STDOUT\n");
break;
case cm_notification_command:
printf("notification: COMMAND:%s\n", dest);
break;
}
return 0;
}
certmonger-0.79.5/tests/tools/pk7verify.c 0000664 0025364 0001750 00000010140 13152316372 015306 0000000 0000000 /*
* Copyright (C) 2015,2017 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#ifdef HAVE_INTTYPES_H
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/log.h"
#include "../../src/pkcs7.h"
#include "../../src/store.h"
#include "../../src/util-o.h"
int
main(int argc, char **argv)
{
struct stat st;
int fd, i, j, root = 0, n_roots = 0, n_others = 0;
ssize_t len;
void *parent;
char **roots, **others, *p, *digest = NULL;
char *tx = NULL, *msgtype = NULL, *pkistatus = NULL, *failinfo = NULL;
unsigned char *snonce = NULL, *rnonce = NULL, *payload = NULL;
size_t snonce_length = 0, rnonce_length = 0, payload_length = 0;
unsigned char *data, buf[BUFSIZ];
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
util_o_init();
ERR_load_crypto_strings();
parent = talloc_new(NULL);
roots = talloc_array_ptrtype(parent, roots, argc);
others = talloc_array_ptrtype(parent, others, argc);
for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-r") == 0) {
root = 1;
continue;
}
fd = open(argv[i], O_RDONLY);
if (fd == -1) {
fprintf(stderr, "Error opening \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
if (fstat(fd, &st) == -1) {
fprintf(stderr, "Error statting \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
p = talloc_size(parent, st.st_size + 1);
if (p == NULL) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
memset(p, '\0', st.st_size + 1);
len = 0;
while (len < st.st_size) {
j = read(fd, p + len, st.st_size - len);
if (j <= 0) {
fprintf(stderr, "Read error on \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
len += j;
}
close(fd);
if (root) {
roots[n_roots++] = p;
root = 0;
} else {
others[n_others++] = p;
}
}
roots[n_roots] = NULL;
others[n_others] = NULL;
len = 0;
data = NULL;
while ((i = read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
data = talloc_realloc_size(parent, data, len + i);
if (data == NULL) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
memcpy(data + len, buf, i);
len += i;
}
if (len == 0) {
fprintf(stderr, "No data to verify.\n");
return 1;
}
i = cm_pkcs7_verify_signed(data, len,
(const char **) roots,
(const char **) others,
NID_pkcs7_data, parent, &digest,
&tx, &msgtype, &pkistatus, &failinfo,
&snonce, &snonce_length,
&rnonce, &rnonce_length,
&payload, &payload_length);
if (i == 0) {
printf("verify passed\n");
} else {
printf("verify failed\n");
}
if (digest != NULL) {
printf("digest:%s\n", digest);
}
if (tx != NULL) {
printf("tx:%s\n", tx);
}
if (msgtype != NULL) {
printf("msgtype:%s\n", msgtype);
}
if (pkistatus != NULL) {
printf("pkistatus:%s\n", pkistatus);
}
if (failinfo != NULL) {
printf("failinfo:%s\n", failinfo);
}
if (snonce != NULL) {
printf("snonce:%s\n", cm_store_base64_from_bin(parent, snonce,
snonce_length));
}
if (rnonce != NULL) {
printf("rnonce:%s\n", cm_store_base64_from_bin(parent, rnonce,
rnonce_length));
}
if (payload != NULL) {
printf("payload:%s\n", cm_store_base64_from_bin(parent, payload,
payload_length));
}
talloc_free(parent);
return i;
}
certmonger-0.79.5/tests/tools/pk7parse.c 0000664 0025364 0001750 00000005207 13152316372 015124 0000000 0000000 /*
* Copyright (C) 2014 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/log.h"
#include "../../src/pkcs7.h"
int
main(int argc, char **argv)
{
struct stat st;
int fd, i, j, n_buffers = 0;
ssize_t len;
void *parent;
unsigned char *p;
const unsigned char **buffers;
size_t *lengths;
char *label, *leaf, *top, **certs;
parent = talloc_new(NULL);
buffers = talloc_array_ptrtype(parent, buffers, argc);
lengths = talloc_array_ptrtype(parent, lengths, argc);
label = "";
for (i = 1; i < argc; i++) {
fd = open(argv[i], O_RDONLY);
if (fd == -1) {
fprintf(stderr, "Error opening \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
if (fstat(fd, &st) == -1) {
fprintf(stderr, "Error statting \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
p = talloc_size(buffers, st.st_size);
if (p == NULL) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
memset(p, 0, st.st_size);
len = 0;
while (len < st.st_size) {
j = read(fd, p + len, st.st_size - len);
if (j <= 0) {
fprintf(stderr, "Read error on \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
len += j;
}
close(fd);
buffers[n_buffers] = p;
lengths[n_buffers] = st.st_size;
if (n_buffers > 0) {
label = talloc_asprintf_append(label, ",%s", argv[i]);
} else {
label = talloc_strdup(parent, argv[i]);
}
n_buffers++;
}
if (cm_pkcs7_parsev(CM_PKCS7_LEAF_PREFER_ENCRYPT,
parent, &leaf, &top, &certs,
NULL, NULL,
n_buffers, buffers, lengths) != 0) {
fprintf(stderr, "\"%s\": parse error.\n", argv[i]);
return 1;
}
printf("[%s]\nTOP:\n%sLEAF:\n%s", label,
top ? top : "", leaf ? leaf : "");
for (i = 0; (certs != NULL) && (certs[i] != NULL); i++) {
printf("%d:\n%s", i + 1, certs[i]);
}
talloc_free(parent);
return 0;
}
certmonger-0.79.5/tests/tools/pk7env.c 0000664 0025364 0001750 00000011013 13152316372 014572 0000000 0000000 /*
* Copyright (C) 2014 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/log.h"
#include "../../src/pkcs7.h"
#include "../../src/store.h"
#define CSR1 "-----BEGIN CERTIFICATE REQUEST-----"
#define CSR2 "-----BEGIN NEW CERTIFICATE REQUEST-----"
#define CERT "-----BEGIN CERTIFICATE-----"
int
main(int argc, char **argv)
{
struct stat st;
int fd, i, j;
ssize_t len;
size_t length;
void *parent;
char *p[3];
unsigned char *enveloped;
parent = talloc_new(NULL);
i = 1;
while (i < argc) {
fd = open(argv[i], O_RDONLY);
if (fd == -1) {
fprintf(stderr, "Error opening \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
if (fstat(fd, &st) == -1) {
fprintf(stderr, "Error statting \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
p[0] = talloc_size(parent, st.st_size + 1);
if (p[0] == NULL) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
memset(p[0], 0, st.st_size + 1);
len = 0;
while (len < st.st_size) {
j = read(fd, p[0] + len, st.st_size - len);
if (j <= 0) {
fprintf(stderr, "Read error on \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
len += j;
}
close(fd);
i++;
if (i >= argc) {
return 1;
}
fd = open(argv[i], O_RDONLY);
if (fd == -1) {
fprintf(stderr, "Error opening \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
if (fstat(fd, &st) == -1) {
fprintf(stderr, "Error statting \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
p[1] = talloc_size(parent, st.st_size + 1);
if (p[1] == NULL) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
memset(p[1], 0, st.st_size + 1);
len = 0;
while (len < st.st_size) {
j = read(fd, p[1] + len, st.st_size - len);
if (j <= 0) {
fprintf(stderr, "Read error on \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
len += j;
}
close(fd);
i++;
if ((strncmp(p[1], CSR1, strlen(CSR1)) == 0) ||
(strncmp(p[1], CSR2, strlen(CSR2)) == 0)) {
if (cm_pkcs7_envelope_csr(p[0], cm_prefs_des3, p[1],
&enveloped, &length) != 0) {
fprintf(stderr, "\"%s\"(\"%s\"): enveloping error.\n",
argv[i - 2], argv[i - 1]);
return 1;
}
printf("%s\n", cm_store_base64_from_bin(NULL, enveloped, length));
free(enveloped);
continue;
}
if (i >= argc) {
return 1;
}
fd = open(argv[i], O_RDONLY);
if (fd == -1) {
fprintf(stderr, "Error opening \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
if (fstat(fd, &st) == -1) {
fprintf(stderr, "Error statting \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
p[2] = talloc_size(parent, st.st_size + 1);
if (p[2] == NULL) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
memset(p[2], 0, st.st_size + 1);
len = 0;
while (len < st.st_size) {
j = read(fd, p[2] + len, st.st_size - len);
if (j <= 0) {
fprintf(stderr, "Read error on \"%s\": %s.\n",
argv[i], strerror(errno));
return 1;
}
len += j;
}
close(fd);
i++;
if ((strncmp(p[1], CERT, strlen(CERT)) == 0) &&
(strncmp(p[2], CERT, strlen(CERT)) == 0)) {
if (cm_pkcs7_generate_ias(p[1], p[2], &enveloped, &length) != 0) {
fprintf(stderr, "\"%s\",\"%s\": generating error.\n",
argv[i - 2], argv[i - 1]);
return 1;
}
printf("%s\n", cm_store_base64_from_bin(NULL, enveloped, length));
free(enveloped);
if (cm_pkcs7_envelope_ias(p[0], cm_prefs_des3, p[1],
p[2], &enveloped, &length) != 0) {
fprintf(stderr, "\"%s\"(\"%s\",\"%s\"): enveloping error.\n",
argv[i - 3], argv[i - 2], argv[i - 1]);
return 1;
}
printf("%s\n", cm_store_base64_from_bin(NULL, enveloped, length));
free(enveloped);
continue;
}
}
return 0;
}
certmonger-0.79.5/tests/tools/pk7decrypt.c 0000664 0025364 0001750 00000005603 13152316372 015464 0000000 0000000 /*
* Copyright (C) 2015,2017 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#ifdef HAVE_INTTYPES_H
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/log.h"
#include "../../src/pkcs7.h"
#include "../../src/store.h"
#include "../../src/store-int.h"
#include "../../src/submit-int.h"
#include "../../src/util-o.h"
int
main(int argc, char **argv)
{
unsigned char *payload = NULL, *data, buf[BUFSIZ];
size_t payload_length = 0;
struct cm_submit_decrypt_envelope_args args;
void *parent;
ssize_t len;
int i;
void (*decrypt)(const unsigned char *envelope, size_t length,
void *decrypt_userdata,
unsigned char **payload, size_t *payload_length) = NULL;
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
parent = talloc_new(NULL);
if (argc < 2) {
fprintf(stderr, "Name of entry file required.\n");
return 1;
}
memset(&args, 0, sizeof(args));
args.entry = cm_store_files_entry_read(parent, argv[1]);
if (args.entry == NULL) {
fprintf(stderr, "Error reading entry from \"%s\".\n", argv[1]);
return 1;
}
len = 0;
data = NULL;
while ((i = read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
data = talloc_realloc_size(parent, data, len + i);
if (data == NULL) {
fprintf(stderr, "Out of memory.\n");
return 1;
}
memcpy(data + len, buf, i);
len += i;
}
if (len == 0) {
fprintf(stderr, "No data to verify.\n");
return 1;
}
switch (args.entry->cm_key_storage_type) {
case cm_key_storage_none:
break;
case cm_key_storage_nssdb:
decrypt = cm_submit_n_decrypt_envelope;
break;
case cm_key_storage_file:
decrypt = cm_submit_o_decrypt_envelope;
break;
}
if (decrypt != NULL) {
(*decrypt)(data, len, &args, &payload, &payload_length);
}
if ((payload != NULL) && (payload_length > 0)) {
printf("payload:%s\n", cm_store_base64_from_bin(parent, payload,
payload_length));
} else {
printf("decrypt error\n");
}
talloc_free(parent);
return ((payload != NULL) && (payload_length > 0)) ? 0 : 1;
}
certmonger-0.79.5/tests/tools/pem2base.c 0000664 0025364 0001750 00000002357 13152316372 015071 0000000 0000000 /*
* Copyright (C) 2011 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include "../../src/submit-u.h"
int
main(int argc, char **argv)
{
char buf[LINE_MAX], *p = NULL, *q;
while (fgets(buf, sizeof(buf), stdin) != NULL) {
if (p == NULL) {
p = strdup(buf);
} else {
q = malloc(strlen(p) + strlen(buf) + 1);
if (q != NULL) {
stpcpy(stpcpy(q, p), buf);
free(p);
p = q;
}
}
}
printf("%s\n", cm_submit_u_base64_from_text(p));
return 0;
}
certmonger-0.79.5/tests/tools/payload.c 0000664 0025364 0001750 00000003726 13152316372 015025 0000000 0000000 /*
* Copyright (C) 2014 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/log.h"
#include "../../src/store.h"
#include "../../src/store-int.h"
int
main(int argc, char **argv)
{
int i;
unsigned int len;
unsigned char *p, *q, buf[LINE_MAX];
SECItem encoded;
CERTSignedData signed_data;
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
p = NULL;
len = 0;
while ((i = read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
q = realloc(p, len + i);
if (q == NULL) {
perror("malloc");
free(p);
return 1;
}
p = q;
memcpy(p + len, buf, i);
len += i;
}
memset(&encoded, 0, sizeof(encoded));
encoded.data = p;
encoded.len = len;
memset(&signed_data, 0, sizeof(signed_data));
if (SEC_ASN1DecodeItem(NULL, &signed_data,
CERT_SignedDataTemplate,
&encoded) == SECSuccess) {
len = 0;
while (len < signed_data.data.len) {
i = write(STDOUT_FILENO,
signed_data.data.data + len,
signed_data.data.len - len);
if (i <= 0) {
perror("write");
return 1;
}
len += i;
}
}
return 0;
}
certmonger-0.79.5/tests/tools/oid2name.c 0000664 0025364 0001750 00000002132 13152316372 015060 0000000 0000000 /*
* Copyright (C) 2009 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include "../../src/log.h"
#include "../../src/oiddict.h"
int
main(int argc, char **argv)
{
int i;
const char *name;
void *parent;
parent = talloc_new(NULL);
for (i = 1; i < argc; i++) {
name = cm_oid_to_name(parent, argv[i]);
if (name != NULL) {
printf("%s\n", name);
} else {
return 1;
}
}
talloc_free(parent);
return 0;
}
certmonger-0.79.5/tests/tools/name2oid.c 0000664 0025364 0001750 00000002130 13152316372 015056 0000000 0000000 /*
* Copyright (C) 2009 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include "../../src/log.h"
#include "../../src/oiddict.h"
int
main(int argc, char **argv)
{
int i;
const char *oid;
void *parent;
parent = talloc_new(NULL);
for (i = 1; i < argc; i++) {
oid = cm_oid_from_name(parent, argv[i]);
if (oid != NULL) {
printf("%s\n", oid);
} else {
return 1;
}
}
talloc_free(parent);
return 0;
}
certmonger-0.79.5/tests/tools/ls.c 0000664 0025364 0001750 00000003600 13152316372 014001 0000000 0000000 /*
* Copyright (C) 2015 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/log.h"
const char *
uidname(uid_t uid)
{
static struct passwd *pwd;
static char name[LINE_MAX];
if ((pwd != NULL) && (pwd->pw_uid == uid)) {
return pwd->pw_name;
}
pwd = getpwuid(uid);
if ((pwd != NULL) && (pwd->pw_uid == uid)) {
return pwd->pw_name;
}
snprintf(name, sizeof(name), "%lu", (unsigned long) uid);
return name;
}
const char *
gidname(gid_t gid)
{
static struct group *grp;
static char name[LINE_MAX];
if ((grp != NULL) && (grp->gr_gid == gid)) {
return grp->gr_name;
}
grp = getgrgid(gid);
if ((grp != NULL) && (grp->gr_gid == gid)) {
return grp->gr_name;
}
snprintf(name, sizeof(name), "%lu", (unsigned long) gid);
return name;
}
int
main(int argc, char **argv)
{
struct stat st;
int i;
for (i = 1; i < argc; i++) {
if (stat(argv[i], &st) == -1) {
fprintf(stderr, "stat(%s): %s\n", argv[i],
strerror(errno));
} else {
printf("%s:%s|%04o|%s\n",
uidname(st.st_uid), gidname(st.st_gid),
st.st_mode & 07777, argv[i]);
}
}
return 0;
}
certmonger-0.79.5/tests/tools/listnicks.c 0000664 0025364 0001750 00000004553 13152316372 015376 0000000 0000000 /*
* Copyright (C) 2011 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/log.h"
#include "../../src/store.h"
#include "../../src/store-int.h"
int
main(int argc, char **argv)
{
struct cm_store_entry *entry;
int i;
void *parent;
CERTCertList *certlist;
CERTCertListNode *node;
SECStatus error;
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
parent = talloc_new(NULL);
if (argc > 1) {
entry = cm_store_files_entry_read(parent, argv[1]);
if (entry == NULL) {
printf("Error reading %s: %s.\n", argv[1],
strerror(errno));
return 1;
}
} else {
printf("Specify an entry file as the single argument.\n");
return 1;
}
if (entry->cm_cert_storage_type != cm_cert_storage_nssdb) {
cm_log(1, "Storage type is not NSSDB.\n");
return 1;
}
/* Open the database. */
error = NSS_Init(entry->cm_cert_storage_location);
if (error != SECSuccess) {
cm_log(1, "Unable to open NSS database.\n");
_exit(1);
}
/* Walk the list of names, if we got one. */
certlist = PK11_ListCerts(PK11CertListAll, NULL);
if (certlist != NULL) {
/* Delete the existing cert. */
i = 0;
for (node = CERT_LIST_HEAD(certlist);
!CERT_LIST_EMPTY(certlist) &&
!CERT_LIST_END(node, certlist);
node = CERT_LIST_NEXT(node)) {
printf("%d: \"%s\"\n", ++i, node->cert->nickname);
}
CERT_DestroyCertList(certlist);
}
talloc_free(parent);
if (NSS_Shutdown() != SECSuccess) {
cm_log(1, "Error shutting down NSS.\n");
}
return 0;
}
certmonger-0.79.5/tests/tools/libexecdir.c 0000664 0025364 0001750 00000001500 13152316372 015472 0000000 0000000 /*
* Copyright (C) 2014 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
int
main(int argc, char **argv)
{
printf("%s\n", CM_DEFAULT_HELPER_PATH);
return 0;
}
certmonger-0.79.5/tests/tools/keyiread.c 0000664 0025364 0001750 00000013577 13152316372 015176 0000000 0000000 /*
* Copyright (C) 2009,2011,2014,2015 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/keyiread.h"
#include "../../src/log.h"
#include "../../src/store.h"
#include "../../src/store-int.h"
#include "tools.h"
static void
wait_to_read(int fd)
{
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
select(fd + 1, &rfds, NULL, NULL, &tv);
}
static const char *
type_name(enum cm_key_algorithm alg)
{
switch (alg) {
case cm_key_rsa:
return "RSA";
break;
#ifdef CM_ENABLE_DSA
case cm_key_dsa:
return "DSA";
break;
#endif
#ifdef CM_ENABLE_EC
case cm_key_ecdsa:
return "EC";
break;
#endif
default:
assert(0);
break;
}
return NULL;
}
static void
munge_key_size(struct cm_key_type *key)
{
switch (key->cm_key_algorithm) {
case cm_key_rsa:
break;
#ifdef CM_ENABLE_DSA
case cm_key_dsa:
key->cm_key_size = howmany(key->cm_key_size, 8) * 8;
break;
#endif
#ifdef CM_ENABLE_EC
case cm_key_ecdsa:
break;
#endif
default:
assert(0);
break;
}
}
int
main(int argc, const char **argv)
{
struct cm_keyiread_state *state;
struct cm_store_entry *entry;
int fd, ret, need_pin, summary = 0, minimum = -1, i;
void *parent;
const char *filename;
poptContext pctx;
struct poptOption popts[] = {
{"summary", 's', POPT_ARG_NONE, &summary, 0, NULL, NULL},
{"minimum", 'm', POPT_ARG_INT, &minimum, 0, NULL, NULL},
POPT_AUTOHELP
POPT_TABLEEND
};
pctx = poptGetContext("keyiread", argc, argv, popts, 0);
while ((i = poptGetNextOpt(pctx)) > 0) {
continue;
}
if (i != -1) {
poptPrintUsage(pctx, stdout, 0);
return 1;
}
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
cm_set_fips_from_env();
parent = talloc_new(NULL);
if (poptPeekArg(pctx) != NULL) {
filename = poptGetArg(pctx);
entry = cm_store_files_entry_read(parent, filename);
if (entry == NULL) {
printf("Error reading %s: %s.\n", filename,
strerror(errno));
return 1;
}
} else {
printf("Specify an entry file as the single argument.\n");
return 1;
}
entry->cm_key_type.cm_key_size = 0;
state = cm_keyiread_start(entry);
if (state != NULL) {
for (;;) {
fd = cm_keyiread_get_fd(state);
if (fd != -1) {
wait_to_read(fd);
} else {
sleep(1);
}
if (cm_keyiread_ready(state) == 0) {
break;
}
}
need_pin = cm_keyiread_need_pin(state);
cm_keyiread_done(state);
if (entry->cm_key_type.cm_key_size != 0) {
munge_key_size(&entry->cm_key_type);
if (entry->cm_key_next_type.cm_key_size != 0) {
munge_key_size(&entry->cm_key_next_type);
if (summary) {
if (minimum > 0) {
if ((entry->cm_key_next_type.cm_key_size >= minimum * 0.9) &&
(entry->cm_key_type.cm_key_size >= minimum * 0.9)) {
printf("OK (%s >= ~%d after %s >= ~%d).\n",
type_name(entry->cm_key_next_type.cm_key_algorithm),
minimum,
type_name(entry->cm_key_type.cm_key_algorithm),
minimum);
} else {
printf("NOT OK (%s:%d < %d after %s:%d < %d).\n",
type_name(entry->cm_key_next_type.cm_key_algorithm),
entry->cm_key_next_type.cm_key_size, minimum,
type_name(entry->cm_key_type.cm_key_algorithm),
entry->cm_key_type.cm_key_size, minimum);
}
} else {
printf("OK (%s after %s).\n",
type_name(entry->cm_key_next_type.cm_key_algorithm),
type_name(entry->cm_key_type.cm_key_algorithm));
}
} else {
printf("OK (%s:%d after %s:%d).\n",
type_name(entry->cm_key_next_type.cm_key_algorithm),
entry->cm_key_next_type.cm_key_size,
type_name(entry->cm_key_type.cm_key_algorithm),
entry->cm_key_type.cm_key_size);
}
} else {
if (summary) {
if (minimum > 0) {
if (entry->cm_key_type.cm_key_size >= minimum * 0.9) {
printf("OK (%s >= ~%d).\n",
type_name(entry->cm_key_type.cm_key_algorithm),
minimum);
} else {
printf("NOT OK (%s:%d < %d).\n",
type_name(entry->cm_key_type.cm_key_algorithm),
entry->cm_key_type.cm_key_size, minimum);
}
} else {
printf("OK (%s).\n",
type_name(entry->cm_key_type.cm_key_algorithm));
}
} else {
printf("OK (%s:%d).\n",
type_name(entry->cm_key_type.cm_key_algorithm),
entry->cm_key_type.cm_key_size);
}
}
ret = 0;
} else {
switch (entry->cm_key_storage_type) {
case cm_key_storage_none:
printf("No key to read.\n");
break;
case cm_key_storage_file:
printf("Failed to read key \"%s\".\n",
entry->cm_key_storage_location);
break;
case cm_key_storage_nssdb:
printf("Failed to read key \"%s\":\"%s\".\n",
entry->cm_key_storage_location,
entry->cm_key_nickname);
break;
}
if (need_pin == 0) {
printf("(Need PIN.)\n");
}
ret = 1;
}
} else {
printf("Failed to start.\n");
ret = 1;
}
cm_store_entry_save(entry);
talloc_free(parent);
return ret;
}
certmonger-0.79.5/tests/tools/keygen.c 0000664 0025364 0001750 00000005676 13152316372 014664 0000000 0000000 /*
* Copyright (C) 2009,2011 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/keygen.h"
#include "../../src/log.h"
#include "../../src/store.h"
#include "../../src/store-int.h"
static void
wait_to_read(int fd)
{
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
select(fd + 1, &rfds, NULL, NULL, &tv);
}
int
main(int argc, char **argv)
{
struct cm_keygen_state *state;
struct cm_store_entry *entry;
int fd, ret;
void *parent;
const char *ktype = "UNKNOWN";
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
parent = talloc_new(NULL);
if (argc > 1) {
entry = cm_store_files_entry_read(parent, argv[1]);
if (entry == NULL) {
printf("Error reading %s: %s.\n", argv[1],
strerror(errno));
return 1;
}
} else {
printf("Specify an entry file as the single argument.\n");
return 1;
}
state = cm_keygen_start(entry);
if (state != NULL) {
for (;;) {
fd = cm_keygen_get_fd(state);
if (fd != -1) {
wait_to_read(fd);
} else {
sleep(1);
}
if (cm_keygen_ready(state) == 0) {
break;
}
}
switch (entry->cm_key_storage_type) {
case cm_key_storage_none:
ktype = "NONE";
break;
case cm_key_storage_file:
ktype = "FILE";
break;
case cm_key_storage_nssdb:
ktype = "NSS";
break;
}
if (cm_keygen_saved_keypair(state) == 0) {
printf("OK.\n");
ret = 0;
} else if (cm_keygen_need_pin(state) == 0) {
printf("Failed to save %s:%s: need PIN.\n",
ktype, entry->cm_key_storage_location);
ret = 1;
} else if (cm_keygen_need_token(state) == 0) {
printf("Failed to save %s:%s: token not present.\n",
ktype, entry->cm_key_storage_location);
ret = 1;
} else if (cm_keygen_need_perms(state) == 0) {
printf("Failed to save %s:%s: need fs permissions.\n",
ktype, entry->cm_key_storage_location);
ret = 1;
} else {
printf("Failed to save %s:%s, don't know why.\n",
ktype, entry->cm_key_storage_location);
ret = 1;
}
cm_keygen_done(state);
} else {
printf("Failed to start.\n");
ret = 1;
}
cm_store_entry_save(entry);
talloc_free(parent);
return ret;
}
certmonger-0.79.5/tests/tools/json-utf8.c 0000664 0025364 0001750 00000005472 13152316372 015231 0000000 0000000 /*
* Copyright (C) 2015,2017 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#ifdef HAVE_INTTYPES_H
#include
#endif
#include
#include
#include
#include
#include
#include "../../src/json.h"
int
main(int argc, char **argv)
{
uint32_t point, point2;
char buf[7];
int n, o;
for (point = 0; point < 0x5000000; point++) {
if ((point >= 0xd800) && (point <= 0xdfff)) {
continue;
}
n = cm_json_point_to_utf8_length(point);
switch (n) {
case 1:
if (point > 0x7f) {
fprintf(stderr, "error at point %lu: %d\n",
(unsigned long) point, n);
return n;
}
break;
case 2:
if ((point < 0x80) || (point > 0x7ff)) {
fprintf(stderr, "error at point %lu: %d\n",
(unsigned long) point, n);
return n;
}
break;
case 3:
if ((point < 0x800) || (point > 0xffff)) {
fprintf(stderr, "error at point %lu: %d\n",
(unsigned long) point, n);
return n;
}
break;
case 4:
if ((point < 0x10000) || (point > 0x1fffff)) {
fprintf(stderr, "error at point %lu: %d\n",
(unsigned long) point, n);
return n;
}
break;
case 5:
if ((point < 0x200000) || (point > 0x3ffffff)) {
fprintf(stderr, "error at point %lu: %d\n",
(unsigned long) point, n);
return n;
}
break;
case 6:
if ((point < 0x4000000) || (point > 0x7fffffff)) {
fprintf(stderr, "error at point %lu: %d\n",
(unsigned long) point, n);
return n;
}
break;
default:
fprintf(stderr, "error at point %lu: %d\n",
(unsigned long) point, n);
return 7;
break;
}
memset(buf, '\0', sizeof(buf));
o = cm_json_point_to_utf8(point, buf, sizeof(buf));
if (o != n) {
fprintf(stderr, "error at encoding of %lu: %d\n",
(unsigned long) point, o);
return 8;
}
o = cm_json_utf8_to_point(buf, &point2);
if (o != n) {
fprintf(stderr, "error at decoding of %s (%lu): %d\n",
buf, (unsigned long) point, o);
return 8;
}
if (point2 != point) {
fprintf(stderr, "decode mismatch: expected \"%s\" to be %lu, got %lu\n",
buf, (unsigned long) point, (unsigned long) point2);
return 9;
}
}
return 0;
}
certmonger-0.79.5/tests/tools/json.c 0000664 0025364 0001750 00000010745 13152316372 014344 0000000 0000000 /*
* Copyright (C) 2015,2017 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#ifdef HAVE_INTTYPES_H
#include
#endif
#include
#include
#include
#include
#include
#include
#include
#include "../../src/json.h"
int
main(int argc, const char **argv)
{
struct stat st;
char *e, *e2, *e3, *e4, *path = NULL;
const char *left, *filename;
struct cm_json *j, *j2, *j3;
void *parent;
int i, n, r, fd, ret = 0, quiet = 0;
poptContext pctx;
struct poptOption popts[] = {
{"quiet", 'q', POPT_ARG_NONE, &quiet, 0, NULL, NULL},
{"path", 'p', POPT_ARG_STRING, &path, 0, NULL, NULL},
POPT_AUTOHELP
POPT_TABLEEND
};
parent = talloc_new(NULL);
pctx = poptGetContext("json", argc, argv, popts, 0);
while ((i = poptGetNextOpt(pctx)) > 0) {
continue;
}
if (i != -1) {
poptPrintUsage(pctx, stdout, 0);
return 1;
}
while ((filename = poptGetArg(pctx)) != NULL) {
fd = open(filename, O_RDONLY);
if (fd == -1) {
ret = errno;
fprintf(stderr, "open(\"%s\"): %s\n", filename,
strerror(errno));
continue;
}
if (fstat(fd, &st) == -1) {
ret = errno;
fprintf(stderr, "stat(\"%s\"): %s\n", filename,
strerror(errno));
continue;
}
e = talloc_size(parent, st.st_size);
if (e == NULL) {
ret = errno;
fprintf(stderr, "malloc(): %s\n", strerror(errno));
continue;
}
r = 0;
while (r < st.st_size) {
n = read(fd, e + r, st.st_size - r);
if (n <= 0) {
ret = errno;
break;
}
r += n;
}
if (r < st.st_size) {
fprintf(stderr, "read(): %s\n", strerror(errno));
close(fd);
break;
}
close(fd);
i = cm_json_decode(parent, e, st.st_size, &j, &left);
if (i != 0) {
ret = -1;
fprintf(stderr, "decode(\"%.*s\"): %s\n",
(int) (st.st_size - (left - e)),
left, cm_json_decode_strerror(i));
continue;
}
if (left - e != st.st_size) {
if (left - e < st.st_size) {
fprintf(stderr, "decode(%.*s) has %lld bytes leftover:\n%.*s\n",
(int) st.st_size, filename,
(long long) (st.st_size - (left - e)),
(int) (st.st_size - (left - e)),
left);
} else {
fprintf(stderr, "decode(%.*s) overran by %lld\n",
(int) st.st_size, filename,
(long long) (left - e - st.st_size));
}
ret = -1;
continue;
}
e2 = cm_json_encode(parent, j);
if (e2 == NULL) {
ret = -1;
fprintf(stderr, "encode(1) failed\n");
continue;
}
i = cm_json_decode(parent, e2, -1, &j2, &left);
if (i != 0) {
ret = -1;
fprintf(stderr, "decode(\"%s\"): %s\n", left,
cm_json_decode_strerror(i));
continue;
}
st.st_size = strlen(e2);
if (left - e2 != st.st_size) {
ret = -1;
if (left - e2 < st.st_size) {
fprintf(stderr, "decode() has %lld bytes leftover:\n%s\n",
(long long) (st.st_size - (left - e2)), left);
} else {
fprintf(stderr, "decode() overran by %lld\n",
(long long) (left - e2 - st.st_size));
}
continue;
}
e3 = cm_json_encode(parent, j2);
if (e3 == NULL) {
ret = -1;
fprintf(stderr, "encode(2) failed\n");
continue;
}
if (strcmp(e2, e3) != 0) {
ret = -1;
fprintf(stderr, "encode() round-trip failed: \"%s\" != \"%s\"\n",
e2, e3);
continue;
}
if (path != NULL) {
j3 = cm_json_find(j2, path);
if (j3 == NULL) {
ret = -1;
fprintf(stderr, "unable to find \"%s\"\n", path);
continue;
}
e4 = cm_json_encode(parent, j3);
if (e4 == NULL) {
ret = -1;
fprintf(stderr, "encode(3) failed\n");
continue;
}
} else {
j3 = NULL;
e4 = NULL;
}
if (!quiet) {
if (strchr(filename, '/') != NULL) {
filename = strrchr(filename, '/') + 1;
}
if (path != NULL) {
printf("[%s]\n%s\n", filename, e4);
} else {
printf("[%s]\n%s\n", filename, e3);
}
}
}
talloc_free(parent);
return ret;
}
certmonger-0.79.5/tests/tools/iterate.c 0000664 0025364 0001750 00000014747 13152316372 015036 0000000 0000000 /*
* Copyright (C) 2009,2010,2011,2012,2013,2014 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/iterate.h"
#include "../../src/log.h"
#include "../../src/store.h"
#include "../../src/store-int.h"
#include "tools.h"
static void
wait_to_read(int fd)
{
fd_set rfds;
struct timeval tv;
if (fd >= 0) {
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
select(fd + 1, &rfds, NULL, NULL, &tv);
} else {
sleep(1);
}
}
struct cm_context {
struct cm_store_ca *ca;
struct cm_store_entry *entry;
};
static struct cm_store_ca *
get_ca_by_index(struct cm_context *cm, int i)
{
if (i == 0) {
return cm->ca;
} else {
return NULL;
}
}
static int
get_n_cas(struct cm_context *cm)
{
return (cm->ca != NULL) ? 1 : 0;
}
static struct cm_store_entry *
get_entry_by_index(struct cm_context *cm, int i)
{
if (i == 0) {
return cm->entry;
} else {
return NULL;
}
}
static int
get_n_entries(struct cm_context *cm)
{
return (cm->entry != NULL) ? 1 : 0;
}
int
main(int argc, char **argv)
{
struct cm_context *cm;
enum cm_state old_state;
int readfd, delay;
void *parent, *istate;
char *p, *q, *continue_states, *stop_states, *tmp;
const char *state;
enum cm_time when;
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
cm_set_fips_from_env();
parent = talloc_new(NULL);
cm = talloc_ptrtype(parent, cm);
if (cm == NULL) {
return 1;
}
memset(cm, 0, sizeof(*cm));
if (argc > 3) {
cm->ca = cm_store_files_ca_read(parent, argv[1]);
if (cm->ca == NULL) {
printf("Error reading %s: %s.\n", argv[1],
strerror(errno));
return 1;
}
cm->entry = cm_store_files_entry_read(parent, argv[2]);
if (cm->entry == NULL) {
printf("Error reading %s: %s.\n", argv[2],
strerror(errno));
return 1;
}
if ((cm->entry->cm_ca_nickname == NULL) ||
(cm->ca->cm_nickname == NULL) ||
(strcasecmp(cm->entry->cm_ca_nickname,
cm->ca->cm_nickname) != 0)) {
talloc_free(cm->ca);
cm->ca = NULL;
}
continue_states = argv[3];
stop_states = NULL;
if ((argc > 4) && (strlen(argv[4]) > 0)) {
stop_states = argv[4];
if (strlen(continue_states) == 0) {
continue_states = NULL;
}
}
} else {
printf("Specify a CA file and an entry file as the first "
"two arguments, a list of continue states as the "
"third, and perhaps a list of stop states as the "
"fourth.\n");
return 1;
}
old_state = cm->entry->cm_state;
state = cm_store_state_as_string(cm->entry->cm_state);
if (cm_iterate_entry_init(cm->entry, &istate) != 0) {
printf("Error initializing.\n");
return 1;
}
if (old_state != cm->entry->cm_state) {
printf("%s\n-(RESET)-\n", state);
}
old_state = CM_INVALID;
state = cm_store_state_as_string(cm->entry->cm_state);
printf("%s\n-START-\n", state);
fflush(NULL);
while (cm_iterate_entry(cm->entry, cm->ca, cm,
get_ca_by_index, get_n_cas,
get_entry_by_index, get_n_entries,
NULL, NULL,
istate, &when, &delay, &readfd) == 0) {
state = cm_store_state_as_string(cm->entry->cm_state);
switch (when) {
case cm_time_now:
if (cm->entry->cm_state != old_state) {
printf("%s\n", state);
} else {
printf("%s (now)\n", state);
}
break;
case cm_time_soon:
if (cm->entry->cm_state != old_state) {
printf("%s\n", state);
} else {
printf("%s (soon)\n", state);
}
break;
case cm_time_soonish:
if (cm->entry->cm_state != old_state) {
printf("%s\n", state);
} else {
printf("%s (soonish)\n", state);
}
break;
case cm_time_delay:
if (cm->entry->cm_state != old_state) {
printf("delay=%ld\n%s\n", (long) delay,
state);
} else {
printf("delay=%ld (again)\n%s (again)\n",
(long) delay, state);
}
break;
case cm_time_no_time:
if (cm->entry->cm_state != old_state) {
printf("%s\n", state);
}
break;
}
if ((cm->entry->cm_state == old_state) &&
((when != cm_time_no_time) || (readfd == -1))) {
/* If we didn't change state, stop. */
printf("-STUCK- (%d:%ld)\n", when, (long) delay);
fflush(NULL);
state = NULL;
break;
}
if (stop_states != NULL) {
/* Check if this state is in our stop-states list. */
for (p = stop_states;
*p != '\0';
p = q + strspn(q, ",")) {
q = p + strcspn(p, ",");
tmp = talloc_strndup(parent, p, q - p);
if (cm->entry->cm_state ==
cm_store_state_from_string(tmp)) {
fflush(NULL);
talloc_free(tmp);
break;
}
talloc_free(tmp);
}
if (*p != '\0') {
/* We found a match. Stop here. */
printf("-STOP-\n");
fflush(NULL);
state = NULL;
break;
}
}
/* Check if this state is in our continue-states list. */
if (continue_states != NULL) {
for (p = continue_states;
*p != '\0';
p = q + strspn(q, ",")) {
q = p + strcspn(p, ",");
tmp = talloc_strndup(parent, p, q - p);
if (cm->entry->cm_state ==
cm_store_state_from_string(tmp)) {
fflush(NULL);
talloc_free(tmp);
break;
}
talloc_free(tmp);
}
/* If we didn't find a match, stop here. */
if (*p == '\0') {
printf("-STOP-\n");
fflush(NULL);
state = NULL;
break;
}
}
/* Wait. */
switch (when) {
case cm_time_now:
break;
case cm_time_soon:
sleep(CM_DELAY_SOON);
break;
case cm_time_soonish:
sleep(CM_DELAY_SOONISH);
break;
case cm_time_delay:
sleep(delay);
break;
case cm_time_no_time:
wait_to_read(readfd);
break;
}
state = cm_store_state_as_string(cm->entry->cm_state);
old_state = cm->entry->cm_state;
}
if (state != NULL) {
printf("-ERROR-\n");
fflush(NULL);
}
cm_iterate_entry_done(cm->entry, istate);
talloc_free(parent);
return 0;
}
certmonger-0.79.5/tests/tools/hooks.c 0000664 0025364 0001750 00000013407 13152316372 014514 0000000 0000000 /*
* Copyright (C) 2014,2015 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/hook.h"
#include "../../src/log.h"
#include "../../src/store-int.h"
#include "../../src/store.h"
#include "tools.h"
static void
wait_to_read(int fd)
{
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
select(fd + 1, &rfds, NULL, NULL, &tv);
}
static struct cm_store_ca **ca;
static struct cm_store_entry **entry;
static int n_cas, n_entries;
static int
get_n_cas(struct cm_context *ctx)
{
return n_cas;
}
static struct cm_store_ca *
get_ca_by_index(struct cm_context *ctx, int n)
{
return ca[n];
}
static int
get_n_entries(struct cm_context *ctx)
{
return n_entries;
}
static struct cm_store_entry *
get_entry_by_index(struct cm_context *ctx, int n)
{
return entry[n];
}
int
main(int argc, const char **argv)
{
struct cm_hook_state *state;
struct cm_store_ca *tmpca, **tmpcas;
struct cm_store_entry *tmpentry, **tmpentries;
int fd, i, c, verbose = 0;
void *parent;
const char *name;
poptContext pctx;
struct poptOption popts[] = {
{"ca", 'c', POPT_ARG_STRING, NULL, 'c', NULL, "FILENAME"},
{"entry", 'e', POPT_ARG_STRING, NULL, 'e', NULL, "FILENAME"},
{"before-command", 'B', POPT_ARG_STRING, NULL, 'B', NULL, "NICKNAME"},
{"after-command", 'C', POPT_ARG_STRING, NULL, 'C', NULL, "NICKNAME"},
{"verbose", 'v', POPT_ARG_NONE, NULL, 'v', NULL, NULL},
POPT_AUTOHELP
POPT_TABLEEND
};
cm_log_set_method(cm_log_stderr);
cm_set_fips_from_env();
parent = talloc_new(NULL);
pctx = poptGetContext("hooks", argc, argv, popts, 0);
if (pctx == NULL) {
return -1;
}
if (argc > 2) {
while ((c = poptGetNextOpt(pctx)) > 0) {
cm_log_set_level(verbose);
switch (c) {
case 'v':
verbose++;
break;
case 'c':
name = poptGetOptArg(pctx);
tmpca = cm_store_files_ca_read(parent, name);
if (tmpca == NULL) {
printf("Error reading %s: %s.\n",
name, strerror(errno));
return -1;
}
tmpcas = talloc_array_ptrtype(parent, tmpcas,
n_cas + 2);
if (tmpcas == NULL) {
printf("Out of memory.\n");
return -1;
}
if (n_cas > 0) {
memcpy(tmpcas, ca,
n_cas * sizeof(ca[0]));
}
tmpcas[n_cas++] = tmpca;
tmpcas[n_cas] = NULL;
ca = tmpcas;
break;
case 'e':
name = poptGetOptArg(pctx);
tmpentry = cm_store_files_entry_read(parent,
name);
if (tmpentry == NULL) {
printf("Error reading %s: %s.\n",
name, strerror(errno));
return -1;
}
tmpentries = talloc_array_ptrtype(parent,
tmpentries,
n_entries + 2);
if (tmpentries == NULL) {
printf("Out of memory.\n");
return -1;
}
if (n_entries > 0) {
memcpy(tmpentries, entry,
n_entries * sizeof(entry[0]));
}
tmpentries[n_entries++] = tmpentry;
tmpentries[n_entries] = NULL;
entry = tmpentries;
break;
}
}
if (c != -1) {
poptPrintUsage(pctx, stdout, 0);
return 1;
}
} else {
printf("Specify CA files (-c) and entry files (-e) as "
"arguments, and nicknames (-B/-C) for actions.\n");
poptPrintUsage(pctx, stdout, 0);
return -1;
}
poptResetContext(pctx);
while ((c = poptGetNextOpt(pctx)) > 0) {
state = NULL;
switch (c) {
case 'B':
name = poptGetOptArg(pctx);
for (i = 0; i < n_entries; i++) {
if (strcmp(name, entry[i]->cm_nickname) == 0) {
printf("Starting pre-save for entry %s.\n", name);
state = cm_hook_start_presave(entry[i], NULL,
get_ca_by_index,
get_n_cas,
get_entry_by_index,
get_n_entries);
}
}
for (i = 0; i < n_cas; i++) {
if (strcmp(name, ca[i]->cm_nickname) == 0) {
printf("Starting pre-save for CA %s.\n", name);
state = cm_hook_start_ca_presave(ca[i], NULL,
get_ca_by_index,
get_n_cas,
get_entry_by_index,
get_n_entries);
}
}
break;
case 'C':
name = poptGetOptArg(pctx);
for (i = 0; i < n_entries; i++) {
if (strcmp(name, entry[i]->cm_nickname) == 0) {
printf("Starting post-save for entry %s.\n", name);
state = cm_hook_start_postsave(entry[i], NULL,
get_ca_by_index,
get_n_cas,
get_entry_by_index,
get_n_entries);
}
}
for (i = 0; i < n_cas; i++) {
if (strcmp(name, ca[i]->cm_nickname) == 0) {
printf("Starting post-save for CA %s.\n", name);
state = cm_hook_start_ca_postsave(ca[i], NULL,
get_ca_by_index,
get_n_cas,
get_entry_by_index,
get_n_entries);
}
}
break;
}
if (state != NULL) {
for (;;) {
if (cm_hook_ready(state) == 0) {
break;
}
fd = cm_hook_get_fd(state);
if (fd != -1) {
wait_to_read(fd);
} else {
sleep(1);
}
}
cm_hook_done(state);
}
}
if (c != -1) {
poptPrintUsage(pctx, stdout, 0);
return 1;
}
talloc_free(parent);
return 0;
}
certmonger-0.79.5/tests/tools/dparse.c 0000664 0025364 0001750 00000010776 13152316372 014655 0000000 0000000 /*
* Copyright (C) 2012,2015 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include "../../src/submit.h"
#include "../../src/submit-d.h"
#include "../../src/submit-e.h"
#include "../../src/submit-u.h"
int
main(int argc, char **argv)
{
const char *mode, *role, *filename;
char *error = NULL, *error_code = NULL, *error_reason = NULL;
char *status = NULL, *requestId = NULL, *cert = NULL;
char *xml, *out = NULL, *err = NULL, **profiles = NULL;
dbus_bool_t can_agent;
int i, vars;
if (argc < 4) {
printf("usage: dparse "
"{submit|check|review|reject|approve|fetch|profiles} "
"{agent|ee} "
"reply.xml\n");
return 0;
}
mode = argv[1];
role = argv[2];
filename = argv[3];
can_agent = (strcasecmp(role, "agent") == 0);
xml = cm_submit_u_from_file(filename);
if (xml == NULL) {
fprintf(stderr, "error reading %s\n", filename);
return -1;
}
if (strcmp(mode, "submit") == 0) {
cm_submit_d_submit_result(NULL, xml,
&error_code, &error_reason, &error,
&status, &requestId, &cert);
i = cm_submit_d_submit_eval(NULL, xml, "SUBMIT",
can_agent, &out, &err);
} else
if (strcmp(mode, "check") == 0) {
cm_submit_d_check_result(NULL, xml,
&error_code, &error_reason, &error,
&status, &requestId);
i = cm_submit_d_check_eval(NULL, xml, "CHECK",
can_agent, &out, &err);
} else
if (strcmp(mode, "reject") == 0) {
cm_submit_d_reject_result(NULL, xml,
&error_code, &error_reason, &error,
&status, &requestId);
i = cm_submit_d_reject_eval(NULL, xml, "REJECT",
can_agent, &out, &err);
} else
if (strcmp(mode, "review") == 0) {
cm_submit_d_review_result(NULL, xml,
&error_code, &error_reason, &error,
&status, &requestId);
i = cm_submit_d_review_eval(NULL, xml, "REVIEW",
can_agent, &out, &err);
} else
if (strcmp(mode, "approve") == 0) {
cm_submit_d_approve_result(NULL, xml,
&error_code, &error_reason, &error,
&status, &requestId);
i = cm_submit_d_approve_eval(NULL, xml, "APPROVE",
can_agent, &out, &err);
} else
if (strcmp(mode, "fetch") == 0) {
cm_submit_d_fetch_result(NULL, xml,
&error_code, &error_reason, &error,
&status, &requestId, &cert);
i = cm_submit_d_fetch_eval(NULL, xml, "FETCH",
can_agent, &out, &err);
} else
if (strcmp(mode, "profiles") == 0) {
cm_submit_d_profiles_result(NULL, xml,
&error_code, &error_reason, &error,
&status, &profiles);
i = cm_submit_d_profiles_eval(NULL, xml, "PROFILES",
can_agent, &out, &err);
} else {
fprintf(stderr, "unknown mode \"%s\"\n", mode);
return -1;
}
printf("[%s-as-%s(%s) = %s]\n",
mode,
can_agent ? "agent" : "end-entity",
filename,
cm_submit_e_status_text(i));
vars = 0;
if (error != NULL) {
printf("error=\"%s\"", error);
vars++;
}
if (error_code != NULL) {
if (vars > 0) {
printf(",");
}
printf("error_code=\"%s\"", error_code);
vars++;
}
if (error_reason != NULL) {
if (vars > 0) {
printf(",");
}
printf("error_reason=\"%s\"", error_reason);
vars++;
}
if (status != NULL) {
if (vars > 0) {
printf(",");
}
printf("status=\"%s\"", status);
vars++;
}
if (requestId != NULL) {
if (vars > 0) {
printf(",");
}
printf("requestId=\"%s\"", requestId);
vars++;
}
if (cert != NULL) {
if (vars > 0) {
printf(",");
}
printf("cert=\"%.*s\"", (int) strcspn(cert, "\r\n"), cert);
vars++;
}
if (vars > 0) {
printf("\n");
}
while ((out != NULL) && (*out != '\0')) {
if (strchr("\r", *out) == NULL) {
putchar((unsigned char) *out);
}
out++;
}
while ((err != NULL) && (*err != '\0')) {
if (strchr("\r", *err) == NULL) {
putchar((unsigned char) *err);
}
err++;
}
printf("\n");
return 0;
}
certmonger-0.79.5/tests/tools/dates.c 0000664 0025364 0001750 00000003631 13152316372 014467 0000000 0000000 /*
* Copyright (C) 2010 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include "../../src/submit.h"
#include "../../src/submit-u.h"
int cm_submit_delta_from_string(const char *deltas, time_t now, time_t *delta);
int
main(int argc, char **argv)
{
struct tm when;
time_t now, later, delta;
int i;
if (argc > 1) {
for (i = 2; i < argc; i++) {
memset(&when, 0, sizeof(when));
when.tm_mday = 1;
when.tm_mon = 0;
when.tm_year = atoi(argv[1]) - 1900;
when.tm_isdst = -1;
if (cm_submit_u_delta_from_string(argv[i],
now = mktime(&when),
&delta) != 0) {
printf("Error at \"%s\".\n", argv[i]);
delta = 0;
}
printf("%04d-%02d-%02d %02d:%02d:%02d",
when.tm_year + 1900,
when.tm_mon + 1,
when.tm_mday,
when.tm_hour,
when.tm_min,
when.tm_sec);
printf(" + \"%s\" = ", argv[i]);
later = now + delta;
localtime_r(&later, &when);
printf("%04d-%02d-%02d %02d:%02d:%02d",
when.tm_year + 1900,
when.tm_mon + 1,
when.tm_mday,
when.tm_hour,
when.tm_min,
when.tm_sec);
printf("\n");
}
}
return 0;
}
certmonger-0.79.5/tests/tools/csrgen.c 0000664 0025364 0001750 00000005541 13152316372 014652 0000000 0000000 /*
* Copyright (C) 2009,2011 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/csrgen.h"
#include "../../src/log.h"
#include "../../src/store.h"
#include "../../src/store-int.h"
#include "tools.h"
static void
wait_to_read(int fd)
{
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
select(fd + 1, &rfds, NULL, NULL, &tv);
}
int
main(int argc, char **argv)
{
struct cm_csrgen_state *state;
struct cm_store_entry *entry;
int fd, ret, i;
void *parent;
char *p;
/* Make minicerts claim to be v3 so that OpenSSL won't skip the version
* number field, which is optional, because we default to the spec's
* default value. */
cm_csrgen_version_for_testing_minicerts = 2;
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
cm_set_fips_from_env();
parent = talloc_new(NULL);
if (argc > 1) {
entry = cm_store_files_entry_read(parent, argv[1]);
if (entry == NULL) {
printf("Error reading %s: %s.\n", argv[1],
strerror(errno));
return 1;
}
} else {
printf("Specify an entry file as the single argument.\n");
return 1;
}
state = cm_csrgen_start(entry);
if (state != NULL) {
for (;;) {
fd = cm_csrgen_get_fd(state);
if (fd != -1) {
wait_to_read(fd);
} else {
sleep(1);
}
if (cm_csrgen_ready(state) == 0) {
break;
}
}
if (cm_csrgen_save_csr(state) == 0) {
while (strlen(entry->cm_csr) > 0) {
i = strlen(entry->cm_csr) - 1;
if (entry->cm_csr[i] == '\n') {
entry->cm_csr[i] = '\0';
} else {
break;
}
}
p = talloc_asprintf(entry, "%s\n", entry->cm_csr);
talloc_free(entry->cm_csr);
entry->cm_csr = p;
printf("%s", entry->cm_csr);
ret = 0;
} else {
printf("Failed to save.\n");
if (cm_csrgen_need_token(state) == 0) {
printf("(Need token.)\n");
} else
if (cm_csrgen_need_pin(state) == 0) {
printf("(Need PIN.)\n");
}
ret = 1;
}
cm_csrgen_done(state);
} else {
printf("Failed to start.\n");
ret = 1;
}
cm_store_entry_save(entry);
talloc_free(parent);
return ret;
}
certmonger-0.79.5/tests/tools/citerate.c 0000664 0025364 0001750 00000015104 13152316372 015165 0000000 0000000 /*
* Copyright (C) 2009,2010,2011,2012,2013,2014 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/iterate.h"
#include "../../src/log.h"
#include "../../src/store.h"
#include "../../src/store-int.h"
#include "tools.h"
static void
wait_to_read(int fd)
{
fd_set rfds;
struct timeval tv;
if (fd >= 0) {
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
select(fd + 1, &rfds, NULL, NULL, &tv);
} else {
sleep(1);
}
}
struct cm_context {
struct cm_store_ca *ca;
struct cm_store_entry *entry;
};
static struct cm_store_ca *
get_ca_by_index(struct cm_context *cm, int i)
{
if (i == 0) {
return cm->ca;
} else {
return NULL;
}
}
static int
get_n_cas(struct cm_context *cm)
{
return (cm->ca != NULL) ? 1 : 0;
}
static struct cm_store_entry *
get_entry_by_index(struct cm_context *cm, int i)
{
if (i == 0) {
return cm->entry;
} else {
return NULL;
}
}
static int
get_n_entries(struct cm_context *cm)
{
return (cm->entry != NULL) ? 1 : 0;
}
int
main(int argc, char **argv)
{
struct cm_context cm;
enum cm_ca_phase_state pstate, old_state;
enum cm_ca_phase phase;
int readfd, delay;
void *parent, *istate;
char *p, *q, *continue_states, *stop_states, *tmp;
const char *state;
enum cm_time when;
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
cm_set_fips_from_env();
parent = talloc_new(NULL);
if (argc > 5) {
cm.ca = cm_store_files_ca_read(parent, argv[1]);
if (cm.ca == NULL) {
printf("Error reading %s: %s.\n", argv[1],
strerror(errno));
return 1;
}
cm.entry = cm_store_files_entry_read(parent, argv[2]);
if (cm.entry == NULL) {
printf("Error reading %s: %s.\n", argv[2],
strerror(errno));
return 1;
}
phase = cm_store_ca_phase_from_string(argv[3]);
if ((cm.entry->cm_ca_nickname == NULL) ||
(cm.ca->cm_nickname == NULL) ||
(strcasecmp(cm.entry->cm_ca_nickname,
cm.ca->cm_nickname) != 0)) {
talloc_free(cm.entry);
cm.entry = NULL;
}
pstate = cm_store_ca_state_from_string(argv[4]);
continue_states = argv[5];
stop_states = NULL;
if ((argc > 6) && (strlen(argv[6]) > 0)) {
stop_states = argv[6];
if (strlen(continue_states) == 0) {
continue_states = NULL;
}
}
} else {
printf("Specify a CA file and an entry file as the first "
"two arguments, a phase as the third, an initial "
"state as the fourth, a list of continue states as "
"the fifth, and perhaps a list of stop states as the "
"sixth.\n");
return 1;
}
if (cm_iterate_ca_init(cm.ca, phase, &istate) != 0) {
printf("Error initializing.\n");
return 1;
}
cm.ca->cm_ca_state[phase] = pstate;
old_state = pstate;
state = cm_store_ca_state_as_string(old_state);
printf("%s\n-START-\n", state);
fflush(NULL);
delay = 0;
readfd = -1;
while (cm_iterate_ca(cm.ca, &cm,
get_ca_by_index, get_n_cas,
get_entry_by_index, get_n_entries,
NULL, istate, &when, &delay,
&readfd) == 0) {
state = cm_store_ca_state_as_string(cm.ca->cm_ca_state[phase]);
switch (when) {
case cm_time_now:
if (cm.ca->cm_ca_state[phase] != old_state) {
printf("%s\n", state);
} else {
printf("%s (now)\n", state);
}
break;
case cm_time_soon:
if (cm.ca->cm_ca_state[phase] != old_state) {
printf("%s\n", state);
} else {
printf("%s (soon)\n", state);
}
break;
case cm_time_soonish:
if (cm.ca->cm_ca_state[phase] != old_state) {
printf("%s\n", state);
} else {
printf("%s (soonish)\n", state);
}
break;
case cm_time_delay:
if (cm.ca->cm_ca_state[phase] != old_state) {
printf("delay=%ld\n%s\n", (long) delay,
state);
} else {
printf("delay=%ld (again)\n%s (again)\n",
(long) delay, state);
}
break;
case cm_time_no_time:
if (cm.ca->cm_ca_state[phase] != old_state) {
printf("%s\n", state);
}
break;
}
if ((cm.ca->cm_ca_state[phase] == old_state) &&
((when != cm_time_no_time) || (readfd == -1))) {
/* If we didn't change state, stop. */
printf("-STUCK- (%d:%ld)\n", when, (long) delay);
fflush(NULL);
state = NULL;
break;
}
if (stop_states != NULL) {
/* Check if this state is in our stop-states list. */
for (p = stop_states;
*p != '\0';
p = q + strspn(q, ",")) {
q = p + strcspn(p, ",");
tmp = talloc_strndup(parent, p, q - p);
if (cm.ca->cm_ca_state[phase] ==
cm_store_ca_state_from_string(tmp)) {
fflush(NULL);
talloc_free(tmp);
break;
}
talloc_free(tmp);
}
if (*p != '\0') {
/* We found a match. Stop here. */
printf("-STOP-\n");
fflush(NULL);
state = NULL;
break;
}
}
/* Check if this state is in our continue-states list. */
if (continue_states != NULL) {
for (p = continue_states;
*p != '\0';
p = q + strspn(q, ",")) {
q = p + strcspn(p, ",");
tmp = talloc_strndup(parent, p, q - p);
if (cm.ca->cm_ca_state[phase] ==
cm_store_ca_state_from_string(tmp)) {
fflush(NULL);
talloc_free(tmp);
break;
}
talloc_free(tmp);
}
/* If we didn't find a match, stop here. */
if (*p == '\0') {
printf("-STOP-\n");
fflush(NULL);
state = NULL;
break;
}
}
/* Wait. */
switch (when) {
case cm_time_now:
break;
case cm_time_soon:
sleep(CM_DELAY_SOON);
break;
case cm_time_soonish:
sleep(CM_DELAY_SOONISH);
break;
case cm_time_delay:
sleep(delay);
break;
case cm_time_no_time:
wait_to_read(readfd);
break;
}
old_state = cm.ca->cm_ca_state[phase];
state = cm_store_ca_state_as_string(old_state);
delay = 0;
readfd = -1;
}
if (state != NULL) {
printf("-ERROR-\n");
fflush(NULL);
}
cm_store_ca_save(cm.ca);
cm_iterate_ca_done(cm.ca, istate);
talloc_free(parent);
return 0;
}
certmonger-0.79.5/tests/tools/checksig.c 0000664 0025364 0001750 00000006201 13152316372 015143 0000000 0000000 /*
* Copyright (C) 2014,2017 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/log.h"
#include "../../src/store.h"
#include "../../src/store-int.h"
int
main(int argc, char **argv)
{
int i;
unsigned int len;
unsigned char *p, *q, buf[LINE_MAX];
SECItem encoded;
CERTSignedData signed_data;
CERTCertificate cert;
SECKEYPublicKey *pubkey;
CERTSubjectPublicKeyInfo *spki;
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
p = NULL;
len = 0;
if (NSS_Initialize(".", NULL, NULL, NULL,
NSS_INIT_READONLY | NSS_INIT_NOCERTDB |
NSS_INIT_NOMODDB) != SECSuccess) {
printf("error initializing NSS\n");
return 1;
}
while ((i = read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
q = realloc(p, len + i);
if (q == NULL) {
perror("malloc");
free(p);
return 1;
}
p = q;
memcpy(p + len, buf, i);
len += i;
}
memset(&encoded, 0, sizeof(encoded));
encoded.data = p;
encoded.len = len;
memset(&signed_data, 0, sizeof(signed_data));
if (SEC_ASN1DecodeItem(NULL, &signed_data,
CERT_SignedDataTemplate,
&encoded) != SECSuccess) {
printf("error decoding certificate\n");
return 1;
}
memset(&cert, 0, sizeof(cert));
if (SEC_ASN1DecodeItem(NULL, &cert,
CERT_CertificateTemplate,
&signed_data.data) != SECSuccess) {
printf("error decoding certificate data\n");
return 1;
}
spki = SECKEY_DecodeDERSubjectPublicKeyInfo(&cert.derPublicKey);
if (spki == NULL) {
printf("error decoding public key info\n");
return 1;
}
pubkey = SECKEY_ExtractPublicKey(spki);
if (pubkey == NULL) {
printf("error finding public key\n");
return 1;
}
signed_data.signature.len = howmany(signed_data.signature.len, 8);
if (VFY_VerifyDataWithAlgorithmID(signed_data.data.data,
signed_data.data.len,
pubkey,
&signed_data.signature,
&signed_data.signatureAlgorithm,
NULL,
NULL) != SECSuccess) {
printf("error in verification: %s\n",
PR_ErrorToName(PORT_GetError()));
return 1;
}
printf("verification OK\n");
SECKEY_DestroyPublicKey(pubkey);
SECKEY_DestroySubjectPublicKeyInfo(spki);
NSS_Shutdown();
return 0;
}
certmonger-0.79.5/tests/tools/certsave.c 0000664 0025364 0001750 00000006065 13152316372 015207 0000000 0000000 /*
* Copyright (C) 2009,2011,2013 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "../../src/certsave.h"
#include "../../src/log.h"
#include "../../src/store.h"
#include "../../src/store-int.h"
#include "tools.h"
static void
wait_to_read(int fd)
{
fd_set rfds;
struct timeval tv;
FD_ZERO(&rfds);
FD_SET(fd, &rfds);
tv.tv_sec = 1;
tv.tv_usec = 0;
select(fd + 1, &rfds, NULL, NULL, &tv);
}
int
main(int argc, char **argv)
{
struct cm_certsave_state *state;
struct cm_store_entry *entry;
int fd, ret;
void *parent;
const char *ctype;
cm_log_set_method(cm_log_stderr);
cm_log_set_level(3);
cm_set_fips_from_env();
parent = talloc_new(NULL);
if (argc > 1) {
entry = cm_store_files_entry_read(parent, argv[1]);
if (entry == NULL) {
printf("Error reading %s: %s.\n", argv[1],
strerror(errno));
return 1;
}
} else {
printf("Specify an entry file as the single argument.\n");
return 1;
}
state = cm_certsave_start(entry);
if (state != NULL) {
for (;;) {
fd = cm_certsave_get_fd(state);
if (fd != -1) {
wait_to_read(fd);
} else {
sleep(1);
}
if (cm_certsave_ready(state) == 0) {
break;
}
}
if (cm_certsave_saved(state) == 0) {
ret = 0;
} else {
ctype = "unknown";
switch (entry->cm_cert_storage_type) {
case cm_cert_storage_file:
ctype = "FILE";
break;
case cm_cert_storage_nssdb:
ctype = "NSS";
break;
}
if (cm_certsave_conflict_subject(state) == 0) {
printf("Failed to save (%s:%s), "
"subject name conflict.\n",
ctype, entry->cm_cert_storage_location);
} else
if (cm_certsave_conflict_nickname(state) == 0) {
printf("Failed to save (%s:%s), "
"certificate nickname conflict.\n",
ctype, entry->cm_cert_storage_location);
} else
if (cm_certsave_permissions_error(state) == 0) {
printf("Failed to save (%s:%s), "
"filesystem permissions error.\n",
ctype, entry->cm_cert_storage_location);
} else {
printf("Failed to save (%s:%s), "
"don't know why.\n",
ctype, entry->cm_cert_storage_location);
}
ret = 1;
}
cm_certsave_done(state);
} else {
printf("Failed to start.\n");
ret = 1;
}
cm_store_entry_save(entry);
talloc_free(parent);
return ret;
}
certmonger-0.79.5/tests/tools/certread.c 0000664 0025364 0001750 00000004116 13152316372 015157 0000000 0000000 /*
* Copyright (C) 2009,2011 Red Hat, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include "../../src/config.h"
#include
#include
#include
#include
#include