From: Andreas Schneider Date: Tue, 18 Aug 2020 15:42:25 +0000 (+0200) Subject: s3:libsmb: Pass cli_credentials to cli_resolve_path(), using helper variables. X-Git-Tag: talloc-2.3.2~277 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5245ab3c4dacc88d5cbe3bb1e3e339e4fb77a4db;p=thirdparty%2Fsamba.git s3:libsmb: Pass cli_credentials to cli_resolve_path(), using helper variables. Signed-off-by: Andreas Schneider Signed-off-by: Jeremy Allison --- diff --git a/source3/client/client.c b/source3/client/client.c index 8575ef40904..7ab948e79dd 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -297,9 +297,14 @@ static int do_dskattr(void) struct cli_state *targetcli = NULL; char *targetpath = NULL; TALLOC_CTX *ctx = talloc_tos(); + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), cli, + status = cli_resolve_path(ctx, + "", + creds, + cli, client_get_cur_dir(), &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { @@ -389,6 +394,8 @@ static int do_cd(const char *new_dir) uint32_t attributes; int ret = 1; TALLOC_CTX *ctx = talloc_stackframe(); + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; newdir = talloc_strdup(ctx, new_dir); @@ -431,7 +438,8 @@ static int do_cd(const char *new_dir) new_cd = client_clean_name(ctx, new_cd); client_set_cur_dir(new_cd); - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, new_cd, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { d_printf("cd %s: %s\n", new_cd, nt_errstr(status)); @@ -808,6 +816,8 @@ NTSTATUS do_list(const char *mask, TALLOC_CTX *ctx = talloc_tos(); struct cli_state *targetcli = NULL; char *targetpath = NULL; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS ret_status = NT_STATUS_OK; NTSTATUS status = NT_STATUS_OK; @@ -831,7 +841,7 @@ NTSTATUS do_list(const char *mask, /* check for dfs */ status = cli_resolve_path(ctx, "", - popt_get_cmdline_auth_info(), + creds, cli, head, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { d_printf("do_list: [%s] %s\n", head, @@ -1041,6 +1051,8 @@ static int do_get(const char *rname, const char *lname_in, bool reget) struct cli_state *targetcli = NULL; char *targetname = NULL; char *lname = NULL; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; lname = talloc_strdup(ctx, lname_in); @@ -1055,7 +1067,8 @@ static int do_get(const char *rname, const char *lname_in, bool reget) } } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, rname, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("Failed to open %s: %s\n", rname, nt_errstr(status)); @@ -1412,9 +1425,12 @@ static bool do_mkdir(const char *name) TALLOC_CTX *ctx = talloc_tos(); struct cli_state *targetcli; char *targetname = NULL; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, name, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("mkdir %s: %s\n", name, nt_errstr(status)); @@ -1473,6 +1489,8 @@ static int cmd_mkdir(void) TALLOC_CTX *ctx = talloc_tos(); char *mask = NULL; char *buf = NULL; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; mask = talloc_strdup(ctx, client_get_cur_dir()); @@ -1509,7 +1527,8 @@ static int cmd_mkdir(void) } status = cli_resolve_path(ctx, "", - popt_get_cmdline_auth_info(), cli, mask, + creds, + cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { return 1; @@ -1823,9 +1842,12 @@ static int do_put(const char *rname, const char *lname, bool reput) struct cli_state *targetcli; char *targetname = NULL; struct push_state state; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, rname, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("Failed to open %s: %s\n", rname, nt_errstr(status)); @@ -2600,6 +2622,8 @@ static int cmd_wdel(void) uint32_t attribute; struct cli_state *targetcli; char *targetname = NULL; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { @@ -2625,7 +2649,8 @@ static int cmd_wdel(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("cmd_wdel %s: %s\n", mask, nt_errstr(status)); @@ -2651,6 +2676,8 @@ static int cmd_open(void) char *targetname = NULL; struct cli_state *targetcli; uint16_t fnum = (uint16_t)-1; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { @@ -2670,7 +2697,8 @@ static int cmd_open(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("open %s: %s\n", mask, nt_errstr(status)); @@ -2772,6 +2800,8 @@ static int cmd_posix_open(void) struct cli_state *targetcli; mode_t mode; uint16_t fnum; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { @@ -2796,7 +2826,8 @@ static int cmd_posix_open(void) } mode = (mode_t)strtol(buf, (char **)NULL, 8); - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("posix_open %s: %s\n", mask, nt_errstr(status)); @@ -2831,6 +2862,8 @@ static int cmd_posix_mkdir(void) char *targetname = NULL; struct cli_state *targetcli; mode_t mode; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { @@ -2855,7 +2888,8 @@ static int cmd_posix_mkdir(void) } mode = (mode_t)strtol(buf, (char **)NULL, 8); - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("posix_mkdir %s: %s\n", mask, nt_errstr(status)); @@ -2879,6 +2913,8 @@ static int cmd_posix_unlink(void) char *buf = NULL; char *targetname = NULL; struct cli_state *targetcli; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { @@ -2897,7 +2933,8 @@ static int cmd_posix_unlink(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("posix_unlink %s: %s\n", mask, nt_errstr(status)); @@ -2922,6 +2959,8 @@ static int cmd_posix_rmdir(void) char *buf = NULL; char *targetname = NULL; struct cli_state *targetcli; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { @@ -2940,7 +2979,8 @@ static int cmd_posix_rmdir(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("posix_rmdir %s: %s\n", mask, nt_errstr(status)); @@ -3229,6 +3269,8 @@ static int cmd_rmdir(void) char *buf = NULL; char *targetname = NULL; struct cli_state *targetcli; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { @@ -3247,7 +3289,8 @@ static int cmd_rmdir(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("rmdir %s: %s\n", mask, nt_errstr(status)); @@ -3276,6 +3319,8 @@ static int cmd_link(void) char *buf2 = NULL; char *targetname = NULL; struct cli_state *targetcli; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) || @@ -3306,7 +3351,8 @@ static int cmd_link(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, oldname, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("link %s: %s\n", oldname, nt_errstr(status)); @@ -3339,6 +3385,8 @@ static int cmd_readlink(void) char *targetname = NULL; char *linkname = NULL; struct cli_state *targetcli; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL)) { @@ -3357,7 +3405,8 @@ static int cmd_readlink(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, name, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("readlink %s: %s\n", name, nt_errstr(status)); @@ -3396,6 +3445,8 @@ static int cmd_symlink(void) char *buf = NULL; char *buf2 = NULL; struct cli_state *newcli; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) || @@ -3418,7 +3469,8 @@ static int cmd_symlink(void) } /* New name must be present in share namespace. */ status = cli_resolve_path(ctx, "", - popt_get_cmdline_auth_info(), cli, newname, + creds, + cli, newname, &newcli, &newname); if (!NT_STATUS_IS_OK(status)) { d_printf("link %s: %s\n", newname, @@ -3454,6 +3506,8 @@ static int cmd_chmod(void) char *targetname = NULL; struct cli_state *targetcli; mode_t mode; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) || @@ -3475,7 +3529,8 @@ static int cmd_chmod(void) mode = (mode_t)strtol(buf, NULL, 8); - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("chmod %s: %s\n", src, nt_errstr(status)); @@ -3619,6 +3674,8 @@ static int cmd_getfacl(void) size_t num_dir_acls = 0; size_t expected_buflen; uint16_t i; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&name,NULL)) { @@ -3637,7 +3694,8 @@ static int cmd_getfacl(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("stat %s: %s\n", src, nt_errstr(status)); @@ -3802,6 +3860,8 @@ static int cmd_geteas(void) NTSTATUS status; size_t i, num_eas; struct ea_struct *eas; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); if (!next_token_talloc(ctx, &cmd_ptr,&name,NULL)) { d_printf("geteas filename\n"); @@ -3819,7 +3879,8 @@ static int cmd_geteas(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("stat %s: %s\n", src, nt_errstr(status)); @@ -3858,6 +3919,8 @@ static int cmd_setea(void) char *eavalue = NULL; char *targetname = NULL; struct cli_state *targetcli; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr, &name, NULL) @@ -3880,7 +3943,8 @@ static int cmd_setea(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("stat %s: %s\n", src, nt_errstr(status)); @@ -3912,6 +3976,8 @@ static int cmd_stat(void) SMB_STRUCT_STAT sbuf; struct tm *lt; time_t tmp_time; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&name,NULL)) { @@ -3930,7 +3996,8 @@ static int cmd_stat(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("stat %s: %s\n", src, nt_errstr(status)); @@ -4019,6 +4086,8 @@ static int cmd_chown(void) char *buf, *buf2, *buf3; struct cli_state *targetcli; char *targetname = NULL; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) || @@ -4042,7 +4111,8 @@ static int cmd_chown(void) if (src == NULL) { return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("chown %s: %s\n", src, nt_errstr(status)); @@ -4076,6 +4146,8 @@ static int cmd_rename(void) struct cli_state *targetcli; char *targetsrc; char *targetdest; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; bool replace = false; @@ -4114,14 +4186,16 @@ static int cmd_rename(void) replace = true; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, src, &targetcli, &targetsrc); if (!NT_STATUS_IS_OK(status)) { d_printf("rename %s: %s\n", src, nt_errstr(status)); return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, dest, &targetcli, &targetdest); if (!NT_STATUS_IS_OK(status)) { d_printf("rename %s: %s\n", dest, nt_errstr(status)); @@ -4178,6 +4252,8 @@ static int cmd_scopy(void) off_t written = 0; struct scopy_timing st; int rc = 0; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) || @@ -4210,14 +4286,16 @@ static int cmd_scopy(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, src, &targetcli, &targetsrc); if (!NT_STATUS_IS_OK(status)) { d_printf("scopy %s: %s\n", src, nt_errstr(status)); return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, dest, &targetcli, &targetdest); if (!NT_STATUS_IS_OK(status)) { d_printf("scopy %s: %s\n", dest, nt_errstr(status)); @@ -4316,6 +4394,8 @@ static int cmd_hardlink(void) char *buf, *buf2; struct cli_state *targetcli; char *targetname; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; if (!next_token_talloc(ctx, &cmd_ptr,&buf,NULL) || @@ -4348,7 +4428,8 @@ static int cmd_hardlink(void) return 1; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("hardlink %s: %s\n", src, nt_errstr(status)); @@ -5022,9 +5103,13 @@ static int cmd_show_connect( void ) TALLOC_CTX *ctx = talloc_tos(); struct cli_state *targetcli; char *targetpath; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), cli, + status = cli_resolve_path(ctx, "", + creds, + cli, client_get_cur_dir(), &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { @@ -5684,6 +5769,8 @@ static char **remote_completion(const char *text, int len) struct cli_state *targetcli = NULL; int i; struct completion_remote info = { NULL, NULL, 1, 0, NULL, 0 }; + struct cli_credentials *creds = + get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()); NTSTATUS status; /* can't have non-static initialisation on Sun CC, so do it @@ -5744,7 +5831,8 @@ static char **remote_completion(const char *text, int len) goto cleanup; } - status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + status = cli_resolve_path(ctx, "", + creds, cli, dirmask, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { goto cleanup; diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index ef75fb36a45..e6695159a96 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -859,7 +859,7 @@ struct cli_dfs_path_split { NTSTATUS cli_resolve_path(TALLOC_CTX *ctx, const char *mountpt, - const struct user_auth_info *dfs_auth_info, + struct cli_credentials *creds, struct cli_state *rootcli, const char *path, struct cli_state **targetcli, @@ -885,7 +885,6 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx, struct smbXcli_tcon *root_tcon = NULL; struct smbXcli_tcon *target_tcon = NULL; struct cli_dfs_path_split *dfs_refs = NULL; - struct cli_credentials *creds = get_cmdline_auth_info_creds(dfs_auth_info); if ( !rootcli || !path || !targetcli ) { return NT_STATUS_INVALID_PARAMETER; @@ -1130,7 +1129,7 @@ NTSTATUS cli_resolve_path(TALLOC_CTX *ctx, if (!strequal(*pp_targetpath, "\\") && !strequal(*pp_targetpath, "/")) { status = cli_resolve_path(ctx, newmount, - dfs_auth_info, + creds, *targetcli, *pp_targetpath, &newcli, diff --git a/source3/libsmb/libsmb_dir.c b/source3/libsmb/libsmb_dir.c index 6d9eb2316a8..4fbfb19b15d 100644 --- a/source3/libsmb/libsmb_dir.c +++ b/source3/libsmb/libsmb_dir.c @@ -915,6 +915,7 @@ SMBC_opendir_ctx(SMBCCTX *context, */ char *targetpath; struct cli_state *targetcli; + struct cli_credentials *creds = NULL; NTSTATUS status; /* We connect to the server and list the directory */ @@ -947,8 +948,12 @@ SMBC_opendir_ctx(SMBCCTX *context, return NULL; } + creds = get_cmdline_auth_info_creds( + context->internal->auth_info); + status = cli_resolve_path( - frame, "", context->internal->auth_info, + frame, "", + creds, srv->cli, path, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { d_printf("Could not resolve %s\n", path); @@ -1547,6 +1552,7 @@ SMBC_mkdir_ctx(SMBCCTX *context, char *targetpath = NULL; uint16_t port = 0; struct cli_state *targetcli = NULL; + struct cli_credentials *creds = NULL; TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; @@ -1599,8 +1605,11 @@ SMBC_mkdir_ctx(SMBCCTX *context, } + creds = get_cmdline_auth_info_creds(context->internal->auth_info); + /*d_printf(">>>mkdir: resolving %s\n", path);*/ - status = cli_resolve_path(frame, "", context->internal->auth_info, + status = cli_resolve_path(frame, "", + creds, srv->cli, path, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { d_printf("Could not resolve %s\n", path); @@ -1658,6 +1667,7 @@ SMBC_rmdir_ctx(SMBCCTX *context, char *targetpath = NULL; uint16_t port = 0; struct cli_state *targetcli = NULL; + struct cli_credentials *creds = NULL; TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; @@ -1710,8 +1720,11 @@ SMBC_rmdir_ctx(SMBCCTX *context, } + creds = get_cmdline_auth_info_creds(context->internal->auth_info), + /*d_printf(">>>rmdir: resolving %s\n", path);*/ - status = cli_resolve_path(frame, "", context->internal->auth_info, + status = cli_resolve_path(frame, "", + creds, srv->cli, path, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { d_printf("Could not resolve %s\n", path); @@ -1963,6 +1976,7 @@ SMBC_chmod_ctx(SMBCCTX *context, char *path = NULL; uint32_t attr; uint16_t port = 0; + struct cli_credentials *creds = NULL; TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; @@ -2014,8 +2028,11 @@ SMBC_chmod_ctx(SMBCCTX *context, return -1; /* errno set by SMBC_server */ } + creds = get_cmdline_auth_info_creds(context->internal->auth_info); + /*d_printf(">>>unlink: resolving %s\n", path);*/ - status = cli_resolve_path(frame, "", context->internal->auth_info, + status = cli_resolve_path(frame, "", + creds, srv->cli, path, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { d_printf("Could not resolve %s\n", path); @@ -2156,6 +2173,7 @@ SMBC_unlink_ctx(SMBCCTX *context, uint16_t port = 0; struct cli_state *targetcli = NULL; SMBCSRV *srv = NULL; + struct cli_credentials *creds = NULL; TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; @@ -2208,8 +2226,11 @@ SMBC_unlink_ctx(SMBCCTX *context, } + creds = get_cmdline_auth_info_creds(context->internal->auth_info); + /*d_printf(">>>unlink: resolving %s\n", path);*/ - status = cli_resolve_path(frame, "", context->internal->auth_info, + status = cli_resolve_path(frame, "", + creds, srv->cli, path, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { d_printf("Could not resolve %s\n", path); @@ -2286,6 +2307,8 @@ SMBC_rename_ctx(SMBCCTX *ocontext, SMBCSRV *srv = NULL; uint16_t port1 = 0; uint16_t port2 = 0; + struct cli_credentials *ocreds = NULL; + struct cli_credentials *ncreds = NULL; TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; @@ -2379,7 +2402,10 @@ SMBC_rename_ctx(SMBCCTX *ocontext, password1); /*d_printf(">>>rename: resolving %s\n", path1);*/ - status = cli_resolve_path(frame, "", ocontext->internal->auth_info, + ocreds = get_cmdline_auth_info_creds(ocontext->internal->auth_info); + + status = cli_resolve_path(frame, "", + ocreds, srv->cli, path1, &targetcli1, &targetpath1); if (!NT_STATUS_IS_OK(status)) { d_printf("Could not resolve %s\n", path1); @@ -2396,7 +2422,10 @@ SMBC_rename_ctx(SMBCCTX *ocontext, /*d_printf(">>>rename: resolved path as %s\n", targetpath1);*/ /*d_printf(">>>rename: resolving %s\n", path2);*/ - status = cli_resolve_path(frame, "", ncontext->internal->auth_info, + ncreds = get_cmdline_auth_info_creds(ncontext->internal->auth_info); + + status = cli_resolve_path(frame, "", + ncreds, srv->cli, path2, &targetcli2, &targetpath2); if (!NT_STATUS_IS_OK(status)) { d_printf("Could not resolve %s\n", path2); diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index 0791df36690..a44925e0e0e 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -103,6 +103,8 @@ SMBC_open_ctx(SMBCCTX *context, if (strlen(path) > 0 && path[strlen(path) - 1] == '\\') { status = NT_STATUS_OBJECT_PATH_INVALID; } else { + struct cli_credentials *creds = NULL; + file = SMB_MALLOC_P(SMBCFILE); if (!file) { errno = ENOMEM; @@ -112,9 +114,12 @@ SMBC_open_ctx(SMBCCTX *context, ZERO_STRUCTP(file); + creds = get_cmdline_auth_info_creds( + context->internal->auth_info); /*d_printf(">>>open: resolving %s\n", path);*/ status = cli_resolve_path( - frame, "", context->internal->auth_info, + frame, "", + creds, srv->cli, path, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { d_printf("Could not resolve %s\n", path); @@ -461,6 +466,7 @@ SMBC_getatr(SMBCCTX * context, struct timespec change_time_ts = {0}; time_t write_time = 0; SMB_INO_T ino = 0; + struct cli_credentials *creds = NULL; TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; @@ -490,7 +496,10 @@ SMBC_getatr(SMBCCTX * context, } DEBUG(4,("SMBC_getatr: sending qpathinfo\n")); - status = cli_resolve_path(frame, "", context->internal->auth_info, + creds = get_cmdline_auth_info_creds(context->internal->auth_info); + + status = cli_resolve_path(frame, "", + creds, srv->cli, fixedpath, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/libsmb/libsmb_stat.c b/source3/libsmb/libsmb_stat.c index b01aeb51ac1..de3ca530cd0 100644 --- a/source3/libsmb/libsmb_stat.c +++ b/source3/libsmb/libsmb_stat.c @@ -254,6 +254,7 @@ SMBC_fstat_ctx(SMBCCTX *context, struct cli_state *targetcli = NULL; SMB_INO_T ino = 0; uint16_t port = 0; + struct cli_credentials *creds = NULL; TALLOC_CTX *frame = talloc_stackframe(); NTSTATUS status; @@ -291,8 +292,11 @@ SMBC_fstat_ctx(SMBCCTX *context, return -1; } + creds = get_cmdline_auth_info_creds(context->internal->auth_info); + /*d_printf(">>>fstat: resolving %s\n", path);*/ - status = cli_resolve_path(frame, "", context->internal->auth_info, + status = cli_resolve_path(frame, "", + creds, file->srv->cli, path, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { diff --git a/source3/libsmb/libsmb_xattr.c b/source3/libsmb/libsmb_xattr.c index c5aa1b571f1..e28eb7ca6c7 100644 --- a/source3/libsmb/libsmb_xattr.c +++ b/source3/libsmb/libsmb_xattr.c @@ -861,13 +861,18 @@ cacl_get(SMBCCTX *context, if (ipc_cli && (all || some_nt || all_nt_acls)) { char *targetpath = NULL; struct cli_state *targetcli = NULL; + struct cli_credentials *creds = NULL; NTSTATUS status; /* Point to the portion after "system.nt_sec_desc." */ name += 19; /* if (all) this will be invalid but unused */ + creds = get_cmdline_auth_info_creds( + context->internal->auth_info); + status = cli_resolve_path( - ctx, "", context->internal->auth_info, + ctx, "", + creds, cli, filename, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { DEBUG(5, ("cacl_get Could not resolve %s\n", @@ -1512,6 +1517,7 @@ cacl_set(SMBCCTX *context, bool numeric = True; char *targetpath = NULL; struct cli_state *targetcli = NULL; + struct cli_credentials *creds = NULL; NTSTATUS status; /* the_acl will be null for REMOVE_ALL operations */ @@ -1541,7 +1547,10 @@ cacl_set(SMBCCTX *context, return -1; } - status = cli_resolve_path(ctx, "", context->internal->auth_info, + creds = get_cmdline_auth_info_creds(context->internal->auth_info); + + status = cli_resolve_path(ctx, "", + creds, cli, filename, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { DEBUG(5,("cacl_set: Could not resolve %s\n", filename)); diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h index c8b81a37c08..bd902ca6191 100644 --- a/source3/libsmb/proto.h +++ b/source3/libsmb/proto.h @@ -150,7 +150,7 @@ NTSTATUS cli_dfs_get_referral(TALLOC_CTX *ctx, size_t *consumed); NTSTATUS cli_resolve_path(TALLOC_CTX *ctx, const char *mountpt, - const struct user_auth_info *dfs_auth_info, + struct cli_credentials *creds, struct cli_state *rootcli, const char *path, struct cli_state **targetcli, diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index 34c552b4490..97f3a23a1a5 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -68,7 +68,7 @@ struct cacl_callback_state { */ static NTSTATUS local_cli_resolve_path(TALLOC_CTX* ctx, const char *mountpt, - const struct user_auth_info *dfs_auth_info, + struct cli_credentials *creds, struct cli_state *rootcli, const char *path, struct cli_state **targetcli, @@ -80,7 +80,7 @@ static NTSTATUS local_cli_resolve_path(TALLOC_CTX* ctx, status = cli_resolve_path(ctx, mountpt, - dfs_auth_info, + creds, rootcli, path, targetcli, @@ -1246,7 +1246,7 @@ static NTSTATUS cacl_set_cb(const char *mntpoint, struct file_info *f, struct cacl_callback_state *cbstate = (struct cacl_callback_state *)state; struct cli_state *cli = NULL; - struct user_auth_info *auth_info = NULL; + struct cli_credentials *creds = NULL; TALLOC_CTX *dirctx = NULL; NTSTATUS status; @@ -1265,7 +1265,7 @@ static NTSTATUS cacl_set_cb(const char *mntpoint, struct file_info *f, } cli = cbstate->cli; - auth_info = cbstate->auth_info; + creds = get_cmdline_auth_info_creds(cbstate->auth_info); /* Work out the directory. */ dir = talloc_strdup(dirctx, mask); @@ -1306,7 +1306,7 @@ static NTSTATUS cacl_set_cb(const char *mntpoint, struct file_info *f, } /* check for dfs */ - status = local_cli_resolve_path(dirctx, "", auth_info, cli, + status = local_cli_resolve_path(dirctx, "", creds, cli, mask2, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { goto out; @@ -1567,6 +1567,7 @@ int main(int argc, char *argv[]) than going via LSA calls to resolve them */ int numeric = 0; struct cli_state *targetcli = NULL; + struct cli_credentials *creds = NULL; char *targetfile = NULL; NTSTATUS status; @@ -1842,9 +1843,11 @@ int main(int argc, char *argv[]) } } + creds = get_cmdline_auth_info_creds(popt_get_cmdline_auth_info()), + status = local_cli_resolve_path(frame, "", - popt_get_cmdline_auth_info(), + creds, cli, filename, &targetcli,