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

« back to all changes in this revision

Viewing changes to source4/lib/ldb/ldb_sqlite3/ldb_sqlite3.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:
255
255
        char *child, *tmp;
256
256
        char *ret = NULL;
257
257
        char *attr;
258
 
        int i;
 
258
        unsigned int i;
259
259
 
260
260
        ldb = ldb_module_get_ctx(module);
261
261
 
557
557
}
558
558
 
559
559
/*
560
 
 * This is a bad hack to support ldap style comparisons whithin sqlite.
 
560
 * This is a bad hack to support ldap style comparisons within sqlite.
561
561
 * val is the attribute in the row currently under test
562
562
 * func is the desired test "<=" ">=" "~" ":"
563
563
 * cmp is the value to compare against (eg: "test")
667
667
        struct lsql_context *ac;
668
668
        struct ldb_message *msg;
669
669
        long long eid;
670
 
        int i, ret;
 
670
        unsigned int i;
 
671
        int ret;
671
672
 
672
673
        ac = talloc_get_type(result, struct lsql_context);
673
674
        ldb = ldb_module_get_ctx(ac->module);
686
687
                /* call the async callback for the last entry
687
688
                 * except the first time */
688
689
                if (ac->current_eid != 0) {
689
 
                        msg = ldb_msg_canonicalize(ldb, msg);
690
 
                        if (!msg) return SQLITE_ABORT;
 
690
                        ret = ldb_msg_normalize(ldb, ac->req, msg, &msg);
 
691
                        if (ret != LDB_SUCCESS) {
 
692
                                return SQLITE_ABORT;
 
693
                        }
691
694
 
692
695
                        ret = ldb_module_send_entry(ac->req, msg, NULL);
693
696
                        if (ret != LDB_SUCCESS) {
694
697
                                ac->callback_failed = true;
 
698
                                /* free msg object */
 
699
                                TALLOC_FREE(msg);
695
700
                                return SQLITE_ABORT;
696
701
                        }
 
702
 
 
703
                        /* free msg object */
 
704
                        TALLOC_FREE(msg);
697
705
                }
698
706
 
699
707
                /* start over */
959
967
 
960
968
        /* complete the last message if any */
