year update and moved some stuff to os_calls.c

ulab-original
jsorg71 19 years ago
parent 2990d6daa7
commit b1b3ff9e7d

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
authenticate user authenticate user
@ -22,60 +22,51 @@
#include "sesman.h" #include "sesman.h"
#define _XOPEN_SOURCE
#include <sys/types.h>
#include <pwd.h>
#include <grp.h>
extern struct config_sesman g_cfg; extern struct config_sesman g_cfg;
/******************************************************************************/ /******************************************************************************/
/* returns non zero if allowed */
int DEFAULT_CC int DEFAULT_CC
access_login_allowed(char* user) access_login_allowed(char* user)
{ {
int i; int gid;
struct group* groups; int ok;
struct passwd* pwd;
if ((0 == g_strncmp(user, "root", 5)) && (0 == g_cfg.sec.allow_root)) if ((0 == g_strncmp(user, "root", 5)) && (0 == g_cfg.sec.allow_root))
{ {
log_message(LOG_LEVEL_WARNING, "ROOT login attempted, but root login is disabled"); log_message(LOG_LEVEL_WARNING,
"ROOT login attempted, but root login is disabled");
return 0; return 0;
} }
if (0 == g_cfg.sec.ts_users_enable) if (0 == g_cfg.sec.ts_users_enable)
{ {
LOG_DBG("Terminal Server Users group is disabled, allowing authentication",1); LOG_DBG("Terminal Server Users group is disabled, allowing authentication",
1);
return 1; return 1;
} }
groups = getgrgid(g_cfg.sec.ts_users); if (0 != g_getuser_info(user, &gid, 0, 0, 0, 0))
if (0==groups)
{
log_message(LOG_LEVEL_ERROR,"Cannot read group info! - login denied");
return 0;
}
pwd = getpwnam(user);
if (0==pwd)
{ {
log_message(LOG_LEVEL_ERROR, "Cannot read user info! - login denied"); log_message(LOG_LEVEL_ERROR, "Cannot read user info! - login denied");
return 0; return 0;
} }
if (g_cfg.sec.ts_users==pwd->pw_gid) if (g_cfg.sec.ts_users == gid)
{ {
LOG_DBG("ts_users is user's primary group", 1); LOG_DBG("ts_users is user's primary group", 1);
return 1; return 1;
} }
i=0; if (0 != g_check_user_in_group(user, g_cfg.sec.ts_users, &ok))
while (0!=groups->gr_mem[i])
{ {
LOG_DBG("user: %s", groups->gr_mem[i]); log_message(LOG_LEVEL_ERROR, "Cannot read group info! - login denied");
if (0==g_strcmp(groups->gr_mem[i], user)) return 1; return 0;
i++; }
if (ok)
{
return 1;
} }
log_message(LOG_LEVEL_INFO, "login denied for user %s", user); log_message(LOG_LEVEL_INFO, "login denied for user %s", user);

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager - access control header session manager - access control header
*/ */

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager - main header session manager - main header
*/ */

@ -14,14 +14,11 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager - read config file session manager - read config file
*/ */
#include "sys/types.h"
#include "grp.h"
#include "arch.h" #include "arch.h"
#include "list.h" #include "list.h"
#include "file.h" #include "file.h"
@ -31,9 +28,9 @@
static int APP_CC static int APP_CC
text2bool(char* s) text2bool(char* s)
{ {
if (0 == g_strncasecmp(s, "1", 1) || if (0 == g_strcasecmp(s, "1") ||
0 == g_strncasecmp(s, "true", 4) || 0 == g_strcasecmp(s, "true") ||
0 == g_strncasecmp(s, "yes", 3)) 0 == g_strcasecmp(s, "yes"))
{ {
return 1; return 1;
} }
@ -105,19 +102,19 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n,
for (i = 0; i < param_n->count; i++) for (i = 0; i < param_n->count; i++)
{ {
buf = (char*)list_get_item(param_n, i); buf = (char*)list_get_item(param_n, i);
if (0 == g_strncasecmp(buf, SESMAN_CFG_DEFWM, 20)) if (0 == g_strcasecmp(buf, SESMAN_CFG_DEFWM))
{ {
g_strncpy(cf->default_wm, (char*)list_get_item(param_v, i), 31); g_strncpy(cf->default_wm, (char*)list_get_item(param_v, i), 31);
} }
else if (0 == g_strncasecmp(buf, SESMAN_CFG_USERWM, 20)) else if (0 == g_strcasecmp(buf, SESMAN_CFG_USERWM))
{ {
g_strncpy(cf->user_wm, (char*)list_get_item(param_v, i), 31); g_strncpy(cf->user_wm, (char*)list_get_item(param_v, i), 31);
} }
else if (0 == g_strncasecmp(buf, SESMAN_CFG_ENABLE_USERWM, 20)) else if (0 == g_strcasecmp(buf, SESMAN_CFG_ENABLE_USERWM))
{ {
cf->enable_user_wm = text2bool((char*)list_get_item(param_v, i)); cf->enable_user_wm = text2bool((char*)list_get_item(param_v, i));
} }
else if (0 == g_strncasecmp(buf, SESMAN_CFG_PORT, 20)) else if (0 == g_strcasecmp(buf, SESMAN_CFG_PORT))
{ {
g_strncpy(cf->listen_port, (char*)list_get_item(param_v, i), 15); g_strncpy(cf->listen_port, (char*)list_get_item(param_v, i), 15);
} }
@ -170,19 +167,19 @@ config_read_logging(int file, struct log_config* lc, struct list* param_n,
for (i = 0; i < param_n->count; i++) for (i = 0; i < param_n->count; i++)
{ {
buf = (char*)list_get_item(param_n, i); buf = (char*)list_get_item(param_n, i);
if (0 == g_strncasecmp(buf, SESMAN_CFG_LOG_FILE, 20)) if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_FILE))
{ {
lc->log_file = g_strdup((char*)list_get_item(param_v, i)); lc->log_file = g_strdup((char*)list_get_item(param_v, i));
} }
if (0 == g_strncasecmp(buf, SESMAN_CFG_LOG_LEVEL, 20)) if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_LEVEL))
{ {
lc->log_level = log_text2level((char*)list_get_item(param_v, i)); lc->log_level = log_text2level((char*)list_get_item(param_v, i));
} }
if (0 == g_strncasecmp(buf, SESMAN_CFG_LOG_ENABLE_SYSLOG, 20)) if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_ENABLE_SYSLOG))
{ {
lc->enable_syslog = text2bool((char*)list_get_item(param_v, i)); lc->enable_syslog = text2bool((char*)list_get_item(param_v, i));
} }
if (0 == g_strncasecmp(buf, SESMAN_CFG_LOG_SYSLOG_LEVEL, 20)) if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_SYSLOG_LEVEL))
{ {
lc->syslog_level = log_text2level((char*)list_get_item(param_v, i)); lc->syslog_level = log_text2level((char*)list_get_item(param_v, i));
} }
@ -204,12 +201,13 @@ config_read_logging(int file, struct log_config* lc, struct list* param_n,
/******************************************************************************/ /******************************************************************************/
int DEFAULT_CC int DEFAULT_CC
config_read_security(int file, struct config_security* sc, struct list* param_n, config_read_security(int file, struct config_security* sc,
struct list* param_n,
struct list* param_v) struct list* param_v)
{ {
int i; int i;
int gid;
char* buf; char* buf;
struct group* g;
list_clear(param_v); list_clear(param_v);
list_clear(param_n); list_clear(param_n);
@ -223,26 +221,24 @@ config_read_security(int file, struct config_security* sc, struct list* param_n,
for (i = 0; i < param_n->count; i++) for (i = 0; i < param_n->count; i++)
{ {
buf = (char*)list_get_item(param_n, i); buf = (char*)list_get_item(param_n, i);
if (0 == g_strncasecmp(buf, SESMAN_CFG_SEC_ALLOW_ROOT, 20)) if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_ALLOW_ROOT))
{ {
sc->allow_root = text2bool((char*)list_get_item(param_v, i)); sc->allow_root = text2bool((char*)list_get_item(param_v, i));
} }
if (0 == g_strncasecmp(buf, SESMAN_CFG_SEC_USR_GROUP, 20)) if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_USR_GROUP))
{ {
g=getgrnam((char*)list_get_item(param_v, i)); if (g_getgroup_info((char*)list_get_item(param_v, i), &gid) == 0)
if (0!=g)
{ {
sc->ts_users_enable = 1; sc->ts_users_enable = 1;
sc->ts_users=g->gr_gid; sc->ts_users = gid;
} }
} }
if (0 == g_strncasecmp(buf, SESMAN_CFG_SEC_ADM_GROUP, 20)) if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_ADM_GROUP))
{ {
g=getgrnam((char*)list_get_item(param_v, i)); if (g_getgroup_info((char*)list_get_item(param_v, i), &gid) == 0)
if (0!=g)
{ {
sc->ts_admins_enable = 1; sc->ts_admins_enable = 1;
sc->ts_admins=g->gr_gid; sc->ts_admins = gid;
} }
} }
} }
@ -291,19 +287,19 @@ config_read_sessions(int file, struct config_sessions* se, struct list* param_n,
for (i = 0; i < param_n->count; i++) for (i = 0; i < param_n->count; i++)
{ {
buf = (char*)list_get_item(param_n, i); buf = (char*)list_get_item(param_n, i);
if (0 == g_strncasecmp(buf, SESMAN_CFG_SESS_MAX, 20)) if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_MAX))
{ {
se->max_sessions = g_atoi((char*)list_get_item(param_v, i)); se->max_sessions = g_atoi((char*)list_get_item(param_v, i));
} }
if (0 == g_strncasecmp(buf, SESMAN_CFG_SESS_KILL_DISC, 20)) if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_KILL_DISC))
{ {
se->kill_disconnected = text2bool((char*)list_get_item(param_v, i)); se->kill_disconnected = text2bool((char*)list_get_item(param_v, i));
} }
if (0 == g_strncasecmp(buf, SESMAN_CFG_SESS_IDLE_LIMIT, 20)) if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_IDLE_LIMIT))
{ {
se->max_idle_time=g_atoi((char*)list_get_item(param_v, i)); se->max_idle_time=g_atoi((char*)list_get_item(param_v, i));
} }
if (0 == g_strncasecmp(buf, SESMAN_CFG_SESS_DISC_LIMIT, 20)) if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_DISC_LIMIT))
{ {
se->max_disc_time=g_atoi((char*)list_get_item(param_v, i)); se->max_disc_time=g_atoi((char*)list_get_item(param_v, i));
} }

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager - read config file session manager - read config file
*/ */
@ -22,7 +22,6 @@
#ifndef CONFIG_H #ifndef CONFIG_H
#define CONFIG_H #define CONFIG_H
#include "sys/types.h"
#include "arch.h" #include "arch.h"
#include "list.h" #include "list.h"
#include "log.h" #include "log.h"
@ -79,13 +78,13 @@ struct config_security
* @brief Terminal Server Users group * @brief Terminal Server Users group
*/ */
int ts_users_enable; int ts_users_enable;
gid_t ts_users; int ts_users;
/** /**
* @var ts_admins * @var ts_admins
* @brief Terminal Server Adminnistrators group * @brief Terminal Server Adminnistrators group
*/ */
int ts_admins_enable; int ts_admins_enable;
gid_t ts_admins; int ts_admins;
}; };
/** /**
@ -189,7 +188,8 @@ config_read(struct config_sesman* cfg);
* *
*/ */
int DEFAULT_CC int DEFAULT_CC
config_read_globals(int file, struct config_sesman* cf, struct list* param_n, struct list* param_v); config_read_globals(int file, struct config_sesman* cf,
struct list* param_n, struct list* param_v);
/** /**
* *
@ -201,7 +201,8 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n, st
* *
*/ */
int DEFAULT_CC int DEFAULT_CC
config_read_logging(int file, struct log_config* lc, struct list* param_n, struct list* param_v); config_read_logging(int file, struct log_config* lc, struct list* param_n,
struct list* param_v);
/** /**
* *
@ -213,7 +214,8 @@ config_read_logging(int file, struct log_config* lc, struct list* param_n, struc
* *
*/ */
int DEFAULT_CC int DEFAULT_CC
config_read_security(int file, struct config_security* sc, struct list* param_n, struct list* param_v); config_read_security(int file, struct config_security* sc,
struct list* param_n, struct list* param_v);
/** /**
* *
@ -225,6 +227,7 @@ config_read_security(int file, struct config_security* sc, struct list* param_n,
* *
*/ */
int DEFAULT_CC int DEFAULT_CC
config_read_sessions(int file, struct config_sessions* ss, struct list* param_n, struct list* param_v); config_read_sessions(int file, struct config_sessions* ss,
struct list* param_n, struct list* param_v);
#endif #endif

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager session manager
linux only linux only

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager session manager
linux only linux only

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager session manager
linux only linux only
@ -23,12 +23,6 @@
#include "sesman.h" #include "sesman.h"
#include <stdio.h>
#include <sys/types.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
int g_sck; int g_sck;
int g_pid; int g_pid;
unsigned char g_fixedkey[8] = { 23, 82, 107, 6, 35, 78, 88, 7 }; unsigned char g_fixedkey[8] = { 23, 82, 107, 6, 35, 78, 88, 7 };
@ -164,7 +158,8 @@ sesman_main_loop()
g_printf("pre auth"); g_printf("pre auth");
if (1 == access_login_allowed(user)) if (1 == access_login_allowed(user))
{ {
log_message(LOG_LEVEL_INFO, "granted TS access to user %s", user); log_message(LOG_LEVEL_INFO,
"granted TS access to user %s", user);
if (0 == code) if (0 == code)
{ {
log_message(LOG_LEVEL_INFO, "starting Xvnc session..."); log_message(LOG_LEVEL_INFO, "starting Xvnc session...");
@ -241,13 +236,15 @@ main(int argc, char** argv)
g_printf("starting sesman...\n"); g_printf("starting sesman...\n");
daemon = 1; daemon = 1;
} }
else if ( (2==argc) && ( (0 == g_strncasecmp(argv[1],"--nodaemon",11)) || (0 == g_strncasecmp(argv[1],"-n",11)) ) ) else if ((2 == argc) && ((0 == g_strcasecmp(argv[1], "--nodaemon")) ||
(0 == g_strcasecmp(argv[1], "-n")) ) )
{ {
/* starts sesman not daemonized */ /* starts sesman not daemonized */
g_printf("starting sesman in foregroud...\n"); g_printf("starting sesman in foregroud...\n");
daemon=0; daemon=0;
} }
else if ( (2==argc) && ( (0 == g_strncasecmp(argv[1],"--help",7)) || (0 == g_strncasecmp(argv[1],"-h",2)) ) ) else if ((2 == argc) && ((0 == g_strcasecmp(argv[1], "--help")) ||
(0 == g_strcasecmp(argv[1], "-h"))))
{ {
/* help screen */ /* help screen */
g_printf("sesman - xrdp session manager\n\n"); g_printf("sesman - xrdp session manager\n\n");
@ -259,13 +256,15 @@ main(int argc, char** argv)
g_printf("if no command is specified, sesman is started in background"); g_printf("if no command is specified, sesman is started in background");
g_exit(0); g_exit(0);
} }
else if ( (2==argc) && ( (0 == g_strncasecmp(argv[1],"--kill",11)) || (0 == g_strncasecmp(argv[1],"-k",11)) ) ) else if ((2 == argc) && ((0 == g_strcasecmp(argv[1], "--kill")) ||
(0 == g_strcasecmp(argv[1], "-k"))))
{ {
/* killing running sesman */ /* killing running sesman */
/* check if sesman is running */ /* check if sesman is running */
if (!g_file_exist(SESMAN_PID_FILE)) if (!g_file_exist(SESMAN_PID_FILE))
{ {
g_printf("sesman is not running (pid file not found - %s)\n", SESMAN_PID_FILE); g_printf("sesman is not running (pid file not found - %s)\n",
SESMAN_PID_FILE);
g_exit(1); g_exit(1);
} }
@ -273,17 +272,17 @@ main(int argc, char** argv)
if (-1 == fd) if (-1 == fd)
{ {
g_printf("error opening pid file: %s\n", strerror(errno)); g_printf("error opening pid file: %s\n", g_get_strerror());
return 1; return 1;
} }
error = g_file_read(fd, pid_s, 7); error = g_file_read(fd, pid_s, 7);
sscanf(pid_s, "%i", &pid); pid = g_atoi(pid_s);
error = g_sigterm(pid); error = g_sigterm(pid);
if (0 != error) if (0 != error)
{ {
g_printf("error killing sesman: %s\n", strerror(errno)); g_printf("error killing sesman: %s\n", g_get_strerror());
} }
else else
{ {
@ -301,7 +300,6 @@ main(int argc, char** argv)
g_exit(1); g_exit(1);
} }
if (g_file_exist(SESMAN_PID_FILE)) if (g_file_exist(SESMAN_PID_FILE))
{ {
g_printf("sesman is already running.\n"); g_printf("sesman is already running.\n");
@ -314,13 +312,14 @@ main(int argc, char** argv)
/* reading config */ /* reading config */
if (0 != config_read(&g_cfg)) if (0 != config_read(&g_cfg))
{ {
g_printf("error reading config: %s\nquitting.\n", strerror(errno)); g_printf("error reading config: %s\nquitting.\n", g_get_strerror());
g_exit(1); g_exit(1);
} }
/* starting logging subsystem */ /* starting logging subsystem */
error = log_start(g_cfg.log.program_name, g_cfg.log.log_file, g_cfg.log.log_level, error = log_start(g_cfg.log.program_name, g_cfg.log.log_file,
g_cfg.log.enable_syslog, g_cfg.log.syslog_level); g_cfg.log.log_level, g_cfg.log.enable_syslog,
g_cfg.log.syslog_level);
if (error != LOG_STARTUP_OK) if (error != LOG_STARTUP_OK)
{ {
@ -328,8 +327,10 @@ main(int argc, char** argv)
{ {
case LOG_ERROR_MALLOC: case LOG_ERROR_MALLOC:
g_printf("error on malloc. cannot start logging. quitting.\n"); g_printf("error on malloc. cannot start logging. quitting.\n");
break;
case LOG_ERROR_FILE_OPEN: case LOG_ERROR_FILE_OPEN:
g_printf("error opening log file. quitting.\n"); g_printf("error opening log file. quitting.\n");
break;
} }
g_exit(1); g_exit(1);
} }
@ -368,7 +369,8 @@ main(int argc, char** argv)
fd = g_file_open(SESMAN_PID_FILE); fd = g_file_open(SESMAN_PID_FILE);
if (-1 == fd) if (-1 == fd)
{ {
log_message(LOG_LEVEL_ERROR, "error opening pid file: %s", strerror(errno)); log_message(LOG_LEVEL_ERROR, "error opening pid file: %s",
g_get_strerror());
log_end(); log_end();
g_exit(1); g_exit(1);
} }

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager - main header session manager - main header
*/ */

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager session manager
linux only linux only

@ -14,15 +14,13 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager session manager
linux only linux only
*/ */
#include <stdlib.h>
#include "sesman.h" #include "sesman.h"
extern unsigned char g_fixedkey[8]; extern unsigned char g_fixedkey[8];
@ -140,22 +138,25 @@ session_start(int width, int height, int bpp, char* username, char* password,
/* check to limit concurrent sessions */ /* check to limit concurrent sessions */
if (g_session_count >= g_cfg.sess.max_sessions) if (g_session_count >= g_cfg.sess.max_sessions)
{ {
log_message(LOG_LEVEL_INFO, "max concurrent session limit exceeded. login for user %s denied", username); log_message(LOG_LEVEL_INFO, "max concurrent session limit exceeded. login \
for user %s denied", username);
return 0; return 0;
} }
#ifndef OLDSESSION #ifndef OLDSESSION
temp=malloc(sizeof(struct session_chain)); temp = (struct session_chain*)g_malloc(sizeof(struct session_chain), 0);
if (temp == 0) if (temp == 0)
{ {
log_message(LOG_LEVEL_ERROR, "cannot create new chain element - user %s", username); log_message(LOG_LEVEL_ERROR, "cannot create new chain element - user %s",
username);
return 0; return 0;
} }
temp->item = malloc(sizeof(struct session_item)); temp->item = (struct session_item*)g_malloc(sizeof(struct session_item), 0);
if (temp->item == 0) if (temp->item == 0)
{ {
free(temp); g_free(temp);
log_message(LOG_LEVEL_ERROR, "cannot create new session item - user %s", username); log_message(LOG_LEVEL_ERROR, "cannot create new session item - user %s",
username);
return 0; return 0;
} }
#endif #endif
@ -215,7 +216,8 @@ session_start(int width, int height, int bpp, char* username, char* password,
g_execlp3("xterm", "xterm", 0); g_execlp3("xterm", "xterm", 0);
/* should not get here */ /* should not get here */
} }
log_message(LOG_LEVEL_ALWAYS,"error starting window manager %s - pid %d", username, g_getpid()); log_message(LOG_LEVEL_ALWAYS,"error starting window manager %s - pid %d",
username, g_getpid());
g_exit(0); g_exit(0);
} }
else /* parent */ else /* parent */
@ -240,11 +242,13 @@ session_start(int width, int height, int bpp, char* username, char* password,
} }
else else
{ {
log_message(LOG_LEVEL_ALWAYS, "bad session type - user %s - pid %d", username, g_getpid()); log_message(LOG_LEVEL_ALWAYS, "bad session type - user %s - pid %d",
username, g_getpid());
g_exit(1); g_exit(1);
} }
/* should not get here */ /* should not get here */
log_message(LOG_LEVEL_ALWAYS,"error doing execve for user %s - pid %d",username,g_getpid()); log_message(LOG_LEVEL_ALWAYS,"error doing execve for user %s - pid %d",
username, g_getpid());
g_exit(1); g_exit(1);
} }
else /* parent */ else /* parent */
@ -295,8 +299,8 @@ session_start(int width, int height, int bpp, char* username, char* password,
g_strncpy(temp->item->name, username, 255); g_strncpy(temp->item->name, username, 255);
temp->item->connect_time = g_time1(); temp->item->connect_time = g_time1();
temp->item->disconnect_time=(time_t) 0; temp->item->disconnect_time = 0;
temp->item->idle_time=(time_t) 0; temp->item->idle_time = 0;
/* if (type==0) /* if (type==0)
{ {
@ -375,10 +379,12 @@ session_kill(int pid)
{ {
if (tmp->item == 0) if (tmp->item == 0)
{ {
log_message(LOG_LEVEL_ERROR, "session descriptor for pid %d is null!", pid); log_message(LOG_LEVEL_ERROR, "session descriptor for pid %d is null!",
pid);
if (prev == 0) if (prev == 0)
{ {
/* prev does no exist, so it's the first element - so we set g_sessions */ /* prev does no exist, so it's the first element - so we set
g_sessions */
g_sessions = tmp->next; g_sessions = tmp->next;
} }
else else
@ -392,18 +398,20 @@ session_kill(int pid)
if (tmp->item->pid == pid) if (tmp->item->pid == pid)
{ {
/* deleting the session */ /* deleting the session */
log_message(LOG_LEVEL_INFO, "session %d - user %s - terminated", tmp->item->pid, tmp->item->name); log_message(LOG_LEVEL_INFO, "session %d - user %s - terminated",
free(tmp->item); tmp->item->pid, tmp->item->name);
g_free(tmp->item);
if (prev == 0) if (prev == 0)
{ {
/* prev does no exist, so it's the first element - so we set g_sessions */ /* prev does no exist, so it's the first element - so we set
g_sessions */
g_sessions = tmp->next; g_sessions = tmp->next;
} }
else else
{ {
prev->next = tmp->next; prev->next = tmp->next;
} }
free(tmp); g_free(tmp);
g_session_count--; g_session_count--;
/*THREAD-FIX release chain lock */ /*THREAD-FIX release chain lock */
return SESMAN_SESSION_KILL_OK; return SESMAN_SESSION_KILL_OK;
@ -430,7 +438,8 @@ session_get_bypid(int pid)
{ {
if (tmp->item == 0) if (tmp->item == 0)
{ {
log_message(LOG_LEVEL_ERROR, "session descriptor for pid %d is null!", pid); log_message(LOG_LEVEL_ERROR, "session descriptor for pid %d is null!",
pid);
/*THREAD-FIX release chain lock */ /*THREAD-FIX release chain lock */
return 0; return 0;
} }

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager session manager
linux only linux only
@ -53,9 +53,9 @@ struct session_item
unsigned char type; unsigned char type;
/* time data */ /* time data */
time_t connect_time; int connect_time;
time_t disconnect_time; int disconnect_time;
time_t idle_time; int idle_time;
}; };
struct session_chain struct session_chain

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager session manager
linux only linux only

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager session manager
linux only linux only

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager session manager
linux only linux only

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
session manager session manager
linux only linux only

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
authenticate user authenticate user

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
authenticate user using kerberos authenticate user using kerberos

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
authenticate user authenticate user

@ -14,7 +14,7 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server. xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2005 Copyright (C) Jay Sorg 2005-2006
authenticate user authenticate user

Loading…
Cancel
Save