summaryrefslogtreecommitdiffstats
path: root/misc.c
diff options
context:
space:
mode:
authorDavid Sommerseth <dazo@users.sourceforge.net>2011-04-26 23:04:18 +0200
committerDavid Sommerseth <dazo@users.sourceforge.net>2011-04-26 23:04:18 +0200
commit20b18fd799e2ea9d0651f3ef913dd9ce2e481471 (patch)
tree86867a1128f35087f37d4b49ecf241b7b8e6b38e /misc.c
parentc5f7d08b8c3d4287dd40bbdf52525add8f5cee20 (diff)
parente4359af463463097dd80e679836905bcd8ad7a13 (diff)
downloadopenvpn-20b18fd799e2ea9d0651f3ef913dd9ce2e481471.tar.gz
openvpn-20b18fd799e2ea9d0651f3ef913dd9ce2e481471.tar.xz
openvpn-20b18fd799e2ea9d0651f3ef913dd9ce2e481471.zip
Merge branch 'svn-branch-2.1' into merge
Pulling in changes from James' 2.1/openvpn branch in SVN. Conflicts: buffer.c init.c manage.h multi.c openvpn.8 options.c ssl.c version.m4 win/sign.py Signed-off-by: David Sommerseth <dazo@users.sourceforge.net>
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/misc.c b/misc.c
index d499009..2d6c6f3 100644
--- a/misc.c
+++ b/misc.c
@@ -1713,6 +1713,16 @@ purge_user_pass (struct user_pass *up, const bool force)
}
}
+void
+set_auth_token (struct user_pass *up, const char *token)
+{
+ if (token && strlen(token) && up && up->defined && !up->nocache)
+ {
+ CLEAR (up->password);
+ strncpynt (up->password, token, USER_PASS_LEN);
+ }
+}
+
/*
* Process string received by untrusted peer before
* printing to console or log file.
@@ -2381,3 +2391,37 @@ openvpn_basename (const char *path)
}
return NULL;
}
+
+/*
+ * Remove SESS_ID_x strings (i.e. auth tokens) from control message
+ * strings so that they will not be output to log file.
+ */
+const char *
+sanitize_control_message(const char *str, struct gc_arena *gc)
+{
+ char *ret = gc_malloc (strlen(str)+1, false, gc);
+ char *cp = ret;
+ bool redact = false;
+
+ strcpy(ret, str);
+ for (;;)
+ {
+ const char c = *cp;
+ if (c == '\0')
+ break;
+ if (c == 'S' && !strncmp(cp, "SESS_ID_", 8))
+ {
+ cp += 7;
+ redact = true;
+ }
+ else
+ {
+ if (c == ',') /* end of session id? */
+ redact = false;
+ if (redact)
+ *cp = '_';
+ }
+ ++cp;
+ }
+ return ret;
+}