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

« back to all changes in this revision

Viewing changes to source4/rpc_server/srvsvc/dcesrv_srvsvc.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:
24
24
#include "rpc_server/dcerpc_server.h"
25
25
#include "librpc/gen_ndr/ndr_srvsvc.h"
26
26
#include "rpc_server/common/common.h"
 
27
#include "rpc_server/common/share.h"
27
28
#include "auth/auth.h"
28
29
#include "libcli/security/security.h"
29
30
#include "system/time.h"
33
34
#define SRVSVC_CHECK_ADMIN_ACCESS do { \
34
35
        struct security_token *t = dce_call->conn->auth_state.session_info->security_token; \
35
36
        if (!security_token_has_builtin_administrators(t) && \
36
 
            !security_token_has_sid_string(t, SID_BUILTIN_SERVER_OPERATORS)) { \
 
37
            !security_token_has_sid(t, &global_sid_Builtin_Server_Operators)) { \
37
38
                return WERR_ACCESS_DENIED; \
38
39
        } \
39
40
} while (0)
68
69
        default:
69
70
                return WERR_UNKNOWN_LEVEL;
70
71
        }
71
 
 
72
 
        return WERR_OK;
73
72
}
74
73
 
75
74
 
93
92
        default:
94
93
                return WERR_UNKNOWN_LEVEL;
95
94
        }
96
 
 
97
 
        return WERR_UNKNOWN_LEVEL;
98
95
}
99
96
 
100
97
 
140
137
        default:
141
138
                return WERR_UNKNOWN_LEVEL;
142
139
        }
143
 
 
144
 
        return WERR_UNKNOWN_LEVEL;
145
140
}
146
141
 
147
142
 
165
160
        default:
166
161
                return WERR_UNKNOWN_LEVEL;
167
162
        }
168
 
 
169
 
        return WERR_UNKNOWN_LEVEL;
170
163
}
171
164
 
172
165
 
194
187
        default:
195
188
                return WERR_UNKNOWN_LEVEL;
196
189
        }
197
 
 
198
 
        return WERR_UNKNOWN_LEVEL;
199
190
}
200
191
 
201
192
 
251
242
        default:
252
243
                return WERR_UNKNOWN_LEVEL;
253
244
        }
254
 
 
255
 
        return WERR_UNKNOWN_LEVEL;
256
245
}
257
246
 
258
247
 
288
277
        default:
289
278
                return WERR_UNKNOWN_LEVEL;
290
279
        }
291
 
 
292
 
        return WERR_UNKNOWN_LEVEL;
293
280
}
294
281
 
295
282
 
313
300
        default:
314
301
                return WERR_UNKNOWN_LEVEL;
315
302
        }
316
 
 
317
 
        return WERR_UNKNOWN_LEVEL;
318
303
}
319
304
 
320
305
 
390
375
        default:
391
376
                return WERR_UNKNOWN_LEVEL;
392
377
        }
393
 
 
394
 
        return WERR_UNKNOWN_LEVEL;
395
378
}
396
379
 
397
380
 
431
414
                NTSTATUS nterr;
432
415
                struct share_info *info;
433
416
                struct share_context *sctx;
434
 
                int count = 8;
435
 
                int i;
 
417
                unsigned int count = 8;
 
418
                unsigned int i;
436
419
 
437
 
                nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
 
420
                nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
438
421
                if (!NT_STATUS_IS_OK(nterr)) {
439
422
                        return ntstatus_to_werror(nterr);
440
423
                }
448
431
                info[i].name = SHARE_TYPE;
449
432
                info[i].type = SHARE_INFO_STRING;
450
433
                switch (r->in.info->info2->type) {
451
 
                case 0x00:
 
434
                case STYPE_DISKTREE:
452
435
                        info[i].value = talloc_strdup(info, "DISK");
453
436
                        break;
454
 
                case 0x01:
 
437
                case STYPE_PRINTQ:
455
438
                        info[i].value = talloc_strdup(info, "PRINTER");
456
439
                        break;
457
 
                case 0x03:
 
440
                case STYPE_IPC:
458
441
                        info[i].value = talloc_strdup(info, "IPC");
459
442
                        break;
460
443
                default:
529
512
                NTSTATUS nterr;
530
513
                struct share_info *info;
531
514
                struct share_context *sctx;
532
 
                int count = 10;
533
 
                int i;
 
515
                unsigned int count = 10;
 
516
                unsigned int i;
534
517
 
535
 
                nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
 
518
                nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
536
519
                if (!NT_STATUS_IS_OK(nterr)) {
537
520
                        return ntstatus_to_werror(nterr);
538
521
                }
618
601
        default:
619
602
                return WERR_UNKNOWN_LEVEL;
620
603
        }
621
 
 
622
 
        return WERR_UNKNOWN_LEVEL;
623
604
}
624
605
 
625
606
static WERROR dcesrv_srvsvc_fiel_ShareInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx,
699
680
        default:
700
681
                return WERR_UNKNOWN_LEVEL;
