Skip to content

Commit 7c79298

Browse files
author
ilsimo
committed
added first management code
added a rough management tool fixes in session.c
1 parent 1e33ad1 commit 7c79298

23 files changed

+1055
-105
lines changed

sesman/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
SESMANOBJ = sesman.o config.o sig.o session.o env.o \
44
os_calls.o d3des.o list.o file.o log.o access.o \
5-
scp.o scp_v0.o scp_v1.o thread.o lock.o
5+
scp.o scp_v0.o scp_v1.o scp_v1_mng.o thread.o lock.o
66

77
SESSVCOBJ = sessvc.o os_calls.o log.o
88

sesman/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ xrdp_sesman_SOURCES = \
2828
scp.c \
2929
scp_v0.c \
3030
scp_v1.c \
31+
scp_v1_mng.c \
3132
sesman.c \
3233
session.c \
3334
sig.c \

sesman/libscp/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ LIBSCPOBJ = libscp_vX.o libscp_v0.o \
44
libscp_init.o libscp_lock.o libscp_tcp.o \
55
libscp_session.o libscp_connection.o \
66
os_calls.o \
7-
# libscp_v1s_mng.o libscp_v1c_mng.o
7+
libscp_v1s_mng.o libscp_v1c_mng.o
88

99
CFGDIR = /etc/xrdp
1010
PIDDIR = /var/run

sesman/libscp/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ libscp_la_SOURCES = \
1313
libscp_v0.c \
1414
libscp_v1c.c \
1515
libscp_v1s.c \
16+
libscp_v1c_mng.c \
17+
libscp_v1s_mng.c \
1618
libscp_vX.c
1719

1820
libscp_la_LIBADD = \

sesman/libscp/libscp.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @file libscp.h
2323
* @brief libscp main header
2424
* @author Simone Fedele
25-
*
25+
*
2626
*/
2727

2828
#ifndef LIBSCP_H
@@ -33,6 +33,7 @@
3333
#endif
3434

3535
#include "libscp_types.h"
36+
#include "libscp_commands.h"
3637

3738
#include "libscp_connection.h"
3839
#include "libscp_session.h"
@@ -44,6 +45,7 @@
4445
#include "libscp_v0.h"
4546
#include "libscp_v1s.h"
4647
#include "libscp_v1c.h"
47-
#include "file_loc.h"
48+
#include "libscp_v1s_mng.h"
49+
#include "libscp_v1c_mng.h"
4850

4951
#endif

sesman/libscp/libscp_commands.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
This program is free software; you can redistribute it and/or modify
3+
it under the terms of the GNU General Public License as published by
4+
the Free Software Foundation; either version 2 of the License, or
5+
(at your option) any later version.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15+
16+
xrdp: A Remote Desktop Protocol server.
17+
Copyright (C) Jay Sorg 2005-2008
18+
*/
19+
20+
/**
21+
*
22+
* @file libscp_commands.h
23+
* @brief libscp data types definitions
24+
* @author Simone Fedele
25+
*
26+
*/
27+
28+
#ifndef LIBSCP_COMMANDS_H
29+
#define LIBSCP_COMMANDS_H
30+
31+
#include "libscp_commands_mng.h"
32+
33+
#define SCP_CMD_LOGIN 0x0001
34+
#define SCP_CMD_CONN_ERROR 0xFFFF
35+
36+
#endif
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
This program is free software; you can redistribute it and/or modify
3+
it under the terms of the GNU General Public License as published by
4+
the Free Software Foundation; either version 2 of the License, or
5+
(at your option) any later version.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15+
16+
xrdp: A Remote Desktop Protocol server.
17+
Copyright (C) Jay Sorg 2005-2008
18+
*/
19+
20+
/**
21+
*
22+
* @file libscp_commands_mng.h
23+
* @brief libscp data types definitions
24+
* @author Simone Fedele
25+
*
26+
*/
27+
28+
#ifndef LIBSCP_COMMANDS_MNG_H
29+
#define LIBSCP_COMMANDS_MNG_H
30+
31+
#define SCP_CMD_MNG_LOGIN 0x0001
32+
#define SCP_CMD_MNG_LOGIN_ALLOW 0x0002
33+
#define SCP_CMD_MNG_LOGIN_DENY 0x0003
34+
#define SCP_CMD_MNG_CMD_ERROR 0x0004
35+
#define SCP_CMD_MNG_LIST_REQ 0x0005
36+
#define SCP_CMD_MNG_LIST 0x0006
37+
#define SCP_CMD_MNG_ACTION 0x0007
38+
39+
#endif

