Skip to content

Instantly share code, notes, and snippets.

@jesboat
Created August 30, 2014 10:40
Show Gist options
  • Save jesboat/4e628ed93537b9e9ab72 to your computer and use it in GitHub Desktop.
Save jesboat/4e628ed93537b9e9ab72 to your computer and use it in GitHub Desktop.
Fix a spurious ssh error/warning message
diff -ru OpenSSH-186 2/openssh/ssh.c OpenSSH-186/openssh/ssh.c
--- OpenSSH-186 2/openssh/ssh.c 2013-07-02 16:09:16.000000000 -0700
+++ OpenSSH-186/openssh/ssh.c 2014-08-30 03:32:29.000000000 -0700
@@ -1505,6 +1505,7 @@
u_int n_ids;
char *identity_files[SSH_MAX_IDENTITY_FILES];
Key *identity_keys[SSH_MAX_IDENTITY_FILES];
+ int identity_file_userprovided[SSH_MAX_IDENTITY_FILES];
#ifdef ENABLE_PKCS11
Key **keys;
int nkeys;
@@ -1513,6 +1514,7 @@
n_ids = 0;
bzero(identity_files, sizeof(identity_files));
bzero(identity_keys, sizeof(identity_keys));
+ bzero(identity_file_userprovided, sizeof(identity_file_userprovided));
#ifdef ENABLE_PKCS11
if (options.pkcs11_provider != NULL &&
@@ -1528,6 +1530,7 @@
identity_keys[n_ids] = keys[i];
identity_files[n_ids] =
xstrdup(options.pkcs11_provider); /* XXX */
+ identity_file_userprovided[n_ids] = 1;
n_ids++;
}
xfree(keys);
@@ -1558,6 +1561,8 @@
xfree(options.identity_files[i]);
identity_files[n_ids] = filename;
identity_keys[n_ids] = public;
+ identity_file_userprovided[n_ids] =
+ options.identity_file_userprovided[i];
if (++n_ids >= SSH_MAX_IDENTITY_FILES)
continue;
@@ -1581,11 +1586,15 @@
identity_keys[n_ids] = public;
/* point to the original path, most likely the private key */
identity_files[n_ids] = xstrdup(filename);
+ identity_file_userprovided[n_ids] =
+ options.identity_file_userprovided[i];
n_ids++;
}
options.num_identity_files = n_ids;
memcpy(options.identity_files, identity_files, sizeof(identity_files));
memcpy(options.identity_keys, identity_keys, sizeof(identity_keys));
+ memcpy(options.identity_file_userprovided, identity_file_userprovided,
+ sizeof(identity_file_userprovided));
bzero(pwname, strlen(pwname));
xfree(pwname);
@jesboat
Copy link
Author

jesboat commented Aug 30, 2014

(user is missing one of the standard ~/.ssh/id_foo files)
&& (user has a PKCS11 library with keys present
    || (user has a certificate present for some other ~/.ssh/id_bar
        && the bar comes before foo))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment