summaryrefslogtreecommitdiffstats
path: root/src/if_perl.xs
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-02-08 14:34:10 +0100
committerBram Moolenaar <Bram@vim.org>2019-02-08 14:34:10 +0100
commit8c62a08faf89663e5633dc5036cd8695c80f1075 (patch)
treeaf5faafe055ea91f652f006d05a29a2dd5c8521b /src/if_perl.xs
parentc6ddce3f2cf6daa3a545405373b661f8a9bccad9 (diff)
patch 8.1.0881: can execute shell commands in rvim through interfacesv8.1.0881
Problem: Can execute shell commands in rvim through interfaces. Solution: Disable using interfaces in restricted mode. Allow for writing file with writefile(), histadd() and a few others.
Diffstat (limited to 'src/if_perl.xs')
-rw-r--r--src/if_perl.xs13
1 files changed, 5 insertions, 8 deletions
diff --git a/src/if_perl.xs b/src/if_perl.xs
index 203bb6a679..67d0b94888 100644
--- a/src/if_perl.xs
+++ b/src/if_perl.xs
@@ -971,6 +971,7 @@ VIM_init(void)
#ifdef DYNAMIC_PERL
static char *e_noperl = N_("Sorry, this command is disabled: the Perl library could not be loaded.");
#endif
+static char *e_perlsandbox = N_("E299: Perl evaluation forbidden in sandbox without the Safe module");
/*
* ":perl"
@@ -1019,13 +1020,12 @@ ex_perl(exarg_T *eap)
vim_free(script);
}
-#ifdef HAVE_SANDBOX
- if (sandbox)
+ if (sandbox || secure)
{
safe = perl_get_sv("VIM::safe", FALSE);
# ifndef MAKE_TEST /* avoid a warning for unreachable code */
if (safe == NULL || !SvTRUE(safe))
- emsg(_("E299: Perl evaluation forbidden in sandbox without the Safe module"));
+ emsg(_(e_perlsandbox));
else
# endif
{
@@ -1037,7 +1037,6 @@ ex_perl(exarg_T *eap)
}
}
else
-#endif
perl_eval_sv(sv, G_DISCARD | G_NOARGS);
SvREFCNT_dec(sv);
@@ -1298,13 +1297,12 @@ do_perleval(char_u *str, typval_T *rettv)
ENTER;
SAVETMPS;
-#ifdef HAVE_SANDBOX
- if (sandbox)
+ if (sandbox || secure)
{
safe = get_sv("VIM::safe", FALSE);
# ifndef MAKE_TEST /* avoid a warning for unreachable code */
if (safe == NULL || !SvTRUE(safe))
- emsg(_("E299: Perl evaluation forbidden in sandbox without the Safe module"));
+ emsg(_(e_perlsandbox));
else
# endif
{
@@ -1320,7 +1318,6 @@ do_perleval(char_u *str, typval_T *rettv)
}
}
else
-#endif /* HAVE_SANDBOX */
sv = eval_pv((char *)str, 0);
if (sv) {