Reputation: 1078
I've to find a directory named 'A' and then launch an executable named 'B' that's in it that takes a path as argument and have a line with an execl() :
execl("./C","C",path,(char*)0);
perror("Exec failed");
where C is in 'A' and has suid bit set.
. I've thought of something like:
find -name A -execdir {}/B path \
However what I get is:
Exec failed: Permission denied
What's wrong ? Launching B from A give me no errors.
Sorry if it is a stupid question, I'm really new to bash script. Any help is appreciated, thanks a lot.
Upvotes: 2
Views: 90
Reputation: 107759
When you run B through that find
command, the current directory is the directory containing A (i.e. the parent directory of A), not A.
You'll get the right directory if you run find -path '*/A/B' -execdir {} \;
.
This may or may not be the right way to solve your real-world problem. In this example, B
serves no purpose, so it's hard to guess what the real-world problem is. Did you consider sudo
?
Upvotes: 5