Changeset 448 for branches/client-1.6/src/smbwrp.c
- Timestamp:
- Apr 23, 2010, 10:04:41 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/client-1.6/src/smbwrp.c
r444 r448 37 37 } 38 38 39 static int 40 net_share_enum_rpc(struct cli_state *cli, 41 void (*fn)(const char *name, 42 uint32 type, 43 const char *comment, 44 void *state), 45 void *state) 46 { 47 int i; 48 NTSTATUS status; 49 WERROR werr; 50 uint32_t resume_handle = 0; 51 uint32_t total_entries = 0; 52 struct srvsvc_NetShareInfoCtr info_ctr; 53 struct srvsvc_NetShareCtr1 ctr1; 54 fstring name = ""; 55 fstring comment = ""; 56 void *mem_ctx; 57 struct rpc_pipe_client *pipe_hnd; 58 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 ZERO_STRUCT(info_ctr); 76 ZERO_STRUCT(ctr1); 77 info_ctr.level = 1; 78 info_ctr.ctr.ctr1 = &ctr1; 79 status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, mem_ctx, 80 pipe_hnd->desthost, 81 &info_ctr, 82 0xffffffff, 83 &total_entries, 84 &resume_handle, 85 &werr); 86 87 /* Was it successful? */ 88 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(werr) || info_ctr.ctr.ctr1->count == 0) { 89 /* Nope. Go clean up. */ 90 goto done; 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 101 done: 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 } 111 112 /* 113 * Wrapper for cli_errno to return not connected error on negative fd 114 * Now returns an OS/2 return code instead of lerrno. 115 */ 116 int os2cli_errno(cli_state * cli) 117 { 118 if (cli->fd == -1) 119 { 120 return maperror( ENOTCONN); 121 } 122 return maperror(cli_errno(cli)); 123 } 124 39 125 void smbwrp_Logging() 40 126 { … … 59 145 60 146 } 61 62 static int 63 net_share_enum_rpc(struct cli_state *cli, 64 void (*fn)(const char *name, 65 uint32 type, 66 const char *comment, 67 void *state), 68 void *state) 69 { 70 int i; 71 NTSTATUS status; 72 WERROR werr; 73 uint32_t resume_handle = 0; 74 uint32_t total_entries = 0; 75 struct srvsvc_NetShareInfoCtr info_ctr; 76 struct srvsvc_NetShareCtr1 ctr1; 77 fstring name = ""; 78 fstring comment = ""; 79 void *mem_ctx; 80 struct rpc_pipe_client *pipe_hnd; 81 82 /* Open the server service pipe */ 83 status = cli_rpc_pipe_open_noauth(cli, &ndr_table_srvsvc.syntax_id, &pipe_hnd); 84 if (!NT_STATUS_IS_OK(status)) { 85 DEBUG(1, ("net_share_enum_rpc pipe open fail!\n")); 86 return -1; 87 } 88 89 /* Allocate a context for parsing and for the entries in "ctr" */ 90 mem_ctx = talloc_init("libsmbclient: net_share_enum_rpc"); 91 if (mem_ctx == NULL) { 92 DEBUG(0, ("out of memory for net_share_enum_rpc!\n")); 93 TALLOC_FREE(pipe_hnd); 94 return -1; 95 } 96 97 /* Issue the NetShareEnum RPC call and retrieve the response */ 98 ZERO_STRUCT(info_ctr); 99 ZERO_STRUCT(ctr1); 100 info_ctr.level = 1; 101 info_ctr.ctr.ctr1 = &ctr1; 102 status = rpccli_srvsvc_NetShareEnumAll(pipe_hnd, mem_ctx, 103 pipe_hnd->desthost, 104 &info_ctr, 105 0xffffffff, 106 &total_entries, 107 &resume_handle, 108 &werr); 109 110 /* Was it successful? */ 111 if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(werr) || info_ctr.ctr.ctr1->count == 0) { 112 /* Nope. Go clean up. */ 113 goto done; 114 } 115 116 /* For each returned entry... */ 117 for (i = 0; i < info_ctr.ctr.ctr1->count; i++) { 118 struct srvsvc_NetShareInfo1 info = info_ctr.ctr.ctr1->array[i]; 119 120 /* Add this share to the list */ 121 (*fn)(info.name, info.type, info.comment, state); 122 } 123 124 done: 125 /* Close the server service pipe */ 126 TALLOC_FREE(pipe_hnd); 127 128 /* Free all memory which was allocated for this request */ 129 TALLOC_FREE(mem_ctx); 130 131 /* Tell 'em if it worked */ 132 return W_ERROR_IS_OK(status) ? 0 : -1; 133 } 134 135 /* 136 * Wrapper for cli_errno to return not connected error on negative fd 137 * Now returns an OS/2 return code instead of lerrno. 138 */ 139 int os2cli_errno(cli_state * cli) 140 { 141 if (cli->fd == -1) 142 { 143 return maperror( ENOTCONN); 144 } 145 return maperror(cli_errno(cli)); 147 const char * smbwrp_getVersion() 148 { 149 return SAMBA_VERSION_STRING; 146 150 } 147 151
Note:
See TracChangeset
for help on using the changeset viewer.