lynx-dev
[Top][All Lists]
Advanced

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

Re: lynx-dev Side effects of deleting a bookmark


From: pg
Subject: Re: lynx-dev Side effects of deleting a bookmark
Date: Sun, 26 Apr 1998 20:21:58 -0600 (MDT)

In a recent note, T.E.Dickey said:

> Date: Sun, 26 Apr 1998 21:02:22 -0400 (EDT)
> 
> The drawback, of course, is that it's hard to accommodate links, or files
> that can be written from more than one userid.
> 
Looking closer, I discover that there is code to preserve the
permissions, which works.  However, the UID and GID are
still at hazard of change, and symlinks do get converted to
regular files.

Attached is a patch which simply copies the bookmarks file and
deletes the workfile.  This preserves the UID, GID, and symlinks,
and avoids the chatter on OS/390.  This may make more sense
than repairing each of the attributes individually before or
after a mv.

A side effect is that if the bookmarks file is unwritable, the
attempt to update will fail; prior to the patch, mv prompted
to override the mode.

I made no attempt to deal with VMS or DOS; it's all #IFDEF UNIX.

-- gil

===================================================
diff -brc ./orig/lynxsrc/LYMessages_en.h ./lynxsrc/LYMessages_en.h
*** ./orig/lynxsrc/LYMessages_en.h      Sat Apr 18 16:29:08 1998
--- ./lynxsrc/LYMessages_en.h   Sun Apr 26 18:54:52 1998
***************
*** 222,229 ****
  #define BOOKTEMP_OPEN_FAILED_FOR_DEL \
   "Unable to open temporary file for deletion of link."
  #define ERROR_RENAMING_TEMP "Error renaming temporary file."
! #define BOOKTEMP_REOPEN_FAIL_FOR_DEL \
!  "Unable to reopen temporary file for deletion of link."
  #endif /* VMS */
  #define BOOKMARK_LINK_NOT_ONE_LINE \
   "Link is not by itself all on one line in bookmark file."
--- 222,229 ----
  #define BOOKTEMP_OPEN_FAILED_FOR_DEL \
   "Unable to open temporary file for deletion of link."
  #define ERROR_RENAMING_TEMP "Error renaming temporary file."
! #define BOOKTEMP_COPY_FAIL \
!  "Unable to copy temporary file for deletion of link."
  #endif /* VMS */
  #define BOOKMARK_LINK_NOT_ONE_LINE \
   "Link is not by itself all on one line in bookmark file."
diff -brc ./orig/lynxsrc/src/LYBookmark.c ./lynxsrc/src/LYBookmark.c
*** ./orig/lynxsrc/src/LYBookmark.c     Thu Apr 23 06:35:22 1998
--- ./lynxsrc/src/LYBookmark.c  Sun Apr 26 18:57:41 1998
***************
*** 479,502 ****
        return;
      }
  
- #ifdef UNIX
-     /*
-      *        Explicitly preserve bookmark file mode on Unix. - DSL
-      */
-     if (stat(filename_buffer, &stat_buf) == 0) {
-       mode = ((stat_buf.st_mode & 0777) | HIDE_CHMOD);
-       (void) fclose(nfp);
-       nfp = NULL;
-       (void) chmod(newfile, mode);
-       if ((nfp = fopen(newfile, "a")) == NULL) {
-           (void) fclose(fp);
-           _statusline(BOOKTEMP_REOPEN_FAIL_FOR_DEL);
-           sleep(AlertSecs);
-           return;
-       }
-     }
- #endif /* UNIX */
- 
      if (is_mosaic_hotlist) {
        int del_line = cur*2;  /* two lines per entry */
        n = -3;  /* skip past cookie and name lines */
--- 479,484 ----
***************
*** 547,552 ****
--- 529,555 ----
  #ifdef DOSPATH
      remove(filename_buffer);
  #endif /* DOSPATH */
+ 
+ #ifdef UNIX
+     /*
+      *        Explicitly preserve bookmark file mode on Unix. - DSL
+      *        Changed to copy  1998-04-26 -- gil
+      */
+     {   char buffer[3072];
+ 
+       sprintf(buffer, "%s %s %s && %s %s",
+           COPY_PATH, newfile, filename_buffer,
+           RM_PATH, newfile);
+ 
+       CTRACE(tfp, "remove_bookmark_link: %s\n", buffer);
+       if( system( buffer ) ) {
+           _statusline(BOOKTEMP_COPY_FAIL);
+           sleep(AlertSecs);
+       } else {
+           return;
+       }
+     }
+ #else  /* UNIX */
      if (rename(newfile, filename_buffer) != -1) {
  #ifdef VMS
        char VMSfilename[256];
***************
*** 591,596 ****
--- 594,600 ----
            perror("renaming the file");
        sleep(AlertSecs);
      }
+ #endif /* UNIX */
  
  failure:
      _statusline(BOOKMARK_DEL_FAILED);

reply via email to

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