Commit Graph

3456 Commits

Author SHA1 Message Date
Ben Cohen
03dbc9546e Split shared memory discovery code into sesshm.c 2019-11-26 18:56:55 +00:00
Ben Cohen
6a13daea30 Tidy and improve code for session discovery
1. Add brackets round if bodies.
2. Use common os_calls/thread_calls functions where available and add
   new ones for:
     g_file_seek_rel_end()
     g_map_file_shared()
     g_unmap_file_shared()
     g_sleep_secs() [because usleep() can error for argument >= 1M]
     g_ftruncate()
     tc_mutex_timed_lock()
     tc_shared_mutex_create()
3. Separate declarations and initialisations.
4. Make macros for sesshm_try_lock() etc cleaner.

Also some minor bugfixes:

1. Fix bug in sesshm_try_lock() which begins "return 0".
2. The return value of pthread_mutex_init() in sesshm_create_new_shm()
   was ignored.  (No longer relevant because tc_shared_mutex_create() is
   now used.)
3. sesshm_map() set g_shm_mapping and returned a value.  (No longer
   relevant because using g_map_file_shared() it is simple enough not to
   need a function.)
2019-11-26 18:56:55 +00:00
Ben Cohen
e450230deb Add cast to fix C++ error 2019-11-26 18:56:55 +00:00
Ben Cohen
5ff8fb8a95 Add shared memory file to rediscover sessions #800
Allow xrdp-sesman to discover sessions still running that were created
by a previous xrdp-sesman process.

Implement this using a file-backed shared mmap region, visible to both
the daemon and session instances of xrdp-sesman.  Add a heartbeat
timestamp updated by the session instance so that the daemon instance
can infer whether the sessions in the mmap region are current or stale.

The shared memory can also be used to pass other data between daemon and
session instances, for example the session's idle time.

Add locking around access to g_sessions and the mmap region.  This is a
PTHREAD_PROCESS_SHARED lock which protects shared memory used by
separate processes.  Defining DEBUG_SESSION_LOCK enables logging to help
debug locking bugs.

Notes:

1. The number of sessions is limited by the size of the array in shared
memory, SESMAN_SHAREDMEM_MAX_SESSIONS.  This could be made dynamic
instead by growing the file and the mmap region.

2. If sesshm_try_open_existing_shm() finds a shm file but it looks
wrong, it creates a new one.  Perhaps it should instead exit with an
error?

3. In sesshm_thread() if the session xrdp-sesman notices that it has
been removed from the daemon's list it exits.  It should kill the X
server and/or window manager first.

4. This doesn't yet update idle times.  I need to work out how to get
this information from the X server.

5. This uses an array of sessions in the mmap region so the linked list
g_sessions might be redundant now.

6. Defining DONT_USE_SHM will let xrdp-sesman run without creating or
trying to use the mmap file.  This could be removed in the future.

7. I think the locking fixes an theorised bug where a session can be
removed from the g_sessions linked list in session_kill() (called from
the signal handler) at the same time as a session is added in
session_start_fork().
2019-11-26 18:56:55 +00:00
metalefty
352107fc5f
Merge pull request #1319 from metalefty/sighup
xrdp: do not exit when caught SIGHUP
2019-11-21 18:42:52 +09:00
jsorg71
36fc802bd9
Merge pull request #1441 from Belinsky-L-V/accept-neg1-cid
make vsock config accept -1 for cid and port
2019-11-14 01:20:51 -08:00
metalefty
2b614d275e
Merge pull request #1442 from yifanjiang/devel
mkpamrules: Support openSUSE's usage of /usr/etc/pam.d to contain the pam configuration files.
2019-11-13 13:30:31 +09:00
Yifan J
732d663c70 mkpamrules: Support openSUSE's usage of /usr/etc/pam.d
to contain the pam configuration files:

https://lists.opensuse.org/opensuse-factory/2019-08/msg00113.html
2019-11-13 11:13:07 +08:00
Belinsky-L-V
a2fd7c09fa make vsock config accept -1 for cid and port
linux/vm_sockets.h defines VMADDR_CID_ANY and VMADDR_PORT_ANY (both
equal to -1U) for vsock cid and port respectively. This change aims to
add the capability to parse negative cid and port numbers for vsock from
the config and pass them to the kernel.

