summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--parser.c32
-rw-r--r--sysif.c2
-rw-r--r--sysif.h1
3 files changed, 29 insertions, 6 deletions
diff --git a/parser.c b/parser.c
index 7083353b..bbc1a427 100644
--- a/parser.c
+++ b/parser.c
@@ -824,6 +824,26 @@ val txr_parse(val source_in, val error_stream,
#if HAVE_TERMIOS
+static void report_security_problem(val name)
+{
+ static int umask_warned;
+
+ format(std_output,
+ lit("** possible security problem: ~a is writable to others\n"),
+ name, nao);
+#if HAVE_SYS_STAT
+ if (!umask_warned++)
+ {
+ val um = umask_wrap(colon_k);
+ if ((c_num(um) & 022) != 022) {
+ format(std_output,
+ lit("** possible reason: your umask has an insecure value: ~,03o\n"),
+ um, nao);
+ }
+ }
+#endif
+}
+
static void load_rcfile(val name)
{
val resolved_name;
@@ -837,10 +857,8 @@ static void load_rcfile(val name)
open_txr_file(name, &lisp_p, &resolved_name, &stream);
if (stream) {
- if (!funcall1(path_private_to_me_p, stat_wrap(stream))) {
- format(std_output,
- lit("** possible security problem: ~a is writable to others\n"),
- name, nao);
+ if (!funcall1(path_private_to_me_p, stream)) {
+ report_security_problem(name);
} else {
val saved_dyn_env = set_dyn_env(make_env(nil, nil, dyn_env));
env_vbind(dyn_env, load_path_s, resolved_name);
@@ -1409,6 +1427,7 @@ val repl(val bindings, val in_stream, val out_stream, val env)
val counter_sym = intern(lit("*n"), user_package);
val var_counter_sym = intern(lit("*v"), user_package);
val result_hash_sym = intern(lit("*r"), user_package);
+ val path_private_to_me_p = intern(lit("path-private-to-me-p"), user_package);
val result_hash = make_hash(nil, nil, nil);
val done = nil;
val counter = one;
@@ -1445,8 +1464,11 @@ val repl(val bindings, val in_stream, val out_stream, val env)
lino_hist_set_max_len(ls, c_num(cdr(hist_len_var)));
- if (histfile_w)
+ if (histfile_w) {
+ if (!funcall1(path_private_to_me_p, histfile))
+ report_security_problem(histfile);
lino_hist_load(ls, histfile_w);
+ }
lino_set_noninteractive(ls, opt_noninteractive);
diff --git a/sysif.c b/sysif.c
index 6b646d9c..40dec6f0 100644
--- a/sysif.c
+++ b/sysif.c
@@ -1246,7 +1246,7 @@ static val wrap_lutimes(val target, val atime, val atimens,
#if HAVE_SYS_STAT
-static val umask_wrap(val mask)
+val umask_wrap(val mask)
{
if (missingp(mask)) {
mode_t m = umask(0777);
diff --git a/sysif.h b/sysif.h
index c2a650c0..08349e5b 100644
--- a/sysif.h
+++ b/sysif.h
@@ -48,6 +48,7 @@ val num_time(time_t time);
#if HAVE_SYS_STAT
struct stat;
val stat_to_struct(struct stat st, val path);
+val umask_wrap(val mask);
#endif
val stat_wrap(val path);
val stdio_ftell(FILE *);