# FreeBSD 9.1 incompatible pointer type recompiling Sendmail



## jcd (Dec 14, 2012)

Hi people, I need your help.  I want to enable Sendmail SMTP authentication as indicated in The FreeBSD handbook - 29.10 SMTP Authentication, but the following error is showing

The message is 
	
	



```
cc1: warnings being treated as errors
/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c: In function 'sm_sasl_init':
/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c:141: warning: passing argument 1 of 'sasl_set_alloc' from incompatible pointer type
/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c:141: warning: passing argument 2 of 'sasl_set_alloc' from incompatible pointer type
/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c:141: warning: passing argument 3 of 'sasl_set_alloc' from incompatible pointer type
*** [sasl.o] Error code 1
```
in the following step:

```
#cd /usr/src/usr.sbin/sendmail
# make cleandir && make obj && make && make install
```
I did not incluide the source code during the OS installtion, so I downloaded it from FreeBSD 9.1-RELEASE.

After this failure, unsure of whether the source code is part of the Sendmail port or not, I proceeded to upgrade the ports collection and resintall Sendmail 8.14.5 with[CMD=""]make install clean[/CMD], but the error persists.

Any idea of how to solve this issue?  Should I fill this as a bug?

Thanks a lot.

Juan


----------



## SirDice (Dec 14, 2012)

Everything under /usr/src/ is not a port, it's part of the base OS.

Is there anything in /etc/make.conf and/or /etc/src.conf?


----------



## jcd (Dec 14, 2012)

Thanks SirDice, I understand that /usr/src/ is not a port, what I am unsure of is if the Senmail port (or any port for that matter) updates files in that path when it is installed.

The contents of /etc/make.conf are as follows:

```
SENDMAIL_CFLAGS=-I/usr/local/include/sasl -DSASL
SENDMAIL_LDFLAGS=-L/usr/local/lib
SENDMAIL_LDADD=-lsas12
# added by use.perl 2012-12-13 00:59:57
PERL_VERSION=5.14.2
```
/etc/src.conf does not exist on the system.

Thanks.
Juan


----------



## mmm12 (Dec 15, 2012)

I'm having the same problem after updating the sasl port. Sendmail was crashing saying it can't find the sasl library (Shared object "libsasl2.so.2" not found, required by "sendmail"). It looks like this library is now at "libsasl2.so.3" 

So, I guessed that sendmail needed to be recompiled. Then, it won't recompile as described above. Next I hacked sasl.c to fix the above typo so that it compiles:

changed line 141 in /usr/src/contrib/sendmail/src/sasl.c to:
       sasl_set_alloc((sasl_malloc_t *)sm_sasl_malloc, (sasl_calloc_t *)sm_sasl_calloc,                                                                       
                       (sasl_realloc_t *)sm_sasl_realloc, (sasl_free_t *)sm_sasl_free);                                   

After that, sendmail is still crashing, either with or without SASL enabled.

I'm a little rusty at fixing such things, but it looks like something is broken, either the instructions for installing sasl or the code.


----------



## mmm12 (Dec 18, 2012)

It seems to be working now for me. I'm not sure exactly what caused or fixed my problem:

1) deinstaled cyrus-sasl and cyrus-sasl2-saslauthd
2) commented out all changes made to originally install sasl2 in files: 
     /etc/make.conf
     /etc/mail/sendmail.mc and remade sendmail.cf
3) did a buildworld, boot -s, installworld
4) verified that sendmail without sasl works with a clean unmodified system
5) I tried to use the mail/sendmail-sasl2 port since that seemed to be a better option 
   but it didn't seem to work. There's not a lot of documentation about that port.
6) reinstalled cyrus-sasl and cyrus-sasl2-saslauthd ports
7) restored the original changes to /etc/make.conf and /etc/mail/sendmail.cf
8) recompiled sendmail including the change to line 141 of sasl.c, restarted sendmail
9) now it works again!

Sendmail wouldn't compile without changing line 141 of /usr/src/contrib/sendmail/src/sasl.c as noted in the post above. Perhaps it would compile within buildworld since it might not have the same compile options (-Werror).


----------



## Chronos (Jan 5, 2013)

@mmm12: Are you on i386? I'm having a similar issue with an i386 box that doesn't manifest itself on amd64. Same fixes (I suspect libsm and libmilter need to be recompiled as well) work for me.


----------



## mmm12 (Jan 8, 2013)

Yes, I'm running on i386. I'm not sure what fixed the problem but sendmail has been working fine since.


----------



## oiram (May 25, 2013)

jcd said:
			
		

> The contents of /etc/make.conf are as follows:
> 
> ```
> SENDMAIL_CFLAGS=-I/usr/local/include/sasl -DSASL
> ...



Change it to

```
SENDMAIL_CFLAGS+= -I/usr/local/include/sasl -DSASL -D_FFR_SMTP_SSL
SENDMAIL_LDFLAGS+= -L/usr/local/lib
SENDMAIL_LDADD+= -lsasl2
```
and try again after applying the change mentioned by @mmm12, change in line 141 in /usr/src/contrib/sendmail/src/sasl.c.


----------



## micski (Sep 8, 2013)

Is this still a problem? I also wanted to recompile Sendmail with SSL authentification - and got the same error. However, I can not seem to be able to get passt that error.

`# make`

