shishi-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

shishi/db core.c error.c file.c shisa.h


From: shishi-commit
Subject: shishi/db core.c error.c file.c shisa.h
Date: Sat, 29 Nov 2003 16:35:38 -0500

CVSROOT:        /cvsroot/shishi
Module name:    shishi
Branch:         
Changes by:     Simon Josefsson <address@hidden>        03/11/29 16:35:38

Modified files:
        db             : core.c error.c file.c shisa.h 

Log message:
        Sync.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/core.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/error.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/file.c.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/shisa.h.diff?tr1=1.7&tr2=1.8&r1=text&r2=text

Patches:
Index: shishi/db/core.c
diff -u shishi/db/core.c:1.1 shishi/db/core.c:1.2
--- shishi/db/core.c:1.1        Fri Nov 28 21:43:26 2003
+++ shishi/db/core.c    Sat Nov 29 16:35:38 2003
@@ -75,7 +75,7 @@
                      const char *realm,
                      Shisa_principal **ph)
 {
-  return SHISA_DB_FIND_ERROR;
+  return SHISA_FIND_ERROR;
 }
 
 void
Index: shishi/db/error.c
diff -u shishi/db/error.c:1.2 shishi/db/error.c:1.3
--- shishi/db/error.c:1.2       Fri Nov 28 21:43:26 2003
+++ shishi/db/error.c   Sat Nov 29 16:35:38 2003
@@ -33,7 +33,7 @@
   {SHISA_CFG_NO_FILE, "The Shisa configuration file does not exist."},
   {SHISA_CFG_IO_ERROR, "File I/O error for Shisa configuration file."},
   {SHISA_CFG_SYNTAX_ERROR, "Syntax error in Shisa configuration token."},
-  {SHISA_DB_OPEN_ERROR, "Shisa database could not be opened."},
+  {SHISA_OPEN_ERROR, "Shisa database could not be opened."},
 };
 
 /**
Index: shishi/db/file.c
diff -u shishi/db/file.c:1.4 shishi/db/file.c:1.5
--- shishi/db/file.c:1.4        Sat Nov 29 13:29:41 2003
+++ shishi/db/file.c    Sat Nov 29 16:35:38 2003
@@ -32,20 +32,18 @@
  * Where LOCATION is a path name, e.g. /var/shisa.  No OPTIONS are
  * currently implemented.
  *
- * Realms are directories in LOCATION that contain a file called
- * "info.txt".  Principals are directories in realm directories that
- * contain a file called "info.txt".  Characters outside A-Za-z0-9_-
- * are escaped using the URL encoding, e.g. example/host%2fwww denote
- * the "host/www" principal in the "example" realm.
+ * Realms are directories in LOCATION.  Principals are directories in
+ * realm directories.  Characters outside A-Za-z0-9_- are escaped
+ * using the URL encoding, e.g. example/host%2fwww denote the
+ * "host/www" principal in the "example" realm.
  *
  * Example file tree:
  *
  * LOCATION/EXAMPLE.ORG
- * LOCATION/EXAMPLE.ORG/info.txt
  * LOCATION/EXAMPLE.ORG/krbtgt%2fEXAMPLE.ORG
- * LOCATION/EXAMPLE.ORG/krbtgt%2fEXAMPLE.ORG/info.txt
  * LOCATION/EXAMPLE.ORG/host%2fkerberos.example.org
- * LOCATION/EXAMPLE.ORG/host%2fkerberos.example.org/info.txt
+ * LOCATION/EXAMPLE.NET
+ * LOCATION/EXAMPLE.NET/krbtgt%2fEXAMPLE.NET
  *
  */
 
@@ -120,6 +118,49 @@
   return SHISA_OK;
 }
 
