aboutsummaryrefslogtreecommitdiffstats
path: root/src/pinentry/pinentry.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/pinentry/pinentry.cpp197
1 files changed, 0 insertions, 197 deletions
diff --git a/src/pinentry/pinentry.cpp b/src/pinentry/pinentry.cpp
index 6168a203..c648aea6 100644
--- a/src/pinentry/pinentry.cpp
+++ b/src/pinentry/pinentry.cpp
@@ -232,48 +232,6 @@ static gpg_error_t pinentry_assuan_reset_handler(assuan_context_t ctx,
return 0;
}
-/* Copy TEXT or TEXTLEN to BUFFER and escape as required. Return a
- pointer to the end of the new buffer. Note that BUFFER must be
- large enough to keep the entire text; allocataing it 3 times of
- TEXTLEN is sufficient. */
-static char *copy_and_escape(char *buffer, const void *text, size_t textlen) {
- int i;
- const unsigned char *s = (unsigned char *)text;
- char *p = buffer;
-
- for (i = 0; i < textlen; i++) {
- if (s[i] < ' ' || s[i] == '+') {
- snprintf(p, 4, "%%%02X", s[i]);
- p += 3;
- } else if (s[i] == ' ')
- *p++ = '+';
- else
- *p++ = s[i];
- }
- return p;
-}
-
-/* Perform percent unescaping in STRING and return the new valid length
- of the string. A terminating Nul character is inserted at the end of
- the unescaped string.
- */
-static size_t do_unescape_inplace(char *s) {
- unsigned char *p, *p0;
-
- p = p0 = (unsigned char *)s;
- while (*s) {
- if (*s == '%' && s[1] && s[2]) {
- s++;
- *p++ = xtoi_2(s);
- s += 2;
- } else
- *p++ = *s++;
- }
- *p = 0;
-
- return (p - p0);
-}
-
/* Return a malloced copy of the commandline for PID. If this is not
* possible NULL is returned. */
#ifndef WINDOWS
@@ -530,18 +488,6 @@ static struct assuan_malloc_hooks assuan_malloc_hooks = {
GpgFrontend::SecureMalloc, GpgFrontend::SecureRealloc,
GpgFrontend::SecureFree};
-/* Initialize the secure memory subsystem, drop privileges and return.
- Must be called early. */
-void pinentry_init(const char *pgmname) {
- /* Store away our name. */
- if (strlen(pgmname) > sizeof this_pgmname - 2) abort();
- strcpy(this_pgmname, pgmname);
-
- gpgrt_check_version(NULL);
-
- assuan_set_malloc_hooks(&assuan_malloc_hooks);
-}
-
/* Simple test to check whether DISPLAY is set or the option --display
was given. Used to decide whether the GUI or curses should be
initialized. */
@@ -590,149 +536,6 @@ int pinentry_have_display(int argc, char **argv) {
/* Set the optional flag used with getinfo. */
void pinentry_set_flavor_flag(const char *string) { flavor_flag = string; }
-static gpg_error_t option_handler(assuan_context_t ctx, const char *key,
- const char *value) {
- (void)ctx;
-
- if (!strcmp(key, "no-grab") && !*value)
- pinentry.grab = 0;
- else if (!strcmp(key, "grab") && !*value)
- pinentry.grab = 1;
- else if (!strcmp(key, "debug-wait")) {
-#ifndef WINDOWS
- fprintf(stderr, "%s: waiting for debugger - my pid is %u ...\n",
- this_pgmname, (unsigned int)getpid());
- sleep(*value ? atoi(value) : 5);
- fprintf(stderr, "%s: ... okay\n", this_pgmname);
-#endif
- } else if (!strcmp(key, "display")) {
- if (pinentry.display) free(pinentry.display);
- pinentry.display = strdup(value);
- if (!pinentry.display) return gpg_error_from_syserror();
- } else if (!strcmp(key, "ttyname")) {
- if (pinentry.ttyname) free(pinentry.ttyname);
- pinentry.ttyname = strdup(value);
- if (!pinentry.ttyname) return gpg_error_from_syserror();
- } else if (!strcmp(key, "ttytype")) {
- if (pinentry.ttytype_l) free(pinentry.ttytype_l);
- pinentry.ttytype_l = strdup(value);
- if (!pinentry.ttytype_l) return gpg_error_from_syserror();
- } else if (!strcmp(key, "ttyalert")) {
- if (pinentry.ttyalert) free(pinentry.ttyalert);
- pinentry.ttyalert = strdup(value);
- if (!pinentry.ttyalert) return gpg_error_from_syserror();
- } else if (!strcmp(key, "lc-ctype")) {
- if (pinentry.lc_ctype) free(pinentry.lc_ctype);
- pinentry.lc_ctype = strdup(value);
- if (!pinentry.lc_ctype) return gpg_error_from_syserror();
- } else if (!strcmp(key, "lc-messages")) {
- if (pinentry.lc_messages) free(pinentry.lc_messages);
- pinentry.lc_messages = strdup(value);
- if (!pinentry.lc_messages) return gpg_error_from_syserror();
- } else if (!strcmp(key, "owner")) {
- long along;
- char *endp;
-
- free(pinentry.owner_host);
- pinentry.owner_host = NULL;
- pinentry.owner_uid = -1;
- pinentry.owner_pid = 0;
-
- errno = 0;
- along = strtol(value, &endp, 10);
- if (along && !errno) {
- pinentry.owner_pid = (unsigned long)along;
- if (*endp) {
- errno = 0;
- if (*endp == '/') { /* we have a uid */
- endp++;
- along = strtol(endp, &endp, 10);
- if (along >= 0 && !errno) pinentry.owner_uid = (int)along;
- }
- if (endp) {
- while (*endp == ' ') endp++;
- if (*endp) {
- pinentry.owner_host = strdup(endp);
- for (endp = pinentry.owner_host; *endp && *endp != ' '; endp++)
- ;
- *endp = 0;
- }
- }
- }
- }
- } else if (!strcmp(key, "parent-wid")) {
- pinentry.parent_wid = atoi(value);
- /* FIXME: Use strtol and add some error handling. */
- } else if (!strcmp(key, "touch-file")) {
- if (pinentry.touch_file) free(pinentry.touch_file);
- pinentry.touch_file = strdup(value);
- if (!pinentry.touch_file) return gpg_error_from_syserror();
- } else if (!strcmp(key, "default-ok")) {
- pinentry.default_ok = strdup(value);
- if (!pinentry.default_ok) return gpg_error_from_syserror();
- } else if (!strcmp(key, "default-cancel")) {
- pinentry.default_cancel = strdup(value);
- if (!pinentry.default_cancel) return gpg_error_from_syserror();
- } else if (!strcmp(key, "default-prompt")) {
- pinentry.default_prompt = strdup(value);
- if (!pinentry.default_prompt) return gpg_error_from_syserror();
- } else if (!strcmp(key, "default-pwmngr")) {
- pinentry.default_pwmngr = strdup(value);
- if (!pinentry.default_pwmngr) return gpg_error_from_syserror();
- } else if (!strcmp(key, "default-cf-visi")) {
- pinentry.default_cf_visi = strdup(value);
- if (!pinentry.default_cf_visi) return gpg_error_from_syserror();
- } else if (!strcmp(key, "default-tt-visi")) {
- pinentry.default_tt_visi = strdup(value);
- if (!pinentry.default_tt_visi) return gpg_error_from_syserror();
- } else if (!strcmp(key, "default-tt-hide")) {
- pinentry.default_tt_hide = strdup(value);
- if (!pinentry.default_tt_hide) return gpg_error_from_syserror();
- } else if (!strcmp(key, "default-capshint")) {
- pinentry.default_capshint = strdup(value);
- if (!pinentry.default_capshint) return gpg_error_from_syserror();
- } else if (!strcmp(key, "allow-external-password-cache") && !*value) {
- pinentry.allow_external_password_cache = 1;
- pinentry.tried_password_cache = 0;
- } else if (!strcmp(key, "allow-emacs-prompt") && !*value) {
-#ifdef INSIDE_EMACS
- pinentry_enable_emacs_cmd_handler();
-#endif
- } else if (!strcmp(key, "invisible-char")) {
- if (pinentry.invisible_char) free(pinentry.invisible_char);
- pinentry.invisible_char = strdup(value);
- if (!pinentry.invisible_char) return gpg_error_from_syserror();
- } else if (!strcmp(key, "formatted-passphrase") && !*value) {
- pinentry.formatted_passphrase = 1;
- } else if (!strcmp(key, "formatted-passphrase-hint")) {
- if (pinentry.formatted_passphrase_hint)
- free(pinentry.formatted_passphrase_hint);
- pinentry.formatted_passphrase_hint = strdup(value);
- if (!pinentry.formatted_passphrase_hint) return gpg_error_from_syserror();
- do_unescape_inplace(pinentry.formatted_passphrase_hint);
- } else if (!strcmp(key, "constraints-enforce") && !*value)
- pinentry.constraints_enforce = 1;
- else if (!strcmp(key, "constraints-hint-short")) {
- if (pinentry.constraints_hint_short) free(pinentry.constraints_hint_short);
- pinentry.constraints_hint_short = strdup(value);
- if (!pinentry.constraints_hint_short) return gpg_error_from_syserror();
- do_unescape_inplace(pinentry.constraints_hint_short);
- } else if (!strcmp(key, "constraints-hint-long")) {
- if (pinentry.constraints_hint_long) free(pinentry.constraints_hint_long);
- pinentry.constraints_hint_long = strdup(value);
- if (!pinentry.constraints_hint_long) return gpg_error_from_syserror();
- do_unescape_inplace(pinentry.constraints_hint_long);
- } else if (!strcmp(key, "constraints-error-title")) {
- if (pinentry.constraints_error_title)
- free(pinentry.constraints_error_title);
- pinentry.constraints_error_title = strdup(value);
- if (!pinentry.constraints_error_title) return gpg_error_from_syserror();
- do_unescape_inplace(pinentry.constraints_error_title);
- } else
- return gpg_error(GPG_ERR_UNKNOWN_OPTION);
- return 0;
-}
-
/* Note, that it is sufficient to allocate the target string D as
long as the source string S, i.e.: strlen(s)+1; */
static void strcpy_escaped(char *d, const char *s) {