Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
3fea9461
Commit
3fea9461
authored
Jan 08, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let vcl_dir and vmod_dir also take colon separated paths.
parent
731f5148
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
30 deletions
+59
-30
mgt_param_tbl.c
bin/varnishd/mgt/mgt_param_tbl.c
+5
-3
m00008.vtc
bin/varnishtest/tests/m00008.vtc
+2
-2
vcc_compile.c
lib/libvcc/vcc_compile.c
+11
-7
vcc_compile.h
lib/libvcc/vcc_compile.h
+2
-0
vcc_vmod.c
lib/libvcc/vcc_vmod.c
+39
-18
No files found.
bin/varnishd/mgt/mgt_param_tbl.c
View file @
3fea9461
...
...
@@ -58,14 +58,16 @@ struct parspec mgt_parspec[] = {
VCC_CC
,
NULL
},
{
"vcl_dir"
,
tweak_string
,
&
mgt_vcl_dir
,
NULL
,
NULL
,
"Directory from which relative VCL filenames (vcl.load and "
"include) are opened."
,
"Directory (or colon separated list of directories) "
"from which relative VCL filenames (vcl.load and "
"include) are to be found."
,
0
,
VARNISH_VCL_DIR
,
NULL
},
{
"vmod_dir"
,
tweak_string
,
&
mgt_vmod_dir
,
NULL
,
NULL
,
"Directory where VCL modules are to be found."
,
"Directory (or colon separated list of directories) "
"where VMODs are to be found."
,
0
,
VARNISH_VMOD_DIR
,
NULL
},
...
...
bin/varnishtest/tests/m00008.vtc
View file @
3fea9461
...
...
@@ -13,12 +13,12 @@ varnish v1 -vcl+backend {
varnish v1 -cliok "param.set vcc_unsafe_path off"
varnish v1 -errvcl {'import ... from path ...'
not allowed
.} {
varnish v1 -errvcl {'import ... from path ...'
is unsafe
.} {
backend default { .host = "${s1_sock}"; }
import ${vmod_std};
}
varnish v1 -cliok "param.set vmod_dir
${topbuild}/lib/libvmod_std/.libs/
"
varnish v1 -cliok "param.set vmod_dir
/nowhere:${topbuild}/lib/libvmod_std/.libs/:/else
"
varnish v1 -vcl+backend {
import std;
...
...
lib/libvcc/vcc_compile.c
View file @
3fea9461
...
...
@@ -450,22 +450,24 @@ vcc_destroy_source(struct source *sp)
/*--------------------------------------------------------------------*/
static
struct
source
*
vcc_file_source
(
const
struct
vcp
*
const
vcp
,
struct
vsb
*
sb
,
c
onst
c
har
*
fn
)
vcc_file_source
(
const
struct
vcp
*
const
vcp
,
struct
vsb
*
sb
,
char
*
fn
)
{
char
*
f
;
char
*
f
,
*
fnp
;
struct
source
*
sp
;
if
(
!
vcp
->
unsafe_path
&&
strchr
(
fn
,
'/'
)
!=
NULL
)
{
VSB_printf
(
sb
,
"Include path is unsafe '%s'
\n
"
,
fn
);
return
(
NULL
);
}
f
=
VFIL_readfile
(
vcp
->
vcl_dir
,
fn
,
NULL
);
if
(
f
==
NULL
)
{
VSB_printf
(
sb
,
"Cannot read file '%s': %s
\n
"
,
fn
,
strerror
(
errno
));
f
=
NULL
;
fnp
=
fn
;
if
(
VFIL_searchpath
(
vcp
->
vcl_path
,
NULL
,
&
f
,
&
fnp
)
||
f
==
NULL
)
{
VSB_printf
(
sb
,
"Cannot read file '%s' (%s)
\n
"
,
fnp
!=
NULL
?
fnp
:
fn
,
strerror
(
errno
));
return
(
NULL
);
}
sp
=
vcc_new_source
(
f
,
NULL
,
fn
);
sp
=
vcc_new_source
(
f
,
NULL
,
fnp
);
free
(
fnp
);
sp
->
freeit
=
f
;
return
(
sp
);
}
...
...
@@ -801,6 +803,7 @@ VCP_VCL_dir(struct vcp *vcp, const char *str)
CHECK_OBJ_NOTNULL
(
vcp
,
VCP_MAGIC
);
REPLACE
(
vcp
->
vcl_dir
,
str
);
VFIL_setpath
(
&
vcp
->
vcl_path
,
str
);
}
/*--------------------------------------------------------------------
...
...
@@ -813,6 +816,7 @@ VCP_VMOD_dir(struct vcp *vcp, const char *str)
CHECK_OBJ_NOTNULL
(
vcp
,
VCP_MAGIC
);
REPLACE
(
vcp
->
vmod_dir
,
str
);
VFIL_setpath
(
&
vcp
->
vmod_path
,
str
);
}
/*--------------------------------------------------------------------
...
...
lib/libvcc/vcc_compile.h
View file @
3fea9461
...
...
@@ -161,7 +161,9 @@ struct vcp {
char
*
builtin_vcl
;
char
*
vcl_dir
;
struct
vfil_path
*
vcl_path
;
char
*
vmod_dir
;
struct
vfil_path
*
vmod_path
;
unsigned
err_unref
;
unsigned
allow_inline_c
;
unsigned
unsafe_path
;
...
...
lib/libvcc/vcc_vmod.c
View file @
3fea9461
...
...
@@ -30,20 +30,39 @@
#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "vcc_compile.h"
#include "vcs_version.h"
#include "vfil.h"
#include "vmod_abi.h"
#include "vrt.h"
static
int
vcc_path_dlopen
(
void
*
priv
,
const
char
*
fn
)
{
void
*
hdl
,
**
pp
;
AN
(
priv
);
AN
(
fn
);
fprintf
(
stderr
,
"TRY <%s>
\n
"
,
fn
);
hdl
=
dlopen
(
fn
,
RTLD_NOW
|
RTLD_LOCAL
);
if
(
hdl
==
NULL
)
return
(
1
);
pp
=
priv
;
*
pp
=
hdl
;
return
(
0
);
}
void
vcc_ParseImport
(
struct
vcc
*
tl
)
{
void
*
hdl
;
char
fn
[
1024
];
char
fn
[
1024
]
,
*
fnp
;
char
buf
[
256
];
struct
token
*
mod
,
*
t1
;
struct
inifin
*
ifp
;
...
...
@@ -85,32 +104,33 @@ vcc_ParseImport(struct vcc *tl)
sym
->
def_e
=
tl
->
t
;
if
(
tl
->
t
->
tok
==
ID
)
{
if
(
!
tl
->
param
->
unsafe_path
)
{
VSB_printf
(
tl
->
sb
,
"'import ... from path ...' not allowed.
\n
At:"
);
vcc_ErrToken
(
tl
,
tl
->
t
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
;
}
if
(
!
vcc_IdIs
(
tl
->
t
,
"from"
))
{
VSB_printf
(
tl
->
sb
,
"Expected 'from path ...'
\n
"
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
;
}
vcc_NextToken
(
tl
);
if
(
!
tl
->
param
->
unsafe_path
&&
strchr
(
tl
->
t
->
dec
,
'/'
))
{
VSB_printf
(
tl
->
sb
,
"'import ... from path ...' is unsafe.
\n
At:"
);
vcc_ErrToken
(
tl
,
tl
->
t
);
vcc_ErrWhere
(
tl
,
tl
->
t
);
return
;
}
ExpectErr
(
tl
,
CSTR
);
bprintf
(
fn
,
"%s"
,
tl
->
t
->
dec
);
vcc_NextToken
(
tl
);
}
else
{
bprintf
(
fn
,
"
%s/libvmod_%.*s.so"
,
tl
->
param
->
vmod_dir
,
PF
(
mod
));
bprintf
(
fn
,
"
libvmod_%.*s.so"
,
PF
(
mod
));
}
SkipToken
(
tl
,
';'
);
hdl
=
dlopen
(
fn
,
RTLD_NOW
|
RTLD_LOCAL
);
if
(
hdl
==
NULL
)
{
fnp
=
fn
;
if
(
VFIL_searchpath
(
tl
->
param
->
vmod_path
,
vcc_path_dlopen
,
&
hdl
,
&
fnp
))
{
VSB_printf
(
tl
->
sb
,
"Could not load VMOD %.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fn
);
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fn
p
!=
NULL
?
fnp
:
fn
);
VSB_printf
(
tl
->
sb
,
"
\t
dlerror: %s
\n
"
,
dlerror
());
vcc_ErrWhere
(
tl
,
mod
);
return
;
...
...
@@ -120,7 +140,7 @@ vcc_ParseImport(struct vcc *tl)
vmd
=
dlsym
(
hdl
,
buf
);
if
(
vmd
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"Malformed VMOD %.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fn
);
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fn
p
);
VSB_printf
(
tl
->
sb
,
"
\t
(no Vmod_Data symbol)
\n
"
);
vcc_ErrWhere
(
tl
,
mod
);
return
;
...
...
@@ -128,7 +148,7 @@ vcc_ParseImport(struct vcc *tl)
if
(
strcmp
(
VCS_Branch
,
"master"
)
==
0
&&
strcmp
(
vmd
->
abi
,
VMOD_ABI_Version
)
!=
0
)
{
VSB_printf
(
tl
->
sb
,
"Incompatible VMOD %.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fn
);
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fn
p
);
VSB_printf
(
tl
->
sb
,
"
\t
ABI mismatch, expected <%s>, got <%s>
\n
"
,
VMOD_ABI_Version
,
vmd
->
abi
);
vcc_ErrWhere
(
tl
,
mod
);
...
...
@@ -137,7 +157,7 @@ vcc_ParseImport(struct vcc *tl)
if
(
vmd
->
vrt_major
!=
VRT_MAJOR_VERSION
||
vmd
->
vrt_minor
>
VRT_MINOR_VERSION
)
{
VSB_printf
(
tl
->
sb
,
"Incompatible VMOD %.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fn
);
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fn
p
);
VSB_printf
(
tl
->
sb
,
"
\t
VMOD version %u.%u
\n
"
,
vmd
->
vrt_major
,
vmd
->
vrt_minor
);
VSB_printf
(
tl
->
sb
,
"
\t
varnishd version %u.%u
\n
"
,
...
...
@@ -151,7 +171,7 @@ vcc_ParseImport(struct vcc *tl)
vmd
->
proto
==
NULL
||
vmd
->
abi
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"Mangled VMOD %.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fn
);
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fn
p
);
VSB_printf
(
tl
->
sb
,
"
\t
Inconsistent metadata
\n
"
);
vcc_ErrWhere
(
tl
,
mod
);
return
;
...
...
@@ -159,7 +179,7 @@ vcc_ParseImport(struct vcc *tl)
if
(
!
vcc_IdIs
(
mod
,
vmd
->
name
))
{
VSB_printf
(
tl
->
sb
,
"Wrong VMOD file %.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fn
);
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fn
p
);
VSB_printf
(
tl
->
sb
,
"
\t
Contains vmod
\"
%s
\"\n
"
,
vmd
->
name
);
vcc_ErrWhere
(
tl
,
mod
);
return
;
...
...
@@ -172,7 +192,8 @@ vcc_ParseImport(struct vcc *tl)
VSB_printf
(
ifp
->
ini
,
"
\t
sizeof(Vmod_%.*s_Func),
\n
"
,
PF
(
mod
));
VSB_printf
(
ifp
->
ini
,
"
\t
\"
%.*s
\"
,
\n
"
,
PF
(
mod
));
VSB_printf
(
ifp
->
ini
,
"
\t
"
);
EncString
(
ifp
->
ini
,
fn
,
NULL
,
0
);
EncString
(
ifp
->
ini
,
fnp
,
NULL
,
0
);
free
(
fnp
);
VSB_printf
(
ifp
->
ini
,
",
\n
"
);
AN
(
vmd
);
AN
(
vmd
->
file_id
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment