summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2013-12-01 02:45:02 +0100
committerAllan McRae <allan@archlinux.org>2013-12-15 11:09:37 +0100
commit841c60f2b396c3b59c7d673dc39dacc3ccbf5658 (patch)
tree77bbf8b0903be74995146533a2d6e0a288c6cc6d /lib/libalpm
parent76a05e94c19922ee27a9c3b751ec3836c13a1bab (diff)
downloadpacman-841c60f2b396c3b59c7d673dc39dacc3ccbf5658.tar.gz
pacman-841c60f2b396c3b59c7d673dc39dacc3ccbf5658.tar.xz
db.c: require unique database names
Allowing multiple databases with the same name causes conflicts as they both point to the same database file but may use different servers, usages, or siglevels. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/db.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index 528b04bb..2069a7b5 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -46,6 +46,8 @@
alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle,
const char *treename, alpm_siglevel_t level)
{
+ alpm_list_t *i;
+
/* Sanity checks */
CHECK_HANDLE(handle, return NULL);
ASSERT(treename != NULL && strlen(treename) != 0,
@@ -53,6 +55,17 @@ alpm_db_t SYMEXPORT *alpm_register_syncdb(alpm_handle_t *handle,
/* Do not register a database if a transaction is on-going */
ASSERT(handle->trans == NULL, RET_ERR(handle, ALPM_ERR_TRANS_NOT_NULL, NULL));
+ /* ensure database name is unique */
+ if(strcmp(treename, "local") == 0) {
+ RET_ERR(handle, ALPM_ERR_DB_NOT_NULL, NULL);
+ }
+ for(i = handle->dbs_sync; i; i = i->next) {
+ alpm_db_t *d = i->data;
+ if(strcmp(treename, d->treename) == 0) {
+ RET_ERR(handle, ALPM_ERR_DB_NOT_NULL, NULL);
+ }
+ }
+
return _alpm_db_register_sync(handle, treename, level);
}