postfix_admin 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +54 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +20 -0
- data/CHANGELOG.md +16 -9
- data/Gemfile +1 -1
- data/LICENSE +1 -1
- data/README.md +26 -20
- data/Rakefile +19 -1
- data/bin/console +6 -2
- data/docker-admin/config.local.php +3 -0
- data/docker-app/Dockerfile +2 -6
- data/docker-app/my.cnf +2 -2
- data/docker-compose.yml +18 -14
- data/lib/postfix_admin/admin.rb +5 -0
- data/lib/postfix_admin/alias.rb +0 -19
- data/lib/postfix_admin/base.rb +118 -98
- data/lib/postfix_admin/cli.rb +180 -125
- data/lib/postfix_admin/concerns/dovecot_cram_md5_password.rb +0 -1
- data/lib/postfix_admin/domain.rb +35 -44
- data/lib/postfix_admin/doveadm.rb +4 -8
- data/lib/postfix_admin/mailbox.rb +14 -6
- data/lib/postfix_admin/runner.rb +35 -22
- data/lib/postfix_admin/version.rb +1 -1
- data/postfix_admin.gemspec +12 -10
- metadata +48 -22
- data/.github/workflows/ruby.yml +0 -37
- data/docker-app/docker-entrypoint.sh +0 -5
- data/docker-app-2.5/Dockerfile +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a15e49758d586d12c05d2e0f15f04b123345942d9de889a3617d9cb13ca25bb
|
4
|
+
data.tar.gz: 9b0a5e9d4741ad9dc8562347c4ca63616bddf97b5e20e6669ae7088bbb04bb29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeee12bb7ba7e2d3530878a431f82bfd0c239f64b96225577d46a20e90d60f870a6df73fe96a3dbc02cc69363b380f63976074d8d0e4debd465ae0c014d337a4
|
7
|
+
data.tar.gz: 257ad43dfbb601927501abab85a6ecf8c0c1bc2d353f2bf7f6be93db81a50c6f27eaf685cc9c6386c5c734a0989e3909346e8aa66247dbabb77c1fb66562b40e
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: CI
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches:
|
13
|
+
- main
|
14
|
+
pull_request:
|
15
|
+
branches:
|
16
|
+
- main
|
17
|
+
|
18
|
+
permissions:
|
19
|
+
contents: read
|
20
|
+
|
21
|
+
jobs:
|
22
|
+
test:
|
23
|
+
|
24
|
+
runs-on: ubuntu-latest
|
25
|
+
strategy:
|
26
|
+
matrix:
|
27
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3']
|
28
|
+
|
29
|
+
steps:
|
30
|
+
- uses: actions/checkout@v4
|
31
|
+
- name: Set up Ruby
|
32
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
33
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
34
|
+
uses: ruby/setup-ruby@v1
|
35
|
+
with:
|
36
|
+
ruby-version: ${{ matrix.ruby-version }}
|
37
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
38
|
+
- name: Install dovecotpw
|
39
|
+
run: sudo apt-get install -y dovecot-core
|
40
|
+
- name: Copy configure file
|
41
|
+
run: cp ./test/misc/postfix_admin.conf ~/.postfix_admin.conf
|
42
|
+
- name: Copy my.cnf (for `rake setup_test_db`)
|
43
|
+
run: cp ./test/misc/ci.my.cnf ~/.my.cnf
|
44
|
+
- name: docker-compose up
|
45
|
+
run: docker-compose up -d db
|
46
|
+
- name: Sleep (work around)
|
47
|
+
# wait-for-it.sh doesn't work with docker compose port mapping
|
48
|
+
run: sleep 10
|
49
|
+
- name: Set up test database
|
50
|
+
run: bundle exec rake setup_test_db
|
51
|
+
- name: Run tests
|
52
|
+
run: bundle exec rake test
|
53
|
+
- name: Run specs
|
54
|
+
run: bundle exec rake spec
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,2 +1,22 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: enable
|
1
3
|
Style/StringLiterals:
|
2
4
|
Enabled: false
|
5
|
+
Style/EmptyMethod:
|
6
|
+
Enabled: false
|
7
|
+
Style/IfUnlessModifier:
|
8
|
+
Enabled: false
|
9
|
+
Style/AsciiComments:
|
10
|
+
Enabled: false
|
11
|
+
Style/FrozenStringLiteralComment:
|
12
|
+
Enabled: false
|
13
|
+
Style/Documentation:
|
14
|
+
Enabled: false
|
15
|
+
Metrics/MethodLength:
|
16
|
+
Enabled: false
|
17
|
+
Metrics/AbcSize:
|
18
|
+
Enabled: false
|
19
|
+
Metrics/ClassLength:
|
20
|
+
Enabled: false
|
21
|
+
Style/EmptyElse:
|
22
|
+
EnforcedStyle: empty
|
data/CHANGELOG.md
CHANGED
@@ -1,22 +1,29 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## 0.3.0
|
4
|
+
* Added support for table display format
|
5
|
+
* No longer supports `dovecotpw` for password hash generation
|
6
|
+
+ Only `doveadm pw` is supported
|
7
|
+
|
1
8
|
## 0.2.1
|
2
|
-
*
|
9
|
+
* Added support for the `superadmin` column in the `admin` table
|
3
10
|
* Added `passwordhash_prefix` keyword in the configuration format for backward compatibility
|
4
11
|
|
5
12
|
## 0.2.0
|
6
|
-
* Switched
|
7
|
-
* Stored password
|
13
|
+
* Switched the object-relational mapper from DataMapper to ActiveRecord
|
14
|
+
* Stored password hashes now include scheme prefixes, such as `{CRAM-MD5}` and `{PLAIN}`
|
8
15
|
|
9
16
|
## 0.1.4
|
10
17
|
* Added "log" subcommand
|
11
18
|
|
12
19
|
## 0.1.3
|
13
|
-
*
|
20
|
+
* Added support for activation and deactivation of domains, admins, and accounts
|
14
21
|
* Added "edit_admin" subcommand
|
15
22
|
|
16
23
|
## 0.1.2
|
17
|
-
*
|
18
|
-
*
|
19
|
-
*
|
24
|
+
* Added support for password hashing by doveadm (external subcommand)
|
25
|
+
* Display active status
|
26
|
+
* Hide passwords in list format
|
20
27
|
|
21
|
-
## 0.1.1,
|
22
|
-
* Fixed string length
|
28
|
+
## 0.1.1, released 2013-05-10
|
29
|
+
* Fixed string length issue for passwords
|
data/Gemfile
CHANGED
data/LICENSE
CHANGED
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -10,19 +10,25 @@ Command Line Tools for Postfix Admin
|
|
10
10
|
+ Web Site http://postfixadmin.sourceforge.net/
|
11
11
|
+ GitHub https://github.com/postfixadmin/postfixadmin
|
12
12
|
|
13
|
-
* Postfix Admin 3.2
|
13
|
+
* Supports Postfix Admin 3.2
|
14
14
|
|
15
|
-
* MySQL/MariaDB
|
15
|
+
* Supports MySQL/MariaDB
|
16
16
|
|
17
|
-
* Other database engines are not supported
|
17
|
+
* Other database engines are not supported
|
18
|
+
|
19
|
+
## Requirements
|
20
|
+
|
21
|
+
* Ruby 2.6 or higher
|
22
|
+
* MySQL/MariaDB
|
23
|
+
* Dovecot (required for setting passwords using the `doveadm pw` subcommand)
|
18
24
|
|
19
25
|
## Installation
|
20
26
|
|
21
|
-
Install postfix_admin
|
27
|
+
Install `postfix_admin` using:
|
22
28
|
|
23
29
|
$ gem install postfix_admin
|
24
30
|
|
25
|
-
|
31
|
+
Execute the `postfix_admin` command to generate your config file at `~/.postfix_admin.conf`:
|
26
32
|
|
27
33
|
$ postfix_admin
|
28
34
|
|
@@ -30,40 +36,40 @@ Edit the file for your environment:
|
|
30
36
|
|
31
37
|
$ vi ~/.postfix_admin.conf
|
32
38
|
|
33
|
-
You can see domains on your host if the `database` parameter is set properly:
|
39
|
+
You can see the domains on your host if the `database` parameter is set properly:
|
34
40
|
|
35
41
|
$ postfix_admin show
|
36
42
|
|
37
43
|
## Usage
|
38
44
|
|
39
|
-
List the postfix_admin subcommands
|
45
|
+
List the `postfix_admin` subcommands with:
|
40
46
|
|
41
47
|
$ postfix_admin
|
42
48
|
|
43
49
|
```
|
44
50
|
Commands:
|
45
|
-
postfix_admin account_passwd user@example.com new_password # Change password of account
|
46
|
-
postfix_admin add_account user@example.com password # Add
|
47
|
-
postfix_admin add_admin admin@example.com password # Add
|
48
|
-
postfix_admin add_admin_domain admin@example.com example.com #
|
49
|
-
postfix_admin add_alias alias@example.com goto@example.net # Add
|
50
|
-
postfix_admin add_domain example.com # Add a domain
|
51
|
-
postfix_admin admin_passwd admin@example.com new_password # Change password of admin
|
51
|
+
postfix_admin account_passwd user@example.com new_password # Change the password of an account
|
52
|
+
postfix_admin add_account user@example.com password # Add a new account
|
53
|
+
postfix_admin add_admin admin@example.com password # Add a new admin user
|
54
|
+
postfix_admin add_admin_domain admin@example.com example.com # Grant an admin user access to a specific domain
|
55
|
+
postfix_admin add_alias alias@example.com goto@example.net # Add a new alias
|
56
|
+
postfix_admin add_domain example.com # Add a new domain
|
57
|
+
postfix_admin admin_passwd admin@example.com new_password # Change the password of an admin user
|
52
58
|
postfix_admin delete_account user@example.com # Delete an account
|
53
|
-
postfix_admin delete_admin admin@example.com # Delete an admin
|
54
|
-
postfix_admin delete_admin_domain admin@example.com example.com #
|
59
|
+
postfix_admin delete_admin admin@example.com # Delete an admin user
|
60
|
+
postfix_admin delete_admin_domain admin@example.com example.com # Revoke an admin user's access to a specific domain
|
55
61
|
postfix_admin delete_alias alias@example.com # Delete an alias
|
56
62
|
postfix_admin delete_domain example.com # Delete a domain
|
57
63
|
postfix_admin dump # Dump all data
|
58
64
|
postfix_admin edit_account user@example.com # Edit an account
|
59
65
|
postfix_admin edit_admin admin@example.com # Edit an admin user
|
60
66
|
postfix_admin edit_alias alias@example.com # Edit an alias
|
61
|
-
postfix_admin edit_domain example.com # Edit a domain
|
67
|
+
postfix_admin edit_domain example.com # Edit a domain
|
62
68
|
postfix_admin help [COMMAND] # Describe available commands or one specific command
|
63
|
-
postfix_admin log #
|
69
|
+
postfix_admin log # Display action logs
|
64
70
|
postfix_admin schemes # List all supported password schemes
|
65
|
-
postfix_admin setup example.com password #
|
66
|
-
postfix_admin show [example.com | admin@example.com | user@example.com] #
|
71
|
+
postfix_admin setup example.com password # Set up a domain
|
72
|
+
postfix_admin show [example.com | admin@example.com | user@example.com] # Display details about domains, admins, or accounts
|
67
73
|
postfix_admin summary [example.com] # Summarize the usage of PostfixAdmin
|
68
74
|
postfix_admin version # Show postfix_admin version
|
69
75
|
```
|
data/Rakefile
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
2
3
|
require "rspec/core/rake_task"
|
3
4
|
|
5
|
+
Rake::TestTask.new(:test) do |t|
|
6
|
+
t.libs << "test"
|
7
|
+
t.libs << "lib"
|
8
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
9
|
+
end
|
10
|
+
|
4
11
|
RSpec::Core::RakeTask.new(:spec)
|
5
12
|
|
6
|
-
task default: :
|
13
|
+
task default: :test
|
14
|
+
|
15
|
+
desc "Set up test database"
|
16
|
+
task :setup_test_db do
|
17
|
+
create_db_cmd = "mysql -e 'CREATE DATABASE `postfix_test`;'"
|
18
|
+
puts create_db_cmd
|
19
|
+
puts `#{create_db_cmd}`
|
20
|
+
|
21
|
+
import_db_cmd = "mysql postfix_test < docker-db/postfix.v1841.sql"
|
22
|
+
puts import_db_cmd
|
23
|
+
puts `#{import_db_cmd}`
|
24
|
+
end
|
data/bin/console
CHANGED
@@ -1,16 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "bundler/setup"
|
4
|
+
Bundler.require(:default, :development)
|
4
5
|
require "postfix_admin"
|
5
6
|
require "postfix_admin/cli"
|
6
7
|
|
7
8
|
# You can add fixtures and/or initialization code here to make experimenting
|
8
9
|
# with your gem easier. You can also use a different console, if you like.
|
9
10
|
|
10
|
-
cli = PostfixAdmin::CLI.new
|
11
|
-
cli.db_setup
|
11
|
+
@cli = PostfixAdmin::CLI.new
|
12
|
+
@cli.db_setup
|
12
13
|
include PostfixAdmin
|
13
14
|
|
15
|
+
include FactoryBot::Syntax::Methods
|
16
|
+
FactoryBot.find_definitions
|
17
|
+
|
14
18
|
require "pry"
|
15
19
|
Pry.start
|
16
20
|
|
@@ -16,6 +16,9 @@ $CONF['password_validation'] = array(
|
|
16
16
|
|
17
17
|
$CONF['encrypt'] = 'dovecot:CRAM-MD5';
|
18
18
|
|
19
|
+
$CONF['domain_quota'] = 'NO';
|
20
|
+
$CONF['quota'] = 'YES';
|
21
|
+
|
19
22
|
// setup_password: 'password'
|
20
23
|
$CONF['setup_password'] = '87745eb0269b2f42813b23601be3231a:6e41880f73d97321f2f0b25a5ee30f57f5ab3be8';
|
21
24
|
?>
|
data/docker-app/Dockerfile
CHANGED
@@ -9,7 +9,7 @@ WORKDIR /app
|
|
9
9
|
COPY Gemfile postfix_admin.gemspec ./
|
10
10
|
COPY ./lib/postfix_admin/version.rb ./lib/postfix_admin/version.rb
|
11
11
|
|
12
|
-
RUN gem install bundler && bundle install
|
12
|
+
RUN gem install bundler -v 2.4.22 && bundle install
|
13
13
|
|
14
14
|
COPY spec/postfix_admin.conf /root/.postfix_admin.conf
|
15
15
|
COPY docker-app/my.cnf /root/.my.cnf
|
@@ -18,8 +18,4 @@ COPY docker-app/my.cnf /root/.my.cnf
|
|
18
18
|
RUN curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -so /wait-for-it.sh && \
|
19
19
|
chmod 755 /wait-for-it.sh
|
20
20
|
|
21
|
-
|
22
|
-
RUN chmod +x /docker-entrypoint.sh
|
23
|
-
ENTRYPOINT ["/docker-entrypoint.sh"]
|
24
|
-
|
25
|
-
CMD ["irb"]
|
21
|
+
CMD ["irb"]
|
data/docker-app/my.cnf
CHANGED
data/docker-compose.yml
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
-
|
1
|
+
# docker compose up -d
|
2
|
+
#
|
3
|
+
# Run tests on service app
|
4
|
+
# You may need to run tests on Docker because of its requirement of doveadm
|
5
|
+
# docker compose exec app bundle exec rake setup_test_db
|
6
|
+
# docker compose exec app bundle exec rake test
|
7
|
+
# docker compose exec app bundle exec rake spec
|
2
8
|
|
3
9
|
services:
|
4
10
|
app:
|
@@ -6,17 +12,10 @@ services:
|
|
6
12
|
context: .
|
7
13
|
dockerfile: docker-app/Dockerfile
|
8
14
|
tty: true
|
9
|
-
volumes:
|
10
|
-
- .:/app
|
11
|
-
depends_on:
|
12
|
-
- db
|
13
|
-
app2.5:
|
14
|
-
tty: true
|
15
|
-
build:
|
16
|
-
context: .
|
17
|
-
dockerfile: docker-app-2.5/Dockerfile
|
18
15
|
volumes:
|
19
16
|
- .:/app
|
17
|
+
environment:
|
18
|
+
- DATABASE_URL=mysql2://postfix:password@db/postfix
|
20
19
|
depends_on:
|
21
20
|
- db
|
22
21
|
admin:
|
@@ -35,12 +34,17 @@ services:
|
|
35
34
|
# - POSTFIXADMIN_DB_NAME=postfix
|
36
35
|
db:
|
37
36
|
image: mariadb:10
|
37
|
+
ports:
|
38
|
+
- "13306:3306"
|
38
39
|
volumes:
|
39
|
-
|
40
|
-
|
41
|
-
#
|
40
|
+
- db-data:/var/lib/mysql
|
41
|
+
- ./docker-db/postfix.v1841.sql:/docker-entrypoint-initdb.d/postfix.sql
|
42
|
+
# - ./docker-db/postfix.v740.sql:/docker-entrypoint-initdb.d/postfix.sql
|
43
|
+
# - ./docker-db/postfix.v352.sql:/docker-entrypoint-initdb.d/postfix.sql
|
42
44
|
environment:
|
43
|
-
-
|
45
|
+
- MYSQL_ROOT_PASSWORD=ScRgkaMz4YwHN5dyxfQj
|
44
46
|
- MYSQL_USER=postfix
|
45
47
|
- MYSQL_PASSWORD=password
|
46
48
|
- MYSQL_DATABASE=postfix
|
49
|
+
volumes:
|
50
|
+
db-data:
|
data/lib/postfix_admin/admin.rb
CHANGED
data/lib/postfix_admin/alias.rb
CHANGED
@@ -24,30 +24,11 @@ module PostfixAdmin
|
|
24
24
|
scope :pure, -> { joins("LEFT OUTER JOIN mailbox ON alias.address = mailbox.username").where("mailbox.username" => nil) }
|
25
25
|
|
26
26
|
attribute :local_part, :string
|
27
|
-
attr_writer :forward_addresses
|
28
|
-
|
29
|
-
def forward_addresses
|
30
|
-
if @forward_addresses.nil?
|
31
|
-
if goto.nil?
|
32
|
-
[nil]
|
33
|
-
else
|
34
|
-
goto.split(",") + [nil]
|
35
|
-
end
|
36
|
-
else
|
37
|
-
@forward_addresses
|
38
|
-
end
|
39
|
-
end
|
40
27
|
|
41
28
|
before_validation do |a|
|
42
29
|
unless a.address
|
43
30
|
a.address = "#{a.local_part}@#{a.domain}" unless a.local_part.empty?
|
44
31
|
end
|
45
|
-
|
46
|
-
unless a.forward_addresses.empty?
|
47
|
-
forward_addresses = a.forward_addresses.dup
|
48
|
-
forward_addresses.delete_if { |f| f.blank? }
|
49
|
-
a.goto = forward_addresses.join(",")
|
50
|
-
end
|
51
32
|
end
|
52
33
|
|
53
34
|
def mailbox?
|