[Pvfs2-cvs] commit by nlmills in pvfs2/src/common/security: pint-security.c pint-security.h

CVS commit program cvs at parl.clemson.edu
Wed Dec 3 22:18:34 EST 2008


Update of /anoncvs/pvfs2/src/common/security
In directory parlweb1:/tmp/cvs-serv7146/src/common/security

Modified Files:
      Tag: cu-security-branch
	pint-security.c pint-security.h 
Log Message:
bug fixes


Index: pint-security.c
===================================================================
RCS file: /anoncvs/pvfs2/src/common/security/Attic/pint-security.c,v
diff -p -u -r1.1.2.51 -r1.1.2.52
--- pint-security.c	4 Dec 2008 02:22:12 -0000	1.1.2.51
+++ pint-security.c	4 Dec 2008 03:18:34 -0000	1.1.2.52
@@ -65,6 +65,8 @@ static void dyn_destroy_function(struct 
 
 #ifndef SECURITY_ENCRYPTION_NONE
 
+static gen_mutex_t lookup_groups_mutex = GEN_MUTEX_INITIALIZER;
+
 /* the private key used for signing */
 static EVP_PKEY *security_privkey = NULL;
 /* the store context used to verify client certificates */
@@ -545,7 +547,6 @@ int PINT_lookup_userid(const char *accou
     return 0;
 }
 
-/* TODO: make this function reentrant */
 int PINT_lookup_groups(const char *account, PVFS_gid **group_array,
         uint32_t *num_groups)
 {
@@ -555,12 +556,15 @@ int PINT_lookup_groups(const char *accou
     uint32_t ngroups;
     int i;
 
+    gen_mutex_lock(&lookup_groups_mutex);
+
     /* TODO: make the size a configurable constant */
     groups = (PVFS_gid*)calloc(32, sizeof(PVFS_gid));
     if (!groups)
     {
         *num_groups = 0;
         *group_array = NULL;
+        gen_mutex_unlock(&lookup_groups_mutex);
         return -PVFS_ENOMEM;
     }
 
@@ -570,6 +574,7 @@ int PINT_lookup_groups(const char *accou
         free(groups);
         *num_groups = 0;
         *group_array = NULL;
+        gen_mutex_unlock(&lookup_groups_mutex);
         return -PVFS_EINVAL;
     }
 
@@ -594,6 +599,7 @@ int PINT_lookup_groups(const char *accou
     *group_array = groups;
     *num_groups = ngroups;
 
+    gen_mutex_unlock(&lookup_groups_mutex);
     return 0;
 }
 
@@ -825,7 +831,7 @@ int PINT_sign_credential(PVFS_credential
     {
         gossip_debug(GOSSIP_SECURITY_DEBUG, "SignUpdate failure.\n");
         EVP_MD_CTX_cleanup(&mdctx);
-        return 0;
+        return -1;
     }
     
     ret = EVP_SignFinal(&mdctx, cred->signature, &cred->sig_size,
@@ -1095,7 +1101,6 @@ static int verify_callback(int ok, X509_
 
 /* TODO: consider logging matches for debugging configs */
 /* TODO: consider case-insensitve compare */
-/* TODO: fix for when emails is NULL */
 static const char *find_account(const char *subject, const STACK *emails)
 {
     const struct server_configuration_s *config;
@@ -1263,6 +1268,31 @@ int PINT_init_capability(PVFS_capability
             ret = -PVFS_ENOMEM;
         }
 #endif /* SECURITY_ENCRYPTION_NONE */
+    }
+    else
+    {
+        ret = -PVFS_EINVAL;
+    }
+
+    return ret;
+}
+
+int PINT_init_credential(PVFS_credential *cred)
+{
+    int ret = 0;
+
+    if (cred)
+    {
+        memset(cred, 0, sizeof(PVFS_credential));
+
+#ifndef SECURITY_ENCRYPTION_NONE
+        cred->signature =
+            (unsigned char*)calloc(1, EVP_PKEY_size(security_privkey));
+        if (cred->signature == NULL)
+        {
+            ret = -PVFS_ENOMEM;
+        }
+#endif /* !SECURITY_ENCRYPTION_NONE */
     }
     else
     {

Index: pint-security.h
===================================================================
RCS file: /anoncvs/pvfs2/src/common/security/Attic/pint-security.h,v
diff -p -u -r1.1.2.26 -r1.1.2.27
--- pint-security.h	4 Dec 2008 02:22:12 -0000	1.1.2.26
+++ pint-security.h	4 Dec 2008 03:18:34 -0000	1.1.2.27
@@ -81,6 +81,8 @@ int PINT_verify_credential (PVFS_credent
  */
 int PINT_init_capability(PVFS_capability *);
 
+int PINT_init_credential(PVFS_credential *);
+
 
 #endif
 



More information about the Pvfs2-cvs mailing list