From 0f6facd7f1eeceb61d924b9e922d9c84706074bc Mon Sep 17 00:00:00 2001 From: kcwu Date: Thu, 24 Feb 2005 19:22:48 +0000 Subject: 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 --- util/bbsenv.pl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 util/bbsenv.pl 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; -- cgit v1.2.3