701
682
        }
702
 
 
703
 
        return WERR_UNKNOWN_LEVEL;
704
683
}
705
684
 
706
685
/* 
720
699
        /* TODO: - paging of results 
721
700
         */
722
701
 
723
 
        nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
 
702
        nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
724
703
        if (!NT_STATUS_IS_OK(nterr)) {
725
704
                return ntstatus_to_werror(nterr);
726
705
        }
733
712
        switch (r->in.info_ctr->level) {
734
713
        case 0:
735
714
        {
736
 
                int i;
 
715
                unsigned int i;
737
716
                struct srvsvc_NetShareCtr0 *ctr0;
738
717
 
739
718
                ctr0 = talloc(mem_ctx, struct srvsvc_NetShareCtr0);
774
753
        }
775
754
        case 1:
776
755
        {
777
 
                int i;
 
756
                unsigned int i;
778
757
                struct srvsvc_NetShareCtr1 *ctr1;
779
758
 
780
759
                ctr1 = talloc(mem_ctx, struct srvsvc_NetShareCtr1);
816
795
        }
817
796
        case 2:
818
797
        {
819
 
                int i;
 
798
                unsigned int i;
820
799
                struct srvsvc_NetShareCtr2 *ctr2;
821
800
 
822
801
                SRVSVC_CHECK_ADMIN_ACCESS;
860
839
        }
861
840
        case 501:
862
841
        {
863
 
                int i;
 
842
                unsigned int i;
864
843
                struct srvsvc_NetShareCtr501 *ctr501;
865
844
 
866
845
                SRVSVC_CHECK_ADMIN_ACCESS;
904
883
        }
905
884
        case 502:
906
885
        {
907
 
                int i;
 
886
                unsigned int i;
908
887
                struct srvsvc_NetShareCtr502 *ctr502;
909
888
 
910
889
                SRVSVC_CHECK_ADMIN_ACCESS;
949
928
        default:
950
929
                return WERR_UNKNOWN_LEVEL;
951
930
        }
952
 
 
953
 
        return WERR_UNKNOWN_LEVEL;
954
931
}
955
932
 
956
933
 
973
950
                return WERR_INVALID_PARAM;
974
951
        }
975
952
 
976
 
        nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
 
953
        nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
977
954
        if (!NT_STATUS_IS_OK(nterr)) {
978
955
                return ntstatus_to_werror(nterr);
979
956
        }
1087
1064
        default:
1088
1065
                return WERR_UNKNOWN_LEVEL;
1089
1066
        }
1090
 
 
1091
 
        return WERR_UNKNOWN_LEVEL;
1092
1067
}
1093
1068
 
1094
1069
static WERROR dcesrv_srvsvc_fill_share_info(struct share_info *info, int *count,
1102
1077
                                        uint32_t csc_policy,
1103
1078
                                        struct security_descriptor *sd)
1104
1079
{
1105
 
        int i = 0;
 
1080
        unsigned int i = 0;
1106
1081
 
1107
1082
        if (level == 501) {
1108
1083
                info[i].name = SHARE_CSC_POLICY;
1221
1196
        info = talloc_array(mem_ctx, struct share_info, 10);
1222
1197
        W_ERROR_HAVE_NO_MEMORY(info);
1223
1198
 
1224
 
        ZERO_STRUCT(r->out);
1225
 
 
1226
1199
        if (strcmp("", r->in.share_name) == 0) {
1227
1200
                return WERR_INVALID_PARAM;
1228
1201
        }
1229
1202
 
1230
 
        nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
 
1203
        nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
1231
1204
        if (!NT_STATUS_IS_OK(nterr)) {
1232
1205
                return ntstatus_to_werror(nterr);
1233
1206
        }
1383
1356
        struct share_config *scfg = NULL;
1384
1357
        char *device;
1385
1358
        const char **names;
1386
 
        int count, i;
 
1359
        int count;
 
1360
        int i;
1387
1361
 
1388
1362
        *r->out.type = 0;
1389
1363
 
1404
1378
        }
1405
1379
        all_string_sub(device, "\\", "/", 0);
1406
1380
 
1407
 
        nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
 
1381
        nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
1408
1382
        if (!NT_STATUS_IS_OK(nterr)) {
1409
1383
                return ntstatus_to_werror(nterr);
1410
1384
        }
1457
1431
                       struct srvsvc_NetSrvGetInfo *r)
