summaryrefslogtreecommitdiffstats
path: root/misc.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2018-06-09 03:01:12 +0000
committerDamien Miller <djm@mindrot.org>2018-06-09 13:11:00 +1000
commit7082bb58a2eb878d23ec674587c742e5e9673c36 (patch)
treeca7c8ddb616358d96279fdbfd5986328f48a1821 /misc.c
parent3b9798bda15bd3f598f5ef07595d64e23504da91 (diff)
upstream: add a SetEnv directive to ssh_config that allows setting
environment variables for the remote session (subject to the server accepting them) refactor SendEnv to remove the arbitrary limit of variable names. ok markus@ OpenBSD-Commit-ID: cfbb00d9b0e10c1ffff1d83424351fd961d1f2be
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/misc.c b/misc.c
index 3e62320a..1198e70c 100644
--- a/misc.c
+++ b/misc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: misc.c,v 1.128 2018/06/06 18:29:18 markus Exp $ */
+/* $OpenBSD: misc.c,v 1.129 2018/06/09 03:01:12 djm Exp $ */
/*
* Copyright (c) 2000 Markus Friedl. All rights reserved.
* Copyright (c) 2005,2006 Damien Miller. All rights reserved.
@@ -239,8 +239,8 @@ set_rdomain(int fd, const char *name)
#define QUOTE "\""
/* return next token in configuration line */
-char *
-strdelim(char **s)
+static char *
+strdelim_internal(char **s, int split_equals)
{
char *old;
int wspace = 0;
@@ -250,7 +250,8 @@ strdelim(char **s)
old = *s;
- *s = strpbrk(*s, WHITESPACE QUOTE "=");
+ *s = strpbrk(*s,
+ split_equals ? WHITESPACE QUOTE "=" : WHITESPACE QUOTE);
if (*s == NULL)
return (old);
@@ -267,18 +268,37 @@ strdelim(char **s)
}
/* Allow only one '=' to be skipped */
- if (*s[0] == '=')
+ if (split_equals && *s[0] == '=')
wspace = 1;
*s[0] = '\0';
/* Skip any extra whitespace after first token */
*s += strspn(*s + 1, WHITESPACE) + 1;
- if (*s[0] == '=' && !wspace)
+ if (split_equals && *s[0] == '=' && !wspace)
*s += strspn(*s + 1, WHITESPACE) + 1;
return (old);
}
+/*
+ * Return next token in configuration line; splts on whitespace or a
+ * single '=' character.
+ */
+char *
+strdelim(char **s)
+{
+ return strdelim_internal(s, 1);
+}
+
+/*
+ * Return next token in configuration line; splts on whitespace only.
+ */
+char *
+strdelimw(char **s)
+{
+ return strdelim_internal(s, 0);
+}
+
struct passwd *
pwcopy(struct passwd *pw)
{