Allows for valid configurations such as "port=vsock://-1:3389" to be
correctly processed, but will parse port and cid inputs like "---1" to
"-", which should currently get silently turned into 0 by atoi inside
g_sck_vsock_bind_address. Inputs that do not contain "-" get parsed as
by xrdp_listen_parse_integer.
2019-11-12 23:59:49 +03:00
jsorg71
8e10f0820c
Merge pull request #1439 from jsorg71/xup_shm_fix
xup: fix for when shmem_id changes
2019-11-08 23:49:09 -08:00
Jay Sorg
e52a4fd0ae xup: fix for when shmem_id changes 2019-11-07 23:28:07 -08:00
jsorg71
8853809310
Merge pull request #1437 from jsorg71/refresh_rect
cleanup refresh rect and check stream bounds
2019-11-07 21:47:36 -08:00
Jay Sorg
0fbbc47092 cleanup refresh rect and check stream bounds 2019-11-07 02:03:57 +00:00
metalefty
c57e867a3b
Merge pull request #1393 from metalefty/chansrv-channels-not-allowed
xrdp: skip connecting to chansrv when no channels enabled
2019-11-06 15:58:37 +09:00
metalefty
1897f8159f
Merge pull request #1427 from jsorg71/rdpsnd_audin_off
default rdpsnd audin off, can enable with --enable-rdpsndaudin
2019-10-24 13:02:42 +09:00
Jay Sorg
d7b1f12d9b default rdpsnd audin off, can enable with --enable-rdpsndaudin 2019-10-22 22:48:15 -07:00
jsorg71
04f885189a
Merge pull request #1425 from jsorg71/sesman-startup
sesman: fix for sesman startup without startup script
2019-10-17 20:54:22 -07:00
Jay Sorg
351c92dfba sesman: fix for sesman startup without startup script 2019-10-16 13:53:22 -07:00
Koichiro IWAO
f37faca65b
xrdp: skip connecting to chansrv when no channels enabled 2019-08-22 17:20:19 +09:00
metalefty
1e4b03eb3c
Merge pull request #1390 from metalefty/rfxcodec
update rfxcodec to the latest release
2019-08-20 00:34:10 +09:00
metalefty
deebc30f58
Merge pull request #1389 from metalefty/prepare-release
NEWS: fix typo in version s/v1.9.11/v0.9.11/
2019-08-20 00:31:55 +09:00
Koichiro IWAO
f097b8028d
update submodule to the latest release 2019-08-20 00:25:07 +09:00
Koichiro IWAO
471d7f0b24
NEWS: fix typo in version s/v1.9.11/v0.9.11/ 2019-08-19 17:16:10 +09:00
metalefty
2999b694e6
Merge pull request #1388 from metalefty/prepare-release
Prepare release
2019-08-19 16:16:59 +09:00
Koichiro IWAO
a350292628
bump version to v0.9.11 2019-08-19 16:00:33 +09:00
Koichiro IWAO
6928caa3bd
Update NEWS for v0.9.11 release 2019-08-19 15:58:36 +09:00
metalefty
6b826d03c8
Merge pull request #1386 from metalefty/xrdp-ini
xrdp: reformat comments/descriptions in xrdp.ini
2019-08-19 15:38:58 +09:00
metalefty
5e6e5bd869
Merge pull request #1387 from metalefty/travis
travis: unbreak the build, libxfixed-dev is required at minimum
2019-08-19 15:33:23 +09:00
Koichiro IWAO
a49edd03aa
travis: unbreak the build, libxfixed-dev is required at minimum 2019-08-19 15:20:14 +09:00
Koichiro IWAO
bcb281707b
xrdp: reformat comments/descriptions in xrdp.ini 2019-08-19 14:20:32 +09:00
jsorg71
d977e7caaa
Merge pull request #1372 from jsorg71/check_term_xup
xup: check term event for more responsive shutdown
2019-07-11 21:04:19 -07:00
Jay Sorg
313abde4ea xup: check term event for more responsive shutdown 2019-07-10 20:52:57 -07:00
jsorg71
cc2f918cd4
Merge pull request #1369 from jsorg71/mic-drdynvc
implement [MS-RDPEAI], mstsc compatible audio input
2019-07-10 11:49:38 -07:00
Jay Sorg
cf67dd56bf chansrv: no logic change, fix typo 2019-07-10 11:18:07 -07:00
Jay Sorg
417bb71abf chansrv: env var to disable rdpsnd record 2019-07-08 22:45:58 -07:00
Jay Sorg
933394c6be chansrv: remove excessive logging 2019-07-08 22:40:31 -07:00
Jay Sorg
8aedd31762 chansrv: use rdpsnd record if supported, else try AUDIO_INPUT(MS-RDPEAI) 2019-07-08 22:03:27 -07:00
Jay Sorg
c5798df0bd chansrv: hook up audin 2019-07-08 18:25:59 -07:00
Jay Sorg
ae40ff27c8 chansrv: audin close should chose channel 2019-07-07 22:05:46 -07:00
Jay Sorg
a9a823b0da chansrv: audio in partial working 2019-07-04 23:52:18 -07:00
Jay Sorg
3c9241022a chansrv: add audin.c/h 2019-07-03 21:31:52 -07:00
jsorg71
f627b29633
Merge pull request #1366 from jsorg71/listen-list
Listen list
2019-07-02 23:58:23 -07:00
Jay Sorg
1ef47cbf0b xrdp: fix seg fault when fork on connect and disconnect 2019-07-02 21:02:09 -07:00
Jay Sorg
37ade1cb25 remove unused variable 2019-07-01 18:07:36 -07:00
Jay Sorg
ee65ccb31d use address for tcp:// and tcp6:// and vsock:// 2019-07-01 17:56:50 -07:00
Jay Sorg
f42e38125e xrdp: enable listen_test, other parameter fixes about listen_test 2019-07-01 00:53:11 -07:00
Jay Sorg
0bc7803eaa add TCP V4 and V6 only socket functions 2019-06-29 23:59:18 -07:00
Jay Sorg
d7bd6f726b xrdp: support old xrdp.ini port, use_vsock style 2019-06-27 09:09:34 -07:00
Jay Sorg
216ba3b4d4 xrdp: update xrdp.ini.in 2019-06-26 22:16:44 -07:00
Jay Sorg
e3f41da2cc xrdp: parsing for listeners 2019-06-26 22:16:43 -07:00