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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70bd18f454fd77684ab652949e36829f6d9e3e8e275e475819b60b025b3fea6e
4
- data.tar.gz: 477da494d685bcaeb45f090d92edbfb1abc6af811e04172a4e4f1865b51eac46
3
+ metadata.gz: 8a15e49758d586d12c05d2e0f15f04b123345942d9de889a3617d9cb13ca25bb
4
+ data.tar.gz: 9b0a5e9d4741ad9dc8562347c4ca63616bddf97b5e20e6669ae7088bbb04bb29
5
5
  SHA512:
6
- metadata.gz: a7b8c5f69e4f15589ca5c10250e88d9dfb76e623bed02548161e24c29fca02e74e97b154bf5f876936922e7b7d134f4fb6f46ab2e85765198fbaf5c7dddb1c32
7
- data.tar.gz: 777b1af93896c8df8a4eab31af493af872a694502cab871c0ea99bcf7e8a82ce014228e82b117c37a3c9953ec86bd54648a01954c2bcae72c373fca94d1c18dc
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,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
- * Supported `superadmin` column of `admin` table
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 its object-relational mapper from DataMapper to ActiveRecord
7
- * 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}`
8
15
 
9
16
  ## 0.1.4
10
17
  * Added "log" subcommand
11
18
 
12
19
  ## 0.1.3
13
- * Support for activation and deactivation of domain, admin and account
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
- * Support password hash by doveadm (external subcommand)
18
- * Show active status
19
- * 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
20
27
 
21
- ## 0.1.1, release 2013-05-10
22
- * 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
 
@@ -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
  ?>
@@ -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
- COPY docker-app/docker-entrypoint.sh /docker-entrypoint.sh
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
@@ -1,5 +1,5 @@
1
1
  [client]
2
- user = postfix
3
- password = password
2
+ user = root
3
+ password = ScRgkaMz4YwHN5dyxfQj
4
4
  host = db
5
5
  database = postfix
data/docker-compose.yml CHANGED
@@ -1,4 +1,10 @@
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:
@@ -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
- - ./docker-db/postfix.v1841.sql:/docker-entrypoint-initdb.d/postfix.sql
40
- # - ./docker-db/postfix.v740.sql:/docker-entrypoint-initdb.d/postfix.sql
41
- # - ./docker-db/postfix.v352.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
42
44
  environment:
43
- - MYSQL_RANDOM_ROOT_PASSWORD=yes
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:
@@ -22,6 +22,11 @@ module PostfixAdmin
22
22
  admin.errors.add(:username, 'cannot be changed') if admin.username_changed?
23
23
  end
24
24
 
25
+ def reload
26
+ @super_admin = nil
27
+ super
28
+ end
29
+
25
30
  def super_admin?
26
31
  if @super_admin.nil?
27
32
  @super_admin = if has_superadmin_column?
@@ -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?