postfix_admin 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a83f945f0f977fc80b8715b899af26d908b3d6b1169d27fae9cf92089bac5082
4
- data.tar.gz: f8f63116ece1064079b99f986fc26778c4f4affc28ae8dbd3beca3496a595186
3
+ metadata.gz: 8a15e49758d586d12c05d2e0f15f04b123345942d9de889a3617d9cb13ca25bb
4
+ data.tar.gz: 9b0a5e9d4741ad9dc8562347c4ca63616bddf97b5e20e6669ae7088bbb04bb29
5
5
  SHA512:
6
- metadata.gz: 22f7cc6d351d3a7e63ba95e653ac21f4b1eeebaebb5a717810477ab0d700dbb3199eeee042ca34909aee1c959bb7d27fe705d1c332895e7bb38ae0cc1f3e9120
7
- data.tar.gz: 821bb8bac75277e3faf303f1db8292256cc9bbcf40cb2de6f63f9c3c38e40f84c5739849edc159ddec8bf262d9fa9e5ea8f9bac15e8dce37f2691f0a017e2772
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
@@ -17,3 +17,5 @@ test/version_tmp
17
17
  tmp
18
18
  .idea
19
19
  .vagrant
20
+ .ruby-version
21
+ .rspec_status
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,18 +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
+
8
+ ## 0.2.1
9
+ * Added support for the `superadmin` column in the `admin` table
10
+ * Added `passwordhash_prefix` keyword in the configuration format for backward compatibility
11
+
1
12
  ## 0.2.0
2
- * Switched its object-relational mapper from DataMapper to ActiveRecord
3
- * Stored password hash includes scheme prefix: like `{CRAM-MD5}`, `{PLAIN}`
13
+ * Switched the object-relational mapper from DataMapper to ActiveRecord
14
+ * Stored password hashes now include scheme prefixes, such as `{CRAM-MD5}` and `{PLAIN}`
4
15
 
5
16
  ## 0.1.4
6
17
  * Added "log" subcommand
7
18
 
8
19
  ## 0.1.3
9
- * Support for activation and deactivation of domain, admin and account
20
+ * Added support for activation and deactivation of domains, admins, and accounts
10
21
  * Added "edit_admin" subcommand
11
22
 
12
23
  ## 0.1.2
13
- * Support password hash by doveadm (external subcommand)
14
- * Show active status
15
- * Don't show passwords using list format
24
+ * Added support for password hashing by doveadm (external subcommand)
25
+ * Display active status
26
+ * Hide passwords in list format
16
27
 
17
- ## 0.1.1, release 2013-05-10
18
- * Fixed string length of password
28
+ ## 0.1.1, released 2013-05-10
29
+ * Fixed string length issue for passwords
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in postfix_admin.gemspec
4
4
  gemspec
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 is supported.
13
+ * Supports Postfix Admin 3.2
14
14
 
15
- * MySQL/MariaDB is supported.
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 as:
27
+ Install `postfix_admin` using:
22
28
 
23
29
  $ gem install postfix_admin
24
30
 
25
- Just execute `postfix_admin` command to generate your config file: `~/.postfix_admin.conf`
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 as:
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 an account
47
- postfix_admin add_admin admin@example.com password # Add an admin user
48
- postfix_admin add_admin_domain admin@example.com example.com # Add admin_domain
49
- postfix_admin add_alias alias@example.com goto@example.net # Add an alias
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 # Delete admin_domain
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 limitation
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 # Show action logs
69
+ postfix_admin log # Display action logs
64
70
  postfix_admin schemes # List all supported password schemes
65
- postfix_admin setup example.com password # Setup a domain
66
- postfix_admin show [example.com | admin@example.com | user@example.com] # Show domains or admins or mailboxes
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: :spec
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
 
