[Pvfs2-cvs] commit by nlmills in pvfs2/src/common/security:
pint-security.c security-hash.c
CVS commit program
cvs at parl.clemson.edu
Thu May 15 16:37:15 EDT 2008
Update of /anoncvs/pvfs2/src/common/security
In directory parlweb1:/tmp/cvs-serv12428/src/common/security
Modified Files:
Tag: cu-security-branch
pint-security.c security-hash.c
Log Message:
improved error handling
Index: pint-security.c
===================================================================
RCS file: /anoncvs/pvfs2/src/common/security/Attic/pint-security.c,v
diff -p -u -r1.1.2.5 -r1.1.2.6
--- pint-security.c 15 May 2008 20:07:33 -0000 1.1.2.5
+++ pint-security.c 15 May 2008 20:37:14 -0000 1.1.2.6
@@ -15,6 +15,7 @@
#include <openssl/pem.h>
#include "pvfs2.h"
+#include "pvfs2-types.h"
#include "pint-eattr.h"
#include "pvfs2-req-proto.h"
#include "pvfs2-internal.h"
@@ -40,26 +41,35 @@ static int lookup_host_handle(uint32_t*,
int PINT_security_initialize(void)
{
+ int ret;
+
gen_mutex_lock(&security_init_mutex);
if (security_init_status)
{
gen_mutex_unlock(&security_init_mutex);
- return -1;
+ return -PVFS_EALREADY;
}
ERR_load_crypto_strings();
OpenSSL_add_all_algorithms();
- /* TODO: return value */
- if (SECURITY_hash_initialize() == -1)
- return -1;
+ ret = SECURITY_hash_initialize();
+ if (ret < 0)
+ {
+ return ret;
+ }
- load_public_keys(SECURITY_DEFAULT_KEYSTORE);
+ /* TODO: better error handling */
+ ret = load_public_keys(SECURITY_DEFAULT_KEYSTORE);
+ if (ret < 0)
+ {
+ return -PVFS_EIO;
+ }
security_init_status = 1;
gen_mutex_unlock(&security_init_mutex);
- return 1;
+ return 0;
}
int PINT_security_finalize(void)
@@ -68,7 +78,7 @@ int PINT_security_finalize(void)
if (!security_init_status)
{
gen_mutex_unlock(&security_init_mutex);
- return -1;
+ return -PVFS_EALREADY;
}
EVP_cleanup();
@@ -78,7 +88,7 @@ int PINT_security_finalize(void)
security_init_status = 0;
gen_mutex_unlock(&security_init_mutex);
- return 1;
+ return 0;
}
static int load_public_keys(char *path)
@@ -136,16 +146,17 @@ static int load_public_keys(char *path)
}
ret = lookup_host_handle(&host, buf);
- if (ret == -1)
+ if (ret < 0)
{
- return -1;
+ fclose(keyfile);
+ return -2;
}
- /* add to hash; return value */
ret = SECURITY_add_pubkey(host, key);
- if (ret == -1)
+ if (ret < 0)
{
- return -1;
+ fclose(keyfile);
+ return -3;
}
}
Index: security-hash.c
===================================================================
RCS file: /anoncvs/pvfs2/src/common/security/Attic/security-hash.c,v
diff -p -u -r1.1.2.8 -r1.1.2.9
--- security-hash.c 15 May 2008 20:07:33 -0000 1.1.2.8
+++ security-hash.c 15 May 2008 20:37:15 -0000 1.1.2.9
@@ -42,7 +42,7 @@ int SECURITY_hash_initialize(void)
if (hash_init_status)
{
gen_mutex_unlock(&hash_mutex);
- return -1;
+ return -PVFS_EALREADY;
}
pubkey_table = qhash_init(pubkey_compare, quickhash_32bit_hash,
@@ -51,7 +51,7 @@ int SECURITY_hash_initialize(void)
if (pubkey_table == NULL)
{
gen_mutex_unlock(&hash_mutex);
- return -1;
+ return -PVFS_ENOMEM;
}
hash_init_status = 1;
@@ -85,7 +85,7 @@ int SECURITY_add_pubkey(uint32_t host, E
entry = (pubkey_entry_t *)malloc(sizeof(pubkey_entry_t));
if (entry == NULL)
{
- return -1;
+ return -PVFS_ENOMEM;
}
entry->host = host;
More information about the Pvfs2-cvs
mailing list