2 Unix SMB/CIFS implementation.
4 Winbind status program.
6 Copyright (C) Tim Potter 2000-2003
7 Copyright (C) Andrew Bartlett <abartlet@samba.org> 2003-2004
8 Copyright (C) Francesco Chemolli <kinkie@kame.usr.dsi.unimi.it> 2000
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 #include "system/filesys.h"
27 #include "lib/cmdline/popt_common.h"
28 #include "auth/auth.h"
31 #define SQUID_BUFFER_SIZE 2010
33 enum stdio_helper_mode {
44 #define NTLM_AUTH_FLAG_USER_SESSION_KEY 0x0004
45 #define NTLM_AUTH_FLAG_LMKEY 0x0008
48 typedef void (*stdio_helper_function)(enum stdio_helper_mode stdio_helper_mode,
49 char *buf, int length, void **private,
50 unsigned int mux_id, void **private2);
52 static void manage_squid_basic_request (enum stdio_helper_mode stdio_helper_mode,
53 char *buf, int length, void **private,
54 unsigned int mux_id, void **private2);
56 static void manage_gensec_request (enum stdio_helper_mode stdio_helper_mode,
57 char *buf, int length, void **private,
58 unsigned int mux_id, void **private2);
60 static void manage_ntlm_server_1_request (enum stdio_helper_mode stdio_helper_mode,
61 char *buf, int length, void **private,
62 unsigned int mux_id, void **private2);
64 static void manage_squid_request(enum stdio_helper_mode helper_mode,
65 stdio_helper_function fn, void **private2);
68 enum stdio_helper_mode mode;
70 stdio_helper_function fn;
71 } stdio_helper_protocols[] = {
72 { SQUID_2_4_BASIC, "squid-2.4-basic", manage_squid_basic_request},
73 { SQUID_2_5_BASIC, "squid-2.5-basic", manage_squid_basic_request},
74 { SQUID_2_5_NTLMSSP, "squid-2.5-ntlmssp", manage_gensec_request},
75 { GSS_SPNEGO_CLIENT, "gss-spnego-client", manage_gensec_request},
76 { GSS_SPNEGO_SERVER, "gss-spnego", manage_gensec_request},
77 { NTLMSSP_CLIENT_1, "ntlmssp-client-1", manage_gensec_request},
78 { NTLM_SERVER_1, "ntlm-server-1", manage_ntlm_server_1_request},
79 { NUM_HELPER_MODES, NULL, NULL}
82 extern int winbindd_fd;
84 static const char *opt_username;
85 static const char *opt_domain;
86 static const char *opt_workstation;
87 static const char *opt_password;
88 static int opt_multiplex;
91 static void mux_printf(unsigned int mux_id, const char *format, ...) PRINTF_ATTRIBUTE(2, 3);
93 static void mux_printf(unsigned int mux_id, const char *format, ...)
98 x_fprintf(x_stdout, "%d ", mux_id);
101 va_start(ap, format);
102 x_vfprintf(x_stdout, format, ap);
108 /* Copy of parse_domain_user from winbindd_util.c. Parse a string of the
109 form DOMAIN/user into a domain and a user */
111 static BOOL parse_ntlm_auth_domain_user(const char *domuser, fstring domain,
115 char *p = strchr(domuser,*lp_winbind_separator());
122 fstrcpy(domain, domuser);
123 domain[PTR_DIFF(p, domuser)] = 0;
128 /* Authenticate a user with a plaintext password */
130 static BOOL check_plaintext_auth(const char *user, const char *pass,
131 BOOL stdout_diagnostics)
133 return (strcmp(pass, opt_password) == 0);
136 /* authenticate a user with an encrypted username/password */
138 static NTSTATUS local_pw_check_specified(const char *username,
140 const char *workstation,
141 const DATA_BLOB *challenge,
142 const DATA_BLOB *lm_response,
143 const DATA_BLOB *nt_response,
145 DATA_BLOB *lm_session_key,
146 DATA_BLOB *user_session_key,
151 struct samr_Password lm_pw, nt_pw;
152 struct samr_Password *lm_pwd, *nt_pwd;
153 TALLOC_CTX *mem_ctx = talloc_init("local_pw_check_specified");
155 nt_status = NT_STATUS_NO_MEMORY;
158 E_md4hash(opt_password, nt_pw.hash);
159 if (E_deshash(opt_password, lm_pw.hash)) {
167 nt_status = ntlm_password_check(mem_ctx,
168 MSV1_0_ALLOW_SERVER_TRUST_ACCOUNT |
169 MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT,
176 lm_pwd, nt_pwd, user_session_key, lm_session_key);
178 if (NT_STATUS_IS_OK(nt_status)) {
182 *lp_winbind_separator(),
186 DEBUG(3, ("Login for user [%s]\\[%s]@[%s] failed due to [%s]\n",
187 domain, username, workstation,
188 nt_errstr(nt_status)));
190 talloc_free(mem_ctx);
193 *error_string = strdup(nt_errstr(nt_status));
200 static void manage_squid_basic_request(enum stdio_helper_mode stdio_helper_mode,
201 char *buf, int length, void **private,
202 unsigned int mux_id, void **private2)
207 pass=memchr(buf,' ',length);
209 DEBUG(2, ("Password not found. Denying access\n"));
210 mux_printf(mux_id, "ERR\n");
216 if (stdio_helper_mode == SQUID_2_5_BASIC) {
217 rfc1738_unescape(user);
218 rfc1738_unescape(pass);
221 if (check_plaintext_auth(user, pass, False)) {
222 mux_printf(mux_id, "OK\n");
224 mux_printf(mux_id, "ERR\n");
228 /* This is a bit hairy, but the basic idea is to do a password callback
229 to the calling application. The callback comes from within gensec */
231 static void manage_gensec_get_pw_request(enum stdio_helper_mode stdio_helper_mode,
232 char *buf, int length, void **private,
233 unsigned int mux_id, void **password)
236 if (strlen(buf) < 2) {
237 DEBUG(1, ("query [%s] invalid", buf));
238 mux_printf(mux_id, "BH\n");
242 if (strlen(buf) > 3) {
243 in = base64_decode_data_blob(NULL, buf + 3);
245 in = data_blob(NULL, 0);
248 if (strncmp(buf, "PW ", 3) == 0) {
250 *password = talloc_strndup(*private /* hopefully the right gensec context, useful to use for talloc */,
251 (const char *)in.data, in.length);
253 if (*password == NULL) {
254 DEBUG(1, ("Out of memory\n"));
255 mux_printf(mux_id, "BH\n");
260 mux_printf(mux_id, "OK\n");
264 DEBUG(1, ("Asked for (and expected) a password\n"));
265 mux_printf(mux_id, "BH\n");
270 * Callback for password credentails. This is not async, and when
271 * GENSEC and the credentails code is made async, it will look rather
275 static const char *get_password(struct cli_credentials *credentials)
277 char *password = NULL;
279 /* Ask for a password */
280 mux_printf((unsigned int)credentials->priv_data, "PW\n");
281 credentials->priv_data = NULL;
283 manage_squid_request(NUM_HELPER_MODES /* bogus */, manage_gensec_get_pw_request, (void **)&password);
287 static void manage_gensec_request(enum stdio_helper_mode stdio_helper_mode,
288 char *buf, int length, void **private,
289 unsigned int mux_id, void **private2)
292 DATA_BLOB out = data_blob(NULL, 0);
293 char *out_base64 = NULL;
294 const char *reply_arg = NULL;
295 struct gensec_ntlm_state {
296 struct gensec_security *gensec_state;
297 const char *set_password;
299 struct gensec_ntlm_state *state;
303 const char *reply_code;
304 struct cli_credentials *creds;
311 state = talloc_zero(NULL, struct gensec_ntlm_state);
313 mux_printf(mux_id, "BH No Memory\n");
318 state->set_password = opt_password;
322 if (strlen(buf) < 2) {
323 DEBUG(1, ("query [%s] invalid", buf));
324 mux_printf(mux_id, "BH\n");
328 if (strlen(buf) > 3) {
329 in = base64_decode_data_blob(NULL, buf + 3);
331 in = data_blob(NULL, 0);
334 if (strncmp(buf, "YR", 2) == 0) {
335 if (state->gensec_state) {
336 talloc_free(state->gensec_state);
337 state->gensec_state = NULL;
339 } else if ( (strncmp(buf, "OK", 2) == 0)) {
343 } else if ( (strncmp(buf, "TT ", 3) != 0) &&
344 (strncmp(buf, "KK ", 3) != 0) &&
345 (strncmp(buf, "AF ", 3) != 0) &&
346 (strncmp(buf, "NA ", 3) != 0) &&
347 (strncmp(buf, "UG", 2) != 0) &&
348 (strncmp(buf, "PW ", 3) != 0)) {
349 DEBUG(1, ("SPNEGO request [%s] invalid\n", buf));
350 mux_printf(mux_id, "BH\n");
356 if (!(state->gensec_state)) {
357 switch (stdio_helper_mode) {
358 case GSS_SPNEGO_CLIENT:
359 case NTLMSSP_CLIENT_1:
360 /* setup the client side */
362 nt_status = gensec_client_start(NULL, &state->gensec_state, NULL);
363 if (!NT_STATUS_IS_OK(nt_status)) {
368 case GSS_SPNEGO_SERVER:
369 case SQUID_2_5_NTLMSSP:
370 if (!NT_STATUS_IS_OK(gensec_server_start(NULL, &state->gensec_state, NULL))) {
378 creds = cli_credentials_init(state->gensec_state);
379 cli_credentials_set_conf(creds);
381 cli_credentials_set_username(creds, opt_username, CRED_SPECIFIED);
384 cli_credentials_set_domain(creds, opt_domain, CRED_SPECIFIED);
386 if (state->set_password) {
387 cli_credentials_set_password(creds, state->set_password, CRED_SPECIFIED);
389 cli_credentials_set_password_callback(creds, get_password);
390 creds->priv_data = (void*)mux_id;
392 if (opt_workstation) {
393 cli_credentials_set_workstation(creds, opt_workstation, CRED_SPECIFIED);
396 switch (stdio_helper_mode) {
397 case GSS_SPNEGO_SERVER:
398 case SQUID_2_5_NTLMSSP:
399 cli_credentials_set_machine_account(creds);
405 gensec_set_credentials(state->gensec_state, creds);
407 switch (stdio_helper_mode) {
408 case GSS_SPNEGO_CLIENT:
409 case GSS_SPNEGO_SERVER:
410 nt_status = gensec_start_mech_by_oid(state->gensec_state, GENSEC_OID_SPNEGO);
415 case NTLMSSP_CLIENT_1:
419 case SQUID_2_5_NTLMSSP:
420 nt_status = gensec_start_mech_by_oid(state->gensec_state, GENSEC_OID_NTLMSSP);
426 if (!NT_STATUS_IS_OK(nt_status)) {
427 DEBUG(1, ("GENSEC mech failed to start: %s\n", nt_errstr(nt_status)));
428 mux_printf(mux_id, "BH\n");
435 mem_ctx = talloc_named(NULL, 0, "manage_gensec_request internal mem_ctx");
437 if (strncmp(buf, "PW ", 3) == 0) {
438 state->set_password = talloc_strndup(state,
439 (const char *)in.data,
442 cli_credentials_set_password(gensec_get_credentials(state->gensec_state),
445 mux_printf(mux_id, "OK\n");
447 talloc_free(mem_ctx);
451 if (strncmp(buf, "UG", 2) == 0) {
453 char *grouplist = NULL;
454 struct auth_session_info *session_info;
456 if (!NT_STATUS_IS_OK(gensec_session_info(state->gensec_state, &session_info))) {
457 DEBUG(1, ("gensec_session_info failed: %s\n", nt_errstr(nt_status)));
458 mux_printf(mux_id, "BH %s\n", nt_errstr(nt_status));
460 talloc_free(mem_ctx);
464 /* get the string onto the context */
465 grouplist = talloc_strdup(mem_ctx, "");
467 for (i=0; i<session_info->security_token->num_sids; i++) {
468 struct security_token *token = session_info->security_token;
469 const char *sidstr = dom_sid_string(session_info,
471 grouplist = talloc_asprintf_append(grouplist, "%s,", sidstr);
474 mux_printf(mux_id, "GL %s\n", grouplist);
475 talloc_free(session_info);
477 talloc_free(mem_ctx);
481 nt_status = gensec_update(state->gensec_state, mem_ctx, in, &out);
483 /* don't leak 'bad password'/'no such user' info to the network client */
484 nt_status = auth_nt_status_squash(nt_status);
487 out_base64 = base64_encode_data_blob(mem_ctx, out);
492 if (NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
496 } else if (state->gensec_state->gensec_role == GENSEC_CLIENT) {
498 } else if (state->gensec_state->gensec_role == GENSEC_SERVER) {
505 } else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_ACCESS_DENIED)) {
507 reply_arg = nt_errstr(nt_status);
508 DEBUG(1, ("GENSEC login failed: %s\n", nt_errstr(nt_status)));
509 } else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_UNSUCCESSFUL)) {
511 reply_arg = nt_errstr(nt_status);
512 DEBUG(1, ("GENSEC login failed: %s\n", nt_errstr(nt_status)));
513 } else if (!NT_STATUS_IS_OK(nt_status)) {
515 reply_arg = nt_errstr(nt_status);
516 DEBUG(1, ("GENSEC login failed: %s\n", nt_errstr(nt_status)));
517 } else if /* OK */ (state->gensec_state->gensec_role == GENSEC_SERVER) {
518 struct auth_session_info *session_info;
520 nt_status = gensec_session_info(state->gensec_state, &session_info);
521 if (!NT_STATUS_IS_OK(nt_status)) {
523 reply_arg = nt_errstr(nt_status);
524 DEBUG(1, ("GENSEC failed to retreive the session info: %s\n", nt_errstr(nt_status)));
528 reply_arg = talloc_asprintf(state->gensec_state,
529 "%s%s%s", session_info->server_info->domain_name,
530 lp_winbind_separator(), session_info->server_info->account_name);
531 talloc_free(session_info);
533 } else if (state->gensec_state->gensec_role == GENSEC_CLIENT) {
535 reply_arg = out_base64;
540 switch (stdio_helper_mode) {
541 case GSS_SPNEGO_SERVER:
542 mux_printf(mux_id, "%s %s %s\n", reply_code,
543 out_base64 ? out_base64 : "*",
544 reply_arg ? reply_arg : "*");
548 mux_printf(mux_id, "%s %s\n", reply_code, out_base64);
549 } else if (reply_arg) {
550 mux_printf(mux_id, "%s %s\n", reply_code, reply_arg);
552 mux_printf(mux_id, "%s\n", reply_code);
556 talloc_free(mem_ctx);
560 static void manage_ntlm_server_1_request(enum stdio_helper_mode stdio_helper_mode,
561 char *buf, int length, void **private,
562 unsigned int mux_id, void **private2)
564 char *request, *parameter;
565 static DATA_BLOB challenge;
566 static DATA_BLOB lm_response;
567 static DATA_BLOB nt_response;
568 static char *full_username;
569 static char *username;
571 static char *plaintext_password;
572 static BOOL ntlm_server_1_user_session_key;
573 static BOOL ntlm_server_1_lm_session_key;
575 if (strequal(buf, ".")) {
576 if (!full_username && !username) {
577 mux_printf(mux_id, "Error: No username supplied!\n");
578 } else if (plaintext_password) {
579 /* handle this request as plaintext */
580 if (!full_username) {
581 if (asprintf(&full_username, "%s%c%s", domain, *lp_winbind_separator(), username) == -1) {
582 mux_printf(mux_id, "Error: Out of memory in asprintf!\n.\n");
586 if (check_plaintext_auth(full_username, plaintext_password, False)) {
587 mux_printf(mux_id, "Authenticated: Yes\n");
589 mux_printf(mux_id, "Authenticated: No\n");
591 } else if (!lm_response.data && !nt_response.data) {
592 mux_printf(mux_id, "Error: No password supplied!\n");
593 } else if (!challenge.data) {
594 mux_printf(mux_id, "Error: No lanman-challenge supplied!\n");
596 char *error_string = NULL;
598 DATA_BLOB user_session_key;
601 if (full_username && !username) {
605 if (!parse_ntlm_auth_domain_user(full_username, fstr_user, fstr_domain)) {
606 /* username might be 'tainted', don't print into our new-line deleimianted stream */
607 mux_printf(mux_id, "Error: Could not parse into domain and username\n");
611 username = smb_xstrdup(fstr_user);
612 domain = smb_xstrdup(fstr_domain);
616 domain = smb_xstrdup(lp_workgroup());
619 if (ntlm_server_1_lm_session_key)
620 flags |= NTLM_AUTH_FLAG_LMKEY;
622 if (ntlm_server_1_user_session_key)
623 flags |= NTLM_AUTH_FLAG_USER_SESSION_KEY;
625 if (!NT_STATUS_IS_OK(
626 local_pw_check_specified(username,
638 mux_printf(mux_id, "Authenticated: No\n");
639 mux_printf(mux_id, "Authentication-Error: %s\n.\n", error_string);
640 SAFE_FREE(error_string);
642 static char zeros[16];
644 char *hex_user_session_key;
646 mux_printf(mux_id, "Authenticated: Yes\n");
648 if (ntlm_server_1_lm_session_key
650 && (memcmp(zeros, lm_key.data,
651 lm_key.length) != 0)) {
652 hex_encode(lm_key.data,
655 mux_printf(mux_id, "LANMAN-Session-Key: %s\n", hex_lm_key);
656 SAFE_FREE(hex_lm_key);
659 if (ntlm_server_1_user_session_key
660 && user_session_key.length
661 && (memcmp(zeros, user_session_key.data,
662 user_session_key.length) != 0)) {
663 hex_encode(user_session_key.data,
664 user_session_key.length,
665 &hex_user_session_key);
666 mux_printf(mux_id, "User-Session-Key: %s\n", hex_user_session_key);
667 SAFE_FREE(hex_user_session_key);
671 /* clear out the state */
672 challenge = data_blob(NULL, 0);
673 nt_response = data_blob(NULL, 0);
674 lm_response = data_blob(NULL, 0);
675 SAFE_FREE(full_username);
678 SAFE_FREE(plaintext_password);
679 ntlm_server_1_user_session_key = False;
680 ntlm_server_1_lm_session_key = False;
681 mux_printf(mux_id, ".\n");
688 /* Indicates a base64 encoded structure */
689 parameter = strstr(request, ":: ");
691 parameter = strstr(request, ": ");
694 DEBUG(0, ("Parameter not found!\n"));
695 mux_printf(mux_id, "Error: Parameter not found!\n.\n");
712 base64_decode_inplace(parameter);
715 if (strequal(request, "LANMAN-Challenge")) {
716 challenge = strhex_to_data_blob(parameter);
717 if (challenge.length != 8) {
718 mux_printf(mux_id, "Error: hex decode of %s failed! (got %d bytes, expected 8)\n.\n",
720 (int)challenge.length);
721 challenge = data_blob(NULL, 0);
723 } else if (strequal(request, "NT-Response")) {
724 nt_response = strhex_to_data_blob(parameter);
725 if (nt_response.length < 24) {
726 mux_printf(mux_id, "Error: hex decode of %s failed! (only got %d bytes, needed at least 24)\n.\n",
728 (int)nt_response.length);
729 nt_response = data_blob(NULL, 0);
731 } else if (strequal(request, "LANMAN-Response")) {
732 lm_response = strhex_to_data_blob(parameter);
733 if (lm_response.length != 24) {
734 mux_printf(mux_id, "Error: hex decode of %s failed! (got %d bytes, expected 24)\n.\n",
736 (int)lm_response.length);
737 lm_response = data_blob(NULL, 0);
739 } else if (strequal(request, "Password")) {
740 plaintext_password = smb_xstrdup(parameter);
741 } else if (strequal(request, "NT-Domain")) {
742 domain = smb_xstrdup(parameter);
743 } else if (strequal(request, "Username")) {
744 username = smb_xstrdup(parameter);
745 } else if (strequal(request, "Full-Username")) {
746 full_username = smb_xstrdup(parameter);
747 } else if (strequal(request, "Request-User-Session-Key")) {
748 ntlm_server_1_user_session_key = strequal(parameter, "Yes");
749 } else if (strequal(request, "Request-LanMan-Session-Key")) {
750 ntlm_server_1_lm_session_key = strequal(parameter, "Yes");
752 mux_printf(mux_id, "Error: Unknown request %s\n.\n", request);
756 static void manage_squid_request(enum stdio_helper_mode helper_mode,
757 stdio_helper_function fn, void **private2)
759 char buf[SQUID_BUFFER_SIZE+1];
765 unsigned int max_mux;
766 void **private_pointers;
769 static struct mux_private *mux_private;
770 static void *normal_private;
773 /* this is not a typo - x_fgets doesn't work too well under squid */
774 if (fgets(buf, sizeof(buf)-1, stdin) == NULL) {
776 DEBUG(1, ("fgets() failed! dying..... errno=%d (%s)\n", ferror(stdin),
777 strerror(ferror(stdin))));
779 exit(1); /* BIIG buffer */
784 c=memchr(buf,'\n',sizeof(buf)-1);
793 DEBUG(0, ("Oversized message\n"));
794 x_fprintf(x_stdout, "ERR\n");
799 DEBUG(10, ("Got '%s' from squid (length: %d).\n",buf,length));
801 if (buf[0] == '\0') {
802 DEBUG(0, ("Invalid Request (empty)\n"));
803 x_fprintf(x_stdout, "ERR\n");
808 if (sscanf(buf, "%u ", &mux_id) != 1) {
809 DEBUG(0, ("Invalid Request - no multiplex id\n"));
810 x_fprintf(x_stdout, "ERR\n");
814 mux_private = talloc(NULL, struct mux_private);
815 mux_private->max_mux = 0;
816 mux_private->private_pointers = NULL;
821 DEBUG(0, ("Invalid Request - no data after multiplex id\n"));
822 x_fprintf(x_stdout, "ERR\n");
826 if (mux_id >= mux_private->max_mux) {
827 unsigned int prev_max = mux_private->max_mux;
828 mux_private->max_mux = mux_id + 1;
829 mux_private->private_pointers
830 = talloc_realloc(mux_private,
831 mux_private->private_pointers,
832 void *, mux_private->max_mux);
833 memset(&mux_private->private_pointers[prev_max], '\0',
834 (sizeof(*mux_private->private_pointers) * (mux_private->max_mux - prev_max)));
837 private = &mux_private->private_pointers[mux_id];
840 private = &normal_private;
843 fn(helper_mode, c, length, private, mux_id, private2);
846 static void squid_stream(enum stdio_helper_mode stdio_mode,
847 stdio_helper_function fn) {
848 /* initialize FDescs */
849 x_setbuf(x_stdout, NULL);
850 x_setbuf(x_stderr, NULL);
852 manage_squid_request(stdio_mode, fn, NULL);
869 OPT_USER_SESSION_KEY,
871 OPT_REQUIRE_MEMBERSHIP,
875 int main(int argc, const char **argv)
877 static const char *helper_protocol;
882 /* NOTE: DO NOT change this interface without considering the implications!
883 This is an external interface, which other programs will use to interact
887 /* We do not use single-letter command abbreviations, because they harm future
888 interface stability. */
890 struct poptOption long_options[] = {
892 { "helper-protocol", 0, POPT_ARG_STRING, &helper_protocol, OPT_DOMAIN, "operate as a stdio-based helper", "helper protocol to use"},
893 { "domain", 0, POPT_ARG_STRING, &opt_domain, OPT_DOMAIN, "domain name"},
894 { "workstation", 0, POPT_ARG_STRING, &opt_workstation, OPT_WORKSTATION, "workstation"},
895 { "username", 0, POPT_ARG_STRING, &opt_username, OPT_PASSWORD, "Username"},
896 { "password", 0, POPT_ARG_STRING, &opt_password, OPT_PASSWORD, "User's plaintext password"},
897 { "multiplex", 0, POPT_ARG_NONE, &opt_multiplex, OPT_MULTIPLEX, "Multiplex Mode"},
903 /* Samba client initialisation */
905 setup_logging(NULL, DEBUG_STDERR);
909 pc = poptGetContext("ntlm_auth", argc, argv, long_options, 0);
911 /* Parse command line options */
914 poptPrintHelp(pc, stderr, 0);
918 pc = poptGetContext(NULL, argc, (const char **)argv, long_options,
919 POPT_CONTEXT_KEEP_FIRST);
921 while((opt = poptGetNextOpt(pc)) != -1) {
927 fprintf(stderr, "%s: %s\n",
928 poptBadOption(pc, POPT_BADOPTION_NOALIAS),
935 if (opt_domain == NULL) {
936 opt_domain = lp_workgroup();
939 if (helper_protocol) {
941 for (i=0; i<NUM_HELPER_MODES; i++) {
942 if (strcmp(helper_protocol, stdio_helper_protocols[i].name) == 0) {
943 squid_stream(stdio_helper_protocols[i].mode, stdio_helper_protocols[i].fn);
947 x_fprintf(x_stderr, "unknown helper protocol [%s]\n\nValid helper protools:\n\n", helper_protocol);
949 for (i=0; i<NUM_HELPER_MODES; i++) {
950 x_fprintf(x_stderr, "%s\n", stdio_helper_protocols[i].name);
957 x_fprintf(x_stderr, "username must be specified!\n\n");
958 poptPrintHelp(pc, stderr, 0);
962 if (opt_workstation == NULL) {
963 opt_workstation = lp_netbios_name();
967 opt_password = getpass("password: ");
973 asprintf(&user, "%s%c%s", opt_domain, *lp_winbind_separator(), opt_username);
974 if (!check_plaintext_auth(user, opt_password, True)) {