authentication: Replace display number with string
The display number is a concept which won't exist for Wayland displays. We use a display nuimber instead.
This commit is contained in:
@@ -64,14 +64,14 @@ auth_uds(const char *user, enum scp_login_status *errorcode);
|
|||||||
*
|
*
|
||||||
* @brief Starts a session
|
* @brief Starts a session
|
||||||
* @param auth_info Auth handle created by auth_userpass
|
* @param auth_info Auth handle created by auth_userpass
|
||||||
* @param display_num Display number
|
* @param display Display name
|
||||||
* @return 0 on success, 1 on failure
|
* @return 0 on success, 1 on failure
|
||||||
*
|
*
|
||||||
* The resources allocated when the session is started are de-allocated
|
* The resources allocated when the session is started are de-allocated
|
||||||
* by auth_end() - there is no separate way to do this.
|
* by auth_end() - there is no separate way to do this.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
auth_start_session(struct auth_info *auth_info, int display_num);
|
auth_start_session(struct auth_info *auth_info, const char *display);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ auth_uds(const char *user, enum scp_login_status *errorcode)
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* returns error */
|
/* returns error */
|
||||||
int
|
int
|
||||||
auth_start_session(struct auth_info *auth_info, int display_num)
|
auth_start_session(struct auth_info *auth_info, const char *display)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ auth_uds(const char *user, enum scp_login_status *errorcode)
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* returns error */
|
/* returns error */
|
||||||
int
|
int
|
||||||
auth_start_session(struct auth_info *auth_info, int display_num)
|
auth_start_session(struct auth_info *auth_info, const char *display)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ auth_uds(const char *user, enum scp_login_status *errorcode)
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/* returns error */
|
/* returns error */
|
||||||
int
|
int
|
||||||
auth_start_session(struct auth_info *auth_info, int display_num)
|
auth_start_session(struct auth_info *auth_info, const char *display)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -398,17 +398,15 @@ auth_uds(const char *user, enum scp_login_status *errorcode)
|
|||||||
|
|
||||||
/* returns error */
|
/* returns error */
|
||||||
static int
|
static int
|
||||||
auth_start_session_private(struct auth_info *auth_info, int display_num)
|
auth_start_session_private(struct auth_info *auth_info, const char *display)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
char display[256];
|
|
||||||
|
|
||||||
g_sprintf(display, ":%d", display_num);
|
|
||||||
error = pam_set_item(auth_info->ph, PAM_TTY, display);
|
error = pam_set_item(auth_info->ph, PAM_TTY, display);
|
||||||
|
|
||||||
if (error != PAM_SUCCESS)
|
if (error != PAM_SUCCESS)
|
||||||
{
|
{
|
||||||
LOG(LOG_LEVEL_ERROR, "pam_set_item failed: %s",
|
LOG(LOG_LEVEL_ERROR, "pam_set_item(PAM_TTY) failed: %s",
|
||||||
pam_strerror(auth_info->ph, error));
|
pam_strerror(auth_info->ph, error));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -444,9 +442,9 @@ auth_start_session_private(struct auth_info *auth_info, int display_num)
|
|||||||
* routine fails
|
* routine fails
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
auth_start_session(struct auth_info *auth_info, int display_num)
|
auth_start_session(struct auth_info *auth_info, const char *display)
|
||||||
{
|
{
|
||||||
int result = auth_start_session_private(auth_info, display_num);
|
int result = auth_start_session_private(auth_info, display);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
LOG(LOG_LEVEL_ERROR,
|
LOG(LOG_LEVEL_ERROR,
|
||||||
|
|||||||
@@ -207,17 +207,15 @@ auth_uds(const char *user, enum scp_login_status *errorcode)
|
|||||||
|
|
||||||
/* returns error */
|
/* returns error */
|
||||||
static int
|
static int
|
||||||
auth_start_session_private(struct auth_info *auth_info, int display_num)
|
auth_start_session_private(struct auth_info *auth_info, const char *display)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
char display[256];
|
|
||||||
|
|
||||||
g_sprintf(display, ":%d", display_num);
|
|
||||||
error = pam_set_item(auth_info->ph, PAM_TTY, display);
|
error = pam_set_item(auth_info->ph, PAM_TTY, display);
|
||||||
|
|
||||||
if (error != PAM_SUCCESS)
|
if (error != PAM_SUCCESS)
|
||||||
{
|
{
|
||||||
LOG(LOG_LEVEL_ERROR, "pam_set_item failed: %s",
|
LOG(LOG_LEVEL_ERROR, "pam_set_item(PAM_TTY) failed: %s",
|
||||||
pam_strerror(auth_info->ph, error));
|
pam_strerror(auth_info->ph, error));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -253,9 +251,9 @@ auth_start_session_private(struct auth_info *auth_info, int display_num)
|
|||||||
* routine fails
|
* routine fails
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
auth_start_session(struct auth_info *auth_info, int display_num)
|
auth_start_session(struct auth_info *auth_info, const char *display)
|
||||||
{
|
{
|
||||||
int result = auth_start_session_private(auth_info, display_num);
|
int result = auth_start_session_private(auth_info, display);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
LOG(LOG_LEVEL_ERROR,
|
LOG(LOG_LEVEL_ERROR,
|
||||||
|
|||||||
@@ -694,6 +694,7 @@ session_start_wrapped(struct login_info *login_info,
|
|||||||
int display_pid;
|
int display_pid;
|
||||||
int window_manager_pid;
|
int window_manager_pid;
|
||||||
enum scp_screate_status status = E_SCP_SCREATE_GENERAL_ERROR;
|
enum scp_screate_status status = E_SCP_SCREATE_GENERAL_ERROR;
|
||||||
|
char displaystr[32];
|
||||||
|
|
||||||
/* Set the secondary groups before starting the session to prevent
|
/* Set the secondary groups before starting the session to prevent
|
||||||
* problems on PAM-based systems (see Linux pam_setcred(3)).
|
* problems on PAM-based systems (see Linux pam_setcred(3)).
|
||||||
@@ -708,7 +709,8 @@ session_start_wrapped(struct login_info *login_info,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (auth_start_session(login_info->auth_info, s->display) != 0)
|
snprintf(displaystr, sizeof(displaystr), "%d", s->display);
|
||||||
|
if (auth_start_session(login_info->auth_info, displaystr) != 0)
|
||||||
{
|
{
|
||||||
// Errors are logged by the auth module, as they are
|
// Errors are logged by the auth module, as they are
|
||||||
// specific to that module
|
// specific to that module
|
||||||
|
|||||||
@@ -304,9 +304,9 @@ main(int argc, char **argv)
|
|||||||
rv = (int)errorcode;
|
rv = (int)errorcode;
|
||||||
if (auth_info && rv == 0 && amp.command != NULL)
|
if (auth_info && rv == 0 && amp.command != NULL)
|
||||||
{
|
{
|
||||||
int display = 10;
|
const char *display = "xrdp-test10";
|
||||||
rv = auth_start_session(auth_info, display);
|
rv = auth_start_session(auth_info, display);
|
||||||
LOG(LOG_LEVEL_INFO, "auth_start_session(,%d) returned %d",
|
LOG(LOG_LEVEL_INFO, "auth_start_session(,%s) returned %d",
|
||||||
display, rv);
|
display, rv);
|
||||||
if (rv == 0)
|
if (rv == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user