From bc3a20e9d8cec0b0b402e922214fc5a7f08e785e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 18 Aug 2004 12:47:08 +0000 Subject: r1879: - add a user sub struct in net_context - add 'net password change' command (it doesn'T work yet because libnet_rpc_connect() isn't implemented yet, and we don't fill in the net_context user substruct yet) metze (This used to be commit 939da063cdf18a5ab7e7f0490ac58d1f138cf0f0) --- source4/utils/net/net_password.c | 100 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 source4/utils/net/net_password.c (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c new file mode 100644 index 0000000000..90f26924a6 --- /dev/null +++ b/source4/utils/net/net_password.c @@ -0,0 +1,100 @@ +/* + Samba Unix/Linux SMB client library + Distributed SMB/CIFS Server Management Utility + + Copyright (C) 2004 Stefan Metzmacher (metze@samba.org) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* + * Code for Changing and setting a password + */ + + +static int net_password_change(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + union libnet_ChangePassword r; + char *password_prompt = NULL; + const char *new_password; + + if (argc > 0 && argv[0]) { + new_password = argv[0]; + } else { + password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for %s:", ctx->user.account_name); + new_password = getpass(password_prompt); + } + + libnetctx = libnet_context_init(); + if (!libnetctx) { + return -1; + } + + /* prepare password change */ + r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; + r.generic.in.account_name = ctx->user.account_name; + r.generic.in.domain_name = ctx->user.domain_name; + r.generic.in.oldpassword = ctx->user.password; + r.generic.in.newpassword = new_password; + + /* do password change */ + status = libnet_ChangePassword(libnetctx, ctx->mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("net_password_change: %s\n",r.generic.out.error_string)); + return -1; + } + + libnet_context_destroy(&libnetctx); + + return 0; +} + +static int net_password_change_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_change_usage: TODO\n"); + return 0; +} + +static int net_password_change_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_change_help: TODO\n"); + return 0; +} + +static const struct net_functable const net_password_functable[] = { + {"change", net_password_change, net_password_change_usage, net_password_change_help}, + {NULL, NULL} +}; + +int net_password(struct net_context *ctx, int argc, const char **argv) +{ + return net_run_function(ctx, argc, argv, net_password_functable, net_password_usage); +} + +int net_password_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_usage: TODO\n"); + return 0; +} + +int net_password_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_help: TODO\n"); + return 0; +} -- cgit From 124e00068f2187e254f76cd82e913809870d799c Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 19 Aug 2004 12:36:05 +0000 Subject: r1915: use popt's cmdline_auth_info to fill the net_context and print the user domain when prompting for a new password metze (This used to be commit aedb2e9e1c418a7ac3cc18299707ae9146e4047a) --- source4/utils/net/net_password.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 90f26924a6..c9c549fcff 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -37,7 +37,8 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a if (argc > 0 && argv[0]) { new_password = argv[0]; } else { - password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for %s:", ctx->user.account_name); + password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", + ctx->user.domain_name, ctx->user.account_name); new_password = getpass(password_prompt); } -- cgit From 9d62046b0e09fa7a4a660859dd8651e6d60c8dc8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 19 Aug 2004 13:32:06 +0000 Subject: r1919: paasword change basicly works now:-) but we need to find the real pdc for the users domain and fallback to other levels metze (This used to be commit f1b9c1f3dd0fb927c065541da900ae43e0018a62) --- source4/utils/net/net_password.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index c9c549fcff..9daa3f401f 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -46,6 +46,9 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a if (!libnetctx) { return -1; } + libnetctx->user.account_name = ctx->user.account_name; + libnetctx->user.domain_name = ctx->user.domain_name; + libnetctx->user.password = ctx->user.password; /* prepare password change */ r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; -- cgit From 32ec317c900efb104f7a7828898cbfdef0609c2a Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 20 Aug 2004 09:55:21 +0000 Subject: r1951: add 'net password set' call use it like: net password set user net password set DOM\\user net password set user pass net password set DOM\\user pass net password set -U DOM\\Administrator%admpass DOM\\user pass metze (This used to be commit b660e5b9e6236c996550973e9bde1e80a8eed775) --- source4/utils/net/net_password.c | 82 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 9daa3f401f..5da18d94b5 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -81,8 +81,90 @@ static int net_password_change_help(struct net_context *ctx, int argc, const cha return 0; } +static int net_password_set(struct net_context *ctx, int argc, const char **argv) +{ + NTSTATUS status; + struct libnet_context *libnetctx; + union libnet_SetPassword r; + char *password_prompt = NULL; + char *p; + char *tmp; + const char *account_name; + const char *domain_name; + const char *new_password = NULL; + + switch (argc) { + case 0: /* no args -> fail */ + DEBUG(0,("net_password_set: no args\n")); + return -1; + case 1: /* only DOM\\user; prompt for password */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + break; + case 2: /* DOM\\USER and password */ + tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + new_password = argv[1]; + break; + default: /* too mayn args -> fail */ + DEBUG(0,("net_password_set: too many args [%d]\n",argc)); + return -1; + } + + if ((p = strchr_m(tmp,'\\'))) { + *p = 0; + domain_name = tmp; + account_name = talloc_strdup(ctx->mem_ctx, p+1); + } else { + account_name = tmp; + domain_name = ctx->user.domain_name; + } + + if (!new_password) { + password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", + domain_name, account_name); + new_password = getpass(password_prompt); + } + + libnetctx = libnet_context_init(); + if (!libnetctx) { + return -1; + } + libnetctx->user.account_name = ctx->user.account_name; + libnetctx->user.domain_name = ctx->user.domain_name; + libnetctx->user.password = ctx->user.password; + + /* prepare password change */ + r.generic.level = LIBNET_SET_PASSWORD_GENERIC; + r.generic.in.account_name = account_name; + r.generic.in.domain_name = domain_name; + r.generic.in.newpassword = new_password; + + /* do password change */ + status = libnet_SetPassword(libnetctx, ctx->mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0,("net_password_set: %s\n",r.generic.out.error_string)); + return -1; + } + + libnet_context_destroy(&libnetctx); + + return 0; +} + +static int net_password_set_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_set_usage: TODO\n"); + return 0; +} + +static int net_password_set_help(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_set_help: TODO\n"); + return 0; +} + static const struct net_functable const net_password_functable[] = { {"change", net_password_change, net_password_change_usage, net_password_change_help}, + {"set", net_password_set, net_password_set_usage, net_password_set_help}, {NULL, NULL} }; -- cgit From 6148deca663f7b6504b044120b166d6c9ae28750 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 03:13:06 +0000 Subject: r3454: moved a few more things out if includes.h into the include/system/ include files. this brings us down to about 11k lines of headers included with includes.h, while still retaining the speed of building with pch (This used to be commit 10188869ef072309ca580b8b933e172571fcdda7) --- source4/utils/net/net_password.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 5da18d94b5..01682bd506 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -20,6 +20,7 @@ */ #include "includes.h" +#include "system/passwd.h" /* * Code for Changing and setting a password -- cgit From 6bd02aa5046b606171a680e6f8aefba31b744af1 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 2 Nov 2004 11:42:35 +0000 Subject: r3478: split out some more pieces of includes.h (This used to be commit 8e9212ecfc61c509f686363d8ec412ce54bc1c8d) --- source4/utils/net/net_password.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 01682bd506..14b48e301e 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -20,6 +20,8 @@ */ #include "includes.h" +#include "utils/net/net.h" +#include "libnet/libnet.h" #include "system/passwd.h" /* -- cgit From a42bbe3cdffe8f0cfdf19583c981f1a18e4cc331 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 23 Dec 2004 04:09:25 +0000 Subject: r4341: Fix const warning. (This used to be commit d8b1ba93a8ed0d5d01cb05b1c14353a0eca4de3e) --- source4/utils/net/net_password.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 14b48e301e..8828b960ee 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -165,7 +165,7 @@ static int net_password_set_help(struct net_context *ctx, int argc, const char * return 0; } -static const struct net_functable const net_password_functable[] = { +static const struct net_functable net_password_functable[] = { {"change", net_password_change, net_password_change_usage, net_password_change_help}, {"set", net_password_set, net_password_set_usage, net_password_set_help}, {NULL, NULL} -- cgit From e82aad1ce39a6b7a2e51b9e2cb494d74ec70e158 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 10 Feb 2005 05:09:35 +0000 Subject: r5298: - got rid of pstring.h from includes.h. This at least makes it a bit less likely that anyone will use pstring for new code - got rid of winbind_client.h from includes.h. This one triggered a huge change, as winbind_client.h was including system/filesys.h and defining the old uint32 and uint16 types, as well as its own pstring and fstring. (This used to be commit 9db6c79e902ec538108d6b7d3324039aabe1704f) --- source4/utils/net/net_password.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 8828b960ee..773e18d661 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -22,6 +22,7 @@ #include "includes.h" #include "utils/net/net.h" #include "libnet/libnet.h" +#include "system/filesys.h" #include "system/passwd.h" /* -- cgit From 530d46f6748a17ca8500a861f53c0d4f451b2005 Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Tue, 15 Feb 2005 01:11:20 +0000 Subject: r5400: Slightly better handling of help messages in net tool. rafal (This used to be commit 5cebb4feedf7d6542c497fe55763d66f51b1c989) --- source4/utils/net/net_password.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 773e18d661..fdc1a2e9a0 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -29,7 +29,6 @@ * Code for Changing and setting a password */ - static int net_password_change(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; @@ -99,8 +98,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv switch (argc) { case 0: /* no args -> fail */ - DEBUG(0,("net_password_set: no args\n")); - return -1; + return net_password_usage(ctx, argc, argv); case 1: /* only DOM\\user; prompt for password */ tmp = talloc_strdup(ctx->mem_ctx, argv[0]); break; @@ -110,7 +108,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv break; default: /* too mayn args -> fail */ DEBUG(0,("net_password_set: too many args [%d]\n",argc)); - return -1; + return net_password_usage(ctx, argc, argv); } if ((p = strchr_m(tmp,'\\'))) { @@ -169,6 +167,7 @@ static int net_password_set_help(struct net_context *ctx, int argc, const char * static const struct net_functable net_password_functable[] = { {"change", net_password_change, net_password_change_usage, net_password_change_help}, {"set", net_password_set, net_password_set_usage, net_password_set_help}, + {"help", net_password_help, net_password_help, net_password_help}, {NULL, NULL} }; @@ -179,12 +178,14 @@ int net_password(struct net_context *ctx, int argc, const char **argv) int net_password_usage(struct net_context *ctx, int argc, const char **argv) { - d_printf("net_password_usage: TODO\n"); + d_printf("net password [options]\n"); return 0; } int net_password_help(struct net_context *ctx, int argc, const char **argv) { - d_printf("net_password_help: TODO\n"); + d_printf("Account password handling:\n"); + d_printf("\tchange\t\tchanges password (old password required)\n"); + d_printf("\tset\t\tsets password\n"); return 0; } -- cgit From 308c7d26c1f9f91ff6667430a8a1a7b4cf4a3a7e Mon Sep 17 00:00:00 2001 From: Rafal Szczesniak Date: Wed, 16 Feb 2005 21:54:01 +0000 Subject: r5425: Convert function tables to new structure (with description) and remove unnecessary help functions as help is generated automatically. Usage functions with precise information about usage of each leaf node remain. rafal (This used to be commit eb66180d14a14cafbfc0df2b39eeaf4ad7bb43a9) --- source4/utils/net/net_password.c | 43 ++++++++++++---------------------------- 1 file changed, 13 insertions(+), 30 deletions(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index fdc1a2e9a0..ee0376989d 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -29,6 +29,13 @@ * Code for Changing and setting a password */ +static int net_password_change_usage(struct net_context *ctx, int argc, const char **argv) +{ + d_printf("net_password_change_usage: TODO\n"); + return 0; +} + + static int net_password_change(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; @@ -72,18 +79,14 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a return 0; } -static int net_password_change_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_password_change_usage: TODO\n"); - return 0; -} -static int net_password_change_help(struct net_context *ctx, int argc, const char **argv) +static int net_password_set_usage(struct net_context *ctx, int argc, const char **argv) { - d_printf("net_password_change_help: TODO\n"); + d_printf("net_password_set_usage: TODO\n"); return 0; } + static int net_password_set(struct net_context *ctx, int argc, const char **argv) { NTSTATUS status; @@ -98,7 +101,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv switch (argc) { case 0: /* no args -> fail */ - return net_password_usage(ctx, argc, argv); + return net_password_set_usage(ctx, argc, argv); case 1: /* only DOM\\user; prompt for password */ tmp = talloc_strdup(ctx->mem_ctx, argv[0]); break; @@ -152,22 +155,10 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv return 0; } -static int net_password_set_usage(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_password_set_usage: TODO\n"); - return 0; -} - -static int net_password_set_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("net_password_set_help: TODO\n"); - return 0; -} static const struct net_functable net_password_functable[] = { - {"change", net_password_change, net_password_change_usage, net_password_change_help}, - {"set", net_password_set, net_password_set_usage, net_password_set_help}, - {"help", net_password_help, net_password_help, net_password_help}, + {"change", "change password (old password required)\n", net_password_change, net_password_change_usage }, + {"set", "set password\n", net_password_set, net_password_set_usage }, {NULL, NULL} }; @@ -181,11 +172,3 @@ int net_password_usage(struct net_context *ctx, int argc, const char **argv) d_printf("net password [options]\n"); return 0; } - -int net_password_help(struct net_context *ctx, int argc, const char **argv) -{ - d_printf("Account password handling:\n"); - d_printf("\tchange\t\tchanges password (old password required)\n"); - d_printf("\tset\t\tsets password\n"); - return 0; -} -- cgit From 02075be0bbc2095073f8898350fded64a7c97c79 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 02:08:38 +0000 Subject: r5917: First step in using the new cli_credentials structure. This patch puts support for it into popt_common, adds a few utility functions (in lib/credentials.c) and the callback functions for the command-line (lib/cmdline/credentials.c). Comments are welcome :-) (This used to be commit 1d49b57c50fe8c2683ea23e9df41ce8ad774db98) --- source4/utils/net/net_password.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index ee0376989d..a68c0b1c6a 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -48,7 +48,8 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a new_password = argv[0]; } else { password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", - ctx->user.domain_name, ctx->user.account_name); + cli_credentials_get_domain(ctx->credentials), + cli_credentials_get_username(ctx->credentials)); new_password = getpass(password_prompt); } @@ -56,15 +57,15 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a if (!libnetctx) { return -1; } - libnetctx->user.account_name = ctx->user.account_name; - libnetctx->user.domain_name = ctx->user.domain_name; - libnetctx->user.password = ctx->user.password; + libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); + libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); + libnetctx->user.password = cli_credentials_get_password(ctx->credentials); /* prepare password change */ r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; - r.generic.in.account_name = ctx->user.account_name; - r.generic.in.domain_name = ctx->user.domain_name; - r.generic.in.oldpassword = ctx->user.password; + r.generic.in.account_name = cli_credentials_get_username(ctx->credentials); + r.generic.in.domain_name = cli_credentials_get_domain(ctx->credentials); + r.generic.in.oldpassword = cli_credentials_get_password(ctx->credentials); r.generic.in.newpassword = new_password; /* do password change */ @@ -120,7 +121,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv account_name = talloc_strdup(ctx->mem_ctx, p+1); } else { account_name = tmp; - domain_name = ctx->user.domain_name; + domain_name = cli_credentials_get_domain(ctx->credentials); } if (!new_password) { @@ -133,9 +134,9 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv if (!libnetctx) { return -1; } - libnetctx->user.account_name = ctx->user.account_name; - libnetctx->user.domain_name = ctx->user.domain_name; - libnetctx->user.password = ctx->user.password; + libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); + libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); + libnetctx->user.password = cli_credentials_get_password(ctx->credentials); /* prepare password change */ r.generic.level = LIBNET_SET_PASSWORD_GENERIC; -- cgit From 34cde065139fdc76f6aa529426cfc1f68a394d54 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 21 Mar 2005 18:42:32 +0000 Subject: r5924: Use cli_credentials in libnet/. (This used to be commit e5bc6f4f1716568ae7022d61b5b35ee047b58414) --- source4/utils/net/net_password.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index a68c0b1c6a..08660fe2a0 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -57,9 +57,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a if (!libnetctx) { return -1; } - libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); - libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); - libnetctx->user.password = cli_credentials_get_password(ctx->credentials); + libnetctx->credentials = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; @@ -134,9 +132,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv if (!libnetctx) { return -1; } - libnetctx->user.account_name= cli_credentials_get_username(ctx->credentials); - libnetctx->user.domain_name = cli_credentials_get_domain(ctx->credentials); - libnetctx->user.password = cli_credentials_get_password(ctx->credentials); + libnetctx->credentials = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_SET_PASSWORD_GENERIC; -- cgit From 0a40093ef39a46b9df82d6d0486b70b354d9dde5 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 3 Jun 2005 21:30:07 +0000 Subject: r7249: Cope with struct member rename (This used to be commit e7549f33f5fb06d8b2a8f31745545cc7b9c8d4f9) --- source4/utils/net/net_password.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 08660fe2a0..68fe9223a1 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -57,7 +57,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a if (!libnetctx) { return -1; } - libnetctx->credentials = ctx->credentials; + libnetctx->cred = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; @@ -132,7 +132,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv if (!libnetctx) { return -1; } - libnetctx->credentials = ctx->credentials; + libnetctx->cred = ctx->credentials; /* prepare password change */ r.generic.level = LIBNET_SET_PASSWORD_GENERIC; -- cgit From af237084ecd4f9928c6c282b9c5c73598d5c73d6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 16 Jun 2005 11:36:09 +0000 Subject: r7633: this patch started as an attempt to make the dcerpc code use a given event_context for the socket_connect() call, so that when things that use dcerpc are running alongside anything else it doesn't block the whole process during a connect. Then of course I needed to change any code that created a dcerpc connection (such as the auth code) to also take an event context, and anything that called that and so on .... thus the size of the patch. There were 3 places where I punted: - abartlet wanted me to add a gensec_set_event_context() call instead of adding it to the gensec init calls. Andrew, my apologies for not doing this. I didn't do it as adding a new parameter allowed me to catch all the callers with the compiler. Now that its done, we could go back and use gensec_set_event_context() - the ejs code calls auth initialisation, which means it should pass in the event context from the web server. I punted on that. Needs fixing. - I used a NULL event context in dcom_get_pipe(). This is equivalent to what we did already, but should be fixed to use a callers event context. Jelmer, can you think of a clean way to do that? I also cleaned up a couple of things: - libnet_context_destroy() makes no sense. I removed it. - removed some unused vars in various places (This used to be commit 3a3025485bdb8f600ab528c0b4b4eef0c65e3fc9) --- source4/utils/net/net_password.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 68fe9223a1..1912beeb41 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -53,7 +53,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(); + libnetctx = libnet_context_init(NULL); if (!libnetctx) { return -1; } @@ -73,7 +73,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a return -1; } - libnet_context_destroy(&libnetctx); + talloc_free(libnetctx); return 0; } @@ -128,7 +128,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(); + libnetctx = libnet_context_init(NULL); if (!libnetctx) { return -1; } @@ -147,7 +147,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv return -1; } - libnet_context_destroy(&libnetctx); + talloc_free(libnetctx); return 0; } -- cgit From 24186a80eb4887b5fb3e72e4b877b456cbe8e35f Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Mon, 29 Aug 2005 04:30:22 +0000 Subject: r9728: A *major* update to the credentials system, to incorporate the Kerberos CCACHE into the system. This again allows the use of the system ccache when no username is specified, and brings more code in common between gensec_krb5 and gensec_gssapi. It also has a side-effect that may (or may not) be expected: If there is a ccache, even if it is not used (perhaps the remote server didn't want kerberos), it will change the default username. Andrew Bartlett (This used to be commit 6202267f6ec1446d6bd11d1d37d05a977bc8d315) --- source4/utils/net/net_password.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 1912beeb41..0bfb8a5be8 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -49,7 +49,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a } else { password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", cli_credentials_get_domain(ctx->credentials), - cli_credentials_get_username(ctx->credentials)); + cli_credentials_get_username(ctx->credentials, ctx->mem_ctx)); new_password = getpass(password_prompt); } @@ -61,7 +61,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a /* prepare password change */ r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; - r.generic.in.account_name = cli_credentials_get_username(ctx->credentials); + r.generic.in.account_name = cli_credentials_get_username(ctx->credentials, ctx->mem_ctx); r.generic.in.domain_name = cli_credentials_get_domain(ctx->credentials); r.generic.in.oldpassword = cli_credentials_get_password(ctx->credentials); r.generic.in.newpassword = new_password; -- cgit From 51cbc188df03f9ee38599fe5a87ec2608117a845 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 22 Sep 2005 01:50:58 +0000 Subject: r10402: Make the RPC-SAMLOGON test pass against Win2k3 SP0 again. I still have issues with Win2k3 SP1, and Samba4 doesn't pass it's own test for the moment, but I'm working on these issues :-) This required a change to the credentials API, so that the special case for NTLM logins using a principal was indeed handled as a special, not general case. Also don't set the realm from a ccache, as then it overrides --option=realm=. Andrew Bartlett (This used to be commit 194e8f07c0cb4685797c5a7a074577c62dfdebe3) --- source4/utils/net/net_password.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 0bfb8a5be8..1912beeb41 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -49,7 +49,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a } else { password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", cli_credentials_get_domain(ctx->credentials), - cli_credentials_get_username(ctx->credentials, ctx->mem_ctx)); + cli_credentials_get_username(ctx->credentials)); new_password = getpass(password_prompt); } @@ -61,7 +61,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a /* prepare password change */ r.generic.level = LIBNET_CHANGE_PASSWORD_GENERIC; - r.generic.in.account_name = cli_credentials_get_username(ctx->credentials, ctx->mem_ctx); + r.generic.in.account_name = cli_credentials_get_username(ctx->credentials); r.generic.in.domain_name = cli_credentials_get_domain(ctx->credentials); r.generic.in.oldpassword = cli_credentials_get_password(ctx->credentials); r.generic.in.newpassword = new_password; -- cgit From d4de4c2d210d2e8c9b5aedf70695594809ad6a0b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 30 Dec 2005 13:16:54 +0000 Subject: r12608: Remove some unused #include lines. (This used to be commit 70e7449318aa0e9d2639c76730a7d1683b2f4981) --- source4/utils/net/net_password.c | 1 - 1 file changed, 1 deletion(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 1912beeb41..8f6b989a5d 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -23,7 +23,6 @@ #include "utils/net/net.h" #include "libnet/libnet.h" #include "system/filesys.h" -#include "system/passwd.h" /* * Code for Changing and setting a password -- cgit From 3f16241a1d3243447d0244ebac05b447aec94df8 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 14 Mar 2006 01:29:56 +0000 Subject: r14363: Remove credentials.h from the global includes. (This used to be commit 98c4c3051391c6f89df5d133665f51bef66b1563) --- source4/utils/net/net_password.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 8f6b989a5d..4c67f87b43 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -23,6 +23,7 @@ #include "utils/net/net.h" #include "libnet/libnet.h" #include "system/filesys.h" +#include "auth/credentials/credentials.h" /* * Code for Changing and setting a password -- cgit From 0479a2f1cbae51fcd8dbdc3c148c808421fb4d25 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 02:07:03 +0000 Subject: r23792: convert Samba4 to GPLv3 There are still a few tidyups of old FSF addresses to come (in both s3 and s4). More commits soon. (This used to be commit fcf38a38ac691abd0fa51b89dc951a08e89fdafa) --- source4/utils/net/net_password.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 4c67f87b43..4547aac6fd 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -6,7 +6,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 4c4323009fa83f00ed319de59a3aad48fcd65994 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 7 Dec 2007 02:37:04 +0100 Subject: r26327: Explicit loadparm_context for RPC client functions. (This used to be commit eeb2251d22b3d6e0379444a73af69d1014692b07) --- source4/utils/net/net_password.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 4547aac6fd..1fcb772e4c 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -52,7 +52,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(NULL); + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -127,7 +127,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(NULL); + libnetctx = libnet_context_init(NULL, ctx->lp_ctx); if (!libnetctx) { return -1; } -- cgit From 4f51b0246db3242ee02ee16905cba13a5dc5633a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 14 Apr 2008 12:43:37 -0400 Subject: Fix problems with event context not being the parent. (This used to be commit 957c4d893acf9e6db06a3fc3a4687ab6bb238635) --- source4/utils/net/net_password.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 1fcb772e4c..97bb467fac 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -22,6 +22,7 @@ #include "utils/net/net.h" #include "libnet/libnet.h" #include "system/filesys.h" +#include "lib/events/events.h" #include "auth/credentials/credentials.h" /* @@ -46,13 +47,13 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a if (argc > 0 && argv[0]) { new_password = argv[0]; } else { - password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", + password_prompt = talloc_asprintf(ctx, "Enter new password for account [%s\\%s]:", cli_credentials_get_domain(ctx->credentials), cli_credentials_get_username(ctx->credentials)); new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -66,7 +67,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a r.generic.in.newpassword = new_password; /* do password change */ - status = libnet_ChangePassword(libnetctx, ctx->mem_ctx, &r); + status = libnet_ChangePassword(libnetctx, ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("net_password_change: %s\n",r.generic.out.error_string)); return -1; @@ -101,10 +102,10 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv case 0: /* no args -> fail */ return net_password_set_usage(ctx, argc, argv); case 1: /* only DOM\\user; prompt for password */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + tmp = talloc_strdup(ctx, argv[0]); break; case 2: /* DOM\\USER and password */ - tmp = talloc_strdup(ctx->mem_ctx, argv[0]); + tmp = talloc_strdup(ctx, argv[0]); new_password = argv[1]; break; default: /* too mayn args -> fail */ @@ -115,19 +116,19 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv if ((p = strchr_m(tmp,'\\'))) { *p = 0; domain_name = tmp; - account_name = talloc_strdup(ctx->mem_ctx, p+1); + account_name = talloc_strdup(ctx, p+1); } else { account_name = tmp; domain_name = cli_credentials_get_domain(ctx->credentials); } if (!new_password) { - password_prompt = talloc_asprintf(ctx->mem_ctx, "Enter new password for account [%s\\%s]:", + password_prompt = talloc_asprintf(ctx, "Enter new password for account [%s\\%s]:", domain_name, account_name); new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(NULL, ctx->lp_ctx); + libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -140,7 +141,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv r.generic.in.newpassword = new_password; /* do password change */ - status = libnet_SetPassword(libnetctx, ctx->mem_ctx, &r); + status = libnet_SetPassword(libnetctx, ctx, &r); if (!NT_STATUS_IS_OK(status)) { DEBUG(0,("net_password_set: %s\n",r.generic.out.error_string)); return -1; -- cgit From a5d52174bd993b32d01d26a795a56df4a92eba45 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Wed, 16 Apr 2008 22:30:15 +0200 Subject: Avoid event_find_context() when the event context is already available in the net utility. (This used to be commit d40804777edf41889bd461f63f7a07cc1cc60e27) --- source4/utils/net/net_password.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source4/utils/net/net_password.c') diff --git a/source4/utils/net/net_password.c b/source4/utils/net/net_password.c index 97bb467fac..55f7c3c31d 100644 --- a/source4/utils/net/net_password.c +++ b/source4/utils/net/net_password.c @@ -53,7 +53,7 @@ static int net_password_change(struct net_context *ctx, int argc, const char **a new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } @@ -128,7 +128,7 @@ static int net_password_set(struct net_context *ctx, int argc, const char **argv new_password = getpass(password_prompt); } - libnetctx = libnet_context_init(event_context_find(ctx), ctx->lp_ctx); + libnetctx = libnet_context_init(ctx->event_ctx, ctx->lp_ctx); if (!libnetctx) { return -1; } -- cgit