summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2004-08-20 09:48:25 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:13 -0500
commitc2e2921bada17aae84e6c29f48401fa467e8ed9c (patch)
tree793f2c9010335b694d74b04018bb0f32a76a3df1 /source4/lib
parent5a8f826653aa32512183070d27f33a98d62f10f1 (diff)
downloadsamba-c2e2921bada17aae84e6c29f48401fa467e8ed9c.tar.gz
samba-c2e2921bada17aae84e6c29f48401fa467e8ed9c.tar.bz2
samba-c2e2921bada17aae84e6c29f48401fa467e8ed9c.zip
r1949: provide functions to access the username, userdomain and userpassword
now you're prompted when cmdline_get_userpassword() is called and the password is not yet known metze (This used to be commit d14a01533c5d465ff3709c48576b798b3be807e0)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/cmdline/popt_common.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c
index ef75d7be1f..20b9aac201 100644
--- a/source4/lib/cmdline/popt_common.c
+++ b/source4/lib/cmdline/popt_common.c
@@ -33,7 +33,7 @@
* -i,--scope
*/
-struct cmdline_auth_info cmdline_auth_info;
+static struct cmdline_auth_info cmdline_auth_info;
static void popt_common_callback(poptContext con,
enum poptCallbackReason reason,
@@ -396,3 +396,38 @@ struct poptOption popt_common_credentials[] = {
{ "machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password" },
POPT_TABLEEND
};
+
+const char *cmdline_get_username(void)
+{
+ return cmdline_auth_info.username;
+}
+
+const char *cmdline_get_userdomain(void)
+{
+ if (cmdline_auth_info.domain[0]) {
+ return cmdline_auth_info.domain;
+ }
+
+ /* I think this should be lp_netbios_name()
+ * instead of lp_workgroup(), because if you're logged in
+ * as domain user the getenv("USER") contains the domain
+ * and this code path isn't used
+ * --metze
+ */
+ return lp_netbios_name();
+}
+
+const char *cmdline_get_userpassword(void)
+{
+ pstring prompt;
+
+ if (cmdline_auth_info.got_pass) {
+ return cmdline_auth_info.password;
+ }
+
+ pstr_sprintf(prompt, "Password for [%s\\%s]:",
+ cmdline_get_userdomain(),
+ cmdline_get_username());
+
+ return getpass(prompt);
+}