changeset 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
files src/child.c src/conf.c src/connect.c src/fail_msg.c src/listen.c src/local.c src/masqmail.c src/online.c src/permissions.c src/smtpsend.c
diffstat 10 files changed, 53 insertions(+), 53 deletions(-) [+]
line wrap: on
line diff
--- a/src/child.c	Thu Dec 02 16:52:39 2010 -0300
+++ b/src/child.c	Thu Dec 02 17:11:25 2010 -0300
@@ -54,7 +54,7 @@
 				execve(*argv, argv, NULL);
 			}
 			logwrite(LOG_ALERT, "execve failed: %s\n", strerror(errno));
-			_exit(EXIT_FAILURE);
+			_exit(1);
 		} else if (pid == -1) {
 			return -1;
 		} else {
--- a/src/conf.c	Thu Dec 02 16:52:39 2010 -0300
+++ b/src/conf.c	Thu Dec 02 17:11:25 2010 -0300
@@ -39,13 +39,13 @@
 		conf.mail_uid = passwd->pw_uid;
 	else {
 		fprintf(stderr, "user %s not found! (terminating)\n", DEF_MAIL_USER);
-		exit(EXIT_FAILURE);
+		exit(1);
 	}
 	if ((group = getgrnam(DEF_MAIL_GROUP)))
 		conf.mail_gid = group->gr_gid;
 	else {
 		fprintf(stderr, "group %s not found! (terminating)\n", DEF_MAIL_GROUP);
-		exit(EXIT_FAILURE);
+		exit(1);
 	}
 }
 
@@ -79,7 +79,7 @@
 	}
 
 	fprintf(stderr, "cannot parse value '%s'\n", rval);
-	exit(EXIT_FAILURE);
+	exit(1);
 }
 
 /* make a list from each line in a file */
@@ -91,7 +91,7 @@
 
 	if ((fptr = fopen(fname, "rt")) == NULL) {
 		logwrite(LOG_ALERT, "could not open %s for reading: %s\n", fname, strerror(errno));
-		exit(EXIT_FAILURE);
+		exit(1);
 	}
 
 	gchar buf[256];
@@ -185,7 +185,7 @@
 #endif
 		} else {
 			logwrite(LOG_ALERT, "unknown resolver %s\n", item);
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 		g_free(item);
 	}