961
969
        if (ctx->ares) {
962
 
                ctx->ares->message = ldb_msg_canonicalize(ldb, ctx->ares->message);
963
 
                if (ctx->ares->message == NULL) {
 
970
                ret = ldb_msg_normalize(ldb, ctx->ares,
 
971
                                        ctx->ares->message,
 
972
                                        &ctx->ares->message);
 
973
                if (ret != LDB_SUCCESS) {
964
974
                        return LDB_ERR_OPERATIONS_ERROR;
965
975
                }
966
976
 
986
996
        char *dn, *ndn;
987
997
        char *errmsg;
988
998
        char *query;
989
 
        int i;
 
999
        unsigned int i;
990
1000
        int ret;
991
1001
 
992
1002
        ldb = ldb_module_get_ctx(module);
1043
1053
                const struct ldb_message_element *el = &msg->elements[i];
1044
1054
                const struct ldb_schema_attribute *a;
1045
1055
                char *attr;
1046
 
                int j;
 
1056
                unsigned int j;
1047
1057
 
1048
1058
                /* Get a case-folded copy of the attribute name */
1049
1059
                attr = ldb_attr_casefold(ctx, el->name);
1053
1063
 
1054
1064
                a = ldb_schema_attribute_by_name(ldb, el->name);
1055
1065
 
 
1066
                if (el->num_value == 0) {
 
1067
                        ldb_asprintf_errstring(ldb, "attribute %s on %s specified, but with 0 values (illegal)",
 
1068
                                               el->name, ldb_dn_get_linearized(msg->dn));
 
1069
                        return LDB_ERR_CONSTRAINT_VIOLATION;
 
1070
                }
 
1071
 
1056
1072
                /* For each value of the specified attribute name... */
1057
1073
                for (j = 0; j < el->num_values; j++) {
1058
1074
                        struct ldb_val value;
1097
1113
        struct lsqlite3_private *lsqlite3;
1098
1114
        struct ldb_context *ldb;
1099
1115
        struct ldb_message *msg = req->op.mod.message;
1100
 
        long long eid;
 
1116
        long long eid;
1101
1117
        char *errmsg;
1102
 
        int i;
 
1118
        unsigned int i;
1103
1119
        int ret;
1104
1120
 
1105
1121
        ldb = ldb_module_get_ctx(module);
1123
1139
                int flags = el->flags & LDB_FLAG_MOD_MASK;
1124
1140
                char *attr;
1125
1141
                char *mod;
1126
 
                int j;
 
1142
                unsigned int j;
1127
1143
 
1128
1144
                /* Get a case-folded copy of the attribute name */
1129
1145
                attr = ldb_attr_casefold(ctx, el->name);
1137
1153
 
1138
1154
                case LDB_FLAG_MOD_REPLACE:
1139
1155
 
 
1156
                        for (j=0; j<el->num_values; j++) {
 
1157
                                if (ldb_msg_find_val(el, &el->values[j]) != &el->values[j]) {
 
1158
                                        ldb_asprintf_errstring(ldb, "%s: value #%d provided more than once", el->name, j);
 
1159
                                        return LDB_ERR_ATTRIBUTE_OR_VALUE_EXISTS;
 
1160
                                }
 
1161
                        }
 
1162
 
1140
1163
                        /* remove all attributes before adding the replacements */
1141
1164
                        mod = lsqlite3_tprintf(ctx,
1142
1165
                                                "DELETE FROM ldb_attribute_values "
1159
1182
                        /* MISSING break is INTENTIONAL */
1160
1183
 
1161
1184
                case LDB_FLAG_MOD_ADD:
1162
 
#warning "We should throw an error if no value is provided!"
 
1185
 
 
1186
                        if (el->num_values == 0) {
 
1187
                                ldb_asprintf_errstring(ldb, "attribute %s on %s specified, but with 0 values (illigal)",
 
1188
                                                       el->name, ldb_dn_get_linearized(msg->dn));
 
1189
                                return LDB_ERR_CONSTRAINT_VIOLATION;
 
1190
                        }
 
1191
 
1163
1192
                        /* For each value of the specified attribute name... */
1164
1193
                        for (j = 0; j < el->num_values; j++) {
1165
1194
                                struct ldb_val value;
1491
1520
 */
1492
1521
        default:
1493
1522
                /* no other op supported */
1494
 
                ret = LDB_ERR_UNWILLING_TO_PERFORM;
 
1523
                ret = LDB_ERR_PROTOCOL_ERROR;
1495
1524
        }
1496
1525
 
1497
1526
        if (!ctx->callback_failed) {
1509
1538
        struct tevent_timer *te;
1510
1539
        struct timeval tv;
1511
1540
 
1512
 
        if (check_critical_controls(req->controls)) {
 
1541
        if (ldb_check_critical_controls(req->controls)) {
1513
1542
                return LDB_ERR_UNSUPPORTED_CRITICAL_EXTENSION;
1514
1543
        }
1515
1544
 
1845
1874
{
1846
1875
        struct ldb_module *module;
1847
1876
        struct lsqlite3_private *lsqlite3;
1848
 
        int i, ret;
 
1877
        unsigned int i;
 
1878
        int ret;
1849
1879
 
1850
1880
        module = ldb_module_new(ldb, ldb, "ldb_sqlite3 backend", &lsqlite3_ops);
1851
 
        if (!module) return -1;
 
1881
        if (!module) return LDB_ERR_OPERATIONS_ERROR;
1852
1882
 
1853
1883
        lsqlite3 = talloc(module, struct lsqlite3_private);
1854
1884
        if (!lsqlite3) {
1892
1922
        }
1893
1923
 
1894
1924
        *_module = module;
1895
 
        return 0;
 
1925
        return LDB_SUCCESS;
1896
1926
 
1897
1927
failed:
1898
1928
        if (lsqlite3 && lsqlite3->sqlite != NULL) {
1899
1929
                (void) sqlite3_close(lsqlite3->sqlite);
1900
1930
        }
1901
1931
        talloc_free(lsqlite3);
1902
 
        return -1;
 
1932
        return LDB_ERR_OPERATIONS_ERROR;
1903
1933
}
1904
1934
 
1905
 
const struct ldb_backend_ops ldb_sqlite3_backend_ops = {
1906
 
        .name = "sqlite3",
1907
 
        .connect_fn = lsqlite3_connect
1908
 
};
 
1935
int ldb_sqlite3_init(const char *version)
 
1936
{
 
1937
        LDB_MODULE_CHECK_VERSION(version);
 
1938
        return ldb_register_backend("sqlite3", lsqlite3_connect, false);
 
1939
}