masqmail

diff src/masqmail.c @ 409:6874a4f265c1

Broke long lines.
author markus schnalke <meillo@marmaro.de>
date Wed, 29 Feb 2012 11:03:46 +0100
parents cdd16614c1f5
children 0430194f7ef8
line diff
     1.1 --- a/src/masqmail.c	Wed Feb 29 10:41:51 2012 +0100
     1.2 +++ b/src/masqmail.c	Wed Feb 29 11:03:46 2012 +0100
     1.3 @@ -66,10 +66,14 @@
     1.4  	if (pidfile) {
     1.5  		uid_t uid = geteuid();
     1.6  		if (seteuid(0) != 0) {
     1.7 -			logwrite(LOG_ALERT, "sigterm_handler: could not set euid to %d: %s\n", 0, strerror(errno));
     1.8 +			logwrite(LOG_ALERT, "sigterm_handler: could not set "
     1.9 +					"euid to %d: %s\n",
    1.10 +					0, strerror(errno));
    1.11  		}
    1.12  		if (unlink(pidfile) != 0)
    1.13 -			logwrite(LOG_WARNING, "could not delete pid file %s: %s\n", pidfile, strerror(errno));
    1.14 +			logwrite(LOG_WARNING,
    1.15 +					"could not delete pid file %s: %s\n",
    1.16 +					pidfile, strerror(errno));
    1.17  		seteuid(uid);  /* we exit anyway after this, just to be sure */
    1.18  	}
    1.19  
    1.20 @@ -111,7 +115,8 @@
    1.21  		pidfile = strdup(name);
    1.22  		return TRUE;
    1.23  	}
    1.24 -	logwrite(LOG_WARNING, "could not write pid file: %s\n", strerror(errno));
    1.25 +	logwrite(LOG_WARNING, "could not write pid file: %s\n",
    1.26 +			strerror(errno));
    1.27  	return FALSE;
    1.28  }
    1.29  
    1.30 @@ -124,7 +129,8 @@
    1.31  	/* daemon */
    1.32  	if (!conf.run_as_user) {
    1.33  		if ((conf.orig_uid != 0) && (conf.orig_uid != conf.mail_uid)) {
    1.34 -			fprintf(stderr, "must be root or %s for daemon.\n", DEF_MAIL_USER);
    1.35 +			fprintf(stderr, "must be root or %s for daemon.\n",
    1.36 +					DEF_MAIL_USER);
    1.37  			exit(1);
    1.38  		}
    1.39  	}
    1.40 @@ -156,7 +162,8 @@
    1.41  	logopen();
    1.42  
    1.43  	logwrite(LOG_NOTICE, "%s %s daemon starting\n", PACKAGE, VERSION);
    1.44 -	listen_port(do_listen ? conf.listen_addresses : NULL, queue_interval, argv);
    1.45 +	listen_port(do_listen ? conf.listen_addresses : NULL,
    1.46 +			queue_interval, argv);
    1.47  }
    1.48  
    1.49  /* -bs or called as smtpd or in.smtpd */
    1.50 @@ -198,7 +205,9 @@
    1.51  	pid_t pid;
    1.52  
    1.53  	if (return_path && !is_privileged_user(conf.orig_uid)) {
    1.54 -		fprintf(stderr, "must be root, %s or in group %s for setting return path.\n", DEF_MAIL_USER, DEF_MAIL_GROUP);
    1.55 +		fprintf(stderr, "must be root, %s or in group %s for "
    1.56 +				"setting return path.\n",
    1.57 +				DEF_MAIL_USER, DEF_MAIL_GROUP);
    1.58  		exit(1);
    1.59  	}
    1.60  
    1.61 @@ -212,18 +221,23 @@
    1.62  
    1.63  	/* warn if -t option and cmdline addr args */
    1.64  	if (addr_cnt && (accept_flags & ACC_RCPT_FROM_HEAD)) {
    1.65 -		logwrite(LOG_ALERT, "command line address arguments are now *added*  to the mail header\\\n");
    1.66 -		logwrite(LOG_ALERT, "  recipient addresses (instead of substracted)  when -t is given.\\\n");
    1.67 +		logwrite(LOG_ALERT, "command line address arguments are "
    1.68 +				"now *added*  to the mail header\\\n");
    1.69 +		logwrite(LOG_ALERT, "  recipient addresses (instead of "
    1.70 +				"substracted)  when -t is given.\\\n");
    1.71  		logwrite(LOG_ALERT, "  this changed with version 0.3.1\n");
    1.72  	}
    1.73  
    1.74  	for (i = 0; i < addr_cnt; i++) {
    1.75  		if (addresses[i][0] == '|') {
    1.76 -			logwrite(LOG_ALERT, "no pipe allowed as recipient address: %s\n", addresses[i]);
    1.77 +			logwrite(LOG_ALERT, "no pipe allowed as recipient "
    1.78 +					"address: %s\n", addresses[i]);
    1.79  			/* should we better ignore this one addr? */
    1.80  			exit(1);
    1.81  		}
    1.82 -		msg->rcpt_list = g_list_append(msg->rcpt_list, create_address_qualified(addresses[i], TRUE, conf.host_name));
    1.83 +		msg->rcpt_list = g_list_append(msg->rcpt_list,
    1.84 +				create_address_qualified(addresses[i],
    1.85 +				TRUE, conf.host_name));
    1.86  	}
    1.87  
    1.88  	/* -f option */
    1.89 @@ -259,7 +273,8 @@
    1.90  	}
    1.91  
    1.92  	/* here the mail is queued and thus in our responsibility */
    1.93 -	logwrite(LOG_NOTICE, "%s <= %s with %s\n", msg->uid, addr_string(msg->return_path), prot_names[PROT_LOCAL]);
    1.94 +	logwrite(LOG_NOTICE, "%s <= %s with %s\n", msg->uid,
    1.95 +			addr_string(msg->return_path), prot_names[PROT_LOCAL]);
    1.96  
    1.97  	if (conf.do_queue) {
    1.98  		/* we're finished as we only need to queue it */
    1.99 @@ -268,7 +283,8 @@
   1.100  
   1.101  	/* deliver at once */
   1.102  	if ((pid = fork()) < 0) {
   1.103 -		logwrite(LOG_ALERT, "could not fork for delivery, id = %s\n", msg->uid);
   1.104 +		logwrite(LOG_ALERT, "could not fork for delivery, id = %s\n",
   1.105 +				msg->uid);
   1.106  	} else if (pid == 0) {
   1.107  		conf.do_verbose = FALSE;
   1.108  		fclose(stdin);
   1.109 @@ -321,8 +337,9 @@
   1.110  
   1.111  	struct passwd *pw = getpwuid(conf.orig_uid);
   1.112  	if (!pw) {
   1.113 -		fprintf(stderr, "could not find a passwd entry for uid %d: %s\n",
   1.114 -		        conf.orig_uid, strerror(errno));
   1.115 +		fprintf(stderr, "could not find a passwd entry for "
   1.116 +				"uid %d: %s\n",
   1.117 +				conf.orig_uid, strerror(errno));
   1.118  		return FALSE;
   1.119  	}
   1.120  
   1.121 @@ -333,7 +350,8 @@
   1.122  		fprintf(stderr, "id: %s\n", *id);
   1.123  
   1.124  		if (!msg->ident) {
   1.125 -			fprintf(stderr, "message %s does not have an ident\n", *id);
   1.126 +			fprintf(stderr, "message %s does not have an ident\n",
   1.127 +					*id);
   1.128  			continue;
   1.129  		}
   1.130  		if (strcmp(pw->pw_name, msg->ident) != 0) {
   1.131 @@ -342,7 +360,8 @@
   1.132  		}
   1.133  
   1.134  		if (msg->received_host || (msg->received_prot != PROT_LOCAL)) {
   1.135 -			fprintf(stderr, "message %s was not received locally\n", *id);
   1.136 +			fprintf(stderr, "message %s was not received "
   1.137 +					"locally\n", *id);
   1.138  			continue;
   1.139  		}
   1.140  
   1.141 @@ -366,7 +385,8 @@
   1.142  
   1.143  	if (do_runq_online) {
   1.144  		if (route_name) {
   1.145 -			conf.online_query = g_strdup_printf("/bin/echo %s", route_name);
   1.146 +			conf.online_query = g_strdup_printf("/bin/echo %s",
   1.147 +					route_name);
   1.148  		}
   1.149  		/*
   1.150  		**  TODO: change behavior of `-qo without argument'?
   1.151 @@ -398,7 +418,8 @@
   1.152  set_mode(enum mta_mode mode)
   1.153  {
   1.154  	if (mta_mode && mta_mode!=mode) {
   1.155 -		fprintf(stderr, "operation mode was already specified (%d vs. %d)\n", mta_mode, mode);
   1.156 +		fprintf(stderr, "operation mode was already specified "
   1.157 +				"(%d vs. %d)\n", mta_mode, mode);
   1.158  		exit(1);
   1.159  	}
   1.160  
   1.161 @@ -491,18 +512,19 @@
   1.162  		} else if (strncmp(opt, "C", 1) == 0) {
   1.163  			conf_file = get_optarg(argv, &arg, opt+1);
   1.164  			if (!conf_file) {
   1.165 -				fprintf(stderr, "-C requires a filename as argument.\n");
   1.166 +				fprintf(stderr, "-C requires filename arg.\n");
   1.167  				exit(1);
   1.168  			}
   1.169  
   1.170  		} else if (strncmp(opt, "d", 1) == 0) {
   1.171  			if (getuid() != 0) {
   1.172 -				fprintf(stderr, "only root may set the debug level.\n");
   1.173 +				fprintf(stderr, "only root may set the "
   1.174 +						"debug level.\n");
   1.175  				exit(1);
   1.176  			}
   1.177  			char *lvl = get_optarg(argv, &arg, opt+1);
   1.178  			if (!lvl) {
   1.179 -				fprintf(stderr, "-d requires a number argument.\n");
   1.180 +				fprintf(stderr, "-d requires number arg.\n");
   1.181  				exit(1);
   1.182  			}
   1.183  			debug_level = atoi(lvl);
   1.184 @@ -511,7 +533,7 @@
   1.185  			/* set return path */
   1.186  			gchar *address = get_optarg(argv, &arg, opt+1);
   1.187  			if (!address) {
   1.188 -				fprintf(stderr, "-f requires an address argument\n");
   1.189 +				fprintf(stderr, "-f requires address arg.\n");
   1.190  				exit(1);
   1.191  			}
   1.192  			f_address = g_strdup(address);
   1.193 @@ -519,7 +541,7 @@
   1.194  		} else if (strncmp(opt, "F", 1) == 0) {
   1.195  			full_sender_name = get_optarg(argv, &arg, opt+1);
   1.196  			if (!full_sender_name) {
   1.197 -				fprintf(stderr, "-F requires a name argument\n");
   1.198 +				fprintf(stderr, "-F requires name arg.\n");
   1.199  				exit(1);
   1.200  			}
   1.201  
   1.202 @@ -550,8 +572,12 @@
   1.203  			/* TODO: behavior might change if it is NULL */
   1.204  			route_name = get_optarg(argv, &arg, opt+2);
   1.205  			if (!route_name) {
   1.206 -				fprintf(stderr, "Please do not use -qo without argument anymore; use -q instead.\n");
   1.207 -				fprintf(stderr, "The behavior for -qo without argument is likely to change.\n");
   1.208 +				fprintf(stderr, "Please do not use -qo "
   1.209 +						"without argument anymore; "
   1.210 +						"use -q instead.\n");
   1.211 +				fprintf(stderr, "The behavior for -qo without "
   1.212 +						"argument is likely to "
   1.213 +						"change.\n");
   1.214  			}
   1.215  
   1.216  		} else if (strncmp(opt, "q", 1) == 0) {
   1.217 @@ -560,10 +586,11 @@
   1.218  
   1.219  			optarg = get_optarg(argv, &arg, opt+1);
   1.220  			if (optarg) {
   1.221 -				/* not just one single queue run but regular runs */
   1.222 +				/* do regular queue runs */
   1.223  				set_mode(MODE_DAEMON);
   1.224  				queue_interval = time_interval(optarg);
   1.225  			} else {
   1.226 +				/* do a single queue run */
   1.227  				set_mode(MODE_RUNQUEUE);
   1.228  				do_runq = TRUE;
   1.229  			}
   1.230 @@ -631,11 +658,13 @@
   1.231  		conf.run_as_user = TRUE;
   1.232  		set_euidgid(conf.orig_uid, conf.orig_gid, NULL, NULL);
   1.233  		if (setgid(conf.orig_gid)) {
   1.234 -			logwrite(LOG_ALERT, "could not set gid to %d: %s\n", conf.orig_gid, strerror(errno));
   1.235 +			logwrite(LOG_ALERT, "could not set gid to %d: %s\n",
   1.236 +					conf.orig_gid, strerror(errno));
   1.237  			exit(1);
   1.238  		}
   1.239  		if (setuid(conf.orig_uid)) {
   1.240 -			logwrite(LOG_ALERT, "could not set uid to %d: %s\n", conf.orig_uid, strerror(errno));
   1.241 +			logwrite(LOG_ALERT, "could not set uid to %d: %s\n",
   1.242 +					conf.orig_uid, strerror(errno));
   1.243  			exit(1);
   1.244  		}
   1.245  	}
   1.246 @@ -645,7 +674,8 @@
   1.247  	/* FIXME: fails if we run as user */
   1.248  	logopen();
   1.249  	if (!read_conf(conf_file)) {
   1.250 -		logwrite(LOG_ALERT, "SHUTTING DOWN due to problems reading config\n");
   1.251 +		logwrite(LOG_ALERT, "SHUTTING DOWN due to problems reading "
   1.252 +				"config\n");
   1.253  		exit(5);
   1.254  	}
   1.255  	logclose();
   1.256 @@ -672,11 +702,15 @@
   1.257  
   1.258  	if (!conf.run_as_user) {
   1.259  		if (setgid(0) != 0) {
   1.260 -			fprintf(stderr, "could not set gid to 0. Is the setuid bit set? : %s\n", strerror(errno));
   1.261 +			fprintf(stderr, "could not set gid to 0. "
   1.262 +					"Is the setuid bit set? : %s\n",
   1.263 +					strerror(errno));
   1.264  			exit(1);
   1.265  		}
   1.266  		if (setuid(0) != 0) {
   1.267 -			fprintf(stderr, "could not gain root privileges. Is the setuid bit set? : %s\n", strerror(errno));
   1.268 +			fprintf(stderr, "could not gain root privileges. "
   1.269 +					"Is the setuid bit set? : %s\n",
   1.270 +					strerror(errno));
   1.271  			exit(1);
   1.272  		}
   1.273  	}
   1.274 @@ -699,10 +733,12 @@
   1.275  	DEBUG(5) debugf("queue_interval = %d\n", queue_interval);
   1.276  
   1.277  	if (f_address) {
   1.278 -		return_path = create_address_qualified(f_address, TRUE, conf.host_name);
   1.279 +		return_path = create_address_qualified(f_address, TRUE,
   1.280 +				conf.host_name);
   1.281  		g_free(f_address);
   1.282  		if (!return_path) {
   1.283 -			fprintf(stderr, "invalid RFC821 address: %s\n", f_address);
   1.284 +			fprintf(stderr, "invalid RFC821 address: %s\n",
   1.285 +					f_address);
   1.286  			exit(1);
   1.287  		}
   1.288  	}
   1.289 @@ -734,9 +770,12 @@
   1.290  
   1.291  	case MODE_ACCEPT:
   1.292  		{
   1.293 -			guint accept_flags = (opt_t ? ACC_RCPT_FROM_HEAD : 0)
   1.294 -			                     | (opt_i ? ACC_DOT_IGNORE : ACC_NODOT_RELAX);
   1.295 -			mode_accept(return_path, full_sender_name, accept_flags, &(argv[arg]), argc - arg);
   1.296 +			guint accept_flags = 0;
   1.297 +			accept_flags |= (opt_t ? ACC_RCPT_FROM_HEAD : 0);
   1.298 +			accept_flags |= (opt_i ?
   1.299 +					ACC_DOT_IGNORE : ACC_NODOT_RELAX);
   1.300 +			mode_accept(return_path, full_sender_name,
   1.301 +					accept_flags, argv + arg, argc - arg);
   1.302  			exit(0);
   1.303  		}
   1.304  		break;