@@ -240,7 +240,7 @@
 
 	if ((addr.s_addr = inet_addr(buf)) == INADDR_NONE) {
 		fprintf(stderr, "'%s' is not a valid address (must be ip)\n", buf);
-		exit(EXIT_FAILURE);
+		exit(1);
 	}
 
 	if (*p) {
@@ -251,7 +251,7 @@
 			n = i ? ~((1 << (32 - i)) - 1) : 0;
 		else {
 			fprintf(stderr, "'%d' is not a valid net mask (must be >= 0 and <= 32)\n", i);
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 	} else
 		n = 0;
--- a/src/connect.c	Thu Dec 02 16:52:39 2010 -0300
+++ b/src/connect.c	Thu Dec 02 17:11:25 2010 -0300
@@ -110,7 +110,7 @@
 
 	if (res_func_list == NULL) {
 		logwrite(LOG_ALERT, "res_funcs == NULL !!!\n");
-		exit(EXIT_FAILURE);
+		exit(1);
 	}
 
 	foreach(res_func_list, res_node) {
@@ -120,7 +120,7 @@
 
 		if (res_func == NULL) {
 			logwrite(LOG_ALERT, "res_func == NULL !!!\n");
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 
 		errno = 0;
--- a/src/fail_msg.c	Thu Dec 02 16:52:39 2010 -0300
+++ b/src/fail_msg.c	Thu Dec 02 17:11:25 2010 -0300
@@ -100,8 +100,8 @@
 
 				fclose(out);
 				waitpid(pid, &status, 0);
-				if ((WEXITSTATUS(status) != EXIT_SUCCESS) || WIFSIGNALED(status)) {
-					if (WEXITSTATUS(status) != EXIT_SUCCESS)
+				if ((WEXITSTATUS(status) != 0) || WIFSIGNALED(status)) {
+					if (WEXITSTATUS(status) != 0)
 						logwrite(LOG_WARNING, "child returned %d\n", WEXITSTATUS(status));
 					if (WIFSIGNALED(status))
 						logwrite(LOG_WARNING, "child got signal: %d\n", WTERMSIG(status));
--- a/src/listen.c	Thu Dec 02 16:52:39 2010 -0300
+++ b/src/listen.c	Thu Dec 02 17:11:25 2010 -0300
@@ -38,7 +38,7 @@
 
 	pid = waitpid(0, &status, 0);
 	if (pid > 0) {
-		if (WEXITSTATUS(status) != EXIT_SUCCESS)
+		if (WEXITSTATUS(status) != 0)
 			logwrite(LOG_WARNING, "process %d exited with %d\n", pid, WEXITSTATUS(status));
 		if (WIFSIGNALED(status))
 			logwrite(LOG_WARNING, "process with pid %d got signal: %d\n", pid, WTERMSIG(status));
@@ -79,7 +79,7 @@
 
 		smtp_in(in, out, rem_host, ident);
 
-		_exit(EXIT_SUCCESS);
+		_exit(0);
 	} else if (pid < 0) {
 		logwrite(LOG_WARNING, "could not fork for incoming smtp connection: %s\n", strerror(errno));
 	}
@@ -118,7 +118,7 @@
 		}
 		if (listen(sock, 1) < 0) {
 			logwrite(LOG_ALERT, "listen: (terminating): %s\n", strerror(errno));
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 		logwrite(LOG_NOTICE, "listening on interface %s:%d\n", iface->address, iface->port);
 		DEBUG(5) debugf("sock = %d\n", sock);
@@ -133,11 +133,11 @@
 	if (!conf.run_as_user) {
 		if (setegid(conf.mail_gid) != 0) {
 			logwrite(LOG_ALERT, "could not change gid to %d: %s\n", conf.mail_gid, strerror(errno));
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 		if (seteuid(conf.mail_uid) != 0) {
 			logwrite(LOG_ALERT, "could not change uid to %d: %s\n", conf.mail_uid, strerror(errno));
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 	}
 
@@ -173,7 +173,7 @@
 		if ((sel_ret = select(FD_SETSIZE, &read_fd_set, NULL, NULL, qival > 0 ? &tm : NULL)) < 0) {
 			if (errno != EINTR) {
 				logwrite(LOG_ALERT, "select: (terminating): %s\n", strerror(errno));
-				exit(EXIT_FAILURE);
+				exit(1);
 			} else {
 				if (sighup_seen) {
 					logwrite(LOG_NOTICE, "HUP signal received. Restarting daemon\n");
@@ -184,7 +184,7 @@
 
 					execv(argv[0], &(argv[0]));
 					logwrite(LOG_ALERT, "restarting failed: %s\n", strerror(errno));
-					exit(EXIT_FAILURE);
+					exit(1);
 				}
 			}
 		} else if (sel_ret > 0) {
@@ -208,7 +208,7 @@
 			if ((pid = fork()) == 0) {
 				queue_run();
 
-				_exit(EXIT_SUCCESS);
+				_exit(0);
 			} else if (pid < 0) {
 				logwrite(LOG_ALERT, "could not fork for queue run");
 			}
--- a/src/local.c	Thu Dec 02 16:52:39 2010 -0300
+++ b/src/local.c	Thu Dec 02 17:11:25 2010 -0300
@@ -132,7 +132,7 @@
 				logwrite(LOG_ALERT, "could not set back uid or gid after local delivery: %s\n", strerror(errno));
 				logwrite(LOG_ALERT, "uid=%d, gid=%d, euid=%d, egid=%d, want = %d, %d\n",
 				         getuid(), getgid(), geteuid(), getegid(), saved_uid, saved_gid);
-				exit(EXIT_FAILURE);
+				exit(1);
 			}
 		} else {
 			logwrite(LOG_ALERT, "could not set uid or gid for local delivery, uid = %d: %s\n", pw->pw_uid, strerror(errno));
--- a/src/masqmail.c	Thu Dec 02 16:52:39 2010 -0300
+++ b/src/masqmail.c	Thu Dec 02 17:11:25 2010 -0300
@@ -138,17 +138,17 @@
 	if (!conf.run_as_user) {
 		if ((conf.orig_uid != 0) && (conf.orig_uid != conf.mail_uid)) {
 			fprintf(stderr, "must be root or %s for daemon.\n", DEF_MAIL_USER);
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 	}
 
 	/* reparent to init only if init is not already the parent */
 	if (getppid() != 1) {
 		if ((pid = fork()) > 0) {
-			exit(EXIT_SUCCESS);
+			exit(0);
 		} else if (pid < 0) {
 			logwrite(LOG_ALERT, "could not fork!\n");
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 	}
 
@@ -193,7 +193,7 @@
 	if (getpeername(0, (struct sockaddr *) (&saddr), &dummy) == 0) {
 		peername = g_strdup(inet_ntoa(saddr.sin_addr));
 	} else if (errno != ENOTSOCK)
-		exit(EXIT_FAILURE);
+		exit(1);
 
 	smtp_in(stdin, stderr, peername, NULL);
 }
@@ -208,7 +208,7 @@
 
 	if (return_path && !is_privileged_user(conf.orig_uid)) {
 		fprintf(stderr, "must be root, %s or in group %s for setting return path.\n", DEF_MAIL_USER, DEF_MAIL_GROUP);
-		exit(EXIT_FAILURE);
+		exit(1);
 	}
 
 	if (!conf.run_as_user) {
@@ -224,7 +224,7 @@
 			msg->rcpt_list = g_list_append(msg->rcpt_list, create_address_qualified(addresses[i], TRUE, conf.host_name));
 		else {
 			logwrite(LOG_ALERT, "no pipe allowed as recipient address: %s\n", addresses[i]);
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 	}
 
@@ -246,34 +246,34 @@
 					fclose(stdout);
 					fclose(stderr);
 					if (deliver(msg)) {
-						exit(EXIT_SUCCESS);
+						exit(0);
 					} else
-						exit(EXIT_FAILURE);
+						exit(1);
 				} else if (pid < 0) {
 					logwrite(LOG_ALERT, "could not fork for delivery, id = %s\n", msg->uid);
 				}
 			}
 		} else {
 			fprintf(stderr, "Could not write spool file\n");
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 	} else {
 		switch (err) {
 		case AERR_EOF:
 			fprintf(stderr, "unexpected EOF.\n");
-			exit(EXIT_FAILURE);
+			exit(1);
 		case AERR_NORCPT:
 			fprintf(stderr, "no recipients.\n");
-			exit(EXIT_FAILURE);
+			exit(1);
 		case AERR_SIZE:
 			fprintf(stderr, "max message size exceeded.\n");
-			exit(EXIT_FAILURE);
+			exit(1);
 		default:
 			/* should never happen: */
 			fprintf(stderr, "Unknown error (%d)\r\n", err);
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
-		exit(EXIT_FAILURE);
+		exit(1);
 	}
 }
 
@@ -399,7 +399,7 @@
 	gchar *M_cmd = NULL;
 	gboolean opt_t = FALSE;
 	gboolean opt_i = FALSE;
-	gint exit_code = EXIT_SUCCESS;
+	gint exit_code = 0;
 	gchar *conf_file = CONF_FILE;
 	gchar *route_name = NULL;
 	gchar *f_address = NULL;
@@ -464,18 +464,18 @@
 			conf_file = get_optarg(argv, &arg, opt+1);
 			if (!conf_file) {
 				fprintf(stderr, "-C requires a filename as argument.\n");
-				exit(EXIT_FAILURE);
+				exit(1);
 			}
 
 		} else if (strncmp(opt, "d", 1) == 0) {
 			if (getuid() != 0) {
 				fprintf(stderr, "only root may set the debug level.\n");
-				exit(EXIT_FAILURE);
+				exit(1);
 			}
 			char *lvl = get_optarg(argv, &arg, opt+1);
 			if (!lvl) {
 				fprintf(stderr, "-d requires a number argument.\n");
-				exit(EXIT_FAILURE);
+				exit(1);
 			}
 			debug_level = atoi(lvl);
 
@@ -484,7 +484,7 @@
 			gchar *address = get_optarg(argv, &arg, opt+1);
 			if (!address) {
 				fprintf(stderr, "-f requires an address argument\n");
-				exit(EXIT_FAILURE);
+				exit(1);
 			}
 			f_address = g_strdup(address);
 
@@ -492,7 +492,7 @@
 			full_sender_name = get_optarg(argv, &arg, opt+1);
 			if (!full_sender_name) {
 				fprintf(stderr, "-F requires a name argument\n");
-				exit(EXIT_FAILURE);
+				exit(1);
 			}
 
 		} else if (strcmp(opt, "i") == 0) {
@@ -542,7 +542,7 @@
 
 		} else {
 			fprintf(stderr, "unrecognized option `-%s'\n", opt);
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 	}
 
@@ -552,7 +552,7 @@
 
 	if (mta_mode == MODE_VERSION) {
 		mode_version();
-		exit(EXIT_SUCCESS);
+		exit(0);
 	}
 
 	/* initialize random generator */
@@ -619,17 +619,17 @@
 	if (!conf.run_as_user) {
 		if (setgid(0) != 0) {
 			fprintf(stderr, "could not set gid to 0. Is the setuid bit set? : %s\n", strerror(errno));
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 		if (setuid(0) != 0) {
 			fprintf(stderr, "could not gain root privileges. Is the setuid bit set? : %s\n", strerror(errno));
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 	}
 
 	if (!logopen()) {
 		fprintf(stderr, "could not open log file\n");
-		exit(EXIT_FAILURE);
+		exit(1);
 	}
 
 	DEBUG(1) debugf("masqmail %s starting\n", VERSION);
@@ -649,7 +649,7 @@
 		g_free(f_address);
 		if (!return_path) {
 			fprintf(stderr, "invalid RFC821 address: %s\n", f_address);
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 	}
 
@@ -671,7 +671,7 @@
 		break;
 
 	case MODE_BI:
-		exit(EXIT_SUCCESS);
+		exit(0);
 		break;  /* well... */
 
 	case MODE_MCMD:
--- a/src/online.c	Thu Dec 02 16:52:39 2010 -0300
+++ b/src/online.c	Thu Dec 02 17:11:25 2010 -0300
@@ -64,7 +64,7 @@
 	}
 	fclose(in);
 	waitpid(pid, &status, 0);
-	if (WEXITSTATUS(status) != EXIT_SUCCESS) {
+	if (WEXITSTATUS(status) != 0) {
 		g_free(name);
 		name = NULL;
 	}
--- a/src/permissions.c	Thu Dec 02 16:52:39 2010 -0300
+++ b/src/permissions.c	Thu Dec 02 17:11:25 2010 -0300
@@ -75,11 +75,11 @@
 
 	if (setegid(gid) != 0) {
 		logwrite(LOG_ALERT, "could not change gid to %d: %s\n", gid, strerror(errno));
-		exit(EXIT_FAILURE);
+		exit(1);
 	}
 	if (seteuid(uid) != 0) {
 		logwrite(LOG_ALERT, "could not change uid to %d: %s\n", uid, strerror(errno));
-		exit(EXIT_FAILURE);
+		exit(1);
 	}
 }
 
@@ -89,7 +89,7 @@
 	if (!conf.run_as_user) {
 		if (!is_privileged_user(old_uid)) {
 			fprintf(stderr, "must be root, %s or in group %s for %s.\n", DEF_MAIL_USER, DEF_MAIL_GROUP, task_name);
-			exit(EXIT_FAILURE);
+			exit(1);
 		}
 
 		set_euidgid(conf.mail_uid, conf.mail_gid, NULL, NULL);
--- a/src/smtpsend.c	Thu Dec 02 16:52:39 2010 -0300
+++ b/src/smtpsend.c	Thu Dec 02 17:11:25 2010 -0300
@@ -101,7 +101,7 @@
 
 		if ((ret = accept_message(stdin, msg, ACC_DOT_IGNORE)) == AERR_OK) {
 			if ((ret = smtp_deliver(server_name, server_port, resolve_list, msg, NULL, NULL)) == smtp_ok) {
-				exit(EXIT_SUCCESS);
+				exit(0);
 			}
 			fprintf(stderr, "deliver failed: %d\n", ret);
 		}