~ubuntu-branches/ubuntu/gutsy/samba/gutsy-updates

« back to all changes in this revision

Viewing changes to source/rpcclient/cmd_dfs.c

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Mitchell
  • Date: 2006-11-28 20:14:37 UTC
  • mfrom: (0.10.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061128201437-a6x4lzlhempazocp
Tags: 3.0.23d-1ubuntu1
* Merge from debian unstable.
* Drop python2.4-samba, replace with python-samba. Added Conflicts/Replaces
  on python2.4-samba
* Drop track-connection-dos.patch, ubuntu-winbind-panic.patch, 
  ubuntu-fix-ldap.patch, ubuntu-setlocale.patch, ubuntu-setlocale-fixes.patch
* Remaining Ubuntu changes:
  - Revert Debian's installation of mount.cifs and umount.cifs as suid
  - Comment out the default [homes] shares and add more verbose comments to
    explain what they do and how they work (closes: launchpad.net/27608)
  - Add a "valid users = %S" stanza to the commented-out [homes] section, to
    show users how to restrict access to \\server\username to only username.
  - Change the (commented-out) "printer admin" example to use "@lpadmin"
    instead of "@ntadmin", since the lpadmin group is used for spool admin.
  - Alter the panic-action script to encourage users to report their
    bugs in Ubuntu packages to Ubuntu, rather than reporting to Debian.
    Modify text to more closely match the Debian script
  - Munge our init script to deal with the fact that our implementation
    (or lack thereof) of log_daemon_msg and log_progress_msg differs
    from Debian's implementation of the same (Ubuntu #19691)
  - Kept ubuntu-auxsrc.patch: some auxilliary sources (undocumented in 
    previous changelogs)
  - Set default workgroup to MSHOME

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
   RPC pipe client
4
4
 
5
5
   Copyright (C) Tim Potter 2000
 
6
   Copyright (C) Jelmer Vernooij       2005.
6
7
 
7
8
   This program is free software; you can redistribute it and/or modify
8
9
   it under the terms of the GNU General Public License as published by
27
28
static NTSTATUS cmd_dfs_exist(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
28
29
                              int argc, const char **argv)
29
30
{
30
 
        BOOL dfs_exists;
 
31
        uint32 dfs_exists;
31
32
        NTSTATUS result;
32
33
 
33
34
        if (argc != 1) {
35
36
                return NT_STATUS_OK;
36
37
        }
37
38
 
38
 
        result = rpccli_dfs_exist(cli, mem_ctx, &dfs_exists);
 
39
        result = rpccli_dfs_GetManagerVersion(cli, mem_ctx, &dfs_exists);
39
40
 
40
41
        if (NT_STATUS_IS_OK(result))
41
42
                printf("dfs is %spresent\n", dfs_exists ? "" : "not ");
47
48
                            int argc, const char **argv)
48
49
{
49
50
        NTSTATUS result;
50
 
        const char *entrypath, *servername, *sharename, *comment;
 
51
        const char *path, *servername, *sharename, *comment;
51
52
        uint32 flags = 0;
52
53
 
53
54
        if (argc != 5) {
54
 
                printf("Usage: %s entrypath servername sharename comment\n", 
 
55
                printf("Usage: %s path servername sharename comment\n", 
55
56
                       argv[0]);
56
57
                return NT_STATUS_OK;
57
58
        }
58
59
 
59
 
        entrypath = argv[1];
 
60
        path = argv[1];
60
61
        servername = argv[2];
61
62
        sharename = argv[3];
62
63
        comment = argv[4];
63
64
 
64
 
        result = rpccli_dfs_add(cli, mem_ctx, entrypath, servername, 
 
65
        result = rpccli_dfs_Add(cli, mem_ctx, path, servername, 
65
66
                             sharename, comment, flags);
66
67
 
67
68
        return result;
71
72
                               int argc, const char **argv)
72
73
{
73
74
        NTSTATUS result;
74
 
        const char *entrypath, *servername, *sharename;
 
75
        const char *path, *servername, *sharename;
75
76
 
76
77
        if (argc != 4) {
77
 
                printf("Usage: %s entrypath servername sharename\n", argv[0]);
 
78
                printf("Usage: %s path servername sharename\n", argv[0]);
78
79
                return NT_STATUS_OK;
79
80
        }
80
81
 
81
 
        entrypath = argv[1];
 
82
        path = argv[1];
82
83
        servername = argv[2];
83
84
        sharename = argv[3];
84
85
 
85
 
        result = rpccli_dfs_remove(cli, mem_ctx, entrypath, servername, 
 
86
        result = rpccli_dfs_Remove(cli, mem_ctx, path, servername, 
86
87
                                sharename);
87
88
 
88
89
        return result;
90
91
 
91
92
/* Display a DFS_INFO_1 structure */
92
93
 
93
 
static void display_dfs_info_1(DFS_INFO_1 *info1)
 
94
static void display_dfs_info_1(NETDFS_DFS_INFO1 *info1)
94
95
{
95
96
        fstring temp;
96
97
 
97
 
        unistr2_to_ascii(temp, &info1->entrypath, sizeof(temp) - 1);
98
 
        printf("entrypath: %s\n", temp);
 
98
        unistr2_to_ascii(temp, &info1->path, sizeof(temp) - 1);
 
99
        printf("path: %s\n", temp);
99
100
}
100
101
 
101
102
/* Display a DFS_INFO_2 structure */
102
103
 
103
 
static void display_dfs_info_2(DFS_INFO_2 *info2)
 
104
static void display_dfs_info_2(NETDFS_DFS_INFO2 *info2)
104
105
{
105
106
        fstring temp;
106
107
 
107
 
        unistr2_to_ascii(temp, &info2->entrypath, sizeof(temp) - 1);
108
 
        printf("entrypath: %s\n", temp);
 
108
        unistr2_to_ascii(temp, &info2->path, sizeof(temp) - 1);
 
109
        printf("path: %s\n", temp);
109
110
 
110
111
        unistr2_to_ascii(temp, &info2->comment, sizeof(temp) - 1);
111
112
        printf("\tcomment: %s\n", temp);
112
113
 
113
114
        printf("\tstate: %d\n", info2->state);
114
 
        printf("\tnum_storages: %d\n", info2->num_storages);
 
115
        printf("\tnum_stores: %d\n", info2->num_stores);
115
116
}
116
117
 
117
118
/* Display a DFS_INFO_3 structure */
118
119
 
119
 
static void display_dfs_info_3(DFS_INFO_3 *info3)
 
120
static void display_dfs_info_3(NETDFS_DFS_INFO3 *info3)
120
121
{
121
122
        fstring temp;
122
123
        int i;
123
124
 
124
 
        unistr2_to_ascii(temp, &info3->entrypath, sizeof(temp) - 1);
125
 
        printf("entrypath: %s\n", temp);
 
125
        unistr2_to_ascii(temp, &info3->path, sizeof(temp) - 1);
 
126
        printf("path: %s\n", temp);
126
127
 
127
128
        unistr2_to_ascii(temp, &info3->comment, sizeof(temp) - 1);
128
129
        printf("\tcomment: %s\n", temp);
129
130
 
130
131
        printf("\tstate: %d\n", info3->state);
131
 
        printf("\tnum_storages: %d\n", info3->num_storages);
132
 
 
133
 
        for (i = 0; i < info3->num_storages; i++) {
134
 
                DFS_STORAGE_INFO *dsi = &info3->storages[i];
135
 
 
136
 
                unistr2_to_ascii(temp, &dsi->servername, sizeof(temp) - 1);
137
 
                printf("\t\tstorage[%d] servername: %s\n", i, temp);
138
 
 
139
 
                unistr2_to_ascii(temp, &dsi->sharename, sizeof(temp) - 1);
140
 
                printf("\t\tstorage[%d] sharename: %s\n", i, temp);
 
132
        printf("\tnum_stores: %d\n", info3->num_stores);
 
133
 
 
134
        for (i = 0; i < info3->num_stores; i++) {
 
135
                NETDFS_DFS_STORAGEINFO *dsi = &info3->stores[i];
 
136
 
 
137
                unistr2_to_ascii(temp, &dsi->server, sizeof(temp) - 1);
 
138
                printf("\t\tstorage[%d] server: %s\n", i, temp);
 
139
 
 
140
                unistr2_to_ascii(temp, &dsi->share, sizeof(temp) - 1);
 
141
                printf("\t\tstorage[%d] share: %s\n", i, temp);
141
142
        }
142
143
}
143
144
 
 
145
 
144
146
/* Display a DFS_INFO_CTR structure */
145
 
 
146
 
static void display_dfs_info_ctr(DFS_INFO_CTR *ctr)
 
147
static void display_dfs_info(NETDFS_DFS_INFO_CTR *ctr)
147
148
{
148
 
        int i;
149
 
 
150
 
        for (i = 0; i < ctr->num_entries; i++) {
151
 
                switch (ctr->switch_value) {
 
149
        switch (ctr->switch_value) {
152
150
                case 0x01:
153
 
                        display_dfs_info_1(&ctr->dfs.info1[i]);
 
151
                        display_dfs_info_1(&ctr->u.info1);
154
152
                        break;
155
153
                case 0x02:
156
 
                        display_dfs_info_2(&ctr->dfs.info2[i]);
 
154
                        display_dfs_info_2(&ctr->u.info2);
157
155
                        break;
158
156
                case 0x03:
159
 
                        display_dfs_info_3(&ctr->dfs.info3[i]);
 
157
                        display_dfs_info_3(&ctr->u.info3);
160
158
                        break;
161
159
                default:
162
160
                        printf("unsupported info level %d\n", 
163
161
                               ctr->switch_value);
164
162
                        break;
 
163
        }
 
164
}
 
165
 
 
166
static void display_dfs_enumstruct(NETDFS_DFS_ENUMSTRUCT *ctr)
 
167
{
 
168
        int i;
 
169
        
 
170
        /* count is always the first element, so we can just use info1 here */
 
171
        for (i = 0; i < ctr->e.u.info1.count; i++) {
 
172
                switch (ctr->level) {
 
173
                case 1: display_dfs_info_1(&ctr->e.u.info1.s[i]); break;
 
174
                case 2: display_dfs_info_2(&ctr->e.u.info2.s[i]); break;
 
175
                case 3: display_dfs_info_3(&ctr->e.u.info3.s[i]); break;
 
176
                default:
 
177
                                printf("unsupported info level %d\n", 
 
178
                               ctr->level);
 
179
                                return;
165
180
                }
166
181
        }
167
182
}
171
186
static NTSTATUS cmd_dfs_enum(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx,
172
187
                             int argc, const char **argv)
173
188
{
174
 
        DFS_INFO_CTR ctr;
 
189
        NETDFS_DFS_ENUMSTRUCT str;
 
190
        NETDFS_DFS_ENUMINFO_CTR ctr;
175
191
        NTSTATUS result;
176
192
        uint32 info_level = 1;
 
193
        uint32 total = 0;
177
194
 
178
195
        if (argc > 2) {
179
196
                printf("Usage: %s [info_level]\n", argv[0]);
183
200
        if (argc == 2)
184
201
                info_level = atoi(argv[1]);
185
202
 
186
 
        result = rpccli_dfs_enum(cli, mem_ctx, info_level, &ctr);
 
203
        ZERO_STRUCT(ctr);
 
204
        init_netdfs_dfs_EnumStruct(&str, info_level, ctr);
 
205
        str.e.ptr0 = 1;
 
206
 
 
207
        result = rpccli_dfs_Enum(cli, mem_ctx, info_level, 0xFFFFFFFF, &str, &total);
187
208
 
188
209
        if (NT_STATUS_IS_OK(result))
189
 
                display_dfs_info_ctr(&ctr);
 
210
                display_dfs_enumstruct(&str);
190
211
 
191
212
        return result;
192
213
}
195
216
                                int argc, const char **argv)
196
217
{
197
218
        NTSTATUS result;
198
 
        const char *entrypath, *servername, *sharename;
 
219
        const char *path, *servername, *sharename;
199
220
        uint32 info_level = 1;
200
 
        DFS_INFO_CTR ctr;
 
221
        NETDFS_DFS_INFO_CTR ctr;
201
222
 
202
223
        if (argc < 4 || argc > 5) {
203
 
                printf("Usage: %s entrypath servername sharename "
 
224
                printf("Usage: %s path servername sharename "
204
225
                       "[info_level]\n", argv[0]);
205
226
                return NT_STATUS_OK;
206
227
        }
207
228
 
208
 
        entrypath = argv[1];
 
229
        path = argv[1];
209
230
        servername = argv[2];
210
231
        sharename = argv[3];
211
232
 
212
233
        if (argc == 5)
213
234
                info_level = atoi(argv[4]);
214
235
 
215
 
        result = rpccli_dfs_get_info(cli, mem_ctx, entrypath, servername, 
 
236
        result = rpccli_dfs_GetInfo(cli, mem_ctx, path, servername, 
216
237
                                  sharename, info_level, &ctr);
217
238
 
218
239
        if (NT_STATUS_IS_OK(result))
219
 
                display_dfs_info_ctr(&ctr);
 
240
                display_dfs_info(&ctr);
220
241
 
221
242
        return result;
222
243
}