aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/gpg/Makefile.am8
-rwxr-xr-xtests/gpg/pinentry22
-rw-r--r--tests/gpg/pinentry.c47
-rw-r--r--tests/json/Makefile.am2
4 files changed, 55 insertions, 24 deletions
diff --git a/tests/gpg/Makefile.am b/tests/gpg/Makefile.am
index 4ceb6102..a6c76666 100644
--- a/tests/gpg/Makefile.am
+++ b/tests/gpg/Makefile.am
@@ -61,7 +61,7 @@ private_keys = \
EXTRA_DIST = initial.test final.test \
pubdemo.asc secdemo.asc cipher-1.asc cipher-2.asc \
cipher-3.asc cipher-no-sig.asc \
- geheim.txt pubkey-1.asc seckey-1.asc pinentry $(private_keys) \
+ geheim.txt pubkey-1.asc seckey-1.asc $(private_keys) \
gpg.conf.in ownertrust.txt
BUILT_SOURCES = gpg.conf gpg-agent.conf pubring-stamp \
@@ -91,6 +91,7 @@ endif
noinst_PROGRAMS = $(c_tests) $(tests_skipped)
+noinst_PROGRAMS += pinentry$(EXEEXT)
clean-local:
-$(TESTS_ENVIRONMENT) $(top_srcdir)/tests/start-stop-agent --stop
@@ -122,5 +123,10 @@ gpg-agent.conf:
# smartcard reader (error might be: Unusable secret key)
echo disable-scdaemon >> ./gpg-agent.conf
+pinentry.o: $(srcdir)/pinentry.c
+ $(CC) $(CFLAGS) -c $(srcdir)/pinentry.c
+
+pinentry$(EXEEXT): pinentry.o
+ $(CC) -o $@ pinentry.o
# end-of-file
diff --git a/tests/gpg/pinentry b/tests/gpg/pinentry
deleted file mode 100755
index b12caae2..00000000
--- a/tests/gpg/pinentry
+++ /dev/null
@@ -1,22 +0,0 @@
-#! /bin/sh
-# Dummy pinentry
-#
-# Copyright 2008 g10 Code GmbH
-#
-# This file is free software; as a special exception the author gives
-# unlimited permission to copy and/or distribute it, with or without
-# modifications, as long as this notice is preserved.
-#
-# This file 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.
-
-echo OK Your orders please
-
-while read cmd; do
- case $cmd in
- GETPIN) echo D abc; echo OK;;
- *) echo OK;;
- esac
-done
diff --git a/tests/gpg/pinentry.c b/tests/gpg/pinentry.c
new file mode 100644
index 00000000..be5d3b35
--- /dev/null
+++ b/tests/gpg/pinentry.c
@@ -0,0 +1,47 @@
+/* pinentry.c - Dummy pinentry program for testing
+ * Copyright (C) 2026 g10 Code GmbH
+ *
+ * This file is part of GPGME.
+ *
+ * GPGME is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * GPGME 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, see <https://gnu.org/licenses/>.
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#define MAX_LINE 256
+
+int
+main (int argc, const char *argv[])
+{
+ char line[MAX_LINE+1];
+
+ (void)argc;
+ (void)argv;
+ puts ("OK Your orders please");
+ fflush (stdout);
+ while (fgets (line, sizeof (line), stdin))
+ {
+ if (strncmp (line, "GETPIN", 6) == 0)
+ puts ("D abc");
+ else if (strncmp (line, "BYE", 3) == 0)
+ break;
+ puts ("OK");
+ fflush (stdout);
+ }
+ puts ("OK closing connection");
+ fflush (stdout);
+ return 0;
+}
diff --git a/tests/json/Makefile.am b/tests/json/Makefile.am
index 5f34b849..863b0683 100644
--- a/tests/json/Makefile.am
+++ b/tests/json/Makefile.am
@@ -110,7 +110,7 @@ gpg-agent.conf:
# This is required for gpg2, which does not support command fd for the
# passphrase. disable-scdaemon is required so that we don't try using
# a key from a smartcard reader (error might be: Unusable secret key)
- echo pinentry-program $(abs_srcdir)/../gpg/pinentry > ./gpg-agent.conf
+ echo pinentry-program $(abs_builddir)/../gpg/pinentry$(EXEEXT) > ./gpg-agent.conf
echo disable-scdaemon >> ./gpg-agent.conf