freeipmi-devel
[Top][All Lists]
Advanced

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

[Freeipmi-devel] Re: freeipmi-0_3_0-sdr-cache-fix.diff


From: Anand Babu
Subject: [Freeipmi-devel] Re: freeipmi-0_3_0-sdr-cache-fix.diff
Date: Fri, 8 Dec 2006 04:10:42 -0400
User-agent: GNU/Emacs/Mutt

On Wed, Dec 06, 2006 at 10:49:03AM -0800, Al Chu wrote:
> This is a bug. Thanks for helping us find it. In your case your home
> dir of user "vcr" is not writable. So it opts for /tmp/.freeipmi-vcr
> dir which already exist. Bug is, if it already exist, it should be
> re-used. Instead it returns error. Bala is fixing it. We will make a
> quick new release of this branch.

Please try this patch. Sorry for delaying late. I had problems with my
mailbox. This fixes the cache creation problem.


Index: common/src/ipmi-sdr-api.c
===================================================================
RCS file: /sources/freeipmi/freeipmi/common/src/ipmi-sdr-api.c,v
retrieving revision 1.4.2.2
diff -p -u -r1.4.2.2 ipmi-sdr-api.c
--- common/src/ipmi-sdr-api.c   13 Nov 2006 23:35:53 -0000      1.4.2.2
+++ common/src/ipmi-sdr-api.c   8 Dec 2006 08:05:26 -0000
@@ -180,14 +180,18 @@ _get_home_directory ()
       }
     }
 
-  asprintf (&home_dir,
-            "/tmp/.%s-%s",
-           PACKAGE_NAME, 
-           user_passwd->pw_name);
-  if (mkdir (home_dir, FREEIPMI_CONFIG_DIRECTORY_MODE) == 0)
-    return home_dir;
+  if (asprintf (&home_dir, "/tmp/.%s-%s", PACKAGE_NAME, user_passwd->pw_name) 
!= -1)
+    {
+      if (access (home_dir, R_OK|W_OK|X_OK) == 0)
+       return home_dir;
+      if (errno == ENOENT)
+       {
+         if (mkdir (home_dir, FREEIPMI_CONFIG_DIRECTORY_MODE) == 0)
+           return home_dir;
+       }
+      free (home_dir);
+    }
   
-  free (home_dir);
   return NULL;
 }
 
@@ -332,6 +336,8 @@ get_sdr_cache_filename (char *host, char
       else
        {
          cache_dir = _get_sdr_cache_directory ();
+         if (cache_dir == NULL)
+           return NULL;
          sdr_cache_dir = cache_dir;
        }
       
Index: ipmi-sensors/src/ipmi-sensors.c
===================================================================
RCS file: /sources/freeipmi/freeipmi/ipmi-sensors/src/ipmi-sensors.c,v
retrieving revision 1.6
diff -p -u -r1.6 ipmi-sensors.c
--- ipmi-sensors/src/ipmi-sensors.c     2 Nov 2006 17:35:55 -0000       1.6
+++ ipmi-sensors/src/ipmi-sensors.c     8 Dec 2006 08:05:26 -0000
@@ -158,7 +158,11 @@ init_sdr_cache (ipmi_device_t dev, struc
   
   if ((sdr_cache_filename = get_sdr_cache_filename (args->common.host, 
                                                    args->sdr_cache_dir)) == 
NULL)
-    return (-1);
+    {
+      perror ("error: get_sdr_cache_filename (): ");
+      return (-1);
+    }
+
   if ((fp = fopen (sdr_cache_filename, "r")))
     {
       rv = load_sdr_cache (fp, &sdr_info, &sdr_record_list, &sdr_record_count);

-- 
Anand Babu 
GPG Key ID: 0x62E15A31
Blog [http://ab.freeshell.org]              
The GNU Operating System [http://www.gnu.org]  





reply via email to

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