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

« back to all changes in this revision

Viewing changes to source4/nbt_server/register.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:
93
93
           registration packets */
94
94
        io.in.name            = iname->name;
95
95
        io.in.dest_addr       = iface->bcast_address;
96
 
        io.in.dest_port       = lp_nbt_port(iface->nbtsrv->task->lp_ctx);
 
96
        io.in.dest_port       = lpcfg_nbt_port(iface->nbtsrv->task->lp_ctx);
97
97
        io.in.address         = iface->ip_address;
98
98
        io.in.nb_flags        = iname->nb_flags;
99
99
        io.in.ttl             = iname->ttl;
118
118
static void nbtd_start_refresh_timer(struct nbtd_iface_name *iname)
119
119
{
120
120
        uint32_t refresh_time;
121
 
        uint32_t max_refresh_time = lp_parm_int(iname->iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "max_refresh_time", 7200);
 
121
        uint32_t max_refresh_time = lpcfg_parm_int(iname->iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "max_refresh_time", 7200);
122
122
 
123
123
        refresh_time = MIN(max_refresh_time, iname->ttl/2);
124
124
        
128
128
                        name_refresh_handler, iname);
129
129
}
130
130
 
 
131
struct nbtd_register_name_state {
 
132
        struct nbtd_iface_name *iname;
 
133
        struct nbt_name_register_bcast io;
 
134
};
131
135
 
132
136
/*
133
137
  a name registration has completed
134
138
*/
135
 
static void nbtd_register_handler(struct composite_context *creq)
 
139
static void nbtd_register_name_handler(struct tevent_req *subreq)
136
140
{
137
 
        struct nbtd_iface_name *iname = talloc_get_type(creq->async.private_data, 
138
 
                                                        struct nbtd_iface_name);
 
141
        struct nbtd_register_name_state *state =
 
142
                tevent_req_callback_data(subreq,
 
143
                struct nbtd_register_name_state);
 
144
        struct nbtd_iface_name *iname = state->iname;
139
145
        NTSTATUS status;
140
 
        TALLOC_CTX *tmp_ctx = talloc_new(iname);
141
146
 
142
 
        status = nbt_name_register_bcast_recv(creq);
 
147
        status = nbt_name_register_bcast_recv(subreq);
 
148
        TALLOC_FREE(subreq);
143
149
        if (NT_STATUS_IS_OK(status)) {
144
150
                /* good - nobody complained about our registration */
145
151
                iname->nb_flags |= NBT_NM_ACTIVE;
146
152
                DEBUG(3,("Registered %s with %s on interface %s\n",
147
 
                         nbt_name_string(tmp_ctx, &iname->name), 
 
153
                         nbt_name_string(state, &iname->name),
148
154
                         iname->iface->ip_address, iname->iface->bcast_address));
149
155
                iname->registration_time = timeval_current();
150
 
                talloc_free(tmp_ctx);
 
156
                talloc_free(state);
151
157
                nbtd_start_refresh_timer(iname);
152
158
                return;
153
159
        }
156
162
        iname->nb_flags |= NBT_NM_CONFLICT;
157
163
 
158
164
        DEBUG(1,("Error registering %s with %s on interface %s - %s\n",
159
 
                 nbt_name_string(tmp_ctx, &iname->name),
 
165
                 nbt_name_string(state, &iname->name),
160
166
                 iname->iface->ip_address, iname->iface->bcast_address,
161
167
                 nt_errstr(status)));
162
 
        talloc_free(tmp_ctx);
 
168
        talloc_free(state);
163
169
}
164
170
 
165
171
 
171
177
                                     uint16_t nb_flags)
172
178
{
173
179
        struct nbtd_iface_name *iname;
174
 
        const char *scope = lp_netbios_scope(iface->nbtsrv->task->lp_ctx);
175
 
        struct nbt_name_register_bcast io;
176
 
        struct composite_context *creq;
 
180
        const char *scope = lpcfg_netbios_scope(iface->nbtsrv->task->lp_ctx);
 
181
        struct nbtd_register_name_state *state;
 
182
        struct tevent_req *subreq;
177
183
        struct nbtd_server *nbtsrv = iface->nbtsrv;
178
184
 
179
185
        iname = talloc(iface, struct nbtd_iface_name);
188
194
                iname->name.scope = NULL;
189
195
        }
190
196
        iname->nb_flags          = nb_flags;
191
 
        iname->ttl               = lp_parm_int(iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "bcast_ttl", 300000);
 
197
        iname->ttl               = lpcfg_parm_int(iface->nbtsrv->task->lp_ctx, NULL, "nbtd", "bcast_ttl", 300000);
192
198
        iname->registration_time = timeval_zero();
193
199
        iname->wins_server       = NULL;
194
200
 
208
214
                return;
209
215
        }
210
216
 
 
217
        state = talloc_zero(iname, struct nbtd_register_name_state);
 
