From: Drew Adams <drew.adams@oracle.com>
To: Eli Zaretskii <eliz@gnu.org>, Drew Adams <drew.adams@oracle.com>
Cc: 21346@debbugs.gnu.org
Subject: bug#21346: 25.0.50; REGRESSION: `directory-files' raises error for DIR that is `file-accessible-directory-p'
Date: Tue, 25 Aug 2015 11:34:54 -0700 (PDT) [thread overview]
Message-ID: <bb9288b5-fa49-41eb-a016-3798404985aa@default> (raw)
In-Reply-To: <<83fv37fdcg.fsf@gnu.org>>
> > In Emacs 24.5 and later I get this error:
> > Debugger entered--Lisp error: (file-error "Opening directory"
> > "Permission denied"
> > "D:/$RECYCLE.BIN/S-1-5-21-3120201979-235963886-2582836866-1001")
>
> This is the correct behavior in this case: you cannot access that
> directory (it is private to another user).
Then why does (file-accessible-directory-p
"D:/$RECYCLE.BIN/S-1-5-21-3120201979-235963886-2582836866-1001")
return t? The doc for that function says that it returns t if
I can open the directory.
> > Evaluating `file-attributes' for the same file returns this:
> >
> > (t 1 37786 513
> > (20885 54199 0 0)
> > (20885 54199 0 0)
> > (20885 54199 0 0)
> > 0 "drwxrwxrwx" t 0 506428215)
>
> What does the following return?
>
> (file-extended-attributes "D:/$RECYCLE.BIN/S-1-5-21-3120201979-
> 235963886-2582836866-1001")
((acl . "O:S-1-5-21-3138815620-4253048750-3916773603-37786G:S-1-5-21-3120201979-235963886-2582836866-513D:P(A;OICI;FA;;;BA)(A;OICI;FA;;;SY)(A;OICI;FA;;;S-1-5-21-3120201979-235963886-2582836866-1001)")
(selinux-context nil nil nil nil))
What does that tell you? Does it say who the mysterious other user
is, to whom the directory is private?
> Anyway, Windows has an elaborate file access permissions mechanism
> that is not reflected in the Posix-style APIs used by
> file-accessible-directory-p and file-attributes. So you have this
> inconsistency. That is unfortunate, but since Windows doesn't have
> any reliable API that would allow us to perform the accessibility
> test, we cannot really improve that situation.
I see. What would you suggest, in that case, for filtering out
such directories, so the error is not raised?
I can wrap the call in `ignore-errors' or equivalent, I suppose.
But at that point it might be too late (depending on the context).
And given this "inconsistency", don't you think this gotcha should be
mentioned in the doc - of `file-accessible-directory-p', for example?
That predicate would seem to be unusable as a general test for access
to a directory. IOW, what it claims it does is hardly what it does,
apparently.
And perhaps we need another predicate that actually does what this
one says it does, by trying to access the directory? Somewhat akin
to `file-remote-p' versus `ffap-file-remote-p'.
> IOW, on Windows you can never be sure you can access a file or
> directory until you actually try. Fortunately, there are only a few
> directories on a typical Windows system where you really cannot
> access files. So this problem is rarely seen in practice.
Can you characterize those "few directories"? Perhaps they can be
described in the doc. Or perhaps `file-accessible-directory-p' can
be taught to return nil for them.
---
BTW, the doc string of `file-accessible-p' says nothing about what
it returns if file FILENAME does NOT name a directory you can open.
It should, I think, say what it does (returns nil, raises an error,
writes to the the Secretary General of the UN, whatever).
Similarly, the manual does not say explicitly that it returns nil
if the dir is not accessible, but one can surmise that from the
fact that it shows an example where it returns nil and the text
says that this implies that attempting to access the directory
raises an error. Still, like the doc string, it could be clearer.
next parent reply other threads:[~2015-08-25 18:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <<2974d023-5059-414f-960d-273fbeaca5de@default>
[not found] ` <<83fv37fdcg.fsf@gnu.org>
2015-08-25 18:34 ` Drew Adams [this message]
2015-08-25 19:09 ` bug#21346: 25.0.50; REGRESSION: `directory-files' raises error for DIR that is `file-accessible-directory-p' Eli Zaretskii
[not found] ` <<bb9288b5-fa49-41eb-a016-3798404985aa@default>
[not found] ` <<83egirfane.fsf@gnu.org>
2015-08-25 20:55 ` Drew Adams
2015-08-26 15:46 ` Eli Zaretskii
2015-08-31 15:01 ` Eli Zaretskii
[not found] ` <<b9a02743-e606-432e-bed0-8de4121098b9@default>
[not found] ` <<83lhcy59xp.fsf@gnu.org>
2015-08-26 16:27 ` Drew Adams
[not found] ` <<838u8r1oz3.fsf@gnu.org>
2015-08-31 15:05 ` Drew Adams
2015-08-25 17:48 Drew Adams
2015-08-25 18:10 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bb9288b5-fa49-41eb-a016-3798404985aa@default \
--to=drew.adams@oracle.com \
--cc=21346@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.