diff options
author | Björn Gustavsson <[email protected]> | 2011-02-24 08:48:09 +0100 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2011-02-24 08:48:09 +0100 |
commit | a03da22b1307d82853b5b1c61e0d086b26efec85 (patch) | |
tree | 2f2260257831ca2bb63187f251b93ab859e19725 /lib | |
parent | d4ea1aa8d1a206e7a143ac4bd9bd6c37c7fccdaa (diff) | |
parent | eb6d08af973484e37e3efb0f159cf732cc618e2a (diff) | |
download | otp-a03da22b1307d82853b5b1c61e0d086b26efec85.tar.gz otp-a03da22b1307d82853b5b1c61e0d086b26efec85.tar.bz2 otp-a03da22b1307d82853b5b1c61e0d086b26efec85.zip |
Merge branch 'bjorn/fix-os_find_executable/OTP-8983' into dev
* bjorn/fix-os_find_executable/OTP-8983:
Never allow os:find_executable/1 to return the path of directories
Diffstat (limited to 'lib')
-rw-r--r-- | lib/kernel/src/os.erl | 7 | ||||
-rw-r--r-- | lib/kernel/test/os_SUITE.erl | 17 |
2 files changed, 20 insertions, 4 deletions
diff --git a/lib/kernel/src/os.erl b/lib/kernel/src/os.erl index 75a11a8afd..ce8c581e08 100644 --- a/lib/kernel/src/os.erl +++ b/lib/kernel/src/os.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% Copyright Ericsson AB 1997-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -82,8 +82,9 @@ verify_executable(Name0, [Ext|Rest], OrigExtensions) -> end; _ -> case file:read_file_info(Name1) of - {ok, #file_info{mode=Mode}} when Mode band 8#111 =/= 0 -> - %% XXX This test for execution permission is not full-proof + {ok, #file_info{type=regular,mode=Mode}} + when Mode band 8#111 =/= 0 -> + %% XXX This test for execution permission is not fool-proof %% on Unix, since we test if any execution bit is set. {ok, Name1}; _ -> diff --git a/lib/kernel/test/os_SUITE.erl b/lib/kernel/test/os_SUITE.erl index ecb9a111f6..b08b12c978 100644 --- a/lib/kernel/test/os_SUITE.erl +++ b/lib/kernel/test/os_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2010. All Rights Reserved. +%% Copyright Ericsson AB 1997-2011. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -175,6 +175,21 @@ find_executable(Config) when is_list(Config) -> ?line find_exe(Current, "my_batch", ".bat", Path), ok; {unix, _} -> + DataDir = ?config(data_dir, Config), + + %% Smoke test. + case lib:progname() of + erl -> + ?line ErlPath = os:find_executable("erl"), + ?line true = is_list(ErlPath), + ?line true = filelib:is_regular(ErlPath); + _ -> + %% Don't bother -- the progname could include options. + ok + end, + + %% Never return a directory name. + ?line false = os:find_executable("unix", [DataDir]), ok; vxworks -> ok |