Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
87ab442f11 | ||
|
9eb2c87ee6 | ||
|
8e5bd16c1e | ||
|
e424fb7772 | ||
|
32f3f14e26 | ||
|
e9c831f920 | ||
|
5d5375873e | ||
|
fc0be10bc5 | ||
|
de82974e53 | ||
|
854446d432 | ||
|
85af7159db | ||
|
b04384e8e1 | ||
|
384425f79f | ||
|
9af5c814fa | ||
|
706a68192a | ||
|
4544f2d8cf | ||
|
faed9f246d | ||
|
3d888c2280 |
@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
Copyright (c) 2004-2012 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -79,7 +79,72 @@ extern char** environ;
|
||||
#define INADDR_NONE ((unsigned long)-1)
|
||||
#endif
|
||||
|
||||
static char g_temp_base[64] = "";
|
||||
static char g_temp_base[128] = "";
|
||||
static char g_temp_base_org[128] = "";
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
g_rm_temp_dir(void)
|
||||
{
|
||||
if (g_temp_base[0] != 0)
|
||||
{
|
||||
if (!g_remove_dir(g_temp_base))
|
||||
{
|
||||
printf("g_rm_temp_dir: removing temp directory [%s] failed\n", g_temp_base);
|
||||
}
|
||||
g_temp_base[0] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int APP_CC
|
||||
g_mk_temp_dir(const char* app_name)
|
||||
{
|
||||
if (app_name != 0)
|
||||
{
|
||||
if (app_name[0] != 0)
|
||||
{
|
||||
if (!g_directory_exist("/tmp/.xrdp"))
|
||||
{
|
||||
if (!g_create_dir("/tmp/.xrdp"))
|
||||
{
|
||||
printf("g_mk_temp_dir: g_create_dir failed\n");
|
||||
return 1;
|
||||
}
|
||||
g_chmod_hex("/tmp/.xrdp", 0x1777);
|
||||
}
|
||||
snprintf(g_temp_base, sizeof(g_temp_base),
|
||||
"/tmp/.xrdp/%s-XXXXXX", app_name);
|
||||
snprintf(g_temp_base_org, sizeof(g_temp_base_org),
|
||||
"/tmp/.xrdp/%s-XXXXXX", app_name);
|
||||
if (mkdtemp(g_temp_base) == 0)
|
||||
{
|
||||
printf("g_mk_temp_dir: mkdtemp failed [%s]\n", g_temp_base);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("g_mk_temp_dir: bad app name\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (g_temp_base_org[0] == 0)
|
||||
{
|
||||
printf("g_mk_temp_dir: g_temp_base_org not set\n");
|
||||
return 1;
|
||||
}
|
||||
g_strncpy(g_temp_base, g_temp_base_org, 127);
|
||||
if (mkdtemp(g_temp_base) == 0)
|
||||
{
|
||||
printf("g_mk_temp_dir: mkdtemp failed [%s]\n", g_temp_base);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void APP_CC
|
||||
@ -91,17 +156,7 @@ g_init(const char* app_name)
|
||||
WSAStartup(2, &wsadata);
|
||||
#endif
|
||||
setlocale(LC_CTYPE, "");
|
||||
if (app_name != 0)
|
||||
{
|
||||
if (app_name[0] != 0)
|
||||
{
|
||||
snprintf(g_temp_base, sizeof(g_temp_base), "/tmp/%s-XXXXXX", app_name);
|
||||
if (mkdtemp(g_temp_base) == 0)
|
||||
{
|
||||
printf("g_init: mkdtemp failed [%s]\n", g_temp_base);
|
||||
}
|
||||
}
|
||||
}
|
||||
g_mk_temp_dir(app_name);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -111,7 +166,7 @@ g_deinit(void)
|
||||
#if defined(_WIN32)
|
||||
WSACleanup();
|
||||
#endif
|
||||
g_remove_dir(g_temp_base);
|
||||
g_rm_temp_dir();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -169,14 +224,17 @@ g_sprintf(char* dest, const char* format, ...)
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
void DEFAULT_CC
|
||||
int DEFAULT_CC
|
||||
g_snprintf(char* dest, int len, const char* format, ...)
|
||||
{
|
||||
int err;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
vsnprintf(dest, len, format, ap);
|
||||
err = vsnprintf(dest, len, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -1829,7 +1887,12 @@ g_execvp(const char* p1, char* args[])
|
||||
#if defined(_WIN32)
|
||||
return 0;
|
||||
#else
|
||||
return execvp(p1, args);
|
||||
int rv;
|
||||
|
||||
g_rm_temp_dir();
|
||||
rv = execvp(p1, args);
|
||||
g_mk_temp_dir(0);
|
||||
return rv;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1841,7 +1904,12 @@ g_execlp3(const char* a1, const char* a2, const char* a3)
|
||||
#if defined(_WIN32)
|
||||
return 0;
|
||||
#else
|
||||
return execlp(a1, a2, a3, (void*)0);
|
||||
int rv;
|
||||
|
||||
g_rm_temp_dir();
|
||||
rv = execlp(a1, a2, a3, (void*)0);
|
||||
g_mk_temp_dir(0);
|
||||
return rv;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1911,6 +1979,17 @@ g_signal_pipe(void (*func)(int))
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* does not work in win32 */
|
||||
void APP_CC
|
||||
g_signal_usr1(void (*func)(int))
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
#else
|
||||
signal(SIGUSR1, func);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* does not work in win32 */
|
||||
int APP_CC
|
||||
@ -1919,7 +1998,14 @@ g_fork(void)
|
||||
#if defined(_WIN32)
|
||||
return 0;
|
||||
#else
|
||||
return fork();
|
||||
int rv;
|
||||
|
||||
rv = fork();
|
||||
if (rv == 0) /* child */
|
||||
{
|
||||
g_mk_temp_dir(0);
|
||||
}
|
||||
return rv;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -2031,9 +2117,13 @@ void APP_CC
|
||||
g_clearenv(void)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
#else
|
||||
#if defined(BSD)
|
||||
environ[0] = 0;
|
||||
#else
|
||||
environ = 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -2093,10 +2183,11 @@ g_sigterm(int pid)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* returns 0 if ok */
|
||||
/* the caller is responsible to free the buffs */
|
||||
/* does not work in win32 */
|
||||
int APP_CC
|
||||
g_getuser_info(const char* username, int* gid, int* uid, char* shell,
|
||||
char* dir, char* gecos)
|
||||
g_getuser_info(const char *username, int *gid, int *uid, char **shell,
|
||||
char **dir, char **gecos)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
return 1;
|
||||
@ -2116,15 +2207,15 @@ g_getuser_info(const char* username, int* gid, int* uid, char* shell,
|
||||
}
|
||||
if (dir != 0)
|
||||
{
|
||||
g_strcpy(dir, pwd_1->pw_dir);
|
||||
*dir = g_strdup(pwd_1->pw_dir);
|
||||
}
|
||||
if (shell != 0)
|
||||
{
|
||||
g_strcpy(shell, pwd_1->pw_shell);
|
||||
*shell = g_strdup(pwd_1->pw_shell);
|
||||
}
|
||||
if (gecos != 0)
|
||||
{
|
||||
g_strcpy(gecos, pwd_1->pw_gecos);
|
||||
*gecos = g_strdup(pwd_1->pw_gecos);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -31,6 +31,10 @@
|
||||
|
||||
#include "arch.h"
|
||||
|
||||
int APP_CC
|
||||
g_rm_temp_dir(void);
|
||||
int APP_CC
|
||||
g_mk_temp_dir(const char* app_name);
|
||||
void APP_CC
|
||||
g_init(const char* app_name);
|
||||
void APP_CC
|
||||
@ -43,7 +47,7 @@ void DEFAULT_CC
|
||||
g_printf(const char *format, ...);
|
||||
void DEFAULT_CC
|
||||
g_sprintf(char* dest, const char* format, ...);
|
||||
void DEFAULT_CC
|
||||
int DEFAULT_CC
|
||||
g_snprintf(char* dest, int len, const char* format, ...);
|
||||
void DEFAULT_CC
|
||||
g_writeln(const char* format, ...);
|
||||
@ -218,6 +222,8 @@ void APP_CC
|
||||
g_signal_terminate(void (*func)(int));
|
||||
void APP_CC
|
||||
g_signal_pipe(void (*func)(int));
|
||||
void APP_CC
|
||||
g_signal_usr1(void (*func)(int));
|
||||
int APP_CC
|
||||
g_fork(void);
|
||||
int APP_CC
|
||||
@ -245,8 +251,8 @@ g_getpid(void);
|
||||
int APP_CC
|
||||
g_sigterm(int pid);
|
||||
int APP_CC
|
||||
g_getuser_info(const char* username, int* gid, int* uid, char* shell,
|
||||
char* dir, char* gecos);
|
||||
g_getuser_info(const char* username, int* gid, int* uid, char** shell,
|
||||
char** dir, char** gecos);
|
||||
int APP_CC
|
||||
g_getgroup_info(const char* groupname, int* gid);
|
||||
int APP_CC
|
||||
|
@ -59,6 +59,9 @@ struct stream
|
||||
/******************************************************************************/
|
||||
#define s_check_rem(s, n) ((s)->p + (n) <= (s)->end)
|
||||
|
||||
/******************************************************************************/
|
||||
#define s_check_rem_out(s, n) ((s)->p + (n) <= (s)->data + (s)->size)
|
||||
|
||||
/******************************************************************************/
|
||||
#define s_check_end(s) ((s)->p == (s)->end)
|
||||
|
||||
|
@ -185,10 +185,10 @@ ssl_mod_exp(char* out, int out_len, char* in, int in_len,
|
||||
char* mod, int mod_len, char* exp, int exp_len)
|
||||
{
|
||||
BN_CTX* ctx;
|
||||
BIGNUM lmod;
|
||||
BIGNUM lexp;
|
||||
BIGNUM lin;
|
||||
BIGNUM lout;
|
||||
BIGNUM *lmod;
|
||||
BIGNUM *lexp;
|
||||
BIGNUM *lin;
|
||||
BIGNUM *lout;
|
||||
int rv;
|
||||
char* l_out;
|
||||
char* l_in;
|
||||
@ -206,15 +206,15 @@ ssl_mod_exp(char* out, int out_len, char* in, int in_len,
|
||||
ssl_reverse_it(l_mod, mod_len);
|
||||
ssl_reverse_it(l_exp, exp_len);
|
||||
ctx = BN_CTX_new();
|
||||
BN_init(&lmod);
|
||||
BN_init(&lexp);
|
||||
BN_init(&lin);
|
||||
BN_init(&lout);
|
||||
BN_bin2bn((tui8*)l_mod, mod_len, &lmod);
|
||||
BN_bin2bn((tui8*)l_exp, exp_len, &lexp);
|
||||
BN_bin2bn((tui8*)l_in, in_len, &lin);
|
||||
BN_mod_exp(&lout, &lin, &lexp, &lmod, ctx);
|
||||
rv = BN_bn2bin(&lout, (tui8*)l_out);
|
||||
lmod = BN_new();
|
||||
lexp = BN_new();
|
||||
lin = BN_new();
|
||||
lout = BN_new();
|
||||
BN_bin2bn((tui8*)l_mod, mod_len, lmod);
|
||||
BN_bin2bn((tui8*)l_exp, exp_len, lexp);
|
||||
BN_bin2bn((tui8*)l_in, in_len, lin);
|
||||
BN_mod_exp(lout, lin, lexp, lmod, ctx);
|
||||
rv = BN_bn2bin(lout, (tui8*)l_out);
|
||||
if (rv <= out_len)
|
||||
{
|
||||
ssl_reverse_it(l_out, rv);
|
||||
@ -224,10 +224,10 @@ ssl_mod_exp(char* out, int out_len, char* in, int in_len,
|
||||
{
|
||||
rv = 0;
|
||||
}
|
||||
BN_free(&lin);
|
||||
BN_free(&lout);
|
||||
BN_free(&lexp);
|
||||
BN_free(&lmod);
|
||||
BN_free(lin);
|
||||
BN_free(lout);
|
||||
BN_free(lexp);
|
||||
BN_free(lmod);
|
||||
BN_CTX_free(ctx);
|
||||
g_free(l_out);
|
||||
g_free(l_in);
|
||||
@ -267,25 +267,33 @@ ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
|
||||
/* srand is in stdlib.h */
|
||||
srand(g_time1());
|
||||
my_key = RSA_generate_key(key_size_in_bits, my_e, 0, 0);
|
||||
const BIGNUM *n;
|
||||
const BIGNUM *d;
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
RSA_get0_key(my_key, &n, NULL, &d);
|
||||
#else
|
||||
n = my_key->n;
|
||||
d = my_key->d;
|
||||
#endif
|
||||
error = my_key == 0;
|
||||
if (error == 0)
|
||||
{
|
||||
len = BN_num_bytes(my_key->n);
|
||||
len = BN_num_bytes(n);
|
||||
error = len != mod_len;
|
||||
}
|
||||
if (error == 0)
|
||||
{
|
||||
BN_bn2bin(my_key->n, (tui8*)lmod);
|
||||
BN_bn2bin(n, (tui8*)lmod);
|
||||
ssl_reverse_it(lmod, mod_len);
|
||||
}
|
||||
if (error == 0)
|
||||
{
|
||||
len = BN_num_bytes(my_key->d);
|
||||
len = BN_num_bytes(d);
|
||||
error = len != pri_len;
|
||||
}
|
||||
if (error == 0)
|
||||
{
|
||||
BN_bn2bin(my_key->d, (tui8*)lpri);
|
||||
BN_bn2bin(d, (tui8*)lpri);
|
||||
ssl_reverse_it(lpri, pri_len);
|
||||
}
|
||||
if (error == 0)
|
||||
@ -328,24 +336,32 @@ ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
|
||||
BN_bin2bn((tui8*)lexp, exp_len, my_e);
|
||||
my_key = RSA_new();
|
||||
error = RSA_generate_key_ex(my_key, key_size_in_bits, my_e, 0) == 0;
|
||||
const BIGNUM *n;
|
||||
const BIGNUM *d;
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
|
||||
RSA_get0_key(my_key, &n, NULL, &d);
|
||||
#else
|
||||
n = my_key->n;
|
||||
d = my_key->d;
|
||||
#endif
|
||||
if (error == 0)
|
||||
{
|
||||
len = BN_num_bytes(my_key->n);
|
||||
len = BN_num_bytes(n);
|
||||
error = len != mod_len;
|
||||
}
|
||||
if (error == 0)
|
||||
{
|
||||
BN_bn2bin(my_key->n, (tui8*)lmod);
|
||||
BN_bn2bin(n, (tui8*)lmod);
|
||||
ssl_reverse_it(lmod, mod_len);
|
||||
}
|
||||
if (error == 0)
|
||||
{
|
||||
len = BN_num_bytes(my_key->d);
|
||||
len = BN_num_bytes(d);
|
||||
error = len != pri_len;
|
||||
}
|
||||
if (error == 0)
|
||||
{
|
||||
BN_bn2bin(my_key->d, (tui8*)lpri);
|
||||
BN_bn2bin(d, (tui8*)lpri);
|
||||
ssl_reverse_it(lpri, pri_len);
|
||||
}
|
||||
if (error == 0)
|
||||
|
@ -202,6 +202,11 @@ trans_force_read_s(struct trans* self, struct stream* in_s, int size)
|
||||
}
|
||||
while (size > 0)
|
||||
{
|
||||
/* make sure stream has room */
|
||||
if ((in_s->end + size) > (in_s->data + in_s->size))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
rcvd = g_tcp_recv(self->sck, in_s->end, size, 0);
|
||||
if (rcvd == -1)
|
||||
{
|
||||
|
@ -454,4 +454,7 @@
|
||||
|
||||
#define CB_ITEMCHANGE 300
|
||||
|
||||
#define XRDP_MAX_BITMAP_CACHE_ID 3
|
||||
#define XRDP_MAX_BITMAP_CACHE_IDX 2000
|
||||
|
||||
#endif
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Process this file with autoconf to produce a configure script
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT([xrdp], [0.6.0], [xrdp-devel@lists.sourceforge.net])
|
||||
AC_INIT([xrdp], [0.6.1], [xrdp-devel@lists.sourceforge.net])
|
||||
AM_CONFIG_HEADER(config_ac.h:config_ac-h.in)
|
||||
AM_INIT_AUTOMAKE([1.6 foreign])
|
||||
AC_PROG_CC
|
||||
|
@ -68,18 +68,34 @@ xrdp_iso_recv_msg(struct xrdp_iso* self, struct stream* s, int* code)
|
||||
}
|
||||
in_uint8s(s, 1);
|
||||
in_uint16_be(s, len);
|
||||
if (len < 4)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (xrdp_tcp_recv(self->tcp_layer, s, len - 4) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (!s_check_rem(s, 2))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, 1);
|
||||
in_uint8(s, *code);
|
||||
if (*code == ISO_PDU_DT)
|
||||
{
|
||||
if (!s_check_rem(s, 1))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!s_check_rem(s, 5))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, 5);
|
||||
}
|
||||
return 0;
|
||||
|
@ -120,6 +120,10 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
|
||||
DEBUG((" out xrdp_mcs_recv xrdp_iso_recv returned non zero"));
|
||||
return 1;
|
||||
}
|
||||
if (!s_check_rem(s, 1))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8(s, opcode);
|
||||
appid = opcode >> 2;
|
||||
if (appid == MCS_DPUM)
|
||||
@ -130,6 +134,10 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
|
||||
/* this is channels getting added from the client */
|
||||
if (appid == MCS_CJRQ)
|
||||
{
|
||||
if (!s_check_rem(s, 4))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint16_be(s, userid);
|
||||
in_uint16_be(s, chanid);
|
||||
DEBUG((" adding channel %4.4x", chanid));
|
||||
@ -143,12 +151,20 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
|
||||
DEBUG((" out xrdp_mcs_recv err got 0x%x need MCS_SDRQ", appid));
|
||||
return 1;
|
||||
}
|
||||
if (!s_check_rem(s, 6))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, 2);
|
||||
in_uint16_be(s, *chan);
|
||||
in_uint8s(s, 1);
|
||||
in_uint8(s, len);
|
||||
if (len & 0x80)
|
||||
{
|
||||
if (!s_check_rem(s, 1))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, 1);
|
||||
}
|
||||
DEBUG((" out xrdp_mcs_recv"));
|
||||
@ -167,16 +183,28 @@ xrdp_mcs_ber_parse_header(struct xrdp_mcs* self, struct stream* s,
|
||||
|
||||
if (tag_val > 0xff)
|
||||
{
|
||||
if (!s_check_rem(s, 2))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint16_be(s, tag);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!s_check_rem(s, 1))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8(s, tag);
|
||||
}
|
||||
if (tag != tag_val)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (!s_check_rem(s, 1))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8(s, l);
|
||||
if (l & 0x80)
|
||||
{
|
||||
@ -184,6 +212,10 @@ xrdp_mcs_ber_parse_header(struct xrdp_mcs* self, struct stream* s,
|
||||
*len = 0;
|
||||
while (l > 0)
|
||||
{
|
||||
if (!s_check_rem(s, 1))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8(s, i);
|
||||
*len = (*len << 8) | i;
|
||||
l--;
|
||||
@ -214,6 +246,10 @@ xrdp_mcs_parse_domain_params(struct xrdp_mcs* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if (!s_check_rem(s, len))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, len);
|
||||
if (s_check(s))
|
||||
{
|
||||
@ -234,7 +270,7 @@ xrdp_mcs_recv_connect_initial(struct xrdp_mcs* self)
|
||||
struct stream* s;
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
init_stream(s, 16 * 1024);
|
||||
if (xrdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
@ -283,6 +319,16 @@ xrdp_mcs_recv_connect_initial(struct xrdp_mcs* self)
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
if ((len <= 0) || (len > 16 * 1024))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
if (!s_check_rem(s, len))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
/* make a copy of client mcs data */
|
||||
init_stream(self->client_mcs_data, len);
|
||||
out_uint8a(self->client_mcs_data, s->p, len);
|
||||
@ -315,16 +361,31 @@ xrdp_mcs_recv_edrq(struct xrdp_mcs* self)
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
if (!s_check_rem(s, 1))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
in_uint8(s, opcode);
|
||||
if ((opcode >> 2) != MCS_EDRQ)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
if (!s_check_rem(s, 4))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, 2);
|
||||
in_uint8s(s, 2);
|
||||
if (opcode & 2)
|
||||
{
|
||||
if (!s_check_rem(s, 2))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
in_uint16_be(s, self->userid);
|
||||
}
|
||||
if (!(s_check_end(s)))
|
||||
@ -351,6 +412,11 @@ xrdp_mcs_recv_aurq(struct xrdp_mcs* self)
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
if (!s_check_rem(s, 1))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
in_uint8(s, opcode);
|
||||
if ((opcode >> 2) != MCS_AURQ)
|
||||
{
|
||||
@ -359,6 +425,11 @@ xrdp_mcs_recv_aurq(struct xrdp_mcs* self)
|
||||
}
|
||||
if (opcode & 2)
|
||||
{
|
||||
if (!s_check_rem(s, 2))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
in_uint16_be(s, self->userid);
|
||||
}
|
||||
if (!(s_check_end(s)))
|
||||
@ -416,15 +487,30 @@ xrdp_mcs_recv_cjrq(struct xrdp_mcs* self)
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
if (!s_check_rem(s, 1))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
in_uint8(s, opcode);
|
||||
if ((opcode >> 2) != MCS_CJRQ)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
if (!s_check_rem(s, 4))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, 4);
|
||||
if (opcode & 2)
|
||||
{
|
||||
if (!s_check_rem(s, 2))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, 2);
|
||||
}
|
||||
if (!(s_check_end(s)))
|
||||
|
@ -638,12 +638,26 @@ static int APP_CC
|
||||
xrdp_process_capset_bmpcache(struct xrdp_rdp* self, struct stream* s,
|
||||
int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
in_uint8s(s, 24);
|
||||
in_uint16_le(s, self->client_info.cache1_entries);
|
||||
/* cache 1 */
|
||||
in_uint16_le(s, i);
|
||||
i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
|
||||
i = MAX(i, 0);
|
||||
self->client_info.cache1_entries = i;
|
||||
in_uint16_le(s, self->client_info.cache1_size);
|
||||
in_uint16_le(s, self->client_info.cache2_entries);
|
||||
/* cache 2 */
|
||||
in_uint16_le(s, i);
|
||||
i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
|
||||
i = MAX(i, 0);
|
||||
self->client_info.cache2_entries = i;
|
||||
in_uint16_le(s, self->client_info.cache2_size);
|
||||
in_uint16_le(s, self->client_info.cache3_entries);
|
||||
/* caceh 3 */
|
||||
in_uint16_le(s, i);
|
||||
i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
|
||||
i = MAX(i, 0);
|
||||
self->client_info.cache3_entries = i;
|
||||
in_uint16_le(s, self->client_info.cache3_size);
|
||||
DEBUG(("cache1 entries %d size %d", self->client_info.cache1_entries,
|
||||
self->client_info.cache1_size));
|
||||
@ -669,16 +683,19 @@ xrdp_process_capset_bmpcache2(struct xrdp_rdp* self, struct stream* s,
|
||||
self->client_info.bitmap_cache_persist_enable = i;
|
||||
in_uint8s(s, 2); /* number of caches in set, 3 */
|
||||
in_uint32_le(s, i);
|
||||
i = MIN(i, 2000);
|
||||
i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
|
||||
i = MAX(i, 0);
|
||||
self->client_info.cache1_entries = i;
|
||||
self->client_info.cache1_size = 256 * Bpp;
|
||||
in_uint32_le(s, i);
|
||||
i = MIN(i, 2000);
|
||||
i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
|
||||
i = MAX(i, 0);
|
||||
self->client_info.cache2_entries = i;
|
||||
self->client_info.cache2_size = 1024 * Bpp;
|
||||
in_uint32_le(s, i);
|
||||
i = i & 0x7fffffff;
|
||||
i = MIN(i, 2000);
|
||||
i = MIN(i, XRDP_MAX_BITMAP_CACHE_IDX);
|
||||
i = MAX(i, 0);
|
||||
self->client_info.cache3_entries = i;
|
||||
self->client_info.cache3_size = 4096 * Bpp;
|
||||
DEBUG(("cache1 entries %d size %d", self->client_info.cache1_entries,
|
||||
@ -840,11 +857,19 @@ xrdp_rdp_process_data_input(struct xrdp_rdp* self, struct stream* s)
|
||||
int param2;
|
||||
int time;
|
||||
|
||||
if (!s_check_rem(s, 4))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint16_le(s, num_events);
|
||||
in_uint8s(s, 2); /* pad */
|
||||
DEBUG(("in xrdp_rdp_process_data_input %d events", num_events));
|
||||
for (index = 0; index < num_events; index++)
|
||||
{
|
||||
if (!s_check_rem(s, 12))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint32_le(s, time);
|
||||
in_uint16_le(s, msg_type);
|
||||
in_uint16_le(s, device_flags);
|
||||
|
@ -724,15 +724,27 @@ xrdp_sec_process_mcs_data_channels(struct xrdp_sec* self, struct stream* s)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (!s_check_rem(s, 4))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint32_le(s, num_channels);
|
||||
if (num_channels > 31)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
for (index = 0; index < num_channels; index++)
|
||||
{
|
||||
channel_item = (struct mcs_channel_item*)
|
||||
g_malloc(sizeof(struct mcs_channel_item), 1);
|
||||
if (!s_check_rem(s, 12))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8a(s, channel_item->name, 8);
|
||||
in_uint32_be(s, channel_item->flags);
|
||||
channel_item->chanid = MCS_GLOBAL_CHANNEL + (index + 1);
|
||||
list_add_item(self->mcs_layer->channel_list, (long)channel_item);
|
||||
list_add_item(self->mcs_layer->channel_list, (tintptr)channel_item);
|
||||
DEBUG(("got channel flags %8.8x name %s", channel_item->flags,
|
||||
channel_item->name));
|
||||
}
|
||||
@ -750,10 +762,14 @@ xrdp_sec_process_mcs_data(struct xrdp_sec* self)
|
||||
int tag = 0;
|
||||
int size = 0;
|
||||
|
||||
s = &self->client_mcs_data;
|
||||
s = &(self->client_mcs_data);
|
||||
/* set p to beginning */
|
||||
s->p = s->data;
|
||||
/* skip header */
|
||||
if (!s_check_rem(s, 23))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, 23);
|
||||
while (s_check_rem(s, 4))
|
||||
{
|
||||
@ -773,7 +789,10 @@ xrdp_sec_process_mcs_data(struct xrdp_sec* self)
|
||||
case SEC_TAG_CLI_CRYPT:
|
||||
break;
|
||||
case SEC_TAG_CLI_CHANNELS:
|
||||
xrdp_sec_process_mcs_data_channels(self, s);
|
||||
if (xrdp_sec_process_mcs_data_channels(self, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
case SEC_TAG_CLI_4:
|
||||
break;
|
||||
@ -878,7 +897,7 @@ xrdp_sec_out_mcs_data(struct xrdp_sec* self)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* process the mcs client data we received from the mcs layer */
|
||||
static void APP_CC
|
||||
static int APP_CC
|
||||
xrdp_sec_in_mcs_data(struct xrdp_sec* self)
|
||||
{
|
||||
struct stream* s = (struct stream *)NULL;
|
||||
@ -890,12 +909,20 @@ xrdp_sec_in_mcs_data(struct xrdp_sec* self)
|
||||
s = &(self->client_mcs_data);
|
||||
/* get hostname, its unicode */
|
||||
s->p = s->data;
|
||||
if (!s_check_rem(s, 47))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, 47);
|
||||
g_memset(client_info->hostname, 0, 32);
|
||||
c = 1;
|
||||
index = 0;
|
||||
while (index < 16 && c != 0)
|
||||
{
|
||||
if (!s_check_rem(s, 2))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8(s, c);
|
||||
in_uint8s(s, 1);
|
||||
client_info->hostname[index] = c;
|
||||
@ -903,13 +930,22 @@ xrdp_sec_in_mcs_data(struct xrdp_sec* self)
|
||||
}
|
||||
/* get build */
|
||||
s->p = s->data;
|
||||
if (!s_check_rem(s, 43 + 4))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, 43);
|
||||
in_uint32_le(s, client_info->build);
|
||||
/* get keylayout */
|
||||
s->p = s->data;
|
||||
if (!s_check_rem(s, 39 + 4))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
in_uint8s(s, 39);
|
||||
in_uint32_le(s, client_info->keylayout);
|
||||
s->p = s->data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -976,7 +1012,10 @@ xrdp_sec_incoming(struct xrdp_sec* self)
|
||||
(int)(self->server_mcs_data.end - self->server_mcs_data.data));
|
||||
#endif
|
||||
DEBUG((" out xrdp_sec_incoming"));
|
||||
xrdp_sec_in_mcs_data(self);
|
||||
if (xrdp_sec_in_mcs_data(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
xrdp 0.6.0
|
||||
xrdp 0.6.1
|
||||
|
||||
Credits
|
||||
This project is very much dependent on rdesktop and the work of Matt Chapman
|
||||
|
@ -411,7 +411,7 @@ setup_listen(void)
|
||||
if (g_use_unix_socket)
|
||||
{
|
||||
g_lis_trans = trans_create(2, 8192, 8192);
|
||||
g_snprintf(port, 255, "/tmp/xrdp_chansrv_socket_%d", 7200 + g_display_num);
|
||||
g_snprintf(port, 255, "/tmp/.xrdp/xrdp_chansrv_socket_%d", 7200 + g_display_num);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
41
sesman/env.c
41
sesman/env.c
@ -59,21 +59,24 @@ env_check_password_file(char* filename, char* password)
|
||||
|
||||
/******************************************************************************/
|
||||
int DEFAULT_CC
|
||||
env_set_user(char* username, char* passwd_file, int display)
|
||||
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];
|
||||
int len;
|
||||
char *pw_shell;
|
||||
char *pw_dir;
|
||||
char text[256];
|
||||
|
||||
error = g_getuser_info(username, &pw_gid, &pw_uid, pw_shell, pw_dir,
|
||||
pw_gecos);
|
||||
pw_shell = 0;
|
||||
pw_dir = 0;
|
||||
error = g_getuser_info(username, &pw_gid, &pw_uid, &pw_shell, &pw_dir, 0);
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
g_rm_temp_dir();
|
||||
error = g_setgid(pw_gid);
|
||||
if (error == 0)
|
||||
{
|
||||
@ -84,6 +87,7 @@ env_set_user(char* username, char* passwd_file, int display)
|
||||
uid = pw_uid;
|
||||
error = g_setuid(uid);
|
||||
}
|
||||
g_mk_temp_dir(0);
|
||||
if (error == 0)
|
||||
{
|
||||
g_clearenv();
|
||||
@ -103,16 +107,35 @@ env_set_user(char* username, char* passwd_file, int display)
|
||||
/* if no auth_file_path is set, then we go for
|
||||
$HOME/.vnc/sesman_username_passwd */
|
||||
g_mkdir(".vnc");
|
||||
g_sprintf(passwd_file, "%s/.vnc/sesman_%s_passwd", pw_dir, username);
|
||||
|
||||
len = g_snprintf(NULL, 0, "%s/.vnc/sesman_%s_passwd", pw_dir, username);
|
||||
|
||||
*passwd_file = (char *) g_malloc(len + 1, 1);
|
||||
if (*passwd_file != NULL)
|
||||
{
|
||||
g_sprintf(*passwd_file, "%s/.vnc/sesman_%s_passwd", pw_dir, username);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* we use auth_file_path as requested */
|
||||
g_sprintf(passwd_file, g_cfg->auth_file_path, username);
|
||||
len = g_snprintf(NULL, 0, g_cfg->auth_file_path, username);
|
||||
|
||||
*passwd_file = (char *) g_malloc(len + 1, 1);
|
||||
if (*passwd_file != NULL)
|
||||
{
|
||||
g_sprintf(*passwd_file, g_cfg->auth_file_path, username);
|
||||
}
|
||||
}
|
||||
|
||||
if (*passwd_file != NULL)
|
||||
{
|
||||
LOG_DBG(&(g_cfg->log), "pass file: %s", *passwd_file);
|
||||
}
|
||||
LOG_DBG(&(g_cfg->log), "pass file: %s", passwd_file);
|
||||
}
|
||||
}
|
||||
g_free(pw_dir);
|
||||
g_free(pw_shell);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ env_check_password_file(char* filename, char* password);
|
||||
*
|
||||
*/
|
||||
int DEFAULT_CC
|
||||
env_set_user(char* username, char* passwd_file, int display);
|
||||
env_set_user(char* username, char** passwd_file, int display);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -167,6 +167,7 @@ main(int argc, char** argv)
|
||||
g_printf("-k, --kill kills running sesman\n");
|
||||
g_printf("-h, --help shows this help\n");
|
||||
g_printf("if no command is specified, sesman is started in background");
|
||||
g_deinit();
|
||||
g_exit(0);
|
||||
}
|
||||
else if ((2 == argc) && ((0 == g_strcasecmp(argv[1], "--kill")) ||
|
||||
@ -178,6 +179,7 @@ main(int argc, char** argv)
|
||||
if (!g_file_exist(pid_file))
|
||||
{
|
||||
g_printf("sesman is not running (pid file not found - %s)\n", pid_file);
|
||||
g_deinit();
|
||||
g_exit(1);
|
||||
}
|
||||
|
||||
@ -194,6 +196,7 @@ main(int argc, char** argv)
|
||||
{
|
||||
g_printf("error reading pid file: %s\n", g_get_strerror());
|
||||
g_file_close(fd);
|
||||
g_deinit();
|
||||
g_exit(error);
|
||||
}
|
||||
g_file_close(fd);
|
||||
@ -208,7 +211,7 @@ main(int argc, char** argv)
|
||||
{
|
||||
g_file_delete(pid_file);
|
||||
}
|
||||
|
||||
g_deinit();
|
||||
g_exit(error);
|
||||
}
|
||||
else
|
||||
@ -217,6 +220,7 @@ main(int argc, char** argv)
|
||||
g_printf("sesman - xrdp session manager\n\n");
|
||||
g_printf("error: invalid command line\n");
|
||||
g_printf("usage: sesman [ --nodaemon | --kill | --help ]\n");
|
||||
g_deinit();
|
||||
g_exit(1);
|
||||
}
|
||||
|
||||
@ -226,6 +230,7 @@ main(int argc, char** argv)
|
||||
g_printf("if it's not running, try removing ");
|
||||
g_printf(pid_file);
|
||||
g_printf("\n");
|
||||
g_deinit();
|
||||
g_exit(1);
|
||||
}
|
||||
|
||||
@ -234,12 +239,14 @@ main(int argc, char** argv)
|
||||
if (0 == g_cfg)
|
||||
{
|
||||
g_printf("error creating config: quitting.\n");
|
||||
g_deinit();
|
||||
g_exit(1);
|
||||
}
|
||||
g_cfg->log.fd = -1; /* don't use logging before reading its config */
|
||||
if (0 != config_read(g_cfg))
|
||||
{
|
||||
g_printf("error reading config: %s\nquitting.\n", g_get_strerror());
|
||||
g_deinit();
|
||||
g_exit(1);
|
||||
}
|
||||
|
||||
@ -257,6 +264,7 @@ main(int argc, char** argv)
|
||||
g_printf("error opening log file [%s]. quitting.\n", g_cfg->log.log_file);
|
||||
break;
|
||||
}
|
||||
g_deinit();
|
||||
g_exit(1);
|
||||
}
|
||||
|
||||
@ -270,6 +278,7 @@ main(int argc, char** argv)
|
||||
|
||||
if (0 != g_pid)
|
||||
{
|
||||
g_deinit();
|
||||
g_exit(0);
|
||||
}
|
||||
|
||||
@ -312,6 +321,7 @@ main(int argc, char** argv)
|
||||
"error opening pid file[%s]: %s",
|
||||
pid_file, g_get_strerror());
|
||||
log_end(&(g_cfg->log));
|
||||
g_deinit();
|
||||
g_exit(1);
|
||||
}
|
||||
g_sprintf(pid_s, "%d", g_pid);
|
||||
|
@ -329,7 +329,7 @@ session_start_fork(int width, int height, int bpp, char* username,
|
||||
char depth[32];
|
||||
char screen[32];
|
||||
char text[256];
|
||||
char passwd_file[256];
|
||||
char *passwd_file;
|
||||
char ** pp1 = (char **)NULL;
|
||||
struct session_chain * temp = (struct session_chain *)NULL;
|
||||
struct list * xserver_params = (struct list *)NULL;
|
||||
@ -343,7 +343,8 @@ session_start_fork(int width, int height, int bpp, char* username,
|
||||
g_memset(depth,0,sizeof(char) * 32);
|
||||
g_memset(screen,0,sizeof(char) * 32);
|
||||
g_memset(text,0,sizeof(char) * 256);
|
||||
g_memset(passwd_file,0,sizeof(char) * 256);
|
||||
|
||||
passwd_file = 0;
|
||||
|
||||
/* check to limit concurrent sessions */
|
||||
if (g_session_count >= g_cfg->sess.max_sessions)
|
||||
@ -475,7 +476,7 @@ session_start_fork(int width, int height, int bpp, char* username,
|
||||
}
|
||||
else if (xpid == 0) /* child */
|
||||
{
|
||||
env_set_user(username, passwd_file, display);
|
||||
env_set_user(username, &passwd_file, display);
|
||||
env_check_password_file(passwd_file, password);
|
||||
if (type == SESMAN_SESSION_TYPE_XVNC)
|
||||
{
|
||||
@ -490,6 +491,7 @@ session_start_fork(int width, int height, int bpp, char* username,
|
||||
list_add_item(xserver_params, (long)g_strdup(depth));
|
||||
list_add_item(xserver_params, (long)g_strdup("-rfbauth"));
|
||||
list_add_item(xserver_params, (long)g_strdup(passwd_file));
|
||||
g_free(passwd_file);
|
||||
|
||||
/* additional parameters from sesman.ini file */
|
||||
//config_read_xserver_params(SESMAN_SESSION_TYPE_XVNC,
|
||||
@ -512,6 +514,7 @@ session_start_fork(int width, int height, int bpp, char* username,
|
||||
list_add_item(xserver_params, (long)g_strdup(geometry));
|
||||
list_add_item(xserver_params, (long)g_strdup("-depth"));
|
||||
list_add_item(xserver_params, (long)g_strdup(depth));
|
||||
g_free(passwd_file);
|
||||
|
||||
/* additional parameters from sesman.ini file */
|
||||
//config_read_xserver_params(SESMAN_SESSION_TYPE_XRDP,
|
||||
|
@ -56,12 +56,12 @@ chansrv_cleanup(int pid)
|
||||
{
|
||||
char text[256];
|
||||
|
||||
g_snprintf(text, 255, "/tmp/xrdp_chansrv_%8.8x_main_term", pid);
|
||||
g_snprintf(text, 255, "/tmp/.xrdp/xrdp_chansrv_%8.8x_main_term", pid);
|
||||
if (g_file_exist(text))
|
||||
{
|
||||
g_file_delete(text);
|
||||
}
|
||||
g_snprintf(text, 255, "/tmp/xrdp_chansrv_%8.8x_thread_done", pid);
|
||||
g_snprintf(text, 255, "/tmp/.xrdp/xrdp_chansrv_%8.8x_thread_done", pid);
|
||||
if (g_file_exist(text))
|
||||
{
|
||||
g_file_delete(text);
|
||||
@ -86,6 +86,7 @@ main(int argc, char** argv)
|
||||
if (argc < 3)
|
||||
{
|
||||
g_writeln("xrdp-sessvc: exiting, not enough parameters");
|
||||
g_deinit();
|
||||
return 1;
|
||||
}
|
||||
g_signal_kill(term_signal_handler); /* SIGKILL */
|
||||
@ -101,6 +102,7 @@ main(int argc, char** argv)
|
||||
if (chansrv_pid == -1)
|
||||
{
|
||||
g_writeln("xrdp-sessvc: fork error");
|
||||
g_deinit();
|
||||
return 1;
|
||||
}
|
||||
else if (chansrv_pid == 0) /* child */
|
||||
@ -110,6 +112,7 @@ main(int argc, char** argv)
|
||||
g_execlp3(exe_path, "xrdp-chansrv", 0);
|
||||
/* should not get here */
|
||||
g_writeln("xrdp-sessvc: g_execlp3() failed");
|
||||
g_deinit();
|
||||
return 1;
|
||||
}
|
||||
lerror = 0;
|
||||
|
@ -49,7 +49,7 @@ int main(int argc, char** argv)
|
||||
dis = strtol(display + 1, &p, 10);
|
||||
memset(&sa, 0, sizeof(sa));
|
||||
sa.sun_family = AF_UNIX;
|
||||
sprintf(sa.sun_path, "/tmp/xrdp_disconnect_display_%d", dis);
|
||||
sprintf(sa.sun_path, "/tmp/.xrdp/xrdp_disconnect_display_%d", dis);
|
||||
if (access(sa.sun_path, F_OK) != 0)
|
||||
{
|
||||
printf("not in an xrdp session\n");
|
||||
|
@ -117,6 +117,14 @@ auth_userpass(char* user, char* pass)
|
||||
g_free(auth_info);
|
||||
return 0;
|
||||
}
|
||||
|
||||
error = pam_set_item(auth_info->ph, PAM_TTY, service_name);
|
||||
if (error != PAM_SUCCESS)
|
||||
{
|
||||
g_printf("pam_set_item failed: %s\r\n",
|
||||
pam_strerror(auth_info->ph, error));
|
||||
}
|
||||
|
||||
error = pam_authenticate(auth_info->ph, 0);
|
||||
if (error != PAM_SUCCESS)
|
||||
{
|
||||
|
@ -1,338 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# build.sh: a script for building X11R7.6 X server for use with xrdp #
|
||||
# Copyright 2011-2012 Jay Sorg Jay.Sorg@gmail.com
|
||||
#
|
||||
# Authors
|
||||
# Jay Sorg Jay.Sorg@gmail.com
|
||||
# Laxmikant Rashinkar LK.Rashinkar@gmail.com
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# flex bison libxml2-dev intltool
|
||||
# xsltproc
|
||||
|
||||
download_file()
|
||||
{
|
||||
file=$1
|
||||
|
||||
cd downloads
|
||||
|
||||
echo "downloading file $file"
|
||||
if [ "$file" = "pixman-0.15.20.tar.bz2" ]; then
|
||||
wget -cq http://ftp.x.org/pub/individual/lib/$file
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "libdrm-2.4.26.tar.bz2" ]; then
|
||||
wget -cq http://dri.freedesktop.org/libdrm/$file
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "MesaLib-7.10.3.tar.bz2" ]; then
|
||||
wget -cq ftp://ftp.freedesktop.org/pub/mesa/7.10.3/$file
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "expat-2.0.1.tar.gz" ]; then
|
||||
wget -cq http://surfnet.dl.sourceforge.net/project/expat/expat/2.0.1/expat-2.0.1.tar.gz
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "freetype-2.4.6.tar.bz2" ]; then
|
||||
wget -cq http://download.savannah.gnu.org/releases/freetype/freetype-2.4.6.tar.bz2
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "xkeyboard-config-2.0.tar.bz2" ]; then
|
||||
wget -cq http://www.x.org/releases/individual/data/xkeyboard-config/xkeyboard-config-2.0.tar.bz2
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "makedepend-1.0.3.tar.bz2" ]; then
|
||||
wget -cq http://xorg.freedesktop.org/releases/individual/util/makedepend-1.0.3.tar.bz2
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "libxml2-sources-2.7.8.tar.gz" ]; then
|
||||
wget -cq ftp://ftp.xmlsoft.org/libxml2/libxml2-sources-2.7.8.tar.gz
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "Python-2.5.tar.bz2" ]; then
|
||||
wget -cq http://www.python.org/ftp/python/2.5/Python-2.5.tar.bz2
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "Python-2.7.tar.bz2" ]; then
|
||||
wget -cq http://www.python.org/ftp/python/2.7/Python-2.7.tar.bz2
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "expat-2.0.1.tar.gz" ]; then
|
||||
wget -cq http://server1.xrdp.org/xrdp/expat-2.0.1.tar.gz
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "cairo-1.8.8.tar.gz" ]; then
|
||||
wget -cq http://server1.xrdp.org/xrdp/cairo-1.8.8.tar.gz
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "libpng-1.2.46.tar.gz" ]; then
|
||||
wget -cq http://server1.xrdp.org/xrdp/libpng-1.2.46.tar.gz
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "intltool-0.41.1.tar.gz" ]; then
|
||||
wget -cq http://launchpad.net/intltool/trunk/0.41.1/+download/intltool-0.41.1.tar.gz
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "libxslt-1.1.26.tar.gz" ]; then
|
||||
wget -cq ftp://xmlsoft.org/libxslt/libxslt-1.1.26.tar.gz
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
elif [ "$file" = "fontconfig-2.8.0.tar.gz" ]; then
|
||||
wget -cq http://server1.xrdp.org/xrdp/fontconfig-2.8.0.tar.gz
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
else
|
||||
wget -cq $download_url/$file
|
||||
status=$?
|
||||
cd ..
|
||||
return $status
|
||||
fi
|
||||
}
|
||||
|
||||
remove_modules()
|
||||
{
|
||||
if [ -d cookies ]; then
|
||||
rm cookies/*
|
||||
fi
|
||||
|
||||
if [ ! -d build_dir ]; then
|
||||
echo ""
|
||||
echo "build_dir does not exist; nothing to delete"
|
||||
echo ""
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd build_dir
|
||||
|
||||
while read line
|
||||
do
|
||||
mod_dir=`echo $line | cut -d':' -f2`
|
||||
if [ -d $mod_dir ]; then
|
||||
rm -rf $mod_dir
|
||||
fi
|
||||
done < ../$data_file
|
||||
|
||||
cd ..
|
||||
}
|
||||
|
||||
make_it()
|
||||
{
|
||||
mod_file=$1
|
||||
mod_name=$2
|
||||
mod_args=$3
|
||||
|
||||
count=`expr $count + 1`
|
||||
|
||||
# if a cookie with $mod_name exists...
|
||||
if [ -e cookies/$mod_name ]; then
|
||||
# ...package has already been built
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "*** processing module $mod_name ($count of $num_modules) ***"
|
||||
echo ""
|
||||
|
||||
# download file
|
||||
download_file $mod_file
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ""
|
||||
echo "failed to download $mod_file - aborting build"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd build_dir
|
||||
|
||||
# if pkg has not yet been extracted, do so now
|
||||
if [ ! -d $mod_name ]; then
|
||||
echo $mod_file | grep -q tar.bz2
|
||||
if [ $? -eq 0 ]; then
|
||||
tar xjf ../downloads/$mod_file > /dev/null 2>&1
|
||||
else
|
||||
tar xzf ../downloads/$mod_file > /dev/null 2>&1
|
||||
fi
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "error extracting module $mod_name"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# patch and configure module - we only need to do this once
|
||||
cd $mod_name
|
||||
# check for patches
|
||||
if [ -e ../../$mod_name.patch ]; then
|
||||
patch -p1 < ../../$mod_name.patch
|
||||
fi
|
||||
# now configure
|
||||
./configure --prefix=$PREFIX_DIR $mod_args
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "configuration failed for module $mn"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# make module
|
||||
make
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ""
|
||||
echo "make failed for module $mod_name"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# install module
|
||||
make install
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ""
|
||||
echo "make install failed for module $mod_name"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# special case after installing python make this sym link
|
||||
# so Mesa builds using this python version
|
||||
case "$mod_name" in
|
||||
*Python-2*)
|
||||
ln -s python $PREFIX_DIR/bin/python2
|
||||
;;
|
||||
esac
|
||||
|
||||
cd ../..
|
||||
touch cookies/$mod_name
|
||||
return 0
|
||||
}
|
||||
|
||||
# this is where we store list of modules to be processed
|
||||
data_file=x11_file_list.txt
|
||||
|
||||
# this is the default download location for most modules
|
||||
download_url=http://www.x.org/releases/X11R7.6/src/everything
|
||||
|
||||
num_modules=`cat $data_file | wc -l`
|
||||
count=0
|
||||
|
||||
##########################
|
||||
# program flow starts here
|
||||
##########################
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo ""
|
||||
echo "usage: build.sh <installation dir>"
|
||||
echo "usage: build.sh <clean>"
|
||||
echo "usage: build.sh default"
|
||||
echo ""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# remove all modules
|
||||
if [ "$1" = "clean" ]; then
|
||||
echo "removing source modules"
|
||||
remove_modules
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "default" ]; then
|
||||
export PREFIX_DIR=$PWD/staging
|
||||
else
|
||||
export PREFIX_DIR=$1
|
||||
fi
|
||||
|
||||
if ! test -d $PREFIX_DIR; then
|
||||
echo "dir does not exit, creating [$PREFIX_DIR]"
|
||||
mkdir $PREFIX_DIR
|
||||
if ! test $? -eq 0; then
|
||||
echo "mkdir failed [$PREFIX_DIR]"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "using $PREFIX_DIR"
|
||||
|
||||
export PKG_CONFIG_PATH=$PREFIX_DIR/lib/pkgconfig:$PREFIX_DIR/share/pkgconfig
|
||||
export PATH=$PREFIX_DIR/bin:$PATH
|
||||
export LD_LIBRARY_PATH=$PREFIX_DIR/lib
|
||||
# really only needed for x84
|
||||
export CFLAGS=-fPIC
|
||||
|
||||
# prefix dir must exist...
|
||||
if [ ! -d $PREFIX_DIR ]; then
|
||||
mkdir -p $PREFIX_DIR
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "$PREFIX_DIR does not exist; failed to create it - cannot continue"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# ...and be writable
|
||||
if [ ! -w $PREFIX_DIR ]; then
|
||||
echo "directory $PREFIX_DIR is not writable - cannot continue"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# create a downloads dir
|
||||
if [ ! -d downloads ]; then
|
||||
mkdir downloads
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "error creating downloads directory"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# this is where we do the actual build
|
||||
if [ ! -d build_dir ]; then
|
||||
mkdir build_dir
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "error creating build_dir directory"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# this is where we store cookie files
|
||||
if [ ! -d cookies ]; then
|
||||
mkdir cookies
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "error creating cookies directory"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
while read line
|
||||
do
|
||||
mod_file=`echo $line | cut -d':' -f1`
|
||||
mod_dir=`echo $line | cut -d':' -f2`
|
||||
mod_args=`echo $line | cut -d':' -f3`
|
||||
mod_args=`eval echo $mod_args`
|
||||
|
||||
make_it $mod_file $mod_dir "$mod_args"
|
||||
|
||||
done < $data_file
|
||||
|
||||
echo "All done"
|
@ -1,13 +0,0 @@
|
||||
diff --git a/src/Xge.c b/src/Xge.c
|
||||
index 7a583e5..2ea5d27 100644
|
||||
--- a/src/Xge.c
|
||||
+++ b/src/Xge.c
|
||||
@@ -294,7 +294,7 @@ _xgeEventToWire(Display* dpy, XEvent* re, xEvent* event)
|
||||
/*
|
||||
* Extensions need to register callbacks for their events.
|
||||
*/
|
||||
-Bool
|
||||
+_X_HIDDEN Bool
|
||||
xgeExtRegister(Display* dpy, int offset, XExtensionHooks* callbacks)
|
||||
{
|
||||
XGEExtNode* newExt;
|
@ -1,100 +0,0 @@
|
||||
Python-2.7.tar.bz2 : Python-2.7 :
|
||||
util-macros-1.11.0.tar.bz2 : util-macros-1.11.0 :
|
||||
font-adobe-75dpi-1.0.3.tar.bz2 : font-adobe-75dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-adobe-100dpi-1.0.3.tar.bz2 : font-adobe-100dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-adobe-utopia-75dpi-1.0.4.tar.bz2 : font-adobe-utopia-75dpi-1.0.4 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-adobe-utopia-100dpi-1.0.4.tar.bz2 : font-adobe-utopia-100dpi-1.0.4 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-adobe-utopia-type1-1.0.4.tar.bz2 : font-adobe-utopia-type1-1.0.4 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-alias-1.0.3.tar.bz2 : font-alias-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-arabic-misc-1.0.3.tar.bz2 : font-arabic-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-bh-75dpi-1.0.3.tar.bz2 : font-bh-75dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-bh-100dpi-1.0.3.tar.bz2 : font-bh-100dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-bh-lucidatypewriter-75dpi-1.0.3.tar.bz2 : font-bh-lucidatypewriter-75dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-bh-lucidatypewriter-100dpi-1.0.3.tar.bz2 : font-bh-lucidatypewriter-100dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-bh-ttf-1.0.3.tar.bz2 : font-bh-ttf-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-bh-type1-1.0.3.tar.bz2 : font-bh-type1-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-bitstream-75dpi-1.0.3.tar.bz2 : font-bitstream-75dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-bitstream-100dpi-1.0.3.tar.bz2 : font-bitstream-100dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-bitstream-type1-1.0.3.tar.bz2 : font-bitstream-type1-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-cronyx-cyrillic-1.0.3.tar.bz2 : font-cronyx-cyrillic-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-cursor-misc-1.0.3.tar.bz2 : font-cursor-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-daewoo-misc-1.0.3.tar.bz2 : font-daewoo-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-dec-misc-1.0.3.tar.bz2 : font-dec-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-ibm-type1-1.0.3.tar.bz2 : font-ibm-type1-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-isas-misc-1.0.3.tar.bz2 : font-isas-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-jis-misc-1.0.3.tar.bz2 : font-jis-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-micro-misc-1.0.3.tar.bz2 : font-micro-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-misc-cyrillic-1.0.3.tar.bz2 : font-misc-cyrillic-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-misc-ethiopic-1.0.3.tar.bz2 : font-misc-ethiopic-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-misc-meltho-1.0.3.tar.bz2 : font-misc-meltho-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-misc-misc-1.1.2.tar.bz2 : font-misc-misc-1.1.2 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-mutt-misc-1.0.3.tar.bz2 : font-mutt-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-schumacher-misc-1.1.2.tar.bz2 : font-schumacher-misc-1.1.2 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-screen-cyrillic-1.0.4.tar.bz2 : font-screen-cyrillic-1.0.4 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-sony-misc-1.0.3.tar.bz2 : font-sony-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-sun-misc-1.0.3.tar.bz2 : font-sun-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-util-1.2.0.tar.bz2 : font-util-1.2.0 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-winitzki-cyrillic-1.0.3.tar.bz2 : font-winitzki-cyrillic-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
font-xfree86-type1-1.0.4.tar.bz2 : font-xfree86-type1-1.0.4 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
|
||||
xf86driproto-2.1.0.tar.bz2 : xf86driproto-2.1.0 :
|
||||
dri2proto-2.3.tar.bz2 : dri2proto-2.3 :
|
||||
glproto-1.4.12.tar.bz2 : glproto-1.4.12 :
|
||||
libpciaccess-0.12.0.tar.bz2 : libpciaccess-0.12.0 :
|
||||
libpthread-stubs-0.3.tar.bz2 : libpthread-stubs-0.3 :
|
||||
libdrm-2.4.26.tar.bz2 : libdrm-2.4.26 :
|
||||
damageproto-1.2.1.tar.bz2 : damageproto-1.2.1 :
|
||||
libXdamage-1.1.3.tar.bz2 : libXdamage-1.1.3 :
|
||||
makedepend-1.0.3.tar.bz2 : makedepend-1.0.3 :
|
||||
libxml2-sources-2.7.8.tar.gz : libxml2-2.7.8 :
|
||||
libpng-1.2.46.tar.gz : libpng-1.2.46 :
|
||||
pixman-0.15.20.tar.bz2 : pixman-0.15.20 : --disable-gtk
|
||||
freetype-2.4.6.tar.bz2 : freetype-2.4.6 :
|
||||
fontconfig-2.8.0.tar.gz : fontconfig-2.8.0 :
|
||||
cairo-1.8.8.tar.gz : cairo-1.8.8 :
|
||||
expat-2.0.1.tar.gz : expat-2.0.1 :
|
||||
xextproto-7.1.2.tar.bz2 : xextproto-7.1.2 :
|
||||
xproto-7.0.20.tar.bz2 : xproto-7.0.20 :
|
||||
xcb-proto-1.6.tar.bz2 : xcb-proto-1.6 :
|
||||
libxcb-1.7.tar.bz2 : libxcb-1.7 :
|
||||
libX11-1.4.0.tar.bz2 : libX11-1.4.0 :
|
||||
libXext-1.2.0.tar.bz2 : libXext-1.2.0 :
|
||||
libICE-1.0.7.tar.bz2 : libICE-1.0.7 :
|
||||
libSM-1.2.0.tar.bz2 : libSM-1.2.0 :
|
||||
libXt-1.0.9.tar.bz2 : libXt-1.0.9 :
|
||||
MesaLib-7.10.3.tar.bz2 : Mesa-7.10.3 : --with-expat=$PREFIX_DIR
|
||||
randrproto-1.3.2.tar.bz2 : randrproto-1.3.2 :
|
||||
renderproto-0.11.1.tar.bz2 : renderproto-0.11.1 :
|
||||
fixesproto-4.1.2.tar.bz2 : fixesproto-4.1.2 :
|
||||
xcmiscproto-1.2.1.tar.bz2 : xcmiscproto-1.2.1 :
|
||||
xtrans-1.2.6.tar.bz2 : xtrans-1.2.6 :
|
||||
xf86vidmodeproto-2.3.tar.bz2 : xf86vidmodeproto-2.3 :
|
||||
xf86bigfontproto-1.2.0.tar.bz2 : xf86bigfontproto-1.2.0 :
|
||||
scrnsaverproto-1.2.1.tar.bz2 : scrnsaverproto-1.2.1 :
|
||||
bigreqsproto-1.1.1.tar.bz2 : bigreqsproto-1.1.1 :
|
||||
resourceproto-1.1.1.tar.bz2 : resourceproto-1.1.1 :
|
||||
fontsproto-2.1.1.tar.bz2 : fontsproto-2.1.1 :
|
||||
inputproto-2.0.1.tar.bz2 : inputproto-2.0.1 :
|
||||
xf86dgaproto-2.1.tar.bz2 : xf86dgaproto-2.1 :
|
||||
videoproto-2.3.1.tar.bz2 : videoproto-2.3.1 :
|
||||
compositeproto-0.4.2.tar.bz2 : compositeproto-0.4.2 :
|
||||
recordproto-1.14.1.tar.bz2 : recordproto-1.14.1 :
|
||||
xineramaproto-1.2.tar.bz2 : xineramaproto-1.2 :
|
||||
libXau-1.0.6.tar.bz2 : libXau-1.0.6 :
|
||||
kbproto-1.0.5.tar.bz2 : kbproto-1.0.5 :
|
||||
libXdmcp-1.1.0.tar.bz2 : libXdmcp-1.1.0 :
|
||||
libxslt-1.1.26.tar.gz : libxslt-1.1.26 :
|
||||
libxkbfile-1.0.7.tar.bz2 : libxkbfile-1.0.7 :
|
||||
libfontenc-1.1.0.tar.bz2 : libfontenc-1.1.0 :
|
||||
libXfont-1.4.3.tar.bz2 : libXfont-1.4.3 :
|
||||
libXmu-1.1.0.tar.bz2 : libXmu-1.1.0 :
|
||||
libXxf86vm-1.1.1.tar.bz2 : libXxf86vm-1.1.1 :
|
||||
libXpm-3.5.9.tar.bz2 : libXpm-3.5.9 :
|
||||
libXaw-1.0.8.tar.bz2 : libXaw-1.0.8 :
|
||||
mkfontdir-1.0.6.tar.bz2 : mkfontdir-1.0.6 :
|
||||
xkbcomp-1.2.0.tar.bz2 : xkbcomp-1.2.0 :
|
||||
xdriinfo-1.0.4.tar.bz2 : xdriinfo-1.0.4 :
|
||||
xorg-server-1.9.3.tar.bz2 : xorg-server-1.9.3 :
|
||||
applewmproto-1.4.1.tar.bz2 : applewmproto-1.4.1 :
|
||||
bdftopcf-1.0.3.tar.bz2 : bdftopcf-1.0.3 :
|
||||
intltool-0.41.1.tar.gz : intltool-0.41.1 :
|
||||
xkeyboard-config-2.0.tar.bz2 : xkeyboard-config-2.0 :
|
@ -1,2 +0,0 @@
|
||||
|
||||
xorg server readme
|
@ -1,13 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
xhost +
|
||||
|
||||
if ! [ -d .nx ]
|
||||
then
|
||||
mkdir .nx
|
||||
fi
|
||||
|
||||
export LD_LIBRARY_PATH=$PWD
|
||||
|
||||
./nxproxy -S nx/nx,session=session,id=jay,root=.nx,connect=127.0.0.1:10,delta=1,stream=1,data=1
|
||||
|
@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
export LD_LIBRARY_PATH=$PWD
|
||||
|
||||
#./nxagent -R -bs -dpi 96 -geometry 1024x768 -noshpix -display nx/nx,link=adsl,delta=1,stream=1,data=1,a8taint=0,cache=4M:9 :9
|
||||
|
||||
# with cache
|
||||
#./nxagent -D -bs -ac -dpi 96 -geometry 1024x768 -noshpix -display nx/nx,link=adsl,delta=1,stream=1,data=1,cache=4M:9 :9
|
||||
|
||||
# without cache
|
||||
./nxagent -D -bs -ac -dpi 96 -geometry 1024x768 -noshpix -display nx/nx,link=adsl,delta=1,stream=1,data=1,cache=0M:9 :9
|
||||
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2004-2007 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#if !defined(ARCH_H)
|
||||
#define ARCH_H
|
||||
|
||||
/* check endianess */
|
||||
#if defined(__sparc__) || defined(__PPC__) || defined(__ppc__)
|
||||
#define B_ENDIAN
|
||||
#elif __BYTE_ORDER == __LITTLE_ENDIAN
|
||||
#define L_ENDIAN
|
||||
#elif __BYTE_ORDER == __BIG_ENDIAN
|
||||
#define B_ENDIAN
|
||||
#endif
|
||||
/* check if we need to align data */
|
||||
#if defined(__sparc__) || defined(__alpha__) || defined(__hppa__) || \
|
||||
defined(__AIX__) || defined(__PPC__) || defined(__mips__) || \
|
||||
defined(__ia64__) || defined(__ppc__)
|
||||
#define NEED_ALIGN
|
||||
#endif
|
||||
|
||||
/* defines for thread creation factory functions */
|
||||
#if defined(_WIN32)
|
||||
#define THREAD_RV unsigned long
|
||||
#define THREAD_CC __stdcall
|
||||
#else
|
||||
#define THREAD_RV void*
|
||||
#define THREAD_CC
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__) || defined(_WIN32)
|
||||
#define APP_CC __fastcall
|
||||
#define DEFAULT_CC __cdecl
|
||||
#else
|
||||
#define APP_CC
|
||||
#define DEFAULT_CC
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(__BORLANDC__)
|
||||
#define EXPORT_CC _export __cdecl
|
||||
#else
|
||||
#define EXPORT_CC
|
||||
#endif
|
||||
#else
|
||||
#define EXPORT_CC
|
||||
#endif
|
||||
|
||||
typedef char ti8;
|
||||
typedef unsigned char tui8;
|
||||
typedef signed char tsi8;
|
||||
typedef short ti16;
|
||||
typedef unsigned short tui16;
|
||||
typedef signed short tsi16;
|
||||
typedef int ti32;
|
||||
typedef unsigned int tui32;
|
||||
typedef signed int tsi32;
|
||||
typedef long tbus;
|
||||
|
||||
#endif
|
@ -1,265 +0,0 @@
|
||||
|
||||
#include "os_calls.h"
|
||||
|
||||
int g_loc_io_count = 0; // bytes read from local port
|
||||
int g_rem_io_count = 0; // bytes read from remote port
|
||||
|
||||
static int g_terminated = 0;
|
||||
static char g_buf[1024 * 32];
|
||||
|
||||
/*****************************************************************************/
|
||||
static int
|
||||
main_loop(char* local_port, char* remote_ip, char* remote_port, int hexdump)
|
||||
{
|
||||
int lis_sck;
|
||||
int acc_sck;
|
||||
int con_sck;
|
||||
int sel;
|
||||
int count;
|
||||
int sent;
|
||||
int error;
|
||||
int i;
|
||||
int acc_to_con;
|
||||
int con_to_acc;
|
||||
|
||||
acc_to_con = 0;
|
||||
con_to_acc = 0;
|
||||
acc_sck = 0;
|
||||
|
||||
/* create the listening socket and setup options */
|
||||
lis_sck = g_tcp_socket();
|
||||
g_tcp_set_non_blocking(lis_sck);
|
||||
error = g_tcp_bind(lis_sck, local_port);
|
||||
if (error != 0)
|
||||
{
|
||||
g_writeln("bind failed");
|
||||
}
|
||||
|
||||
/* listen for an incomming connection */
|
||||
if (error == 0)
|
||||
{
|
||||
error = g_tcp_listen(lis_sck);
|
||||
if (error == 0)
|
||||
{
|
||||
g_writeln("listening for connection");
|
||||
}
|
||||
}
|
||||
|
||||
/* accept an incomming connection */
|
||||
if (error == 0)
|
||||
{
|
||||
while ((!g_terminated) && (error == 0))
|
||||
{
|
||||
acc_sck = g_tcp_accept(lis_sck);
|
||||
if ((acc_sck == -1) && g_tcp_last_error_would_block(lis_sck))
|
||||
{
|
||||
g_sleep(100);
|
||||
}
|
||||
else if (acc_sck == -1)
|
||||
{
|
||||
error = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (error == 0)
|
||||
{
|
||||
error = g_terminated;
|
||||
}
|
||||
|
||||
/* stop listening */
|
||||
g_tcp_close(lis_sck);
|
||||
lis_sck = 0;
|
||||
if (error == 0)
|
||||
{
|
||||
g_writeln("got connection");
|
||||
}
|
||||
}
|
||||
|
||||
/* connect outgoing socket */
|
||||
con_sck = 0;
|
||||
if (error == 0)
|
||||
{
|
||||
con_sck = g_tcp_socket();
|
||||
g_tcp_set_non_blocking(con_sck);
|
||||
error = g_tcp_connect(con_sck, remote_ip, remote_port);
|
||||
if ((error == -1) && g_tcp_last_error_would_block(con_sck))
|
||||
{
|
||||
error = 0;
|
||||
i = 0;
|
||||
while ((!g_tcp_can_send(con_sck, 100)) && (!g_terminated) && (i < 100))
|
||||
{
|
||||
g_sleep(100);
|
||||
i++;
|
||||
}
|
||||
if (i > 99)
|
||||
{
|
||||
g_writeln("timout connecting");
|
||||
error = 1;
|
||||
}
|
||||
if (g_terminated)
|
||||
{
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
if ((error != 0) && (!g_terminated))
|
||||
{
|
||||
g_writeln("error connecting to remote\r\n");
|
||||
}
|
||||
}
|
||||
while ((!g_terminated) && (error == 0))
|
||||
{
|
||||
sel = g_tcp_select(con_sck, acc_sck);
|
||||
if (sel == 0)
|
||||
{
|
||||
g_sleep(10);
|
||||
continue;
|
||||
}
|
||||
if (sel & 1)
|
||||
{
|
||||
// can read from con_sck w/o blocking
|
||||
count = g_tcp_recv(con_sck, g_buf, 1024 * 16, 0);
|
||||
error = count < 1;
|
||||
if (error == 0)
|
||||
{
|
||||
g_loc_io_count += count;
|
||||
con_to_acc += count;
|
||||
if (hexdump)
|
||||
{
|
||||
g_writeln("from remove, the socket from connect");
|
||||
g_hexdump(g_buf, count);
|
||||
}
|
||||
#if 0
|
||||
g_writeln("local_io_count: %d\tremote_io_count: %d",
|
||||
g_loc_io_count, g_rem_io_count);
|
||||
#endif
|
||||
sent = 0;
|
||||
while ((sent < count) && (error == 0) && (!g_terminated))
|
||||
{
|
||||
i = g_tcp_send(acc_sck, g_buf + sent, count - sent, 0);
|
||||
if ((i == -1) && g_tcp_last_error_would_block(acc_sck))
|
||||
{
|
||||
g_tcp_can_send(acc_sck, 1000);
|
||||
}
|
||||
else if (i < 1)
|
||||
{
|
||||
error = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sent += i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sel & 2)
|
||||
{
|
||||
// can read from acc_sck w/o blocking
|
||||
count = g_tcp_recv(acc_sck, g_buf, 1024 * 16, 0);
|
||||
error = count < 1;
|
||||
if (error == 0)
|
||||
{
|
||||
g_rem_io_count += count;
|
||||
acc_to_con += count;
|
||||
if (hexdump)
|
||||
{
|
||||
g_writeln("from accepted, the socket from accept");
|
||||
g_hexdump(g_buf, count);
|
||||
}
|
||||
#if 0
|
||||
g_writeln("local_io_count: %d\tremote_io_count: %d",
|
||||
g_loc_io_count, g_rem_io_count);
|
||||
#endif
|
||||
sent = 0;
|
||||
while ((sent < count) && (error == 0) && (!g_terminated))
|
||||
{
|
||||
i = g_tcp_send(con_sck, g_buf + sent, count - sent, 0);
|
||||
if ((i == -1) && g_tcp_last_error_would_block(con_sck))
|
||||
{
|
||||
g_tcp_can_send(con_sck, 1000);
|
||||
}
|
||||
else if (i < 1)
|
||||
{
|
||||
error = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
sent += i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
g_tcp_close(lis_sck);
|
||||
g_tcp_close(con_sck);
|
||||
g_tcp_close(acc_sck);
|
||||
g_writeln("acc_to_con %d", acc_to_con);
|
||||
g_writeln("con_to_acc %d", con_to_acc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
static int
|
||||
usage(void)
|
||||
{
|
||||
g_writeln("tcp_proxy <local-port> <remote-ip> <remote-port> [dump]");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
void
|
||||
proxy_shutdown(int sig)
|
||||
{
|
||||
g_writeln("shutting down");
|
||||
g_terminated = 1;
|
||||
}
|
||||
|
||||
void
|
||||
clear_counters(int sig)
|
||||
{
|
||||
g_writeln("cleared counters at: local_io_count: %d remote_io_count: %d",
|
||||
g_loc_io_count, g_rem_io_count);
|
||||
g_loc_io_count = 0;
|
||||
g_rem_io_count = 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
int dump;
|
||||
|
||||
if (argc < 4)
|
||||
{
|
||||
usage();
|
||||
return 0;
|
||||
}
|
||||
g_init();
|
||||
g_signal(2, proxy_shutdown); /* SIGINT */
|
||||
g_signal(9, proxy_shutdown); /* SIGKILL */
|
||||
g_signal(10, clear_counters);/* SIGUSR1*/
|
||||
g_signal(15, proxy_shutdown);/* SIGTERM */
|
||||
if (argc < 5)
|
||||
{
|
||||
while (!g_terminated)
|
||||
{
|
||||
g_loc_io_count = 0;
|
||||
g_rem_io_count = 0;
|
||||
main_loop(argv[1], argv[2], argv[3], 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dump = g_strcasecmp(argv[4], "dump") == 0;
|
||||
while (!g_terminated)
|
||||
{
|
||||
main_loop(argv[1], argv[2], argv[3], dump);
|
||||
}
|
||||
}
|
||||
g_deinit();
|
||||
return 0;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,208 +0,0 @@
|
||||
/*
|
||||
Copyright (c) 2004-2007 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
generic operating system calls
|
||||
*/
|
||||
|
||||
#if !defined(OS_CALLS_H)
|
||||
#define OS_CALLS_H
|
||||
|
||||
#include "arch.h"
|
||||
|
||||
void APP_CC
|
||||
g_init(void);
|
||||
void APP_CC
|
||||
g_deinit(void);
|
||||
void* APP_CC
|
||||
g_malloc(int size, int zero);
|
||||
void APP_CC
|
||||
g_free(void* ptr);
|
||||
void DEFAULT_CC
|
||||
g_printf(const char *format, ...);
|
||||
void DEFAULT_CC
|
||||
g_sprintf(char* dest, const char* format, ...);
|
||||
void DEFAULT_CC
|
||||
g_snprintf(char* dest, int len, const char* format, ...);
|
||||
void DEFAULT_CC
|
||||
g_writeln(const char* format, ...);
|
||||
void DEFAULT_CC
|
||||
g_write(const char* format, ...);
|
||||
void APP_CC
|
||||
g_hexdump(char* p, int len);
|
||||
void APP_CC
|
||||
g_memset(void* ptr, int val, int size);
|
||||
void APP_CC
|
||||
g_memcpy(void* d_ptr, const void* s_ptr, int size);
|
||||
int APP_CC
|
||||
g_getchar(void);
|
||||
int APP_CC
|
||||
g_tcp_set_no_delay(int sck);
|
||||
int APP_CC
|
||||
g_tcp_socket(void);
|
||||
int APP_CC
|
||||
g_tcp_local_socket(void);
|
||||
void APP_CC
|
||||
g_tcp_close(int sck);
|
||||
int APP_CC
|
||||
g_tcp_connect(int sck, const char* address, const char* port);
|
||||
int APP_CC
|
||||
g_tcp_force_send(int sck, char* data, int len);
|
||||
int APP_CC
|
||||
g_tcp_force_recv(int sck, char* data, int len);
|
||||
int APP_CC
|
||||
g_tcp_set_non_blocking(int sck);
|
||||
int APP_CC
|
||||
g_tcp_bind(int sck, char* port);
|
||||
int APP_CC
|
||||
g_tcp_local_bind(int sck, char* port);
|
||||
int APP_CC
|
||||
g_tcp_listen(int sck);
|
||||
int APP_CC
|
||||
g_tcp_accept(int sck);
|
||||
int APP_CC
|
||||
g_tcp_recv(int sck, void* ptr, int len, int flags);
|
||||
int APP_CC
|
||||
g_tcp_send(int sck, const void* ptr, int len, int flags);
|
||||
int APP_CC
|
||||
g_tcp_last_error_would_block(int sck);
|
||||
int APP_CC
|
||||
g_tcp_can_send(int sck, int millis);
|
||||
int APP_CC
|
||||
g_tcp_can_recv(int sck, int millis);
|
||||
int APP_CC
|
||||
g_tcp_select(int sck1, int sck2);
|
||||
void APP_CC
|
||||
g_sleep(int msecs);
|
||||
void APP_CC
|
||||
g_random(char* data, int len);
|
||||
int APP_CC
|
||||
g_abs(int i);
|
||||
int APP_CC
|
||||
g_memcmp(const void* s1, const void* s2, int len);
|
||||
int APP_CC
|
||||
g_file_open(const char* file_name);
|
||||
int APP_CC
|
||||
g_file_close(int fd);
|
||||
int APP_CC
|
||||
g_file_read(int fd, char* ptr, int len);
|
||||
int APP_CC
|
||||
g_file_write(int fd, char* ptr, int len);
|
||||
int APP_CC
|
||||
g_file_seek(int fd, int offset);
|
||||
int APP_CC
|
||||
g_file_lock(int fd, int start, int len);
|
||||
int APP_CC
|
||||
g_set_file_rights(const char* filename, int read, int write);
|
||||
int APP_CC
|
||||
g_chmod_hex(const char* filename, int flags);
|
||||
int APP_CC
|
||||
g_mkdir(const char* dirname);
|
||||
char* APP_CC
|
||||
g_get_current_dir(char* dirname, int maxlen);
|
||||
int APP_CC
|
||||
g_set_current_dir(char* dirname);
|
||||
int APP_CC
|
||||
g_file_exist(const char* filename);
|
||||
int APP_CC
|
||||
g_directory_exist(const char* dirname);
|
||||
int APP_CC
|
||||
g_create_dir(const char* dirname);
|
||||
int APP_CC
|
||||
g_remove_dir(const char* dirname);
|
||||
int APP_CC
|
||||
g_file_delete(const char* filename);
|
||||
int APP_CC
|
||||
g_strlen(const char* text);
|
||||
char* APP_CC
|
||||
g_strcpy(char* dest, const char* src);
|
||||
char* APP_CC
|
||||
g_strncpy(char* dest, const char* src, int len);
|
||||
char* APP_CC
|
||||
g_strcat(char* dest, const char* src);
|
||||
char* APP_CC
|
||||
g_strdup(const char* in);
|
||||
int APP_CC
|
||||
g_strcmp(const char* c1, const char* c2);
|
||||
int APP_CC
|
||||
g_strncmp(const char* c1, const char* c2, int len);
|
||||
int APP_CC
|
||||
g_strcasecmp(const char* c1, const char* c2);
|
||||
int APP_CC
|
||||
g_strncasecmp(const char* c1, const char* c2, int len);
|
||||
int APP_CC
|
||||
g_atoi(char* str);
|
||||
int APP_CC
|
||||
g_pos(char* str, const char* to_find);
|
||||
long APP_CC
|
||||
g_load_library(char* in);
|
||||
int APP_CC
|
||||
g_free_library(long lib);
|
||||
void* APP_CC
|
||||
g_get_proc_address(long lib, const char* name);
|
||||
int APP_CC
|
||||
g_system(char* aexec);
|
||||
char* APP_CC
|
||||
g_get_strerror(void);
|
||||
int APP_CC
|
||||
g_execvp(const char* p1, char* args[]);
|
||||
int APP_CC
|
||||
g_execlp3(const char* a1, const char* a2, const char* a3);
|
||||
void APP_CC
|
||||
g_signal(int sig_num, void (*func)(int));
|
||||
void APP_CC
|
||||
g_signal_child_stop(void (*func)(int));
|
||||
void APP_CC
|
||||
g_unset_signals(void);
|
||||
int APP_CC
|
||||
g_fork(void);
|
||||
int APP_CC
|
||||
g_setgid(int pid);
|
||||
int APP_CC
|
||||
g_initgroups(const char* user, int gid);
|
||||
int APP_CC
|
||||
g_setuid(int pid);
|
||||
int APP_CC
|
||||
g_waitchild(void);
|
||||
int APP_CC
|
||||
g_waitpid(int pid);
|
||||
void APP_CC
|
||||
g_clearenv(void);
|
||||
int APP_CC
|
||||
g_setenv(const char* name, const char* value, int rewrite);
|
||||
char* APP_CC
|
||||
g_getenv(const char* name);
|
||||
int APP_CC
|
||||
g_exit(int exit_code);
|
||||
int APP_CC
|
||||
g_getpid(void);
|
||||
int APP_CC
|
||||
g_sigterm(int pid);
|
||||
int APP_CC
|
||||
g_getuser_info(const char* username, int* gid, int* uid, char* shell,
|
||||
char* dir, char* gecos);
|
||||
int APP_CC
|
||||
g_getgroup_info(const char* groupname, int* gid);
|
||||
int APP_CC
|
||||
g_check_user_in_group(const char* username, int gid, int* ok);
|
||||
int APP_CC
|
||||
g_time1(void);
|
||||
|
||||
#endif
|
@ -1,3 +0,0 @@
|
||||
|
||||
this is a project to develope a program to test xwindows
|
||||
|
@ -1,204 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
#include "common.h"
|
||||
|
||||
// multi byte values are stored in little endian
|
||||
|
||||
struct bmp_magic
|
||||
{
|
||||
char magic[2];
|
||||
};
|
||||
|
||||
struct bmp_hdr
|
||||
{
|
||||
uint32_t size; // file size in bytes
|
||||
uint16_t reserved1;
|
||||
uint16_t reserved2;
|
||||
uint32_t offset; // offset to image data, in bytes
|
||||
};
|
||||
|
||||
struct dib_hdr
|
||||
{
|
||||
uint32_t hdr_size;
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
uint16_t nplanes;
|
||||
uint16_t bpp;
|
||||
uint32_t compress_type;
|
||||
uint32_t image_size;
|
||||
int32_t hres;
|
||||
int32_t vres;
|
||||
uint32_t ncolors;
|
||||
uint32_t nimpcolors;
|
||||
};
|
||||
|
||||
// forward declarations
|
||||
int parse_bmp(char *filename, struct pic_info *pic_info);
|
||||
int parse_bmp_24(struct bmp_hdr *bmp_hdr, struct dib_hdr *dib_hdr, int fd, struct pic_info *pic_info);
|
||||
|
||||
int parse_bmp(char *filename, struct pic_info *pic_info)
|
||||
{
|
||||
int got_magic;
|
||||
int fd;
|
||||
int rval;
|
||||
|
||||
struct bmp_magic magic;
|
||||
struct bmp_hdr bmp_hdr;
|
||||
struct dib_hdr dib_hdr;
|
||||
|
||||
if ((fd = open(filename, O_RDONLY)) < 0) {
|
||||
printf("error opeing %s\n", filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// read BMP magic...
|
||||
if ((rval = read(fd, magic.magic, 2)) != 2) {
|
||||
fprintf(stderr, "error reading BMP signature from file %s\n", filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
got_magic = 0;
|
||||
|
||||
// ...and confirm that this is indeed a BMP file
|
||||
if ((magic.magic[0] == 'B') && (magic.magic[1] == 'M')) {
|
||||
// BM – Windows 3.1x, 95, NT, ... etc
|
||||
got_magic = 1;
|
||||
}
|
||||
else if ((magic.magic[0] == 'B') && (magic.magic[1] == 'A')) {
|
||||
// BA – OS/2 struct Bitmap Array
|
||||
got_magic = 1;
|
||||
}
|
||||
else if ((magic.magic[0] == 'C') && (magic.magic[1] == 'I')) {
|
||||
// CI – OS/2 struct Color Icon
|
||||
got_magic = 1;
|
||||
}
|
||||
else if ((magic.magic[0] == 'C') && (magic.magic[1] == 'P')) {
|
||||
// CP – OS/2 const Color Pointer
|
||||
got_magic = 1;
|
||||
}
|
||||
else if ((magic.magic[0] == 'I') && (magic.magic[1] == 'C')) {
|
||||
// IC – OS/2 struct Icon
|
||||
got_magic = 1;
|
||||
}
|
||||
else if ((magic.magic[0] == 'P') && (magic.magic[1] == 'T')) {
|
||||
// PT – OS/2 Pointer
|
||||
got_magic = 1;
|
||||
}
|
||||
|
||||
if (!got_magic) {
|
||||
fprintf(stderr, "%s is not a valid BMP file\n", filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// read BMP header
|
||||
if ((rval = read(fd, &bmp_hdr, sizeof(bmp_hdr))) < sizeof(bmp_hdr)) {
|
||||
fprintf(stderr, "error BMP header from file %s\n", filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// read DIB header
|
||||
if ((rval = read(fd, &dib_hdr, sizeof(dib_hdr))) < sizeof(dib_hdr)) {
|
||||
fprintf(stderr, "error reading DIB header from file %s\n", filename);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if 0
|
||||
printf("header size: %d\n", dib_hdr.hdr_size);
|
||||
printf("width: %d\n", dib_hdr.width);
|
||||
printf("height: %d\n", dib_hdr.height);
|
||||
printf("num planes: %d\n", dib_hdr.nplanes);
|
||||
printf("bpp: %d\n", dib_hdr.bpp);
|
||||
printf("comp type: %d\n", dib_hdr.compress_type);
|
||||
printf("image size: %d\n", dib_hdr.image_size);
|
||||
printf("hres: %d\n", dib_hdr.hres);
|
||||
printf("vres: %d\n", dib_hdr.vres);
|
||||
printf("ncolors: %d\n", dib_hdr.ncolors);
|
||||
printf("nimpcolors: %d\n", dib_hdr.nimpcolors);
|
||||
#endif
|
||||
|
||||
if (dib_hdr.compress_type) {
|
||||
printf("TODO: compressed images not yet supported\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pic_info->width = dib_hdr.width;
|
||||
pic_info->height = dib_hdr.height;
|
||||
|
||||
if (dib_hdr.bpp == 24) {
|
||||
rval = parse_bmp_24(&bmp_hdr, &dib_hdr, fd, pic_info);
|
||||
}
|
||||
close(fd);
|
||||
return rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* extract 24bit BMP data from image file
|
||||
*
|
||||
* @return 0 on success
|
||||
* @return -1 on failure
|
||||
*/
|
||||
|
||||
int parse_bmp_24(
|
||||
struct bmp_hdr *bmp_hdr,
|
||||
struct dib_hdr *dib_hdr,
|
||||
int fd,
|
||||
struct pic_info *pic_info
|
||||
)
|
||||
{
|
||||
char *file_data;
|
||||
char *ptr_file_data;
|
||||
char *mem_data;
|
||||
char *ptr_mem_data;
|
||||
char *cptr;
|
||||
|
||||
int w = dib_hdr->width; // picture width
|
||||
int h = dib_hdr->height; // picture height
|
||||
int bpl; // bytes per line
|
||||
int bytes;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
// bytes per image line = width x bytes_per_pixel + padding
|
||||
i = (w * 3) % 4;
|
||||
j = (i == 0) ? 0 : 4 - i;
|
||||
bpl = w * 3 + j;
|
||||
|
||||
// 24 bit depth, no alpha channel
|
||||
file_data = (char *) malloc(h * bpl);
|
||||
|
||||
// point to first line in image data, which is stored in reverse order
|
||||
ptr_file_data = (file_data + dib_hdr->image_size) - bpl;
|
||||
|
||||
// 24 bit depth, with alpha channel
|
||||
mem_data = (char *) malloc(w * h * 4);
|
||||
ptr_mem_data = mem_data;
|
||||
|
||||
pic_info->pixel_data = ptr_mem_data;
|
||||
|
||||
// seek to beginning of pixel data
|
||||
lseek(fd, bmp_hdr->offset, SEEK_SET);
|
||||
|
||||
// read all pixel data
|
||||
bytes = read(fd, file_data, dib_hdr->image_size);
|
||||
|
||||
// convert 24bit to 24 bit with alpha and store in reverse
|
||||
for (i = 0; i < h; i ++)
|
||||
{
|
||||
cptr = ptr_file_data;
|
||||
for (j = 0; j < w; j++)
|
||||
{
|
||||
*ptr_mem_data++ = *cptr++; // blue value
|
||||
*ptr_mem_data++ = *cptr++; // green value
|
||||
*ptr_mem_data++ = *cptr++; // red value
|
||||
*ptr_mem_data++ = 0; // alpha channel
|
||||
}
|
||||
ptr_file_data -= bpl;
|
||||
}
|
||||
|
||||
free(file_data);
|
||||
return 0;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#ifndef __XDEMO_H
|
||||
#define __XDEMO_H
|
||||
|
||||
#define DEBUG
|
||||
|
||||
#ifdef DEBUG
|
||||
#define dprint(x...) printf(x)
|
||||
#else
|
||||
#define dprint(x...)
|
||||
#endif
|
||||
|
||||
struct pic_info
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
char *pixel_data;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,674 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <signal.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "common.h"
|
||||
|
||||
// LK_TODO
|
||||
// http://tronche.com/gui/x/xlib/GC/convenience-functions/fill-tile-and-stipple.html
|
||||
// fill stipple
|
||||
|
||||
// drawfonts: XDrawString, XDrawImageString XDrawText XLoadFont XTextExtents
|
||||
// http://www.ac3.edu.au/SGI_Developer/books/XLib_PG/sgi_html/apa.html
|
||||
// http://www.ac3.edu.au/SGI_Developer/books/XLib_PG/sgi_html/index.html
|
||||
|
||||
// use jpg lib to convert bmp to jpg and vice versa
|
||||
|
||||
#define MAX_COLORS 5
|
||||
#define SCROLL_JUMP 1 // scroll in increments of g_winHeight
|
||||
#define SCROLL_SMOOTH1 2 // scroll using XPutImage + XCopyArea
|
||||
#define SCROLL_SMOOTH2 3 // scroll using XPutImage only
|
||||
|
||||
int parse_bmp(char *filename, struct pic_info *);
|
||||
int drawBMP(char *filename, int scroll_type);
|
||||
int signal_tcp_proxy(char *proxy_app);
|
||||
|
||||
// globals
|
||||
Display *g_disp;
|
||||
Window g_win;
|
||||
XColor g_colors[MAX_COLORS];
|
||||
GC g_gc;
|
||||
int g_winWidth;
|
||||
int g_winHeight;
|
||||
int g_delay_dur;
|
||||
|
||||
void start_timer(struct timeval *tv)
|
||||
{
|
||||
gettimeofday(tv, NULL);
|
||||
}
|
||||
|
||||
|
||||
uint32_t time_elapsed_ms(struct timeval tv)
|
||||
{
|
||||
struct timeval tv_now;
|
||||
uint32_t dur;
|
||||
|
||||
gettimeofday(&tv_now, NULL);
|
||||
dur = ((tv_now.tv_sec - tv.tv_sec) * 1000) + ((tv_now.tv_usec - tv.tv_usec) / 1000);
|
||||
return dur;
|
||||
}
|
||||
|
||||
|
||||
uint32_t time_elapsed_us(struct timeval tv)
|
||||
{
|
||||
struct timeval tv_now;
|
||||
uint32_t dur;
|
||||
|
||||
gettimeofday(&tv_now, NULL);
|
||||
dur = ((tv_now.tv_sec - tv.tv_sec) * 1000000) + (tv_now.tv_usec - tv.tv_usec);
|
||||
return dur;
|
||||
}
|
||||
|
||||
int drawLines(int count)
|
||||
{
|
||||
int x1;
|
||||
int y1;
|
||||
int x2;
|
||||
int y2;
|
||||
int i;
|
||||
int index;
|
||||
|
||||
if (count <= 0) {
|
||||
return 0; // nothing to do
|
||||
}
|
||||
|
||||
srandom(time(NULL));
|
||||
XClearArea(g_disp, g_win, 0, 0, g_winWidth, g_winHeight, 0);
|
||||
|
||||
for (i = 0, index = 0; i < count; i++)
|
||||
{
|
||||
x1 = random() % g_winWidth;
|
||||
y1 = random() % g_winHeight;
|
||||
x2 = random() % g_winWidth;
|
||||
y2 = random() % g_winHeight;
|
||||
XSetForeground(g_disp, g_gc, g_colors[index++].pixel);
|
||||
if (index == MAX_COLORS) {
|
||||
index = 0;
|
||||
}
|
||||
// from-to
|
||||
XDrawLine(g_disp, g_win, g_gc, x1, y1, x2, y2);
|
||||
XFlush(g_disp);
|
||||
usleep(g_delay_dur);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// LK_TODO support user defined w and h
|
||||
|
||||
int drawRectangles(int count)
|
||||
{
|
||||
int x1;
|
||||
int y1;
|
||||
int w;
|
||||
int h;
|
||||
int i;
|
||||
int index;
|
||||
|
||||
if (count <= 0) {
|
||||
return 0; // nothing to do
|
||||
}
|
||||
|
||||
srandom(time(NULL));
|
||||
XClearArea(g_disp, g_win, 0, 0, g_winWidth, g_winHeight, 0);
|
||||
|
||||
for (i = 0, index = 0; i < count; i++)
|
||||
{
|
||||
x1 = random() % g_winWidth;
|
||||
y1 = random() % g_winHeight;
|
||||
w = 160;
|
||||
h = 140;
|
||||
XSetForeground(g_disp, g_gc, g_colors[index++].pixel);
|
||||
if (index == MAX_COLORS) {
|
||||
index = 0;
|
||||
}
|
||||
//XDrawRectangle(g_disp, g_win, g_gc, x1, y1, w, h);
|
||||
XFillRectangle(g_disp, g_win, g_gc, x1, y1, w, h);
|
||||
XFlush(g_disp);
|
||||
usleep(g_delay_dur);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drawFont(int count, char *msg)
|
||||
{
|
||||
int x1;
|
||||
int y1;
|
||||
int i;
|
||||
int index;
|
||||
|
||||
#ifdef CHANGE_FONT_SIZE
|
||||
int w;
|
||||
int h;
|
||||
int actual_count;
|
||||
char **font_list;
|
||||
#endif
|
||||
|
||||
if (count <= 0) {
|
||||
return 0; // nothing to do
|
||||
}
|
||||
|
||||
srandom(time(NULL));
|
||||
XClearArea(g_disp, g_win, 0, 0, g_winWidth, g_winHeight, 0);
|
||||
|
||||
#ifdef CHANGE_FONT_SIZE
|
||||
font_list = XListFonts(g_disp, "−*−courier−*−*−*−*−0−0−*−*−*−0−*−*", 2000, &actual_count);
|
||||
if (!font_list) {
|
||||
printf("actual_count=%d\n", actual_count);
|
||||
for (i = 0; i < actual_count; i++)
|
||||
{
|
||||
printf("%s\n", font_list[i]);
|
||||
}
|
||||
XFreeFontNames(font_list);
|
||||
}
|
||||
else {
|
||||
printf("XListFonts() reted NULL\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
srandom(time(NULL));
|
||||
|
||||
for (i = 0, index = 0; i < count; i++)
|
||||
{
|
||||
x1 = random() % g_winWidth;
|
||||
y1 = random() % g_winHeight;
|
||||
XSetForeground(g_disp, g_gc, g_colors[index++].pixel);
|
||||
if (index == MAX_COLORS) {
|
||||
index = 0;
|
||||
}
|
||||
XDrawString(g_disp, g_win, g_gc, x1, y1, msg, strlen(msg));
|
||||
XFlush(g_disp);
|
||||
usleep(g_delay_dur);
|
||||
}
|
||||
return 0; // nothing to do
|
||||
}
|
||||
|
||||
/**
|
||||
* display a usage message
|
||||
*/
|
||||
|
||||
void
|
||||
usage()
|
||||
{
|
||||
printf("usage: xdemo [-l] [-r] [-s] [-f <string>] [-i <image file>] [-g <WxH>] [-c <count>] [-o <scroll type>] [-d <delay>] -z\n");
|
||||
printf(" -l draw lines\n");
|
||||
printf(" -r draw fill rectangles\n");
|
||||
printf(" -s draw stipple rectangles\n");
|
||||
printf(" -f <string> draw string using fonts\n");
|
||||
printf(" -i <image file> draw image\n");
|
||||
printf(" -g <WxH> geometry, default is 640x480\n");
|
||||
printf(" -c <count> iteration count, default is 5000\n");
|
||||
printf(" -d <delay> loop delay in micro seconds, default 1000\n");
|
||||
printf(" -o <jump|smooth1|smooth2> define scrolling method\n");
|
||||
printf(" -z <proxy_app> zero proxy counters for specified application\n\n");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
XEvent evt;
|
||||
Colormap colormap;
|
||||
struct timeval tv;
|
||||
int screenNumber;
|
||||
long eventMask;
|
||||
unsigned long white;
|
||||
unsigned long black;
|
||||
Status rc;
|
||||
int iters;
|
||||
int opt;
|
||||
int draw_lines;
|
||||
int draw_rects;
|
||||
int draw_stipples;
|
||||
int draw_fonts;
|
||||
int draw_image;
|
||||
int zero_counters;
|
||||
int scroll_type;
|
||||
char image_file[256];
|
||||
char proxy_app[256];
|
||||
char msg[4096];
|
||||
|
||||
// set some defaults
|
||||
g_winWidth = 640;
|
||||
g_winHeight = 480;
|
||||
iters = 5000;
|
||||
draw_lines = 1;
|
||||
draw_rects = 1;
|
||||
draw_stipples = 1;
|
||||
draw_fonts = 1;
|
||||
draw_image = 1;
|
||||
g_delay_dur = 1000;
|
||||
scroll_type = SCROLL_SMOOTH1;
|
||||
zero_counters = 0;
|
||||
strcpy(image_file, "yosemite.bmp");
|
||||
strcpy(msg, "To be or not to be!");
|
||||
|
||||
// process cmd line args
|
||||
opterr = 0;
|
||||
while ((opt = getopt(argc, argv, "lrsg:c:f:i:d:o:z:")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
case 'g':
|
||||
if (sscanf(optarg, "%dx%d", &g_winWidth, &g_winHeight) != 2) {
|
||||
fprintf(stderr, "\nerror: invalid geometry specified\n\n");
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'c':
|
||||
if (sscanf(optarg, "%d", &iters) != 1) {
|
||||
fprintf(stderr, "\nerror: invalid count specified\n\n");
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
draw_lines = 1;
|
||||
draw_rects = 0;
|
||||
draw_stipples = 0;
|
||||
draw_fonts = 0;
|
||||
draw_image = 0;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
draw_rects = 1;
|
||||
draw_lines = 0;
|
||||
draw_stipples = 0;
|
||||
draw_fonts = 0;
|
||||
draw_image = 0;
|
||||
break;
|
||||
|
||||
case 's':
|
||||
draw_stipples = 1;
|
||||
draw_lines = 0;
|
||||
draw_rects = 0;
|
||||
draw_fonts = 0;
|
||||
draw_image = 0;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
if (strlen(optarg) <= 0) {
|
||||
fprintf(stderr, "\nerror: -f option requires an argument\n\n");
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
draw_fonts = 1;
|
||||
strncpy(msg, optarg, 4096);
|
||||
draw_lines = 0;
|
||||
draw_rects = 0;
|
||||
draw_stipples = 0;
|
||||
draw_image = 0;
|
||||
break;
|
||||
|
||||
case 'i':
|
||||
if (strlen(optarg) <= 0) {
|
||||
fprintf(stderr, "\nerror: -i option requires an argument\n\n");
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
draw_image = 1;
|
||||
strncpy(image_file, optarg, 255);
|
||||
draw_lines = 0;
|
||||
draw_rects = 0;
|
||||
draw_stipples = 0;
|
||||
draw_fonts = 0;
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
usage();
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
printf("xdemo Ver 1.0\n");
|
||||
return 0;
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
if (sscanf(optarg, "%d", &g_delay_dur) != 1) {
|
||||
fprintf(stderr, "\nerror: -d option requires an argument\n\n");
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
if (strlen(optarg) <= 0) {
|
||||
fprintf(stderr, "\nerror: invalid proxy application specified\n\n");
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
strcpy(proxy_app, optarg);
|
||||
printf("##### LK_TODO: proxy_app=%s\n", proxy_app);
|
||||
zero_counters = 1;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
if (strcmp(optarg, "jump") == 0) {
|
||||
scroll_type = SCROLL_JUMP;
|
||||
}
|
||||
else if (strcmp(optarg, "smooth1") == 0) {
|
||||
scroll_type = SCROLL_SMOOTH1;
|
||||
}
|
||||
else if (strcmp(optarg, "smooth2") == 0) {
|
||||
scroll_type = SCROLL_SMOOTH2;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\ninvalid scroll type specified\n\n");
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
// must have at least one operation
|
||||
if ((!draw_lines) && (!draw_rects) && (!draw_stipples) &&
|
||||
(!draw_fonts) && (!draw_image)) {
|
||||
usage();
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_disp = XOpenDisplay(NULL);
|
||||
if (!g_disp) {
|
||||
dprint("error opening X display\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
screenNumber = DefaultScreen(g_disp);
|
||||
white = WhitePixel(g_disp, screenNumber);
|
||||
black = BlackPixel(g_disp, screenNumber);
|
||||
|
||||
g_win = XCreateSimpleWindow(g_disp,
|
||||
DefaultRootWindow(g_disp),
|
||||
50, 50, // origin
|
||||
g_winWidth, g_winHeight, // size
|
||||
0, black, // border
|
||||
white ); // backgd
|
||||
|
||||
XMapWindow(g_disp, g_win);
|
||||
//eventMask = StructureNotifyMask | MapNotify | VisibilityChangeMask;
|
||||
eventMask = StructureNotifyMask | VisibilityChangeMask;
|
||||
XSelectInput(g_disp, g_win, eventMask);
|
||||
|
||||
g_gc = XCreateGC(g_disp, g_win,
|
||||
0, // mask of values
|
||||
NULL ); // array of values
|
||||
#if 0
|
||||
do
|
||||
{
|
||||
dprint("about to call XNextEvent(...)\n");
|
||||
XNextEvent(g_disp, &evt);// calls XFlush
|
||||
dprint("returned from XNextEvent(...)\n");
|
||||
}
|
||||
//while(evt.type != MapNotify);
|
||||
while(evt.type != VisibilityNotify);
|
||||
#endif
|
||||
|
||||
// get access to the screen's color map
|
||||
colormap = DefaultColormap(g_disp, screenNumber);
|
||||
|
||||
// alloc red color
|
||||
rc = XAllocNamedColor(g_disp, colormap, "red", &g_colors[0], &g_colors[0]);
|
||||
if (rc == 0) {
|
||||
printf("XAllocNamedColor - failed to allocated 'red' color.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
rc = XAllocNamedColor(g_disp, colormap, "green", &g_colors[1], &g_colors[1]);
|
||||
if (rc == 0) {
|
||||
printf("XAllocNamedColor - failed to allocated 'green' color.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
rc = XAllocNamedColor(g_disp, colormap, "blue", &g_colors[2], &g_colors[2]);
|
||||
if (rc == 0) {
|
||||
printf("XAllocNamedColor - failed to allocated 'blue' color.\n");
|
||||
exit(1);
|
||||
}
|
||||
rc = XAllocNamedColor(g_disp, colormap, "yellow", &g_colors[3], &g_colors[3]);
|
||||
if (rc == 0) {
|
||||
printf("XAllocNamedColor - failed to allocated 'yellow' color.\n");
|
||||
exit(1);
|
||||
}
|
||||
rc = XAllocNamedColor(g_disp, colormap, "orange", &g_colors[4], &g_colors[4]);
|
||||
if (rc == 0) {
|
||||
printf("XAllocNamedColor - failed to allocated 'orange' color.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (zero_counters) {
|
||||
signal_tcp_proxy(proxy_app);
|
||||
}
|
||||
|
||||
if (draw_lines) {
|
||||
start_timer(&tv);
|
||||
drawLines(iters);
|
||||
printf("drew %d lines in %d ms\n", iters, time_elapsed_ms(tv));
|
||||
}
|
||||
|
||||
if (draw_rects) {
|
||||
start_timer(&tv);
|
||||
drawRectangles(iters);
|
||||
printf("drew %d rects in %d ms\n", iters, time_elapsed_ms(tv));
|
||||
}
|
||||
|
||||
if (draw_stipples) {
|
||||
start_timer(&tv);
|
||||
// LK_TODO
|
||||
}
|
||||
|
||||
if (draw_fonts) {
|
||||
start_timer(&tv);
|
||||
drawFont(iters, msg);
|
||||
printf("drew %d strings in %d ms\n", iters, time_elapsed_ms(tv));
|
||||
}
|
||||
|
||||
if (draw_image) {
|
||||
start_timer(&tv);
|
||||
drawBMP(image_file, scroll_type);
|
||||
printf("drew BMP in %d ms\n", time_elapsed_ms(tv));
|
||||
}
|
||||
|
||||
if (zero_counters) {
|
||||
signal_tcp_proxy(proxy_app);
|
||||
}
|
||||
|
||||
eventMask = ButtonPressMask|ButtonReleaseMask;
|
||||
|
||||
XSelectInput(g_disp, g_win, eventMask);
|
||||
|
||||
do
|
||||
{
|
||||
XNextEvent(g_disp, &evt); // calls XFlush()
|
||||
}
|
||||
while(evt.type != ButtonRelease);
|
||||
|
||||
XDestroyWindow(g_disp, g_win);
|
||||
XCloseDisplay(g_disp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int drawBMP(char *filename, int scroll_type)
|
||||
{
|
||||
struct pic_info pic_info;
|
||||
XImage *image;
|
||||
Visual *visual;
|
||||
Pixmap pixmap;
|
||||
int depth;
|
||||
int i;
|
||||
int j;
|
||||
|
||||
if (parse_bmp(filename, &pic_info) < 0) {
|
||||
exit(-1);
|
||||
}
|
||||
XClearArea(g_disp, g_win, 0, 0, g_winWidth, g_winHeight, 0);
|
||||
|
||||
depth = DefaultDepth(g_disp, DefaultScreen(g_disp));
|
||||
visual = DefaultVisual(g_disp, DefaultScreen(g_disp));
|
||||
|
||||
// create empty pixmap
|
||||
pixmap = XCreatePixmap(g_disp, g_win, pic_info.width, pic_info.height, depth);
|
||||
|
||||
// create an image from pixel data
|
||||
image = XCreateImage(g_disp, visual, depth, ZPixmap, 0, pic_info.pixel_data,
|
||||
pic_info.width, pic_info.height, 32, 0);
|
||||
|
||||
if (pic_info.height <= g_winHeight) {
|
||||
// image is too small to scroll
|
||||
XFlush(g_disp);
|
||||
XPutImage(g_disp, g_win, g_gc, image, 0, 0, 0, 0, pic_info.width, pic_info.height);
|
||||
XFlush(g_disp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (scroll_type == SCROLL_JUMP) {
|
||||
// copy image to pixelmap
|
||||
XPutImage(g_disp, pixmap, g_gc, image, 0, 0, 0, 0, pic_info.width, pic_info.height);
|
||||
|
||||
if (pic_info.height <= g_winHeight) {
|
||||
// image too small - no scrolling required
|
||||
XFlush(g_disp);
|
||||
XCopyArea(g_disp, // connection to X server
|
||||
pixmap, // source drawable
|
||||
g_win, // dest drawable
|
||||
g_gc, // graphics context
|
||||
0, 0, // source x,y
|
||||
pic_info.width, // width
|
||||
pic_info.height, // height
|
||||
0, 0); // dest x,y
|
||||
XFlush(g_disp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
j = pic_info.height / g_winHeight;
|
||||
if (pic_info.height % g_winHeight != 0) {
|
||||
// need to include the last part of the image
|
||||
j++;
|
||||
}
|
||||
XFlush(g_disp);
|
||||
for (i = 0; i < j; i++)
|
||||
{
|
||||
XCopyArea(g_disp, // connection to X server
|
||||
pixmap, // source drawable
|
||||
g_win, // dest drawable
|
||||
g_gc, // graphics context
|
||||
0, i * g_winHeight, // source x,y
|
||||
pic_info.width, // width
|
||||
pic_info.height, // height
|
||||
0, 0); // dest x,y
|
||||
XFlush(g_disp);
|
||||
sleep(3);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** smooth scroll the image
|
||||
*/
|
||||
|
||||
// number of lines to be scrolled
|
||||
j = pic_info.height - g_winHeight;
|
||||
|
||||
if (scroll_type == SCROLL_SMOOTH1) {
|
||||
XFlush(g_disp);
|
||||
XPutImage(g_disp, g_win, g_gc, image, 0, 0, 0, 0, pic_info.width, pic_info.height);
|
||||
XFlush(g_disp);
|
||||
usleep(10000);
|
||||
for (i = 0; i < j; i++)
|
||||
{
|
||||
XCopyArea(g_disp, g_win, g_win, g_gc, 0, 1, g_winWidth, g_winHeight - 1, 0, 0);
|
||||
XPutImage(g_disp, g_win, g_gc, image, 0, g_winHeight + i, 0, g_winHeight -1 , pic_info.width, 1);
|
||||
XFlush(g_disp);
|
||||
usleep(10000);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (scroll_type == SCROLL_SMOOTH2) {
|
||||
XFlush(g_disp);
|
||||
for (i = 0; i < j; i++)
|
||||
{
|
||||
XPutImage(g_disp, g_win, g_gc, image, 0, i, 0, 0, pic_info.width, pic_info.height - i);
|
||||
XFlush(g_disp);
|
||||
usleep(10000);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int process_bmp_event()
|
||||
{
|
||||
XEvent ev;
|
||||
long event_mask;
|
||||
|
||||
event_mask = ExposureMask|ButtonPressMask|ButtonReleaseMask|StructureNotifyMask;
|
||||
XSelectInput(g_disp, g_win, event_mask);
|
||||
XNextEvent(g_disp, &ev);
|
||||
switch(ev.type)
|
||||
{
|
||||
case Expose:
|
||||
printf("got expose event\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("did not get expose event\n");
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* send a SIGUSR1 to process tcp_proxy, causing it to clear counters
|
||||
*
|
||||
* @return 0 on success, -1 on failure
|
||||
*/
|
||||
|
||||
int signal_tcp_proxy(char *proc_name)
|
||||
{
|
||||
FILE *fp;
|
||||
char *cptr;
|
||||
char buf[2048];
|
||||
int pids[10];
|
||||
int status = 0;
|
||||
int num_procs;
|
||||
int i;
|
||||
|
||||
sprintf(buf, "pidof %s", proc_name);
|
||||
if ((fp = popen(buf, "r")) == NULL ) {
|
||||
printf("xdemo: popen() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
cptr = fgets(buf, 2047, fp);
|
||||
if (cptr == NULL) {
|
||||
pclose(fp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
num_procs = sscanf(buf, "%d %d %d %d %d %d %d %d %d %d",
|
||||
&pids[0], &pids[1], &pids[2], &pids[3], &pids[4],
|
||||
&pids[5], &pids[6], &pids[7], &pids[8], &pids[9]);
|
||||
if (num_procs > 0) {
|
||||
for (i = 0; i < num_procs; i++) {
|
||||
kill(pids[i], SIGUSR1);
|
||||
printf("sent SIGUSR1 to process %d\n", pids[i]);
|
||||
}
|
||||
}
|
||||
|
||||
pclose(fp);
|
||||
return status;
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.8 MiB |
@ -279,6 +279,7 @@ main(int argc, char** argv)
|
||||
g_writeln("Unknown Parameter");
|
||||
g_writeln("xrdp -h for help");
|
||||
g_writeln("");
|
||||
g_deinit();
|
||||
g_exit(0);
|
||||
}
|
||||
|
||||
@ -311,6 +312,7 @@ main(int argc, char** argv)
|
||||
}
|
||||
g_file_close(fd);
|
||||
}
|
||||
g_deinit();
|
||||
g_exit(0);
|
||||
}
|
||||
if (startup_params->no_daemon)
|
||||
@ -329,6 +331,7 @@ main(int argc, char** argv)
|
||||
g_writeln(" -nodaemon: don't fork into background");
|
||||
g_writeln(" -kill: shut down xrdp");
|
||||
g_writeln("");
|
||||
g_deinit();
|
||||
g_exit(0);
|
||||
}
|
||||
if (startup_params->version)
|
||||
@ -339,12 +342,14 @@ main(int argc, char** argv)
|
||||
g_writeln("See http://xrdp.sourceforge.net for more information.");
|
||||
g_writeln("Version %s",PACKAGE_VERSION);
|
||||
g_writeln("");
|
||||
g_deinit();
|
||||
g_exit(0);
|
||||
}
|
||||
if (g_file_exist(pid_file)) /* xrdp.pid */
|
||||
{
|
||||
g_writeln("It looks like xrdp is allready running,");
|
||||
g_writeln("if not delete the xrdp.pid file and try again");
|
||||
g_deinit();
|
||||
g_exit(0);
|
||||
}
|
||||
if (!no_daemon)
|
||||
@ -354,11 +359,13 @@ main(int argc, char** argv)
|
||||
if (fd == -1)
|
||||
{
|
||||
g_writeln("running in daemon mode with no access to pid files, quitting");
|
||||
g_deinit();
|
||||
g_exit(0);
|
||||
}
|
||||
if (g_file_write(fd, "0", 1) == -1)
|
||||
{
|
||||
g_writeln("running in daemon mode with no access to pid files, quitting");
|
||||
g_deinit();
|
||||
g_exit(0);
|
||||
}
|
||||
g_file_close(fd);
|
||||
@ -371,12 +378,14 @@ main(int argc, char** argv)
|
||||
if (pid == -1)
|
||||
{
|
||||
g_writeln("problem forking");
|
||||
g_deinit();
|
||||
g_exit(1);
|
||||
}
|
||||
if (0 != pid)
|
||||
{
|
||||
g_writeln("process %d started ok", pid);
|
||||
/* exit, this is the main process */
|
||||
g_deinit();
|
||||
g_exit(0);
|
||||
}
|
||||
g_sleep(1000);
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include "parse.h"
|
||||
#include "trans.h"
|
||||
#include "libxrdpinc.h"
|
||||
#include "xrdp_types.h"
|
||||
#include "xrdp_constants.h"
|
||||
#include "xrdp_types.h"
|
||||
#include "defines.h"
|
||||
#include "os_calls.h"
|
||||
#include "ssl_calls.h"
|
||||
|
@ -59,6 +59,8 @@ name=freerdp-any
|
||||
lib=libxrdpfreerdp1.so
|
||||
ip=ask
|
||||
port=ask3389
|
||||
username=ask
|
||||
password=ask
|
||||
|
||||
[xrdp7]
|
||||
name=sesman-X11rdp
|
||||
|
@ -34,15 +34,26 @@ xrdp_cache_create(struct xrdp_wm* owner,
|
||||
self->wm = owner;
|
||||
self->session = session;
|
||||
self->use_bitmap_comp = client_info->use_bitmap_comp;
|
||||
self->cache1_entries = client_info->cache1_entries;
|
||||
|
||||
self->cache1_entries = MIN(XRDP_MAX_BITMAP_CACHE_IDX,
|
||||
client_info->cache1_entries);
|
||||
self->cache1_entries = MAX(self->cache1_entries, 0);
|
||||
self->cache1_size = client_info->cache1_size;
|
||||
self->cache2_entries = client_info->cache2_entries;
|
||||
|
||||
self->cache2_entries = MIN(XRDP_MAX_BITMAP_CACHE_IDX,
|
||||
client_info->cache2_entries);
|
||||
self->cache2_entries = MAX(self->cache2_entries, 0);
|
||||
self->cache2_size = client_info->cache2_size;
|
||||
self->cache3_entries = client_info->cache3_entries;
|
||||
|
||||
self->cache3_entries = MIN(XRDP_MAX_BITMAP_CACHE_IDX,
|
||||
client_info->cache3_entries);
|
||||
self->cache3_entries = MAX(self->cache3_entries, 0);
|
||||
self->cache3_size = client_info->cache3_size;
|
||||
|
||||
self->bitmap_cache_persist_enable = client_info->bitmap_cache_persist_enable;
|
||||
self->bitmap_cache_version = client_info->bitmap_cache_version;
|
||||
self->pointer_cache_entries = client_info->pointer_cache_entries;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
@ -702,7 +702,7 @@ xrdp_mm_process_login_response(struct xrdp_mm* self, struct stream* s)
|
||||
{
|
||||
/* unix socket */
|
||||
self->chan_trans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
|
||||
g_snprintf(port, 255, "/tmp/xrdp_chansrv_socket_%d", 7200 + display);
|
||||
g_snprintf(port, 255, "/tmp/.xrdp/xrdp_chansrv_socket_%d", 7200 + display);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -187,6 +187,12 @@ xrdp_process_main_loop(struct xrdp_process* self)
|
||||
}
|
||||
libxrdp_disconnect(self->session);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* this will try to send a disconnect,
|
||||
maybe should check that connection got far enough */
|
||||
libxrdp_disconnect(self->session);
|
||||
}
|
||||
xrdp_process_mod_end(self);
|
||||
libxrdp_exit(self->session);
|
||||
self->session = 0;
|
||||
|
@ -150,7 +150,8 @@ struct xrdp_cache
|
||||
struct xrdp_palette_item palette_items[6];
|
||||
/* bitmap */
|
||||
int bitmap_stamp;
|
||||
struct xrdp_bitmap_item bitmap_items[3][2000];
|
||||
struct xrdp_bitmap_item bitmap_items[XRDP_MAX_BITMAP_CACHE_ID]
|
||||
[XRDP_MAX_BITMAP_CACHE_IDX];
|
||||
int use_bitmap_comp;
|
||||
int cache1_entries;
|
||||
int cache1_size;
|
||||
|
Loading…
Reference in New Issue
Block a user