From c0fea1f0f791f0b2a161f5c89fd532ce2270c240 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 25 Jan 2009 12:22:20 +0100 Subject: Fix chain_reply for pipe reads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The caller might have over-allocated reply->outbuf. Deal with that. Sorry, Günther, for giving you so much pain ... Volker --- source3/smbd/process.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/source3/smbd/process.c b/source3/smbd/process.c index dc038b6b95..a025bb4197 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -1640,8 +1640,18 @@ void chain_reply(struct smb_request *req) /* * In req->chain_outbuf we collect all the replies. Start the * chain by copying in the first reply. + * + * We do the realloc because later on we depend on + * talloc_get_size to determine the length of + * chain_outbuf. The reply_xxx routines might have + * over-allocated (reply_pipe_read_and_X used to be such an + * example). */ - req->chain_outbuf = req->outbuf; + req->chain_outbuf = TALLOC_REALLOC_ARRAY( + req, req->outbuf, uint8_t, smb_len(req->outbuf) + 4); + if (req->chain_outbuf == NULL) { + goto error; + } req->outbuf = NULL; } else { if (!smb_splice_chain(&req->chain_outbuf, -- cgit From 28b7c44de846930e5f7c9aae3a7a423368c03ae1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 25 Jan 2009 20:32:59 +0100 Subject: Make smb_bytes_push_str deal with a NULL buf returning NULL --- source3/libsmb/clifile.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 7c75826414..04bbabe087 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -783,10 +783,15 @@ int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str) { - size_t buflen = talloc_get_size(buf); + size_t buflen; char *converted; size_t converted_size; + if (buf == NULL) { + return NULL; + } + + buflen = talloc_get_size(buf); /* * We're pushing into an SMB buffer, align odd */ -- cgit From 6baf760d176cc5ea8eb0cba6d68171f1950c1b75 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 25 Jan 2009 20:33:22 +0100 Subject: Fix an error path memleak --- source3/libsmb/clifile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 04bbabe087..ecb2bf0f5a 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -814,6 +814,7 @@ uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str) buf = TALLOC_REALLOC_ARRAY(NULL, buf, uint8_t, buflen + converted_size); if (buf == NULL) { + TALLOC_FREE(converted); return NULL; } -- cgit From 7f25e0da7348d786a36fa14403938b4f209fb52b Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 26 Jan 2009 03:38:05 +0100 Subject: Decouple clistr_pull from struct cli_state->inbuf --- source3/include/proto.h | 4 ++-- source3/include/safe_string.h | 12 ++++++------ source3/libsmb/cliconnect.c | 38 +++++++++++++++++++++++++------------- source3/libsmb/clidfs.c | 7 ++++--- source3/libsmb/clifile.c | 2 +- source3/libsmb/clifsinfo.c | 6 ++++-- source3/libsmb/clilist.c | 10 +++++----- source3/libsmb/clirap.c | 6 ++++-- source3/libsmb/clistr.c | 12 ++++++------ 9 files changed, 57 insertions(+), 40 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 1414ba89ec..8838419705 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -2825,7 +2825,7 @@ size_t clistr_push_fn(const char *function, int flags); size_t clistr_pull_fn(const char *function, unsigned int line, - struct cli_state *cli, + const char *inbuf, char *dest, const void *src, int dest_len, @@ -2834,7 +2834,7 @@ size_t clistr_pull_fn(const char *function, size_t clistr_pull_talloc_fn(const char *function, unsigned int line, TALLOC_CTX *ctx, - struct cli_state *cli, + const char *inbuf, char **pp_dest, const void *src, int src_len, diff --git a/source3/include/safe_string.h b/source3/include/safe_string.h index c030acf8fd..a7230964c9 100644 --- a/source3/include/safe_string.h +++ b/source3/include/safe_string.h @@ -146,13 +146,13 @@ size_t __unsafe_string_function_usage_here_char__(void); clistr_push_fn2(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, \ cli, dest, src, dest_len, flags) -#define clistr_pull(cli, dest, src, dest_len, src_len, flags) \ +#define clistr_pull(inbuf, dest, src, dest_len, src_len, flags) \ clistr_pull_fn2(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, \ - cli, dest, src, dest_len, src_len, flags) + inbuf, dest, src, dest_len, src_len, flags) -#define clistr_pull_talloc(ctx, cli, pp_dest, src, src_len, flags) \ +#define clistr_pull_talloc(ctx, inbuf, pp_dest, src, src_len, flags) \ clistr_pull_talloc_fn(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, \ - ctx, cli, pp_dest, src, src_len, flags) + ctx, inbuf, pp_dest, src, src_len, flags) #define srvstr_push(base_ptr, smb_flags2, dest, src, dest_len, flags) \ srvstr_push_fn2(SAFE_STRING_FUNCTION_NAME, SAFE_STRING_LINE, \ @@ -200,10 +200,10 @@ size_t __unsafe_string_function_usage_here_char__(void); ? __unsafe_string_function_usage_here_size_t__() \ : clistr_push_fn(fn_name, fn_line, cli, dest, src, dest_len, flags)) -#define clistr_pull_fn2(fn_name, fn_line, cli, dest, src, dest_len, srclen, flags) \ +#define clistr_pull_fn2(fn_name, fn_line, inbuf, dest, src, dest_len, srclen, flags) \ (CHECK_STRING_SIZE(dest, dest_len) \ ? __unsafe_string_function_usage_here_size_t__() \ - : clistr_pull_fn(fn_name, fn_line, cli, dest, src, dest_len, srclen, flags)) + : clistr_pull_fn(fn_name, fn_line, inbuf, dest, src, dest_len, srclen, flags)) #define srvstr_push_fn2(fn_name, fn_line, base_ptr, smb_flags2, dest, src, dest_len, flags) \ (CHECK_STRING_SIZE(dest, dest_len) \ diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 9e4266de5a..bc690f2e02 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -199,9 +199,12 @@ static NTSTATUS cli_session_setup_guest(struct cli_state *cli) cli->vuid = SVAL(cli->inbuf,smb_uid); p = smb_buf(cli->inbuf); - p += clistr_pull(cli, cli->server_os, p, sizeof(fstring), -1, STR_TERMINATE); - p += clistr_pull(cli, cli->server_type, p, sizeof(fstring), -1, STR_TERMINATE); - p += clistr_pull(cli, cli->server_domain, p, sizeof(fstring), -1, STR_TERMINATE); + p += clistr_pull(cli->inbuf, cli->server_os, p, sizeof(fstring), + -1, STR_TERMINATE); + p += clistr_pull(cli->inbuf, cli->server_type, p, sizeof(fstring), + -1, STR_TERMINATE); + p += clistr_pull(cli->inbuf, cli->server_domain, p, sizeof(fstring), + -1, STR_TERMINATE); if (strstr(cli->server_type, "Samba")) { cli->is_samba = True; @@ -276,9 +279,12 @@ static NTSTATUS cli_session_setup_plaintext(struct cli_state *cli, cli->vuid = SVAL(cli->inbuf,smb_uid); p = smb_buf(cli->inbuf); - p += clistr_pull(cli, cli->server_os, p, sizeof(fstring), -1, STR_TERMINATE); - p += clistr_pull(cli, cli->server_type, p, sizeof(fstring), -1, STR_TERMINATE); - p += clistr_pull(cli, cli->server_domain, p, sizeof(fstring), -1, STR_TERMINATE); + p += clistr_pull(cli->inbuf, cli->server_os, p, sizeof(fstring), + -1, STR_TERMINATE); + p += clistr_pull(cli->inbuf, cli->server_type, p, sizeof(fstring), + -1, STR_TERMINATE); + p += clistr_pull(cli->inbuf, cli->server_domain, p, sizeof(fstring), + -1, STR_TERMINATE); fstrcpy(cli->user_name, user); if (strstr(cli->server_type, "Samba")) { @@ -426,9 +432,12 @@ static NTSTATUS cli_session_setup_nt1(struct cli_state *cli, const char *user, cli->vuid = SVAL(cli->inbuf,smb_uid); p = smb_buf(cli->inbuf); - p += clistr_pull(cli, cli->server_os, p, sizeof(fstring), -1, STR_TERMINATE); - p += clistr_pull(cli, cli->server_type, p, sizeof(fstring), -1, STR_TERMINATE); - p += clistr_pull(cli, cli->server_domain, p, sizeof(fstring), -1, STR_TERMINATE); + p += clistr_pull(cli->inbuf, cli->server_os, p, sizeof(fstring), + -1, STR_TERMINATE); + p += clistr_pull(cli->inbuf, cli->server_type, p, sizeof(fstring), + -1, STR_TERMINATE); + p += clistr_pull(cli->inbuf, cli->server_domain, p, sizeof(fstring), + -1, STR_TERMINATE); if (strstr(cli->server_type, "Samba")) { cli->is_samba = True; @@ -512,11 +521,13 @@ static DATA_BLOB cli_session_setup_blob_receive(struct cli_state *cli) blob2 = data_blob(p, SVAL(cli->inbuf, smb_vwv3)); p += blob2.length; - p += clistr_pull(cli, cli->server_os, p, sizeof(fstring), -1, STR_TERMINATE); + p += clistr_pull(cli->inbuf, cli->server_os, p, sizeof(fstring), + -1, STR_TERMINATE); /* w2k with kerberos doesn't properly null terminate this field */ len = smb_bufrem(cli->inbuf, p); - p += clistr_pull(cli, cli->server_type, p, sizeof(fstring), len, 0); + p += clistr_pull(cli->inbuf, cli->server_type, p, sizeof(fstring), + len, 0); return blob2; } @@ -1178,7 +1189,8 @@ bool cli_send_tconX(struct cli_state *cli, if (cli_is_error(cli)) return False; - clistr_pull(cli, cli->dev, smb_buf(cli->inbuf), sizeof(fstring), -1, STR_TERMINATE|STR_ASCII); + clistr_pull(cli->inbuf, cli->dev, smb_buf(cli->inbuf), sizeof(fstring), + -1, STR_TERMINATE|STR_ASCII); if (cli->protocol >= PROTOCOL_NT1 && smb_buflen(cli->inbuf) == 3) { @@ -1350,7 +1362,7 @@ NTSTATUS cli_negprot_recv(struct async_req *req) /* work out if they sent us a workgroup */ if (!(cli->capabilities & CAP_EXTENDED_SECURITY) && smb_buflen(cli->inbuf) > 8) { - clistr_pull(cli, cli->server_domain, + clistr_pull(cli->inbuf, cli->server_domain, bytes+8, sizeof(cli->server_domain), num_bytes-8, STR_UNICODE|STR_NOALIGN); diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c index d649c504b7..f853e4e670 100644 --- a/source3/libsmb/clidfs.c +++ b/source3/libsmb/clidfs.c @@ -785,9 +785,10 @@ bool cli_dfs_get_referral(TALLOC_CTX *ctx, if (p + node_offset > endp) { goto out; } - clistr_pull_talloc(ctx, cli, &referrals[i].dfspath, - p+node_offset, -1, - STR_TERMINATE|STR_UNICODE ); + clistr_pull_talloc(ctx, cli->inbuf, + &referrals[i].dfspath, + p+node_offset, -1, + STR_TERMINATE|STR_UNICODE); if (!referrals[i].dfspath) { goto out; diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index ecb2bf0f5a..02cd2108bf 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -1751,7 +1751,7 @@ int cli_ctemp(struct cli_state *cli, const char *path, char **tmp_path) if (!path2) { return -1; } - clistr_pull(cli, path2, p, + clistr_pull(cli->inbuf, path2, p, len+1, len, STR_ASCII); *tmp_path = path2; } diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c index 5e73b61cd2..77290d2df9 100644 --- a/source3/libsmb/clifsinfo.c +++ b/source3/libsmb/clifsinfo.c @@ -229,7 +229,8 @@ bool cli_get_fs_volume_info_old(struct cli_state *cli, fstring volume_name, uint *pserial_number = IVAL(rdata,0); } nlen = CVAL(rdata,l2_vol_cch); - clistr_pull(cli, volume_name, rdata + l2_vol_szVolLabel, sizeof(fstring), nlen, STR_NOALIGN); + clistr_pull(cli->inbuf, volume_name, rdata + l2_vol_szVolLabel, + sizeof(fstring), nlen, STR_NOALIGN); /* todo: but not yet needed * return the other stuff @@ -290,7 +291,8 @@ bool cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 * *pserial_number = IVAL(rdata,8); } nlen = IVAL(rdata,12); - clistr_pull(cli, volume_name, rdata + 18, sizeof(fstring), nlen, STR_UNICODE); + clistr_pull(cli->inbuf, volume_name, rdata + 18, sizeof(fstring), + nlen, STR_UNICODE); /* todo: but not yet needed * return the other stuff diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c index 1431b804b0..e604725493 100644 --- a/source3/libsmb/clilist.c +++ b/source3/libsmb/clilist.c @@ -98,7 +98,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx, between win2000 and win9x for this call (tridge) */ ret = clistr_pull_talloc(ctx, - cli, + cli->inbuf, &finfo->name, p, len+2, @@ -127,7 +127,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx, return pdata_end - base; } ret = clistr_pull_talloc(ctx, - cli, + cli->inbuf, &finfo->name, p, len, @@ -179,7 +179,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx, /* stupid NT bugs. grr */ int flags = 0; if (p[1] == 0 && namelen > 1) flags |= STR_UNICODE; - clistr_pull(cli, finfo->short_name, p, + clistr_pull(cli->inbuf, finfo->short_name, p, sizeof(finfo->short_name), slen, flags); } @@ -188,7 +188,7 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx, return pdata_end - base; } ret = clistr_pull_talloc(ctx, - cli, + cli->inbuf, &finfo->name, p, namelen, @@ -514,7 +514,7 @@ static bool interpret_short_filename(TALLOC_CTX *ctx, finfo->mtime_ts.tv_nsec = finfo->atime_ts.tv_nsec = 0; finfo->size = IVAL(p,26); ret = clistr_pull_talloc(ctx, - cli, + cli->inbuf, &finfo->name, p+30, 12, diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c index 1656d9eb1c..3f95e77aee 100644 --- a/source3/libsmb/clirap.c +++ b/source3/libsmb/clirap.c @@ -952,7 +952,8 @@ bool cli_qfilename(struct cli_state *cli, int fnum, char *name, size_t namelen) return False; } - clistr_pull(cli, name, rdata+4, namelen, IVAL(rdata, 0), STR_UNICODE); + clistr_pull(cli->inbuf, name, rdata+4, namelen, IVAL(rdata, 0), + STR_UNICODE); SAFE_FREE(rparam); SAFE_FREE(rdata); @@ -1232,7 +1233,8 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_state *cli, const char *fname, fstrin return NT_STATUS_INVALID_NETWORK_RESPONSE; } - clistr_pull(cli, alt_name, rdata+4, sizeof(fstring), len, STR_UNICODE); + clistr_pull(cli->inbuf, alt_name, rdata+4, sizeof(fstring), len, + STR_UNICODE); SAFE_FREE(rdata); SAFE_FREE(rparam); diff --git a/source3/libsmb/clistr.c b/source3/libsmb/clistr.c index 5d20d632aa..8685781404 100644 --- a/source3/libsmb/clistr.c +++ b/source3/libsmb/clistr.c @@ -51,22 +51,22 @@ size_t clistr_push_fn(const char *function, size_t clistr_pull_fn(const char *function, unsigned int line, - struct cli_state *cli, + const char *inbuf, char *dest, const void *src, int dest_len, int src_len, int flags) { - return pull_string_fn(function, line, cli->inbuf, - SVAL(cli->inbuf, smb_flg2), dest, src, dest_len, + return pull_string_fn(function, line, inbuf, + SVAL(inbuf, smb_flg2), dest, src, dest_len, src_len, flags); } size_t clistr_pull_talloc_fn(const char *function, unsigned int line, TALLOC_CTX *ctx, - struct cli_state *cli, + const char *inbuf, char **pp_dest, const void *src, int src_len, @@ -75,8 +75,8 @@ size_t clistr_pull_talloc_fn(const char *function, return pull_string_talloc_fn(function, line, ctx, - cli->inbuf, - SVAL(cli->inbuf, smb_flg2), + inbuf, + SVAL(inbuf, smb_flg2), pp_dest, src, src_len, -- cgit From 512cf0ad50d30fcb35a28b0ef1b859d754f42a99 Mon Sep 17 00:00:00 2001 From: Karolin Seeger Date: Mon, 26 Jan 2009 14:17:23 +0100 Subject: docs: Add manpage for vfs_shadow_copy2. Karolin --- docs-xml/manpages-3/vfs_shadow_copy2.8.xml | 174 +++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 docs-xml/manpages-3/vfs_shadow_copy2.8.xml diff --git a/docs-xml/manpages-3/vfs_shadow_copy2.8.xml b/docs-xml/manpages-3/vfs_shadow_copy2.8.xml new file mode 100644 index 0000000000..364dd59144 --- /dev/null +++ b/docs-xml/manpages-3/vfs_shadow_copy2.8.xml @@ -0,0 +1,174 @@ + + + + + + vfs_shadow_copy2 + 8 + Samba + System Administration tools + 3.2 + + + + + vfs_shadow_copy2 + Expose snapshots to Windows clients as shadow copies. + + + + + vfs objects = shadow_copy2 + + + + + DESCRIPTION + + This VFS module is part of the + samba + 7 suite. + + The vfs_shadow_copy2 VFS module functionality + that is similar to Microsoft Shadow Copy services. When setup properly, + this module allows Microsoft Shadow Copy clients to browse + "shadow copies" on Samba shares. + + + This is a 2nd implementation of a shadow copy module. This + version has the following features: + + You don't need to populate your shares with symlinks to the + snapshots. This can be very important when you have thousands of + shares, or use [homes]. + The inode number of the files is altered so it is different + from the original. This allows the 'restore' button to work + without a sharing violation. + + + This module is stackable. + + + + + CONFIGURATION + + vfs_shadow_copy2 relies on a filesystem + snapshot implementation. Many common filesystems have native + support for this. + + + Filesystem snapshots must be mounted on + specially named directories in order to be recognized by + vfs_shadow_copy2. The snapshot mount points must + be immediate children of a the directory being shared. + + The snapshot naming convention is @GMT-YYYY.MM.DD-hh.mm.ss, + where: + + YYYY is the 4 digit year + MM is the 2 digit month + DD is the 2 digit day + hh is the 2 digit hour + mm is the 2 digit minute + ss is the 2 digit second. + + + + The vfs_shadow_copy2 snapshot naming convention can be + produced with the following date + 1 command: + + TZ=GMT date +@GMT-%Y.%m.%d-%H.%M.%S + + + + + + OPTIONS + + + + shadow:snapdir = SNAPDIR + + + Path to the directory where snapshots are kept. + + + + + + shadow:basedir = BASEDIR + + + Path to the base directory that snapshots are from. + + + + + + shadow:fixinodes = yes/no + + + If you enable shadow:fixinodes + then this module will modify the apparent inode + number of files in the snapshot directories using a hash of the + files path. This is needed for snapshot systems where the + snapshots have the same device:inode number as the original + files (such as happens with GPFS snapshots). If you don't set + this option then the 'restore' button in the shadow copy UI + will fail with a sharing violation. + + + + + + + + EXAMPLES + + Add shadow copy support to user home directories: + + + shadow_copy2 + /data/snaphots + /data/home + + + + + + CAVEATS + + This is not a backup, archival, or version control solution. + + + With Samba or Windows servers, + vfs_shadow_copy2 is designed to be an end-user + tool only. It does not replace or enhance your backup and + archival solutions and should in no way be considered as + such. Additionally, if you need version control, implement a + version control system. + + + + + + + VERSION + + This man page is correct for version 3.2.7 of the Samba suite. + + + + + AUTHOR + + The original Samba software and related utilities + were created by Andrew Tridgell. Samba is now developed + by the Samba Team as an Open Source project similar + to the way the Linux kernel is developed. + + + + -- cgit From d8f15e4efc00b9d509ff5761e9ca8ff5c6f443f7 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 26 Jan 2009 14:38:34 +0100 Subject: Document default of the printing config variable. Signed-off-by: Andreas Schneider --- docs-xml/smbdotconf/printing/printing.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs-xml/smbdotconf/printing/printing.xml b/docs-xml/smbdotconf/printing/printing.xml index 3be0f42939..c365594e1f 100644 --- a/docs-xml/smbdotconf/printing/printing.xml +++ b/docs-xml/smbdotconf/printing/printing.xml @@ -33,4 +33,6 @@ See also the discussion in the [printers] section. +Depends on the operating system, see +testparm -v. -- cgit