1458
1432
{
1459
1433
        struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
1460
 
        struct dcerpc_server_info *server_info = lp_dcerpc_server_info(mem_ctx, dce_ctx->lp_ctx);
 
1434
        struct dcerpc_server_info *server_info = lpcfg_dcerpc_server_info(mem_ctx, dce_ctx->lp_ctx);
1461
1435
 
1462
1436
        ZERO_STRUCTP(r->out.info);
1463
1437
 
1490
1464
                info101->version_major  = server_info->version_major;
1491
1465
                info101->version_minor  = server_info->version_minor;
1492
1466
                info101->server_type    = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
1493
 
                info101->comment        = talloc_strdup(mem_ctx, lp_serverstring(dce_ctx->lp_ctx));
 
1467
                info101->comment        = talloc_strdup(mem_ctx, lpcfg_serverstring(dce_ctx->lp_ctx));
1494
1468
                W_ERROR_HAVE_NO_MEMORY(info101->comment);
1495
1469
 
1496
1470
                r->out.info->info101 = info101;
1510
1484
                info102->version_major  = server_info->version_major;
1511
1485
                info102->version_minor  = server_info->version_minor;
1512
1486
                info102->server_type    = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
1513
 
                info102->comment        = talloc_strdup(mem_ctx, lp_serverstring(dce_ctx->lp_ctx));
 
1487
                info102->comment        = talloc_strdup(mem_ctx, lpcfg_serverstring(dce_ctx->lp_ctx));
1514
1488
                W_ERROR_HAVE_NO_MEMORY(info102->comment);
1515
1489
 
1516
1490
                info102->users          = dcesrv_common_get_users(mem_ctx, dce_ctx);
1528
1502
        default:
1529
1503
                return WERR_UNKNOWN_LEVEL;
1530
1504
        }
1531
 
 
1532
 
        return WERR_UNKNOWN_LEVEL;
1533
1505
}
1534
1506
 
1535
1507
 
1576
1548
        default:
1577
1549
                return WERR_UNKNOWN_LEVEL;
1578
1550
        }
1579
 
 
1580
 
        return WERR_UNKNOWN_LEVEL;
1581
1551
}
1582
1552
 
1583
1553
 
1657
1627
        default:
1658
1628
                return WERR_UNKNOWN_LEVEL;
1659
1629
        }
1660
 
 
1661
 
        return WERR_UNKNOWN_LEVEL;
1662
1630
}
1663
1631
 
1664
1632
/* 
1787
1755
        default:
1788
1756
                return WERR_INVALID_PARAM;
1789
1757
        }
1790
 
 
1791
 
        return WERR_INVALID_PARAM;
1792
1758
}
1793
1759
 
1794
1760
 
1820
1786
        /* TODO: - paging of results 
1821
1787
         */
1822
1788
 
1823
 
        nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
 
1789
        nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
1824
1790
        if (!NT_STATUS_IS_OK(nterr)) {
1825
1791
                return ntstatus_to_werror(nterr);
1826
1792
        }
1833
1799
        switch (r->in.info_ctr->level) {
1834
1800
        case 0:
1835
1801
        {
1836
 
                int i, y = 0;
1837
 
                int count;
 
1802
                unsigned int i, y = 0;
 
1803
                unsigned int count;
1838
1804
                struct srvsvc_NetShareCtr0 *ctr0;
1839
1805
 
1840
1806
                ctr0 = talloc(mem_ctx, struct srvsvc_NetShareCtr0);
1885
1851
        }
1886
1852
        case 1:
1887
1853
        {
1888
 
                int i, y = 0;
1889
 
                int count;
 
1854
                unsigned int i, y = 0;
 
1855
                unsigned int count;
1890
1856
                struct srvsvc_NetShareCtr1 *ctr1;
1891
1857
 
1892
1858
                ctr1 = talloc(mem_ctx, struct srvsvc_NetShareCtr1);
1937
1903
        }
1938
1904
        case 2:
1939
1905
        {
1940
 
                int i, y = 0;
1941
 
                int count;
 
1906
                unsigned int i, y = 0;
 
1907
                unsigned int count;
1942
1908
                struct srvsvc_NetShareCtr2 *ctr2;
1943
1909
 
1944
1910
                SRVSVC_CHECK_ADMIN_ACCESS;
1991
1957
        }
1992
1958
        case 502:
1993
1959
        {
1994
 
                int i, y = 0;
1995
 
                int count;
 
1960
                unsigned int i, y = 0;
 
1961
                unsigned int count;
1996
1962
                struct srvsvc_NetShareCtr502 *ctr502;
1997
1963
 
1998
1964
                SRVSVC_CHECK_ADMIN_ACCESS;
2046
2012
        default:
2047
2013
                return WERR_UNKNOWN_LEVEL;
2048
2014
        }
2049
 
 
2050
 
        return WERR_UNKNOWN_LEVEL;
2051
2015
}
2052
2016
 
2053
2017
 
2287
2251
        NTSTATUS nterr;
2288
2252
        struct share_context *sctx;
2289
2253
                
2290
 
        nterr = share_get_context_by_name(mem_ctx, lp_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
 
2254
        nterr = share_get_context_by_name(mem_ctx, lpcfg_share_backend(dce_call->conn->dce_ctx->lp_ctx), dce_call->event_ctx, dce_call->conn->dce_ctx->lp_ctx, &sctx);
2291
2255
        if (!NT_STATUS_IS_OK(nterr)) {
2292
2256
                return ntstatus_to_werror(nterr);
2293
2257
        }