diff options
author | Jeremy Allison <jra@samba.org> | 2008-08-29 09:29:21 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2008-08-29 09:29:21 -0700 |
commit | 8f525afbd2f2a849086c60ee890218a070cecd34 (patch) | |
tree | b4398adfa7e57dacf7f7d9b29b4a14f6596d6fe0 /source3/nsswitch/wbinfo.c | |
parent | b12c7dbb53023d1ea9e7df20137c0ad6ba21b9f0 (diff) | |
parent | d2dc2e34be6f13956a91678bcb8dd098fb0e5c8b (diff) | |
download | samba-8f525afbd2f2a849086c60ee890218a070cecd34.tar.gz samba-8f525afbd2f2a849086c60ee890218a070cecd34.tar.bz2 samba-8f525afbd2f2a849086c60ee890218a070cecd34.zip |
Merge branch 'v3-devel' of ssh://jra@git.samba.org/data/git/samba into v3-devel
(This used to be commit 882297edc024c146f24fc9f847d2b0b813f93fc7)
Diffstat (limited to 'source3/nsswitch/wbinfo.c')
-rw-r--r-- | source3/nsswitch/wbinfo.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/source3/nsswitch/wbinfo.c b/source3/nsswitch/wbinfo.c index 463d9233d0..60524d1d1b 100644 --- a/source3/nsswitch/wbinfo.c +++ b/source3/nsswitch/wbinfo.c @@ -1341,6 +1341,28 @@ static bool wbinfo_ping(void) return WBC_ERROR_IS_OK(wbc_status); } +static bool wbinfo_change_user_password(const char *username) +{ + wbcErr wbc_status; + char *old_password = NULL; + char *new_password = NULL; + + old_password = wbinfo_prompt_pass("old", username); + new_password = wbinfo_prompt_pass("new", username); + + wbc_status = wbcChangeUserPassword(username, old_password, new_password); + + /* Display response */ + + d_printf("Password change for user %s %s\n", username, + WBC_ERROR_IS_OK(wbc_status) ? "succeeded" : "failed"); + + SAFE_FREE(old_password); + SAFE_FREE(new_password); + + return WBC_ERROR_IS_OK(wbc_status); +} + /* Main program */ enum { @@ -1360,7 +1382,8 @@ enum { OPT_UID_INFO, OPT_GROUP_INFO, OPT_VERBOSE, - OPT_ONLINESTATUS + OPT_ONLINESTATUS, + OPT_CHANGE_USER_PASSWORD }; int main(int argc, char **argv, char **envp) @@ -1427,6 +1450,7 @@ int main(int argc, char **argv, char **envp) #endif { "separator", 0, POPT_ARG_NONE, 0, OPT_SEPARATOR, "Get the active winbind separator", NULL }, { "verbose", 0, POPT_ARG_NONE, 0, OPT_VERBOSE, "Print additional information per command", NULL }, + { "change-user-password", 0, POPT_ARG_STRING, &string_arg, OPT_CHANGE_USER_PASSWORD, "Change the password for a user", NULL }, POPT_COMMON_CONFIGFILE POPT_COMMON_VERSION POPT_TABLEEND @@ -1707,6 +1731,14 @@ int main(int argc, char **argv, char **envp) goto done; } break; + case OPT_CHANGE_USER_PASSWORD: + if (!wbinfo_change_user_password(string_arg)) { + d_fprintf(stderr, "Could not change user password " + "for user %s\n", string_arg); + goto done; + } + break; + /* generic configuration options */ case OPT_DOMAIN_NAME: break; |