[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
shishi db/core.c db/db.c db/file.c db/internal....
From: |
shishi-commit |
Subject: |
shishi db/core.c db/db.c db/file.c db/internal.... |
Date: |
Tue, 02 Dec 2003 11:19:43 -0500 |
CVSROOT: /cvsroot/shishi
Module name: shishi
Branch:
Changes by: Simon Josefsson <address@hidden> 03/12/02 11:19:43
Modified files:
db : core.c db.c file.c internal.h shisa.h
src : shisa.c
Log message:
Fix.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/core.c.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/db.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/file.c.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/internal.h.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/shisa.h.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/src/shisa.c.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
Patches:
Index: shishi/db/core.c
diff -u shishi/db/core.c:1.5 shishi/db/core.c:1.6
--- shishi/db/core.c:1.5 Sun Nov 30 20:42:25 2003
+++ shishi/db/core.c Tue Dec 2 11:19:42 2003
@@ -73,8 +73,8 @@
int
shisa_principal_find (Shisa * dbh,
- const char *client,
const char *realm,
+ const char *principal,
Shisa_principal *ph)
{
_Shisa_db *db;
@@ -83,7 +83,7 @@
for (i = 0, db = dbh->dbs; i < dbh->ndbs; i++, db++)
{
- rc = db->backend->principal_find (dbh, db->state, client, realm, ph);
+ rc = db->backend->principal_find (dbh, db->state, realm, principal, ph);
if (rc == SHISA_OK || (rc != SHISA_OK && rc != SHISA_NO_PRINCIPAL))
return rc;
}
@@ -93,8 +93,8 @@
int
shisa_principal_update (Shisa * dbh,
- const char *client,
const char *realm,
+ const char *principal,
const Shisa_principal * ph)
{
_Shisa_db *db;
@@ -104,7 +104,7 @@
for (i = 0, db = dbh->dbs; i < dbh->ndbs; i++, db++)
{
/* XXX ignore read-only backends. */
- rc = db->backend->principal_update (dbh, db->state, client, realm, ph);
+ rc = db->backend->principal_update (dbh, db->state, realm, principal,
ph);
/* XXX ignore error and continue for ignore-error backends. */
return rc;
}
@@ -114,8 +114,8 @@
int
shisa_principal_add (Shisa * dbh,
- const char *client,
const char *realm,
+ const char *principal,
const Shisa_principal * ph,
const Shisa_key * key)
{
@@ -123,10 +123,14 @@
size_t i;
int rc;
+ if (realm == NULL)
+ return SHISA_NO_REALM;
+
for (i = 0, db = dbh->dbs; i < dbh->ndbs; i++, db++)
{
/* XXX ignore read-only backends. */
- rc = db->backend->principal_add (dbh, db->state, client, realm, ph, key);
+ rc = db->backend->principal_add (dbh, db->state, realm,
+ principal, ph, key);
/* XXX ignore error and continue for ignore-error backends. */
return rc;
}
@@ -143,6 +147,9 @@
size_t i;
int rc;
+ if (realm == NULL)
+ return SHISA_NO_REALM;
+
for (i = 0, db = dbh->dbs; i < dbh->ndbs; i++, db++)
{
/* XXX ignore read-only backends. */
@@ -152,40 +159,4 @@
}
return SHISA_REMOVE_PRINCIPAL_ERROR;
-}
-
-int
-shisa_realm_add (Shisa * dbh, const char *realm)
-{
- _Shisa_db *db;
- size_t i;
- int rc;
-
- for (i = 0, db = dbh->dbs; i < dbh->ndbs; i++, db++)
- {
- /* XXX ignore read-only backends. */
- rc = db->backend->realm_add (dbh, db->state, realm);
- /* XXX ignore error and continue for ignore-error backends. */
- return rc;
- }
-
- return SHISA_NO_PRINCIPAL;
-}
-
-int
-shisa_realm_remove (Shisa * dbh, const char *realm)
-{
- _Shisa_db *db;
- size_t i;
- int rc;
-
- for (i = 0, db = dbh->dbs; i < dbh->ndbs; i++, db++)
- {
- /* XXX ignore read-only backends. */
- rc = db->backend->realm_remove (dbh, db->state, realm);
- /* XXX ignore error and continue for ignore-error backends. */
- return rc;
- }
-
- return SHISA_NO_PRINCIPAL;
}
Index: shishi/db/db.c
diff -u shishi/db/db.c:1.7 shishi/db/db.c:1.8
--- shishi/db/db.c:1.7 Sun Nov 30 20:42:25 2003
+++ shishi/db/db.c Tue Dec 2 11:19:42 2003
@@ -26,8 +26,6 @@
shisa_file_init,
shisa_file_enumerate_realms,
shisa_file_enumerate_principals,
- shisa_file_realm_add,
- shisa_file_realm_remove,
shisa_file_principal_find,
shisa_file_principal_update,
shisa_file_principal_add,
Index: shishi/db/file.c
diff -u shishi/db/file.c:1.10 shishi/db/file.c:1.11
--- shishi/db/file.c:1.10 Sun Nov 30 20:42:25 2003
+++ shishi/db/file.c Tue Dec 2 11:19:42 2003
@@ -183,75 +183,33 @@
}
int
-shisa_file_realm_add (Shisa * dbh,
- void *state,
- const char *realm)
-{
- Shisa_file *info = state;
-
- if (_shisa_isdir2 (info->path, realm))
- return SHISA_ADD_REALM_EXISTS;
-
- if (_shisa_mkdir2 (info->path, realm) != 0)
- return SHISA_ADD_REALM_ERROR;
-
- return SHISA_OK;
-
-}
-
-int
-shisa_file_realm_remove (Shisa * dbh,
- void *state,
- const char *realm)
-{
- Shisa_file *info = state;
- size_t nprincipals = 0;
- int rc;
-
- if (!_shisa_isdir2 (info->path, realm))
- return SHISA_NO_REALM;
-
- rc = shisa_file_enumerate_principals (dbh, state, realm, NULL, &nprincipals);
- if (rc != SHISA_OK)
- return rc;
-
- if (nprincipals > 0)
- return SHISA_REMOVE_REALM_NONEMPTY;
-
- if (_shisa_rmdir2 (info->path, realm) != 0)
- return SHISA_REMOVE_REALM_ERROR;
-
- return SHISA_OK;
-}
-
-int
shisa_file_principal_find (Shisa * dbh,
void *state,
- const char *client,
const char *realm,
+ const char *principal,
Shisa_principal *ph)
{
Shisa_file *info = state;
- if (!_shisa_isdir3 (info->path, realm, client))
+ if (!_shisa_isdir3 (info->path, realm, principal))
return SHISA_NO_PRINCIPAL;
ph->notusedbefore =
- _shisa_mtime4 (info->path, realm, client, "validfrom.stamp");
+ _shisa_mtime4 (info->path, realm, principal, "validfrom.stamp");
ph->isdisabled =
- _shisa_isfile4 (info->path, realm, client, "disabled.flag");
- ph->kvno = _shisa_uint32link4 (info->path, realm, client, "latest.key");
+ _shisa_isfile4 (info->path, realm, principal, "disabled.flag");
+ ph->kvno = _shisa_uint32link4 (info->path, realm, principal, "latest.key");
ph->lastinitialtgt =
- _shisa_mtime4 (info->path, realm, client, "lastinitaltgt.stamp");
+ _shisa_mtime4 (info->path, realm, principal, "lastinitaltgt.stamp");
ph->lastinitialrequest =
- _shisa_mtime4 (info->path, realm, client, "lastinitial.stamp");
- ph->lasttgt = _shisa_mtime4 (info->path, realm, client, "lasttgt.stamp");
+ _shisa_mtime4 (info->path, realm, principal, "lastinitial.stamp");
+ ph->lasttgt = _shisa_mtime4 (info->path, realm, principal, "lasttgt.stamp");
ph->lastrenewal =
- _shisa_mtime4 (info->path, realm, client, "lastrenewal.stamp");
+ _shisa_mtime4 (info->path, realm, principal, "lastrenewal.stamp");
ph->passwordexpire =
- _shisa_mtime4 (info->path, realm, client, "passwordexpire.stamp");
+ _shisa_mtime4 (info->path, realm, principal, "passwordexpire.stamp");
ph->accountexpire =
- _shisa_mtime4 (info->path, realm, client, "accountexpire.stamp");
+ _shisa_mtime4 (info->path, realm, principal, "accountexpire.stamp");
return SHISA_OK;
}
@@ -259,8 +217,8 @@
int
shisa_file_principal_update (Shisa * dbh,
void *state,
- const char *client,
const char *realm,
+ const char *principal,
const Shisa_principal * ph)
{
Shisa_file *info = state;
@@ -268,13 +226,28 @@
return SHISA_OK;
}
-int
-shisa_file_principal_add (Shisa * dbh,
- void *state,
- const char *realm,
- const char *principal,
- const Shisa_principal * ph,
- const Shisa_key * key)
+static int
+realm_add (Shisa * dbh, void *state, const char *realm)
+{
+ Shisa_file *info = state;
+
+ if (_shisa_isdir2 (info->path, realm))
+ return SHISA_ADD_REALM_EXISTS;
+
+ if (_shisa_mkdir2 (info->path, realm) != 0)
+ return SHISA_ADD_REALM_ERROR;
+
+ return SHISA_OK;
+
+}
+
+static int
+principal_add (Shisa * dbh,
+ void *state,
+ const char *realm,
+ const char *principal,
+ const Shisa_principal * ph,
+ const Shisa_key * key)
{
Shisa_file *info = state;
@@ -296,10 +269,51 @@
}
int
-shisa_file_principal_remove (Shisa * dbh,
- void *state,
- const char *realm,
- const char *principal)
+shisa_file_principal_add (Shisa * dbh,
+ void *state,
+ const char *realm,
+ const char *principal,
+ const Shisa_principal * ph,
+ const Shisa_key * key)
+{
+ int rc;
+
+ if (principal == NULL)
+ rc = realm_add (dbh, state, realm);
+ else
+ rc = principal_add (dbh, state, realm, principal, ph, key);
+
+ return rc;
+}
+
+static int
+realm_remove (Shisa * dbh, void *state, const char *realm)
+{
+ Shisa_file *info = state;
+ size_t nprincipals = 0;
+ int rc;
+
+ if (!_shisa_isdir2 (info->path, realm))
+ return SHISA_NO_REALM;
+
+ rc = shisa_file_enumerate_principals (dbh, state, realm, NULL, &nprincipals);
+ if (rc != SHISA_OK)
+ return rc;
+
+ if (nprincipals > 0)
+ return SHISA_REMOVE_REALM_NONEMPTY;
+
+ if (_shisa_rmdir2 (info->path, realm) != 0)
+ return SHISA_REMOVE_REALM_ERROR;
+
+ return SHISA_OK;
+}
+
+static int
+principal_remove (Shisa * dbh,
+ void *state,
+ const char *realm,
+ const char *principal)
{
Shisa_file *info = state;
size_t nprincipals = 0;
@@ -315,6 +329,22 @@
return SHISA_REMOVE_PRINCIPAL_ERROR;
return SHISA_OK;
+}
+
+int
+shisa_file_principal_remove (Shisa * dbh,
+ void *state,
+ const char *realm,
+ const char *principal)
+{
+ int rc;
+
+ if (principal == NULL)
+ rc = realm_remove (dbh, state, realm);
+ else
+ rc = principal_remove (dbh, state, realm, principal);
+
+ return rc;
}
void
Index: shishi/db/internal.h
diff -u shishi/db/internal.h:1.7 shishi/db/internal.h:1.8
--- shishi/db/internal.h:1.7 Sun Nov 30 20:42:25 2003
+++ shishi/db/internal.h Tue Dec 2 11:19:43 2003
@@ -55,26 +55,20 @@
const char *realm,
char ***principals,
size_t *nprincipals);
-typedef int (*_Shisa_db_realm_add) (Shisa * dbh,
- void *state,
- const char *realm);
-typedef int (*_Shisa_db_realm_remove) (Shisa * dbh,
- void *state,
- const char *realm);
typedef int (*_Shisa_db_principal_find) (Shisa * dbh,
void *state,
- const char *client,
const char *realm,
+ const char *principal,
Shisa_principal *ph);
typedef int (*_Shisa_db_principal_update) (Shisa * dbh,
void *state,
- const char *client,
const char *realm,
+ const char *principal,
const Shisa_principal * ph);
typedef int (*_Shisa_db_principal_add) (Shisa * dbh,
void *state,
- const char *client,
const char *realm,
+ const char *principal,
const Shisa_principal * ph,
const Shisa_key * key);
typedef int (*_Shisa_db_principal_remove) (Shisa * dbh,
@@ -89,8 +83,6 @@
_Shisa_db_init init;
_Shisa_db_enumerate_realms enumerate_realms;
_Shisa_db_enumerate_principals enumerate_principals;
- _Shisa_db_realm_add realm_add;
- _Shisa_db_realm_remove realm_remove;
_Shisa_db_principal_find principal_find;
_Shisa_db_principal_update principal_update;
_Shisa_db_principal_add principal_add;
@@ -131,26 +123,20 @@
const char *realm,
char ***principals,
size_t *nprincipals);
-extern int shisa_file_realm_add (Shisa * dbh,
- void *state,
- const char *realm);
-extern int shisa_file_realm_remove (Shisa * dbh,
- void *state,
- const char *realm);
extern int shisa_file_principal_find (Shisa * dbh,
void *state,
- const char *client,
const char *realm,
+ const char *principal,
Shisa_principal *ph);
extern int shisa_file_principal_update (Shisa * dbh,
void *state,
- const char *client,
const char *realm,
+ const char *principal,
const Shisa_principal * ph);
extern int shisa_file_principal_add (Shisa * dbh,
void *state,
- const char *client,
const char *realm,
+ const char *principal,
const Shisa_principal * ph,
const Shisa_key * key);
extern int shisa_file_principal_remove (Shisa * dbh,
Index: shishi/db/shisa.h
diff -u shishi/db/shisa.h:1.12 shishi/db/shisa.h:1.13
--- shishi/db/shisa.h:1.12 Sun Nov 30 20:42:25 2003
+++ shishi/db/shisa.h Tue Dec 2 11:19:43 2003
@@ -107,20 +107,17 @@
char ***principals,
size_t * nprincipals);
-extern int shisa_realm_add (Shisa * dbh, const char *realm);
-extern int shisa_realm_remove (Shisa * dbh, const char *realm);
-
extern int shisa_principal_find (Shisa * dbh,
- const char *client,
const char *realm,
+ const char *principal,
Shisa_principal * ph);
extern int shisa_principal_update (Shisa * dbh,
- const char *client,
const char *realm,
+ const char *principal,
const Shisa_principal * ph);
extern int shisa_principal_add (Shisa * dbh,
- const char *client,
const char *realm,
+ const char *principal,
const Shisa_principal * ph,
const Shisa_key * key);
extern int shisa_principal_remove (Shisa * dbh,
Index: shishi/src/shisa.c
diff -u shishi/src/shisa.c:1.11 shishi/src/shisa.c:1.12
--- shishi/src/shisa.c:1.11 Sun Nov 30 22:01:19 2003
+++ shishi/src/shisa.c Tue Dec 2 11:19:43 2003
@@ -75,7 +75,7 @@
}
int
-dumplist_realm_principal (const char *principal, const char *realm)
+dumplist_realm_principal (const char *realm, const char *principal)
{
Shisa_principal ph;
int rc;
@@ -84,7 +84,7 @@
args_info.enabled_flag ||
args_info.disabled_flag)
{
- rc = shisa_principal_find (dbh, principal, realm, &ph);
+ rc = shisa_principal_find (dbh, realm, principal, &ph);
if (rc != SHISA_OK)
return rc;
}
@@ -137,7 +137,7 @@
for (i = 0; i < nprincipals; i++)
{
if (rc == SHISA_OK)
- rc = dumplist_realm_principal (principals[i], realm);
+ rc = dumplist_realm_principal (realm, principals[i]);
free (principals[i]);
}
if (nprincipals > 0)
@@ -158,7 +158,7 @@
char *realm = args_info.inputs[0];
char *principal = args_info.inputs[1];
printf ("%s\n", realm);
- rc = dumplist_realm_principal (principal, realm);
+ rc = dumplist_realm_principal (realm, principal);
}
else
{
@@ -184,12 +184,12 @@
}
int
-modify_realm_principal (const char *principal, const char *realm)
+modify_principal (const char *realm, const char *principal)
{
Shisa_principal ph;
int rc;
- printf ("Modifying principal address@hidden'...", realm, principal); fflush
(stdout);
+ printf ("Modifying principal address@hidden'...", principal, realm); fflush
(stdout);
rc = shisa_principal_update (dbh, realm, principal, &ph);
if (rc != SHISA_OK)
@@ -209,7 +209,7 @@
int rc;
if (args_info.inputs_num == 2)
- rc = modify_realm_principal (args_info.inputs[1], args_info.inputs[0]);
+ rc = modify_principal (args_info.inputs[0], args_info.inputs[1]);
else
{
error (0, 0, "too few arguments");
@@ -221,34 +221,20 @@
}
int
-add_realm_principal (const char *principal, const char *realm)
+add_principal (const char *realm, const char *principal)
{
Shisa_principal ph;
Shisa_key key;
int rc;
- printf ("Adding principal address@hidden'...", realm, principal); fflush
(stdout);
-
- rc = shisa_principal_add (dbh, realm, principal, &ph, &key);
- if (rc != SHISA_OK)
- {
- printf ("failure: %s\n", shisa_strerror (rc));
- return EXIT_FAILURE;
- }
-
- printf ("done\n");
-
- return EXIT_SUCCESS;
-}
-
-int
-add_realm (const char *realm)
-{
- int rc;
+ if (principal == NULL)
+ printf ("Adding realm `%s'...", realm);
+ else
+ printf ("Adding principal address@hidden'...", principal, realm);
- printf ("Adding realm `%s'...", realm); fflush (stdout);
+ fflush (stdout);
- rc = shisa_realm_add (dbh, realm);
+ rc = shisa_principal_add (dbh, realm, principal, &ph, &key);
if (rc != SHISA_OK)
{
printf ("failure: %s\n", shisa_strerror (rc));
@@ -266,9 +252,9 @@
int rc;
if (args_info.inputs_num == 1)
- rc = add_realm (args_info.inputs[0]);
+ rc = add_principal (args_info.inputs[0], NULL);
else if (args_info.inputs_num == 2)
- rc = add_realm_principal (args_info.inputs[1], args_info.inputs[0]);
+ rc = add_principal (args_info.inputs[0], args_info.inputs[1]);
else
{
error (0, 0, "too few arguments");
@@ -280,13 +266,17 @@
}
int
-delete_realm_principal (const char *realm, const char *principal)
+delete_principal (const char *realm, const char *principal)
{
int rc;
- printf ("Removing principal address@hidden'...", realm, principal); fflush
(stdout);
+ if (principal == NULL)
+ printf ("Removing realm `%s'...", realm);
+ else
+ printf ("Removing principal address@hidden'...", principal, realm);
+ fflush (stdout);
- rc = shisa_principal_remove (dbh, principal, realm);
+ rc = shisa_principal_remove (dbh, realm, principal);
if (rc != SHISA_OK)
{
printf ("failure: %s\n", shisa_strerror (rc));
@@ -299,34 +289,14 @@
}
int
-delete_realm (const char *realm)
-{
- int rc;
-
- printf ("Removing realm `%s'...", realm); fflush (stdout);
-
- rc = shisa_realm_remove (dbh, realm);
- if (rc != SHISA_OK)
- {
- printf ("failure: %s\n", shisa_strerror (rc));
- return EXIT_FAILURE;
- }
-
- printf ("done\n", realm);
-
- return EXIT_SUCCESS;
-
-}
-
-int
delete (void)
{
int rc;
if (args_info.inputs_num == 1)
- rc = delete_realm (args_info.inputs[0]);
+ rc = delete_principal (args_info.inputs[0], NULL);
else if (args_info.inputs_num == 2)
- rc = delete_realm_principal (args_info.inputs[1], args_info.inputs[0]);
+ rc = delete_principal (args_info.inputs[0], args_info.inputs[1]);
else
{
error (0, 0, "too few arguments");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- shishi db/core.c db/db.c db/file.c db/internal....,
shishi-commit <=