View | Details | Raw Unified | Return to bug 3484
Collapse All | Expand All

(-)a/sftp-server.8 (+4 lines)
Lines 38-43 Link Here
38
.Op Fl P Ar denied_requests
38
.Op Fl P Ar denied_requests
39
.Op Fl p Ar allowed_requests
39
.Op Fl p Ar allowed_requests
40
.Op Fl u Ar umask
40
.Op Fl u Ar umask
41
.Op Fl t Ar session_timeout
41
.Ek
42
.Ek
42
.Nm
43
.Nm
43
.Fl Q Ar protocol_feature
44
.Fl Q Ar protocol_feature
Lines 138-143 Sets an explicit Link Here
138
.Xr umask 2
139
.Xr umask 2
139
to be applied to newly-created files and directories, instead of the
140
to be applied to newly-created files and directories, instead of the
140
user's default mask.
141
user's default mask.
142
.It Fl t Ar session_timeout
143
Sets a timeout for idle connections in seconds. Specify 0 to disable the
144
timeout.
141
.El
145
.El
142
.Pp
146
.Pp
143
On some systems,
147
On some systems,
(-)a/sftp-server.c (-4 / +16 lines)
Lines 1892-1898 sftp_server_usage(void) Link Here
1892
	fprintf(stderr,
1892
	fprintf(stderr,
1893
	    "usage: %s [-ehR] [-d start_directory] [-f log_facility] "
1893
	    "usage: %s [-ehR] [-d start_directory] [-f log_facility] "
1894
	    "[-l log_level]\n\t[-P denied_requests] "
1894
	    "[-l log_level]\n\t[-P denied_requests] "
1895
	    "[-p allowed_requests] [-u umask]\n"
1895
	    "[-p allowed_requests] [-u umask] [-t session_timeout]\n"
1896
	    "       %s -Q protocol_feature\n",
1896
	    "       %s -Q protocol_feature\n",
1897
	    __progname, __progname);
1897
	    __progname, __progname);
1898
	exit(1);
1898
	exit(1);
Lines 1906-1911 sftp_server_main(int argc, char **argv, struct passwd *user_pw) Link Here
1906
	SyslogFacility log_facility = SYSLOG_FACILITY_AUTH;
1906
	SyslogFacility log_facility = SYSLOG_FACILITY_AUTH;
1907
	char *cp, *homedir = NULL, uidstr[32], buf[4*4096];
1907
	char *cp, *homedir = NULL, uidstr[32], buf[4*4096];
1908
	long mask;
1908
	long mask;
1909
	long timeout = -1;
1909
1910
1910
	extern char *optarg;
1911
	extern char *optarg;
1911
	extern char *__progname;
1912
	extern char *__progname;
Lines 1916-1922 sftp_server_main(int argc, char **argv, struct passwd *user_pw) Link Here
1916
	pw = pwcopy(user_pw);
1917
	pw = pwcopy(user_pw);
1917
1918
1918
	while (!skipargs && (ch = getopt(argc, argv,
1919
	while (!skipargs && (ch = getopt(argc, argv,
1919
	    "d:f:l:P:p:Q:u:cehR")) != -1) {
1920
	    "d:f:l:P:p:Q:u:cehRt:")) != -1) {
1920
		switch (ch) {
1921
		switch (ch) {
1921
		case 'Q':
1922
		case 'Q':
1922
			if (strcasecmp(optarg, "requests") != 0) {
1923
			if (strcasecmp(optarg, "requests") != 0) {
Lines 1978-1983 sftp_server_main(int argc, char **argv, struct passwd *user_pw) Link Here
1978
				fatal("Invalid umask \"%s\"", optarg);
1979
				fatal("Invalid umask \"%s\"", optarg);
1979
			(void)umask((mode_t)mask);
1980
			(void)umask((mode_t)mask);
1980
			break;
1981
			break;
1982
		case 't':
1983
			timeout = strtol(optarg, &cp, 10);
1984
			if (*cp != '\0' || timeout < 0 || timeout > INT_MAX / 1000)
1985
				fatal("Invalid timeout \"%s\"", optarg);
1986
			if (timeout == 0)
1987
				timeout = -1;
1988
			else
1989
				timeout *= 1000;
1990
			break;
1981
		case 'h':
1991
		case 'h':
1982
		default:
1992
		default:
1983
			sftp_server_usage();
1993
			sftp_server_usage();
Lines 2057-2067 sftp_server_main(int argc, char **argv, struct passwd *user_pw) Link Here
2057
			pfd[1].events = POLLOUT;
2067
			pfd[1].events = POLLOUT;
2058
		}
2068
		}
2059
2069
2060
		if (poll(pfd, 2, -1) == -1) {
2070
		if ((r = poll(pfd, 2, (int)timeout)) == -1) {
2061
			if (errno == EINTR)
2071
			if (errno == EINTR)
2062
				continue;
2072
				continue;
2063
			error("poll: %s", strerror(errno));
2073
			error("poll: %s", strerror(errno));
2064
			sftp_server_cleanup_exit(2);
2074
			sftp_server_cleanup_exit(2);
2075
		} else if (r == 0) {
2076
			logit("session timed out");
2077
			sftp_server_cleanup_exit(0);
2065
		}
2078
		}
2066
2079
2067
		/* copy stdin to iqueue */
2080
		/* copy stdin to iqueue */
2068
- 

Return to bug 3484