diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2023-10-11 22:42:27 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2023-10-11 22:42:27 +0000 |
commit | 5421edd9e436557ec42a71a55b1b995fd1a9e19f (patch) | |
tree | edd2265cd96e133981f389dc644905cb8b27c7c8 /usr.bin/ssh/misc.c | |
parent | 1d4230bb66ff2a0537ee9811a62bd493e860c79c (diff) |
add ChannelTimeout support to the client, mirroring the same option
in the server. ok markus@
Diffstat (limited to 'usr.bin/ssh/misc.c')
-rw-r--r-- | usr.bin/ssh/misc.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/usr.bin/ssh/misc.c b/usr.bin/ssh/misc.c index 59ee9c9edfc..433c2341593 100644 --- a/usr.bin/ssh/misc.c +++ b/usr.bin/ssh/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.187 2023/08/28 03:31:16 djm Exp $ */ +/* $OpenBSD: misc.c,v 1.188 2023/10/11 22:42:26 djm Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005-2020 Damien Miller. All rights reserved. @@ -2386,6 +2386,43 @@ format_absolute_time(uint64_t t, char *buf, size_t len) strftime(buf, len, "%Y-%m-%dT%H:%M:%S", &tm); } +/* + * Parse a "pattern=interval" clause (e.g. a ChannelTimeout). + * Returns 0 on success or non-zero on failure. + * Caller must free *typep. + */ +int +parse_pattern_interval(const char *s, char **typep, int *secsp) +{ + char *cp, *sdup; + int secs; + + if (typep != NULL) + *typep = NULL; + if (secsp != NULL) + *secsp = 0; + if (s == NULL) + return -1; + sdup = xstrdup(s); + + if ((cp = strchr(sdup, '=')) == NULL || cp == sdup) { + free(sdup); + return -1; + } + *cp++ = '\0'; + if ((secs = convtime(cp)) < 0) { + free(sdup); + return -1; + } + /* success */ + if (typep != NULL) + *typep = xstrdup(sdup); + if (secsp != NULL) + *secsp = secs; + free(sdup); + return 0; +} + /* check if path is absolute */ int path_absolute(const char *path) |