summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-25 03:22:48 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-25 03:22:48 +0800
commit0f6facd7f1eeceb61d924b9e922d9c84706074bc (patch)
treeb637d9b69f5f2f97d2212f32e63ff27c98ffdb93 /util
parent4c93dcf3d3467422215b0313a89ca34c60122e03 (diff)
downloadpttbbs-0f6facd7f1eeceb61d924b9e922d9c84706074bc.tar
pttbbs-0f6facd7f1eeceb61d924b9e922d9c84706074bc.tar.gz
pttbbs-0f6facd7f1eeceb61d924b9e922d9c84706074bc.tar.bz2
pttbbs-0f6facd7f1eeceb61d924b9e922d9c84706074bc.tar.lz
pttbbs-0f6facd7f1eeceb61d924b9e922d9c84706074bc.tar.xz
pttbbs-0f6facd7f1eeceb61d924b9e922d9c84706074bc.tar.zst
pttbbs-0f6facd7f1eeceb61d924b9e922d9c84706074bc.zip
for saving memory, perl script to filter out unnecessary environment variables
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2539 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-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;