hostname in aliases.db

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

hostname in aliases.db

Marat Khalili
I've got the following problem which is not critical but still
interesting. I'm cloning an LXC container which optionally can contain
postfix installation. After cloning the filesystem there's a number of
places I need to change the hostname in.

I used grep to search for these places and unexpectedly found mentioning
of hostname in /etc/aliases.db, even though /etc/aliases does not
include it. Thus I wonder if I need to re-generate /etc/aliases.db and
how can I do it without actually starting container?

I can run `newaliases -oAhash:/container/rootfs/etc/aliases` from host,
but then there's a name of the host system in aliases.db, not
container's. I can also re-generate it from within a container after
starting it and then reload postfix, but it is kludgy. Is there some
better way?


--

With Best Regards,
Marat Khalili
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: hostname in aliases.db

/dev/rob0
On Sat, Aug 05, 2017 at 07:11:08PM +0300, Marat Khalili wrote:
> I'm cloning an LXC container which optionally can contain postfix
> installation. After cloning the filesystem there's a number of
> places I need to change the hostname in.
>
> I used grep to search for these places and unexpectedly found
> mentioning of hostname in /etc/aliases.db, even though /etc/aliases
> does not include it.

Is this an actual problem?  Also, I wonder why you'd need multiple
containers with Postfix installs?  Did you consider possibly using a
null client like msmtp, if all these containers need to do is send
mail through a relayhost?

> Thus I wonder if I need to re-generate /etc/aliases.db and how can
> I do it without actually starting container?

You might indeed want to generate your aliases.db for each container,
and chroot(1) might be a means to do that.

> I can run `newaliases -oAhash:/container/rootfs/etc/aliases` from
> host, but then there's a name of the host system in aliases.db,
> not container's.

See also postalias(1), but I'm still not sure that this is a real
problem.  Does something in the container not work properly with
host-generated aliases.db?

> I can also re-generate it from within a container after starting
> it and then reload postfix, but it is kludgy. Is there some better
> way?

The better way would probably be to simplify your mail
infrastructure, using null clients where appropriate.

I have nothing against containerizing Postfix nor running it in
virtual machines, but unless your organization is very huge you do
not need more than 1-2 MX hosts and perhaps a per-site MSA (which
often can coexist on the submission port with MX instances.)
--
  http://rob0.nodns4.us/
  Offlist GMX mail is seen only if "/dev/rob0" is in the Subject:
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: hostname in aliases.db

Marat Khalili
> You might indeed want to generate your aliases.db for each container,
> and chroot(1) might be a means to do that.
Completely forgot about chroot, much better than starting whole container.


> See also postalias(1), but I'm still not sure that this is a real
> problem.  Does something in the container not work properly with
> host-generated aliases.db?
That's what I'd like to know to, is this hostname mention even being
used? Testing one particular container is not sufficient since I might
run into problems with some other container later, after I end scripting it.


> The better way would probably be to simplify your mail
> infrastructure, using null clients where appropriate.
>
> I have nothing against containerizing Postfix nor running it in
> virtual machines, but unless your organization is very huge you do
> not need more than 1-2 MX hosts and perhaps a per-site MSA (which
> often can coexist on the submission port with MX instances.)
Completely agree. It is mostly a problem of having a hammer and seeing
everything as a nail: I'm also not happy about having many full-blown
postfix instances, but it works and learning something requires an
effort. Is msmtp the recommended tool for doing this or just one of the
many out there?


--

With Best Regards,
Marat Khalili

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: hostname in aliases.db

/dev/rob0
On Sat, Aug 05, 2017 at 07:58:19PM +0300, Marat Khalili wrote:
> > See also postalias(1), but I'm still not sure that this is a
> > real problem.  Does something in the container not work
> > properly with host-generated aliases.db?
>
> That's what I'd like to know to, is this hostname mention even
> being used?

I doubt it is, but I am too lazy / busy to test. :)  You could also
consult your Berkeley DB documentation.

I do know that Postfix simply queries it for the localpart in a
localpart@domain, where domain is in $mydestination.  Metadata in
aliases.db is not queried.

> Testing one particular container is not sufficient since I might
> run into problems with some other container later, after I end
> scripting it.
>
>
> > The better way would probably be to simplify your mail
> > infrastructure, using null clients where appropriate.
> >
> > I have nothing against containerizing Postfix nor running it
> > in virtual machines, but unless your organization is very huge
> > you do not need more than 1-2 MX hosts and perhaps a per-site
> > MSA (which often can coexist on the submission port with MX
> > instances.)
>
> Completely agree. It is mostly a problem of having a hammer and
> seeing everything as a nail: I'm also not happy about having many
> full-blown postfix instances, but it works and learning something
> requires an effort.

Hehe, okay. :)

> Is msmtp the recommended tool for doing this or just one of the
> many out there?

There are several, and I am unable specifically to recommend one
against the others, because I'm like you.  I have this hammer, and
when I need to do something involving sending mail, I just use
Postfix. ;)
--
  http://rob0.nodns4.us/
  Offlist GMX mail is seen only if "/dev/rob0" is in the Subject:
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: hostname in aliases.db

Marat Khalili
On 05/08/17 21:30, /dev/rob0 wrote:
> On Sat, Aug 05, 2017 at 07:58:19PM +0300, Marat Khalili wrote:
>> That's what I'd like to know to, is this hostname mention even
>> being used?
> I doubt it is, but I am too lazy / busy to test. :)  You could also
> consult your Berkeley DB documentation.
>
> I do know that Postfix simply queries it for the localpart in a
> localpart@domain, where domain is in $mydestination.  Metadata in
> aliases.db is not queried.

Well, I looked it bit more into it and it quickly became exercise in
software archaeology. That's what I found out:

1) It's not metadata, it's data associated with key 'YP_MASTER_NAME'.

2) It was present in sendmail and used by NIS:
https://books.google.ru/books?id=NQblqMiVqvQC&pg=PT152&lpg=PT152&dq=YP_MASTER_NAME 
.

3) It was added to postfix in 1999 as documented in HISTORY:

> 19990325
>
>         Workaround: Solaris NIS alias maps need special entries
>         (YP_MASTER_NAME, YP_LAST_MODIFIED). What's worse, normal
>         keys/values include a null byte at the end, but the YP_XXX
>         ones don't. Problem reported by Walcir Fontanini, state
>         university of Campinas, Brazil.  File: postalias/postalias.c.

4) Finally, it is currently set in postalias.c but never used indeed.

Final results: no need to change it, but if necessary it can be changed
with newaliases under chroot (tested this), directly with some Berkeley
DB tool (since it is just one known key-value pair), or specified in
makedbm command-line. Also, this problem is not even new: see
https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.nis/nis_movmastserv.htm

Thank you for the help, it was an interesting excursion for me.

--

With Best Regards,
Marat Khalili
Loading...