Skip to content

Commit

Permalink
Fix proftpd
Browse files Browse the repository at this point in the history
  • Loading branch information
swelljoe committed Jul 22, 2017
1 parent ed88d74 commit 27318a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions lib/Virtualmin/Config/Plugin/ProFTPd.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ our $config_directory;
our (%gconfig, %miniserv);
our $trust_unknown_referers = 1;

my $log = Log::Log4perl->get_logger("virtualmin-config-system");

sub new {
my $class = shift;

Expand Down Expand Up @@ -35,23 +37,24 @@ sub actions {
eval {
foreign_require("init", "init-lib.pl");
init::enable_at_boot("proftpd");
foreign_require("proftpd", "proftpd-lib.pl");
my $conf = proftpd::get_config();
if ($gconfig{'os_type'} eq 'freebsd') {

# This directory is missing on FreeBSD
make_dir("/var/run/proftpd", oct(755));
}

# UseIPv6 doesn't work on FreeBSD
foreign_require("proftpd", "proftpd-lib.pl");
my $conf = proftpd::get_config();
proftpd::save_directive("UseIPv6", [], $conf, $conf);
# UseIPv6 doesn't work on FreeBSD
proftpd::save_directive("UseIPv6", [], $conf, $conf);
}

# Create a virtualmin.conf file and Include it
# Debian has /etc/proftpd/conf.d, CentOS we create it.
my $config_directory = "/etc/proftpd/conf.d";
if (!-d $config_directory) {
$log->info('/etc/proftpd/conf.d missing. Creating it.');
use File::Path 'make_path';
make_path($config_directory, {mode => '0755'});
make_path($config_directory, {mode => oct(755)});
}

# Where are certs and keys stored?
Expand All @@ -65,19 +68,20 @@ sub actions {
$keyfile = '/etc/pki/tls/private/proftpd.pem';
}
else {
log->warn("No configuration available for OS type $gconfig{'os_type'}.");
$log->warn("No configuration available for OS type $gconfig{'os_type'}.");
die "Skipping additional ProFTPd configuration for this OS.";
}

# Add to end of file, if not already there Include /etc/proftpd/conf.d
save_directive('Include', '/etc/proftpd/conf.d', $conf, $conf);
proftpd::save_directive('Include', '/etc/proftpd/conf.d', $conf, $conf);

# generate TLS cert/key pair
my $hostname = `hostname -f`;
my $org = "Certificate Generated by Virtualmin for $hostname";

$log->info('Generating a self-signed certificate for TLS.');
$self->logsystem(
"openssl req -new -x509 -nodes -out $certfile -keyout $keyfile \
-subj '/C=NA/ST=NA/L=NA/O=$org/CN=$hostname'"
"openssl req -new -x509 -nodes -out $certfile -keyout $keyfile -subj '/C=NA/ST=NA/L=NA/O=$org/CN=$hostname'"
);

# Generate ssh key pairs
Expand Down
2 changes: 1 addition & 1 deletion virtualmin-config.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: virtualmin-config
Version: 6.0.7
Release: 1
Release: 2
Summary: Collection of plugins to initialize the configuration of services that Virtualmin manages, and a command line tool called init-system to run them
License: GPL+
Group: Development/Libraries
Expand Down

0 comments on commit 27318a6

Please sign in to comment.