prefix all struct HDB elements with hdb_
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@12880 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
100
lib/hdb/ndbm.c
100
lib/hdb/ndbm.c
@@ -56,7 +56,7 @@ NDBM_destroy(krb5_context context, HDB *db)
|
||||
krb5_error_code ret;
|
||||
|
||||
ret = hdb_clear_master_key (context, db);
|
||||
free(db->name);
|
||||
free(db->hdb_name);
|
||||
free(db);
|
||||
return 0;
|
||||
}
|
||||
@@ -64,14 +64,14 @@ NDBM_destroy(krb5_context context, HDB *db)
|
||||
static krb5_error_code
|
||||
NDBM_lock(krb5_context context, HDB *db, int operation)
|
||||
{
|
||||
struct ndbm_db *d = db->db;
|
||||
struct ndbm_db *d = db->hdb_db;
|
||||
return hdb_lock(d->lock_fd, operation);
|
||||
}
|
||||
|
||||
static krb5_error_code
|
||||
NDBM_unlock(krb5_context context, HDB *db)
|
||||
{
|
||||
struct ndbm_db *d = db->db;
|
||||
struct ndbm_db *d = db->hdb_db;
|
||||
return hdb_unlock(d->lock_fd);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ NDBM_seq(krb5_context context, HDB *db,
|
||||
unsigned flags, hdb_entry *entry, int first)
|
||||
|
||||
{
|
||||
struct ndbm_db *d = (struct ndbm_db *)db->db;
|
||||
struct ndbm_db *d = (struct ndbm_db *)db->hdb_db;
|
||||
datum key, value;
|
||||
krb5_data key_data, data;
|
||||
krb5_error_code ret = 0;
|
||||
@@ -93,15 +93,15 @@ NDBM_seq(krb5_context context, HDB *db,
|
||||
return HDB_ERR_NOENTRY;
|
||||
key_data.data = key.dptr;
|
||||
key_data.length = key.dsize;
|
||||
ret = db->lock(context, db, HDB_RLOCK);
|
||||
ret = db->hdb_lock(context, db, HDB_RLOCK);
|
||||
if(ret) return ret;
|
||||
value = dbm_fetch(d->db, key);
|
||||
db->unlock(context, db);
|
||||
db->hdb_unlock(context, db);
|
||||
data.data = value.dptr;
|
||||
data.length = value.dsize;
|
||||
if(hdb_value2entry(context, &data, entry))
|
||||
return NDBM_seq(context, db, flags, entry, 0);
|
||||
if (db->master_key_set && (flags & HDB_F_DECRYPT)) {
|
||||
if (db->hdb_master_key_set && (flags & HDB_F_DECRYPT)) {
|
||||
ret = hdb_unseal_keys (context, db, entry);
|
||||
if (ret)
|
||||
hdb_free_entry (context, entry);
|
||||
@@ -137,7 +137,7 @@ static krb5_error_code
|
||||
NDBM_rename(krb5_context context, HDB *db, const char *new_name)
|
||||
{
|
||||
/* XXX this function will break */
|
||||
struct ndbm_db *d = db->db;
|
||||
struct ndbm_db *d = db->hdb_db;
|
||||
|
||||
int ret;
|
||||
char *old_dir, *old_pag, *new_dir, *new_pag;
|
||||
@@ -145,19 +145,19 @@ NDBM_rename(krb5_context context, HDB *db, const char *new_name)
|
||||
int lock_fd;
|
||||
|
||||
/* lock old and new databases */
|
||||
ret = db->lock(context, db, HDB_WLOCK);
|
||||
ret = db->hdb_lock(context, db, HDB_WLOCK);
|
||||
if(ret)
|
||||
return ret;
|
||||
asprintf(&new_lock, "%s.lock", new_name);
|
||||
if(new_lock == NULL) {
|
||||
db->unlock(context, db);
|
||||
db->hdb_unlock(context, db);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
lock_fd = open(new_lock, O_RDWR | O_CREAT, 0600);
|
||||
if(lock_fd < 0) {
|
||||
ret = errno;
|
||||
db->unlock(context, db);
|
||||
db->hdb_unlock(context, db);
|
||||
krb5_set_error_string(context, "open(%s): %s", new_lock,
|
||||
strerror(ret));
|
||||
free(new_lock);
|
||||
@@ -166,13 +166,13 @@ NDBM_rename(krb5_context context, HDB *db, const char *new_name)
|
||||
free(new_lock);
|
||||
ret = hdb_lock(lock_fd, HDB_WLOCK);
|
||||
if(ret) {
|
||||
db->unlock(context, db);
|
||||
db->hdb_unlock(context, db);
|
||||
close(lock_fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
asprintf(&old_dir, "%s.dir", db->name);
|
||||
asprintf(&old_pag, "%s.pag", db->name);
|
||||
asprintf(&old_dir, "%s.dir", db->hdb_name);
|
||||
asprintf(&old_pag, "%s.pag", db->hdb_name);
|
||||
asprintf(&new_dir, "%s.dir", new_name);
|
||||
asprintf(&new_pag, "%s.pag", new_name);
|
||||
|
||||
@@ -182,7 +182,7 @@ NDBM_rename(krb5_context context, HDB *db, const char *new_name)
|
||||
free(new_dir);
|
||||
free(new_pag);
|
||||
hdb_unlock(lock_fd);
|
||||
db->unlock(context, db);
|
||||
db->hdb_unlock(context, db);
|
||||
|
||||
if(ret) {
|
||||
ret = errno;
|
||||
@@ -194,25 +194,25 @@ NDBM_rename(krb5_context context, HDB *db, const char *new_name)
|
||||
close(d->lock_fd);
|
||||
d->lock_fd = lock_fd;
|
||||
|
||||
free(db->name);
|
||||
db->name = strdup(new_name);
|
||||
free(db->hdb_name);
|
||||
db->hdb_name = strdup(new_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static krb5_error_code
|
||||
NDBM__get(krb5_context context, HDB *db, krb5_data key, krb5_data *reply)
|
||||
{
|
||||
struct ndbm_db *d = (struct ndbm_db *)db->db;
|
||||
struct ndbm_db *d = (struct ndbm_db *)db->hdb_db;
|
||||
datum k, v;
|
||||
int code;
|
||||
|
||||
k.dptr = key.data;
|
||||
k.dsize = key.length;
|
||||
code = db->lock(context, db, HDB_RLOCK);
|
||||
code = db->hdb_lock(context, db, HDB_RLOCK);
|
||||
if(code)
|
||||
return code;
|
||||
v = dbm_fetch(d->db, k);
|
||||
db->unlock(context, db);
|
||||
db->hdb_unlock(context, db);
|
||||
if(v.dptr == NULL)
|
||||
return HDB_ERR_NOENTRY;
|
||||
|
||||
@@ -224,7 +224,7 @@ static krb5_error_code
|
||||
NDBM__put(krb5_context context, HDB *db, int replace,
|
||||
krb5_data key, krb5_data value)
|
||||
{
|
||||
struct ndbm_db *d = (struct ndbm_db *)db->db;
|
||||
struct ndbm_db *d = (struct ndbm_db *)db->hdb_db;
|
||||
datum k, v;
|
||||
int code;
|
||||
|
||||
@@ -233,11 +233,11 @@ NDBM__put(krb5_context context, HDB *db, int replace,
|
||||
v.dptr = value.data;
|
||||
v.dsize = value.length;
|
||||
|
||||
code = db->lock(context, db, HDB_WLOCK);
|
||||
code = db->hdb_lock(context, db, HDB_WLOCK);
|
||||
if(code)
|
||||
return code;
|
||||
code = dbm_store(d->db, k, v, replace ? DBM_REPLACE : DBM_INSERT);
|
||||
db->unlock(context, db);
|
||||
db->hdb_unlock(context, db);
|
||||
if(code == 1)
|
||||
return HDB_ERR_EXISTS;
|
||||
if (code < 0)
|
||||
@@ -248,17 +248,17 @@ NDBM__put(krb5_context context, HDB *db, int replace,
|
||||
static krb5_error_code
|
||||
NDBM__del(krb5_context context, HDB *db, krb5_data key)
|
||||
{
|
||||
struct ndbm_db *d = (struct ndbm_db *)db->db;
|
||||
struct ndbm_db *d = (struct ndbm_db *)db->hdb_db;
|
||||
datum k;
|
||||
int code;
|
||||
krb5_error_code ret;
|
||||
|
||||
k.dptr = key.data;
|
||||
k.dsize = key.length;
|
||||
ret = db->lock(context, db, HDB_WLOCK);
|
||||
ret = db->hdb_lock(context, db, HDB_WLOCK);
|
||||
if(ret) return ret;
|
||||
code = dbm_delete(d->db, k);
|
||||
db->unlock(context, db);
|
||||
db->hdb_unlock(context, db);
|
||||
if(code < 0)
|
||||
return errno;
|
||||
return 0;
|
||||
@@ -275,18 +275,18 @@ NDBM_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
asprintf(&lock_file, "%s.lock", (char*)db->name);
|
||||
asprintf(&lock_file, "%s.lock", (char*)db->hdb_name);
|
||||
if(lock_file == NULL) {
|
||||
free(d);
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
return ENOMEM;
|
||||
}
|
||||
d->db = dbm_open((char*)db->name, flags, mode);
|
||||
d->db = dbm_open((char*)db->hdb_name, flags, mode);
|
||||
if(d->db == NULL){
|
||||
ret = errno;
|
||||
free(d);
|
||||
free(lock_file);
|
||||
krb5_set_error_string(context, "dbm_open(%s): %s", db->name,
|
||||
krb5_set_error_string(context, "dbm_open(%s): %s", db->hdb_name,
|
||||
strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
@@ -301,7 +301,7 @@ NDBM_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
return ret;
|
||||
}
|
||||
free(lock_file);
|
||||
db->db = d;
|
||||
db->hdb_db = d;
|
||||
if((flags & O_ACCMODE) == O_RDONLY)
|
||||
ret = hdb_check_db_format(context, db);
|
||||
else
|
||||
@@ -314,7 +314,7 @@ NDBM_open(krb5_context context, HDB *db, int flags, mode_t mode)
|
||||
static krb5_error_code
|
||||
NDBM_close(krb5_context context, HDB *db)
|
||||
{
|
||||
struct ndbm_db *d = db->db;
|
||||
struct ndbm_db *d = db->hdb_db;
|
||||
dbm_close(d->db);
|
||||
close(d->lock_fd);
|
||||
free(d);
|
||||
@@ -331,30 +331,30 @@ hdb_ndbm_create(krb5_context context, HDB **db,
|
||||
return ENOMEM;
|
||||
}
|
||||
|
||||
(*db)->db = NULL;
|
||||
(*db)->name = strdup(filename);
|
||||
if ((*db)->name == NULL) {
|
||||
(*db)->hdb_db = NULL;
|
||||
(*db)->hdb_name = strdup(filename);
|
||||
if ((*db)->hdb_name == NULL) {
|
||||
krb5_set_error_string(context, "malloc: out of memory");
|
||||
free(*db);
|
||||
*db = NULL;
|
||||
return ENOMEM;
|
||||
}
|
||||
(*db)->master_key_set = 0;
|
||||
(*db)->openp = 0;
|
||||
(*db)->open = NDBM_open;
|
||||
(*db)->close = NDBM_close;
|
||||
(*db)->fetch = _hdb_fetch;
|
||||
(*db)->store = _hdb_store;
|
||||
(*db)->remove = _hdb_remove;
|
||||
(*db)->firstkey = NDBM_firstkey;
|
||||
(*db)->nextkey= NDBM_nextkey;
|
||||
(*db)->lock = NDBM_lock;
|
||||
(*db)->unlock = NDBM_unlock;
|
||||
(*db)->rename = NDBM_rename;
|
||||
(*db)->_get = NDBM__get;
|
||||
(*db)->_put = NDBM__put;
|
||||
(*db)->_del = NDBM__del;
|
||||
(*db)->destroy = NDBM_destroy;
|
||||
(*db)->hdb_master_key_set = 0;
|
||||
(*db)->hdb_openp = 0;
|
||||
(*db)->hdb_open = NDBM_open;
|
||||
(*db)->hdb_close = NDBM_close;
|
||||
(*db)->hdb_fetch = _hdb_fetch;
|
||||
(*db)->hdb_store = _hdb_store;
|
||||
(*db)->hdb_remove = _hdb_remove;
|
||||
(*db)->hdb_firstkey = NDBM_firstkey;
|
||||
(*db)->hdb_nextkey= NDBM_nextkey;
|
||||
(*db)->hdb_lock = NDBM_lock;
|
||||
(*db)->hdb_unlock = NDBM_unlock;
|
||||
(*db)->hdb_rename = NDBM_rename;
|
||||
(*db)->hdb__get = NDBM__get;
|
||||
(*db)->hdb__put = NDBM__put;
|
||||
(*db)->hdb__del = NDBM__del;
|
||||
(*db)->hdb_destroy = NDBM_destroy;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user