~ubuntu-branches/ubuntu/maverick/samba/maverick-security

« back to all changes in this revision

Viewing changes to source/pidl/tests/util.pl

  • Committer: Bazaar Package Importer
  • Author(s): Steve Langasek
  • Date: 2009-03-03 22:02:23 UTC
  • mfrom: (0.28.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090303220223-3bdlm2d9fwx1p1ye
Tags: 2:3.3.1-1ubuntu1
* Merge from Debian unstable (LP: #337094), remaining changes:
  + debian/patches/VERSION.patch:
    - setup SAMBA_VERSION_SUFFIX to Ubuntu.
  + 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/mksambapasswd.awk:
    - Do not add user with UID less than 1000 to smbpasswd.
  + debian/control:
    - Make libwbclient0 replace/conflict with hardy's likewise-open.
    - Don't build against ctdb.
  + debian/rules:
    - enable "native" PIE hardening.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
* Dropped changes, merged in Debian:
  + debian/libpam-smbpass.pam-config, debian/libpam-smbpass.postinst,
    debian/libpam-smbpass.prerm, debian/libpam-smbpass.files,
    debian/rules:
    - Make libpam-smbpasswd depend on libpam-runtime to allow 
      libpam-smbpasswd for auto-configuration.
  + debian/control:
    - Provide a config block for the new PAM framework to auto-configure
      itself
  + debian/samba.postinst:
    - When populating the new sambashare group, it is not an error
      if the user simply does not exist; test for this case and let
      the install continue instead of aborting.
  + debian/winbind.files:
    - include additional files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
# (C) 2007 Jelmer Vernooij <jelmer@samba.org>
 
3
# Published under the GNU General Public License
 
4
use strict;
 
5
use warnings;
 
6
 
 
7
use Test::More tests => 72;
 
8
use FindBin qw($RealBin);
 
9
use lib "$RealBin";
 
10
use Util;
 
11
use Parse::Pidl qw(error);
 
12
use Parse::Pidl::Util;
 
13
 
 
14
# has_property()
 
15
is(undef, has_property({}, "foo"));
 
16
is(undef, has_property({PROPERTIES => {}}, "foo"));
 
17
is("data", has_property({PROPERTIES => {foo => "data"}}, "foo"));
 
18
is(undef, has_property({PROPERTIES => {foo => undef}}, "foo"));
 
19
 
 
20
# is_constant()
 
21
ok(is_constant("2"));
 
22
ok(is_constant("256"));
 
23
ok(is_constant("0x400"));
 
24
ok(is_constant("0x4BC"));
 
25
ok(not is_constant("0x4BGC"));
 
26
ok(not is_constant("str"));
 
27
ok(not is_constant("2 * expr"));
 
28
 
 
29
# make_str()
 
30
is("\"bla\"", make_str("bla"));
 
31
is("\"bla\"", make_str("\"bla\""));
 
32
is("\"\"bla\"\"", make_str("\"\"bla\"\""));
 
33
is("\"bla\"\"", make_str("bla\""));
 
34
is("\"foo\"bar\"", make_str("foo\"bar"));
 
35
 
 
36
is("bla", unmake_str("\"bla\""));
 
37
is("\"bla\"", unmake_str("\"\"bla\"\""));
 
38
 
 
39
# print_uuid()
 
40
is(undef, print_uuid("invalid"));
 
41
is("{0x12345778,0x1234,0xabcd,{0xef,0x00},{0x01,0x23,0x45,0x67,0x89,0xac}}",
 
42
   print_uuid("12345778-1234-abcd-ef00-0123456789ac"));
 
43
is("{0x12345778,0x1234,0xabcd,{0xef,0x00},{0x01,0x23,0x45,0x67,0x89,0xac}}",
 
44
   print_uuid("\"12345778-1234-abcd-ef00-0123456789ac\""));
 
45
 
 
46
# property_matches()
 
47
# missing property
 
48
ok(not property_matches({PROPERTIES => {}}, "x", "data"));
 
49
# data not matching
 
50
ok(not property_matches({PROPERTIES => {x => "bar"}}, "x", "data"));
 
51
# data matching exactly
 
52
ok(property_matches({PROPERTIES => {x => "data"}}, "x", "data"));
 
53
# regex matching
 
54
ok(property_matches({PROPERTIES => {x => "data"}}, "x", "^([dat]+)\$"));
 
55
 
 
56
# ParseExpr()
 
57
is(undef, ParseExpr("", {}, undef));
 
58
is("a", ParseExpr("a", {"b" => "2"}, undef));
 
59
is("2", ParseExpr("a", {"a" => "2"}, undef));
 
60
is("2 * 2", ParseExpr("a*a", {"a" => "2"}, undef));
 
61
is("r->length + r->length",
 
62
   ParseExpr("length+length", {"length" => "r->length"}, undef));
 
63
is("2 / 2 * (r->length)",
 
64
        ParseExpr("constant/constant*(len)", {"constant" => "2",
 
65
                                                      "len" => "r->length"}, undef));
 
66
is("2 + 2 - r->length",
 
67
        ParseExpr("constant+constant-len", {"constant" => "2",
 
68
                                                      "len" => "r->length"}, undef));
 
69
is("*r->length", ParseExpr("*len", { "len" => "r->length"}, undef));
 
70
is("**r->length", ParseExpr("**len", { "len" => "r->length"}, undef));
 
71
is("r->length & 2", ParseExpr("len&2", { "len" => "r->length"}, undef));
 
72
is("&r->length", ParseExpr("&len", { "len" => "r->length"}, undef));
 
73
is("calc()", ParseExpr("calc()", { "foo" => "2"}, undef));
 
74
is("calc(2 * 2)", ParseExpr("calc(foo * 2)", { "foo" => "2"}, undef));
 
75
is("strlen(\"data\")", ParseExpr("strlen(foo)", { "foo" => "\"data\""}, undef));
 
76
is("strlen(\"data\", 4)", ParseExpr("strlen(foo, 4)", { "foo" => "\"data\""}, undef));
 
77
is("foo / bar", ParseExpr("foo / bar", { "bla" => "\"data\""}, undef));
 
78
is("r->length % 2", ParseExpr("len%2", { "len" => "r->length"}, undef));
 
79
is("r->length == 2", ParseExpr("len==2", { "len" => "r->length"}, undef));
 
80
is("r->length != 2", ParseExpr("len!=2", { "len" => "r->length"}, undef));
 
81
is("pr->length", ParseExpr("pr->length", { "p" => "r"}, undef));
 
82
is("r->length", ParseExpr("p->length", { "p" => "r"}, undef));
 
83
is("_foo / bla32", ParseExpr("_foo / bla32", { "bla" => "\"data\""}, undef));
 
84
is("foo.bar.blah", ParseExpr("foo.blah", { "foo" => "foo.bar"}, undef));
 
85
is("\"bla\"", ParseExpr("\"bla\"", {}, undef));
 
86
is("1 << 2", ParseExpr("1 << 2", {}, undef));
 
87
is("1 >> 2", ParseExpr("1 >> 2", {}, undef));
 
88
is("0x200", ParseExpr("0x200", {}, undef));
 
89
is("2?3:0", ParseExpr("2?3:0", {}, undef));
 
90
is("~0", ParseExpr("~0", {}, undef));
 
91
is("b->a->a", ParseExpr("a->a->a", {"a" => "b"}, undef));
 
92
is("b.a.a", ParseExpr("a.a.a", {"a" => "b"}, undef));
 
93
 
 
94
test_errors("nofile:0: Parse error in `~' near `~'\n", sub {
 
95
        is(undef, ParseExpr("~", {}, {FILE => "nofile", LINE => 0})); });
 
96
 
 
97
test_errors("nofile:0: Got pointer, expected integer\n", sub {
 
98
                is(undef, ParseExprExt("foo", {}, {FILE => "nofile", LINE => 0},
 
99
                                         undef, sub { my $x = shift;
 
100
                                                         error({FILE => "nofile", LINE => 0},
 
101
                                                                         "Got pointer, expected integer");
 
102
                                                         return undef; }))});
 
103
 
 
104
is("b.a.a", ParseExpr("b.a.a", {"a" => "b"}, undef));
 
105
is("((rr_type) == NBT_QTYPE_NETBIOS)", ParseExpr("((rr_type)==NBT_QTYPE_NETBIOS)", {}, undef));
 
106
is("talloc_check_name", ParseExpr("talloc_check_name", {}, undef));
 
107
is("talloc_check_name()", ParseExpr("talloc_check_name()", {}, undef));
 
108
is("talloc_check_name(ndr)", ParseExpr("talloc_check_name(ndr)", {}, undef));
 
109
is("talloc_check_name(ndr, 1)", ParseExpr("talloc_check_name(ndr,1)", {}, undef));
 
110
is("talloc_check_name(ndr, \"struct ndr_push\")", ParseExpr("talloc_check_name(ndr,\"struct ndr_push\")", {}, undef));
 
111
is("((rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, \"struct ndr_push\")", ParseExpr("((rr_type)==NBT_QTYPE_NETBIOS)&&talloc_check_name(ndr,\"struct ndr_push\")", {}, undef));
 
112
is("(rdata).data.length", ParseExpr("(rdata).data.length", {}, undef));
 
113
is("((rdata).data.length == 2)", ParseExpr("((rdata).data.length==2)", {}, undef));
 
114
is("((rdata).data.length == 2)?0:rr_type", ParseExpr("((rdata).data.length==2)?0:rr_type", {}, undef));
 
115
is("((((rr_type) == NBT_QTYPE_NETBIOS) && talloc_check_name(ndr, \"struct ndr_push\") && ((rdata).data.length == 2))?0:rr_type)", ParseExpr("((((rr_type)==NBT_QTYPE_NETBIOS)&&talloc_check_name(ndr,\"struct ndr_push\")&&((rdata).data.length==2))?0:rr_type)", {}, undef));