Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ocaml should add script's directory to search path, not current directory #6081

Closed
vicuna opened this issue Jul 19, 2013 · 3 comments
Closed

ocaml should add script's directory to search path, not current directory #6081

vicuna opened this issue Jul 19, 2013 · 3 comments
Labels
Milestone

Comments

@vicuna
Copy link

@vicuna vicuna commented Jul 19, 2013

Original bug ID: 6081
Reporter: talex
Status: closed (set by @damiendoligez on 2015-01-16T22:45:14Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 4.00.1
Target version: 4.03.0+dev / +beta1
Fixed in version: 4.03.0+dev / +beta1
Category: ~DO NOT USE (was: OCaml general)
Tags: patch
Parent of: #7347
Monitored by: @gasche @hcarty

Bug description

When running "ocaml /path/to/script.ml", OCaml searches the current directory first for libraries. This is probably not useful, and can be a security risk. It would make more sense to add the script's directory to the search path instead, as e.g. Python does.

Steps to reproduce

$ cat /usr/local/bin/show_home
#!/usr/bin/ocaml
#load "unix.cma";;
print_endline (Unix.getenv "HOME")

$ touch /tmp/unix.cma

$ cd /
$ show_home
/home/tal

$ cd /tmp
$ show_home
Fatal error: exception End_of_file

Additional information

My attempt at a patch is here:

talex5@a0b7d7e

gasche asked me to report this here:

http://roscidus.com/blog/blog/2013/07/07/ocaml-binary-compatibility/

File attachments

@vicuna
Copy link
Author

@vicuna vicuna commented Aug 19, 2013

Comment author: @damiendoligez

Makes sense, but I don't think it has anything to do with the runtime system.

@vicuna
Copy link
Author

@vicuna vicuna commented Jan 17, 2014

Comment author: @damiendoligez

Got the patch from github and uploaded it here.

(hint: just add ".patch" to github's commit URL to get the raw patch file)

@vicuna
Copy link
Author

@vicuna vicuna commented Jan 16, 2015

Comment author: @damiendoligez

Patch adapted and applied to trunk (rev 15779).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant