~ubuntu-branches/ubuntu/vivid/samba/vivid

« back to all changes in this revision

Viewing changes to source3/rpcclient/cmd_echo.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "includes.h"
22
22
#include "rpcclient.h"
23
 
#include "../librpc/gen_ndr/cli_echo.h"
 
23
#include "../librpc/gen_ndr/ndr_echo_c.h"
24
24
 
25
25
static NTSTATUS cmd_echo_add_one(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
26
26
                                 int argc, const char **argv)
27
27
{
 
28
        struct dcerpc_binding_handle *b = cli->binding_handle;
28
29
        uint32 request = 1, response;
29
 
        NTSTATUS result;
 
30
        NTSTATUS status;
30
31
 
31
32
        if (argc > 2) {
32
33
                printf("Usage: %s [num]\n", argv[0]);
33
34
                return NT_STATUS_OK;
34
35
        }
35
36
 
36
 
        if (argc == 2)
 
37
        if (argc == 2) {
37
38
                request = atoi(argv[1]);
38
 
 
39
 
        result = rpccli_echo_AddOne(cli, mem_ctx, request, &response);
40
 
 
41
 
        if (!NT_STATUS_IS_OK(result))
 
39
        }
 
40
 
 
41
        status = dcerpc_echo_AddOne(b, mem_ctx, request, &response);
 
42
        if (!NT_STATUS_IS_OK(status)) {
42
43
                goto done;
 
44
        }
43
45
 
44
46
        printf("%d + 1 = %d\n", request, response);
45
47
 
46
48
done:
47
 
        return result;
 
49
        return status;
48
50
}
49
51
 
50
52
static NTSTATUS cmd_echo_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
51
53
                              int argc, const char **argv)
52
54
{
 
55
        struct dcerpc_binding_handle *b = cli->binding_handle;
53
56
        uint32 size, i;
54
 
        NTSTATUS result;
 
57
        NTSTATUS status;
55
58
        uint8_t *in_data = NULL, *out_data = NULL;
56
59
 
57
60
        if (argc != 2) {
63
66
        if ( (in_data = (uint8_t*)SMB_MALLOC(size)) == NULL ) {
64
67
                printf("Failure to allocate buff of %d bytes\n",
65
68
                       size);
66
 
                result = NT_STATUS_NO_MEMORY;
 
69
                status = NT_STATUS_NO_MEMORY;
67
70
                goto done;
68
71
        }
69
72
        if ( (out_data = (uint8_t*)SMB_MALLOC(size)) == NULL ) {
70
73
                printf("Failure to allocate buff of %d bytes\n",
71
74
                       size);
72
 
                result = NT_STATUS_NO_MEMORY;
 
75
                status = NT_STATUS_NO_MEMORY;
73
76
                goto done;
74
77
        }
75
78
 
76
 
        for (i = 0; i < size; i++)
 
79
        for (i = 0; i < size; i++) {
77
80
                in_data[i] = i & 0xff;
78
 
 
79
 
        result = rpccli_echo_EchoData(cli, mem_ctx, size, in_data, out_data);
80
 
 
81
 
        if (!NT_STATUS_IS_OK(result))
 
81
        }
 
82
 
 
83
        status = dcerpc_echo_EchoData(b, mem_ctx, size, in_data, out_data);
 
84
        if (!NT_STATUS_IS_OK(status)) {
82
85
                goto done;
 
86
        }
83
87
 
84
88
        for (i = 0; i < size; i++) {
85
89
                if (in_data[i] != out_data[i]) {
86
90
                        printf("mismatch at offset %d, %d != %d\n",
87
91
                               i, in_data[i], out_data[i]);
88
 
                        result = NT_STATUS_UNSUCCESSFUL;
 
92
                        status = NT_STATUS_UNSUCCESSFUL;
89
93
                }
90
94
        }
91
95
 
93
97
        SAFE_FREE(in_data);
94
98
        SAFE_FREE(out_data);
95
99
 
96
 
        return result;
 
100
        return status;
97
101
}
98
102
 
99
103
static NTSTATUS cmd_echo_source_data(struct rpc_pipe_client *cli, 
100
104
                                     TALLOC_CTX *mem_ctx, int argc, 
101
105
                                     const char **argv)
102
106
{
 
107
        struct dcerpc_binding_handle *b = cli->binding_handle;
103
108
        uint32 size, i;
104
 
        NTSTATUS result;
 
109
        NTSTATUS status;
105
110
        uint8_t *out_data = NULL;
106
111
 
107
112
        if (argc != 2) {
113
118
        if ( (out_data = (uint8_t*)SMB_MALLOC(size)) == NULL ) {
114
119
                printf("Failure to allocate buff of %d bytes\n",
115
120
                       size);
116
 
                result = NT_STATUS_NO_MEMORY;
 
121
                status = NT_STATUS_NO_MEMORY;
117
122
                goto done;              
118
123
        }
119
124
        
120
125
 
121
 
        result = rpccli_echo_SourceData(cli, mem_ctx, size, out_data);
122
 
 
123
 
        if (!NT_STATUS_IS_OK(result))
 
126
        status = dcerpc_echo_SourceData(b, mem_ctx, size, out_data);
 
127
        if (!NT_STATUS_IS_OK(status)) {
124
128
                goto done;
 
129
        }
125
130
 
126
131
        for (i = 0; i < size; i++) {
127
132
                if (out_data && out_data[i] != (i & 0xff)) {
128
133
                        printf("mismatch at offset %d, %d != %d\n",
129
134
                               i, out_data[i], i & 0xff);
130
 
                        result = NT_STATUS_UNSUCCESSFUL;
 
135
                        status = NT_STATUS_UNSUCCESSFUL;
131
136
                }
132
137
        }
133
138
 
134
139
done:
135
140
 
136
141
        SAFE_FREE(out_data);
137
 
        return result;
 
142
        return status;
138
143
}
139
144
 
140
145
static NTSTATUS cmd_echo_sink_data(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
141
146
                                   int argc, const char **argv)
142
147
{
 
148
        struct dcerpc_binding_handle *b = cli->binding_handle;
143
149
        uint32 size, i;
144
 
        NTSTATUS result;
 
150
        NTSTATUS status;
145
151
        uint8_t *in_data = NULL;
146
152
 
147
153
        if (argc != 2) {
153
159
        if ( (in_data = (uint8_t*)SMB_MALLOC(size)) == NULL ) {
154
160
                printf("Failure to allocate buff of %d bytes\n",
155
161
                       size);
156
 
                result = NT_STATUS_NO_MEMORY;
 
162
                status = NT_STATUS_NO_MEMORY;
157
163
                goto done;              
158
164
        }
159
165
 
160
 
        for (i = 0; i < size; i++)
 
166
        for (i = 0; i < size; i++) {
161
167
                in_data[i] = i & 0xff;
162
 
 
163
 
        result = rpccli_echo_SinkData(cli, mem_ctx, size, in_data);
164
 
 
165
 
        if (!NT_STATUS_IS_OK(result))
 
168
        }
 
169
 
 
170
        status = dcerpc_echo_SinkData(b, mem_ctx, size, in_data);
 
171
        if (!NT_STATUS_IS_OK(status)) {
166
172
                goto done;
 
173
        }
167
174
 
168
175
done:
169
176
        SAFE_FREE(in_data);
170
177
 
171
 
        return result;
 
178
        return status;
172
179
}
173
180
 
174
181
/* List of commands exported by this module */