Changeset 817 for branches/client-2.1/src/smbwrp.c
- Timestamp:
- Sep 27, 2013, 1:55:10 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/client-2.1/src/smbwrp.c
r816 r817 39 39 static int 40 40 net_share_enum_rpc(struct cli_state *cli, 41 42 43 44 45 46 { 47 41 void (*fn)(const char *name, 42 uint32 type, 43 const char *comment, 44 void *state), 45 void *state) 46 { 47 int i; 48 48 NTSTATUS status; 49 49 WERROR werr; 50 50 uint32_t resume_handle = 0; 51 52 53 51 uint32_t total_entries = 0; 52 struct srvsvc_NetShareInfoCtr info_ctr; 53 struct srvsvc_NetShareCtr1 ctr1; 54 54 fstring name = ""; 55 56 55 fstring comment = ""; 56 void *mem_ctx; 57 57 struct rpc_pipe_client *pipe_hnd; 58 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 59 /* Open the server service pipe */ 60 status = cli_rpc_pipe_open_noauth(cli, &ndr_table_srvsvc.syntax_id, &pipe_hnd); 61 if (!NT_STATUS_IS_OK(status)) { 62 DEBUG(1, ("net_share_enum_rpc pipe open fail!\n")); 63 return -1; 64 } 65 66 /* Allocate a context for parsing and for the entries in "ctr" */ 67 mem_ctx = talloc_init("libsmbclient: net_share_enum_rpc"); 68 if (mem_ctx == NULL) { 69 DEBUG(0, ("out of memory for net_share_enum_rpc!\n")); 70 TALLOC_FREE(pipe_hnd); 71 return -1; 72 } 73 74 /* Issue the NetShareEnum RPC call and retrieve the response */ 75 75 ZERO_STRUCT(info_ctr); 76 77 78 76 ZERO_STRUCT(ctr1); 77 info_ctr.level = 1; 78 info_ctr.ctr.ctr1 = &ctr1; 79 79 status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, mem_ctx, 80 81 82 83 84 85 86 87 80 pipe_hnd->desthost, 81 &info_ctr, 82 0xffffffff, 83 &total_entries, 84 &resume_handle, 85 &werr); 86 87 /* Was it successful? */ 88 88 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(werr) || info_ctr.ctr.ctr1->count == 0) { 89 89 /* Nope. Go clean up. */ 90 90 goto done; 91 92 93 94 95 96 97 98 99 91 } 92 93 /* For each returned entry... */ 94 for (i = 0; i < info_ctr.ctr.ctr1->count; i++) { 95 struct srvsvc_NetShareInfo1 info = info_ctr.ctr.ctr1->array[i]; 96 97 /* Add this share to the list */ 98 (*fn)(info.name, info.type, info.comment, state); 99 } 100 100 101 101 done: 102 103 104 105 106 107 108 109 102 /* Close the server service pipe */ 103 TALLOC_FREE(pipe_hnd); 104 105 /* Free all memory which was allocated for this request */ 106 TALLOC_FREE(mem_ctx); 107 108 /* Tell 'em if it worked */ 109 return W_ERROR_IS_OK(status) ? 0 : -1; 110 110 } 111 111 … … 125 125 void smbwrp_Logging() 126 126 { 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 127 char slogfile[_MAX_PATH +1] = {0}; 128 char slogfilename[] = "log.smbc"; 129 char *env = getenv("LOGFILES"); 130 if (env != NULL) 131 { 132 strncpy(slogfile, env, sizeof(slogfile) -1); 133 strncat(slogfile, "\\", sizeof(slogfile) - strlen(slogfile) -1); 134 strncat(slogfile, slogfilename, sizeof(slogfile) - strlen(slogfile) -1); 135 } 136 else 137 { 138 strncpy(slogfile, slogfilename, sizeof(slogfile) -1); 139 } 140 141 // init samba for debug messages 142 setup_logging(slogfile, false); 143 lp_set_logfile(slogfile); 144 debug_parse_levels("10"); 145 145 146 146 } 147 147 const char * smbwrp_getVersion() 148 148 { 149 149 return SAMBA_VERSION_STRING; 150 150 } 151 151 … … 169 169 initialised = 1; 170 170 171 171 lp_set_in_client(true); /* Make sure that we tell lp_load we are client */ 172 172 173 173 load_case_tables(); … … 184 184 } 185 185 186 187 188 189 186 if (writeLog()) 187 { 188 smbwrp_Logging(); 189 } 190 190 191 191 /* … … 200 200 void smbwrp_initthread(void) 201 201 { 202 203 *Block SIGPIPE (from lib/util_sock.c: write())204 *It is not needed and should not stop execution205 206 202 /* 203 Block SIGPIPE (from lib/util_sock.c: write()) 204 It is not needed and should not stop execution 205 */ 206 BlockSignals(True, SIGPIPE); 207 207 } 208 208 … … 313 313 uint16 setup = TRANSACT2_QPATHINFO; 314 314 char *param; 315 315 size_t nlen = 2*(strlen(fname)+1); 316 316 char *rparam=NULL, *rdata=NULL; 317 317 char *p; 318 319 320 318 319 param = SMB_MALLOC_ARRAY(char, 6+nlen+2); 320 if (!param) { 321 321 return false; 322 322 } … … 331 331 332 332 if (!cli_send_trans(cli, SMBtrans2, 333 NULL,/* name */334 -1, 0,/* fid, flags */335 &setup, 1, 0,/* setup, length, max */336 param, param_len, 10,/* param, length, max */337 NULL, data_len, cli->max_xmit/* data, length, max */338 333 NULL, /* name */ 334 -1, 0, /* fid, flags */ 335 &setup, 1, 0, /* setup, length, max */ 336 param, param_len, 10, /* param, length, max */ 337 NULL, data_len, cli->max_xmit /* data, length, max */ 338 )) { 339 339 return False; 340 340 } 341 341 342 342 SAFE_FREE(param); 343 343 if (!cli_receive_trans(cli, SMBtrans2, 344 345 344 &rparam, ¶m_len, 345 &rdata, &data_len)) { 346 346 return False; 347 347 } … … 402 402 403 403 if (!cli_send_trans(cli, SMBtrans2, 404 NULL,/* name */405 -1, 0,/* fid, flags */406 &setup, 1, 0,/* setup, length, max */407 param, param_len, 2,/* param, length, max */408 NULL, data_len, cli->max_xmit/* data, length, max */409 404 NULL, /* name */ 405 -1, 0, /* fid, flags */ 406 &setup, 1, 0, /* setup, length, max */ 407 param, param_len, 2, /* param, length, max */ 408 NULL, data_len, cli->max_xmit /* data, length, max */ 409 )) { 410 410 return False; 411 411 } 412 412 413 413 if (!cli_receive_trans(cli, SMBtrans2, 414 415 414 &rparam, ¶m_len, 415 &rdata, &data_len)) { 416 416 return False; 417 417 } … … 503 503 504 504 again: 505 505 zero_sockaddr(&ss); 506 506 507 507 /* have to open a new connection */ … … 695 695 debuglocal(4,"cli_close new mtime %lu\n", file->mtime); 696 696 } 697 698 if (file->updatetime == 2 && !cli_setattrE(cli, file->fd, file->ctime, 0, file->mtime))699 {700 debuglocal(4,"Set attrE on close failed %d\n", os2cli_errno(cli));701 }702 697 703 698 if (!cli_close(cli, file->fd)) … … 706 701 } 707 702 708 if (!rc && (file->openattr || file->mtime ))709 { 710 debuglocal(4,"Set attr on close %s %08x %d %d\n", file->fname, file->openattr, file->mtime, file->mtime);711 if (!cli_set atr(cli, file->fname, file->openattr, file->mtime))712 { 713 debuglocal(4,"Set attron close failed %d\n", os2cli_errno(cli));703 if (!rc && (file->openattr || file->mtime || file->ctime)) 704 { 705 debuglocal(4,"Set pathinfo on close %s %08x %d %d\n", file->fname, file->openattr, file->mtime, file->ctime); 706 if (!cli_setpathinfo(cli, file->fname, file->ctime, 0, file->mtime, 0, file->openattr)) 707 { 708 debuglocal(4,"Set pathinfo on close failed %d\n", os2cli_errno(cli)); 714 709 //rc = os2cli_errno(cli); 715 710 } 716 717 711 } 718 712 719 713 file->openattr = 0; 720 714 file->mtime = 0; 721 file->updatetime = 0; 715 file->ctime = 0; 716 file->updatetime = 0; 722 717 file->fd = -1; 723 718 file->offset = 0;
Note:
See TracChangeset
for help on using the changeset viewer.