unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#17330: files.el cd-absolute overcome false negative from file-executable-p
@ 2014-04-23 20:54 Philip Hodges
  2014-05-03  0:24 ` Glenn Morris
                   ` (2 more replies)
  0 siblings, 3 replies; 36+ messages in thread
From: Philip Hodges @ 2014-04-23 20:54 UTC (permalink / raw)
  To: 17330


[using emacs-w32.exe 24.3 in cygwin but also applies to other platforms.]

Symptom:
When I try to cd to my samba-mounted directory,
or try to run ediff-files, it refuses with the error
"Cannot cd to my_directory_name: Permission denied"
The same directory opens fine in dired-mode, and I can open files within it.

A workaround is to make my directory and its parents executable for "others",
but of course it would be much better to keep the correct mode in force.
Maybe a more recent or better configured samba on the server would help.

This is just one way in which file-executable-p can produce a false negative,
where executing the file or searching the directory may succeed after all.

[False positives, where the operation refuses, have no impact so long as
the operation fails quickly with an equivalent but authoritative error message.]

This is typical of many situations where it is not good enough just
to check quickly whether it just looks like it can or cannot be done;
you have to also actually try it, and report the outcome of
that particular attempt at that particular moment.
A preliminary check may still be useful too if it produces a better error
message quickly up front with no dashed expectations or cleaning up to do.

The comments in fileio.c check_executable (and check_writeable) point out
that on some filesystems there might be an access control list (ACL) in force,
and that the effective user might have more permission than the real user.

Suggested fix:
In files.el the function cd-absolute can ask for confirmation in case
check-executable-p might be producing a false negative:

;; in emacs-24.3/lisp/files.el [cd-absolute] replace the expression
    (unless (file-executable-p dir)
      (error "Cannot cd to %s:  Permission denied" dir))
;; with
    (unless (file-executable-p dir)
      (unless (yes-or-no-p
			   (format
				"Directory does not look searchable; try to cd to %s anyway? "
				dir))
		(error "Cannot cd to %s:  Permission denied" dir)))

I encountered the cd failure originally on invoking ediff-files to merge
source code from a samba mount, then noticed cd itself is affected too.
I haven't run into any other false negative cases.
The 24.3 distribution contains about 50 calls to
file-executable-p where a fix like this might potentially be useful,
not to mention custom code and community packages, and other similar functions.

In directory search contexts file-searchable-p might be a better name.






^ permalink raw reply	[flat|nested] 36+ messages in thread
[parent not found: <E6923B15-B9A8-4B3C-ADDF-713810613ADD@bluewin.ch>]

end of thread, other threads:[~2021-10-23  5:09 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-23 20:54 bug#17330: files.el cd-absolute overcome false negative from file-executable-p Philip Hodges
2014-05-03  0:24 ` Glenn Morris
2014-05-03  9:17   ` Philip Hodges
2014-05-03  9:35     ` Achim Gratz
2014-05-03 13:26       ` Eli Zaretskii
2014-05-03 13:58         ` Achim Gratz
2014-05-03 16:37           ` Eli Zaretskii
2014-05-03 13:40     ` Eli Zaretskii
2014-05-04  4:16     ` Glenn Morris
2014-05-04 13:01       ` Stefan Monnier
2014-05-04 16:18         ` Eli Zaretskii
2014-05-04 18:07         ` Glenn Morris
2014-05-04 22:44           ` Stefan Monnier
2014-05-09  6:54             ` Glenn Morris
2014-05-03 22:43 ` bug#17330: thanks for the comments Philip Hodges
2014-05-04 13:24   ` bug#17330: files.el cd-absolute overcome false negative from file-executable-p Philip Hodges
2014-05-04 16:24     ` Eli Zaretskii
2014-05-05 22:43       ` Philip Hodges
2014-05-06  7:17         ` Eli Zaretskii
2014-05-06 12:46         ` Stefan Monnier
2014-05-06 16:56           ` Glenn Morris
2014-05-11 13:55             ` Philip Hodges
2014-05-06  4:15 ` Glenn Morris
     [not found] <E6923B15-B9A8-4B3C-ADDF-713810613ADD@bluewin.ch>
2014-05-07 18:15 ` Eli Zaretskii
2014-05-08  5:55   ` Philip Hodges
2014-05-08  7:09     ` Glenn Morris
2014-05-08 16:18     ` Eli Zaretskii
2014-05-11 10:46       ` Philip Hodges
2014-05-11 17:00         ` Eli Zaretskii
2014-05-11 18:26           ` Philip Hodges
2014-05-11 18:38             ` Glenn Morris
2014-05-11 21:59               ` Philip Hodges
2014-05-12  7:10                 ` Glenn Morris
2014-05-12  7:26                   ` Philip Hodges
2021-10-23  5:09               ` Stefan Kangas
2014-05-11 18:43             ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).