gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r7724 - in GNUnet/src: include setup util/disk


From: gnunet
Subject: [GNUnet-SVN] r7724 - in GNUnet/src: include setup util/disk
Date: Sun, 28 Sep 2008 21:03:37 -0600 (MDT)

Author: grothoff
Date: 2008-09-28 21:03:37 -0600 (Sun, 28 Sep 2008)
New Revision: 7724

Modified:
   GNUnet/src/include/gnunet_util_disk.h
   GNUnet/src/setup/gnunet-setup.c
   GNUnet/src/util/disk/storage.c
Log:
return NO if dir is not writeable

Modified: GNUnet/src/include/gnunet_util_disk.h
===================================================================
--- GNUnet/src/include/gnunet_util_disk.h       2008-09-28 21:04:53 UTC (rev 
7723)
+++ GNUnet/src/include/gnunet_util_disk.h       2008-09-29 03:03:37 UTC (rev 
7724)
@@ -139,7 +139,8 @@
  * a file.
  *
  * @param filename name of a file in the directory
- * @returns GNUNET_OK on success, GNUNET_SYSERR on failure
+ * @returns GNUNET_OK on success, GNUNET_SYSERR on failure,
+ *          GNUNET_NO if directory exists but is not writeable
  */
 int GNUNET_disk_directory_create_for_file (struct GNUNET_GE_Context *ectx,
                                            const char *filename);

Modified: GNUnet/src/setup/gnunet-setup.c
===================================================================
--- GNUnet/src/setup/gnunet-setup.c     2008-09-28 21:04:53 UTC (rev 7723)
+++ GNUnet/src/setup/gnunet-setup.c     2008-09-29 03:03:37 UTC (rev 7724)
@@ -221,6 +221,7 @@
   char *value;
   char *option;
   int i;
+  struct stat buf;
 
   ectx = GNUNET_GE_create_context_stderr (GNUNET_NO,
                                           GNUNET_GE_WARNING | GNUNET_GE_ERROR
@@ -300,6 +301,16 @@
                                  GNUNET_GE_FATAL | GNUNET_GE_USER |
                                  GNUNET_GE_ADMIN | GNUNET_GE_IMMEDIATE,
                                  "access", dirname);
+  if ( (0 == STAT(cfgFilename, &buf)) &&
+       (S_ISDIR(buf.st_mode)) )
+    {
+      fprintf (stderr, _("Configuration file `%s' must be a filename (but is a 
directory).\n"),
+              cfgFilename);
+      GNUNET_GC_free (cfg);
+      GNUNET_GE_free_context (ectx);
+      GNUNET_free (dirname);
+      return 1;
+    }
   GNUNET_free (dirname);
 
   if (0 == ACCESS (cfgFilename, F_OK))

Modified: GNUnet/src/util/disk/storage.c
===================================================================
--- GNUnet/src/util/disk/storage.c      2008-09-28 21:04:53 UTC (rev 7723)
+++ GNUnet/src/util/disk/storage.c      2008-09-29 03:03:37 UTC (rev 7724)
@@ -359,7 +359,10 @@
  * a file.
  *
  * @param filename name of a file in the directory
- * @returns GNUNET_OK on success, GNUNET_SYSERR on failure
+ * @returns GNUNET_OK on success, 
+ *          GNUNET_SYSERR on failure,
+ *          GNUNET_NO if the directory
+ *          exists but is not writeable for us
  */
 int
 GNUNET_disk_directory_create_for_file (struct GNUNET_GE_Context *ectx,
@@ -377,6 +380,9 @@
     len--;
   rdir[len] = '\0';
   ret = GNUNET_disk_directory_create (ectx, rdir);
+  if ( (ret == GNUNET_OK) &&
+       (0 != ACCESS (rdir, W_OK) ) )
+    ret = GNUNET_NO;
   GNUNET_free (rdir);
   return ret;
 }





reply via email to

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