[SCM] Samba Shared Repository - branch v3-3-test updated -
release-3-2-0pre2-3444-g9710619
Günther Deschner
gd at samba.org
Wed Jul 30 14:43:28 GMT 2008
The branch, v3-3-test has been updated
via 97106199f1a2add886a14523aa7b402667d2cd89 (commit)
via 87b6aac13598a2ac28054de5ab90d63bef65f1fe (commit)
from ff9bcd57738aa04c5e18e0e21dd0e788127317c4 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-3-test
- Log -----------------------------------------------------------------
commit 97106199f1a2add886a14523aa7b402667d2cd89
Author: Günther Deschner <gd at samba.org>
Date: Fri Jul 18 20:43:14 2008 +0200
netapi: use init_samr_CryptPasswordEx and init_samr_CryptPassword.
Guenther
commit 87b6aac13598a2ac28054de5ab90d63bef65f1fe
Author: Günther Deschner <gd at samba.org>
Date: Fri Jul 18 20:42:55 2008 +0200
rpc_client: add init_samr_CryptPasswordEx and init_samr_CryptPassword.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source/include/proto.h | 6 +++++
source/lib/netapi/user.c | 34 ++++++++----------------------
source/rpc_client/init_samr.c | 46 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+), 25 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/include/proto.h b/source/include/proto.h
index bf3adb5..7e70f3c 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -7574,6 +7574,12 @@ void init_samr_user_info23(struct samr_UserInfo23 *r,
void init_samr_user_info24(struct samr_UserInfo24 *r,
uint8_t data[516],
uint8_t pw_len);
+void init_samr_CryptPasswordEx(const char *pwd,
+ DATA_BLOB *session_key,
+ struct samr_CryptPasswordEx *pwd_buf);
+void init_samr_CryptPassword(const char *pwd,
+ DATA_BLOB *session_key,
+ struct samr_CryptPassword *pwd_buf);
/* The following definitions come from rpc_client/init_srvsvc.c */
diff --git a/source/lib/netapi/user.c b/source/lib/netapi/user.c
index fe30b14..e36274b 100644
--- a/source/lib/netapi/user.c
+++ b/source/lib/netapi/user.c
@@ -292,29 +292,12 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
if (uX.usriX_password) {
- uchar pwbuf[532];
- struct MD5Context md5_ctx;
- uint8_t confounder[16];
- DATA_BLOB confounded_session_key = data_blob(NULL, 16);
-
- encode_pw_buffer(pwbuf, uX.usriX_password, STR_UNICODE);
-
- generate_random_buffer((uint8_t *)confounder, 16);
-
- MD5Init(&md5_ctx);
- MD5Update(&md5_ctx, confounder, 16);
- MD5Update(&md5_ctx, cli->user_session_key.data,
- cli->user_session_key.length);
- MD5Final(confounded_session_key.data, &md5_ctx);
-
- SamOEMhashBlob(pwbuf, 516, &confounded_session_key);
- memcpy(&pwbuf[516], confounder, 16);
-
- memcpy(user_info->info25.password.data, pwbuf, sizeof(pwbuf));
- data_blob_free(&confounded_session_key);
-
user_info->info25.info = info21;
+ init_samr_CryptPasswordEx(uX.usriX_password,
+ &cli->user_session_key,
+ &user_info->info25.password);
+
status = rpccli_samr_SetUserInfo2(pipe_cli, ctx,
&user_handle,
25,
@@ -324,10 +307,9 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
user_info->info23.info = info21;
- encode_pw_buffer(user_info->info23.password.data,
- uX.usriX_password, STR_UNICODE);
- SamOEMhashBlob(user_info->info23.password.data, 516,
- &cli->user_session_key);
+ init_samr_CryptPassword(uX.usriX_password,
+ &cli->user_session_key,
+ &user_info->info23.password);
status = rpccli_samr_SetUserInfo2(pipe_cli, ctx,
&user_handle,
@@ -335,7 +317,9 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
user_info);
}
} else {
+
user_info->info21 = info21;
+
status = rpccli_samr_SetUserInfo(pipe_cli, ctx,
&user_handle,
21,
diff --git a/source/rpc_client/init_samr.c b/source/rpc_client/init_samr.c
index c5d7dcd..2e75753 100644
--- a/source/rpc_client/init_samr.c
+++ b/source/rpc_client/init_samr.c
@@ -460,3 +460,49 @@ void init_samr_user_info24(struct samr_UserInfo24 *r,
memcpy(r->password.data, data, sizeof(r->password.data));
r->pw_len = pw_len;
}
+
+/*************************************************************************
+ inits a samr_CryptPasswordEx structure
+ *************************************************************************/
+
+void init_samr_CryptPasswordEx(const char *pwd,
+ DATA_BLOB *session_key,
+ struct samr_CryptPasswordEx *pwd_buf)
+{
+ /* samr_CryptPasswordEx */
+
+ uchar pwbuf[532];
+ struct MD5Context md5_ctx;
+ uint8_t confounder[16];
+ DATA_BLOB confounded_session_key = data_blob(NULL, 16);
+
+ encode_pw_buffer(pwbuf, pwd, STR_UNICODE);
+
+ generate_random_buffer((uint8_t *)confounder, 16);
+
+ MD5Init(&md5_ctx);
+ MD5Update(&md5_ctx, confounder, 16);
+ MD5Update(&md5_ctx, session_key->data,
+ session_key->length);
+ MD5Final(confounded_session_key.data, &md5_ctx);
+
+ SamOEMhashBlob(pwbuf, 516, &confounded_session_key);
+ memcpy(&pwbuf[516], confounder, 16);
+
+ memcpy(pwd_buf->data, pwbuf, sizeof(pwbuf));
+ data_blob_free(&confounded_session_key);
+}
+
+/*************************************************************************
+ inits a samr_CryptPassword structure
+ *************************************************************************/
+
+void init_samr_CryptPassword(const char *pwd,
+ DATA_BLOB *session_key,
+ struct samr_CryptPassword *pwd_buf)
+{
+ /* samr_CryptPassword */
+
+ encode_pw_buffer(pwd_buf->data, pwd, STR_UNICODE);
+ SamOEMhashBlob(pwd_buf->data, 516, session_key);
+}
--
Samba Shared Repository
More information about the samba-cvs
mailing list