+static int
+isdir (const char *path)
+{
+  struct stat buf;
+  int rc;
+
+  rc = stat (path, &buf);
+  if (rc != 0 || !S_ISDIR (buf.st_mode))
+    return 0;
+
+  return 1;
+}
+
+static int
+isdir2 (const char *path1, const char *path2)
+{
+  char *tmp;
+  int rc;
+
+  asprintf (&tmp, "%s/%s", path1, path2);
+
+  rc = isdir (tmp);
+
+  free (tmp);
+
+  return rc;
+}
+
+static int
+isdir3 (const char *path1, const char *path2, const char *path3)
+{
+  char *tmp;
+  int rc;
+
+  asprintf (&tmp, "%s/%s/%s", path1, path2, path3);
+
+  rc = isdir (tmp);
+
+  free (tmp);
+
+  return rc;
+}
+
 int
 shisa_file_init (Shisa *dbh,
                 const char *location,
@@ -127,15 +168,13 @@
                 void **state)
 {
   Shisa_file *info;
-  struct stat buf;
   int rc;
 
-  rc = stat (location, &buf);
-  if (rc != 0 || !S_ISDIR (buf.st_mode))
+  if (!isdir (location))
     {
       errno = ENOTDIR;
       perror (location);
-      return SHISA_DB_OPEN_ERROR;
+      return SHISA_OPEN_ERROR;
     }
 
   *state = info = xcalloc (1, sizeof (*info));
@@ -148,23 +187,11 @@
   return SHISA_OK;
 }
 
-static int
-has_info_txt (char *path, char *directory)
+static char *
+unescape_filename (const char *path)
 {
-  struct stat buf;
-  char *tmp;
-  int rc;
-
-  asprintf (&tmp, "%s/%s/info.txt", path, directory);
-
-  rc = stat (tmp, &buf);
-
-  free (tmp);
-
-  if (rc != 0 || !S_ISREG (buf.st_mode))
-    return 0;
-
-  return 1;
+  /* XXX fix. */
+  return xstrdup (path);
 }
 
 static int
@@ -181,10 +208,10 @@
     {
       if (strcmp (de->d_name, ".") == 0 || strcmp (de->d_name, "..") == 0)
        continue;
-      if (has_info_txt (path, de->d_name))
+      if (isdir2 (path, de->d_name))
        {
          *files = xrealloc (*files, (*nfiles + 1) * sizeof (**files));
-         (*files)[(*nfiles)++] = xstrdup (de->d_name);
+         (*files)[(*nfiles)++] = unescape_filename (de->d_name);
        }
     }
 
@@ -198,7 +225,7 @@
        free (**files);
       free (*files);
 
-      return SHISA_DB_LIST_REALM_ERROR;
+      return SHISA_LIST_REALM_ERROR;
     }
 
   return SHISA_OK;
@@ -218,7 +245,7 @@
   if (dir == NULL)
     {
       perror(path);
-      return SHISA_DB_LIST_REALM_ERROR;
+      return SHISA_LIST_REALM_ERROR;
     }
 
   rc = shisa_file_ls_1 (dbh, path, files, nfiles, dir);
@@ -227,7 +254,7 @@
       rc = closedir (dir);
       if (rc != 0)
        perror (path);
-      return SHISA_DB_LIST_REALM_ERROR;
+      return SHISA_LIST_REALM_ERROR;
     }
 
   rc = closedir (dir);
@@ -241,7 +268,7 @@
        free (**files);
       free (*files);
 
-      return SHISA_DB_LIST_REALM_ERROR;
+      return SHISA_LIST_REALM_ERROR;
     }
 
   return SHISA_OK;
@@ -290,6 +317,12 @@
                           Shisa_principal **ph)
 {
   Shisa_file *info = state;
+  Shisa_principal *princ;
+
+  if (!isdir3 (info->path, realm, client))
+    return SHISA_NO_PRINCIPAL;
+
+  princ = xmalloc (sizeof (*princ));
 
   return SHISA_INIT_ERROR;
 }
@@ -305,4 +338,23 @@
        free (info->path);
       free (info);
     }
+}
+
+static int
+has_info_txt (char *path, char *directory)
+{
+  struct stat buf;
+  char *tmp;
+  int rc;
+
+  asprintf (&tmp, "%s/%s/info.txt", path, directory);
+
+  rc = stat (tmp, &buf);
+
+  free (tmp);
+
+  if (rc != 0 || !S_ISREG (buf.st_mode))
+    return 0;
+
+  return 1;
 }
