[GH-ISSUE #818] Import of aliases broken #732

Closed
opened 2026-02-27 11:13:16 +03:00 by kerem · 9 comments
Owner

Originally created by @ddt-consult on GitHub (Dec 17, 2015).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/818

The import of aliases into modoboa 1.4.2 is broken.
If I try to import one domain with one account and one alias pointing to this account into a fresh installation of modoboa (see CSV files below), the import of the identities fails with "Local recipient not found".
AFAIKT in Alias.set_recipients() modoboa checks whether the target for an alias already exists in the DB. If that's not the case, it checks whether the target is itlself another alias. If that's not the case either, it raises an exception instead of creating the target.
Just for testing I commented lines 133-139 in alias.py, i. e.

                    # if rcpt is None:
                    #     raise NotFound(
                    #         _("Local recipient {}@{} not found")
                    #         .format(local_part, domname)
                    #     )
                    # if rcpt.address == self.address:
                    #     raise Conflict

and the import of my identities file succeeded.

domains.csv:
domain;ddt-consult.de;100000;True

identities.csv:
account;admin@ddt-consult.de;{SHA512-CRYPT}$6$rounds=70000$yOfLHTrqigEMkPlW$.6Oq0b1bmcrfk8OcuDNzZYbOEVVgkcmrnPH3Mmqwyg6qlBjxVbRX7fGwxWUqYsimYxnGABXME4Ba8xt.1KaTK/;;;True;DomainAdmins;admin@ddt-consult.de;100000;ddt-consult.de alias;abuse@ddt-consult.de;True;admin@ddt-consult.de

Originally created by @ddt-consult on GitHub (Dec 17, 2015). Original GitHub issue: https://github.com/modoboa/modoboa/issues/818 The import of aliases into modoboa 1.4.2 is broken. If I try to import one domain with one account and one alias pointing to this account into a fresh installation of modoboa (see CSV files below), the import of the identities fails with "Local recipient not found". AFAIKT in Alias.set_recipients() modoboa checks whether the target for an alias already exists in the DB. If that's not the case, it checks whether the target is itlself another alias. If that's not the case either, it raises an exception instead of creating the target. Just for testing I commented lines 133-139 in alias.py, i. e. ``` python # if rcpt is None: # raise NotFound( # _("Local recipient {}@{} not found") # .format(local_part, domname) # ) # if rcpt.address == self.address: # raise Conflict ``` and the import of my identities file succeeded. domains.csv: `domain;ddt-consult.de;100000;True` identities.csv: `account;admin@ddt-consult.de;{SHA512-CRYPT}$6$rounds=70000$yOfLHTrqigEMkPlW$.6Oq0b1bmcrfk8OcuDNzZYbOEVVgkcmrnPH3Mmqwyg6qlBjxVbRX7fGwxWUqYsimYxnGABXME4Ba8xt.1KaTK/;;;True;DomainAdmins;admin@ddt-consult.de;100000;ddt-consult.de alias;abuse@ddt-consult.de;True;admin@ddt-consult.de`
kerem 2026-02-27 11:13:16 +03:00
Author
Owner

@tonioo commented on GitHub (Jan 5, 2016):

Hi,
I can't reproduce your issue with 1.4.2. Are you importing from the CLI or from the interface ?

<!-- gh-comment-id:168922015 --> @tonioo commented on GitHub (Jan 5, 2016): Hi, I can't reproduce your issue with 1.4.2. Are you importing from the CLI or from the interface ?
Author
Owner

@ddt-consult commented on GitHub (Jan 12, 2016):

From the command line.

If you just copied the identities.csv above from this webpage, the linefeed between the account and the alias line may get eaten. Then you would have just one line in the CSV and only the account would get created but not the alias (which triggers the error).

BTW: that's the traceback I get when I try to import this identities.csv:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
    utility.execute()
  File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute
    output = self.handle(*args, **options)
  File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/modoboa/admin/management/commands/import_identities.py", line 34, in handle
    import_csv(filename, kwargs)
  File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/modoboa/admin/management/commands/_import.py", line 43, in import_csv
    fct(superadmin, row, options)
  File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/modoboa/admin/lib.py", line 147, in import_alias
    _import_alias(user, row, expected_elements=4)
  File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/modoboa/admin/lib.py", line 143, in _import_alias
    alias.from_csv(user, row, **kwargs)
  File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/modoboa/admin/models/alias.py", line 177, in from_csv
    self.set_recipients([raddress.strip() for raddress in row[3:]])
  File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/modoboa/admin/models/alias.py", line 134, in set_recipients
    .format(local_part, domname)
modoboa.lib.exceptions.NotFound: Local recipient admin@ddt-consult.de not found
<!-- gh-comment-id:170876387 --> @ddt-consult commented on GitHub (Jan 12, 2016): From the command line. If you just copied the identities.csv above from this webpage, the linefeed between the account and the alias line may get eaten. Then you would have just one line in the CSV and only the account would get created but not the alias (which triggers the error). BTW: that's the traceback I get when I try to import this identities.csv: ``` Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line utility.execute() File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 346, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 394, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 445, in execute output = self.handle(*args, **options) File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/modoboa/admin/management/commands/import_identities.py", line 34, in handle import_csv(filename, kwargs) File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/modoboa/admin/management/commands/_import.py", line 43, in import_csv fct(superadmin, row, options) File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/modoboa/admin/lib.py", line 147, in import_alias _import_alias(user, row, expected_elements=4) File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/modoboa/admin/lib.py", line 143, in _import_alias alias.from_csv(user, row, **kwargs) File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/modoboa/admin/models/alias.py", line 177, in from_csv self.set_recipients([raddress.strip() for raddress in row[3:]]) File "/usr/local/share/modoboa-1.4.2/venv/local/lib/python2.7/site-packages/modoboa/admin/models/alias.py", line 134, in set_recipients .format(local_part, domname) modoboa.lib.exceptions.NotFound: Local recipient admin@ddt-consult.de not found ```
Author
Owner

@tonioo commented on GitHub (Jan 18, 2016):

I still can't reproduce it. Which database do you use ? Have you made modifications to your settings file ?

<!-- gh-comment-id:172454976 --> @tonioo commented on GitHub (Jan 18, 2016): I still can't reproduce it. Which database do you use ? Have you made modifications to your settings file ?
Author
Owner

@ddt-consult commented on GitHub (Jan 18, 2016):

DB: MySQL.
Of course I have made modifications to settings.py: ALLOWED_HOSTS, LANGUAGE_CODE, ...

<!-- gh-comment-id:172456559 --> @ddt-consult commented on GitHub (Jan 18, 2016): DB: MySQL. Of course I have made modifications to settings.py: ALLOWED_HOSTS, LANGUAGE_CODE, ...
Author
Owner

@tonioo commented on GitHub (Jan 18, 2016):

Would it be easy for you to check the behaviour using a postgresql database ?

<!-- gh-comment-id:172484138 --> @tonioo commented on GitHub (Jan 18, 2016): Would it be easy for you to check the behaviour using a postgresql database ?
Author
Owner

@tonioo commented on GitHub (Jan 27, 2016):

@ddt-consult ping

<!-- gh-comment-id:175685974 --> @tonioo commented on GitHub (Jan 27, 2016): @ddt-consult ping
Author
Owner

@dirtyhillbilly commented on GitHub (Oct 3, 2020):

I have the same problem. The misleading part is that when an identity is created, the associated mailbox is not.

<!-- gh-comment-id:703097628 --> @dirtyhillbilly commented on GitHub (Oct 3, 2020): I have the same problem. The misleading part is that when an identity is created, the associated mailbox is not.
Author
Owner

@tonioo commented on GitHub (Oct 5, 2020):

@dirtyhillbilly Can you provide the file you used for import?

<!-- gh-comment-id:703440969 --> @tonioo commented on GitHub (Oct 5, 2020): @dirtyhillbilly Can you provide the file you used for import?
Author
Owner

@dirtyhillbilly commented on GitHub (Oct 6, 2020):

The file I used lacked the "address" part, thus creating the account didn't create the mailbox.
Things like that work as expected :

account;xxx@foo.net;{SHA512-CRYPT}$6$rounds=70000$fybLy/WWfW.I/fx3$yR2zDgcN549pE7EJelnYYuXA/TLO.m53ssk/eiajieVQF7/E5B3hAyD6456sdGf3KvxZuEhQ1aQfZOzaB1407.;firstname;lastname;SimpleUser;True;xxx@foo.net
<!-- gh-comment-id:704085182 --> @dirtyhillbilly commented on GitHub (Oct 6, 2020): The file I used lacked the "address" part, thus creating the account didn't create the mailbox. Things like that work as expected : ``` account;xxx@foo.net;{SHA512-CRYPT}$6$rounds=70000$fybLy/WWfW.I/fx3$yR2zDgcN549pE7EJelnYYuXA/TLO.m53ssk/eiajieVQF7/E5B3hAyD6456sdGf3KvxZuEhQ1aQfZOzaB1407.;firstname;lastname;SimpleUser;True;xxx@foo.net ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#732
No description provided.