+2002-10-08 Tom Yu <tlyu@mit.edu>
+
+ * kadmin.c (quit): Release exclusive lock, if acquired.
+ (kadmin_lock, kadmin_unlock): New functions to call kadm5_lock and
+ kadm5_unlock.
+
+ * kadmin.h: Add kadmin_lock and kadmin_unlock.
+
+ * kadmin_ct.ct: Add lock and unlock commands.
+
2002-08-29 Ken Raeburn <raeburn@mit.edu>
* Makefile.in: Revert $(S)=>/ change, for Windows support.
krb5_context context;
char *ccache_name = NULL;
+int locked = 0;
+
static void usage()
{
fprintf(stderr,
int quit()
{
+ kadm5_ret_t retval;
+
+ if (locked) {
+ retval = kadm5_unlock(handle);
+ if (retval) {
+ com_err("quit", retval, "while unlocking locked database");
+ return 1;
+ }
+ locked = 0;
+ }
+
kadm5_destroy(handle);
if (ccache_name != NULL) {
fprintf(stderr,
return 0;
}
+void kadmin_lock(argc, argv)
+ int argc;
+ char *argv[];
+{
+ kadm5_ret_t retval;
+
+ if (locked)
+ return;
+ retval = kadm5_lock(handle);
+ if (retval) {
+ com_err("lock", retval, "");
+ return;
+ }
+ locked = 1;
+}
+
+void kadmin_unlock(argc, argv)
+ int argc;
+ char *argv[];
+{
+ kadm5_ret_t retval;
+
+ if (!locked)
+ return;
+ retval = kadm5_lock(handle);
+ if (retval) {
+ com_err("unlock", retval, "");
+ return;
+ }
+ locked = 0;
+}
+
void kadmin_delprinc(argc, argv)
int argc;
char *argv[];
/* It would be nice if ss produced a header file we could reference */
extern char *kadmin_startup(int argc, char *argv[]);
extern int quit (void);
+extern void kadmin_lock(int argc, char *argv[]);
+extern void kadmin_unlock(int argc, char *argv[]);
extern void kadmin_delprinc(int argc, char *argv[]);
extern void kadmin_cpw(int argc, char *argv[]);
extern void kadmin_addprinc(int argc, char *argv[]);
request kadmin_keytab_remove, "Remove entry(s) from a keytab",
ktremove, ktrem;
+request kadmin_lock, "Lock database exclusively (use with extreme caution!)",
+ lock;
+
+request kadmin_unlock, "Release exclusive database lock",
+ unlock;
+
# list_requests is generic -- unrelated to Kerberos
request ss_list_requests, "List available requests.",
list_requests, lr, "?";
+2002-10-08 Tom Yu <tlyu@mit.edu>
+
+ * adb.h (struct _osa_adb_db_ent_t): Add opencnt, which keeps track
+ of how many times an open was attempted on the adb.
+
+ * admin.h: Add kadm5_lock and kadm5_unlock.
+
2002-09-18 Ken Raeburn <raeburn@mit.edu>
* admin.h (struct __krb5_realm_params): New field
BTREEINFO btinfo;
char *filename;
osa_adb_lock_t lock;
+ int opencnt;
} osa_adb_db_ent, *osa_adb_db_t, *osa_adb_princ_t, *osa_adb_policy_t;
/* an osa_pw_hist_ent stores all the key_datas for a single password */
krb5_ui_4 api_version,
void **server_handle);
#endif
+kadm5_ret_t kadm5_lock(void *server_handle);
+kadm5_ret_t kadm5_unlock(void *server_handle);
kadm5_ret_t kadm5_flush(void *server_handle);
kadm5_ret_t kadm5_destroy(void *server_handle);
kadm5_ret_t kadm5_create_principal(void *server_handle,
+2002-10-08 Tom Yu <tlyu@mit.edu>
+
+ * Makefile.in (LIBMINOR): Bump.
+
+ * client_init.c (kadm5_lock, kadm5_unlock): Add stubs that error
+ out, since these are not supported on the client side.
+
2002-09-18 Ken Raeburn <raeburn@mit.edu>
* client_init.c (_kadm5_init_any): If creating a new ccache, put
LIB=kadm5clnt
LIBMAJOR=5
-LIBMINOR=0
+LIBMINOR=1
STOBJLISTS=../OBJS.ST OBJS.ST
SHLIB_EXPDEPS=\
$(TOPLIBD)/libgssrpc$(SHLIBEXT) \
return code;
}
+/* not supported on client */
+kadm5_ret_t kadm5_lock(void *server_handle)
+{
+ return EINVAL;
+}
+
+/* not supported on client */
+kadm5_ret_t kadm5_unlock(void *server_handle)
+{
+ return EINVAL;
+}
kadm5_ret_t kadm5_flush(void *server_handle)
{
+2002-10-08 Tom Yu <tlyu@mit.edu>
+
+ * adb_openclose.c (osa_adb_init_db): Reset opencnt.
+ (osa_adb_open_and_lock): Don't open multiple times; merely
+ increment opencnt if already open.
+ (osa_adb_close_and_unlock): Decrement opencnt instead of
+ unconditionaly closing.
+
+ * server_init.c (kadm5_lock, kadm5_unlock): New functions to
+ support persistent exclusive locks across multiple API calls.
+
2002-08-29 Ken Raeburn <raeburn@mit.edu>
* Makefile.in: Revert $(S)=>/ change, for Windows support.
LIB=kadm5srv
LIBMAJOR=5
-LIBMINOR=0
+LIBMINOR=1
STOBJLISTS=../OBJS.ST OBJS.ST
SHLIB_EXPDEPS=\
$(TOPLIBD)/libgssrpc$(SHLIBEXT) \
db->lock = &lockp->lockinfo;
db->lock->refcnt++;
+ db->opencnt = 0;
db->filename = strdup(filename);
db->magic = magic;
ret = osa_adb_get_lock(db, locktype);
if (ret != OSA_ADB_OK)
return ret;
-
+ if (db->opencnt)
+ goto open_ok;
+
db->db = dbopen(db->filename, O_RDWR, 0600, DB_BTREE, &db->btinfo);
if (db->db != NULL)
- return OSA_ADB_OK;
+ goto open_ok;
switch (errno) {
#ifdef EFTYPE
case EFTYPE:
case EINVAL:
db->db = dbopen(db->filename, O_RDWR, 0600, DB_HASH, &db->info);
if (db->db != NULL)
- return OSA_ADB_OK;
+ goto open_ok;
default:
(void) osa_adb_release_lock(db);
if (errno == EINVAL)
return OSA_ADB_BAD_DB;
return errno;
}
+open_ok:
+ db->opencnt++;
+ return OSA_ADB_OK;
}
osa_adb_ret_t osa_adb_close_and_unlock(osa_adb_princ_t db)
{
- if(db->db->close(db->db) == -1) {
+ if (--db->opencnt)
+ return osa_adb_release_lock(db);
+ if(db->db != NULL && db->db->close(db->db) == -1) {
(void) osa_adb_release_lock(db);
return OSA_ADB_FAILURE;
}
return(osa_adb_release_lock(db));
}
-
return KADM5_OK;
}
+kadm5_ret_t kadm5_lock(void *server_handle)
+{
+ kadm5_server_handle_t handle = server_handle;
+ kadm5_ret_t ret;
+
+ CHECK_HANDLE(server_handle);
+ ret = osa_adb_open_and_lock(handle->policy_db, OSA_ADB_EXCLUSIVE);
+ if (ret)
+ return ret;
+ ret = krb5_db_lock(handle->context, KRB5_LOCKMODE_EXCLUSIVE);
+ if (ret)
+ return ret;
+}
+
+kadm5_ret_t kadm5_unlock(void *server_handle)
+{
+ kadm5_server_handle_t handle = server_handle;
+ kadm5_ret_t ret;
+
+ CHECK_HANDLE(server_handle);
+ ret = osa_adb_close_and_unlock(handle->policy_db);
+ if (ret)
+ return ret;
+ ret = krb5_db_unlock(handle->context);
+ if (ret)
+ return ret;
+}
+
kadm5_ret_t kadm5_flush(void *server_handle)
{
kadm5_server_handle_t handle = server_handle;