Subject: Root user cannot create /.addressbook

From: Richard Gering <[email-masked]>
Date: Fri, 26 Sep 1997 17:28:30 +0100 (WET)

Hi all!

I just noticed that in Pine 3.96 for UNIX systems, the user root (still) 
cannot create a private .addressbook as long as the home directory is "/".

Unless I'm overlooking something, fixing the problem just takes changing a
single line:

*** pine3.96/pine/adrbklib.c.org	Mon Feb 24 22:57:13 1997
--- pine3.96/pine/adrbklib.c	Fri Sep 26 17:52:31 1997
***************
*** 257,263 ****
      if(p = last_cmpnt(ab->filename)){
  	strncpy(path, ab->filename, p - ab->filename - 1);
          path[p - ab->filename - 1] = '\0';
! 	p = path;
      }
      else
        p = ".";
--- 257,263 ----
      if(p = last_cmpnt(ab->filename)){
  	strncpy(path, ab->filename, p - ab->filename - 1);
          path[p - ab->filename - 1] = '\0';
! 	p = (*path) ? path : "/";
      }
      else
        p = ".";

The change at least makes my UnixWare system quite happy :-)

Pine Team: could you please confirm that this change is sane?  If so, I'd
like inform a certain vendor that this fix be included on the version they
plan to distribute.

Thanks in advance! 

Kind regards,

- Richard Gering.

-- 
+-----------------------------------------------------------------------------+
| Richard Gering ([email-masked]) |         UNIX: when you're ready         |
| Computer Industries International |         for an operating system         |
+-----------------------------------------------------------------------------+

---

From: Steve Hubert <[email-masked]>
Date: Fri, 26 Sep 1997 12:05:19 -0700 (PDT)

This is how we've fixed that for pine 4.00. This gets rid of the
assumption that the directory delimiter is a "/". Thanks.

-- 
Steve Hubert <[email-masked]>
Networks and Distributed Computing, Univ. of Washington, Seattle

*** adrbklib.c.old	Fri Sep 26 12:02:32 1997
--- adrbklib.c.new	Fri Sep 26 11:58:57 1997
***************
*** 255,269 ****
      }
  
      if(p = last_cmpnt(ab->filename)){
! 	strncpy(path, ab->filename, p - ab->filename - 1);
!         path[p - ab->filename - 1] = '\0';
! 	p = path;
      }
      else
!       p = ".";
  
!     ab->temp_filename = temp_nam(p, "a1");
!     ab->temp_hashfile = temp_nam(p, "a2");
      if(!ab->temp_filename || !ab->temp_hashfile){
  	if(warning)
  	  (void)strcpy(warning, "Can't create temporary file");
--- 255,271 ----
      }
  
      if(p = last_cmpnt(ab->filename)){
! 	int to_copy;
! 
! 	to_copy = (p - ab->filename > 1) ? (p - ab->filename - 1) : 1;
! 	strncpy(path, ab->filename, to_copy);
! 	path[to_copy] = '\0';
      }
      else
!       strcpy(path, ".");
  
!     ab->temp_filename = temp_nam(path, "a1");
!     ab->temp_hashfile = temp_nam(path, "a2");
      if(!ab->temp_filename || !ab->temp_hashfile){
  	if(warning)
  	  (void)strcpy(warning, "Can't create temporary file");
***************
*** 277,286 ****
       * rename from temp_hashfile to hashfile isn't going to work.  So
       * set it to NULL in that case to let us know there is a problem.
       */
!     if(!in_dir(p, ab->temp_hashfile))
        fs_give((void **)&ab->temp_hashfile);  /* sets it to NULL */
  
!     if(!in_dir(p, ab->temp_filename))
        fs_give((void **)&ab->temp_filename);
  
      /* open addrbook for reading */
--- 279,288 ----
       * rename from temp_hashfile to hashfile isn't going to work.  So
       * set it to NULL in that case to let us know there is a problem.
       */
!     if(!in_dir(path, ab->temp_hashfile))
        fs_give((void **)&ab->temp_hashfile);  /* sets it to NULL */
  
!     if(!in_dir(path, ab->temp_filename))
        fs_give((void **)&ab->temp_filename);
  
      /* open addrbook for reading */