masqmail

diff src/masqmail.c @ 262:fc1c6425c024

s/EXIT_SUCCESS/0/ && s/EXIT_FAILURE/1/ The constants are all to bulky. We should have different, meaningful exit codes anyway.
author markus schnalke <meillo@marmaro.de>
date Thu, 02 Dec 2010 17:11:25 -0300
parents 0afe18a9ee03
children e9e73505ab2c
line diff
     1.1 --- a/src/masqmail.c	Thu Dec 02 16:52:39 2010 -0300
     1.2 +++ b/src/masqmail.c	Thu Dec 02 17:11:25 2010 -0300
     1.3 @@ -138,17 +138,17 @@
     1.4  	if (!conf.run_as_user) {
     1.5  		if ((conf.orig_uid != 0) && (conf.orig_uid != conf.mail_uid)) {
     1.6  			fprintf(stderr, "must be root or %s for daemon.\n", DEF_MAIL_USER);
     1.7 -			exit(EXIT_FAILURE);
     1.8 +			exit(1);
     1.9  		}
    1.10  	}
    1.11  
    1.12  	/* reparent to init only if init is not already the parent */
    1.13  	if (getppid() != 1) {
    1.14  		if ((pid = fork()) > 0) {
    1.15 -			exit(EXIT_SUCCESS);
    1.16 +			exit(0);
    1.17  		} else if (pid < 0) {
    1.18  			logwrite(LOG_ALERT, "could not fork!\n");
    1.19 -			exit(EXIT_FAILURE);
    1.20 +			exit(1);
    1.21  		}
    1.22  	}
    1.23  
    1.24 @@ -193,7 +193,7 @@
    1.25  	if (getpeername(0, (struct sockaddr *) (&saddr), &dummy) == 0) {
    1.26  		peername = g_strdup(inet_ntoa(saddr.sin_addr));
    1.27  	} else if (errno != ENOTSOCK)
    1.28 -		exit(EXIT_FAILURE);
    1.29 +		exit(1);
    1.30  
    1.31  	smtp_in(stdin, stderr, peername, NULL);
    1.32  }
    1.33 @@ -208,7 +208,7 @@
    1.34  
    1.35  	if (return_path && !is_privileged_user(conf.orig_uid)) {
    1.36  		fprintf(stderr, "must be root, %s or in group %s for setting return path.\n", DEF_MAIL_USER, DEF_MAIL_GROUP);
    1.37 -		exit(EXIT_FAILURE);
    1.38 +		exit(1);
    1.39  	}
    1.40  
    1.41  	if (!conf.run_as_user) {
    1.42 @@ -224,7 +224,7 @@
    1.43  			msg->rcpt_list = g_list_append(msg->rcpt_list, create_address_qualified(addresses[i], TRUE, conf.host_name));
    1.44  		else {
    1.45  			logwrite(LOG_ALERT, "no pipe allowed as recipient address: %s\n", addresses[i]);
    1.46 -			exit(EXIT_FAILURE);
    1.47 +			exit(1);
    1.48  		}
    1.49  	}
    1.50  
    1.51 @@ -246,34 +246,34 @@
    1.52  					fclose(stdout);
    1.53  					fclose(stderr);
    1.54  					if (deliver(msg)) {
    1.55 -						exit(EXIT_SUCCESS);
    1.56 +						exit(0);
    1.57  					} else
    1.58 -						exit(EXIT_FAILURE);
    1.59 +						exit(1);
    1.60  				} else if (pid < 0) {
    1.61  					logwrite(LOG_ALERT, "could not fork for delivery, id = %s\n", msg->uid);
    1.62  				}
    1.63  			}
    1.64  		} else {
    1.65  			fprintf(stderr, "Could not write spool file\n");
    1.66 -			exit(EXIT_FAILURE);
    1.67 +			exit(1);
    1.68  		}
    1.69  	} else {
    1.70  		switch (err) {
    1.71  		case AERR_EOF:
    1.72  			fprintf(stderr, "unexpected EOF.\n");
    1.73 -			exit(EXIT_FAILURE);
    1.74 +			exit(1);
    1.75  		case AERR_NORCPT:
    1.76  			fprintf(stderr, "no recipients.\n");
    1.77 -			exit(EXIT_FAILURE);
    1.78 +			exit(1);
    1.79  		case AERR_SIZE:
    1.80  			fprintf(stderr, "max message size exceeded.\n");
    1.81 -			exit(EXIT_FAILURE);
    1.82 +			exit(1);
    1.83  		default:
    1.84  			/* should never happen: */
    1.85  			fprintf(stderr, "Unknown error (%d)\r\n", err);
    1.86 -			exit(EXIT_FAILURE);
    1.87 +			exit(1);
    1.88  		}
    1.89 -		exit(EXIT_FAILURE);
    1.90 +		exit(1);
    1.91  	}
    1.92  }
    1.93  
    1.94 @@ -399,7 +399,7 @@
    1.95  	gchar *M_cmd = NULL;
    1.96  	gboolean opt_t = FALSE;
    1.97  	gboolean opt_i = FALSE;
    1.98 -	gint exit_code = EXIT_SUCCESS;
    1.99 +	gint exit_code = 0;
   1.100  	gchar *conf_file = CONF_FILE;
   1.101  	gchar *route_name = NULL;
   1.102  	gchar *f_address = NULL;
   1.103 @@ -464,18 +464,18 @@
   1.104  			conf_file = get_optarg(argv, &arg, opt+1);
   1.105  			if (!conf_file) {
   1.106  				fprintf(stderr, "-C requires a filename as argument.\n");
   1.107 -				exit(EXIT_FAILURE);
   1.108 +				exit(1);
   1.109  			}
   1.110  
   1.111  		} else if (strncmp(opt, "d", 1) == 0) {
   1.112  			if (getuid() != 0) {
   1.113  				fprintf(stderr, "only root may set the debug level.\n");
   1.114 -				exit(EXIT_FAILURE);
   1.115 +				exit(1);
   1.116  			}
   1.117  			char *lvl = get_optarg(argv, &arg, opt+1);
   1.118  			if (!lvl) {
   1.119  				fprintf(stderr, "-d requires a number argument.\n");
   1.120 -				exit(EXIT_FAILURE);
   1.121 +				exit(1);
   1.122  			}
   1.123  			debug_level = atoi(lvl);
   1.124  
   1.125 @@ -484,7 +484,7 @@
   1.126  			gchar *address = get_optarg(argv, &arg, opt+1);
   1.127  			if (!address) {
   1.128  				fprintf(stderr, "-f requires an address argument\n");
   1.129 -				exit(EXIT_FAILURE);
   1.130 +				exit(1);
   1.131  			}
   1.132  			f_address = g_strdup(address);
   1.133  
   1.134 @@ -492,7 +492,7 @@
   1.135  			full_sender_name = get_optarg(argv, &arg, opt+1);
   1.136  			if (!full_sender_name) {
   1.137  				fprintf(stderr, "-F requires a name argument\n");
   1.138 -				exit(EXIT_FAILURE);
   1.139 +				exit(1);
   1.140  			}
   1.141  
   1.142  		} else if (strcmp(opt, "i") == 0) {
   1.143 @@ -542,7 +542,7 @@
   1.144  
   1.145  		} else {
   1.146  			fprintf(stderr, "unrecognized option `-%s'\n", opt);
   1.147 -			exit(EXIT_FAILURE);
   1.148 +			exit(1);
   1.149  		}
   1.150  	}
   1.151  
   1.152 @@ -552,7 +552,7 @@
   1.153  
   1.154  	if (mta_mode == MODE_VERSION) {
   1.155  		mode_version();
   1.156 -		exit(EXIT_SUCCESS);
   1.157 +		exit(0);
   1.158  	}
   1.159  
   1.160  	/* initialize random generator */
   1.161 @@ -619,17 +619,17 @@
   1.162  	if (!conf.run_as_user) {
   1.163  		if (setgid(0) != 0) {
   1.164  			fprintf(stderr, "could not set gid to 0. Is the setuid bit set? : %s\n", strerror(errno));
   1.165 -			exit(EXIT_FAILURE);
   1.166 +			exit(1);
   1.167  		}
   1.168  		if (setuid(0) != 0) {
   1.169  			fprintf(stderr, "could not gain root privileges. Is the setuid bit set? : %s\n", strerror(errno));
   1.170 -			exit(EXIT_FAILURE);
   1.171 +			exit(1);
   1.172  		}
   1.173  	}
   1.174  
   1.175  	if (!logopen()) {
   1.176  		fprintf(stderr, "could not open log file\n");
   1.177 -		exit(EXIT_FAILURE);
   1.178 +		exit(1);
   1.179  	}
   1.180  
   1.181  	DEBUG(1) debugf("masqmail %s starting\n", VERSION);
   1.182 @@ -649,7 +649,7 @@
   1.183  		g_free(f_address);
   1.184  		if (!return_path) {
   1.185  			fprintf(stderr, "invalid RFC821 address: %s\n", f_address);
   1.186 -			exit(EXIT_FAILURE);
   1.187 +			exit(1);
   1.188  		}
   1.189  	}
   1.190  
   1.191 @@ -671,7 +671,7 @@
   1.192  		break;
   1.193  
   1.194  	case MODE_BI:
   1.195 -		exit(EXIT_SUCCESS);
   1.196 +		exit(0);
   1.197  		break;  /* well... */
   1.198  
   1.199  	case MODE_MCMD: