sesexec: Changes to existing files from sesman
env.c : The value of XRDP_SESSION in the environment is now set to the PID of the sesexec process, which ties up the session with the output of "xrdp-sesadmin -c=list". Later versions of xrdp-sesadmin can use this value to get information about the current process.
This commit is contained in:
parent
74cd7d1837
commit
c5971b535d
@ -35,7 +35,7 @@
|
||||
#include "list.h"
|
||||
#include "log.h"
|
||||
#include "os_calls.h"
|
||||
#include "sesman.h"
|
||||
#include "sesexec.h"
|
||||
#include "ssl_calls.h"
|
||||
#include "string_calls.h"
|
||||
#include "xrdp_sockets.h"
|
||||
@ -62,10 +62,10 @@ env_check_password_file(const char *filename, const char *passwd)
|
||||
ssl_sha1_transform(sha1, passwd, passwd_bytes);
|
||||
ssl_sha1_complete(sha1, passwd_hash);
|
||||
ssl_sha1_info_delete(sha1);
|
||||
g_snprintf(passwd_hash_text, 39, "%2.2x%2.2x%2.2x%2.2x",
|
||||
g_snprintf(passwd_hash_text, sizeof(passwd_hash_text),
|
||||
"%2.2x%2.2x%2.2x%2.2x",
|
||||
(tui8)passwd_hash[0], (tui8)passwd_hash[1],
|
||||
(tui8)passwd_hash[2], (tui8)passwd_hash[3]);
|
||||
passwd_hash_text[39] = 0;
|
||||
passwd = passwd_hash_text;
|
||||
|
||||
/* create file from password */
|
||||
@ -143,21 +143,23 @@ env_set_user(int uid, char **passwd_file, int display,
|
||||
g_setenv("SHELL", pw_shell, 1);
|
||||
g_setenv("USER", pw_username, 1);
|
||||
g_setenv("LOGNAME", pw_username, 1);
|
||||
g_sprintf(text, "%d", uid);
|
||||
g_snprintf(text, sizeof(text), "%d", uid);
|
||||
g_setenv("UID", text, 1);
|
||||
g_setenv("HOME", pw_dir, 1);
|
||||
g_set_current_dir(pw_dir);
|
||||
g_sprintf(text, ":%d.0", display);
|
||||
g_snprintf(text, sizeof(text), ":%d.0", display);
|
||||
g_setenv("DISPLAY", text, 1);
|
||||
g_setenv("XRDP_SESSION", "1", 1);
|
||||
// Use our PID as the XRDP_SESSION value
|
||||
g_snprintf(text, sizeof(text), "%d", g_pid);
|
||||
g_setenv("XRDP_SESSION", text, 1);
|
||||
/* XRDP_SOCKET_PATH should be set even here. It's used by
|
||||
* xorgxrdp and the pulseaudio plugin */
|
||||
g_setenv("XRDP_SOCKET_PATH", XRDP_SOCKET_PATH, 1);
|
||||
/* pulse sink socket */
|
||||
g_snprintf(text, sizeof(text) - 1, CHANSRV_PORT_OUT_BASE_STR, display);
|
||||
g_snprintf(text, sizeof(text), CHANSRV_PORT_OUT_BASE_STR, display);
|
||||
g_setenv("XRDP_PULSE_SINK_SOCKET", text, 1);
|
||||
/* pulse source socket */
|
||||
g_snprintf(text, sizeof(text) - 1, CHANSRV_PORT_IN_BASE_STR, display);
|
||||
g_snprintf(text, sizeof(text), CHANSRV_PORT_IN_BASE_STR, display);
|
||||
g_setenv("XRDP_PULSE_SOURCE_SOCKET", text, 1);
|
||||
if ((env_names != 0) && (env_values != 0) &&
|
||||
(env_names->count == env_values->count))
|
||||
@ -189,29 +191,33 @@ env_set_user(int uid, char **passwd_file, int display,
|
||||
|
||||
len = g_snprintf(NULL, 0, "%s/.vnc/sesman_passwd-%s@%s:%d",
|
||||
pw_dir, pw_username, hostname, display);
|
||||
++len; // Allow for terminator
|
||||
|
||||
*passwd_file = (char *) g_malloc(len + 1, 1);
|
||||
*passwd_file = (char *) g_malloc(len, 1);
|
||||
if (*passwd_file != NULL)
|
||||
{
|
||||
/* Try legacy names first, remove if found */
|
||||
g_sprintf(*passwd_file, "%s/.vnc/sesman_%s_passwd:%d",
|
||||
pw_dir, pw_username, display);
|
||||
g_snprintf(*passwd_file, len,
|
||||
"%s/.vnc/sesman_%s_passwd:%d",
|
||||
pw_dir, pw_username, display);
|
||||
if (g_file_exist(*passwd_file))
|
||||
{
|
||||
LOG(LOG_LEVEL_WARNING, "Removing old "
|
||||
"password file %s", *passwd_file);
|
||||
g_file_delete(*passwd_file);
|
||||
}
|
||||
g_sprintf(*passwd_file, "%s/.vnc/sesman_%s_passwd",
|
||||
pw_dir, pw_username);
|
||||
g_snprintf(*passwd_file, len,
|
||||
"%s/.vnc/sesman_%s_passwd",
|
||||
pw_dir, pw_username);
|
||||
if (g_file_exist(*passwd_file))
|
||||
{
|
||||
LOG(LOG_LEVEL_WARNING, "Removing insecure "
|
||||
"password file %s", *passwd_file);
|
||||
g_file_delete(*passwd_file);
|
||||
}
|
||||
g_sprintf(*passwd_file, "%s/.vnc/sesman_passwd-%s@%s:%d",
|
||||
pw_dir, pw_username, hostname, display);
|
||||
g_snprintf(*passwd_file, len,
|
||||
"%s/.vnc/sesman_passwd-%s@%s:%d",
|
||||
pw_dir, pw_username, hostname, display);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -219,10 +225,12 @@ env_set_user(int uid, char **passwd_file, int display,
|
||||
/* we use auth_file_path as requested */
|
||||
len = g_snprintf(NULL, 0, g_cfg->auth_file_path, pw_username);
|
||||
|
||||
*passwd_file = (char *) g_malloc(len + 1, 1);
|
||||
++len; // Allow for terminator
|
||||
*passwd_file = (char *) g_malloc(len, 1);
|
||||
if (*passwd_file != NULL)
|
||||
{
|
||||
g_sprintf(*passwd_file, g_cfg->auth_file_path, pw_username);
|
||||
g_snprintf(*passwd_file, len,
|
||||
g_cfg->auth_file_path, pw_username);
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -34,7 +34,8 @@
|
||||
#include "scp_application_types.h"
|
||||
#include "xrdp_constants.h"
|
||||
|
||||
struct auth_info;
|
||||
struct login_info;
|
||||
struct exit_status;
|
||||
|
||||
/**
|
||||
* Information used to start a session
|
||||
@ -42,35 +43,94 @@ struct auth_info;
|
||||
struct session_parameters
|
||||
{
|
||||
unsigned int display;
|
||||
int uid;
|
||||
struct guid guid;
|
||||
enum scp_session_type type;
|
||||
unsigned short height;
|
||||
unsigned short width;
|
||||
unsigned short height;
|
||||
unsigned char bpp;
|
||||
char shell[INFO_CLIENT_MAX_CB_LEN];
|
||||
char directory[INFO_CLIENT_MAX_CB_LEN];
|
||||
struct guid guid;
|
||||
const char *shell; // Must not be NULL
|
||||
const char *directory; // Must not be NULL
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Data involved in running a session (opaque type)
|
||||
*
|
||||
* Allocate with session_start() and free with
|
||||
* session_data_free() once session_active() returns zero.
|
||||
*/
|
||||
struct session_data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief starts a session
|
||||
*
|
||||
* @param auth_info Authentication info
|
||||
* @param login_info info for logged in user
|
||||
* @param s Session parameters
|
||||
* @param[out] pid PID of sub-process
|
||||
* @return status
|
||||
* @param[out] session_data Pointer to session data for the session
|
||||
*
|
||||
* The returned PID is only valid if the status returned is
|
||||
* E_SCP_SCREATE_OK
|
||||
* session_data is only set if E_SCP_CREATE_OK is returned
|
||||
* @return status
|
||||
*/
|
||||
enum scp_screate_status
|
||||
session_start(struct auth_info *auth_info,
|
||||
session_start(struct login_info *login_info,
|
||||
const struct session_parameters *s,
|
||||
int *pid);
|
||||
struct session_data **session_data);
|
||||
|
||||
int
|
||||
session_reconnect(int display, int uid,
|
||||
struct auth_info *auth_info);
|
||||
/**
|
||||
* Processes an exited child process
|
||||
*
|
||||
* The PID of the child process is removed from the session_data.
|
||||
*
|
||||
* @param sd session_data for this session
|
||||
* @param pid PID of exited process
|
||||
* @param e Exit status of the exited process
|
||||
*/
|
||||
void
|
||||
session_process_child_exit(struct session_data *sd,
|
||||
int pid,
|
||||
const struct exit_status *e);
|
||||
|
||||
/**
|
||||
* Returns a count of active processes in the session
|
||||
*
|
||||
* @param sd session_data for this session
|
||||
*/
|
||||
unsigned int
|
||||
session_active(const struct session_data *sd);
|
||||
|
||||
/**
|
||||
* Returns the start time for an active session
|
||||
*
|
||||
* @param sd session_data for this session
|
||||
*/
|
||||
time_t
|
||||
session_get_start_time(const struct session_data *sd);
|
||||
|
||||
/***
|
||||
* Ask a session to terminate by signalling the window manager
|
||||
*
|
||||
* @param sd session_data for this session
|
||||
*/
|
||||
void
|
||||
session_send_term(struct session_data *sd);
|
||||
|
||||
/**
|
||||
* Frees a session_data object
|
||||
*
|
||||
* @param sd session_data for this session
|
||||
*
|
||||
* Do not call this until session_active() returns zero, or you
|
||||
* lose the ability to track the session PIDs
|
||||
*/
|
||||
void
|
||||
session_data_free(struct session_data *session_data);
|
||||
|
||||
/**
|
||||
* Runs the reconnect script for the session
|
||||
*/
|
||||
void
|
||||
session_reconnect(struct login_info *login_info,
|
||||
struct session_data *sd);
|
||||
|
||||
#endif // SESSION_H
|
||||
|
@ -103,8 +103,7 @@ wait_for_xserver(uid_t uid,
|
||||
pid_t pid = g_fork();
|
||||
if (pid < 0)
|
||||
{
|
||||
LOG(LOG_LEVEL_ERROR, "Can't create pipe : %s",
|
||||
g_get_strerror());
|
||||
// Error already logged
|
||||
}
|
||||
else if (pid == 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user