.github
.zed
admin
appl
cf
doc
etc
include
kadmin
kcm
kdc
kpasswd
kuser
lib
asn1
base
com_err
gss_preauth
gssapi
hcrypto
hdb
heimdal
hx509
data
ref
ChangeLog
Makefile.am
NTMakefile
TODO
ca.c
cert.c
char_map.h
cms.c
collector.c
crypto-ec.c
crypto.c
doxygen.c
env.c
error.c
file.c
hx509.h
hx509_err.et
hx_locl.h
hxtool-commands.in
hxtool-version.rc
hxtool.1
hxtool.c
keyset.c
ks_dir.c
ks_file.c
ks_keychain.c
ks_mem.c
ks_null.c
ks_p11.c
ks_p12.c
libhx509-exports.def
lock.c
name.c
peer.c
print.c
quote.py
req.c
revoke.c
sel-gram.y
sel-lex.l
sel.c
sel.h
softp11.c
test_ca.in
test_cert.in
test_chain.in
test_cms.in
test_crypto.in
test_expr.c
test_java_pkcs11.in
test_name.c
test_nist.in
test_nist2.in
test_nist_cert.in
test_nist_pkcs12.in
test_pkcs11.in
test_query.in
test_req.in
test_soft_pkcs11.c
test_windows.in
tst-crypto-available1
tst-crypto-available2
tst-crypto-available3
tst-crypto-select
tst-crypto-select1
tst-crypto-select2
tst-crypto-select3
tst-crypto-select4
tst-crypto-select5
tst-crypto-select6
tst-crypto-select7
version-script.map
ipc
kadm5
kafs
kdfs
krb5
libedit
ntlm
otp
roken
sl
sqlite
vers
wind
Makefile.am
NTMakefile
nix
packages
po
tests
tools
windows
.gitignore
.travis.yml
CODE_OF_CONDUCT.md
ChangeLog
ChangeLog.1998
ChangeLog.1999
ChangeLog.2000
ChangeLog.2001
ChangeLog.2002
ChangeLog.2003
ChangeLog.2004
ChangeLog.2005
ChangeLog.2006
ChangeLog.2007
LICENSE
Makefile.am
Makefile.am.common
NEWS
NTMakefile
README
README.fast
README.md
SECURITY.md
TODO
acinclude.m4
appveyor.yml
autogen.sh
configure.ac
flake.lock
flake.nix
krb5.conf
88 lines
2.1 KiB
C
88 lines
2.1 KiB
C
|
|
#include "hx_locl.h"
|
|
#include <err.h>
|
|
|
|
struct foo {
|
|
int val;
|
|
char *str;
|
|
} foo[] = {
|
|
{ 0, "FALSE" },
|
|
{ 1, "TRUE" },
|
|
{ 0, "!TRUE" },
|
|
{ 0, "! TRUE" },
|
|
{ 0, "!\tTRUE" },
|
|
{ 0, "( FALSE AND FALSE )" },
|
|
{ 0, "( TRUE AND FALSE )" },
|
|
{ 1, "( TRUE AND TRUE )" },
|
|
{ 1, "( TRUE OR TRUE )" },
|
|
{ 1, "( TRUE OR FALSE )" },
|
|
{ 0, "( FALSE OR FALSE )" },
|
|
{ 1, "! ( FALSE OR FALSE )" },
|
|
|
|
{ 1, "\"foo\" TAILMATCH \"foo\"" },
|
|
{ 1, "\"foobar\" TAILMATCH \"bar\"" },
|
|
{ 0, "\"foobar\" TAILMATCH \"foo\"" },
|
|
|
|
{ 1, "\"foo\" == \"foo\"" },
|
|
{ 0, "\"foo\" == \"bar\"" },
|
|
{ 0, "\"foo\" != \"foo\"" },
|
|
{ 1, "\"foo\" != \"bar\"" },
|
|
{ 1, "%{variable} == \"foo\"" },
|
|
{ 0, "%{variable} == \"bar\"" },
|
|
{ 1, "%{context.variable} == \"foo\"" },
|
|
{ 0, "%{context.variable} == \"bar\"" },
|
|
{ 1, "\"foo\" IN ( \"bar\", \"foo\")" },
|
|
{ 0, "\"foo\" IN ( \"bar\", \"baz\")" },
|
|
{ 0, "\"bar\" IN %{context}" },
|
|
{ 1, "\"foo\" IN %{context}" },
|
|
{ 1, "\"variable\" IN %{context}" },
|
|
|
|
{ 1, "\"foo\" IN %{context} AND %{context.variable} == \"foo\"" }
|
|
};
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
struct hx_expr *expr;
|
|
hx509_context context;
|
|
hx509_env env = NULL, env2 = NULL;
|
|
int val, i, ret;
|
|
|
|
#if 0
|
|
extern int yydebug;
|
|
yydebug = 1;
|
|
#endif
|
|
|
|
ret = hx509_context_init(&context);
|
|
if (ret)
|
|
errx(1, "hx509_context_init failed with %d", ret);
|
|
|
|
hx509_env_add(context, &env, "variable", "foo");
|
|
hx509_env_add(context, &env2, "variable", "foo");
|
|
hx509_env_add_binding(context, &env, "context", env2);
|
|
|
|
for (i = 0; i < sizeof(foo)/sizeof(foo[0]); i++) {
|
|
|
|
expr = _hx509_expr_parse(foo[i].str);
|
|
if (expr == NULL)
|
|
errx(1, "_hx509_expr_parse failed for %d: %s", i, foo[i].str);
|
|
|
|
val = _hx509_expr_eval(context, env, expr);
|
|
if (foo[i].val) {
|
|
if (val == 0)
|
|
errx(1, "_hx509_expr_eval not true when it should: %d: %s",
|
|
i, foo[i].str);
|
|
} else {
|
|
if (val)
|
|
errx(1, "_hx509_expr_eval true when it should not: %d: %s",
|
|
i, foo[i].str);
|
|
}
|
|
|
|
_hx509_expr_free(expr);
|
|
}
|
|
|
|
hx509_env_free(&env);
|
|
|
|
return 0;
|
|
}
|