X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=crypt_common.c;h=1fd8189ca3c5a201bd2d227bb366bd800757a5a5;hp=b39ee5e4cb6fce2b28a3b87034350f321d7cd75d;hb=52fb766fd183e555d8c85185e35a4dc365097756;hpb=9165680a9639a8412adef13b96e466efdbb9d806 diff --git a/crypt_common.c b/crypt_common.c index b39ee5e4..1fd8189c 100644 --- a/crypt_common.c +++ b/crypt_common.c @@ -96,32 +96,29 @@ int check_ssh_key_header(const unsigned char *blob, int blen) return -E_SSH_KEY_HEADER; if (rlen < strlen(KEY_TYPE_TXT)) return -E_SSH_KEY_HEADER; - PARA_DEBUG_LOG("type: %s, rlen: %d\n", p, rlen); + PARA_DEBUG_LOG("type: %s, rlen: %u\n", p, rlen); if (strncmp((char *)p, KEY_TYPE_TXT, strlen(KEY_TYPE_TXT))) return -E_SSH_KEY_HEADER; return 4 + rlen; } /** - * Check existence and permissions of a key file. + * Check existence and permissions of a private key file. * * \param file The path of the key file. - * \param private_key Whether this is a private key. * - * This checks whether the file exists. If it is a private key, we additionally - * check that the permissions are restrictive enough. It is considered an error - * if we own the file and it is readable for others. + * This checks whether the file exists and its permissions are restrictive + * enough. It is considered an error if we own the file and it is readable for + * others. * * \return Standard. */ -int check_key_file(const char *file, bool private_key) +int check_private_key_file(const char *file) { struct stat st; if (stat(file, &st) != 0) return -ERRNO_TO_PARA_ERROR(errno); - if (!private_key) - return 0; if ((st.st_uid == getuid()) && (st.st_mode & 077) != 0) return -E_KEY_PERM; return 1;