From patchwork Thu Dec 11 22:36:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Staples X-Patchwork-Id: 420269 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 755B21400DE for ; Fri, 12 Dec 2014 09:37:06 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 2F07228C075; Thu, 11 Dec 2014 23:35:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00 autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id EB5B72800B8 for ; Thu, 11 Dec 2014 23:35:09 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 CL_IP_EQ_FROM_MX=-3.1; rate: -7.6 Received: from mail0.frost.chambana.net (mail0.frost.chambana.net [209.66.96.68]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Thu, 11 Dec 2014 23:35:08 +0100 (CET) Received: from [192.168.13.162] (lockheed.naf.chambana.net [192.168.13.1]) (Authenticated sender: danstaples) by mail0.frost.chambana.net (Postfix) with ESMTPSA id 376A3BDF262C93CDDC957; Thu, 11 Dec 2014 17:36:52 -0500 (EST) Message-ID: <548A1C84.6080404@opentechinstitute.org> Date: Thu, 11 Dec 2014 17:36:52 -0500 From: Dan Staples User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: nbd@openwrt.org Cc: openwrt-devel@lists.openwrt.org Subject: [OpenWrt-Devel] [PATCH] uhttpd2: Set HTTPS environment variable X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Currently, the only way for cgi scripts to determine if the request was made over SSL seems to be to check if the SERVER_PORT environment variable is set to 443, which is less than ideal. This sets the HTTPS environment variable, like the first version of uhttpd. Signed-off-by: Dan Staples --- proc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/proc.c b/proc.c index 9c4b685..b520b91 100644 --- a/proc.c +++ b/proc.c @@ -81,6 +81,7 @@ enum extra_vars { VAR_METHOD, VAR_PATH_INFO, VAR_USER, + VAR_TLS, VAR_REDIRECT, VAR_SERVER_NAME, VAR_SERVER_ADDR, @@ -108,6 +109,7 @@ static struct env_var extra_vars[] = { [VAR_METHOD] = { "REQUEST_METHOD" }, [VAR_PATH_INFO] = { "PATH_INFO" }, [VAR_USER] = { "REMOTE_USER" }, + [VAR_TLS] = { "HTTPS" }, [VAR_REDIRECT] = { "REDIRECT_STATUS", redirect_status }, [VAR_SERVER_NAME] = { "SERVER_NAME", local_addr }, [VAR_SERVER_ADDR] = { "SERVER_ADDR", local_addr }, @@ -143,6 +145,7 @@ struct env_var *uh_get_process_vars(struct client *cl, struct path_info *pi) extra_vars[VAR_METHOD].value = http_methods[req->method]; extra_vars[VAR_PATH_INFO].value = pi->info; extra_vars[VAR_USER].value = req->realm ? req->realm->user : NULL; + extra_vars[VAR_TLS].value = cl->tls ? "on" : NULL; snprintf(redirect_status, sizeof(redirect_status), "%d", req->redirect_status);