[PATCH] sftp-server argument error handling

Tony Finch dot at dotat.at
Tue Jun 19 02:56:27 EST 2007


When you give sftp-server a bogus -l or -f parameter, it logs a useful
error message then blunders on to call log_init() with the bogus value.
log_init() then prints a less useful message to stderr and exits. The
following patch tidies this up by only printing the more useful error to
stderr and not blundering on afterwards.

--- sftp-server.c.orig	Mon Jun 18 16:37:46 2007
+++ sftp-server.c	Mon Jun 18 16:39:14 2007
@@ -1220,7 +1220,8 @@
 	sanitise_stdfd();

 	__progname = ssh_get_progname(argv[0]);
-	log_init(__progname, log_level, log_facility, log_stderr);
+	/* Send any argument errors to stderr */
+	log_init(__progname, log_level, log_facility, 1);

 	while (!skipargs && (ch = getopt(argc, argv, "C:f:l:che")) != -1) {
 		switch (ch) {
@@ -1237,12 +1238,12 @@
 		case 'l':
 			log_level = log_level_number(optarg);
 			if (log_level == SYSLOG_LEVEL_NOT_SET)
-				error("Invalid log level \"%s\"", optarg);
+				fatal("Invalid log level \"%s\"", optarg);
 			break;
 		case 'f':
 			log_facility = log_facility_number(optarg);
 			if (log_level == SYSLOG_FACILITY_NOT_SET)
-				error("Invalid log facility \"%s\"", optarg);
+				fatal("Invalid log facility \"%s\"", optarg);
 			break;
 		case 'h':
 		default:

Tony.
-- 
f.a.n.finch  <dot at dotat.at>  http://dotat.at/
HUMBER THAMES: SOUTHEASTERLY, VEERING SOUTHWESTERLY FOR A TIME, 3 OR 4
OCCASIONALLY 5. SLIGHT OR MODERATE. SHOWERS. MODERATE OR GOOD.


More information about the openssh-unix-dev mailing list