diff options
author | Volker Lendecke <vl@samba.org> | 2019-09-16 03:54:32 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2019-09-17 22:49:35 +0000 |
commit | e00e53344df78b54bb5978de7062bf4c1242bd46 (patch) | |
tree | ab60d7fbf2e3c74df8ba61e0be7f68f66ae839ed /source3 | |
parent | 4f8db9b3cff9ef548a66b45f998573aea103db8c (diff) | |
download | samba-e00e53344df78b54bb5978de7062bf4c1242bd46.tar.gz |
smbd: Make fsp->fh->gen_id unique per process
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/durable.c | 2 | ||||
-rw-r--r-- | source3/smbd/files.c | 14 | ||||
-rw-r--r-- | source3/smbd/proto.h | 1 |
3 files changed, 15 insertions, 2 deletions
diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c index a42c201b81b..2863b41b354 100644 --- a/source3/smbd/durable.c +++ b/source3/smbd/durable.c @@ -657,7 +657,6 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, } fsp->fh->private_options = e->private_options; - fsp->fh->gen_id = smbXsrv_open_hash(op); fsp->file_id = file_id; fsp->file_pid = smb1req->smbpid; fsp->vuid = smb1req->vuid; @@ -666,6 +665,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, fsp->can_read = ((fsp->access_mask & (FILE_READ_DATA)) != 0); fsp->can_write = ((fsp->access_mask & (FILE_WRITE_DATA|FILE_APPEND_DATA)) != 0); fsp->fnum = op->local_id; + fsp_set_gen_id(fsp); /* * TODO: diff --git a/source3/smbd/files.c b/source3/smbd/files.c index e8fbb57c88b..e0ec601c56f 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -83,6 +83,17 @@ fail: return status; } +void fsp_set_gen_id(files_struct *fsp) +{ + static uint64_t gen_id = 1; + + /* + * A billion of 64-bit increments per second gives us + * more than 500 years of runtime without wrap. + */ + fsp->fh->gen_id = gen_id++; +} + /**************************************************************************** Find first available file slot. ****************************************************************************/ @@ -116,12 +127,13 @@ NTSTATUS file_new(struct smb_request *req, connection_struct *conn, fsp->op = op; op->compat = fsp; fsp->fnum = op->local_id; - fsp->fh->gen_id = smbXsrv_open_hash(op); } else { DEBUG(10, ("%s: req==NULL, INTERNAL_OPEN_ONLY, smbXsrv_open " "allocated\n", __func__)); } + fsp_set_gen_id(fsp); + /* * Create an smb_filename with "" for the base_name. There are very * few NULL checks, so make sure it's initialized with something. to diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 5ebee0486e7..f1c374f652b 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -368,6 +368,7 @@ NTSTATUS filename_convert_with_privilege(TALLOC_CTX *mem_ctx, NTSTATUS fsp_new(struct connection_struct *conn, TALLOC_CTX *mem_ctx, files_struct **result); +void fsp_set_gen_id(files_struct *fsp); NTSTATUS file_new(struct smb_request *req, connection_struct *conn, files_struct **result); void file_close_conn(connection_struct *conn); |