Blob Blame History Raw
From 3e038dd2b6ddc77eb27205d04252378f6038abcb Mon Sep 17 00:00:00 2001
From: John Dennis <jdennis@redhat.com>
Date: Wed, 13 Nov 2013 18:23:43 -0500
Subject: [PATCH] PW_TYPE_BOOLEAN config item should be declared int, not bool
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit

PW_TYPE_BOOLEAN config items are treated as int by the config
parser in conffile.c. bools and ints are not the same size,
on many architectures sizeof(bool) == 1 and sizeof(int) == 4

Manifestation of the problem

  # Loaded module rlm_exec
  # Instantiating module "echo" from file /etc/raddb/mods-enabled/echo
  exec echo {
  	wait = yes
  	program = "/bin/echo %{User-Name}"
  	input_pairs = "request"
  	output_pairs = "reply"
  	shell_escape = yes
  }
Error: /etc/raddb/mods-enabled/echo[34]: Cannot read output pairs if wait = no
Error: /etc/raddb/mods-enabled/echo[34]: Instantiation failed for module "echo"

In rlm_exec.c:

	if (!inst->wait &&
	    (inst->output != NULL)) {
		cf_log_err_cs(conf, "Cannot read output pairs if wait = no");
		return -1;
	}

wait = yes in the config file and is parsed as TRUE which writes a 1
into an integer but inst->wait is read as a byte so the test is not
performed correctly.
---
 src/modules/rlm_exec/rlm_exec.c | 2 +-
 src/modules/rlm_pap/rlm_pap.c   | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/modules/rlm_exec/rlm_exec.c b/src/modules/rlm_exec/rlm_exec.c
index 0d8149d..4770359 100644
--- a/src/modules/rlm_exec/rlm_exec.c
+++ b/src/modules/rlm_exec/rlm_exec.c
@@ -33,7 +33,7 @@ RCSID("$Id$")
 typedef struct rlm_exec_t {
 	char const	*xlat_name;
 	int		bare;
-	bool		wait;
+	int		wait;
 	char		*program;
 	char		*input;
 	char		*output;
diff --git a/src/modules/rlm_pap/rlm_pap.c b/src/modules/rlm_pap/rlm_pap.c
index 7ebcedf..8ec63dc 100644
--- a/src/modules/rlm_pap/rlm_pap.c
+++ b/src/modules/rlm_pap/rlm_pap.c
@@ -42,9 +42,9 @@ RCSID("$Id$")
  */
 typedef struct rlm_pap_t {
 	char const *name;	/* CONF_SECTION->name, not strdup'd */
-	bool auto_header;
+	int auto_header;
 	int auth_type;
-	bool normify;
+	int normify;
 } rlm_pap_t;
 
 /*
-- 
1.8.1.4