summaryrefslogtreecommitdiffstats
path: root/util/bbsenv.pl
diff options
context:
space:
mode:
Diffstat (limited to 'util/bbsenv.pl')
-rw-r--r--util/bbsenv.pl28
1 files changed, 28 insertions, 0 deletions
diff --git a/util/bbsenv.pl b/util/bbsenv.pl
new file mode 100644
index 00000000..4bbdb8ba
--- /dev/null
+++ b/util/bbsenv.pl
@@ -0,0 +1,28 @@
+#!/usr/bin/perl -w
+# for saving memory, filter out unnecessary environment variables
+use strict;
+
+########################################
+# mbbsd 會用到的 external program:
+# tar rm cat mv cp stty
+# bin/railway_wrapper.pl -> lynx -> LANG
+# bin/buildir bin/builddb.pl bin/xchatd
+# mutt -> TMPDIR
+# /usr/bin/uuencode /usr/sbin/sendmail
+##########################################
+# 若無 getpwuid(2), mutt 會需要 HOME,USER
+
+$ENV{PATH}="/bin:/usr/bin:/usr/local/bin";
+#$ENV{SHELL}="/bin/sh";
+my @acceptenv=qw(
+ ^PATH$
+ ^USER$ ^HOME$
+ ^TZ$ ^TZDIR$ ^TMPDIR$
+ ^MALLOC_
+ );
+# TERM SHELL PWD LANG LOGNAME
+for my $env(keys %ENV) {
+ delete $ENV{$env} if !grep { $env =~ $_ } @acceptenv;
+}
+
+exec { $ARGV[0] } @ARGV;