sesman/libscp/libscp_session.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ scp_session_create()
5050
s->password = 0;
5151
s->hostname = 0;
5252
s->errstr = 0;
53+
s->mng = 0;
5354
s->locale[0]='\0';
5455

5556
return s;
@@ -69,6 +70,12 @@ scp_session_set_type(struct SCP_SESSION* s, tui8 type)
6970
break;
7071
case SCP_SESSION_TYPE_MANAGE:
7172
s->type = SCP_SESSION_TYPE_MANAGE;
73+
s->mng = g_malloc(sizeof(struct SCP_MNG_DATA),1);
74+
if (NULL == s->mng)
75+
{
76+
log_message(s_log, LOG_LEVEL_ERROR, "[session:%d] set_type: internal error", __LINE__);
77+
return 1;
78+
}
7279
break;
7380
default:
7481
log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_type: unknown type", __LINE__);
@@ -311,25 +318,31 @@ scp_session_destroy(struct SCP_SESSION* s)
311318
if (s->username)
312319
{
313320
g_free(s->username);
314-
s->username=0;
321+
s->username = 0;
315322
}
316323

317324
if (s->password)
318325
{
319326
g_free(s->password);
320-
s->password=0;
327+
s->password = 0;
321328
}
322329

323330
if (s->hostname)
324331
{
325332
g_free(s->hostname);
326-
s->hostname=0;
333+
s->hostname = 0;
327334
}
328335

329336
if (s->errstr)
330337
{
331338
g_free(s->errstr);
332-
s->errstr=0;
339+
s->errstr = 0;
340+
}
341+
342+
if (s->mng)
343+
{
344+
g_free(s->mng);
345+
s->mng = 0;
333346
}
334347

335348
g_free(s);

sesman/libscp/libscp_types.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
#define SCP_SERVER_MAX_LIST_SIZE 100
5858

59-
#define free_session(s) {g_free((s)->username); g_free((s)->password); g_free((s)->hostname); g_free(s);}
59+
#include "libscp_types_mng.h"
6060

6161
struct SCP_CONNECTION
6262
{
@@ -80,8 +80,9 @@ struct SCP_SESSION
8080
tui8 addr_type;
8181
tui32 ipv4addr;
8282
tui8 ipv6addr[16];
83-
tui16 display;
83+
SCP_DISPLAY display;
8484
char* errstr;
85+
struct SCP_MNG_DATA* mng;
8586
};
8687

8788
struct SCP_DISCONNECTED_SESSION
@@ -135,6 +136,8 @@ enum SCP_SERVER_STATES_E
135136
SCP_SERVER_STATE_SELECTION_CANCEL,
136137
/*SCP_SERVER_STATE_FORCE_NEW,*/
137138
SCP_SERVER_STATE_START_MANAGE,
139+
SCP_SERVER_STATE_MNG_LISTREQ,
140+
SCP_SERVER_STATE_MNG_ACTION,
138141
SCP_SERVER_STATE_END
139142
};
140143

sesman/libscp/libscp_types_mng.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
This program is free software; you can redistribute it and/or modify
3+
it under the terms of the GNU General Public License as published by
4+
the Free Software Foundation; either version 2 of the License, or
5+
(at your option) any later version.
6+
7+
This program is distributed in the hope that it will be useful,
8+
but WITHOUT ANY WARRANTY; without even the implied warranty of
9+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10+
GNU General Public License for more details.
11+
12+
You should have received a copy of the GNU General Public License
13+
along with this program; if not, write to the Free Software
14+
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15+
16+
xrdp: A Remote Desktop Protocol server.
17+
Copyright (C) Jay Sorg 2005-2008
18+
*/
19+
20+
/**
21+
*
22+
* @file libscp_types_mng.h
23+
* @brief libscp data types definitions
24+
* @author Simone Fedele
25+
*
26+
*/
27+
28+
#ifndef LIBSCP_TYPES_MNG_H
29+
#define LIBSCP_TYPES_MNG_H
30+
31+
#include "os_calls.h"
32+
#include "parse.h"
33+
#include "arch.h"
34+
#include "log.h"
35+
36+
enum SCP_MNG_COMMAND
37+
{
38+
SCP_MNG_CMD_KILL,
39+
SCP_MNG_CMD_DISCONNECT
40+
};
41+
42+
struct SCP_MNG_DATA
43+
{
44+
enum SCP_MNG_COMMAND cmd;
45+
SCP_SID sid;
46+
};
47+
48+
#endif

0 commit comments

Comments
 (0)