commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Apostolos Lerios (JIRA)" <j...@apache.org>
Subject [jira] Commented: (IO-168) Symbolic links (symlinks) followed when deleting directory.
Date Fri, 30 May 2008 11:33:45 GMT

    [ https://issues.apache.org/jira/browse/IO-168?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12601095#action_12601095
] 

Apostolos Lerios commented on IO-168:
-------------------------------------

Yes. Here is how.

    public static final FileType get
        (File file)
    {
        if (file==null) {
            return UNKNOWN;
        }
        try {
            if (!file.exists()) {
                return NONEXISTENT;
            }
            if (file.getCanonicalFile().equals(file.getAbsoluteFile())) {
                if (file.isDirectory()) {
                    return DIR;
                }
                if (file.isFile()) {
                    return FILE;
                }
            } else {
                if (file.isDirectory()) {
                    return LINK_DIR;
                }
                if (file.isFile()) {
                    return LINK_FILE;
                }
            }
        } catch (IOException ex) {
           // CANNOT_GET_TYPE
        }
        return UNKNOWN;
    }


> Symbolic links (symlinks) followed when deleting directory.
> -----------------------------------------------------------
>
>                 Key: IO-168
>                 URL: https://issues.apache.org/jira/browse/IO-168
>             Project: Commons IO
>          Issue Type: Bug
>          Components: Utilities
>    Affects Versions: 1.4
>         Environment: Linux only (symlinks required for bug to manifest)
>            Reporter: Apostolos Lerios
>
> If 'dlink' is a symbolic link to a directory 'dir', and FileUtils.forceDelete is called
on dlink, then here is what happens:
> 1) the contents of 'dir' are emptied (the link is followed).
> 2) 'dir' continues to exist (but is empty).
> 3) 'dlink' is removed.
> The correct behavior is to simply remove 'dlink' without following it and thus without
altering the contents of 'dir' (or 'dir' itself).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message