```
cc -O2 -pipe  -I/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src -I/usr/src/usr.sbin/sendmail/../../contrib/sendmail/include -I. -DNEWDB -DNIS -DTCPWRAPPERS -DMAP_REGEX -DDNSMAP -DNETINET6 -DSTARTTLS -D_FFR_TLS_1 -I/usr/local/include/sasl -DSASL -std=gnu99 -fstack-protector -Wsystem-headers -Werror -Wno-pointer-sign -c /usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c
cc1: warnings being treated as errors
/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c: In function 'sm_sasl_init':
/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c:141: warning: passing argument 1 of 'sasl_set_alloc' from incompatible pointer type
/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c:141: warning: passing argument 2 of 'sasl_set_alloc' from incompatible pointer type
/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c:141: warning: passing argument 3 of 'sasl_set_alloc' from incompatible pointer type
*** Error code 1

Stop in /usr/src/usr.sbin/sendmail.
```


----------



## fonz (Sep 8, 2013)

micski said:
			
		

> ```
> cc1: warnings being treated as errors
> ```


You could try turning that off.


----------



## micski (Sep 8, 2013)

I could not find any information about this in the FreeBSD General Commands Manual about make nor make.conf. The same is the case for the comments in /usr/share/examples/etc/make.conf.

How is the compiler instructed to not treat warnings as compiler stop errors? Is this safe to do?

I would assume, that it can either be given on the command line - or configured permanently in /etc/make.conf.


----------



## micski (Sep 9, 2013)

After reading Google posts about this problem, it seems, that the compiler stops because a special compiler flag Werror is set somewhere in the depths of the source Makefiles or source code files in general. However, I have not been able to locate the flag inspite of recursive searches with grep.

Of course, the source code probably could be fixed, so it does not trigger warnings, but, that might take the skills of a system programmer. I looked at the problem code in /usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c and it seems to be a memory allocation pointer problem.


```
void * sm_sasl_malloc(size) unsigned long size;
{
  return sm_malloc((size_t) size);
}
```

So, it seems to me, that the code, combined with the warning stop flag, makes the compiler stop with the following error message.


```
cc -O2 -pipe  -I/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src -I/usr/src/usr.sbin/sendmail/../../contrib/sendmail/include -I. -DNEWDB -DNIS -DTCPWRAPPERS -DMAP_REGEX -DDNSMAP -DNETINET6 -DSTARTTLS -D_FFR_TLS_1 -I/usr/local/include/sasl -DSASL -std=gnu99 -fstack-protector -Wsystem-headers -Werror -Wno-pointer-sign -c /usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c
cc1: warnings being treated as errors
/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c: In function 'sm_sasl_init':
/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c:141: warning: passing argument 1 of 'sasl_set_alloc' from incompatible pointer type
/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c:141: warning: passing argument 2 of 'sasl_set_alloc' from incompatible pointer type
/usr/src/usr.sbin/sendmail/../../contrib/sendmail/src/sasl.c:141: warning: passing argument 3 of 'sasl_set_alloc' from incompatible pointer type
*** Error code 1

Stop in /usr/src/usr.sbin/sendmail.
```


----------



## fonz (Sep 9, 2013)

micski said:
			
		

> it seems, that the compiler stops because a special compiler flag Werror is set somewhere in the depths of the source Makefiles or source code files in general.


That's correct. The default behaviour is to treat warnings as warnings and errors as errors. To have warnings treated as errors, the -Werror flag has to be set somewhere.



			
				micski said:
			
		

> Of course, the source code probably could be fixed, so it does not trigger warnings, but, that might take the skills of a system programmer.


Correct again, to some extent. However, warnings are more a sign of sloppy and/or non-portable programming than of serious mistakes. That's why they are warnings and don't usually cause compilation to stop, unless the -Werror flag (or one of its relatives) has been set explicitly.

In any case, I can see two leftover questions: where (i.e. in which Makefile) is that flag set and why?

As for the former, it must be either in a Makefile somewhere in the source tree, in /etc/make.conf or in the environment.

As for the latter, C compilers can be really fussy and the -Werror flag should only be used on really clean code (or for diagnostic purposes).

Have you tried updating your source tree? When I try to build Sendmail from source I see plenty of -Wno-* flags but no -Werror. Moreover, I see some warnings that indicate the presence of very old-fashioned (K&R-style) programming. Such programming is not necessarily wrong, but having that kind of code does make it wrong to use -Werror.


----------



## micski (Sep 9, 2013)

I am very sorry: I seemed to have confused myself with the line numbers of sasl.c. I made the changes to sasl.c, as proposed above, and the compiling went through.


----------



## kpa (Sep 9, 2013)

The system sources for FreeBSD are compiled with warnings treated as errors by default. The supported way to turn this behaviour off seems to be these settings in make.conf(5) (from https://wiki.freebsd.org/BuildingFreeBSDWithClang):


```
# This setting to build world without -Werror:
NO_WERROR=
# This setting to build kernel without -Werror:
WERROR=
```


----------



## mix_room (Sep 13, 2013)

I am aware that it might not be the answer you want, but have you tried mail/opensmtpd? I found it to be much easier than Sendmail to work with. 

It does SMTP authentication as well. You might have a look here: http://wiki.defcon.no/guides/opensmtpd#adding_smtps_with_authentication


----------

