[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
shishi/db file.c
From: |
shishi-commit |
Subject: |
shishi/db file.c |
Date: |
Sat, 29 Nov 2003 13:29:42 -0500 |
CVSROOT: /cvsroot/shishi
Module name: shishi
Branch:
Changes by: Simon Josefsson <address@hidden> 03/11/29 13:29:42
Modified files:
db : file.c
Log message:
Fix.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/shishi/shishi/db/file.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
Patches:
Index: shishi/db/file.c
diff -u shishi/db/file.c:1.3 shishi/db/file.c:1.4
--- shishi/db/file.c:1.3 Fri Nov 28 21:43:26 2003
+++ shishi/db/file.c Sat Nov 29 13:29:41 2003
@@ -19,6 +19,36 @@
*
*/
+/*
+ * Theory of operation:
+ *
+ * Data is stored in the standard file system, so it is subject to
+ * normal access permission infrastructure, e.g. POSIX ACL or normal
+ * Unix file permissions. A definition of the file database looks
+ * like:
+ *
+ * file LOCATION OPTIONS
+ *
+ * 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.
+ *
+ * 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
+ *
+ */
+
#include "internal.h"
/* For stat. */
@@ -119,6 +149,25 @@
}
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;
+}
+
+static int
shisa_file_ls_1 (Shisa *dbh,
char *path,
char ***files,
@@ -128,14 +177,15 @@
struct dirent *de;
int rc;
- errno = 0;
-
- while ((de = readdir (dir)) != NULL)
+ while (errno = 0, (de = readdir (dir)) != NULL)
{
if (strcmp (de->d_name, ".") == 0 || strcmp (de->d_name, "..") == 0)
continue;
- *files = xrealloc (*files, (*nfiles + 1) * sizeof (**files));
- (*files)[(*nfiles)++] = xstrdup (de->d_name);
+ if (has_info_txt (path, de->d_name))
+ {
+ *files = xrealloc (*files, (*nfiles + 1) * sizeof (**files));
+ (*files)[(*nfiles)++] = xstrdup (de->d_name);
+ }
}
if (errno != 0)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- shishi/db file.c,
shishi-commit <=