2002-09-24 20:53:45 +02:00
|
|
|
package Qpsmtpd::Utils;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
sub tildeexp {
|
2014-09-10 22:43:46 +02:00
|
|
|
my ($self, $path) = @_;
|
2002-09-24 20:53:45 +02:00
|
|
|
$path =~ s{^~([^/]*)} {
|
2014-09-10 22:43:46 +02:00
|
|
|
$1
|
2002-09-24 20:53:45 +02:00
|
|
|
? (getpwnam($1))[7]
|
|
|
|
: ( $ENV{HOME} || $ENV{LOGDIR} || (getpwuid($>))[7])
|
|
|
|
}ex;
|
|
|
|
return $path;
|
|
|
|
}
|
|
|
|
|
2014-09-10 22:43:46 +02:00
|
|
|
sub is_localhost {
|
|
|
|
my ($self, $ip) = @_;
|
|
|
|
return if ! $ip;
|
|
|
|
return 1 if $ip =~ /^127\./; # IPv4
|
|
|
|
return 1 if $ip =~ /:127\./; # IPv4 mapped IPv6
|
|
|
|
return 1 if $ip eq '::1'; # IPv6
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-09-24 20:53:45 +02:00
|
|
|
1;
|