218
        if (state == NULL) {
 
219
                return;
 
220
        }
 
221
 
 
222
        state->iname = iname;
 
223
 
211
224
        /* setup a broadcast name registration request */
212
 
        io.in.name            = iname->name;
213
 
        io.in.dest_addr       = iface->bcast_address;
214
 
        io.in.dest_port       = lp_nbt_port(iface->nbtsrv->task->lp_ctx);
215
 
        io.in.address         = iface->ip_address;
216
 
        io.in.nb_flags        = nb_flags;
217
 
        io.in.ttl             = iname->ttl;
 
225
        state->io.in.name      = iname->name;
 
226
        state->io.in.dest_addr = iface->bcast_address;
 
227
        state->io.in.dest_port = lpcfg_nbt_port(iface->nbtsrv->task->lp_ctx);
 
228
        state->io.in.address   = iface->ip_address;
 
229
        state->io.in.nb_flags  = nb_flags;
 
230
        state->io.in.ttl       = iname->ttl;
218
231
 
219
232
        nbtsrv->stats.total_sent++;
220
 
        creq = nbt_name_register_bcast_send(iface->nbtsock, &io);
221
 
        if (creq == NULL) return;
222
 
 
223
 
        creq->async.fn = nbtd_register_handler;
224
 
        creq->async.private_data = iname;
 
233
 
 
234
        subreq = nbt_name_register_bcast_send(state, nbtsrv->task->event_ctx,
 
235
                                              iface->nbtsock, &state->io);
 
236
        if (subreq == NULL) {
 
237
                return;
 
238
        }
 
239
 
 
240
        tevent_req_set_callback(subreq, nbtd_register_name_handler, state);
225
241
}
226
242
 
227
243
 
262
278
 
263
279
        /* note that we don't initially mark the names "ACTIVE". They are 
264
280
           marked active once registration is successful */
265
 
        nbtd_register_name(nbtsrv, lp_netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_CLIENT, nb_flags);
266
 
        nbtd_register_name(nbtsrv, lp_netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_USER,   nb_flags);
267
 
        nbtd_register_name(nbtsrv, lp_netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_SERVER, nb_flags);
 
281
        nbtd_register_name(nbtsrv, lpcfg_netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_CLIENT, nb_flags);
 
282
        nbtd_register_name(nbtsrv, lpcfg_netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_USER,   nb_flags);
 
283
        nbtd_register_name(nbtsrv, lpcfg_netbios_name(nbtsrv->task->lp_ctx), NBT_NAME_SERVER, nb_flags);
268
284
 
269
 
        aliases = lp_netbios_aliases(nbtsrv->task->lp_ctx);
 
285
        aliases = lpcfg_netbios_aliases(nbtsrv->task->lp_ctx);
270
286
        while (aliases && aliases[0]) {
271
287
                nbtd_register_name(nbtsrv, aliases[0], NBT_NAME_CLIENT, nb_flags);
272
288
                nbtd_register_name(nbtsrv, aliases[0], NBT_NAME_SERVER, nb_flags);
273
289
                aliases++;
274
290
        }
275
291
 
276
 
        if (lp_server_role(nbtsrv->task->lp_ctx) == ROLE_DOMAIN_CONTROLLER)     {
 
292
        if (lpcfg_server_role(nbtsrv->task->lp_ctx) == ROLE_DOMAIN_CONTROLLER)  {
277
293
                bool is_pdc = samdb_is_pdc(nbtsrv->sam_ctx);
278
294
                if (is_pdc) {
279
 
                        nbtd_register_name(nbtsrv, lp_workgroup(nbtsrv->task->lp_ctx),
 
295
                        nbtd_register_name(nbtsrv, lpcfg_workgroup(nbtsrv->task->lp_ctx),
280
296
                                           NBT_NAME_PDC, nb_flags);
281
297
                }
282
 
                nbtd_register_name(nbtsrv, lp_workgroup(nbtsrv->task->lp_ctx),
 
298
                nbtd_register_name(nbtsrv, lpcfg_workgroup(nbtsrv->task->lp_ctx),
283
299
                                   NBT_NAME_LOGON, nb_flags | NBT_NM_GROUP);
284
300
        }
285
301
 
286
302
        nb_flags |= NBT_NM_GROUP;
287
 
        nbtd_register_name(nbtsrv, lp_workgroup(nbtsrv->task->lp_ctx), NBT_NAME_CLIENT, nb_flags);
 
303
        nbtd_register_name(nbtsrv, lpcfg_workgroup(nbtsrv->task->lp_ctx), NBT_NAME_CLIENT, nb_flags);
288
304
 
289
305
        nb_flags |= NBT_NM_PERMANENT;
290
306
        nbtd_register_name(nbtsrv, "__SAMBA__",       NBT_NAME_CLIENT, nb_flags);