From 0a1f5f0f557607311afe4d807cc9b67e4ba49549 Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Fri, 23 May 2014 11:07:39 +0200 Subject: [PATCH] The custom header options allows %U and %G. --- src/ocserv-args.def | 5 +++-- src/worker-vpn.c | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ocserv-args.def b/src/ocserv-args.def index a22c17b9..7f3b5f7c 100644 --- a/src/ocserv-args.def +++ b/src/ocserv-args.def @@ -392,7 +392,7 @@ route = 192.168.5.0/255.255.255.0 #route-add-cmd = "ip route add %R dev %D" #route-del-cmd = "ip route delete %R dev %D" -# This option allows to forward a proxy. The special strings '%U' +# This option allows to forward a proxy. The special keywords '%U' # and '%G', if present will be replaced by the username and group name. #proxy-url = http://example.com/ #proxy-url = http://example.com/%U/ @@ -424,7 +424,8 @@ route = 192.168.5.0/255.255.255.0 # authentication and prior to VPN tunnel establishment. You shouldn't # need to use this option normally; if you do and you think that # this may help others, please send your settings and reason to -# the openconnect mailing list. +# the openconnect mailing list. The special keywords '%U' +# and '%G', if present will be replaced by the username and group name. #custom-header = "X-My-Header: hi there" @end example diff --git a/src/worker-vpn.c b/src/worker-vpn.c index f94121cd..f4a4fda0 100644 --- a/src/worker-vpn.c +++ b/src/worker-vpn.c @@ -1640,12 +1640,13 @@ static int connect_handler(worker_st * ws) SEND_ERR(ret); for (i = 0; i < ws->config->custom_header_size; i++) { - oclog(ws, LOG_DEBUG, "adding custom header '%s'", - ws->config->custom_header[i]); + const char *h = replace_vals(ws, ws->config->custom_header[i]); + + oclog(ws, LOG_DEBUG, "adding custom header '%s'", h); ret = - tls_printf(ws->session, "%s\r\n", - ws->config->custom_header[i]); + tls_printf(ws->session, "%s\r\n", h); SEND_ERR(ret); + talloc_free(h); } /* calculate base MTU */