Index: shishi/db/shisa.h
diff -u shishi/db/shisa.h:1.7 shishi/db/shisa.h:1.8
--- shishi/db/shisa.h:1.7       Fri Nov 28 21:43:26 2003
+++ shishi/db/shisa.h   Sat Nov 29 16:35:38 2003
@@ -34,25 +34,31 @@
   SHISA_CFG_NO_FILE = 2,
   SHISA_CFG_IO_ERROR = 3,
   SHISA_CFG_SYNTAX_ERROR = 4,
-  SHISA_DB_OPEN_ERROR = 5,
-  SHISA_DB_NO_REALM = 6,
-  SHISA_DB_LIST_REALM_ERROR = 7,
-  SHISA_DB_NO_PRINCIPAL = 8,
-  SHISA_DB_LIST_PRINCIPAL_ERROR = 8,
-  SHISA_DB_FIND_ERROR = 9
+  SHISA_OPEN_ERROR = 5,
+  SHISA_NO_REALM = 6,
+  SHISA_LIST_REALM_ERROR = 7,
+  SHISA_NO_PRINCIPAL = 8,
+  SHISA_LIST_PRINCIPAL_ERROR = 8,
+  SHISA_FIND_ERROR = 9,
+  SHISA_NO_KEY = 10
 };
 typedef enum Shisa_rc Shisa_rc;
 
-typedef struct Shisa           Shisa;
+typedef struct Shisa Shisa;
 
 struct Shisa_principal
 {
   char *name;
   char *realm;
   time_t notusedbefore;
-  time_t notusedafter;
   int isdisabled;
   int32_t kvno;
+  time_t lastinitialtgt;       /* time of last initial request for a TGT */
+  time_t lastinitialrequest;   /* time of last initial request */
+  time_t lasttgt;              /* time of issue for the newest TGT used */
+  time_t lastrenewal;          /* time of the last renewal */
+  time_t passwordexpire;       /* time when the password will expire */
+  time_t accountexpire;                /* time when the account will expire. */
 };
 typedef struct Shisa_principal Shisa_principal;
 
@@ -85,35 +91,38 @@
 extern const char *shisa_cfg_default_systemfile (Shisa * dbh);
 
 /* Core API. */
-extern int shisa_enumerate_realms (Shisa *dbh,
-                                  char ***realms,
-                                  size_t *nrealms);
-extern int shisa_enumerate_principals (Shisa *dbh,
+extern int shisa_enumerate_realms (Shisa * dbh,
+                                  char ***realms, size_t * nrealms);
+extern int shisa_enumerate_principals (Shisa * dbh,
                                       const char *realm,
                                       char ***principals,
-                                      size_t *nprincipals);
+                                      size_t * nprincipals);
 
 extern int shisa_principal_find (Shisa * dbh,
                                 const char *client,
-                                const char *realm,
-                                Shisa_principal **ph);
-extern void shisa_principal_free (Shisa_principal *ph);
+                                const char *realm, Shisa_principal ** ph);
+extern void shisa_principal_free (Shisa_principal * ph);
 extern int shisa_principal_set (Shisa * dbh, const Shisa_principal * ph);
 extern int shisa_principal_add (Shisa * dbh, const Shisa_principal * ph,
-                               const Shisa_key *key);
+                               const Shisa_key * key);
 extern int shisa_principal_remove (Shisa * dbh, const Shisa_principal * ph);
 
 extern int shisa_key_find (Shisa * dbh, const Shisa_principal * ph,
-                         Shisa_key **key);
-extern void shisa_key_free (Shisa_key *key);
+                          Shisa_key ** key);
+extern void shisa_key_free (Shisa_key * key);
 extern int shisa_key_set (Shisa * dbh, const Shisa_principal * ph,
-                         const Shisa_key *key);
+                         const Shisa_key * key);
 extern int shisa_key_add (Shisa * dbh, const Shisa_principal * ph,
-                         const Shisa_key *key);
+                         const Shisa_key * key);
 extern int shisa_key_remove (Shisa * dbh, const Shisa_principal * ph,
-                            const Shisa_key *key);
+                            const Shisa_key * key);
 
 /* Utility API. */
+extern int shisa_principal_find_enabled (Shisa * dbh,
+                                        const char *client,
+                                        const char *realm,
+                                        time_t t,
+                                        Shisa_principal ** ph);
 extern int shisa_addpasswd (Shisa * dbh, Shisa_principal * ph,
                            const char *passwd);
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]