mirror of
https://github.com/samba-team/samba.git
synced 2025-03-10 12:58:35 +03:00
s3:client: Evaluate the AUTH_INFO_REQUIRED variable set by cups
This should not switch to username,password if cups has been configured to use negotiate (Kerberos authentication). BUG: https://bugzilla.samba.org/show_bug.cgi?id=13832 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Bryan Mason <bmason@redhat.com> Signed-off-by: Guenther Deschner <gd@samba.org> (cherry picked from commit 5274b09fbaa5e45cc58f3301818d4e9f6a402845)
This commit is contained in:
parent
d311eff5aa
commit
590fd47587
@ -60,7 +60,7 @@
|
||||
* Local functions...
|
||||
*/
|
||||
|
||||
static int get_exit_code(struct cli_state * cli, NTSTATUS nt_status, bool use_kerberos);
|
||||
static int get_exit_code(struct cli_state * cli, NTSTATUS nt_status);
|
||||
static void list_devices(void);
|
||||
static struct cli_state *smb_complete_connection(const char *, const char *,
|
||||
int, const char *, const char *, const char *, const char *, int, bool *need_auth);
|
||||
@ -72,6 +72,8 @@ static char *uri_unescape_alloc(const char *);
|
||||
static bool smb_encrypt;
|
||||
#endif
|
||||
|
||||
static const char *auth_info_required;
|
||||
|
||||
/*
|
||||
* 'main()' - Main entry for SMB backend.
|
||||
*/
|
||||
@ -185,6 +187,11 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
}
|
||||
}
|
||||
|
||||
auth_info_required = getenv("AUTH_INFO_REQUIRED");
|
||||
if (auth_info_required == NULL) {
|
||||
auth_info_required = "none";
|
||||
}
|
||||
|
||||
cmp = strncmp(dev_uri, "smb://", 6);
|
||||
if (cmp != 0) {
|
||||
fprintf(stderr,
|
||||
@ -233,6 +240,10 @@ main(int argc, /* I - Number of command-line arguments */
|
||||
server = uri + 6;
|
||||
}
|
||||
|
||||
if (password != empty_str) {
|
||||
auth_info_required = "username,password";
|
||||
}
|
||||
|
||||
tmp = server;
|
||||
|
||||
if ((sep = strchr_m(tmp, '/')) == NULL) {
|
||||
@ -352,8 +363,7 @@ done:
|
||||
|
||||
static int
|
||||
get_exit_code(struct cli_state * cli,
|
||||
NTSTATUS nt_status,
|
||||
bool use_kerberos)
|
||||
NTSTATUS nt_status)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -380,10 +390,7 @@ get_exit_code(struct cli_state * cli,
|
||||
}
|
||||
|
||||
if (cli) {
|
||||
if (use_kerberos)
|
||||
fputs("ATTR: auth-info-required=negotiate\n", stderr);
|
||||
else
|
||||
fputs("ATTR: auth-info-required=username,password\n", stderr);
|
||||
fprintf(stderr, "ATTR: auth-info-required=%s\n", auth_info_required);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -452,6 +459,7 @@ smb_complete_connection(const char *myname,
|
||||
}
|
||||
|
||||
if (flags & CLI_FULL_CONNECTION_USE_KERBEROS) {
|
||||
auth_info_required = "negotiate";
|
||||
use_kerberos = true;
|
||||
}
|
||||
|
||||
@ -474,7 +482,7 @@ smb_complete_connection(const char *myname,
|
||||
if (!NT_STATUS_IS_OK(nt_status)) {
|
||||
fprintf(stderr, "ERROR: Session setup failed: %s\n", nt_errstr(nt_status));
|
||||
|
||||
if (get_exit_code(cli, nt_status, use_kerberos) == 2) {
|
||||
if (get_exit_code(cli, nt_status) == 2) {
|
||||
*need_auth = true;
|
||||
}
|
||||
|
||||
@ -488,7 +496,7 @@ smb_complete_connection(const char *myname,
|
||||
fprintf(stderr, "ERROR: Tree connect failed (%s)\n",
|
||||
nt_errstr(nt_status));
|
||||
|
||||
if (get_exit_code(cli, nt_status, use_kerberos) == 2) {
|
||||
if (get_exit_code(cli, nt_status) == 2) {
|
||||
*need_auth = true;
|
||||
}
|
||||
|
||||
@ -677,7 +685,7 @@ smb_print(struct cli_state * cli, /* I - SMB connection */
|
||||
if (!NT_STATUS_IS_OK(nt_status)) {
|
||||
fprintf(stderr, "ERROR: %s opening remote spool %s\n",
|
||||
nt_errstr(nt_status), title);
|
||||
return get_exit_code(cli, nt_status, false);
|
||||
return get_exit_code(cli, nt_status);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -695,7 +703,7 @@ smb_print(struct cli_state * cli, /* I - SMB connection */
|
||||
status = cli_writeall(cli, fnum, 0, (uint8_t *)buffer,
|
||||
tbytes, nbytes, NULL);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
int ret = get_exit_code(cli, status, false);
|
||||
int ret = get_exit_code(cli, status);
|
||||
fprintf(stderr, "ERROR: Error writing spool: %s\n",
|
||||
nt_errstr(status));
|
||||
fprintf(stderr, "DEBUG: Returning status %d...\n",
|
||||
@ -711,7 +719,7 @@ smb_print(struct cli_state * cli, /* I - SMB connection */
|
||||
if (!NT_STATUS_IS_OK(nt_status)) {
|
||||
fprintf(stderr, "ERROR: %s closing remote spool %s\n",
|
||||
nt_errstr(nt_status), title);
|
||||
return get_exit_code(cli, nt_status, false);
|
||||
return get_exit_code(cli, nt_status);
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user