* Al Chu <[EMAIL PROTECTED]> [07.12.2006 00:50]:

> > 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.
> 
> If Dmitry is close/semi-close to finishg up the port patch, perhaps we
> can release it and this fix together?
> 
> Dmitry?

Preliminary patch, that includes fixes for these problems is here:

ftp://ftp.riss-telecom.ru/pub/patches/freeipmi-0.3.0-fbsd3.diff

But I want Tejram to test this patch before it may be committed.  I sent
him the new test port for this.

The _get_home_directory() part for Your review:

--- ../freeipmi-0.3.0/common/src/ipmi-sdr-api.c Mon Nov  6 23:24:34 2006
+++ ./common/src/ipmi-sdr-api.c Thu Dec  7 00:49:00 2006
@@ -165,12 +165,25 @@ _get_home_directory ()
   uid_t user_id;
   struct passwd *user_passwd = alloca (sizeof (*user_passwd));
   char *home_dir = NULL;
-  long int buf_len = sysconf (_SC_GETPW_R_SIZE_MAX);
-  char *buf = alloca (buf_len);
+  long int buf_len;
+  char *buf;
+
+#if defined(_SC_GETPW_R_SIZE_MAX)
+  buf_len = sysconf(_SC_GETPW_R_SIZE_MAX);
+  if (buf_len < 0)
+    /* Variable was not implemented */
+#endif
+    buf_len = 1024;    /* XXX */
+  buf = alloca (buf_len);
 
   user_id = getuid ();
   if (getpwuid_r (user_id, user_passwd, buf, buf_len, &user_passwd) != 0)
     return NULL;
+  if (user_passwd == NULL) {
+    /* User not found */
+    errno = ENOENT;
+    return NULL;
+  }
 
   if (user_passwd->pw_dir)
     {
@@ -184,7 +197,8 @@ _get_home_directory ()
             "/tmp/.%s-%s",
            PACKAGE_NAME, 
            user_passwd->pw_name);
-  if (mkdir (home_dir, FREEIPMI_CONFIG_DIRECTORY_MODE) == 0)
+  if (mkdir (home_dir, FREEIPMI_CONFIG_DIRECTORY_MODE) == 0 ||
+      errno == EEXIST)
     return home_dir;
   
   free (home_dir);

> 
> Al
> 
> -- 
> Albert Chu
> [EMAIL PROTECTED]
> 925-422-5311
> Computer Scientist
> High Performance Systems Division
> Lawrence Livermore National Laboratory

    wbr&w, dmitry.
-- 
Dmitry Frolov <[EMAIL PROTECTED]>
RISS-Telecom Network, Novosibirsk, Russia
[EMAIL PROTECTED], +7 383 2278800, DVF-RIPE


_______________________________________________
Freeipmi-devel mailing list
Freeipmi-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/freeipmi-devel

Reply via email to