summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-12-12 16:49:33 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-12-12 17:03:10 -0800
commit50b1097643934c8caec9530e5eda6ed6534aaf61 (patch)
tree268821c4e87abe6ec6d9bdc0f3dfee321f66d2fc /os
parent99998196017ef38ec88459b50605aa20f628788b (diff)
Constify the reason string throughout the authorization check framework
Almost all of the places the string is assigned point to a literal string constant, so use const char * for those, and const char ** for function calls that return it via an argument. Fortunately the top level function, ClientAuthorized, which returns the string as its return value is called from only one place, ProcEstablishConnection. ProcEstablishConnection stores either that return value or a string literal in char *reason. It only uses reason as an argument to SendConnSetup. SendConnSetup passes the reason argument to strlen & WriteToClient, both of which already have const qualifiers on their args. Thus added const to the reason variable in ProcEstablishConnection and the reason argument to SendConnSetup. Fixes gcc warnings: dispatch.c: In function 'ProcEstablishConnection': dispatch.c:3711:9: warning: assignment discards qualifiers from pointer target type auth.c: In function 'CheckAuthorization': auth.c:218:14: warning: assignment discards qualifiers from pointer target type auth.c:220:20: warning: assignment discards qualifiers from pointer target type connection.c: In function 'ClientAuthorized': connection.c:683:3: warning: return discards qualifiers from pointer target type mitauth.c: In function 'MitCheckCookie': mitauth.c:88:13: warning: assignment discards qualifiers from pointer target type xdmauth.c:259:14: warning: assignment discards qualifiers from pointer target type xdmauth.c:270:14: warning: assignment discards qualifiers from pointer target type xdmauth.c:277:11: warning: assignment discards qualifiers from pointer target type xdmauth.c:293:15: warning: assignment discards qualifiers from pointer target type xdmauth.c:313:14: warning: assignment discards qualifiers from pointer target type xdmauth.c:322:11: warning: assignment discards qualifiers from pointer target type rpcauth.c: In function 'SecureRPCCheck': rpcauth.c:136:10: warning: assignment discards qualifiers from pointer target type Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: Jamey Sharp <jamey@minilop.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'os')
-rw-r--r--os/auth.c2
-rw-r--r--os/connection.c4
-rw-r--r--os/mitauth.c2
-rw-r--r--os/osdep.h2
-rw-r--r--os/rpcauth.c2
-rw-r--r--os/xdmauth.c4
6 files changed, 8 insertions, 8 deletions
diff --git a/os/auth.c b/os/auth.c
index 9d36249f2..6669c148e 100644
--- a/os/auth.c
+++ b/os/auth.c
@@ -163,7 +163,7 @@ CheckAuthorization (
unsigned int data_length,
const char *data,
ClientPtr client,
- char **reason) /* failure message. NULL for default msg */
+ const char **reason) /* failure message. NULL for default msg */
{
int i;
struct stat buf;
diff --git a/os/connection.c b/os/connection.c
index 6f480deb6..8a677a7ef 100644
--- a/os/connection.c
+++ b/os/connection.c
@@ -629,7 +629,7 @@ AuthorizationIDOfClient(ClientPtr client)
*
*****************************************************************/
-char *
+const char *
ClientAuthorized(ClientPtr client,
unsigned int proto_n, char *auth_proto,
unsigned int string_n, char *auth_string)
@@ -639,7 +639,7 @@ ClientAuthorized(ClientPtr client,
int family;
int fromlen;
XID auth_id;
- char *reason = NULL;
+ const char *reason = NULL;
XtransConnInfo trans_conn;
priv = (OsCommPtr)client->osPrivate;
diff --git a/os/mitauth.c b/os/mitauth.c
index 4b8f6e978..477736ee8 100644
--- a/os/mitauth.c
+++ b/os/mitauth.c
@@ -76,7 +76,7 @@ MitCheckCookie (
unsigned short data_length,
const char *data,
ClientPtr client,
- char **reason)
+ const char **reason)
{
struct auth *auth;
diff --git a/os/osdep.h b/os/osdep.h
index 72bd7d762..71a7e44e3 100644
--- a/os/osdep.h
+++ b/os/osdep.h
@@ -137,7 +137,7 @@ typedef void (*AuthInitFunc) (AuthInitArgs);
#define AuthAddCArgs unsigned short data_length, const char *data, XID id
typedef int (*AuthAddCFunc) (AuthAddCArgs);
-#define AuthCheckArgs unsigned short data_length, const char *data, ClientPtr client, char **reason
+#define AuthCheckArgs unsigned short data_length, const char *data, ClientPtr client, const char **reason
typedef XID (*AuthCheckFunc) (AuthCheckArgs);
#define AuthFromIDArgs XID id, unsigned short *data_lenp, char **datap
diff --git a/os/rpcauth.c b/os/rpcauth.c
index 989a49a06..63b97b675 100644
--- a/os/rpcauth.c
+++ b/os/rpcauth.c
@@ -128,7 +128,7 @@ static char rpc_error[MAXNETNAMELEN+50];
_X_HIDDEN XID
SecureRPCCheck (unsigned short data_length, const char *data,
- ClientPtr client, char **reason)
+ ClientPtr client, const char **reason)
{
char *fullname;
diff --git a/os/xdmauth.c b/os/xdmauth.c
index b8cbada18..733fda504 100644
--- a/os/xdmauth.c
+++ b/os/xdmauth.c
@@ -248,7 +248,7 @@ XdmClientAuthTimeout (long now)
static XdmClientAuthPtr
XdmAuthorizationValidate (unsigned char *plain, int length,
- XdmAuthKeyPtr rho, ClientPtr xclient, char **reason)
+ XdmAuthKeyPtr rho, ClientPtr xclient, const char **reason)
{
XdmClientAuthPtr client, existing;
long now;
@@ -376,7 +376,7 @@ XdmAddCookie (unsigned short data_length, const char *data, XID id)
XID
XdmCheckCookie (unsigned short cookie_length, const char *cookie,
- ClientPtr xclient, char **reason)
+ ClientPtr xclient, const char **reason)
{
XdmAuthorizationPtr auth;
XdmClientAuthPtr client;