xrdp: xrdp_mm.c fix some warnings and code cleanup
This commit is contained in:
parent
05de2e592a
commit
30f64f27b6
@ -1077,7 +1077,8 @@ xrdp_mm_sesman_data_in(struct trans *trans)
|
|||||||
#ifndef USE_NOPAM
|
#ifndef USE_NOPAM
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
/* return 0 on success */
|
/* 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 reply;
|
||||||
int rec = 32+1; /* 32 is reserved for PAM failures this means connect failure */
|
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
|
/* 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
|
* 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.*/
|
* 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)
|
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 */
|
self-> usechansrv = 0; /* true if chansrvport is set in xrdp.ini or using sesman */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ACCESS
|
#ifdef ACCESS
|
||||||
#ifndef USE_NOPAM
|
#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:
|
case PAM_SUCCESS:
|
||||||
return "Success";
|
return "Success";
|
||||||
case PAM_OPEN_ERR:
|
case PAM_OPEN_ERR:
|
||||||
@ -1277,19 +1282,17 @@ const char *getPAMError(const int pamError)
|
|||||||
return "Error connecting to PAM";
|
return "Error connecting to PAM";
|
||||||
case 32 + 3:
|
case 32 + 3:
|
||||||
return "Username okey but group problem";
|
return "Username okey but group problem";
|
||||||
default:{
|
default:
|
||||||
char replytxt[80];
|
g_snprintf(text, text_bytes, "Not defined PAM error:%d", pamError);
|
||||||
g_sprintf(replytxt,"Not defined PAM error:%d",pamError);
|
return text;
|
||||||
return replytxt ;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
static const char * APP_CC
|
||||||
|
getPAMAdditionalErrorInfo(const int pamError, struct xrdp_mm *self)
|
||||||
}
|
{
|
||||||
|
switch (pamError)
|
||||||
const char *getPAMAdditionalErrorInfo(const int pamError,struct xrdp_mm *self)
|
|
||||||
{
|
{
|
||||||
switch(pamError){
|
|
||||||
case PAM_SUCCESS:
|
case PAM_SUCCESS:
|
||||||
return NULL;
|
return NULL;
|
||||||
case PAM_OPEN_ERR:
|
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";
|
return "Authentication error - Verify that user/password is valid";
|
||||||
}
|
}
|
||||||
default:{
|
default:
|
||||||
return "No expected error";
|
return "No expected error";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@ -1436,8 +1436,9 @@ xrdp_mm_connect(struct xrdp_mm *self)
|
|||||||
if (use_pam_auth)
|
if (use_pam_auth)
|
||||||
{
|
{
|
||||||
int reply;
|
int reply;
|
||||||
char replytxt[80];
|
char replytxt[128];
|
||||||
char *additionalError;
|
char pam_error[128];
|
||||||
|
const char *additionalError;
|
||||||
xrdp_wm_log_msg(self->wm, "Please wait, we now perform access control...");
|
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"); */
|
/* 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 */
|
/* access_control return 0 on success */
|
||||||
reply = access_control(pam_auth_username, pam_auth_password, pam_auth_sessionIP);
|
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);
|
xrdp_wm_log_msg(self->wm, replytxt);
|
||||||
log_message(LOG_LEVEL_INFO, replytxt);
|
log_message(LOG_LEVEL_INFO, replytxt);
|
||||||
additionalError = getPAMAdditionalErrorInfo(reply, self);
|
additionalError = getPAMAdditionalErrorInfo(reply, self);
|
||||||
if (additionalError)
|
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;
|
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."
|
#define CHANNEL_NAME_PREFIX "channel."
|
||||||
/* update the channel lists from connection specific overrides
|
/* update the channel lists from connection specific overrides
|
||||||
* return 1 on success 0 on failure */
|
* 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;
|
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
|
/* internal function return 1 if name is in list of channels
|
||||||
* and if the value is allowed */
|
* and if the value is allowed */
|
||||||
int DEFAULT_CC
|
int DEFAULT_CC
|
||||||
|
Loading…
Reference in New Issue
Block a user