sysdb_upgrade.c revision 12a000c8c7c07259e438fb1e992134bdd07d9a30
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose Simo Sorce <ssorce@redhat.com>
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose Stephen Gallagher <sgallagh@redhat.com>
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose Copyright (C) 2008-2011 Simo Sorce <ssorce@redhat.com>
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose Copyright (C) 2008-2011 Stephen Gallagher
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose This program is free software; you can redistribute it and/or modify
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose it under the terms of the GNU General Public License as published by
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose the Free Software Foundation; either version 3 of the License, or
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose (at your option) any later version.
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose This program is distributed in the hope that it will be useful,
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose GNU General Public License for more details.
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose You should have received a copy of the GNU General Public License
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zelenystatic errno_t commence_upgrade(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_CRIT_FAILURE, "UPGRADING DB TO VERSION %s\n", new_ver);
5e60c73cb91d1659755fb5ea829837db68d46163Sumit Bosestatic errno_t update_version(struct upgrade_ctx *ctx)
cd5033e86bb4065d75188e2b6ef287a4421344c8Sumit Bose ret = ldb_msg_add_empty(msg, "version", LDB_FLAG_MOD_REPLACE, NULL);
cd5033e86bb4065d75188e2b6ef287a4421344c8Sumit Bose ret = ldb_msg_add_string(msg, "version", ctx->new_version);
d2a8b08561e6700bdd4feb988becae4e8f5368ddJakub Hrozekstatic int finish_upgrade(int ret, struct upgrade_ctx **ctx, const char **ver)
c3243e3212f91b69ef9990e2cb4c9339bf2f7888Jakub Hrozek "Could not cancel transaction! [%s]\n",
c3243e3212f91b69ef9990e2cb4c9339bf2f7888Jakub Hrozek /* Do not overwrite ret here, we want to return
c3243e3212f91b69ef9990e2cb4c9339bf2f7888Jakub Hrozek * the original failure, not the failure of the
c3243e3212f91b69ef9990e2cb4c9339bf2f7888Jakub Hrozek * transaction cancellation.
d2a8b08561e6700bdd4feb988becae4e8f5368ddJakub Hrozek/* serach all groups that have a memberUid attribute.
d2a8b08561e6700bdd4feb988becae4e8f5368ddJakub Hrozek * change it into a member attribute for a user of same domain.
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov * remove the memberUid attribute
d2a8b08561e6700bdd4feb988becae4e8f5368ddJakub Hrozek * add the new member attribute
d2a8b08561e6700bdd4feb988becae4e8f5368ddJakub Hrozek * finally stop indexing memberUid
d2a8b08561e6700bdd4feb988becae4e8f5368ddJakub Hrozek * upgrade version to 0.2
d2a8b08561e6700bdd4feb988becae4e8f5368ddJakub Hrozekint sysdb_upgrade_01(struct ldb_context *ldb, const char **ver)
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose const char *filter = "(&(memberUid=*)(objectclass=group))";
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose const char *mdn;
096a9678919fae460342469989b97fd47d812823Sumit Bose ret = commence_upgrade(tmp_ctx, ldb, SYSDB_VERSION_0_2, &ctx);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov el = ldb_msg_find_element(res->msgs[i], "memberUid");
096a9678919fae460342469989b97fd47d812823Sumit Bose "memberUid is missing from message [%s], skipping\n",
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose /* create modification message */
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = ldb_msg_add_empty(msg, "memberUid", LDB_FLAG_MOD_DELETE, NULL);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = ldb_msg_add_empty(msg, SYSDB_MEMBER, LDB_FLAG_MOD_ADD, NULL);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose /* get domain name component value */
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose val = ldb_dn_get_component_val(res->msgs[i]->dn, 2);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose domain = talloc_strndup(tmp_ctx, (const char *)val->data, val->length);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose mem_dn = ldb_dn_new_fmt(tmp_ctx, ldb, SYSDB_TMPL_USER,
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose mdn = talloc_strdup(msg, ldb_dn_get_linearized(mem_dn));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = ldb_msg_add_string(msg, SYSDB_MEMBER, mdn);
5e60c73cb91d1659755fb5ea829837db68d46163Sumit Bose /* ok now we are ready to modify the entry */
5e60c73cb91d1659755fb5ea829837db68d46163Sumit Bose /* conversion done, update version number */
096a9678919fae460342469989b97fd47d812823Sumit Boseint sysdb_check_upgrade_02(struct sss_domain_info *domains,
096a9678919fae460342469989b97fd47d812823Sumit Bose bool ctx_trans = false;
096a9678919fae460342469989b97fd47d812823Sumit Bose ret = sysdb_ldb_connect(tmp_ctx, ldb_file, &ldb);
096a9678919fae460342469989b97fd47d812823Sumit Bose DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_ldb_connect failed.\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov el = ldb_msg_find_element(res->msgs[0], "version");
c5711b0279ea85d69fe3c77dfb194360c346e1d7Sumit Bose /* all fine, return */
c5711b0279ea85d69fe3c77dfb194360c346e1d7Sumit Bose /* convert database */
c5711b0279ea85d69fe3c77dfb194360c346e1d7Sumit Bose /* need to convert database to split files */
89ddc9ed474e9ac2b1e7bccb0a58610babf26cf8Jakub Hrozek /* not a v2 upgrade, return and let the normal code take over any
c5711b0279ea85d69fe3c77dfb194360c346e1d7Sumit Bose * further upgrade */
c5711b0279ea85d69fe3c77dfb194360c346e1d7Sumit Bose /* == V2->V3 UPGRADE == */
c5711b0279ea85d69fe3c77dfb194360c346e1d7Sumit Bose "UPGRADING DB TO VERSION %s\n", SYSDB_VERSION_0_3);
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek /* ldb uses posix locks,
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek * posix is stupid and kills all locks when you close *any* file
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek * descriptor associated to the same file.
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek * Therefore we must close and reopen the ldb file here */
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek /* == Backup and reopen ldb == */
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek ret = backup_file(ldb_file, SSSDBG_FATAL_FAILURE);
31dd31b00ad759f256282ef0f7054e60672161ceJakub Hrozek /* reopen */
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek ret = sysdb_ldb_connect(tmp_ctx, ldb_file, &ldb);
9b7762729da24a901388ea53da29448f23e0f77bJakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, "sysdb_ldb_connect failed.\n");
bba1a5fd62cffcae076d1351df5a83fbc4a6ec17Simo Sorce /* open a transaction */
31dd31b00ad759f256282ef0f7054e60672161ceJakub Hrozek /* == Upgrade contents == */
bba1a5fd62cffcae076d1351df5a83fbc4a6ec17Simo Sorce /* skip local */
bba1a5fd62cffcae076d1351df5a83fbc4a6ec17Simo Sorce /* create new dom db */
fdda4b659fa3be3027df91a2b053835186ec2c59Sumit Bose /* search all entries for this domain in local,
09d7c105839bfc7447ea0f766413ed86675ca075Sumit Bose * copy them all in the new database,
c5711b0279ea85d69fe3c77dfb194360c346e1d7Sumit Bose * then remove them from local */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* skip pre-created congtainers */
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek /* regenerate the DN against the new ldb as it may have different
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek * casefolding rules (example: name changing from case insensitive
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek * to case sensitive) */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce DEBUG(SSSDBG_FATAL_FAILURE, "WARNING: Could not add entry %s,"
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce " to new ldb file! (%d [%s])\n",
31dd31b00ad759f256282ef0f7054e60672161ceJakub Hrozek "WARNING: Could not remove entry %s,"
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce " from old ldb file! (%d [%s])\n",
bba1a5fd62cffcae076d1351df5a83fbc4a6ec17Simo Sorce /* now remove the basic containers from local */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* these were optional so debug at level 9 in case
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce * of failure just for tracing */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce DEBUG(SSSDBG_TRACE_ALL, "WARNING: Could not remove entry %s,"
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce " from old ldb file! (%d [%s])\n",
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce DEBUG(SSSDBG_TRACE_ALL, "WARNING: Could not remove entry %s,"
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose " from old ldb file! (%d [%s])\n",
bba1a5fd62cffcae076d1351df5a83fbc4a6ec17Simo Sorce DEBUG(SSSDBG_TRACE_ALL, "WARNING: Could not remove entry %s,"
bba1a5fd62cffcae076d1351df5a83fbc4a6ec17Simo Sorce " from old ldb file! (%d [%s])\n",
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek "Failed to commit ldb transaction! (%d)\n", ret);
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* conversion done, upgrade version number */
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose ret = ldb_msg_add_empty(msg, "version", LDB_FLAG_MOD_REPLACE, NULL);
4c20fe34346919cf676c3e1b54b7701069e2aac6Simo Sorce ret = ldb_msg_add_string(msg, "version", SYSDB_VERSION_0_3);
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose "Failed to commit ldb transaction! (%d)\n", ret);
ad9ca94d0c793c2e30e77f4cc385bf10e42e382fJakub Hrozek "Failed to cancel ldb transaction! (%d)\n", ret);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny "Failed to cancel ldb transaction! (%d)\n", ret);
5ea449b18d2597f2581627de80bcaf2bc70b0fd3Simo Sorceint sysdb_upgrade_03(struct sysdb_ctx *sysdb, const char **ver)
4c20fe34346919cf676c3e1b54b7701069e2aac6Simo Sorce ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_4, &ctx);
4c20fe34346919cf676c3e1b54b7701069e2aac6Simo Sorce /* Make this database case-sensitive */
4c20fe34346919cf676c3e1b54b7701069e2aac6Simo Sorce msg->dn = ldb_dn_new(tmp_ctx, sysdb->ldb, "@ATTRIBUTES");
4c20fe34346919cf676c3e1b54b7701069e2aac6Simo Sorce ret = ldb_msg_add_empty(msg, "name", LDB_FLAG_MOD_DELETE, NULL);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov /* conversion done, update version number */
4c20fe34346919cf676c3e1b54b7701069e2aac6Simo Sorceint sysdb_upgrade_04(struct sysdb_ctx *sysdb, const char **ver)
21f19d573047e70ee8ec0119ec00c1ed1af9ec04Simo Sorce ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_5, &ctx);
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose /* Add new index */
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose msg->dn = ldb_dn_new(tmp_ctx, sysdb->ldb, "@INDEXLIST");
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose ret = ldb_msg_add_empty(msg, "@IDXATTR", LDB_FLAG_MOD_ADD, NULL);
ad9ca94d0c793c2e30e77f4cc385bf10e42e382fJakub Hrozek ret = ldb_msg_add_string(msg, "@IDXATTR", "originalDN");
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny /* Rebuild memberuid and memberoif attributes */
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose msg->dn = ldb_dn_new(tmp_ctx, sysdb->ldb, "@MEMBEROF-REBUILD");
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose /* conversion done, update version number */
81165faf5d951aca69f410713730c26ff048ec44Sumit Boseint sysdb_upgrade_05(struct sysdb_ctx *sysdb, const char **ver)
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_6, &ctx);
ad9ca94d0c793c2e30e77f4cc385bf10e42e382fJakub Hrozek /* Add new indexes */
ad9ca94d0c793c2e30e77f4cc385bf10e42e382fJakub Hrozek msg->dn = ldb_dn_new(tmp_ctx, sysdb->ldb, "@INDEXLIST");
ad9ca94d0c793c2e30e77f4cc385bf10e42e382fJakub Hrozek /* Add Index for dataExpireTimestamp */
ad9ca94d0c793c2e30e77f4cc385bf10e42e382fJakub Hrozek ret = ldb_msg_add_empty(msg, "@IDXATTR", LDB_FLAG_MOD_ADD, NULL);
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose ret = ldb_msg_add_string(msg, "@IDXATTR", "dataExpireTimestamp");
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose /* Add index to speed up ONELEVEL searches */
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose ret = ldb_msg_add_empty(msg, "@IDXONE", LDB_FLAG_MOD_ADD, NULL);
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose /* conversion done, update version number */
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Boseint sysdb_upgrade_06(struct sysdb_ctx *sysdb, const char **ver)
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_7, &ctx);
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose /* Add new indexes */
a50b229c8ea1e22c9efa677760b94d8c48c3ec89Sumit Bose msg->dn = ldb_dn_new(tmp_ctx, sysdb->ldb, "@ATTRIBUTES");
a50b229c8ea1e22c9efa677760b94d8c48c3ec89Sumit Bose /* Case insensitive search for originalDN */
a50b229c8ea1e22c9efa677760b94d8c48c3ec89Sumit Bose ret = ldb_msg_add_empty(msg, SYSDB_ORIG_DN, LDB_FLAG_MOD_ADD, NULL);
44329653f423c632b027065a9c0ea0bf4199396aSumit Bose ret = ldb_msg_add_string(msg, SYSDB_ORIG_DN, "CASE_INSENSITIVE");
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose /* conversion done, update version number */
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Boseint sysdb_upgrade_07(struct sysdb_ctx *sysdb, const char **ver)
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_8, &ctx);
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose /* Add new indexes */
cd5033e86bb4065d75188e2b6ef287a4421344c8Sumit Bose msg->dn = ldb_dn_new(tmp_ctx, sysdb->ldb, "@INDEXLIST");
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose /* Add Index for nameAlias */
cd5033e86bb4065d75188e2b6ef287a4421344c8Sumit Bose ret = ldb_msg_add_empty(msg, "@IDXATTR", LDB_FLAG_MOD_ADD, NULL);
2bf1cbffaac3b4bc0bd736493c985ca865092805Sumit Bose ret = ldb_msg_add_string(msg, "@IDXATTR", "nameAlias");
2bf1cbffaac3b4bc0bd736493c985ca865092805Sumit Bose /* conversion done, update version number */
2bf1cbffaac3b4bc0bd736493c985ca865092805Sumit Boseint sysdb_upgrade_08(struct sysdb_ctx *sysdb, const char **ver)
cd5033e86bb4065d75188e2b6ef287a4421344c8Sumit Bose ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_9, &ctx);
cd5033e86bb4065d75188e2b6ef287a4421344c8Sumit Bose /* Add new indexes */
cd5033e86bb4065d75188e2b6ef287a4421344c8Sumit Bose msg->dn = ldb_dn_new(tmp_ctx, sysdb->ldb, "@INDEXLIST");
2bf1cbffaac3b4bc0bd736493c985ca865092805Sumit Bose /* Add Index for servicePort and serviceProtocol */
cd5033e86bb4065d75188e2b6ef287a4421344c8Sumit Bose ret = ldb_msg_add_empty(msg, "@IDXATTR", LDB_FLAG_MOD_ADD, NULL);
cd5033e86bb4065d75188e2b6ef287a4421344c8Sumit Bose ret = ldb_msg_add_string(msg, "@IDXATTR", "servicePort");
2bf1cbffaac3b4bc0bd736493c985ca865092805Sumit Bose ret = ldb_msg_add_string(msg, "@IDXATTR", "serviceProtocol");
2bf1cbffaac3b4bc0bd736493c985ca865092805Sumit Bose /* conversion done, update version number */
2bf1cbffaac3b4bc0bd736493c985ca865092805Sumit Boseint sysdb_upgrade_09(struct sysdb_ctx *sysdb, const char **ver)
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_10, &ctx);
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose /* Add new indexes */
21f19d573047e70ee8ec0119ec00c1ed1af9ec04Simo Sorce msg->dn = ldb_dn_new(tmp_ctx, sysdb->ldb, "@INDEXLIST");
ccc2af010bbbe6d8a7496fb717216135bc4c1993Simo Sorce /* Add Index for servicePort and serviceProtocol */
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose ret = ldb_msg_add_empty(msg, "@IDXATTR", LDB_FLAG_MOD_ADD, NULL);
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose ret = ldb_msg_add_string(msg, "@IDXATTR", "sudoUser");
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose /* conversion done, update version number */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorceint sysdb_upgrade_10(struct sysdb_ctx *sysdb, struct sss_domain_info *domain,
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce const char **ver)
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce const char *filter = "(&(objectClass=user)(!(uidNumber=*))(memberOf=*))";
b17b51c2779906bf3a5e4aecbb9ef8bfbfc2ebabJakub Hrozek const char *attrs[] = { "name", "memberof", NULL };
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_11, &ctx);
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose ret = ldb_search(sysdb->ldb, tmp_ctx, &res, basedn, LDB_SCOPE_SUBTREE,
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose memberof_el = ldb_msg_find_element(user, "memberof");
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose name = ldb_msg_find_attr_as_string(user, "name", NULL);
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose DEBUG(SSSDBG_TRACE_LIBS, "User [%s] is a member of %d groups\n",
08ab0d4ede41a1749e0bc26f78a37a4d10c20db8Sumit Bose msg->dn = ldb_dn_from_ldb_val(tmp_ctx, sysdb->ldb, &memberof_el->values[j]);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_MINOR_FAILURE, "DN validation failed during "
20ccfd63a17dc15dd24e6543424d86913d511c4bSumit Bose "upgrade: [%s]\n",
ad9ca94d0c793c2e30e77f4cc385bf10e42e382fJakub Hrozek ret = ldb_msg_add_empty(msg, "ghost", LDB_FLAG_MOD_ADD, NULL);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_TRACE_FUNC, "Adding ghost [%s] to entry [%s]\n",
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sss_ldb_modify_permissive(sysdb->ldb, msg);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose /* If we failed adding the ghost user(s) because the values already
21f19d573047e70ee8ec0119ec00c1ed1af9ec04Simo Sorce * exist, they were probably propagated from a parent that was
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose * upgraded before us. Mark the group as expired so that it is
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose * refreshed on next request.
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose msg->dn = ldb_dn_from_ldb_val(tmp_ctx, sysdb->ldb, &memberof_el->values[j]);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = ldb_msg_add_string(msg, SYSDB_CACHE_EXPIRE, "1");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov ret = sss_ldb_modify_permissive(sysdb->ldb, msg);
5a5f1e1053415efaa99bb4d5bc7ce7ac0a95b757Jakub Hrozek DEBUG(SSSDBG_TRACE_FUNC, "Removing fake user [%s]\n",
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny /* conversion done, update version number */
cd5033e86bb4065d75188e2b6ef287a4421344c8Sumit Boseint sysdb_upgrade_11(struct sysdb_ctx *sysdb, struct sss_domain_info *domain,
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny const char **ver)
f99534c058e9367d2610de89b1af4dcc1ec63035Sumit Bose const char *key;
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny const char *value;
3912262270a6449ebe1d3e92c27c217b4044f894Simo Sorce ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_12, &ctx);
3912262270a6449ebe1d3e92c27c217b4044f894Simo Sorce basedn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, SYSDB_TMPL_CUSTOM_SUBTREE,
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek ret = ldb_search(sysdb->ldb, tmp_ctx, &res, basedn, LDB_SCOPE_SUBTREE,
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek attrs, "(objectClass=%s)", SYSDB_AUTOFS_ENTRY_OC);
9af86b9c936d07cff9d0c2054acde908749ea522Jakub Hrozek DEBUG(SSSDBG_TRACE_LIBS, "Found %d autofs entries\n", res->count);
5a5f1e1053415efaa99bb4d5bc7ce7ac0a95b757Jakub Hrozek memberof_el = ldb_msg_find_element(entry, SYSDB_MEMBEROF);
5a5f1e1053415efaa99bb4d5bc7ce7ac0a95b757Jakub Hrozek for (j = 0; j < memberof_el->num_values; j++) {
5a5f1e1053415efaa99bb4d5bc7ce7ac0a95b757Jakub Hrozek memberof_dn = ldb_dn_from_ldb_val(tmp_ctx, sysdb->ldb,
5a5f1e1053415efaa99bb4d5bc7ce7ac0a95b757Jakub Hrozek DEBUG(SSSDBG_OP_FAILURE, "Cannot convert memberof into DN, skipping\n");
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny DEBUG(SSSDBG_OP_FAILURE, "Cannot get map name from map DN\n");
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose "Cannot save autofs entry [%s]-[%s] into map %s\n",
21f19d573047e70ee8ec0119ec00c1ed1af9ec04Simo Sorce /* Delete the old entry if it was either processed or incomplete */
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorce DEBUG(SSSDBG_OP_FAILURE, "Cannot delete old autofs entry %s\n",
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorce /* conversion done, update version number */
d6d8287a9b8a240e068a26769dc6ce4582604850Simo Sorceint sysdb_upgrade_12(struct sysdb_ctx *sysdb, const char **ver)
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_13, &ctx);
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce /* add new indexes */
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce msg->dn = ldb_dn_new(tmp_ctx, sysdb->ldb, "@INDEXLIST");
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce /* add index for sshKnownHostsExpire */
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose ret = ldb_msg_add_empty(msg, "@IDXATTR", LDB_FLAG_MOD_ADD, NULL);
44af0057c1fd52f6252f82ca73a06acfcac6c5e3Michal Zidek ret = ldb_msg_add_string(msg, "@IDXATTR", "sshKnownHostsExpire");
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorce /* conversion done, update version number */
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorceint sysdb_upgrade_13(struct sysdb_ctx *sysdb, const char **ver)
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose int i, j, l, n;
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_14, &ctx);
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose basedn = ldb_dn_new(ctx, sysdb->ldb, SYSDB_BASE);
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose DEBUG(SSSDBG_OP_FAILURE, "Failed to build base dn\n");
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose DEBUG(SSSDBG_OP_FAILURE, "Failed to search subdomains\n");
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose tmp_str = ldb_msg_find_attr_as_string(dom_res->msgs[i], "cn", NULL);
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose "The object [%s] doesn't have a name\n",
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose basedn = ldb_dn_new_fmt(ctx, sysdb->ldb, SYSDB_DOM_BASE, tmp_str);
03abdaa21ecf562b714f204ca42379ff08626f75Simo Sorce "Failed to build base dn for subdomain %s\n", tmp_str);
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose if (n <= l + 1) {
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose /* Do not remove subdomain containers, only their contents */
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce "Failed to delete %s\n",
87ed72b47859e673b636c85f35b85f1546c7ed3dSimo Sorce /* conversion done, update version number */
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashovint sysdb_upgrade_14(struct sysdb_ctx *sysdb, const char **ver)
87ed72b47859e673b636c85f35b85f1546c7ed3dSimo Sorce ret = commence_upgrade(sysdb, sysdb->ldb, SYSDB_VERSION_0_15, &ctx);
5063dcc5ab685dce325b13b9c1e93cee2a673e60Sumit Bose basedn = ldb_dn_new(ctx, sysdb->ldb, SYSDB_BASE);
87ed72b47859e673b636c85f35b85f1546c7ed3dSimo Sorce DEBUG(SSSDBG_OP_FAILURE, "Failed to build base dn\n");
fab48878db202d620f43c9da23e375866d1db2c6Sumit Bose /* create base ranges container */
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce msg->dn = ldb_dn_new(msg, sysdb->ldb, SYSDB_TMPL_RANGE_BASE);
d2a8b08561e6700bdd4feb988becae4e8f5368ddJakub Hrozek /* do a synchronous add */
2b4b6b829f197493b4901bec96fefaadbc7a2464Jakub Hrozek "Failed to upgrade DB (%d, [%s])!\n",
goto done;
if (ret) {
goto done;
if (!newdn) {
goto done;
if (ret) {
goto done;
done:
return ret;
int ret;
if (!tmp_ctx) {
return ENOMEM;
if (ret) {
return ret;
if (!msg) {
goto done;
goto done;
goto done;
goto done;
goto done;
done:
return ret;
if (ret) {
return ret;
done:
return ret;