s3:netapi: Implement public libnetapi_get_(username|password) functions
authorAndreas Schneider <asn@samba.org>
Thu, 18 Mar 2021 08:59:08 +0000 (09:59 +0100)
committerGünther Deschner <gd@samba.org>
Wed, 24 Mar 2021 00:55:32 +0000 (00:55 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source3/lib/netapi/netapi.c
source3/lib/netapi/netapi.h
source3/lib/netapi/netapi_private.h
source3/wscript_build

index fb8b4bc61136031b723a98943b42c6c27efce7a2..820dd8ac6e01a762ba1860fb1a6c81e85182429c 100644 (file)
@@ -227,6 +227,52 @@ NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx,
 /****************************************************************
 ****************************************************************/
 
+/**
+ * @brief Get the username of the libnet context
+ *
+ * @param[in]  ctx      The netapi context
+ *
+ * @param[in]  username A pointer to hold the username.
+ *
+ * @return 0 on success, an werror code otherwise.
+ */
+NET_API_STATUS libnetapi_get_username(struct libnetapi_ctx *ctx,
+                                     const char **username)
+{
+       if (ctx == NULL) {
+               return W_ERROR_V(WERR_INVALID_PARAMETER);
+       }
+
+       if (username != NULL) {
+               *username = ctx->username;
+       }
+
+       return NET_API_STATUS_SUCCESS;
+}
+
+/**
+ * @brief Get the password of the libnet context
+ *
+ * @param[in]  ctx      The netapi context
+ *
+ * @param[in]  password A pointer to hold the password.
+ *
+ * @return 0 on success, an werror code otherwise.
+ */
+NET_API_STATUS libnetapi_get_password(struct libnetapi_ctx *ctx,
+                                     const char **password)
+{
+       if (ctx == NULL) {
+               return W_ERROR_V(WERR_INVALID_PARAMETER);
+       }
+
+       if (password != NULL) {
+               *password = ctx->password;
+       }
+
+       return NET_API_STATUS_SUCCESS;
+}
+
 NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx,
                                      const char *username)
 {
index 6fc539c8f6f09400c2aea1ad947d4ea610b0c4ae..b7fdb752a79199c5fa3a44ac5deffd2ade37a74b 100644 (file)
@@ -1391,6 +1391,12 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx);
 
 NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx);
 
+NET_API_STATUS libnetapi_get_username(struct libnetapi_ctx *ctx,
+                                     const char **username);
+
+NET_API_STATUS libnetapi_get_password(struct libnetapi_ctx *ctx,
+                                     const char **password);
+
 /****************************************************************
 ****************************************************************/
 
index 4d028251c43a75d234d017c6107b980b0358b4d0..998d2b2b634524419f69a446936c49fed3eceeb4 100644 (file)
@@ -53,8 +53,6 @@ struct libnetapi_private_ctx {
        struct messaging_context *msg_ctx;
 };
 
-NET_API_STATUS libnetapi_get_password(struct libnetapi_ctx *ctx, char **password);
-NET_API_STATUS libnetapi_get_username(struct libnetapi_ctx *ctx, char **username);
 NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx,
                                          const char *format, ...)
                                          PRINTF_ATTRIBUTE(2,3);
index e70491f6d70a9db2e3ec4f099bdaf217093ef7d1..f34ebe1467638c4c8335e9de0228d1109b3788b3 100644 (file)
@@ -42,7 +42,7 @@ bld.SAMBA3_LIBRARY('netapi',
                     ''',
                     public_headers='../source3/lib/netapi/netapi.h',
                     pc_files='libnet/netapi.pc',
-                    vnum='0')
+                    vnum='0.1.0')
 
 bld.SAMBA3_LIBRARY('gse',
                    source='librpc/crypto/gse_krb5.c librpc/crypto/gse.c',