@@ -0,0 +1,6 @@
1
+ FROM postfixadmin:3.2.4-apache
2
+
3
+ RUN apt-get update && \
4
+ apt-get install -y dovecot-core iproute2 mariadb-client && \
5
+ rm -rf /var/lib/apt/lists/*
6
+
@@ -0,0 +1,24 @@
1
+ <?php
2
+ $CONF['configured'] = true;
3
+
4
+ $CONF['database_type'] = 'mysqli';
5
+ $CONF['database_user'] = 'postfix';
6
+ $CONF['database_password'] = 'password';
7
+ $CONF['database_name'] = 'postfix';
8
+ $CONF['database_host'] = 'db';
9
+
10
+ $CONF['password_validation'] = array(
11
+ # '/regular expression/' => '$PALANG key (optional: + parameter)',
12
+ '/.{5}/' => 'password_too_short 5', # minimum length 5 characters
13
+ '/([a-zA-Z].*){3}/' => 'password_no_characters 3', # must contain at least 3 characters
14
+ // '/([0-9].*){2}/' => 'password_no_digits 2', # must contain at least 2 digits
15
+ );
16
+
17
+ $CONF['encrypt'] = 'dovecot:CRAM-MD5';
18
+
19
+ $CONF['domain_quota'] = 'NO';
20
+ $CONF['quota'] = 'YES';
21
+
22
+ // setup_password: 'password'
23
+ $CONF['setup_password'] = '87745eb0269b2f42813b23601be3231a:6e41880f73d97321f2f0b25a5ee30f57f5ab3be8';
24
+ ?>
@@ -0,0 +1,21 @@
1
+ FROM ruby:2.6
2
+
3
+ RUN apt-get update && \
4
+ apt-get install -y dovecot-core iproute2 mariadb-client && \
5
+ rm -rf /var/lib/apt/lists/*
6
+
7
+ WORKDIR /app
8
+
9
+ COPY Gemfile postfix_admin.gemspec ./
10
+ COPY ./lib/postfix_admin/version.rb ./lib/postfix_admin/version.rb
11
+
12
+ RUN gem install bundler -v 2.4.22 && bundle install
13
+
14
+ COPY spec/postfix_admin.conf /root/.postfix_admin.conf
15
+ COPY docker-app/my.cnf /root/.my.cnf
16
+
17
+ # for GitHub Actions
18
+ RUN curl https://raw.githubusercontent.com/vishnubob/wait-for-it/master/wait-for-it.sh -so /wait-for-it.sh && \
19
+ chmod 755 /wait-for-it.sh
20
+
21
+ CMD ["irb"]
data/docker-app/my.cnf ADDED
@@ -0,0 +1,5 @@
1
+ [client]
2
+ user = root
3
+ password = ScRgkaMz4YwHN5dyxfQj
4
+ host = db
5
+ database = postfix
data/docker-compose.yml CHANGED
@@ -1,24 +1,50 @@
1
- version: '3.8'
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:
5
- build: .
11
+ build:
12
+ context: .
13
+ dockerfile: docker-app/Dockerfile
6
14
  tty: true
15
+ volumes:
16
+ - .:/app
17
+ environment:
18
+ - DATABASE_URL=mysql2://postfix:password@db/postfix
19
+ depends_on:
20
+ - db
21
+ admin:
22
+ build: docker-admin
7
23
  ports:
8
- - '7080:80'
24
+ - '8080:80'
9
25
  volumes:
10
- - .:/app
11
- - /sys/fs/cgroup:/sys/fs/cgroup:ro
12
- tmpfs:
13
- - /tmp
14
- - /run
15
- stop_signal: SIGRTMIN+3
26
+ - ./docker-admin/config.local.php:/var/www/html/config.local.php
27
+ depends_on:
28
+ - db
29
+ # environment:
30
+ # - POSTFIXADMIN_DB_TYPE=mysqli
31
+ # - POSTFIXADMIN_DB_HOST=db
32
+ # - POSTFIXADMIN_DB_USER=postfix
33
+ # - POSTFIXADMIN_DB_PASSWORD=password
34
+ # - POSTFIXADMIN_DB_NAME=postfix
16
35
  db:
17
36
  image: mariadb:10
37
+ ports:
38
+ - "13306:3306"
18
39
  volumes:
19
- - ./spec/postfix.v1841.sql:/docker-entrypoint-initdb.d/postfix.sql
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
20
44
  environment:
21
- - MYSQL_RANDOM_ROOT_PASSWORD=yes
45
+ - MYSQL_ROOT_PASSWORD=ScRgkaMz4YwHN5dyxfQj
22
46
  - MYSQL_USER=postfix
23
47
  - MYSQL_PASSWORD=password
24
48
  - MYSQL_DATABASE=postfix
49
+ volumes:
50
+ db-data: