| 25 |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 26 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 |
*/ |
*/ |
|
|
|
| 28 |
#include "key.h" |
#include "key.h" |
| 29 |
#include "kex.h" |
#include "kex.h" |
| 30 |
|
|
| 1871 |
return (ret); |
return (ret); |
| 1872 |
} |
} |
| 1873 |
|
|
| 1874 |
|
// Callback function |
| 1875 |
|
// |
| 1876 |
|
// argument: |
| 1877 |
|
// key: known_hostsに登録されている鍵 |
| 1878 |
|
// _ctx: サーバから送られてきた鍵候補群 |
| 1879 |
|
// |
| 1880 |
|
// return: |
| 1881 |
|
// 1: deprecated keyのため、呼び元でkey領域の解放禁止。 |
| 1882 |
|
// 0: 呼び元でのkey領域の解放が必要。 |
| 1883 |
|
static int hostkeys_find(Key *key, void *_ctx) |
| 1884 |
|
{ |
| 1885 |
|
struct hostkeys_update_ctx *ctx = (struct hostkeys_update_ctx *)_ctx; |
| 1886 |
|
int ret = 0; |
| 1887 |
|
size_t i; |
| 1888 |
|
Key **tmp; |
| 1889 |
|
|
| 1890 |
|
// SSH1は対象外。 |
| 1891 |
|
if (key->type == KEY_RSA1) |
| 1892 |
|
goto error; |
| 1893 |
|
|
| 1894 |
|
// すでに登録済みの鍵がないかを探す。 |
| 1895 |
|
for (i = 0; i < ctx->nkeys; i++) { |
| 1896 |
|
if (HOSTS_compare_public_key(key, ctx->keys[i]) == 1) { |
| 1897 |
|
ctx->keys_seen[i] = 1; |
| 1898 |
|
goto error; |
| 1899 |
|
} |
| 1900 |
|
} |
| 1901 |
|
|
| 1902 |
|
// deprecatedな鍵は、古いものリストに入れておく。 |
| 1903 |
|
tmp = realloc(ctx->old_keys, (ctx->nold + 1)*sizeof(*ctx->old_keys)); |
| 1904 |
|
if (tmp != NULL) { |
| 1905 |
|
ctx->old_keys = tmp; |
| 1906 |
|
ctx->old_keys[ctx->nold++] = key; |
| 1907 |
|
} |
| 1908 |
|
|
| 1909 |
|
ret = 1; |
| 1910 |
|
|
| 1911 |
|
error: |
| 1912 |
|
return (ret); |
| 1913 |
|
} |
| 1914 |
|
|
| 1915 |
// |
// |
| 1916 |
// SSHサーバホスト鍵(known_hosts)の自動更新(OpenSSH 6.8 or later: host key rotation support) |
// SSHサーバホスト鍵(known_hosts)の自動更新(OpenSSH 6.8 or later: host key rotation support) |
| 1917 |
// |
// |
| 2008 |
goto error; |
goto error; |
| 2009 |
} |
} |
| 2010 |
|
|
| 2011 |
//HOSTS_hostkey_foreach(pvar, NULL, ctx); |
if ((ctx->keys_seen = calloc(ctx->nkeys, sizeof(*ctx->keys_seen))) == NULL) { |
| 2012 |
|
_snprintf_s(msg, sizeof(msg), _TRUNCATE, "Not memory: calloc ctx->keys %d", |
| 2013 |
|
ctx->nkeys); |
| 2014 |
|
notify_verbose_message(pvar, msg, LOG_LEVEL_FATAL); |
| 2015 |
|
goto error; |
| 2016 |
|
} |
| 2017 |
|
|
| 2018 |
|
HOSTS_hostkey_foreach(pvar, hostkeys_find, ctx); |
| 2019 |
|
|
| 2020 |
success = 1; |
success = 1; |
| 2021 |
|
|