[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24823 - in gnunet/src: chat fs include mesh regex util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24823 - in gnunet/src: chat fs include mesh regex util |
Date: |
Wed, 7 Nov 2012 17:56:55 +0100 |
Author: harsha
Date: 2012-11-07 17:56:55 +0100 (Wed, 07 Nov 2012)
New Revision: 24823
Modified:
gnunet/src/chat/chat.c
gnunet/src/fs/fs_api.c
gnunet/src/fs/gnunet-auto-share.c
gnunet/src/include/gnunet_disk_lib.h
gnunet/src/mesh/gnunet-regex-profiler.c
gnunet/src/regex/gnunet-regex-simulation-profiler.c
gnunet/src/util/disk.c
gnunet/src/util/test_disk.c
Log:
Parameterized directory listing permission check
Modified: gnunet/src/chat/chat.c
===================================================================
--- gnunet/src/chat/chat.c 2012-11-07 14:39:40 UTC (rev 24822)
+++ gnunet/src/chat/chat.c 2012-11-07 16:56:55 UTC (rev 24823)
@@ -473,7 +473,7 @@
return NULL;
}
GNUNET_DISK_directory_create (home);
- if (GNUNET_OK != GNUNET_DISK_directory_test (home))
+ if (GNUNET_OK != GNUNET_DISK_directory_test (home, GNUNET_YES))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Failed to access chat home directory `%s'\n"), home);
Modified: gnunet/src/fs/fs_api.c
===================================================================
--- gnunet/src/fs/fs_api.c 2012-11-07 14:39:40 UTC (rev 24822)
+++ gnunet/src/fs/fs_api.c 2012-11-07 16:56:55 UTC (rev 24823)
@@ -738,7 +738,7 @@
dn = get_serialization_file_name_in_dir (h, ext, uni, "");
if (NULL == dn)
return;
- if ((GNUNET_OK == GNUNET_DISK_directory_test (dn)) &&
+ if ((GNUNET_YES == GNUNET_DISK_directory_test (dn, GNUNET_YES)) &&
(GNUNET_OK != GNUNET_DISK_directory_remove (dn)))
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rmdir", dn);
GNUNET_free (dn);
@@ -2700,7 +2700,7 @@
dn = get_download_sync_filename (dc, dc->serialization, ".dir");
if (NULL != dn)
{
- if (GNUNET_YES == GNUNET_DISK_directory_test (dn))
+ if (GNUNET_YES == GNUNET_DISK_directory_test (dn, GNUNET_YES))
GNUNET_DISK_directory_scan (dn, &deserialize_subdownload, dc);
GNUNET_free (dn);
}
@@ -2813,7 +2813,7 @@
sc->serialization, "");
if (NULL != dn)
{
- if (GNUNET_YES == GNUNET_DISK_directory_test (dn))
+ if (GNUNET_YES == GNUNET_DISK_directory_test (dn, GNUNET_YES))
GNUNET_DISK_directory_scan (dn, &deserialize_search_result, sc);
GNUNET_free (dn);
}
@@ -2940,7 +2940,7 @@
dn = get_serialization_file_name (h, master_path, "");
if (NULL == dn)
return;
- if (GNUNET_YES == GNUNET_DISK_directory_test (dn))
+ if (GNUNET_YES == GNUNET_DISK_directory_test (dn, GNUNET_YES))
GNUNET_DISK_directory_scan (dn, proc, h);
GNUNET_free (dn);
}
Modified: gnunet/src/fs/gnunet-auto-share.c
===================================================================
--- gnunet/src/fs/gnunet-auto-share.c 2012-11-07 14:39:40 UTC (rev 24822)
+++ gnunet/src/fs/gnunet-auto-share.c 2012-11-07 16:56:55 UTC (rev 24823)
@@ -681,7 +681,7 @@
{
/* check arguments */
if ((args[0] == NULL) || (args[1] != NULL) ||
- (GNUNET_YES != GNUNET_DISK_directory_test (args[0])))
+ (GNUNET_YES != GNUNET_DISK_directory_test (args[0], GNUNET_YES)))
{
printf (_("You must specify one and only one directory name for automatic
publication.\n"));
ret = -1;
Modified: gnunet/src/include/gnunet_disk_lib.h
===================================================================
--- gnunet/src/include/gnunet_disk_lib.h 2012-11-07 14:39:40 UTC (rev
24822)
+++ gnunet/src/include/gnunet_disk_lib.h 2012-11-07 16:56:55 UTC (rev
24823)
@@ -663,17 +663,18 @@
/**
- * Test if "fil" is a directory that can be accessed.
- * Will not print an error message if the directory
- * does not exist. Will log errors if GNUNET_SYSERR is
- * returned.
+ * Test if "fil" is a directory and readable. Also check if the directory is
+ * listable. Will not print an error message if the directory does not exist.
+ * Will log errors if GNUNET_SYSERR is returned (i.e., a file exists with the
+ * same name).
*
* @param fil filename to test
- * @return GNUNET_YES if yes, GNUNET_NO if does not exist, GNUNET_SYSERR
- * on any error and if exists but not directory
+ * @param is_listable GNUNET_YES to additionally check if "fil" is listable
+ * @return GNUNET_YES if yes, GNUNET_NO if not, GNUNET_SYSERR if it
+ * does not exist
*/
int
-GNUNET_DISK_directory_test (const char *fil);
+GNUNET_DISK_directory_test (const char *fil, int is_listable);
/**
Modified: gnunet/src/mesh/gnunet-regex-profiler.c
===================================================================
--- gnunet/src/mesh/gnunet-regex-profiler.c 2012-11-07 14:39:40 UTC (rev
24822)
+++ gnunet/src/mesh/gnunet-regex-profiler.c 2012-11-07 16:56:55 UTC (rev
24823)
@@ -1711,7 +1711,7 @@
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR,
"open",
data_filename);
- if (GNUNET_YES != GNUNET_DISK_directory_test (args[1]))
+ if (GNUNET_YES != GNUNET_DISK_directory_test (args[1], GNUNET_YES))
{
fprintf (stderr, _("Specified policies directory does not exist.
Exiting.\n"));
shutdown_task = GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
Modified: gnunet/src/regex/gnunet-regex-simulation-profiler.c
===================================================================
--- gnunet/src/regex/gnunet-regex-simulation-profiler.c 2012-11-07 14:39:40 UTC
(rev 24822)
+++ gnunet/src/regex/gnunet-regex-simulation-profiler.c 2012-11-07 16:56:55 UTC
(rev 24823)
@@ -499,7 +499,7 @@
result = GNUNET_SYSERR;
return;
}
- if (GNUNET_YES != GNUNET_DISK_directory_test (args[0]))
+ if (GNUNET_YES != GNUNET_DISK_directory_test (args[0], GNUNET_YES))
{
fprintf (stderr, _("Specified policies directory does not exist.
Exiting.\n"));
result = GNUNET_SYSERR;
Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c 2012-11-07 14:39:40 UTC (rev 24822)
+++ gnunet/src/util/disk.c 2012-11-07 16:56:55 UTC (rev 24823)
@@ -584,17 +584,19 @@
/**
- * Test if "fil" is a directory.
- * Will not print an error message if the directory
- * does not exist. Will log errors if GNUNET_SYSERR is
- * returned (i.e., a file exists with the same name).
+ * Test if "fil" is a directory and readable. Also check if the directory is
+ * listable. Will not print an error message if the directory does not exist.
+ * Will log errors if GNUNET_SYSERR is returned (i.e., a file exists with the
+ * same name).
*
* @param fil filename to test
- * @return GNUNET_YES if yes, GNUNET_NO if not, GNUNET_SYSERR if it
- * does not exist
+ * @param is_listable GNUNET_YES to additionally check if "fil" is listable;
+ * GNUNET_NO to disable this check
+ * @return GNUNET_YES if yes, GNUNET_NO if not; GNUNET_SYSERR if it
+ * does not exist
*/
int
-GNUNET_DISK_directory_test (const char *fil)
+GNUNET_DISK_directory_test (const char *fil, int is_listable)
{
struct stat filestat;
int ret;
@@ -611,7 +613,11 @@
}
if (!S_ISDIR (filestat.st_mode))
return GNUNET_NO;
- if (ACCESS (fil, R_OK | X_OK) < 0)
+ if (GNUNET_YES == is_listable)
+ ret = ACCESS (fil, R_OK | X_OK);
+ else
+ ret = ACCESS (fil, R_OK);
+ if (ret < 0)
{
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "access", fil);
return GNUNET_SYSERR;
@@ -716,7 +722,7 @@
if (DIR_SEPARATOR == rdir[pos2])
{
rdir[pos2] = '\0';
- ret = GNUNET_DISK_directory_test (rdir);
+ ret = GNUNET_DISK_directory_test (rdir, GNUNET_YES);
if (GNUNET_SYSERR == ret)
{
GNUNET_free (rdir);
@@ -740,7 +746,7 @@
if ((rdir[pos] == DIR_SEPARATOR) || (pos == len))
{
rdir[pos] = '\0';
- ret = GNUNET_DISK_directory_test (rdir);
+ ret = GNUNET_DISK_directory_test (rdir, GNUNET_YES);
if (ret == GNUNET_SYSERR)
{
GNUNET_free (rdir);
@@ -1393,7 +1399,7 @@
/* EISDIR is not sufficient in all cases, e.g.
* sticky /tmp directory may result in EPERM on BSD.
* So we also explicitly check "isDirectory" */
- (GNUNET_YES != GNUNET_DISK_directory_test (filename)))
+ (GNUNET_YES != GNUNET_DISK_directory_test (filename, GNUNET_YES)))
{
LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "rmdir", filename);
return GNUNET_SYSERR;
Modified: gnunet/src/util/test_disk.c
===================================================================
--- gnunet/src/util/test_disk.c 2012-11-07 14:39:40 UTC (rev 24822)
+++ gnunet/src/util/test_disk.c 2012-11-07 16:56:55 UTC (rev 24823)
@@ -250,7 +250,7 @@
return 1;
if (GNUNET_OK != GNUNET_DISK_directory_create ("test"))
return 1;
- if (GNUNET_YES != GNUNET_DISK_directory_test ("test"))
+ if (GNUNET_YES != GNUNET_DISK_directory_test ("test", GNUNET_YES))
return 1;
if (GNUNET_OK != GNUNET_DISK_directory_remove ("test"))
return 1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24823 - in gnunet/src: chat fs include mesh regex util,
gnunet <=