Skip to content

Commit

Permalink
Merge branch 'master' into michaelkrieger-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGoodwin committed Jan 11, 2024
2 parents 978a5cf + 78bf7b7 commit eda637d
Show file tree
Hide file tree
Showing 543 changed files with 15,087 additions and 40,026 deletions.
89 changes: 75 additions & 14 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,94 @@ name: GitHubBuild
on: [push]

jobs:
build:
lint_etc:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2

runs-on: ubuntu-latest
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
tools: composer
extensions: sqlite3

steps:
- uses: actions/checkout@v1
- name: run install.sh
run: /bin/bash install.sh

- name: Validate composer.json and composer.lock
- name: check composer
run: composer validate

- name: setup templates_c
run: mkdir templates_c || true
# Needing to 'update' here isn't ideal, but we need to cope with tests that run under different PHP versions :-/
- name: Install dependencies
run: composer update --prefer-dist -n

- name: check formatting
run: composer check-format

- name: touch config.local.php
run: touch config.local.php

- name: psalm static analysis
run: composer psalm

testsuite:
needs: [lint_etc]
runs-on: ubuntu-22.04
strategy:
matrix:
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]

steps:
- uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
tools: composer
extensons: sqlite3

- name: run install.sh
run: /bin/bash install.sh

- name: touch config.local.php
run: touch config.local.php && php -v

- name: Install dependencies
run: composer install --prefer-dist --no-progress --no-suggest
run: composer install --prefer-dist -n

- name: Build/test
run: composer build
run: composer test

build_coverage_report:
needs: [testsuite]
continue-on-error: true
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2

- name: setup coveralls
run: mkdir -p build/logs || true
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
tools: composer
extensions: sqlite3

- name: run install.sh
run: /bin/bash install.sh

- name: touch config.local.php
run: touch config.local.php && php -v

- name: Install dependencies
run: composer update --prefer-dist -n

- name: build coveralls coverage
run: php -d xdebug.mode=coverage vendor/bin/phpunit tests

