Opened 21 years ago

Closed 21 years ago

Last modified 20 years ago

#703 closed defect (fixed)

<remove> can't remove a dangling symlink

Reported by: gerard@… Owned by: alfs-log@…
Priority: lowest Milestone:
Component: nALFS - Back End (XML Handlers) Version: SVN
Severity: normal Keywords:
Cc:

Description

The remove handler uses the 'stat' call to remove files and check if the file exists in the first place.

The stat call tries to resolve a symlink. lstat call is identical to stat except it looks at the link itself. From stat(2) man page:

<quote> stat stats the file pointed to by file_name and fills in buf.

lstat is identical to stat, except in the case of a symbolic link, where the link itself is stat-ed, not the file that it refers to. </quote>

The patch as it would apply to 1.1.7 (not checked if it applies to CVS):

diff -Naur nALFS-1.1.7.orig/src/handlers/new-remove.c nALFS-1.1.7/src/handlers/new-remove.c --- nALFS-1.1.7.orig/src/handlers/new-remove.c 2003-02-28 08:28:51.000000000 -0700 +++ nALFS-1.1.7/src/handlers/new-remove.c 2003-05-24 11:45:11.000000000 -0600 @@ -37,7 +37,7 @@

{

struct stat file_stat;

  • if (stat(file, &file_stat)) {

+ if (lstat(file, &file_stat)) {

if (errno == ENOENT) {

Nprint_h_warn("File %s doesn't exist.", file); return 0;

370,5-25 Bot

Change History (2)

comment:1 by neven@…, 21 years ago

Resolution: fixed
Status: newclosed

Check for file existence is removed from the handler.

However, I did replace stat() with lstat() in the code that prints a warning, for syntax version 2.0.

comment:2 by jwrober@…, 20 years ago

Version: CVSSVN
Note: See TracTickets for help on using tickets.