Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

cd sometimes gives wrong error message when directory doesn't exist #33

Closed
iammer opened this issue Aug 15, 2018 · 3 comments
Closed

cd sometimes gives wrong error message when directory doesn't exist #33

iammer opened this issue Aug 15, 2018 · 3 comments

Comments

@iammer
Copy link

iammer commented Aug 15, 2018

Sometimes error message given is "Permission denied" instead of "No such file or directory" when attempting to cd to non-existent directory using full path.

With proot:

$ pwd
/home
$ cd no-exist
bash: cd: no-exist: No such file or directory
$ cd /home/no-exist
bash: cd: /home/no-exist: No such file or directory
$ cd ~/no-exist
bash: cd: /data/data/com.termux/files/home/no-exist: Permission denied
$ cd /data/data/com.termux/files/home/no-exist
bash: cd: /data/data/com.termux/files/home/no-exist: Permission denied

Without proot:

$ pwd
/data/data/com.termux/files/home
$ cd no-exist
bash: cd: no-exist: No such file or directory
$ cd ~/no-exist
bash: cd: /data/data/com.termux/files/home/no-exist: No such file or directory
$ cd /data/data/com.termux/files/home/no-exist
bash: cd: /data/data/com.termux/files/home/no-exist: No such file or directory

I am running proot as below:

exec /data/data/com.termux/files/usr/bin/proot -b /system:/system -b /vendor:/vendor -b /data:/data -b /property_contexts:/property_contexts -b /storage:/storage -b /data/data/com.termux/files/usr:/usr -b /data/data/com.termux/files/usr/bin:/bin -b /data/data/com.termux/files/usr/etc:/etc -b /data/data/com.termux/files/usr/lib:/lib -b /data/data/com.termux/files/usr/share:/share -b /data/data/com.termux/files/usr/tmp:/tmp -b /data/data/com.termux/files/usr/var:/var -b /dev:/dev -b /proc:/proc --cwd=/home -r /data/data/com.termux/files/usr/.. /bin/bash -l
@jlmess77
Copy link
Contributor

I also have seen a lot of it. It's almost similar to proot-me/proot#138 but it's related with the unlink though.

@michalbednarski
Copy link
Collaborator

I couldn't reproduce your issue (I get ENOENT in both cases). Linked proot-me/proot#138 appears to be possible to fix nicely with

--- a/src/path/canon.c
+++ b/src/path/canon.c
@@ -154,6 +154,11 @@ static inline int substitute_binding_stat(Tracee *tracee, Finality finality, uns                        
        statl.st_mode = 0;
        status = lstat(host_path, &statl);

+       /** Propagate EACCES to caller if it occured.  */
+       if (status < 0 && errno == EACCES) {
+               return -errno;
+       }
+
        /* Build the glue between the hostfs and the guestfs during                                                          
         * the initialization of a binding.  */
        if (status < 0 && tracee->glue_type != 0) {

However it looks like your issue isn't similar to that (in fact I'd say it's opposite of that: they are describing not getting EACCES inside proot and you describe getting EACCES inside proot).

I think i'd need full trace to see what's going on (substitute $ARGS with your invocation arguments

strace -s5000 -o trace.txt proot -v 9 $ARGS

@iammer
Copy link
Author

iammer commented Aug 18, 2018

Ok, since you couldn't reproduce I did some more digging.

The problem is I have shopt -s cdspell in my .bashrc which doesn't get invoked unless I am using proot. If I run shopt -s cdspell, I can reproduce without proot. Because of the permissions on / and /data, I don't think EACCES is unexpected.

I don't think this is a proot issue (or really a bug at all). I am going to close the ticket.

@iammer iammer closed this as completed Aug 18, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants