mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Merge remote-tracking branch 'origin/topic/awelzel/2991-unload-zeek-package'
* origin/topic/awelzel/2991-unload-zeek-package: unload: Fix unloading of packages
This commit is contained in:
commit
5570f806ca
2 changed files with 16 additions and 1 deletions
10
src/scan.l
10
src/scan.l
|
@ -489,6 +489,16 @@ when return TOK_WHEN;
|
||||||
const char* file = zeek::util::skip_whitespace(yytext + 7);
|
const char* file = zeek::util::skip_whitespace(yytext + 7);
|
||||||
std::string path = find_relative_script_file(file);
|
std::string path = find_relative_script_file(file);
|
||||||
|
|
||||||
|
if ( ! path.empty() && zeek::util::is_dir(path.c_str()) )
|
||||||
|
{
|
||||||
|
// open_package() appends __load__.zeek to path and verifies existence
|
||||||
|
FILE *f = zeek::util::detail::open_package(path);
|
||||||
|
if (f)
|
||||||
|
fclose(f);
|
||||||
|
else
|
||||||
|
path = "";
|
||||||
|
}
|
||||||
|
|
||||||
if ( path.empty() )
|
if ( path.empty() )
|
||||||
zeek::reporter->Error("failed find file associated with @unload %s", file);
|
zeek::reporter->Error("failed find file associated with @unload %s", file);
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
# This tests the @unload directive
|
# This tests the @unload directive
|
||||||
#
|
#
|
||||||
# @TEST-EXEC: zeek -b unload misc/loaded-scripts dontloadme > output
|
# @TEST-EXEC: zeek -b unload misc/loaded-scripts dontloadme pkg-dontloadme > output
|
||||||
# @TEST-EXEC: btest-diff output
|
# @TEST-EXEC: btest-diff output
|
||||||
# @TEST-EXEC: grep dontloadme loaded_scripts.log && exit 1 || exit 0
|
# @TEST-EXEC: grep dontloadme loaded_scripts.log && exit 1 || exit 0
|
||||||
|
|
||||||
@TEST-START-FILE unload.zeek
|
@TEST-START-FILE unload.zeek
|
||||||
@unload dontloadme
|
@unload dontloadme
|
||||||
|
@unload pkg-dontloadme
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
@TEST-START-FILE dontloadme.zeek
|
@TEST-START-FILE dontloadme.zeek
|
||||||
print "Loaded: dontloadme.zeek";
|
print "Loaded: dontloadme.zeek";
|
||||||
@TEST-END-FILE
|
@TEST-END-FILE
|
||||||
|
|
||||||
|
@TEST-START-FILE pkg-dontloadme/__load__.zeek
|
||||||
|
print "Loaded: pkg-dontloadme/__load__.zeek";
|
||||||
|
@TEST-END-FILE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue