The branch, master has been updated via 547524d s3: popt: Change to NULL from talloc_autofree_context() now we correctly free on exit. via 47dc643 s3: client tools: Call popt_free_cmdline_auth_info() on all normal exits. via bec0cd2 s3: client tools. Remove direct access to struct user_auth_info *cmdline_auth_info. via 1a8f410 s3: popt: Add utility functions popt_get_cmdline_auth_info(), popt_free_cmdline_auth_info(). via 2dcef34 s3: popt: When using a global variable, don't hide it by helper locals. from 8c87d4e s3-gpo: Build scripts, security and registry CSE with --enable-developer
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 547524d7f808abd7cfd0ae00af540c78182627bc Author: Jeremy Allison <j...@samba.org> Date: Tue Apr 25 17:09:18 2017 -0700 s3: popt: Change to NULL from talloc_autofree_context() now we correctly free on exit. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> Autobuild-User(master): Andreas Schneider <a...@cryptomilk.org> Autobuild-Date(master): Tue May 9 14:00:40 CEST 2017 on sn-devel-144 commit 47dc643b0d22a50bce8feab1a4994f576a3e3afa Author: Jeremy Allison <j...@samba.org> Date: Tue Apr 25 17:08:30 2017 -0700 s3: client tools: Call popt_free_cmdline_auth_info() on all normal exits. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit bec0cd2ee261f68f16c7860858e1128702806f5a Author: Jeremy Allison <j...@samba.org> Date: Tue Apr 25 17:03:10 2017 -0700 s3: client tools. Remove direct access to struct user_auth_info *cmdline_auth_info. Only access through utility functions. Remove all the local pointer aliases that were just being set to cmdline_auth_info in the client tools. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit 1a8f410ece7c352e33c4e9f218b83e7b7c9b7100 Author: Jeremy Allison <j...@samba.org> Date: Tue Apr 25 17:01:25 2017 -0700 s3: popt: Add utility functions popt_get_cmdline_auth_info(), popt_free_cmdline_auth_info(). Leave the global cmdline_auth_info still exposed, we will make it static once the users have been converted to the utility functions. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> commit 2dcef34795b219dc8f175ae8df4477a9c923e42c Author: Jeremy Allison <j...@samba.org> Date: Tue Apr 25 16:32:05 2017 -0700 s3: popt: When using a global variable, don't hide it by helper locals. That makes it very unclear when you're using a global. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> ----------------------------------------------------------------------- Summary of changes: examples/fuse/smb2mount.c | 3 +- source3/client/client.c | 174 +++++++++++++++++++++------------------- source3/include/popt_common.h | 3 +- source3/lib/popt_common.c | 46 ++++++----- source3/rpcclient/cmd_spoolss.c | 22 ++--- source3/rpcclient/rpcclient.c | 44 ++++++---- source3/utils/smbcacls.c | 4 +- source3/utils/smbcquotas.c | 26 +++--- source3/utils/smbtree.c | 3 +- 9 files changed, 183 insertions(+), 142 deletions(-) Changeset truncated at 500 lines: diff --git a/examples/fuse/smb2mount.c b/examples/fuse/smb2mount.c index 4ed985f..816b0b5 100644 --- a/examples/fuse/smb2mount.c +++ b/examples/fuse/smb2mount.c @@ -143,7 +143,7 @@ int main(int argc, char *argv[]) *share = 0; share++; - cli = connect_one(cmdline_auth_info, server, port, share); + cli = connect_one(popt_get_cmdline_auth_info(), server, port, share); if (cli == NULL) { return -1; } @@ -154,6 +154,7 @@ int main(int argc, char *argv[]) return -1; } + popt_free_cmdline_auth_info(); TALLOC_FREE(frame); return 0; } diff --git a/source3/client/client.c b/source3/client/client.c index d2ebea0..6464736 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -108,9 +108,6 @@ struct cli_state *cli; static char CLI_DIRSEP_CHAR = '\\'; static char CLI_DIRSEP_STR[] = { '\\', '\0' }; -/* Authentication for client connections. */ -struct user_auth_info *auth_info; - /* Accessor functions for directory paths. */ static char *fileselection; static const char *client_get_fileselection(void) @@ -304,7 +301,7 @@ static int do_dskattr(void) TALLOC_CTX *ctx = talloc_tos(); NTSTATUS status; - status = cli_resolve_path(ctx, "", auth_info, cli, + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), cli, client_get_cur_dir(), &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { @@ -405,8 +402,8 @@ static int do_cd(const char *new_dir) new_cd = clean_name(ctx, new_cd); client_set_cur_dir(new_cd); - status = cli_resolve_path(ctx, "", auth_info, cli, new_cd, - &targetcli, &targetpath); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, new_cd, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { d_printf("cd %s: %s\n", new_cd, nt_errstr(status)); client_set_cur_dir(saved_dir); @@ -857,9 +854,9 @@ NTSTATUS do_list(const char *mask, /* check for dfs */ - status = cli_resolve_path(ctx, "", auth_info, cli, - head, &targetcli, - &targetpath); + status = cli_resolve_path(ctx, "", + popt_get_cmdline_auth_info(), + cli, head, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { d_printf("do_list: [%s] %s\n", head, nt_errstr(status)); @@ -900,8 +897,9 @@ NTSTATUS do_list(const char *mask, } } else { /* check for dfs */ - status = cli_resolve_path(ctx, "", auth_info, cli, mask, - &targetcli, &targetpath); + status = cli_resolve_path(ctx, "", + popt_get_cmdline_auth_info(), cli, mask, + &targetcli, &targetpath); if (NT_STATUS_IS_OK(status)) { status = cli_list(targetcli, targetpath, attribute, do_list_helper, targetcli); @@ -1085,8 +1083,8 @@ static int do_get(const char *rname, const char *lname_in, bool reget) } } - status = cli_resolve_path(ctx, "", auth_info, cli, rname, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, rname, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("Failed to open %s: %s\n", rname, nt_errstr(status)); return 1; @@ -1483,8 +1481,8 @@ static bool do_mkdir(const char *name) char *targetname = NULL; NTSTATUS status; - status = cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, name, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("mkdir %s: %s\n", name, nt_errstr(status)); return false; @@ -1527,6 +1525,7 @@ static bool do_altname(const char *name) static int cmd_quit(void) { cli_shutdown(cli); + popt_free_cmdline_auth_info(); exit(0); /* NOTREACHED */ return 0; @@ -1572,8 +1571,9 @@ static int cmd_mkdir(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, mask, - &targetcli, &targetname); + status = cli_resolve_path(ctx, "", + popt_get_cmdline_auth_info(), cli, mask, + &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { return 1; } @@ -1881,8 +1881,8 @@ static int do_put(const char *rname, const char *lname, bool reput) struct push_state state; NTSTATUS status; - status = cli_resolve_path(ctx, "", auth_info, cli, rname, - &targetcli, &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, rname, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("Failed to open %s: %s\n", rname, nt_errstr(status)); return 1; @@ -1984,6 +1984,7 @@ static int do_put(const char *rname, const char *lname, bool reput) if (f == stdin) { cli_shutdown(cli); + popt_free_cmdline_auth_info(); exit(rc); } @@ -2463,8 +2464,8 @@ static int cmd_wdel(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("cmd_wdel %s: %s\n", mask, nt_errstr(status)); return 1; @@ -2503,8 +2504,8 @@ static int cmd_open(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("open %s: %s\n", mask, nt_errstr(status)); return 1; @@ -2570,7 +2571,8 @@ static int cmd_posix_encrypt(void) } else { bool auth_requested = false; - creds = get_cmdline_auth_info_creds(auth_info); + creds = get_cmdline_auth_info_creds( + popt_get_cmdline_auth_info()); auth_requested = cli_credentials_authentication_requested(creds); if (!auth_requested) { @@ -2624,8 +2626,8 @@ static int cmd_posix_open(void) } mode = (mode_t)strtol(buf, (char **)NULL, 8); - status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("posix_open %s: %s\n", mask, nt_errstr(status)); return 1; @@ -2679,8 +2681,8 @@ static int cmd_posix_mkdir(void) } mode = (mode_t)strtol(buf, (char **)NULL, 8); - status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("posix_mkdir %s: %s\n", mask, nt_errstr(status)); return 1; @@ -2717,8 +2719,8 @@ static int cmd_posix_unlink(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("posix_unlink %s: %s\n", mask, nt_errstr(status)); return 1; @@ -2756,8 +2758,8 @@ static int cmd_posix_rmdir(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("posix_rmdir %s: %s\n", mask, nt_errstr(status)); return 1; @@ -3058,8 +3060,8 @@ static int cmd_rmdir(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, mask, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, mask, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("rmdir %s: %s\n", mask, nt_errstr(status)); return 1; @@ -3109,8 +3111,8 @@ static int cmd_link(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, oldname, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, oldname, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("link %s: %s\n", oldname, nt_errstr(status)); return 1; @@ -3156,8 +3158,8 @@ static int cmd_readlink(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, name, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, name, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("readlink %s: %s\n", name, nt_errstr(status)); return 1; @@ -3210,8 +3212,9 @@ static int cmd_symlink(void) return 1; } /* New name must be present in share namespace. */ - status = cli_resolve_path(ctx, "", auth_info, cli, newname, - &newcli, &newname); + status = cli_resolve_path(ctx, "", + popt_get_cmdline_auth_info(), cli, newname, + &newcli, &newname); if (!NT_STATUS_IS_OK(status)) { d_printf("link %s: %s\n", oldname, nt_errstr(status)); return 1; @@ -3262,8 +3265,8 @@ static int cmd_chmod(void) mode = (mode_t)strtol(buf, NULL, 8); - status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("chmod %s: %s\n", src, nt_errstr(status)); return 1; @@ -3419,8 +3422,8 @@ static int cmd_getfacl(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("stat %s: %s\n", src, nt_errstr(status)); return 1; @@ -3587,8 +3590,8 @@ static int cmd_geteas(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("stat %s: %s\n", src, nt_errstr(status)); return 1; @@ -3644,8 +3647,8 @@ static int cmd_setea(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("stat %s: %s\n", src, nt_errstr(status)); return 1; @@ -3690,8 +3693,8 @@ static int cmd_stat(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("stat %s: %s\n", src, nt_errstr(status)); return 1; @@ -3798,8 +3801,8 @@ static int cmd_chown(void) if (!src) { return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("chown %s: %s\n", src, nt_errstr(status)); return 1; @@ -3862,15 +3865,15 @@ static int cmd_rename(void) replace = true; } - status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, - &targetsrc); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + 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, "", auth_info, cli, dest, &targetcli, - &targetdest); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, dest, &targetcli, &targetdest); if (!NT_STATUS_IS_OK(status)) { d_printf("rename %s: %s\n", dest, nt_errstr(status)); return 1; @@ -3950,15 +3953,15 @@ static int cmd_scopy(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, - &targetsrc); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + 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, "", auth_info, cli, dest, &targetcli, - &targetdest); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, dest, &targetcli, &targetdest); if (!NT_STATUS_IS_OK(status)) { d_printf("scopy %s: %s\n", dest, nt_errstr(status)); return 1; @@ -4080,8 +4083,8 @@ static int cmd_hardlink(void) return 1; } - status = cli_resolve_path(ctx, "", auth_info, cli, src, &targetcli, - &targetname); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, src, &targetcli, &targetname); if (!NT_STATUS_IS_OK(status)) { d_printf("hardlink %s: %s\n", src, nt_errstr(status)); return 1; @@ -4738,7 +4741,7 @@ static int cmd_show_connect( void ) char *targetpath; NTSTATUS status; - status = cli_resolve_path(ctx, "", auth_info, cli, + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), cli, client_get_cur_dir(), &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { @@ -5148,7 +5151,7 @@ static int process_command_string(const char *cmd_in) status = cli_cm_open(talloc_tos(), NULL, have_ip ? dest_ss_str : desthost, - service, auth_info, + service, popt_get_cmdline_auth_info(), true, smb_encrypt, max_protocol, port, name_type, &cli); @@ -5328,8 +5331,8 @@ static char **remote_completion(const char *text, int len) goto cleanup; } - status = cli_resolve_path(ctx, "", auth_info, cli, dirmask, &targetcli, - &targetpath); + status = cli_resolve_path(ctx, "", popt_get_cmdline_auth_info(), + cli, dirmask, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { goto cleanup; } @@ -5577,8 +5580,9 @@ static int process(const char *base_directory) status = cli_cm_open(talloc_tos(), NULL, have_ip ? dest_ss_str : desthost, - service, auth_info, true, smb_encrypt, - max_protocol, port, name_type, &cli); + service, popt_get_cmdline_auth_info(), + true, smb_encrypt, max_protocol, port, + name_type, &cli); if (!NT_STATUS_IS_OK(status)) { return 1; } @@ -5613,8 +5617,9 @@ static int do_host_query(const char *query_host) status = cli_cm_open(talloc_tos(), NULL, have_ip ? dest_ss_str : query_host, - "IPC$", auth_info, true, smb_encrypt, - max_protocol, port, name_type, &cli); + "IPC$", popt_get_cmdline_auth_info(), + true, smb_encrypt, max_protocol, port, + name_type, &cli); if (!NT_STATUS_IS_OK(status)) { return 1; } @@ -5646,9 +5651,9 @@ static int do_host_query(const char *query_host) cli_shutdown(cli); status = cli_cm_open(talloc_tos(), NULL, have_ip ? dest_ss_str : query_host, - "IPC$", auth_info, true, smb_encrypt, - max_protocol, NBT_SMB_PORT, name_type, - &cli); + "IPC$", popt_get_cmdline_auth_info(), + true, smb_encrypt, max_protocol, + NBT_SMB_PORT, name_type, &cli); if (!NT_STATUS_IS_OK(status)) { cli = NULL; } @@ -5682,8 +5687,9 @@ static int do_tar_op(const char *base_directory) status = cli_cm_open(talloc_tos(), NULL, have_ip ? dest_ss_str : desthost, - service, auth_info, true, smb_encrypt, - max_protocol, port, name_type, &cli); + service, popt_get_cmdline_auth_info(), + true, smb_encrypt, max_protocol, + port, name_type, &cli); if (!NT_STATUS_IS_OK(status)) { ret = 1; goto out; @@ -5818,10 +5824,11 @@ int main(int argc,char *argv[]) /* if the service has already been retrieved then check if we have also a password */ if (service_opt - && (!get_cmdline_auth_info_got_pass(cmdline_auth_info)) + && (!get_cmdline_auth_info_got_pass( + popt_get_cmdline_auth_info())) && poptPeekArg(pc)) { - set_cmdline_auth_info_password(cmdline_auth_info, - poptGetArg(pc)); + set_cmdline_auth_info_password( + popt_get_cmdline_auth_info(), poptGetArg(pc)); } @@ -5920,9 +5927,9 @@ int main(int argc,char *argv[]) /* if the service has already been retrieved then check if we have also a password */ if (service_opt - && !get_cmdline_auth_info_got_pass(cmdline_auth_info) + && !get_cmdline_auth_info_got_pass(popt_get_cmdline_auth_info()) && poptPeekArg(pc)) { - set_cmdline_auth_info_password(cmdline_auth_info, + set_cmdline_auth_info_password(popt_get_cmdline_auth_info(), poptGetArg(pc)); } @@ -5964,8 +5971,8 @@ int main(int argc,char *argv[]) /* Ensure we have a password (or equivalent). */ popt_common_credentials_post(); - auth_info = cmdline_auth_info; - smb_encrypt = get_cmdline_auth_info_smb_encrypt(auth_info); + smb_encrypt = get_cmdline_auth_info_smb_encrypt( + popt_get_cmdline_auth_info()); max_protocol = lp_client_max_protocol(); @@ -5993,11 +6000,12 @@ int main(int argc,char *argv[]) rc = do_host_query(qhost); } else if (message) { - rc = do_message_op(auth_info); -- Samba Shared Repository