- name: Coveralls
run: php vendor/bin/php-coveralls -v --coverage_clover=coverage.xml || true
run: vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v || true
env:
COVERALLS_RUN_LOCALLY: 1
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
/config.local.php
/templates_c/*.tpl.php
/templates_c/*menu.conf.php
/vendor/
/.php_cs.cache
/.idea
/vendor
/composer.lock
/coverage
/composer.phar
/composer_2.phar
/.php-cs-fixer.cache
/.phpunit.result.cache
/build
/tests/postfixadmin.sqlite.*.test
/phpstorm-docker-dev/
9 changes: 4 additions & 5 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
->files()->notName('config.inc.php')->notName('config.local.php')
->in(__DIR__);

return PhpCsFixer\Config::create()
$config = new PhpCsFixer\Config();

return $config
->setFinder($finder)
->setRules(array(
'@PSR2' => true,
'braces' => array(
'position_after_functions_and_oop_constructs' => 'same',
),
'@PSR12' => true,
'method_argument_space' => false, # don't break formatting in initStruct()
'no_spaces_inside_parenthesis' => false, # don't break formatting in initStruct()
));
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ php:
- 7.2
- 7.3
- 7.4
- 8.0

services:
- mysql
Expand Down
45 changes: 31 additions & 14 deletions ADDITIONS/README.TXT → ADDITIONS/README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,69 @@
#
# Postfix Admin ADDITIONS
#

BEFORE YOU START
----------------
# BEFORE YOU START


**** ALL THESE SCRIPTS ARE CREATED BY THIRD PARTIES ****
**** THEY ARE AS IS, USE AT YOUR OWN RISK! ****

ADDITIONS
---------
# ADDITIONS

In this directory you will find additional scripts that are build by others.

- change_password.tgz
## change_password.tgz

by George Vieira <george at citadelcomputer dot com dot au>
SquirrelMail plugin to change your passwor

- cleanupdirs.pl
## cleanupdirs.pl

by jared bell <jared at beol dot net>
Displays a list of mailboxes that need to be deleted

- mailbox_remover.pl
## mailbox_remover.pl

by Petr Znojemsky
Deletes all unused mailboxes

- mkeveryone.pl
## mkeveryone.pl

by Joshua Preston
Generate an 'everybody' alias for a domain.

- pfa_maildir_cleanup.pl
## pfa_maildir_cleanup.pl
by Stephen Fulton <sfulton at esoteric dot ca>
Deletes all unused mailboxes

- postfixadmin-0.3-1.4.tar.gz
## postfixadmin-0.3-1.4.tar.gz

by Florian Kimmerl <info at spacekoeln dot de>

The Postfixadmin SquirrelMail plugin let users change their virtual alias,
vacation status/message and password.

- virtualmaildel.php
See also : https://github.com/postfixadmin/postfixadmin/tree/master/ADDITIONS/squirrelmail-plugin


## virtualmaildel.php

by George Vieira <george at citadelcomputer dot com dot au>
Deletes all unused mailboxes

## Example mailbox / domain scripts for Postfixadmin

- postfixadmin-mailbox-postcreation.sh
- postfixadmin-mailbox-postdeletion.sh
- postfixadmin-domain-postdeletion.sh
by Troels Arvin <troels@arvin.dk>

Examples of scripts relevant to the optional


$CONF['mailbox_postcreation_script'],
$CONF['mailbox_postdeletion_script'] and
$CONF['domain_postdeletion_script'] configuration options.


## Cyrus Quota Usage

See https://github.com/o-m-d/cyrus-quotausage-to-pfa

22 changes: 17 additions & 5 deletions ADDITIONS/fetchmail.pl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
our $db_password="CHANGE_ME!";

# Where to create a lockfile; please ensure path exists.
our $run_dir="/var/run/fetchmail";
our $run_dir="/var/lock/fetchmail";

# in case you want to use dovecot deliver to put the mail directly into the users mailbox,
# set "mda" in the fetchmail table to the keyword "dovecot".
Expand All @@ -54,6 +54,18 @@ sub log_and_die {
die $message;
}

sub escape_password {
$output = "";
for $i (0..length($_[0])-1){
$char = substr($_[0], $i, 1);
if ($char eq "\\" or $char eq "\"")
{
$output = $output . "\\";
}
$output = $output . $char;
}
return $output;
}
# read options and arguments

$configfile = "/etc/fetchmail-all/config";
Expand Down Expand Up @@ -98,18 +110,18 @@ sub log_and_die {
}

$sql = "
SELECT id,mailbox,src_server,src_auth,src_user,src_password,src_folder,fetchall,keep,protocol,mda,extra_options,usessl, sslcertck, sslcertpath, sslfingerprint
SELECT id,mailbox,src_server,src_auth,src_user,src_password,src_folder,fetchall,keep,protocol,mda,extra_options,usessl, sslcertck, sslcertpath, sslfingerprint, src_port
FROM fetchmail
WHERE $sql_cond > poll_time*60
";

my (%config);
map{
my ($id,$mailbox,$src_server,$src_auth,$src_user,$src_password,$src_folder,$fetchall,$keep,$protocol,$mda,$extra_options,$usessl,$sslcertck,$sslcertpath,$sslfingerprint)=@$_;
my ($id,$mailbox,$src_server,$src_auth,$src_user,$src_password,$src_folder,$fetchall,$keep,$protocol,$mda,$extra_options,$usessl,$sslcertck,$sslcertpath,$sslfingerprint,$src_port)=@$_;

syslog("info","fetch ${src_user}@${src_server} for ${mailbox}");

$cmd="user '${src_user}' there with password '".decode_base64($src_password)."'";
$cmd="user '${src_user}' there with password '".escape_password(decode_base64($src_password))."'";
$cmd.=" folder '${src_folder}'" if ($src_folder);

if ($mda) {
Expand Down Expand Up @@ -148,7 +160,7 @@ sub log_and_die {
print $file_handler $text;
close $file_handler;

$ret=`/usr/bin/fetchmail -f $filename -i $run_dir/fetchmail.pid`;
$ret=`/usr/bin/fetchmail -f $filename --pidfile $run_dir/fetchmail.pid`;

unlink $filename;

Expand Down
2 changes: 1 addition & 1 deletion ADDITIONS/mailbox_remover.pl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
close(TOUCH);
print "Archiving $maildir\n";
@args = ($archcmd, "cvzf", $archive, $maildir);
system(@args) == 0 or die "Creating archive for $maildir failed: $?"
system(@args) == 0 or die "Creating archive for $maildir failed: $?";

rmtree($maildir);
print localtime() . " $maildir has been deleted.\n";
Expand Down
2 changes: 1 addition & 1 deletion ADDITIONS/postfixadmin-domain-postdeletion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# "somedomain.com". If $basedir/somedomain.com exists, it will
# be removed.

# The script will not actually delete the directory. I moves it
# The script will not actually delete the directory. It moves it
# to a special directory which may once in a while be cleaned up
# by the system administrator.

Expand Down
2 changes: 1 addition & 1 deletion ADDITIONS/postfixadmin-mailbox-postdeletion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# The script looks at arguments 1 and 2, assuming that they
# indicate username and domain, respectively.

# The script will not actually delete the maildir. I moves it
# The script will not actually delete the maildir. It moves it
# to a special directory which may once in a while be cleaned up
# by the system administrator.

Expand Down
19 changes: 19 additions & 0 deletions ADDITIONS/postfixadmin-mailbox-postpassword.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Example script for dovecot mail-crypt-plugin
# https://doc.dovecot.org/configuration_manual/mail_crypt_plugin/

IFS= read -r -d $'\0' OLD_PASSWORD
IFS= read -r -d $'\0' NEW_PASSWORD

# New user
if [ -z "$OLD_PASSWORD" ]; then
OLD_PASSWORD="$(openssl rand -hex 16)"
doveadm -o plugin/mail_crypt_private_password="$OLD_PASSWORD" mailbox cryptokey generate -u "$1" -U
fi

# If you're using dovecot >= 2.3.19, try this instead (See: https://github.com/postfixadmin/postfixadmin/issues/646)
# printf "%s\n%s\n" "$OLD_PASSWORD" "$NEW_PASSWORD" "$NEW_PASSWORD" | doveadm mailbox cryptokey password -u "$1" -N -O

# Password change
printf "%s\n%s\n" "$OLD_PASSWORD" "$NEW_PASSWORD" | doveadm mailbox cryptokey password -u "$1" -N -O ""
10 changes: 5 additions & 5 deletions ADDITIONS/quota_usage.pl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ sub list_quota_usage {
$usage = $usage + 500;
$usage = int $usage / 1000;
}
if($insert_db == 1){execSql("UPDATE mailbox set quota_usage = $usage, quota_usage_date = CAST(NOW() AS DATE) WHERE username = '$email'");}

if($insert_db == 1)
{
execSql("INSERT INTO quota2 (username, bytes) values ('$email', $usage) ON DUPLICATE KEY UPDATE bytes = VALUES(bytes)");
}
print_list() if ($list == 1);

}
Expand Down Expand Up @@ -144,8 +148,4 @@ sub help {
print "$0 [options...]\n";
print "-l|--list List quota used\n";
print "-i|--addmysql For insert quota used in database mysql\n";
}
1 change: 1 addition & 0 deletions ADDITIONS/squirrelmail-plugin/common.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

// vim:ts=4:sw=4:et
ini_set('include_path', get_include_path() . ':' . dirname(__FILE__));

Expand Down

0 comments on commit eda637d

Please sign in to comment.