summaryrefslogtreecommitdiffstats
path: root/sesman/env.c
diff options
context:
space:
mode:
authorilsimo <ilsimo>2005-10-06 19:27:38 +0000
committerilsimo <ilsimo>2005-10-06 19:27:38 +0000
commitc2fda67a1c245ac9963b583df5e9cc00c4eeb298 (patch)
tree46a09b2f5a1da03083a7e3c58a8f6401b7a9f3c6 /sesman/env.c
parent534b2691cdc8822d92709d16d5be21950c484fe1 (diff)
downloadxrdp-proprietary-c2fda67a1c245ac9963b583df5e9cc00c4eeb298.tar.gz
xrdp-proprietary-c2fda67a1c245ac9963b583df5e9cc00c4eeb298.zip
Adding auth.h env.c env.h session.c session.h tcp.c tcp.h
Diffstat (limited to 'sesman/env.c')
-rw-r--r--sesman/env.c108
1 files changed, 108 insertions, 0 deletions
diff --git a/sesman/env.c b/sesman/env.c
new file mode 100644
index 00000000..9ea5d6bd
--- /dev/null
+++ b/sesman/env.c
@@ -0,0 +1,108 @@
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ xrdp: A Remote Desktop Protocol server.
+ Copyright (C) Jay Sorg 2005
+
+ session manager
+ linux only
+
+ enc.c: user environment handling code
+
+*/
+
+//#include "d3des.h"
+//#include "arch.h"
+//#include "parse.h"
+//#include "os_calls.h"
+#include "sesman.h"
+//#include "config.h"
+//#include "tcp.h"
+//#include "sig.h"
+//#include "session.h"
+//#include "env.h"
+
+//int g_sck;
+//extern int g_pid;
+extern unsigned char g_fixedkey[8];
+//struct session_item g_session_items[100]; /* sesman.h */
+//struct sesman_config g_cfg; /* config.h */
+
+/******************************************************************************/
+int DEFAULT_CC
+env_check_password_file(char* filename, char* password)
+{
+ char encryptedPasswd[16];
+ int fd;
+
+ g_memset(encryptedPasswd, 0, 16);
+ g_strncpy(encryptedPasswd, password, 8);
+ rfbDesKey(g_fixedkey, 0);
+ rfbDes(encryptedPasswd, encryptedPasswd);
+ fd = g_file_open(filename);
+ if (fd == 0)
+ {
+ return 1;
+ }
+ g_file_write(fd, encryptedPasswd, 8);
+ g_file_close(fd);
+ g_set_file_rights(filename, 1, 1); /* set read and write flags */
+ return 0;
+}
+
+/******************************************************************************/
+int DEFAULT_CC
+env_set_user(char* username, char* passwd_file, int display)
+{
+ int error;
+ int pw_uid;
+ int pw_gid;
+ int uid;
+ char pw_shell[256];
+ char pw_dir[256];
+ char pw_gecos[256];
+ char text[256];
+
+ error = g_getuser_info(username, &pw_gid, &pw_uid, pw_shell, pw_dir,
+ pw_gecos);
+ if (error == 0)
+ {
+ error = g_setgid(pw_gid);
+ if (error == 0)
+ {
+ uid = pw_uid;
+ error = g_setuid(uid);
+ }
+ if (error == 0)
+ {
+ g_clearenv();
+ g_setenv("SHELL", pw_shell, 1);
+ g_setenv("PATH", "/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin", 1);
+ g_setenv("USER", username, 1);
+ g_sprintf(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_setenv("DISPLAY", text, 1);
+ if (passwd_file != 0)
+ {
+ g_mkdir(".vnc");
+ g_sprintf(passwd_file, "%s/.vnc/sesman_passwd", pw_dir);
+ }
+ }
+ }
+ return error;
+}