xrdp: xrdp_mm.c fix some warnings and code cleanup

This commit is contained in:
Jay Sorg 2013-03-11 13:27:52 -07:00
parent 05de2e592a
commit 30f64f27b6

View File

@ -1077,7 +1077,8 @@ xrdp_mm_sesman_data_in(struct trans *trans)
#ifndef USE_NOPAM
/*********************************************************************/
/* return 0 on success */
int access_control(char *username, char *password, char *srv)
static int APP_CC
access_control(char *username, char *password, char *srv)
{
int reply;
int rec = 32+1; /* 32 is reserved for PAM failures this means connect failure */
@ -1193,7 +1194,8 @@ int access_control(char *username, char *password, char *srv)
/* This routine clears all states to make sure that our next login will be
* as expected. If the user does not press ok on the log window and try to
* connect again we must make sure that no previous information is stored.*/
void cleanup_states(struct xrdp_mm *self)
static void APP_CC
cleanup_states(struct xrdp_mm *self)
{
if (self != NULL)
{
@ -1210,11 +1212,14 @@ void cleanup_states(struct xrdp_mm *self)
self-> usechansrv = 0; /* true if chansrvport is set in xrdp.ini or using sesman */
}
}
#ifdef ACCESS
#ifndef USE_NOPAM
const char *getPAMError(const int pamError)
static const char * APP_CC
getPAMError(const int pamError, char *text, int text_bytes)
{
switch (pamError)
{
switch(pamError){
case PAM_SUCCESS:
return "Success";
case PAM_OPEN_ERR:
@ -1277,19 +1282,17 @@ const char *getPAMError(const int pamError)
return "Error connecting to PAM";
case 32 + 3:
return "Username okey but group problem";
default:{
char replytxt[80];
g_sprintf(replytxt,"Not defined PAM error:%d",pamError);
return replytxt ;
default:
g_snprintf(text, text_bytes, "Not defined PAM error:%d", pamError);
return text;
}
}
}
}
const char *getPAMAdditionalErrorInfo(const int pamError,struct xrdp_mm *self)
static const char * APP_CC
getPAMAdditionalErrorInfo(const int pamError, struct xrdp_mm *self)
{
switch (pamError)
{
switch(pamError){
case PAM_SUCCESS:
return NULL;
case PAM_OPEN_ERR:
@ -1331,12 +1334,9 @@ const char *getPAMAdditionalErrorInfo(const int pamError,struct xrdp_mm *self)
{
return "Authentication error - Verify that user/password is valid";
}
default:{
default:
return "No expected error";
}
}
}
#endif
#endif
@ -1436,8 +1436,9 @@ xrdp_mm_connect(struct xrdp_mm *self)
if (use_pam_auth)
{
int reply;
char replytxt[80];
char *additionalError;
char replytxt[128];
char pam_error[128];
const char *additionalError;
xrdp_wm_log_msg(self->wm, "Please wait, we now perform access control...");
/* g_writeln("we use pam modules to check if we can approve this user"); */
@ -1456,16 +1457,18 @@ xrdp_mm_connect(struct xrdp_mm *self)
/* access_control return 0 on success */
reply = access_control(pam_auth_username, pam_auth_password, pam_auth_sessionIP);
g_sprintf(replytxt, "Reply from access control: %s", getPAMError(reply));
g_sprintf(replytxt, "Reply from access control: %s",
getPAMError(reply, pam_error, 127));
xrdp_wm_log_msg(self->wm, replytxt);
log_message(LOG_LEVEL_INFO, replytxt);
additionalError = getPAMAdditionalErrorInfo(reply, self);
if (additionalError)
{
if(additionalError[0])
g_snprintf(replytxt, 127, "%s", additionalError);
if (replytxt[0])
{
xrdp_wm_log_msg(self->wm,additionalError);
xrdp_wm_log_msg(self->wm, replytxt);
}
}
@ -2123,6 +2126,28 @@ int read_allowed_channel_names(struct list *names, struct list *values)
return ret;
}
/* internal function return -1 if name is not in list
* otherwise return the index 0->count-1*/
int DEFAULT_CC
find_name_in_lists(char *inName, struct list *names)
{
int reply = -1; /*means not in the list*/
int index;
char *name;
for (index = 0; index < names->count; index++)
{
name = (char *)list_get_item(names, index);
if ( (name != 0) && (g_strncmp(name, inName, MAX_CHANNEL_NAME) == 0) )
{
reply = index;
break; /* stop loop - item found*/
}
}
return reply;
}
#define CHANNEL_NAME_PREFIX "channel."
/* update the channel lists from connection specific overrides
* return 1 on success 0 on failure */
@ -2156,28 +2181,6 @@ int update_allowed_channel_names(struct xrdp_wm *wm, struct list *names, struct
return ret;
}
/* internal function return -1 if name is not in list
* otherwise return the index 0->count-1*/
int DEFAULT_CC
find_name_in_lists(char *inName, struct list *names)
{
int reply = -1; /*means not in the list*/
int index;
char *name;
for (index = 0; index < names->count; index++)
{
name = (char *)list_get_item(names, index);
if ( (name != 0) && (g_strncmp(name, inName, MAX_CHANNEL_NAME) == 0) )
{
reply = index;
break; /* stop loop - item found*/
}
}
return reply;
}
/* internal function return 1 if name is in list of channels
* and if the value is allowed */
int DEFAULT_CC