[Openvas-commits] r13110 - in trunk/openvas-libraries: . omp

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Fri Mar 23 08:40:35 CET 2012


Author: mattm
Date: 2012-03-23 08:40:35 +0100 (Fri, 23 Mar 2012)
New Revision: 13110

Modified:
   trunk/openvas-libraries/ChangeLog
   trunk/openvas-libraries/omp/omp.c
   trunk/openvas-libraries/omp/omp.h
Log:
	* omp/omp.c (omp_create_lsc_credential_key): New function.

	* omp/omp.h: Add header accordingly.

Modified: trunk/openvas-libraries/ChangeLog
===================================================================
--- trunk/openvas-libraries/ChangeLog	2012-03-22 20:47:47 UTC (rev 13109)
+++ trunk/openvas-libraries/ChangeLog	2012-03-23 07:40:35 UTC (rev 13110)
@@ -1,3 +1,9 @@
+2012-03-23  Matthew Mundell <matthew.mundell at greenbone.net>
+
+	* omp/omp.c (omp_create_lsc_credential_key): New function.
+
+	* omp/omp.h: Add header accordingly.
+
 2012-03-21  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
 
 	* CMakeLists.txt: Fixed build for LDAP.
@@ -6,7 +12,7 @@
 
 	* CMakeLists.txt: Added check for LDAP library and make
 	LDAP default in case it is found. BUILD_WITHOUT_LDAP will
-	explicitely disable LDAP. 
+	explicitely disable LDAP.
 
 	* misc/CMakeLists.txt: Removed check for ldap library.
 

Modified: trunk/openvas-libraries/omp/omp.c
===================================================================
--- trunk/openvas-libraries/omp/omp.c	2012-03-22 20:47:47 UTC (rev 13109)
+++ trunk/openvas-libraries/omp/omp.c	2012-03-23 07:40:35 UTC (rev 13110)
@@ -2284,6 +2284,85 @@
 }
 
 /**
+ * @brief Create an LSC Credential with a key.
+ *
+ * @param[in]   session      Pointer to GNUTLS session.
+ * @param[in]   name         Name of LSC Credential.
+ * @param[in]   login        Login associated with name.
+ * @param[in]   passphrase   Passphrase for public key.
+ * @param[in]   public_key   Public key.
+ * @param[in]   private_key  Private key.
+ * @param[in]   comment      LSC Credential comment.
+ * @param[out]  uuid         Either NULL or address for UUID of created
+ *                           credential.
+ *
+ * @return 0 on success, -1 or OMP response code on error.
+ */
+int
+omp_create_lsc_credential_key (gnutls_session_t *session,
+                               const char *name,
+                               const char *login,
+                               const char *passphrase,
+                               const char *public_key,
+                               const char *private_key,
+                               const char *comment,
+                               char **uuid)
+{
+  int ret;
+
+  /* Create the OMP request. */
+
+  gchar* request;
+  if (comment)
+    request = g_markup_printf_escaped ("<create_lsc_credential>"
+                                       "<name>%s</name>"
+                                       "<login>%s</login>"
+                                       "<key>"
+                                       "<phrase>%s</phrase>"
+                                       "<public>%s</public>"
+                                       "<private>%s</private>"
+                                       "</key>"
+                                       "<comment>%s</comment>"
+                                       "</create_lsc_credential>",
+                                       name,
+                                       login,
+                                       passphrase
+                                        ? passphrase
+                                        : "",
+                                       public_key,
+                                       private_key,
+                                       comment);
+  else
+    request = g_markup_printf_escaped ("<create_lsc_credential>"
+                                       "<name>%s</name>"
+                                       "<login>%s</login>"
+                                       "<key>"
+                                       "<phrase>%s</phrase>"
+                                       "<public>%s</public>"
+                                       "<private>%s</private>"
+                                       "</key>"
+                                       "</create_lsc_credential>",
+                                       name,
+                                       login,
+                                       passphrase
+                                        ? passphrase
+                                        : "",
+                                       public_key,
+                                       private_key);
+
+  /* Send the request. */
+
+  ret = openvas_server_send (session, request);
+  g_free (request);
+  if (ret) return -1;
+
+  ret = omp_read_create_response (session, uuid);
+  if (ret == 201)
+    return 0;
+  return ret;
+}
+
+/**
  * @brief Delete a LSC credential.
  *
  * @param[in]   session     Pointer to GNUTLS session.

Modified: trunk/openvas-libraries/omp/omp.h
===================================================================
--- trunk/openvas-libraries/omp/omp.h	2012-03-22 20:47:47 UTC (rev 13109)
+++ trunk/openvas-libraries/omp/omp.h	2012-03-23 07:40:35 UTC (rev 13110)
@@ -144,6 +144,10 @@
 int omp_create_lsc_credential (gnutls_session_t *, const char *, const char *,
                                const char *, const char *, char **);
 
+int omp_create_lsc_credential_key (gnutls_session_t *, const char *,
+                                   const char *, const char *, const char *,
+                                   const char *, const char *, char **);
+
 int omp_delete_lsc_credential (gnutls_session_t *, const char *);
 
 int omp_create_agent (gnutls_session_t *, const char *, const char *);



More information about the Openvas-commits mailing list