The branch, v4-3-test has been updated via e765cf9 kerberos: make sure we only use prompter type when available. via 26baf7f winbind: Fix 100% loop via 51eacb5 s3: smbd: Fix NULL pointer bug introduced by previous 'raw' stream fix (bug #11522). via d0e2a34 s3: smbd: fix a crash in unix_convert() via 3cea564 net: fix a crash with net ads keytab create via 3747699 s3: tests: smbclient test to ensure we can create and see a :foobar stream on the top level directory in a share. via 1681d0e s3: smbd: Fix opening/creating :stream files on the root share directory. via 134b9de s3: smbd: Remove unused parameter from build_stream_path(). via d768273 s3: smbclient: Move cmd_setmode out of clitar.c and back into client.c via e818bae pam_winbind: Fix a segfault if initialization fails via 9da6994 s4: torture: Test mkdir race condition. via 69c4f43 s3: smbd: Fix mkdir race condition. via d0d61f8 lib/param: fix hiding of FLAG_SYNONYM values via fd48773 s4:lib/messaging: use 'msg.lock' and 'msg.sock' for messaging related subdirs via af6fb44 s3:lib/messages: use 'msg.lock' and 'msg.sock' for messaging related subdirs via 9fdcaed s3:lib/messages: add missing allocation check for priv_path via f003617 s3: dfs: Fix a crash when the dfs targets are disabled. from 8aaba4b nss_winbind: fix hang on Solaris on big groups
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-3-test - Log ----------------------------------------------------------------- commit e765cf9702e7b18e4d8351c00f1fd0fe21cb73a1 Author: Günther Deschner <g...@samba.org> Date: Fri Oct 2 04:23:59 2015 +0200 kerberos: make sure we only use prompter type when available. We also verified that we cannot simply remove the prompter as several older versions of Heimdal would crash. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11038 Guenther Signed-off-by: Günther Deschner <g...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> Autobuild-User(master): Günther Deschner <g...@samba.org> Autobuild-Date(master): Fri Oct 2 07:29:43 CEST 2015 on sn-devel-104 (cherry picked from commit 6755376cedaf0c88230b47e04c584c7d9fce13e3) Autobuild-User(v4-3-test): Karolin Seeger <ksee...@samba.org> Autobuild-Date(v4-3-test): Mon Oct 5 12:44:42 CEST 2015 on sn-devel-104 commit 26baf7ff19cebb062432b4772e10cb7d50178ebe Author: Volker Lendecke <v...@samba.org> Date: Fri Aug 28 12:33:13 2015 +0200 winbind: Fix 100% loop Thanks to "L.P.H. van Belle" <be...@bazuin.nl> for help in reproducing the issue. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11038 From the bug report: "With e551cdb37d3e re-applied the problem is gone with and without kerberos. Moreover, if correctly configured, sshd requests you to change your password at logon time, which then succeeds. The problem why I had this reverted was because I had not gone through the pain to correctly configure all the PAM services (in particular the "account" section), leading to sshd letting the user in when the password had to be changed." Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Alexander Bokovoy <a...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit e551cdb37d3e8cfb155bc33f9b162761c8d60889) Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Fri Oct 2 00:16:29 CEST 2015 on sn-devel-104 (cherry picked from commit e524ab9f7ee9f4aff50dd5bc42312f9000bf1c6e) commit 51eacb5d78793f8b7de7b9f573da636091d6aaf1 Author: Jeremy Allison <j...@samba.org> Date: Wed Sep 30 17:12:11 2015 -0700 s3: smbd: Fix NULL pointer bug introduced by previous 'raw' stream fix (bug #11522). Ensure dirpath can never be NULL. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11535 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> Autobuild-User(master): Ralph Böhme <s...@samba.org> Autobuild-Date(master): Thu Oct 1 08:58:36 CEST 2015 on sn-devel-104 (cherry picked from commit f9ceaf443991e0bb5db23eeced2841436f47359e) commit d0e2a341ac2e117fb9961d9ae4b2acc94b9b73aa Author: Ralph Boehme <s...@samba.org> Date: Fri Sep 25 21:06:57 2015 +0200 s3: smbd: fix a crash in unix_convert() Some error code paths may result in dirpath being NULL. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11535 Signed-off-by: Ralph Boehme <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit bec685fb13e7cbe3bb98e5647183720d31f1c522) commit 3cea564cd98959098144d1f77a617076b203bece Author: Uri Simchoni <urisimch...@gmail.com> Date: Wed Sep 23 14:45:47 2015 +0300 net: fix a crash with net ads keytab create Fix a crash that happens when executing "net ads keytab create" and the machine account in AD does not have setvice principal names attached to it. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11528 Signed-off-by: Uri Simchoni <urisimch...@gmail.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Stefan Metzmacher <me...@samba.org> (cherry picked from commit e224e622971853bddbe24df717ea5dcddef71b89) commit 374769986a0b35e10816c1777691de37ae32c52e Author: Jeremy Allison <j...@samba.org> Date: Wed Sep 16 16:12:15 2015 -0700 s3: tests: smbclient test to ensure we can create and see a :foobar stream on the top level directory in a share. Regression test for: BUG: https://bugzilla.samba.org/show_bug.cgi?id=11522 Remember to remove the ARCHIVE attribute from the toplevel share when done (can only be done over SMB2+). Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> Autobuild-User(master): Ralph Böhme <s...@samba.org> Autobuild-Date(master): Fri Sep 18 11:00:44 CEST 2015 on sn-devel-104 (cherry picked from commit 6ce3643e45bac6660ae69123738c4b39d7bc1864) commit 1681d0ea0842403050f75c921523830c68ee1d47 Author: Jeremy Allison <j...@samba.org> Date: Wed Sep 16 12:03:34 2015 -0700 s3: smbd: Fix opening/creating :stream files on the root share directory. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11522 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> (cherry picked from commit 74fd4f93efe92516fc507edf71a588660782879e) commit 134b9de72236778fa08d4fe051fde167c792ed09 Author: Jeremy Allison <j...@samba.org> Date: Wed Sep 16 12:42:46 2015 -0700 s3: smbd: Remove unused parameter from build_stream_path(). Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> (cherry picked from commit 94e7e707783036b57babc73d320d2a3d8c0648d6) commit d7682739ee82a5d5ce98d04e585ee9e8e9ff924b Author: Jeremy Allison <j...@samba.org> Date: Thu Sep 17 15:54:40 2015 -0700 s3: smbclient: Move cmd_setmode out of clitar.c and back into client.c setmode <file> attribute is a valid smbclient command even if libarchive isn't on the system and tarmode isn't compiled in. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> (cherry picked from commit a47012d5429044c9a3616718bac21360f281aa81) commit e818bae92ce4f655ba4873383bfb4915efaa9213 Author: Andreas Schneider <a...@samba.org> Date: Tue Sep 8 16:48:08 2015 +0200 pam_winbind: Fix a segfault if initialization fails BUG: https://bugzilla.samba.org/show_bug.cgi?id=11502 Signed-off-by: Andreas Schneider <a...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> Autobuild-User(master): Michael Adam <ob...@samba.org> Autobuild-Date(master): Tue Sep 8 21:39:21 CEST 2015 on sn-devel-104 (cherry picked from commit 7d84cd6e40024fd361ea21635f7befed40f0e41f) commit 9da69942f16657b11ca4905403849284185e2b2e Author: Jeremy Allison <j...@samba.org> Date: Tue Sep 22 18:01:22 2015 -0700 s4: torture: Test mkdir race condition. Found by Max of LoadDynamix <adx.fo...@gmail.com> BUG: https://bugzilla.samba.org/show_bug.cgi?id=11486 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> Autobuild-User(master): Volker Lendecke <v...@samba.org> Autobuild-Date(master): Thu Sep 24 06:13:22 CEST 2015 on sn-devel-104 (cherry picked from commit 969d043596c0a382325d54d16dbd5e049f884fa9) commit 69c4f4327266bcd31b6c83f6f56ef478bc7ebd14 Author: Jeremy Allison <j...@samba.org> Date: Tue Sep 22 18:02:53 2015 -0700 s3: smbd: Fix mkdir race condition. Found by Max of LoadDynamix <adx.fo...@gmail.com> BUG: https://bugzilla.samba.org/show_bug.cgi?id=11486 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> (cherry picked from commit b1c823dc8c2824ec89921601d8e5e95f6d18fca8) commit d0d61f8e123706eb3a00c75b3d1249111ad90571 Author: Stefan Metzmacher <me...@samba.org> Date: Fri Sep 18 18:54:31 2015 +0200 lib/param: fix hiding of FLAG_SYNONYM values BUG: https://bugzilla.samba.org/show_bug.cgi?id=11526 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Michael Adam <ob...@samba.org> (cherry picked from commit 25dcdc92709a46d87125bc454faae7cad43d6b71) commit fd487736b76a295870b7d3282e2dbaeb249ae3bb Author: Stefan Metzmacher <me...@samba.org> Date: Wed Sep 16 12:44:43 2015 +0200 s4:lib/messaging: use 'msg.lock' and 'msg.sock' for messaging related subdirs In Samba 4.2, we used lock_path("msg") (with 0700) for the socket directory, while we use lock_path("msg") (with 0755) for the lock file directory. This generates a conflict that prevents samba, smbd, nmbd and winbindd from starting after an upgrade. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11515 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> Autobuild-User(master): Stefan Metzmacher <me...@samba.org> Autobuild-Date(master): Thu Sep 17 09:04:59 CEST 2015 on sn-devel-104 (cherry picked from commit 1d2a1a685ebdf479c511e01764e5148dbcbb37c9) commit af6fb44fe0ea95ac4c03b2213de7ac8e6b67e22d Author: Stefan Metzmacher <me...@samba.org> Date: Wed Sep 16 12:44:43 2015 +0200 s3:lib/messages: use 'msg.lock' and 'msg.sock' for messaging related subdirs In Samba 4.2, we used lock_path("msg") (with 0700) for the socket directory, while we use lock_path("msg") (with 0755) for the lock file directory. This generates a conflict that prevents samba, smbd, nmbd and winbindd from starting after an upgrade. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11515 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> (cherry picked from commit 1aabd9298d59d4f57d321ecaee59e99d966089ff) commit 9fdcaed05c4b0ea9957edf2d6fc727f17ffa9058 Author: Stefan Metzmacher <me...@samba.org> Date: Wed Sep 16 12:42:48 2015 +0200 s3:lib/messages: add missing allocation check for priv_path BUG: https://bugzilla.samba.org/show_bug.cgi?id=11515 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Volker Lendecke <v...@samba.org> (cherry picked from commit b0fa8316beefc7808b059f514448d41224d1c1fb) commit f003617584b12a834861bb9759f766b8684592a6 Author: Har Gagan Sahai <sharga...@novell.com> Date: Thu Sep 10 16:04:27 2015 +0530 s3: dfs: Fix a crash when the dfs targets are disabled. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11509 Signed-off-by: Har Gagan Sahai <sharga...@novell.com> Reviewed-by: Jeremy Allison <j...@samba.org> Reviewed-by: Ira Cooper <i...@wakeful.net> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Fri Sep 11 06:39:19 CEST 2015 on sn-devel-104 ----------------------------------------------------------------------- Summary of changes: lib/param/loadparm.c | 89 +++++++++++------- nsswitch/pam_winbind.c | 19 ++-- selftest/knownfail | 1 + source3/client/client.c | 118 +++++++++++++++++++++++ source3/client/client_proto.h | 6 ++ source3/client/clitar.c | 129 ------------------------- source3/lib/messages.c | 10 +- source3/libads/kerberos.c | 26 +++++ source3/libads/ldap.c | 7 ++ source3/libsmb/clidfs.c | 4 +- source3/script/tests/test_smbclient_s3.sh | 36 +++++++ source3/smbd/filename.c | 35 ++++++- source3/smbd/open.c | 19 ++++ source4/heimdal_build/wscript_configure | 1 + source4/lib/messaging/messaging.c | 4 +- source4/torture/smb2/create.c | 151 ++++++++++++++++++++++++++++++ wscript_configure_system_mitkrb5 | 2 + 17 files changed, 470 insertions(+), 187 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c index 06a9e59..c26442a 100644 --- a/lib/param/loadparm.c +++ b/lib/param/loadparm.c @@ -2014,22 +2014,28 @@ void lpcfg_dump_globals(struct loadparm_context *lp_ctx, FILE *f, fprintf(f, "# Global parameters\n[global]\n"); - for (i = 0; parm_table[i].label; i++) - if (parm_table[i].p_class == P_GLOBAL && - (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) { - if (!show_defaults) { - if (lp_ctx->flags && (lp_ctx->flags[i] & FLAG_DEFAULT)) { - continue; - } + for (i = 0; parm_table[i].label; i++) { + if (parm_table[i].p_class != P_GLOBAL) { + continue; + } - if (is_default(lp_ctx->globals, i)) { - continue; - } + if (parm_table[i].flags & FLAG_SYNONYM) { + continue; + } + + if (!show_defaults) { + if (lp_ctx->flags && (lp_ctx->flags[i] & FLAG_DEFAULT)) { + continue; + } + + if (is_default(lp_ctx->globals, i)) { + continue; } + } - fprintf(f, "\t%s = ", parm_table[i].label); - lpcfg_print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f); - fprintf(f, "\n"); + fprintf(f, "\t%s = ", parm_table[i].label); + lpcfg_print_parameter(&parm_table[i], lpcfg_parm_ptr(lp_ctx, NULL, &parm_table[i]), f); + fprintf(f, "\n"); } if (lp_ctx->globals->param_opt != NULL) { for (data = lp_ctx->globals->param_opt; data; @@ -2057,34 +2063,45 @@ void lpcfg_dump_a_service(struct loadparm_service * pService, struct loadparm_se fprintf(f, "\n[%s]\n", pService->szService); for (i = 0; parm_table[i].label; i++) { - if (parm_table[i].p_class == P_LOCAL && - (*parm_table[i].label != '-') && - (i == 0 || (parm_table[i].offset != parm_table[i - 1].offset))) - { - if (pService == sDefault) { - if (!show_defaults) { - if (flags && (flags[i] & FLAG_DEFAULT)) { - continue; - } + if (parm_table[i].p_class != P_LOCAL) { + continue; + } - if (is_default(sDefault, i)) { - continue; - } + if (parm_table[i].flags & FLAG_SYNONYM) { + continue; + } + + if (*parm_table[i].label == '-') { + continue; + } + + if (pService == sDefault) { + if (!show_defaults) { + if (flags && (flags[i] & FLAG_DEFAULT)) { + continue; } - } else { - if (lpcfg_equal_parameter(parm_table[i].type, - ((char *)pService) + - parm_table[i].offset, - ((char *)sDefault) + - parm_table[i].offset)) + + if (is_default(sDefault, i)) { continue; + } + } + } else { + bool equal; + + equal = lpcfg_equal_parameter(parm_table[i].type, + ((char *)pService) + + parm_table[i].offset, + ((char *)sDefault) + + parm_table[i].offset); + if (equal) { + continue; } - - fprintf(f, "\t%s = ", parm_table[i].label); - lpcfg_print_parameter(&parm_table[i], - ((char *)pService) + parm_table[i].offset, f); - fprintf(f, "\n"); } + + fprintf(f, "\t%s = ", parm_table[i].label); + lpcfg_print_parameter(&parm_table[i], + ((char *)pService) + parm_table[i].offset, f); + fprintf(f, "\n"); } if (pService->param_opt != NULL) { for (data = pService->param_opt; data; data = data->next) { diff --git a/nsswitch/pam_winbind.c b/nsswitch/pam_winbind.c index 1e16741..a2d9f3b 100644 --- a/nsswitch/pam_winbind.c +++ b/nsswitch/pam_winbind.c @@ -2489,7 +2489,7 @@ static int _pam_delete_cred(pam_handle_t *pamh, int flags, retval = _pam_winbind_init_context(pamh, flags, argc, argv, type, &ctx); if (retval) { - goto out; + return retval; } _PAM_LOG_FUNCTION_ENTER("_pam_delete_cred", ctx); @@ -2625,7 +2625,7 @@ int pam_sm_authenticate(pam_handle_t *pamh, int flags, retval = _pam_winbind_init_context(pamh, flags, argc, argv, PAM_WINBIND_AUTHENTICATE, &ctx); if (retval) { - goto out; + return retval; } _PAM_LOG_FUNCTION_ENTER("pam_sm_authenticate", ctx); @@ -2777,7 +2777,7 @@ int pam_sm_setcred(pam_handle_t *pamh, int flags, ret = _pam_winbind_init_context(pamh, flags, argc, argv, PAM_WINBIND_SETCRED, &ctx); if (ret) { - goto out; + return ret; } _PAM_LOG_FUNCTION_ENTER("pam_sm_setcred", ctx); @@ -2808,8 +2808,6 @@ int pam_sm_setcred(pam_handle_t *pamh, int flags, break; } - out: - _PAM_LOG_FUNCTION_LEAVE("pam_sm_setcred", ctx, ret); TALLOC_FREE(ctx); @@ -2833,7 +2831,7 @@ int pam_sm_acct_mgmt(pam_handle_t *pamh, int flags, ret = _pam_winbind_init_context(pamh, flags, argc, argv, PAM_WINBIND_ACCT_MGMT, &ctx); if (ret) { - goto out; + return ret; } _PAM_LOG_FUNCTION_ENTER("pam_sm_acct_mgmt", ctx); @@ -2929,7 +2927,7 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags, ret = _pam_winbind_init_context(pamh, flags, argc, argv, PAM_WINBIND_OPEN_SESSION, &ctx); if (ret) { - goto out; + return ret; } _PAM_LOG_FUNCTION_ENTER("pam_sm_open_session", ctx); @@ -2938,7 +2936,7 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags, /* check and create homedir */ ret = _pam_mkhomedir(ctx); } - out: + _PAM_LOG_FUNCTION_LEAVE("pam_sm_open_session", ctx, ret); TALLOC_FREE(ctx); @@ -2956,12 +2954,11 @@ int pam_sm_close_session(pam_handle_t *pamh, int flags, ret = _pam_winbind_init_context(pamh, flags, argc, argv, PAM_WINBIND_CLOSE_SESSION, &ctx); if (ret) { - goto out; + return ret; } _PAM_LOG_FUNCTION_ENTER("pam_sm_close_session", ctx); -out: _PAM_LOG_FUNCTION_LEAVE("pam_sm_close_session", ctx, ret); TALLOC_FREE(ctx); @@ -3043,7 +3040,7 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags, ret = _pam_winbind_init_context(pamh, flags, argc, argv, PAM_WINBIND_CHAUTHTOK, &ctx); if (ret) { - goto out; + return ret; } _PAM_LOG_FUNCTION_ENTER("pam_sm_chauthtok", ctx); diff --git a/selftest/knownfail b/selftest/knownfail index 447544e..bf73176 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -143,6 +143,7 @@ ^samba4.raw.acls.*.create_file ^samba4.smb2.create.*.acldir ^samba4.smb2.create.*.impersonation +^samba4.smb2.create.*.mkdir-dup # bug 11486 ^samba4.smb2.acls.*.generic ^samba4.smb2.acls.*.inheritflags ^samba4.smb2.acls.*.owner diff --git a/source3/client/client.c b/source3/client/client.c index f49f3ff..034b48a 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -4656,6 +4656,124 @@ static int cmd_show_connect( void ) return 0; } +/** + * set_remote_attr - set DOS attributes of a remote file + * @filename: path to the file name + * @new_attr: attribute bit mask to use + * @mode: one of ATTR_SET or ATTR_UNSET + * + * Update the file attributes with the one provided. + */ +int set_remote_attr(const char *filename, uint16_t new_attr, int mode) +{ + extern struct cli_state *cli; + uint16_t old_attr; + NTSTATUS status; + + status = cli_getatr(cli, filename, &old_attr, NULL, NULL); + if (!NT_STATUS_IS_OK(status)) { + d_printf("cli_getatr failed: %s\n", nt_errstr(status)); + return 1; + } + + if (mode == ATTR_SET) { + new_attr |= old_attr; + } else { + new_attr = old_attr & ~new_attr; + } + + status = cli_setatr(cli, filename, new_attr, 0); + if (!NT_STATUS_IS_OK(status)) { + d_printf("cli_setatr failed: %s\n", nt_errstr(status)); + return 1; + } + + return 0; +} + +/** + * cmd_setmode - interactive command to set DOS attributes + * + * Read a filename and mode from the client command line and update + * the file DOS attributes. + */ +int cmd_setmode(void) +{ + const extern char *cmd_ptr; + char *buf; + char *fname = NULL; + uint16_t attr[2] = {0}; + int mode = ATTR_SET; + int err = 0; + bool ok; + TALLOC_CTX *ctx = talloc_new(NULL); + if (ctx == NULL) { + return 1; + } + + ok = next_token_talloc(ctx, &cmd_ptr, &buf, NULL); + if (!ok) { + d_printf("setmode <filename> <[+|-]rsha>\n"); + err = 1; + goto out; + } + + fname = talloc_asprintf(ctx, + "%s%s", + client_get_cur_dir(), + buf); + if (fname == NULL) { + err = 1; + goto out; + } + + while (next_token_talloc(ctx, &cmd_ptr, &buf, NULL)) { + const char *s = buf; + + while (*s) { + switch (*s++) { + case '+': + mode = ATTR_SET; + break; + case '-': + mode = ATTR_UNSET; + break; + case 'r': + attr[mode] |= FILE_ATTRIBUTE_READONLY; + break; + case 'h': + attr[mode] |= FILE_ATTRIBUTE_HIDDEN; + break; + case 's': + attr[mode] |= FILE_ATTRIBUTE_SYSTEM; + break; + case 'a': + attr[mode] |= FILE_ATTRIBUTE_ARCHIVE; + break; + default: + d_printf("setmode <filename> <perm=[+|-]rsha>\n"); + err = 1; + goto out; + } + } + } + + if (attr[ATTR_SET] == 0 && attr[ATTR_UNSET] == 0) { + d_printf("setmode <filename> <[+|-]rsha>\n"); + err = 1; + goto out; + } + + DEBUG(2, ("perm set %d %d\n", attr[ATTR_SET], attr[ATTR_UNSET])); + + /* ignore return value: server might not store DOS attributes */ + set_remote_attr(fname, attr[ATTR_SET], ATTR_SET); + set_remote_attr(fname, attr[ATTR_UNSET], ATTR_UNSET); +out: + talloc_free(ctx); + return err; +} + /**************************************************************************** iosize command ***************************************************************************/ diff --git a/source3/client/client_proto.h b/source3/client/client_proto.h index 86f1d18..d3d4036 100644 --- a/source3/client/client_proto.h +++ b/source3/client/client_proto.h @@ -26,6 +26,11 @@ struct cli_state; struct file_info; +enum { + ATTR_UNSET, + ATTR_SET, +}; + /* The following definitions come from client/client.c */ const char *client_get_cur_dir(void); @@ -36,6 +41,7 @@ NTSTATUS do_list(const char *mask, const char *dir), bool rec, bool dirs); +int set_remote_attr(const char *filename, uint16_t new_attr, int mode); int cmd_iosize(void); /* The following definitions come from client/dnsbrowse.c */ diff --git a/source3/client/clitar.c b/source3/client/clitar.c index 5561845..7eb3fa0 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -121,11 +121,6 @@ enum tar_selection { TAR_EXCLUDE, /* X flag */ }; -enum { - ATTR_UNSET, - ATTR_SET, -}; - struct tar { TALLOC_CTX *talloc_ctx; @@ -216,7 +211,6 @@ static int make_remote_path(const char *full_path); static int max_token (const char *str); static NTSTATUS is_subpath(const char *sub, const char *full, bool *_subpath_match); -static int set_remote_attr(const char *filename, uint16_t new_attr, int mode); /** * tar_get_ctx - retrieve global tar context handle @@ -383,88 +377,6 @@ out: return err; } -/** - * cmd_setmode - interactive command to set DOS attributes - * - * Read a filename and mode from the client command line and update - * the file DOS attributes. - */ -int cmd_setmode(void) -{ - const extern char *cmd_ptr; - char *buf; - char *fname = NULL; - uint16_t attr[2] = {0}; - int mode = ATTR_SET; - int err = 0; - bool ok; - TALLOC_CTX *ctx = talloc_new(NULL); - if (ctx == NULL) { - return 1; - } - - ok = next_token_talloc(ctx, &cmd_ptr, &buf, NULL); - if (!ok) { - DBG(0, ("setmode <filename> <[+|-]rsha>\n")); - err = 1; - goto out; - } - - fname = talloc_asprintf(ctx, - "%s%s", - client_get_cur_dir(), - buf); - if (fname == NULL) { - err = 1; - goto out; - } - - while (next_token_talloc(ctx, &cmd_ptr, &buf, NULL)) { - const char *s = buf; - - while (*s) { - switch (*s++) { - case '+': - mode = ATTR_SET; - break; - case '-': - mode = ATTR_UNSET; - break; - case 'r': - attr[mode] |= FILE_ATTRIBUTE_READONLY; - break; - case 'h': - attr[mode] |= FILE_ATTRIBUTE_HIDDEN; - break; - case 's': - attr[mode] |= FILE_ATTRIBUTE_SYSTEM; - break; - case 'a': - attr[mode] |= FILE_ATTRIBUTE_ARCHIVE; - break; - default: - DBG(0, ("setmode <filename> <perm=[+|-]rsha>\n")); - err = 1; - goto out; - } - } - } - - if (attr[ATTR_SET] == 0 && attr[ATTR_UNSET] == 0) { - DBG(0, ("setmode <filename> <[+|-]rsha>\n")); - err = 1; - goto out; - } - - DBG(2, ("perm set %d %d\n", attr[ATTR_SET], attr[ATTR_UNSET])); - - /* ignore return value: server might not store DOS attributes */ - set_remote_attr(fname, attr[ATTR_SET], ATTR_SET); - set_remote_attr(fname, attr[ATTR_UNSET], ATTR_UNSET); -out: - talloc_free(ctx); - return err; -} /** * tar_parse_args - parse and set tar command line arguments @@ -1631,41 +1543,6 @@ out: return status; } -/** - * set_remote_attr - set DOS attributes of a remote file - * @filename: path to the file name - * @new_attr: attribute bit mask to use - * @mode: one of ATTR_SET or ATTR_UNSET - * - * Update the file attributes with the one provided. - */ -static int set_remote_attr(const char *filename, uint16_t new_attr, int mode) -{ - extern struct cli_state *cli; - uint16_t old_attr; - NTSTATUS status; -- Samba Shared Repository