Changeset 988 for vendor/current/source4/ntvfs/smb2
- Timestamp:
- Nov 24, 2016, 1:14:11 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/source4/ntvfs/smb2/vfs_smb2.c
r740 r988 42 42 #include "libcli/smb2/smb2_calls.h" 43 43 44 NTSTATUS ntvfs_smb2_init(void); 45 44 46 struct cvfs_file { 45 47 struct cvfs_file *prev, *next; … … 99 101 along to the client 100 102 */ 103 #if 0 101 104 static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *p_private) 102 105 { … … 122 125 return true; 123 126 } 127 #endif 124 128 125 129 /* … … 161 165 struct cvfs_private *p; 162 166 const char *host, *user, *pass, *domain, *remote_share, *sharename; 163 struct composite_context *creq;164 167 struct share_config *scfg = ntvfs->ctx->config; 165 168 struct smb2_tree *tree; … … 167 170 bool machine_account; 168 171 struct smbcli_options options; 172 TALLOC_CTX *tmp_ctx; 173 174 tmp_ctx = talloc_new(req); 175 if (tmp_ctx == NULL) { 176 return NT_STATUS_NO_MEMORY; 177 } 169 178 170 179 switch (tcon->generic.level) { … … 179 188 break; 180 189 default: 181 return NT_STATUS_INVALID_LEVEL; 190 status = NT_STATUS_INVALID_LEVEL; 191 goto out; 182 192 } 183 193 … … 191 201 /* Here we need to determine which server to connect to. 192 202 * For now we use parametric options, type cifs. 193 * Later we will use security=server and auth_server.c.194 203 */ 195 host = share_string_option( scfg, SMB2_SERVER, NULL);196 user = share_string_option( scfg, SMB2_USER, NULL);197 pass = share_string_option( scfg, SMB2_PASSWORD, NULL);198 domain = share_string_option( scfg, SMB2_DOMAIN, NULL);199 remote_share = share_string_option( scfg, SMB2_SHARE, NULL);204 host = share_string_option(tmp_ctx, scfg, SMB2_SERVER, NULL); 205 user = share_string_option(tmp_ctx, scfg, SMB2_USER, NULL); 206 pass = share_string_option(tmp_ctx, scfg, SMB2_PASSWORD, NULL); 207 domain = share_string_option(tmp_ctx, scfg, SMB2_DOMAIN, NULL); 208 remote_share = share_string_option(tmp_ctx, scfg, SMB2_SHARE, NULL); 200 209 if (!remote_share) { 201 210 remote_share = sharename; … … 206 215 p = talloc_zero(ntvfs, struct cvfs_private); 207 216 if (!p) { 208 return NT_STATUS_NO_MEMORY; 217 status = NT_STATUS_NO_MEMORY; 218 goto out; 209 219 } 210 220 … … 213 223 if (!host) { 214 224 DEBUG(1,("CIFS backend: You must supply server\n")); 215 return NT_STATUS_INVALID_PARAMETER; 225 status = NT_STATUS_INVALID_PARAMETER; 226 goto out; 216 227 } 217 228 … … 220 231 credentials = cli_credentials_init(p); 221 232 if (!credentials) { 222 return NT_STATUS_NO_MEMORY; 233 status = NT_STATUS_NO_MEMORY; 234 goto out; 223 235 } 224 236 cli_credentials_set_conf(credentials, ntvfs->ctx->lp_ctx); … … 237 249 status = cli_credentials_set_machine_account(credentials, ntvfs->ctx->lp_ctx); 238 250 if (!NT_STATUS_IS_OK(status)) { 239 return status;251 goto out; 240 252 } 241 253 } else if (req->session_info->credentials) { … … 244 256 } else { 245 257 DEBUG(1,("CIFS backend: NO delegated credentials found: You must supply server, user and password or the client must supply delegated credentials\n")); 246 return NT_STATUS_INVALID_PARAMETER; 258 status = NT_STATUS_INVALID_PARAMETER; 259 goto out; 247 260 } 248 261 249 262 lpcfg_smbcli_options(ntvfs->ctx->lp_ctx, &options); 250 263 251 creq = smb2_connect_send(p, host,264 status = smb2_connect(p, host, 252 265 lpcfg_parm_string_list(p, ntvfs->ctx->lp_ctx, NULL, "smb2", "ports", NULL), 253 remote_share,254 255 256 ntvfs->ctx->event_ctx, &options,257 lpcfg_socket_options(ntvfs->ctx->lp_ctx),258 lpcfg_gensec_settings(p, ntvfs->ctx->lp_ctx)259 260 261 status = smb2_connect_recv(creq, p, &tree);262 NT_STATUS_NOT_OK_RETURN(status);266 remote_share, 267 lpcfg_resolve_context(ntvfs->ctx->lp_ctx), 268 credentials, 269 &tree, 270 ntvfs->ctx->event_ctx, &options, 271 lpcfg_socket_options(ntvfs->ctx->lp_ctx), 272 lpcfg_gensec_settings(p, ntvfs->ctx->lp_ctx)); 273 if (!NT_STATUS_IS_OK(status)) { 274 goto out; 275 } 263 276 264 277 status = smb2_get_roothandle(tree, &p->roothandle); 265 NT_STATUS_NOT_OK_RETURN(status); 278 if (!NT_STATUS_IS_OK(status)) { 279 goto out; 280 } 266 281 267 282 p->tree = tree; … … 270 285 271 286 ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS"); 272 NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type); 287 if (ntvfs->ctx->fs_type == NULL) { 288 status = NT_STATUS_NO_MEMORY; 289 goto out; 290 } 273 291 ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "A:"); 274 NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type); 292 if (ntvfs->ctx->dev_type == NULL) { 293 status = NT_STATUS_NO_MEMORY; 294 goto out; 295 } 275 296 276 297 if (tcon->generic.level == RAW_TCON_TCONX) { … … 283 304 smbcli_oplock_handler(p->transport, oplock_handler, p); 284 305 */ 285 return NT_STATUS_OK; 306 307 status = NT_STATUS_OK; 308 309 out: 310 TALLOC_FREE(tmp_ctx); 311 return status; 286 312 } 287 313 … … 835 861 836 862 /* fill in all the operations */ 837 ops.connect = cvfs_connect;838 ops.disconnect = cvfs_disconnect;839 ops.unlink = cvfs_unlink;840 ops.chkpath = cvfs_chkpath;841 ops.qpathinfo = cvfs_qpathinfo;842 ops.setpathinfo = cvfs_setpathinfo;843 ops.open = cvfs_open;844 ops.mkdir = cvfs_mkdir;845 ops.rmdir = cvfs_rmdir;846 ops.rename = cvfs_rename;847 ops.copy = cvfs_copy;848 ops.ioctl = cvfs_ioctl;849 ops.read = cvfs_read;850 ops.write = cvfs_write;851 ops.seek = cvfs_seek;852 ops.flush = cvfs_flush;853 ops.close = cvfs_close;854 ops.exit = cvfs_exit;855 ops.lock = cvfs_lock;856 ops.setfileinfo = cvfs_setfileinfo;857 ops.qfileinfo = cvfs_qfileinfo;858 ops.fsinfo = cvfs_fsinfo;859 ops.lpq = cvfs_lpq;860 ops.search_first = cvfs_search_first;861 ops.search_next = cvfs_search_next;862 ops.search_close = cvfs_search_close;863 ops.trans = cvfs_trans;864 ops.logoff = cvfs_logoff;865 ops.async_setup = cvfs_async_setup;866 ops.cancel = cvfs_cancel;867 ops.notify = cvfs_notify;863 ops.connect_fn = cvfs_connect; 864 ops.disconnect_fn = cvfs_disconnect; 865 ops.unlink_fn = cvfs_unlink; 866 ops.chkpath_fn = cvfs_chkpath; 867 ops.qpathinfo_fn = cvfs_qpathinfo; 868 ops.setpathinfo_fn = cvfs_setpathinfo; 869 ops.open_fn = cvfs_open; 870 ops.mkdir_fn = cvfs_mkdir; 871 ops.rmdir_fn = cvfs_rmdir; 872 ops.rename_fn = cvfs_rename; 873 ops.copy_fn = cvfs_copy; 874 ops.ioctl_fn = cvfs_ioctl; 875 ops.read_fn = cvfs_read; 876 ops.write_fn = cvfs_write; 877 ops.seek_fn = cvfs_seek; 878 ops.flush_fn = cvfs_flush; 879 ops.close_fn = cvfs_close; 880 ops.exit_fn = cvfs_exit; 881 ops.lock_fn = cvfs_lock; 882 ops.setfileinfo_fn = cvfs_setfileinfo; 883 ops.qfileinfo_fn = cvfs_qfileinfo; 884 ops.fsinfo_fn = cvfs_fsinfo; 885 ops.lpq_fn = cvfs_lpq; 886 ops.search_first_fn = cvfs_search_first; 887 ops.search_next_fn = cvfs_search_next; 888 ops.search_close_fn = cvfs_search_close; 889 ops.trans_fn = cvfs_trans; 890 ops.logoff_fn = cvfs_logoff; 891 ops.async_setup_fn = cvfs_async_setup; 892 ops.cancel_fn = cvfs_cancel; 893 ops.notify_fn = cvfs_notify; 868 894 869 895 /* register ourselves with the NTVFS subsystem. We register
Note:
See TracChangeset
for help on using the changeset viewer.