Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • D dynamorio
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,467
    • Issues 1,467
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 44
    • Merge requests 44
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • DynamoRIO
  • dynamorio
  • Issues
  • #2109
Closed
Open
Issue created Dec 13, 2016 by Administrator@rootContributor

drrun should imitate a shell when searching for the app

Created by: egrimley

On Unix, it should work thus:

If "app" contains '/', then try to use that filepath, which could be absolute or relative. Do not search in any other directories. Do not try adding any suffixes.

Otherwise, if the environment variable PATH is defined and not the empty string, split it into components, using ':', and try prefixing each in turn, with a '/' if the component is non-empty, so an empty component is treated as the current directory. Use stat() to check whether the resulting filepath refers to an executable ordinary file. (There are some complications here involving "owner", "group" and "other". We look at only one of those three. Which we look at depends who we are and who owns the file.) If the filepath is not an ordinary executable file, try the next component. If no executable ordinary file is found this way, give an error. Do not try in the current directory if the current directory was not on the PATH. Do not try adding any suffixes.

Otherwise, give an error. It is not worth trying to do anything clever if PATH is undefined or set to the empty string.

Some possible test cases:

mkdir t
cd t

umask 0002
mkdir a b c

touch    a/x.exe b/x.exe c/x.exe x.exe
chmod +x a/x.exe b/x.exe c/x.exe x.exe

../bin64/drrun -- ./x.exe
# .../t/x.exe ... Failed to read app ELF headers.

../bin64/drrun -- ./x
# Failed to create process for ...

PATH=.:`pwd`: ../bin64/drrun -- x
# drrun: x: command not found

mkdir a/x
touch b/x c/x x
chmod +x x

PATH=a:b:c ../bin64/drrun -- x
# drrun: x: command not found

PATH=:a:b:c ../bin64/drrun -- x
# .../t/x ... Failed to read app ELF headers.

PATH=a::b:c ../bin64/drrun -- x
# .../t/x ... Failed to read app ELF headers.

PATH=a:b:c: ../bin64/drrun -- x
# .../t/x ... Failed to read app ELF headers.

chmod +x c/x

PATH=a:b:c ../bin64/drrun -- x
# .../t/c/x ... Failed to read app ELF headers.

PATH= ../bin64/drrun -- ./x
# .../t/x ... Failed to read app ELF headers.

PATH= ../bin64/drrun -- x
# Error: PATH is not set

chmod a+x b/x
sudo chown root:root b/x

PATH=a:b:c ../bin64/drrun -- x
# .../t/b/x .. Failed to read app ELF headers.

sudo chmod u-x b/x

PATH=a:b:c ../bin64/drrun -- x
# .../t/b/x .. Failed to read app ELF headers.

PATH=a:b:c sudo ../bin64/drrun -- x
# drrun: x: command not found
Assignee
Assign to
Time tracking