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

« back to all changes in this revision

Viewing changes to source3/utils/smbfilter.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:
2
2
   Unix SMB/CIFS implementation.
3
3
   SMB filter/socket plugin
4
4
   Copyright (C) Andrew Tridgell 1999
5
 
   
 
5
 
6
6
   This program is free software; you can redistribute it and/or modify
7
7
   it under the terms of the GNU General Public License as published by
8
8
   the Free Software Foundation; either version 3 of the License, or
9
9
   (at your option) any later version.
10
 
   
 
10
 
11
11
   This program is distributed in the hope that it will be useful,
12
12
   but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
14
   GNU General Public License for more details.
15
 
   
 
15
 
16
16
   You should have received a copy of the GNU General Public License
17
17
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
18
*/
19
19
 
20
20
#include "includes.h"
 
21
#include "system/filesys.h"
 
22
#include "system/select.h"
 
23
#include "../lib/util/select.h"
 
24
#include "libsmb/nmblib.h"
21
25
 
22
26
#define SECURITY_MASK 0
23
27
#define SECURITY_SET  0
43
47
        }
44
48
        if (write(fd, ppacket, length) != length) {
45
49
                fprintf(stderr,"Failed to write %s\n", fname);
 
50
                close(fd);
46
51
                return;
47
52
        }
48
53
        close(fd);
189
194
        }
190
195
 
191
196
        while (c != -1 || s != -1) {
192
 
                fd_set fds;
193
 
                int num;
194
 
                
195
 
                FD_ZERO(&fds);
196
 
                if (s >= 0 && s < FD_SETSIZE) FD_SET(s, &fds);
197
 
                if (c >= 0 && c < FD_SETSIZE) FD_SET(c, &fds);
198
 
 
199
 
                num = sys_select_intr(MAX(s+1, c+1),&fds,NULL,NULL,NULL);
200
 
                if (num <= 0) continue;
201
 
                
202
 
                if (c != -1 && FD_ISSET(c, &fds)) {
 
197
                struct pollfd fds[2];
 
198
                int num_fds, ret;
 
199
 
 
200
                memset(fds, 0, sizeof(struct pollfd) * 2);
 
201
                fds[0].fd = -1;
 
202
                fds[1].fd = -1;
 
203
                num_fds = 0;
 
204
 
 
205
                if (s != -1) {
 
206
                        fds[num_fds].fd = s;
 
207
                        fds[num_fds].events = POLLIN|POLLHUP;
 
208
                        num_fds += 1;
 
209
                }
 
210
                if (c != -1) {
 
211
                        fds[num_fds].fd = c;
 
212
                        fds[num_fds].events = POLLIN|POLLHUP;
 
213
                        num_fds += 1;
 
214
                }
 
215
 
 
216
                ret = sys_poll_intr(fds, num_fds, -1);
 
217
                if (ret <= 0) {
 
218
                        continue;
 
219
                }
 
220
 
 
221
                /*
 
222
                 * find c in fds and see if it's readable
 
223
                 */
 
224
                if ((c != -1) &&
 
225
                    (((fds[0].fd == c)
 
226
                      && (fds[0].revents & (POLLIN|POLLHUP|POLLERR))) ||
 
227
                     ((fds[1].fd == c)
 
228
                      && (fds[1].revents & (POLLIN|POLLHUP|POLLERR))))) {
203
229
                        size_t len;
204
230
                        if (!NT_STATUS_IS_OK(receive_smb_raw(
205
231
                                                        c, packet, sizeof(packet),
213
239
                                exit(1);
214
240
                        }                       
215
241
                }
216
 
                if (s != -1 && FD_ISSET(s, &fds)) {
 
242
 
 
243
                /*
 
244
                 * find s in fds and see if it's readable
 
245
                 */
 
246
                if ((s != -1) &&
 
247
                    (((fds[0].fd == s)
 
248
                      && (fds[0].revents & (POLLIN|POLLHUP|POLLERR))) ||
 
249
                     ((fds[1].fd == s)
 
250
                      && (fds[1].revents & (POLLIN|POLLHUP|POLLERR))))) {
217
251
                        size_t len;
218
252
                        if (!NT_STATUS_IS_OK(receive_smb_raw(
219
253
                                                        s, packet, sizeof(packet),
245
279
 
246
280
        zero_sockaddr(&my_ss);
247
281
        s = open_socket_in(SOCK_STREAM, 445, 0, &my_ss, True);
248
 
        
 
282
 
249
283
        if (s == -1) {
250
284
                d_printf("bind failed\n");
251
285
                exit(1);
261
295
        }
262
296
 
263
297
        while (1) {
264
 
                fd_set fds;
265
 
                int num;
 
298
                int num, revents;
266
299
                struct sockaddr_storage ss;
267
300
                socklen_t in_addrlen = sizeof(ss);
268
 
                
269
 
                FD_ZERO(&fds);
270
 
                if (s < 0 || s >= FD_SETSIZE) {
271
 
                        break;
272
 
                }
273
 
                FD_SET(s, &fds);
274
301
 
275
 
                num = sys_select_intr(s+1,&fds,NULL,NULL,NULL);
276
 
                if (num > 0) {
 
302
                num = poll_intr_one_fd(s, POLLIN|POLLHUP, -1, &revents);
 
303
                if ((num > 0) && (revents & (POLLIN|POLLHUP|POLLERR))) {
277
304
                        c = accept(s, (struct sockaddr *)&ss, &in_addrlen);
278
305
                        if (c != -1) {
279
306
                                if (fork() == 0) {
297
324
 
298
325
        load_case_tables();
299
326
 
300
 
        setup_logging(argv[0],True);
 
327
        setup_logging(argv[0], DEBUG_STDOUT);
301
328
 
302
329
        configfile = get_dyn_CONFIGFILE();
303
330