Skip to content

Return error code on failure #14

@Syed-Shahrukh-OSSRevival

Description

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=611504

% sendmail -t -i -fReturn-Path: /dev/null@alea.gnuu.de
sendmail: recipients with -t option not supported
% echo $?
0

The call above is wrong, I know, but ssmtp doesn't tell so via exit code
which makes the caller, e.g. PHP, think everything was fine. This is not
good. Ssmtp should return with an exit code different from zero.

This function on handling error exit with success 0.

void paq(char *format, ...)
{
	va_list ap;   

	va_start(ap, format);
	(void)vfprintf(stderr, format, ap);
	va_end(ap);

	exit(0);
}

Define error codes for all instance of paq usage.
example:


typedef enum error_code {
NO_RCPT  //No recipients supplied - mail will not be sent,
RCPT_MINUS_T //recipients with -t option not supported,
...
} error_code_t 

enum of error code with change in the function.

void paq(error_code_t error_code, char *format, ...) 
{
	va_list ap;   

	va_start(ap, format);
	(void)vfprintf(stderr, format, ap);
	va_end(ap);

	exit(error_code);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions