-/* $Id: js_dir.c,v 1.1 2006/09/08 12:50:43 mmondor Exp $ */
+/* $Id: js_dir.c,v 1.2 2006/09/08 14:24:07 mmondor Exp $ */
/*
* Copyright (c) 2006, Matthew Mondor
jsval *);
static JSBool dir_m_close(JSContext *, JSObject *, uintN, jsval *, jsval *);
+static int dir_path_allow(const char *);
+
/*
}
path = JS_GetStringBytes(JSVAL_TO_STRING(argv[0]));
+
+ if (dir_path_allow(path) == -1) {
+ char str[1024];
+
+ (void) snprintf(str, sizeof(str), "opendir('%s'): %s",
+ path, "Denied by security hook dir_path_allow()");
+ QUEUE_EXCEPTION(str);
+ goto err;
+ }
+
if ((dir = opendir(path)) == NULL) {
- char str[256];
+ char str[1024];
(void) snprintf(str, sizeof(str), "opendir('%s'): %s",
- str, strerror(errno));
+ path, strerror(errno));
QUEUE_EXCEPTION(str);
goto err;
}
return JS_TRUE;
}
+
+
+/* Security hook could be added here */
+static int
+dir_path_allow(const char *path)
+{
+
+ return 0;
+}