|
From: <jgs...@us...> - 2003-12-09 06:50:16
|
Update of /cvsroot/serverfilters
In directory sc8-pr-cvs1:/tmp/cvs-serv28582
Modified Files:
ChangeLog README backend.php config.php functions.php
options.php recipie_functions.php
Log Message:
Removed FTP requirement. New backend uses "sudo" do properly move and set permissions on files with scripts in the script directory.
Index: README
===================================================================
RCS file: /cvsroot/serverfilters/README,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** README 8 Dec 2003 18:53:06 -0000 1.2
--- README 9 Dec 2003 06:50:12 -0000 1.3
***************
*** 11,21 ****
ServerSideFilters supports standard shell users and Virtual Domains.
- ServerSideFilter can be configured to store the filter file in a local
- directory or to use FTP to put the file in the users home directory.
- See the configure.php file to select this option.
- FTP support in PHP is required to use this FTP version.
-
- FTP method must be used for maildrop due to file permission requirements.
-
For qmail users, this script can also be configured to create the proper
dot-qmail files for delivery.
--- 11,14 ----
***************
*** 39,71 ****
4) reconfigure SquirrelMail to enable the ServerSideFilter plugin.
-
- apache.conf
- The following text is taken straight from the vadmin plugin. If you already have
- vadmin setup and working, you do not need to mess with this at all. Vadmin
- is not a requirement, I am simply giving due credit.
-
- Edit apache.conf and change two things -- the path to your
- squirrelmail directory if it's not /usr/share/squirrelmail (in which
- case some people at FHS might want to have a word or two with you),
- and change "LLAMA" to some unique string. This is the encryption
- hash that will be used to encrypt your vadmin data, including
- domain passwords. Make it something good. If you don't change it
- from "LLAMA," you will suffer the consequences when someone logs in
- and runs porn warez from your server.
-
- Once you have edited the file, you have two options. If you have
- /etc/httpd/conf.d directory (which is true for at least Red Hat
- Linux 8 and above), then just move that file into that dir. I.e.:
- mv apache.conf /etc/httpd/conf.d/vadmin-apache.conf.
-
- If you don't have /etc/httpd/conf.d directory, then move the file
- into /etc/httpd/conf and add the following line into your global
- apache.conf:
- Include vadmin-apache.conf
-
- !!!IMPORTANT!!!
- Wherever you have moved the file, run the following commands on it:
- chown root:root vadmin-apache.conf
- chmod 0600 vadmin-apache.conf
--- 32,35 ----
Index: backend.php
===================================================================
RCS file: /cvsroot/serverfilters/backend.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** backend.php 8 Dec 2003 18:28:03 -0000 1.2
--- backend.php 9 Dec 2003 06:50:12 -0000 1.3
***************
*** 12,29 ****
*/
- /*
- * Local Backend
- * Functions here work with a local file
- */
function local_filter_get() {
global $username, $FILTERDIR, $FILTERFILE, $VIRTUAL_DOMAINS, $SEPERATOR;
! if (isset($VIRTUAL_DOMAINS) && ($VIRTUAL_DOMAINS==1)) {
! list($user, $domain) = split($SEPERATOR,$username);
! } else {
! $user = $username;
! $domain = '';
! }
! $path = preg_replace(array('/\[DOMAIN\]/','/\[USERNAME\]/'),array($domain,$user),$FILTERDIR);
if (!file_exists($path)) {
mkdirs($path,0700);
--- 12,20 ----
*/
function local_filter_get() {
global $username, $FILTERDIR, $FILTERFILE, $VIRTUAL_DOMAINS, $SEPERATOR;
! $path = vd_replace($FILTERDIR);
!
if (!file_exists($path)) {
mkdirs($path,0700);
***************
*** 32,38 ****
$file = "$path/$FILTERFILE";
$localfile = "/tmp/$FILTERFILE.$username";
! if (file_exists($file))
! copy($file, $localfile);
! else
touch($localfile);
--- 23,30 ----
$file = "$path/$FILTERFILE";
$localfile = "/tmp/$FILTERFILE.$username";
! if (local_file_exists($file)) {
! $command = escapeshellcmd("sudo ./script/getrc $file $localfile");
! system($command);
! } else
touch($localfile);
***************
*** 43,55 ****
global $username, $FILTERDIR, $FILTERFILE, $VIRTUAL_DOMAINS, $SEPERATOR;
! if (isset($VIRTUAL_DOMAINS) && ($VIRTUAL_DOMAINS==1)) {
! list($user, $domain) = split($SEPERATOR,$username);
! } else {
! $user = $username;
! $domain = '';
! }
! $path = preg_replace(array('/\[DOMAIN\]/','/\[USERNAME\]/'),array($domain,$user),$FILTERDIR);
$file = "$path/$FILTERFILE";
! return file_exists($file);
}
--- 35,52 ----
global $username, $FILTERDIR, $FILTERFILE, $VIRTUAL_DOMAINS, $SEPERATOR;
! $path = vd_replace($FILTERDIR);
!
$file = "$path/$FILTERFILE";
! return local_file_exists($file);
!
! }
!
! function local_file_exists($file) {
! $command = escapeshellcmd("sudo ./script/rcexists $file");
! system($command, $exists);
! if ($exists == 0)
! return true;
! else
! return false;
}
***************
*** 59,69 ****
global $username, $FILTERDIR, $FILTERFILE, $VIRTUAL_DOMAINS, $SEPERATOR;
! if (isset($VIRTUAL_DOMAINS) && ($VIRTUAL_DOMAINS==1)) {
! list($user, $domain) = split($SEPERATOR,$username);
! } else {
! $user = $username;
! $domain = '';
! }
! $path = preg_replace(array('/\[DOMAIN\]/','/\[USERNAME\]/'),array($domain,$user),$FILTERDIR);
if (!file_exists($path)) {
mkdirs($path,0700);
--- 56,61 ----
global $username, $FILTERDIR, $FILTERFILE, $VIRTUAL_DOMAINS, $SEPERATOR;
! $path = vd_replace($FILTERDIR);
!
if (!file_exists($path)) {
mkdirs($path,0700);
***************
*** 71,189 ****
$newfile = "$path/$FILTERFILE";
- copy($file, $newfile);
- }
- // the local method has no way to check passwords. this function should really never be called.
- function local_check_pass() {
- return false;
- }
- /*
- * FTP backend
- * These functions implement moving the filter files and qmail files via FTP
- */
- function ftp_filter_get() {
- global $username, $FILTERDIR, $FILTERFILE, $VIRTUAL_DOMAINS, $SEPERATOR;
if ($VIRTUAL_DOMAINS)
- list($user,$domain) = split($SEPERATOR,$username);
- else {
- $user = $username;
- $domain = '';
- }
- $path = preg_replace(array('/\[DOMAIN\]/','/\[USERNAME\]/'),array($domain,$user),$FILTERDIR);
- $filtername = "$path/$FILTERFILE";
- $localfile = "/tmp/$FILTERFILE.$username";
- _ftp_get($localfile, $filtername);
- return $localfile;
- }
-
- function ftp_filter_exists() {
- $file = ftp_filter_get();
- if (filesize($file) > 0) $ret = true;
- else $ret = false;
- unlink($file);
- return $ret;
- }
-
- function ftp_filter_put($file) {
- global $username, $FILTERDIR, $FILTERFILE, $VIRTUAL_DOMAINS, $SEPERATOR;
- if ($VIRTUAL_DOMAINS)
- list($user,$domain) = split($SEPERATOR,$username);
- else {
- $user = $username;
- $domain = '';
- }
- $path = preg_replace(array('/\[DOMAIN\]/','/\[USERNAME\]/'),array($domain,$user),$FILTERDIR);
- $filtername = "$path/$FILTERFILE";
- _ftp_put($file,$filtername);
- }
-
- function ftp_write_dot_qmail($file) {
- global $username, $VIRTUAL_DOMAINS, $SEPERATOR;
- if ($VIRTUAL_DOMAINS) {
- list($user,$domain) = split($SEPERATOR,$username);
- $dot_qmail = ".qmail-$user";
- } else {
- $dot_qmail = '.qmail';
- }
- _ftp_put($file,$dot_qmail);
- }
-
- function ftp_check_pass ($user, $pass) {
- global $imapServerAddress;
-
- $conn = @ftp_connect($imapServerAddress);
- $ret = @ftp_login($conn, $user, $pass);
- @ftp_quit($conn);
- return $ret;
- }
- // Raw ftp functions
- function _ftp_get($localfile, $remotefile) {
- global $username, $key, $onetimepad, $imapServerAddress, $VIRTUAL_DOMAINS, $SEPERATOR;
-
- if ($VIRTUAL_DOMAINS) {
- list($vuser,$vdomain) = split($SEPERATOR,$username);
- $password = my_get_domain_passwd($vdomain);
$user = my_virtual_domain_user($vdomain);
! } else {
! compatibility_sqextractGlobalVar('onetimepad');
! if (!compatibility_check_php_version(4, 1)) {
! global $HTTP_COOKIE_VARS;
! $_COOKIE = $HTTP_COOKIE_VARS;
! }
! $key = $_COOKIE['key'];
! $password = OneTimePadDecrypt($key, $onetimepad);
$user = $username;
- }
! $conn = @ftp_connect($imapServerAddress);
! @ftp_login($conn, $user, $password);
! @ftp_get($conn, $localfile, $remotefile, FTP_BINARY) or touch($localfile);
! @ftp_quit($conn);
}
- function _ftp_put($localfile, $remotefile) {
- global $username, $key, $onetimepad, $imapServerAddress, $VIRTUAL_DOMAINS, $SEPERATOR;
-
- if ($VIRTUAL_DOMAINS) {
- list($vuser,$vdomain) = split($SEPERATOR,$username);
- $password = my_get_domain_passwd($vdomain);
- $user = my_virtual_domain_user($vdomain);
- } else {
- compatibility_sqextractGlobalVar('onetimepad');
- if (!compatibility_check_php_version(4, 1)) {
- global $HTTP_COOKIE_VARS;
- $_COOKIE = $HTTP_COOKIE_VARS;
- }
- $key = $_COOKIE['key'];
- $password = OneTimePadDecrypt($key, $onetimepad);
- $user = $username;
- }
- $conn = @ftp_connect($imapServerAddress);
- @ftp_login($conn, $user, $password);
- @ftp_put($conn, $remotefile, $localfile, FTP_BINARY);
- @ftp_site($conn,"CHMOD 0600 $remotefile");
-
- @ftp_quit($conn);
- }
/**
--- 63,76 ----
$newfile = "$path/$FILTERFILE";
if ($VIRTUAL_DOMAINS)
$user = my_virtual_domain_user($vdomain);
! else
$user = $username;
! $command = escapeshellcmd("sudo ./script/putrc $user $file $localfile");
! system($command);
}
/**
***************
*** 242,256 ****
function vd_replace($setting) {
! global $VIRTUAL_DOMAINS, $SEPERATOR;
if (isset($VIRTUAL_DOMAINS) && ($VIRTUAL_DOMAINS==1)) {
list($user, $domain) = split($SEPERATOR,$username);
} else {
$user = $username;
$domain = '';
}
-
return preg_replace(
! array('/\[DOMAIN\]/','/\[USERNAME\]/'),
! array($domain,$user),
$setting
);
--- 129,144 ----
function vd_replace($setting) {
! global $username, $VIRTUAL_DOMAINS, $SEPERATOR;
if (isset($VIRTUAL_DOMAINS) && ($VIRTUAL_DOMAINS==1)) {
list($user, $domain) = split($SEPERATOR,$username);
+ $domuser = my_virtual_domain_user($domain);
} else {
$user = $username;
$domain = '';
+ $domuser = '';
}
return preg_replace(
! array('/\[DOMAIN\]/','/\[USERNAME\]/','/\[DOMUSER\]/'),
! array($domain,$user,$domuser),
$setting
);
***************
*** 311,340 ****
}
- /*
- * Virtual Domain Backend
- * Some of this code is loosely based off of code from Konstantin Riabitsev's vadmin plugin
- */
- function qmail_list_virtual_domains(){
- $control = '/var/qmail/control';
- $vfile = "$control/virtualdomains";
- if (!file_exists($vfile) || !is_readable($vfile)){
- return false;
- }
- $fd = fopen($vfile, 'r');
- $contents = fread($fd, filesize($vfile));
- $contents = rtrim($contents);
- if (strlen($contents) > 0){
- $domuary = explode("\n", $contents);
- $domary = array();
- foreach ($domuary as $domu){
- $domain = preg_replace('/:.*/s', '', $domu);
- array_push($domary, $domain);
- }
- return $domary;
- } else {
- return false;
- }
- }
-
function qmail_virtual_domain_user($domain){
$control = '/var/qmail/control';
--- 199,202 ----
***************
*** 357,470 ****
return false;
}
- }
-
-
- /**
- * Crypto code.
- * These functions encrypt the password
- *
- * This function stolen nearly verbatim from hastymail.
- * http://hastymail.sf.net/
- */
- function my_rc4_crypt($input, $key) {
- $k_tmp = preg_split('//', $key, -1, PREG_SPLIT_NO_EMPTY);
- foreach($k_tmp as $char) {
- $k[] = ord($char);
- }
- unset($k_tmp);
- $message = preg_split('//', $input, -1, PREG_SPLIT_NO_EMPTY);
- $rep = count($k);
- for ($n=0;$n<$rep;$n++) {
- $s[] = $n;
- }
- $i = 0;
- $f = 0;
- for ($i = 0;$i<$rep;$i++) {
- $f = (($f + $s[$i] + $k[$i]) % $rep);
- $tmp = $s[$i];
- $s[$i] = $s[$f];
- $s[$f] = $tmp;
- }
- $i = 0;
- $f = 0;
- foreach($message as $letter) {
- $i = (($i + 1) % $rep);
- $f = (($f + $s[$i]) % $rep);
- $tmp = $s[$i];
- $s[$i] = $s[$f];
- $s[$f] = $tmp;
- $t = $s[$i] + $s[$f];
- $done = ($t^(ord($letter)));
- $i++;
- $f++;
- $enc_array[] = chr($done);
- }
- $coded = implode('', $enc_array);
- return $coded;
- }
-
- /**
- * This function does the encryption and decryption of sensitive
- * data stored on the HDD. It uses the CRYPTO_HASH_LINE as key.
- * This function is taken from the VADMIN plugin.
- *
- * @param $input the contents to encrypt/decrypt.
- * @param $mode a string that can be either "decrypt" or "encrypt"
- * depending on which action needs to be performed.
- * @return the results of encryption/decryption.
- */
- function my_crypto($input, $mode){
- $CRYPTO_HASH_LINE = $_SERVER{'CRYPTO_HASH_LINE'};
- $MCRYPT_ALGO = $_SERVER{'MCRYPT_ALGO'};
-
- /**
- * See if we have everything needed for
- * encryption/decryption. This includes checking for the
- * encryption functions, the algorithm, and the hash line.
- */
- if (!$CRYPTO_HASH_LINE || !$MCRYPT_ALGO){
- $message = '';
- if (!$CRYPTO_HASH_LINE){
- $message .= _("Could not find CRYPTO_HASH_LINE! ");
- }
- if (!$MCRYPT_ALGO){
- $message .= _("Could not find MCRYPT_ALGO! ");
- }
- echo "CRYPTO is misconfigured: $message";
- }
- $key = $CRYPTO_HASH_LINE;
- if ($MCRYPT_ALGO == 'rc4_builtin'){
- switch($mode){
- case 'encrypt':
- $endresult = base64_encode(vadmin_rc4_crypt($input, $key));
- break;
- case 'decrypt':
- $endresult = vadmin_rc4_crypt(base64_decode($input), $key);
- break;
- }
- } else {
- if (!function_exists('mcrypt_generic')){
- $message = _("An algorithm other than 'rc4_builtin' specified, but mcrypt support not found.");
- echo "CRYPTO is misconfigured: $message";
- }
- $td = mcrypt_module_open($MCRYPT_ALGO, '', MCRYPT_MODE_ECB, '');
- $iv = mcrypt_create_iv(mcrypt_enc_get_iv_size ($td), MCRYPT_RAND);
- @mcrypt_generic_init($td, $key, $iv);
- switch ($mode){
- case 'encrypt':
- $endresult = base64_encode(mcrypt_generic($td, $input));
- break;
- case 'decrypt':
- $endresult = mdecrypt_generic($td, base64_decode($input));
- /**
- * There will be trailing nul's on the end. Remove
- * these. They suck.
- */
- $endresult = rtrim($endresult);
- break;
- }
- mcrypt_generic_deinit($td);
- }
- return $endresult;
}
--- 219,222 ----
Index: config.php
===================================================================
RCS file: /cvsroot/serverfilters/config.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** config.php 8 Dec 2003 18:28:03 -0000 1.2
--- config.php 9 Dec 2003 06:50:12 -0000 1.3
***************
*** 7,28 ****
! global $STORAGE_DIR, $ADMIN, $ALWAYS_CREATE, $FILE_BACKEND, $FILTERDIR, $FILTERFILE,
! $FILTER_APP, $FILTER_APP_PATH, $DEFAULT_DELIVERY, $SPAMFILTER, $SPAMHEADER,
$SPAMVALUE, $UNSUREVALUE, $VIRTUAL_DOMAINS, $LOCAL_MAILDIR,
! $USE_MAILDIRS, $VD_BACKEND, $SEPERATOR, $CREATE_DOT_QMAIL;
! /**
! * STORAGE_DIR
! * If you are using virtual domains, then the domain password
! * will need to be stored in an encrypted file. This is the location
! * for that file. You will be able to set the passwords in the
! * admin module on the options page.
! * Admin
! * names of users allowed to set the domain passwords when using
! * Virtual Domains and the ftp backend.
! * when one of these users logs in, they will have a link under the
! * Mail filters option to set domain passwords.
! */
! $STORAGE_DIR = '/var/lib/serversidefilter';
! $ADMIN = array('jgs...@bs...');
/**
--- 7,14 ----
! global $ALWAYS_CREATE, $FILTERDIR, $FILTERFILE, $FILTER_APP, $FILTER_APP_PATH,
! $DEFAULT_DELIVERY, $SPAMFILTER, $SPAMHEADER,
$SPAMVALUE, $UNSUREVALUE, $VIRTUAL_DOMAINS, $LOCAL_MAILDIR,
! $USE_MAILDIRS, $SEPERATOR, $CREATE_DOT_QMAIL, $DOT_QMAIL_DIR;
/**
***************
*** 36,53 ****
- /**
- * FILE_BACKEND
- * this is the method to save the filter file.
- * 'local'
- * Setting to local will store the file in the HOMEDIR listed below.
- * This setting will not work if you want this script to generate
- * dot-qmail files. This is also not compatible with maildrop.
- * 'ftp'
- * Setting to FTP will transfer the file via ftp to the user's
- * home directory.
- */
- //$FILE_BACKEND = 'local';
- $FILE_BACKEND = 'ftp';
-
/*
* This is the directory where the filter files will be stored
--- 22,25 ----
***************
*** 57,63 ****
* and the appropriate domain name and username will be entered.
*/
! //$FILTERDIR = '/var/lib/squirrelmail/home/[DOMAIN]/[USERNAME]'; //example for FILE_LOCATION='local'
! $FILTERDIR = 'users/[USERNAME]'; //example for virtual domains and using ftp
! //$FILTERDIR = '.';
/*
--- 29,34 ----
* and the appropriate domain name and username will be entered.
*/
! //$FILTERDIR = '/var/lib/squirrelmail/home/[DOMAIN]/[USERNAME]';
! $FILTERDIR = '/home/email/[DOMUSER]/users/[USERNAME]';
/*
***************
*** 100,104 ****
$SPAMFILTER = '/usr/bin/spamc -u [USERNAME] -f';
$SPAMHEADER = 'X-Spam-Flag';
! $SPAMVALUE = 'YES';
//$SPAMFILTER= '/usr/bin/sb_filter.py';
//$SPAMHEADER = 'X-SpamBayes-Classification';
--- 71,75 ----
$SPAMFILTER = '/usr/bin/spamc -u [USERNAME] -f';
$SPAMHEADER = 'X-Spam-Flag';
! $SPAMVALUE = 'Yes';
//$SPAMFILTER= '/usr/bin/sb_filter.py';
//$SPAMHEADER = 'X-SpamBayes-Classification';
***************
*** 106,113 ****
//$UNSUREVALUE = 'unsure';
- /**** Virtual Domain Settings ****/
-
- // Set this to 1 if you host virtual domains and have virtual users
- $VIRTUAL_DOMAINS = 1;
/*
--- 77,80 ----
***************
*** 128,144 ****
$USE_MAILDIRS = 1;
! /*
! * VD_BACKEND
! * This is basically the mailserver you use to implement virtual domains.
! * This is used to determine the base directory of your virtual domains.
! * This is only used when VIRTUAL_USERS = 1
! * 'qmail'
! * Setting this to qmail will read /var/qmail/control/virtualdomains to
! * determine the location of the Maildir folders
! * 'postfix'
! * Option not yet supported
! */
! $VD_BACKEND = 'qmail';
// Character that seperates username from domain name
--- 95,102 ----
$USE_MAILDIRS = 1;
! /**** Virtual Domain Settings ****/
+ // Set this to 1 if you host virtual domains and have virtual users
+ $VIRTUAL_DOMAINS = 1;
// Character that seperates username from domain name
***************
*** 151,154 ****
--- 109,113 ----
// Currently only works if FTP method is selected
$CREATE_DOT_QMAIL = 1;
+ $DOT_QMAIL_DIR = "/home/email/[DOMUSER]/";
?>
Index: functions.php
===================================================================
RCS file: /cvsroot/serverfilters/functions.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** functions.php 4 Dec 2003 23:15:06 -0000 1.1.1.1
--- functions.php 9 Dec 2003 06:50:12 -0000 1.2
***************
*** 17,57 ****
* Filter functions
* The are the functions you call to get or write the filter files
- * The backend implementation is called from within these functions
- * The backend definitions are backend.php
*/
function filter_get() {
! global $FILE_BACKEND;
! $filter_get = $FILE_BACKEND.'_filter_get';
! return $filter_get();
}
! function filter_exists(){
! global $FILE_BACKEND;
! $filter_exists = $FILE_BACKEND.'_filter_exists';
! return $filter_exists();
}
function filter_put($file) {
! global $FILE_BACKEND;
! $filter_put = $FILE_BACKEND.'_filter_put';
! return $filter_put($file);
}
function write_dot_qmail() {
! global $username, $SEPERATOR, $VIRTUAL_DOMAINS, $FILE_BACKEND,
! $FILTERDIR, $FILTERFILE, $FILTER_APP_PATH;
$tmpfile = "/tmp/.qmail-$username";
! if ($VIRTUAL_DOMAINS) list($user,$domain) = split($SEPERATOR,$username);
! else $user = $username;
$fd = fopen($tmpfile,"w");
! $filterpath = preg_replace(array('/\[DOMAIN\]/','/\[USERNAME\]/'),array($domain,$user),$FILTERDIR);
$filterfile = "$filterpath/$FILTERFILE";
$contents = "|preline $FILTER_APP_PATH $filterfile\n";
fwrite($fd, $contents);
fclose($fd);
! $write_dot_qmail = $FILE_BACKEND.'_write_dot_qmail';
! $write_dot_qmail($tmpfile);
! unlink($tmpfile);
}
--- 17,98 ----
* Filter functions
* The are the functions you call to get or write the filter files
*/
function filter_get() {
! global $username, $FILTERDIR, $FILTERFILE;
!
! $path = vd_replace($FILTERDIR);
!
! if (!file_exists($path)) {
! mkdirs($path,0700);
! }
!
! $file = "$path/$FILTERFILE";
! $localfile = "/tmp/$FILTERFILE.$username";
! if (filter_exists($file)) {
! $command = escapeshellcmd("sudo ../plugins/serversidefilter/script/getrc $file $localfile");
! system($command);
! } else
! touch($localfile);
!
! return $localfile;
}
! function filter_exists() {
! global $FILTERDIR, $FILTERFILE;
!
! $path = vd_replace($FILTERDIR);
!
! $file = "$path/$FILTERFILE";
!
! $command = escapeshellcmd("sudo ../plugins/serversidefilter/script/rcexists $file");
! system($command, $exists);
! if ($exists == 0) {
! return true;
! } else {
! return false;
! }
}
+ // Put the filter file
+
function filter_put($file) {
! global $username, $FILTERDIR, $FILTERFILE, $VIRTUAL_DOMAINS, $SEPERATOR;
!
! $path = vd_replace($FILTERDIR);
!
! $newfile = "$path/$FILTERFILE";
!
! if ($VIRTUAL_DOMAINS) {
! list($user, $domain) = split($SEPERATOR,$username);
! $user = my_virtual_domain_user($domain);
! } else
! $user = $username;
!
! $command = escapeshellcmd("sudo ../plugins/serversidefilter/script/putrc $user $file $newfile");
! system($command);
}
function write_dot_qmail() {
! global $username, $SEPERATOR, $VIRTUAL_DOMAINS, $FILTERDIR, $FILTERFILE, $FILTER_APP_PATH, $DOT_QMAIL_DIR;
$tmpfile = "/tmp/.qmail-$username";
! if ($VIRTUAL_DOMAINS) {
! list($user, $domain) = split($SEPERATOR,$username);
! $user = my_virtual_domain_user($domain);
! $dot_qmail = "$DOT_QMAIL_DIR/.qmail-$user";
! } else {
! $user = $username;
! $dot_qmail = "$DOT_QMAIL_DIR/.qmail";
! }
$fd = fopen($tmpfile,"w");
! $filterpath = vd_replace($FILTERDIR);
$filterfile = "$filterpath/$FILTERFILE";
$contents = "|preline $FILTER_APP_PATH $filterfile\n";
fwrite($fd, $contents);
fclose($fd);
!
! $command = escapeshellcmd("sudo ../plugins/serversidefilter/script/putrc $user $tmpfile $dot_qmail");
! system($command, $exists);
!
}
***************
*** 94,160 ****
*/
- // Get the list of vitual domains
- function my_list_virtual_domains() {
- global $VD_BACKEND;
- $list_vd = $VD_BACKEND.'_list_virtual_domains';
- return $list_vd();
- }
-
// get the owner of a virtual domain
function my_virtual_domain_user($domain) {
! global $VD_BACKEND;
! $vd_user = $VD_BACKEND.'_virtual_domain_user';
return $vd_user($domain);
}
-
- // check to see if the password is saved
- function check_pass($domain){
- global $STORAGE_DIR, $FILE_BACKEND;
-
- $vdomain = preg_replace('/\./','_',$domain);
- $file = "$STORAGE_DIR/$vdomain";
- if (file_exists($file) && is_file($file)) {
- $ckpass = $FILE_BACKEND.'_check_pass';
- $user = my_virtual_domain_user($domain);
- $pass = my_get_domain_passwd($domain);
- return $ckpass($user,$pass);
- } else
- return false;
- }
-
-
- /**
- * This function will return a stored domain password or false if
- * there isn't one.
- *
- * @param $domain a vadmin domain.
- * @return the domain password stored in $domain/passwd, or
- * false if that file is empty.
- */
- function my_get_domain_passwd($domain){
- global $STORAGE_DIR;
-
- $mydomain = preg_replace('/\./','_',$domain);
- $file = "$STORAGE_DIR/$mydomain";
- if (file_exists($file) && is_file($file)) {
- $fd = fopen($file,'r');
- $contents = fread($fd, filesize($file));
- $contents = rtrim($contents);
- $clearpass = my_crypto($contents, 'decrypt');
- return $clearpass;
- } else return false;
- }
-
- // store the domain password to a file
- function my_put_domain_passwd($domain, $clearpass){
- global $STORAGE_DIR;
-
- $file = "$STORAGE_DIR/$domain";
- $fd = fopen($file,'w');
- $encpass = my_crypto($clearpass, 'encrypt');
- fwrite($fd,$encpass);
- fclose($fd);
- }
-
?>
--- 135,143 ----
*/
// get the owner of a virtual domain
function my_virtual_domain_user($domain) {
! $vd_user = 'qmail_virtual_domain_user';
return $vd_user($domain);
}
?>
Index: options.php
===================================================================
RCS file: /cvsroot/serverfilters/options.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** options.php 8 Dec 2003 18:28:03 -0000 1.2
--- options.php 9 Dec 2003 06:50:12 -0000 1.3
***************
*** 174,177 ****
--- 174,178 ----
unlink($file);
+ $value = count($recipies);
displayPageHeader($color, 'None');
?>
***************
*** 182,214 ****
<table width="100%" border=0 cellpadding=1 cellspacing=1>
- <?php
- if (in_array($username, $ADMIN) && $VIRTUAL_DOMAINS && ($FILE_BACKEND == 'ftp')) {
- echo "<tr><td bgcolor=$color[4] align=center><br>";
- echo '<center><a href=admin.php>Admin - Set Domain Passwords</a></center>';
- $vdomains = my_list_virtual_domains();
- $goodpass = true;
- foreach($vdomains as $vdomain) {
- if (!check_pass($vdomain)) {
- echo "<center>" . _("Passwords out of date") . "</center>";
- $goodpass = false;
- break;
- }
- }
- if ($goodpass) echo "<center>" . _("Passwords are all up to date") . "</center>";
- echo "<br></td></tr>";
- }
- ?>
<tr><td bgcolor="<?php echo $color[4] ?>" align=center><br>
<table border=1 frame=void rules=rows noshade=0 bordercolor=<?php echo $color[0]?> cellpadding=5 cellspacing=0>
- <?php
- if ($VIRTUAL_DOMAINS && ($FILE_BACKEND == 'ftp')) {
- list($vuser,$vdomain) = split($SEPERATOR,$username);
- if (!check_pass($vdomain)) {
- echo _("Your domain") . " ($vdomain) " . _("password is out of date. Your administrator will need to correct this before you may setup your mailfilters.");
- exit;
- }
- }
- $value = count($recipies);
- ?>
<tr><td bgcolor="<?php echo $color[4] ?>" align=center colspan=6>
<table border=4 rules=rows noshade=0 bordercolor=<?php echo $color[0]?> cellpadding=5 cellspacing=0>
--- 183,188 ----
Index: recipie_functions.php
===================================================================
RCS file: /cvsroot/serverfilters/recipie_functions.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** recipie_functions.php 8 Dec 2003 18:28:03 -0000 1.2
--- recipie_functions.php 9 Dec 2003 06:50:12 -0000 1.3
***************
*** 162,167 ****
fclose($nf);
! if (isset($CREATE_DOT_QMAIL) && $CREATE_DOT_QMAIL == 1 &&
! $FILE_BACKEND != 'local')
write_dot_qmail();
}
--- 162,166 ----
fclose($nf);
! if (isset($CREATE_DOT_QMAIL) && $CREATE_DOT_QMAIL == 1)
write_dot_qmail();
}
|