Codebase list xrdp / upstream/0.9.19
New upstream version 0.9.19 Dominik George 2 years ago
206 changed file(s) with 12243 addition(s) and 3806 deletion(s). Raw diff Collapse all Expand all
1010 astyle_config.as \
1111 bootstrap \
1212 coding_style.md \
13 description-pak \
14 design.txt \
15 faq-compile.txt \
16 faq-general.txt \
17 file-loc.txt \
1813 fontdump \
19 install.txt \
2014 m4 \
21 postinstall-pak \
2215 vrplayer
2316
2417 if XRDP_NEUTRINORDP
5447 libxrdp \
5548 $(PAINTERDIR) \
5649 $(RFXCODECDIR) \
50 sesman \
5751 xrdp \
58 sesman \
5952 keygen \
6053 docs \
6154 instfiles \
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
162162 unique=`for i in $$list; do \
163163 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
164164 done | $(am__uniquify_input)`
165 ETAGS = etags
166 CTAGS = ctags
167 CSCOPE = cscope
168165 DIST_SUBDIRS = common vnc xup mc neutrinordp libxrdp libpainter \
169 librfxcodec xrdp sesman keygen docs instfiles genkeymap \
166 librfxcodec sesman xrdp keygen docs instfiles genkeymap \
170167 xrdpapi pkgconfig xrdpvr tests tools
171168 am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config_ac-h.in \
172 COPYING compile config.guess config.sub install-sh ltmain.sh \
173 missing tap-driver.sh
169 COPYING NEWS.md README.md compile config.guess config.sub \
170 install-sh ltmain.sh missing tap-driver.sh
174171 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
175172 distdir = $(PACKAGE)-$(VERSION)
176173 top_distdir = $(distdir)
230227 CHECK_LIBS = @CHECK_LIBS@
231228 CPP = @CPP@
232229 CPPFLAGS = @CPPFLAGS@
230 CSCOPE = @CSCOPE@
231 CTAGS = @CTAGS@
233232 CYGPATH_W = @CYGPATH_W@
234233 DEFS = @DEFS@
235234 DEPDIR = @DEPDIR@
241240 ECHO_N = @ECHO_N@
242241 ECHO_T = @ECHO_T@
243242 EGREP = @EGREP@
243 ETAGS = @ETAGS@
244244 EXEEXT = @EXEEXT@
245245 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
246246 FDKAAC_LIBS = @FDKAAC_LIBS@
250250 FUSE_CFLAGS = @FUSE_CFLAGS@
251251 FUSE_LIBS = @FUSE_LIBS@
252252 GREP = @GREP@
253 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
254 IMLIB2_LIBS = @IMLIB2_LIBS@
253255 INSTALL = @INSTALL@
254256 INSTALL_DATA = @INSTALL_DATA@
255257 INSTALL_PROGRAM = @INSTALL_PROGRAM@
373375 astyle_config.as \
374376 bootstrap \
375377 coding_style.md \
376 description-pak \
377 design.txt \
378 faq-compile.txt \
379 faq-general.txt \
380 file-loc.txt \
381378 fontdump \
382 install.txt \
383379 m4 \
384 postinstall-pak \
385380 vrplayer
386381
387382 @XRDP_NEUTRINORDP_FALSE@NEUTRINORDPDIR =
401396 libxrdp \
402397 $(PAINTERDIR) \
403398 $(RFXCODECDIR) \
399 sesman \
404400 xrdp \
405 sesman \
406401 keygen \
407402 docs \
408403 instfiles \
580575 distclean-tags:
581576 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
582577 -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
583
584578 distdir: $(BUILT_SOURCES)
585579 $(MAKE) $(AM_MAKEFLAGS) distdir-am
586580
0 # Release notes for xrdp v0.9.19 (2022/03/17)
1
2 ## General announcements
3 * Running xrdp and xrdp-sesman on separate hosts is still supported by this release, but is now deprecated. This is not secure. A future release will replace the TCP socket used between these processes with a Unix Domain Socket, and then cross-host running will not be possible.
4
5 ## New features
6 * Both inbound and outbound clipboards can now be restricted for text, files or images [Sponsored by @CyberTrust @clear-code and @kenhys] (#2087)
7
8 ## Bug fixes
9 * [CVE-2022-23613](https://www.cve.org/CVERecord?id=CVE-2022-23613): Privilege escalation on xrdp-sesman (This fix is also in the out-of-band v0.9.18.1 release)
10 * The versions of imlib2 used on RHEL 7 and 8 are now detected correctly (#2118)
11 * Some situations where zombie processes could exist have been resolved (#2146, #2151, #2168)
12 * Some null-pointer exceptions which can happen in the logging module have been addressed (#2149)
13 * Some minor logging errors have been corrected (#2152)
14 * The signal handling in sesman has been reworked to prevent race conditions when a child exits. This has also made it possible to reliably reload the sesman configuration with SIGHUP (#1729, #2168)
15
16 ## Internal changes
17 * Versions 0.13 and later of checklib can undefine the pre-processor symbol `HAVE_STDINT_H`. The xrdp tests now build successfully against these versions (#2124)
18 * OpenSSL packaging changes (#2130):-
19 - The OpenSSL 3 EVP interface is now fully supported
20 - When building against OpenSSL 3, an internal implementation of the RC4 cipher is used instead of the implementation from the OpenSSL legacy provider
21 - The wrapping of the OpenSSL library has been improved which should make it simpler to provide an alternative cryptographic provider in the future, if required
22 - The logging of TLS/non-TLS security negotiation has been improved
23 * cppcheck version used for CI bumped to 2.7 (#2140)
24 * The `s_check()` macro which is easily mis-used has been removed (#2144)
25 * Status values for the DRDYNVC channel are now available in `libxrdp/xrdp_channel.h`
26
27 ## Changes for packagers or developers
28 * On OpenSSL 3 systems, there is now no need to build with the `-Wno-error=deprecated-declarations` flag
29
30 ## Known issues
31
32 * On-the-fly resolution change requires the Microsoft Store version of Remote Desktop client but sometimes crashes on connect (#1869)
33 * xrdp's login dialog is not relocated at the center of the new resolution after on-the-fly resolution change happens (#1867)
34
35 -----------------------
36
37 # Release notes for xrdp v0.9.18.1 (2022/02/08)
38
39 This is a security fix release that includes fixes for the following privilege escalation vulnerability.
40
41 * [CVE-2022-23613: Privilege escalation on xrdp-sesman](https://www.cve.org/CVERecord?id=CVE-2022-23613)
42
43 Users who uses xrdp v0.9.17 or v0.9.18 are recommended to update to this version.
44
45 ## Special thanks
46
47 Thanks to [Gilad Kleinman](https://github.com/giladkl) reporting the vulnerability and reviewing fix.
48
49 -----------------------
50
51 # Release notes for xrdp v0.9.18 (2022/01/10)
52
53 ## General announcements
54 * Running xrdp and xrdp-sesman on separate hosts is still supported by this release, but is now deprecated. This is not secure. A future release will replace the TCP socket used between these processes with a Unix Domain Socket, and then cross-host running will not be possible.
55 * Special thanks for @trishume for contributing code to the RFX codec
56
57 ## New features
58 * Backgrounds and logos on the login screen can now be zoomed and scaled (#1962)
59 * Small change for Alpine Linux support (#2005)
60 * loongarch support (#2057)
61 * Improved Fail2ban support (#1976)
62
63 ## Bug fixes
64 * Logging is improved for security protocol level decisions (#1974, #1975)
65 * An unnecessary log error message which is always generated when running neutrinordp has been removed (#2016)
66 * An incorrect development log message has been fixed (#2074)
67 * Some informational and error messages written to the console on stdout have been removed or replaced with log messages (#2078 #2080)
68 * Failure to attach to the memory area shared with xorgxrdp is now logged (#2065)
69 * A regression in the VNC module logging which might cause a connection to drop out has been identified and fixed (#1989)
70 * Remote drive redirection now works if printer redirection is also requested by the client (#327)
71 * Some file names could not be copied from the client to the server over the clipboard. This is now fixed (#1992, #1995)
72 * A config value has been added which allows copy-pasting of files to work with Nautilus for GNOME 3 versions >= 3.29.92 (#1994, #1996)
73 * Clipboard now works properly when files can't be read (#1997 #2001)
74 * (xorgxrdp v0.2.18) The screen is fully refreshed after initialising shared memory which should fix black screen problems like #1964
75 * An incorrect initialisation reported by @qarmin has been fixed (#1909)
76 * Some minor memory leaks have been fixed (#2014 #2028)
77 * A hard hang in chansrv when copying files from the remote system has been addressed (#2032)
78 * Users can now capitalise username and password on the login screen if required (#2061)
79 * Some failed size checks in the fastpath code with `--enable-devel-streamcheck` have been addressed (#2066,#2070)
80 * Log level for clipboard restriction has been promoted from DEVEL DEBUG to INFO (#2088)
81 * A buffer overflow in the RFX codec associated with large screens has been fixed (#2087)
82
83 ## Internal changes
84 * Some 64-bit packages are removed during the 32-bit CI build process in an attempt to make this more robust (#1985)
85 * Minor improvements to error checking and logging for file copy-paste (#1996)
86 * Now uses cppcheck 2.6 for CI builds (#2008)
87 * Generated systemd unit files now ignored by git (#2006)
88 * More internal tests (#2015)
89 * Some unnecessary files have been removed from the distribution (#2030)
90 * The `which` command in shell scripts has been replaced with `command -v` (#2067)
91 * Additional unit tests added for `g_file_get_size()` (#1988)
92 * A compiler warning with -O3 on gcc 11.1 has been addressed (#2105)
93 * An unused declaration for xrdp_wm_drdynvc_up has been removed (#2098)
94 * The SCP V0 code has been unified, which will make it easier to update and replace (#2011)
95 * Monitor processing unit tests for existing xrdp_sec function have been added (#1932)
96 * The librfxcodec has been updated as part of #2087, and also to add stack frames to assemble code to assist debugging
97
98 ## Changes for packagers or developers
99 * The `--with-imlib2` option has been added. If xrdp is built with imlib2, the login screen supports more image formats for the background and logo, and better quality zooming and scaling (#1962)
100
101 ## Known issues
102
103 * On-the-fly resolution change requires the Microsoft Store version of Remote Desktop client but sometimes crashes on connect (#1869)
104 * xrdp's login dialog is not relocated at the center of the new resolution after on-the-fly resolution change happens (#1867)
105
106 -----------------------
107
0108 # Release notes for xrdp v0.9.17 (2021/08/31)
1109
2110 ## General announcements
150258
151259 This is a security fix release that includes fixes for the following local buffer overflow vulnerability.
152260
153 * [CVE-2022-4044: Local users can perform a buffer overflow attack against the xrdp-sesman service and then impersonate it](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-4044)
261 * [CVE-2020-4044: Local users can perform a buffer overflow attack against the xrdp-sesman service and then impersonate it](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-4044)
154262
155263 This update is recommended for all xrdp users.
156264
11 [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/neutrinolabs/xrdp-questions)
22 ![Apache-License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)
33
4 *Current Version:* 0.9.17
4 [![Latest Version](https://img.shields.io/github/v/release/neutrinolabs/xrdp.svg?label=Latest%20Version)](https://github.com/neutrinolabs/xrdp/releases)
55
66 # xrdp - an open source RDP server
77
9494 be needed depending on your configuration.
9595
9696 To compile xrdp from a checked out git repository, you would additionally
97 need **autoconf**, **automake**, **libtool** and **pkgconfig**.
97 need **autoconf**, **automake**, **libtool** and **pkg-config**.
9898
9999 ### Get the source and build it
100100
0 # generated automatically by aclocal 1.16.3 -*- Autoconf -*-
1
2 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
0 # generated automatically by aclocal 1.16.5 -*- Autoconf -*-
1
2 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
33
44 # This file is free software; the Free Software Foundation
55 # gives unlimited permission to copy and/or distribute it,
1919 If you have problems, you may need to regenerate the build system entirely.
2020 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
2121
22 # Copyright (C) 2002-2020 Free Software Foundation, Inc.
22 # Copyright (C) 2002-2021 Free Software Foundation, Inc.
2323 #
2424 # This file is free software; the Free Software Foundation
2525 # gives unlimited permission to copy and/or distribute it,
3434 [am__api_version='1.16'
3535 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
3636 dnl require some minimum version. Point them to the right macro.
37 m4_if([$1], [1.16.3], [],
37 m4_if([$1], [1.16.5], [],
3838 [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
3939 ])
4040
5050 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
5151 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
5252 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
53 [AM_AUTOMAKE_VERSION([1.16.3])dnl
53 [AM_AUTOMAKE_VERSION([1.16.5])dnl
5454 m4_ifndef([AC_AUTOCONF_VERSION],
5555 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
5656 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
5757
5858 # AM_AUX_DIR_EXPAND -*- Autoconf -*-
5959
60 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
60 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
6161 #
6262 # This file is free software; the Free Software Foundation
6363 # gives unlimited permission to copy and/or distribute it,
109109
110110 # AM_COND_IF -*- Autoconf -*-
111111
112 # Copyright (C) 2008-2020 Free Software Foundation, Inc.
112 # Copyright (C) 2008-2021 Free Software Foundation, Inc.
113113 #
114114 # This file is free software; the Free Software Foundation
115115 # gives unlimited permission to copy and/or distribute it,
146146
147147 # AM_CONDITIONAL -*- Autoconf -*-
148148
149 # Copyright (C) 1997-2020 Free Software Foundation, Inc.
149 # Copyright (C) 1997-2021 Free Software Foundation, Inc.
150150 #
151151 # This file is free software; the Free Software Foundation
152152 # gives unlimited permission to copy and/or distribute it,
177177 Usually this means the macro was only invoked conditionally.]])
178178 fi])])
179179
180 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
180 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
181181 #
182182 # This file is free software; the Free Software Foundation
183183 # gives unlimited permission to copy and/or distribute it,
368368
369369 # Generate code to set up dependency tracking. -*- Autoconf -*-
370370
371 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
371 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
372372 #
373373 # This file is free software; the Free Software Foundation
374374 # gives unlimited permission to copy and/or distribute it,
436436
437437 # Do all the work for Automake. -*- Autoconf -*-
438438
439 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
439 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
440440 #
441441 # This file is free software; the Free Software Foundation
442442 # gives unlimited permission to copy and/or distribute it,
464464 # release and drop the old call support.
465465 AC_DEFUN([AM_INIT_AUTOMAKE],
466466 [AC_PREREQ([2.65])dnl
467 m4_ifdef([_$0_ALREADY_INIT],
468 [m4_fatal([$0 expanded multiple times
469 ]m4_defn([_$0_ALREADY_INIT]))],
470 [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl
467471 dnl Autoconf wants to disallow AM_ names. We explicitly allow
468472 dnl the ones we care about.
469473 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
500504 [_AM_SET_OPTIONS([$1])dnl
501505 dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
502506 m4_if(
503 m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
507 m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]),
504508 [ok:ok],,
505509 [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
506510 AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
552556 [m4_define([AC_PROG_OBJCXX],
553557 m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
554558 ])
559 # Variables for tags utilities; see am/tags.am
560 if test -z "$CTAGS"; then
561 CTAGS=ctags
562 fi
563 AC_SUBST([CTAGS])
564 if test -z "$ETAGS"; then
565 ETAGS=etags
566 fi
567 AC_SUBST([ETAGS])
568 if test -z "$CSCOPE"; then
569 CSCOPE=cscope
570 fi
571 AC_SUBST([CSCOPE])
572
555573 AC_REQUIRE([AM_SILENT_RULES])dnl
556574 dnl The testsuite driver may need to know about EXEEXT, so add the
557575 dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
633651 done
634652 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
635653
636 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
654 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
637655 #
638656 # This file is free software; the Free Software Foundation
639657 # gives unlimited permission to copy and/or distribute it,
654672 fi
655673 AC_SUBST([install_sh])])
656674
657 # Copyright (C) 2003-2020 Free Software Foundation, Inc.
675 # Copyright (C) 2003-2021 Free Software Foundation, Inc.
658676 #
659677 # This file is free software; the Free Software Foundation
660678 # gives unlimited permission to copy and/or distribute it,
675693
676694 # Check to see how 'make' treats includes. -*- Autoconf -*-
677695
678 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
696 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
679697 #
680698 # This file is free software; the Free Software Foundation
681699 # gives unlimited permission to copy and/or distribute it,
718736
719737 # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
720738
721 # Copyright (C) 1997-2020 Free Software Foundation, Inc.
739 # Copyright (C) 1997-2021 Free Software Foundation, Inc.
722740 #
723741 # This file is free software; the Free Software Foundation
724742 # gives unlimited permission to copy and/or distribute it,
752770
753771 # Helper functions for option handling. -*- Autoconf -*-
754772
755 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
773 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
756774 #
757775 # This file is free software; the Free Software Foundation
758776 # gives unlimited permission to copy and/or distribute it,
781799 AC_DEFUN([_AM_IF_OPTION],
782800 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
783801
784 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
802 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
785803 #
786804 # This file is free software; the Free Software Foundation
787805 # gives unlimited permission to copy and/or distribute it,
828846 # For backward compatibility.
829847 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
830848
831 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
849 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
832850 #
833851 # This file is free software; the Free Software Foundation
834852 # gives unlimited permission to copy and/or distribute it,
847865
848866 # Check to make sure that the build environment is sane. -*- Autoconf -*-
849867
850 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
868 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
851869 #
852870 # This file is free software; the Free Software Foundation
853871 # gives unlimited permission to copy and/or distribute it,
928946 rm -f conftest.file
929947 ])
930948
931 # Copyright (C) 2009-2020 Free Software Foundation, Inc.
949 # Copyright (C) 2009-2021 Free Software Foundation, Inc.
932950 #
933951 # This file is free software; the Free Software Foundation
934952 # gives unlimited permission to copy and/or distribute it,
9881006 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
9891007 ])
9901008
991 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
1009 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
9921010 #
9931011 # This file is free software; the Free Software Foundation
9941012 # gives unlimited permission to copy and/or distribute it,
10161034 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
10171035 AC_SUBST([INSTALL_STRIP_PROGRAM])])
10181036
1019 # Copyright (C) 2006-2020 Free Software Foundation, Inc.
1037 # Copyright (C) 2006-2021 Free Software Foundation, Inc.
10201038 #
10211039 # This file is free software; the Free Software Foundation
10221040 # gives unlimited permission to copy and/or distribute it,
10351053
10361054 # Check how to create a tarball. -*- Autoconf -*-
10371055
1038 # Copyright (C) 2004-2020 Free Software Foundation, Inc.
1056 # Copyright (C) 2004-2021 Free Software Foundation, Inc.
10391057 #
10401058 # This file is free software; the Free Software Foundation
10411059 # gives unlimited permission to copy and/or distribute it,
00 #!/bin/sh
11
2 which autoconf
2 command -v autoconf
33 if ! test $? -eq 0
44 then
55 echo "error, install autoconf"
66 exit 1
77 fi
88
9 which automake
9 command -v automake
1010 if ! test $? -eq 0
1111 then
1212 echo "error, install automake"
1313 exit 1
1414 fi
1515
16 which libtool || which libtoolize
16 command -v libtool || command -v libtoolize
1717 if ! test $? -eq 0
1818 then
1919 echo "error, install libtool"
2020 exit 1
2121 fi
2222
23 which pkg-config
23 command -v pkg-config
2424 if ! test $? -eq 0
2525 then
2626 echo "error, install pkg-config"
4646 fifo.h \
4747 file.c \
4848 file.h \
49 guid.c \
50 guid.h \
4951 list.c \
5052 list.h \
5153 list16.c \
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
142142 libcommon_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
143143 $(am__DEPENDENCIES_1)
144144 am__libcommon_la_SOURCES_DIST = arch.h base64.h base64.c defines.h \
145 fifo.c fifo.h file.c file.h list.c list.h list16.c list16.h \
146 log.c log.h os_calls.c os_calls.h parse.c parse.h rail.h \
147 ssl_calls.c ssl_calls.h string_calls.c string_calls.h \
148 thread_calls.c thread_calls.h trans.c trans.h \
145 fifo.c fifo.h file.c file.h guid.c guid.h list.c list.h \
146 list16.c list16.h log.c log.h os_calls.c os_calls.h parse.c \
147 parse.h rail.h ssl_calls.c ssl_calls.h string_calls.c \
148 string_calls.h thread_calls.c thread_calls.h trans.c trans.h \
149149 pixman-region16.c pixman-region.h
150150 @XRDP_PIXMAN_FALSE@am__objects_1 = pixman-region16.lo
151 am_libcommon_la_OBJECTS = base64.lo fifo.lo file.lo list.lo list16.lo \
152 log.lo os_calls.lo parse.lo ssl_calls.lo string_calls.lo \
153 thread_calls.lo trans.lo $(am__objects_1)
151 am_libcommon_la_OBJECTS = base64.lo fifo.lo file.lo guid.lo list.lo \
152 list16.lo log.lo os_calls.lo parse.lo ssl_calls.lo \
153 string_calls.lo thread_calls.lo trans.lo $(am__objects_1)
154154 libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS)
155155 AM_V_lt = $(am__v_lt_@AM_V@)
156156 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
172172 depcomp = $(SHELL) $(top_srcdir)/depcomp
173173 am__maybe_remake_depfiles = depfiles
174174 am__depfiles_remade = ./$(DEPDIR)/base64.Plo ./$(DEPDIR)/fifo.Plo \
175 ./$(DEPDIR)/file.Plo ./$(DEPDIR)/list.Plo \
175 ./$(DEPDIR)/file.Plo ./$(DEPDIR)/guid.Plo ./$(DEPDIR)/list.Plo \
176176 ./$(DEPDIR)/list16.Plo ./$(DEPDIR)/log.Plo \
177177 ./$(DEPDIR)/os_calls.Plo ./$(DEPDIR)/parse.Plo \
178178 ./$(DEPDIR)/pixman-region16.Plo ./$(DEPDIR)/ssl_calls.Plo \
222222 unique=`for i in $$list; do \
223223 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
224224 done | $(am__uniquify_input)`
225 ETAGS = etags
226 CTAGS = ctags
227225 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
228226 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
229227 ACLOCAL = @ACLOCAL@
241239 CHECK_LIBS = @CHECK_LIBS@
242240 CPP = @CPP@
243241 CPPFLAGS = @CPPFLAGS@
242 CSCOPE = @CSCOPE@
243 CTAGS = @CTAGS@
244244 CYGPATH_W = @CYGPATH_W@
245245 DEFS = @DEFS@
246246 DEPDIR = @DEPDIR@
252252 ECHO_N = @ECHO_N@
253253 ECHO_T = @ECHO_T@
254254 EGREP = @EGREP@
255 ETAGS = @ETAGS@
255256 EXEEXT = @EXEEXT@
256257 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
257258 FDKAAC_LIBS = @FDKAAC_LIBS@
261262 FUSE_CFLAGS = @FUSE_CFLAGS@
262263 FUSE_LIBS = @FUSE_LIBS@
263264 GREP = @GREP@
265 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
266 IMLIB2_LIBS = @IMLIB2_LIBS@
264267 INSTALL = @INSTALL@
265268 INSTALL_DATA = @INSTALL_DATA@
266269 INSTALL_PROGRAM = @INSTALL_PROGRAM@
415418 fifo.h \
416419 file.c \
417420 file.h \
421 guid.c \
422 guid.h \
418423 list.c \
419424 list.h \
420425 list16.c \
522527 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64.Plo@am__quote@ # am--include-marker
523528 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fifo.Plo@am__quote@ # am--include-marker
524529 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Plo@am__quote@ # am--include-marker
530 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/guid.Plo@am__quote@ # am--include-marker
525531 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Plo@am__quote@ # am--include-marker
526532 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list16.Plo@am__quote@ # am--include-marker
527533 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Plo@am__quote@ # am--include-marker
638644
639645 distclean-tags:
640646 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
641
642647 distdir: $(BUILT_SOURCES)
643648 $(MAKE) $(AM_MAKEFLAGS) distdir-am
644649
718723 -rm -f ./$(DEPDIR)/base64.Plo
719724 -rm -f ./$(DEPDIR)/fifo.Plo
720725 -rm -f ./$(DEPDIR)/file.Plo
726 -rm -f ./$(DEPDIR)/guid.Plo
721727 -rm -f ./$(DEPDIR)/list.Plo
722728 -rm -f ./$(DEPDIR)/list16.Plo
723729 -rm -f ./$(DEPDIR)/log.Plo
776782 -rm -f ./$(DEPDIR)/base64.Plo
777783 -rm -f ./$(DEPDIR)/fifo.Plo
778784 -rm -f ./$(DEPDIR)/file.Plo
785 -rm -f ./$(DEPDIR)/guid.Plo
779786 -rm -f ./$(DEPDIR)/list.Plo
780787 -rm -f ./$(DEPDIR)/list16.Plo
781788 -rm -f ./$(DEPDIR)/log.Plo
8080 defined(__AIX__) || defined(__m68k__) || defined(__mips__) || \
8181 defined(__ia64__) || defined(__arm__) || defined(__sh__) || \
8282 (defined(__PPC__) && defined(__BIG_ENDIAN__)) || \
83 (defined(__ppc__) && defined(__BIG_ENDIAN__))
83 (defined(__ppc__) && defined(__BIG_ENDIAN__)) || \
84 defined(__loongarch__)
8485 #define NEED_ALIGN
8586 #elif defined(__x86__) || defined(__x86_64__) || \
8687 defined(__AMD64__) || defined(_M_IX86) || defined (_M_AMD64) || \
00 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * Copyright (C) Koichiro Iwao 2017
1 * Copyright (C) 2022 Matt Burt, all xrdp contributors
42 *
53 * Licensed under the Apache License, Version 2.0 (the "License");
64 * you may not use this file except in compliance with the License.
1412 * See the License for the specific language governing permissions and
1513 * limitations under the License.
1614 *
17 * Base64 encoder / decoder
15 */
16
17 /**
18 * @file common/base64.c
19 * @brief Base64 encoder / decoder
1820 */
1921
2022 #if defined(HAVE_CONFIG_H)
2325
2426 #include "string_calls.h"
2527
26 #include <openssl/bio.h>
27 #include <openssl/evp.h>
28
28 #include "base64.h"
29
30 /*
31 * Values for invalid and padding characters, used in the charmap
32 * for converting base64 to binary
33 *
34 * Thse value are specially chosen to make it easy to detect padding or
35 * invalid characters by or-ing together the values looked up in
36 * a base64 quantum */
37 #define E_INVALID 0x40
38 #define E_PAD 0x80
39
40 /* Determine the character set on this platform */
41 #if ('a' == 0x61 && 'z' == 0x7a ) && \
42 ('A' == 0x41 && 'Z' == 0x5a ) && \
43 ('0' == 0x30 && '9' == 0x39 )
44 # define PLATFORM_IS_ASCII 1
45 #else
46 # error "Unrecognised character set on this platform"
47 #endif /* character set check */
48
49
50 /*
51 * Define a table to map the base64 character values to bit values.
52 */
53 #ifdef PLATFORM_IS_ASCII
54 #define CHARMAP_BASE 0x28
55 #define E_IV E_INVALID /* For table alignment */
56 const unsigned char charmap[] =
57 {
58 /* 0x28 */ E_IV, E_IV, E_IV, 0x3e, E_IV, E_IV, E_IV, 0x3f,
59 /* 0x30 */ 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
60 /* 0x38 */ 0x3c, 0x3d, E_IV, E_IV, E_IV, E_PAD, E_IV, E_IV,
61 /* 0x40 */ E_IV, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
62 /* 0x48 */ 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
63 /* 0x50 */ 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
64 /* 0x58 */ 0x17, 0x18, 0x19, E_IV, E_IV, E_IV, E_IV, E_IV,
65 /* 0x60 */ E_IV, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
66 /* 0x68 */ 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
67 /* 0x70 */ 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
68 /* 0x78 */ 0x31, 0x32, 0x33
69 };
70 #undef E_IV
71 #endif /* PLATFORM_IS_ASCII */
72
73
74 /**
75 * Lookup a value in the charmap
76 *
77 * @param x - byte to lookup. Only referenced once so can safely have
78 * side effects.
79 * @param dest - destination to assign result to.
80 */
81 #define CM_LOOKUP(x,dest) \
82 { \
83 unsigned int t = (unsigned int)(x) - CHARMAP_BASE;\
84 dest = (t < sizeof(charmap)) ? charmap[t] : E_INVALID; \
85 }
86
87 /*****************************************************************************/
88
89 int
90 base64_decode(const char *src, char *dst, size_t dst_len, size_t *actual_len)
91 {
92 *actual_len = 0;
93 size_t src_len;
94 size_t src_i = 0;
95 size_t dst_i = 0;
96 unsigned int a; /* Four characters of base64 quantum */
97 unsigned int b;
98 unsigned int c;
99 unsigned int d;
100 unsigned int v;
101
102 #define OUTPUT_CHAR(x) \
103 { \
104 if (dst_i < dst_len) \
105 { \
106 dst[dst_i] = (x);\
107 } \
108 ++dst_i; \
109 }
110
111 src_len = g_strlen(src);
112
113 while (src_i < src_len)
114 {
115 if ((src_len - src_i) >= 4)
116 {
117 /* Usual case - full quantum */
118 CM_LOOKUP(src[src_i++], a);
119 CM_LOOKUP(src[src_i++], b);
120 CM_LOOKUP(src[src_i++], c);
121 CM_LOOKUP(src[src_i++], d);
122 }
123 else
124 {
125 /* Add padding on the end to make up the full quantum */
126 CM_LOOKUP(src[src_i++], a);
127 b = E_PAD;
128 c = E_PAD;
129 d = E_PAD;
130 if ((src_len - src_i) > 0)
131 {
132 CM_LOOKUP(src[src_i++], b);
133 }
134 if ((src_len - src_i) > 0)
135 {
136 CM_LOOKUP(src[src_i++], c);
137 }
138 }
139
140 /*
141 * Bitwise-or the translated quantum values together, so that
142 * any invalid or padding characters can be detected with a
143 * single test */
144 v = a | b | c | d;
145
146 if ((v & E_INVALID) != 0)
147 {
148 return -1; /* At least one invalid character */
149 }
150
151 if ((v & E_PAD) == 0)
152 {
153 /* No padding - a full quantum */
154 v = (a << 18) | (b << 12) | (c << 6) | d;
155 OUTPUT_CHAR(v >> 16);
156 OUTPUT_CHAR((v >> 8) & 0xff);
157 OUTPUT_CHAR(v & 0xff);
158 }
159 else if (((a | b | c) & E_PAD) == 0)
160 {
161 /* No padding in the first 3 chars, so the padding must
162 * be at the end */
163 v = (a << 10) | (b << 4) | (c >> 2);
164 OUTPUT_CHAR(v >> 8);
165 OUTPUT_CHAR(v & 0xff);
166 }
167 else if (((a | b) & E_PAD) == 0 && c == d)
168 {
169 /* No padding in first two chars, so if the last two chars are
170 * equal, they must both be padding */
171 v = (a << 2) | (b >> 4);
172 OUTPUT_CHAR(v);
173 }
174 else
175 {
176 /* Illegal padding */
177 return -1;
178 }
179 }
180
181 *actual_len = dst_i;
182 return 0;
183
184 #undef OUTPUT_CHAR
185 }
186
187 /*****************************************************************************/
29188 size_t
30 base64_decoded_bytes(const char *src)
189 base64_encode(const char *src, size_t src_len, char *dst, size_t dst_len)
31190 {
32 size_t len;
33 size_t padding;
34
35 len = g_strlen(src);
36 padding = 0;
37
38 if (src[len - 1] == '=')
39 {
40 padding++;
41
42 if (src[len - 2] == '=')
43 {
44 padding++;
45 }
46 }
47
48 return len * 3 / 4 - padding;
191 char *p = dst;
192 size_t src_i = 0;
193 size_t max_src_len;
194 unsigned int v;
195 static const char *b64chr =
196 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
197 "abcdefghijklmnopqrstuvwxyz"
198 "0123456789+/=";
199
200 /* Each three octets of the source results in four bytes at the output,
201 * plus we need a terminator. So we can work out the maximum number of
202 * source octets we can process */
203 if (dst_len == 0)
204 {
205 max_src_len = 0;
206 }
207 else
208 {
209 max_src_len = (dst_len - 1) / 4 * 3;
210 }
211
212 if (src_len > max_src_len)
213 {
214 src_len = max_src_len;
215 }
216
217 while (src_i < src_len)
218 {
219 switch (src_len - src_i)
220 {
221 case 1:
222 v = (unsigned int)(unsigned char)src[src_i++] << 4;
223 *p++ = b64chr[v >> 6];
224 *p++ = b64chr[v & 0x3f];
225 *p++ = b64chr[64];
226 *p++ = b64chr[64];
227 break;
228
229 case 2:
230 v = (unsigned int)(unsigned char)src[src_i++] << 10;
231 v |= (unsigned int)(unsigned char)src[src_i++] << 2;
232 *p++ = b64chr[v >> 12];
233 *p++ = b64chr[(v >> 6) & 0x3f];
234 *p++ = b64chr[v & 0x3f];
235 *p++ = b64chr[64];
236 break;
237
238 default:
239 v = (unsigned int)(unsigned char)src[src_i++] << 16;
240 v |= (unsigned int)(unsigned char)src[src_i++] << 8;
241 v |= (unsigned int)(unsigned char)src[src_i++];
242 *p++ = b64chr[v >> 18];
243 *p++ = b64chr[(v >> 12) & 0x3f];
244 *p++ = b64chr[(v >> 6) & 0x3f];
245 *p++ = b64chr[v & 0x3f];
246 break;
247 }
248 }
249
250 *p = '\0';
251
252 return src_len;
49253 }
50
51 /*****************************************************************************/
52 char *
53 base64_decode(char *dst, const char *src, size_t len)
54 {
55 BIO *b64;
56 BIO *bio;
57 char *b64str;
58 size_t estimated_decoded_bytes;
59 size_t decoded_bytes;
60
61 b64str = g_strdup(src);
62 estimated_decoded_bytes = base64_decoded_bytes(b64str);
63 dst[estimated_decoded_bytes] = '\0';
64
65 b64 = BIO_new(BIO_f_base64());
66 bio = BIO_new_mem_buf(b64str, len);
67 bio = BIO_push(b64, bio);
68 BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
69 decoded_bytes = BIO_read(bio, dst, len);
70 BIO_free_all(bio);
71
72 /* if input is corrupt, return empty string */
73 if (estimated_decoded_bytes != decoded_bytes)
74 {
75 g_strncpy(dst, "", sizeof(""));
76 }
77
78 return dst;
79 }
00 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * Copyright (C) Koichiro Iwao 2017
1 * Copyright (C) 2021 Koichiro Iwao, all xrdp contributors
42 *
53 * Licensed under the Apache License, Version 2.0 (the "License");
64 * you may not use this file except in compliance with the License.
1311 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1412 * See the License for the specific language governing permissions and
1513 * limitations under the License.
16 *
17 * Base64 encoder / decoder
1814 */
1915
20 #if !defined(SSL_CALLS_H)
21 #define SSL_CALLS_H
16 /**
17 * @file common/base64.h
18 * @brief Base64 encoder / decoder
19 *
20 * Base-64 is described in RFC4648. The following notes apply to this
21 * implementation:-
22 * - The only supported characters are [A-Za-z0-9+/=]. At present,
23 * embedded linefeeds and URL encodings are not supported.
24 *
25 */
26
27 #if !defined(BASE64_CALLS_H)
28 #define BASE64_CALLS_H
2229
2330 #include "arch.h"
2431
32 /*
33 * Decodes a base64 string
34 *
35 * @param src Pointer to null-terminated source
36 * @param dst Pointer to output buffer
37 * @param dst_len Length of above. No more than this is written to the
38 * output buffer
39 * @param actual_len Pointer to value to receive actual length of decoded data
40 * @return 0 for success, 1 for an invalid input string
41 *
42 * The following notes apply to this implementation:-
43 * - Embedded padding is supported, provided it only occurs at the end
44 * of a quantum as described in RFC4648(4). This allows concatenated
45 * encodings to be fed into the decoder.
46 * - Padding of the last quantum is assumed if not provided.
47 * - Excess padding of the last quantum is ignored.
48 *
49 * Only dst_len bytes at most are written to the output. The length
50 * returned in actual_len however represents how much buffer is needed for
51 * a correct result. This may be more than dst_len, and enables the caller
52 * to detect a potential buffer overflow
53 */
54 int
55 base64_decode(const char *src, char *dst, size_t dst_len, size_t *actual_len);
56
57 /*
58 * Encodes a buffer as base64
59 *
60 * @param src Pointer to source
61 * @param src_len Length of above.
62 * @param dst Pointer to output buffer for null-terminated string
63 * @param dst_len Length of above. No more than this is written to the
64 * output buffer
65 * @return Number of source characters processed
66 *
67 * The following notes apply to this implementation:-
68 * - Padding of the last quantum is always written if the number of
69 * source bytes is not divisible by 3.
70 *
71 * The number of source characters processed is always returned. If
72 * the destination buffer is too small for all the output plus a
73 * terminator, the returned value from this procedure will be less than
74 * src_len. In this case no padding characters will have been written,
75 * and the remaining characters can be converted with more calls to
76 * this procedure.
77 */
2578 size_t
26 base64_decoded_bytes(const char *src);
27 char *
28 base64_decode(char *dst, const char *src, size_t len);
79 base64_encode(const char *src, size_t src_len, char *dst, size_t dst_len);
2980
30 #endif
81 #endif /* BASE64_CALLS_H */
0 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * Copyright (C) 2021 Matt Burt, all xrdp contributors
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19 /**
20 * @file common/guid.c
21 * @brief GUID manipulation definitions
22 */
23
24 #if defined(HAVE_CONFIG_H)
25 #include <config_ac.h>
26 #endif
27
28 #include "guid.h"
29 #include "os_calls.h"
30 #include "string_calls.h"
31
32 struct guid
33 guid_new(void)
34 {
35 struct guid guid = {0};
36 g_random(guid.g, sizeof(guid.g));
37 return guid;
38 }
39
40 void
41 guid_clear(struct guid *guid)
42 {
43 g_memset(&guid->g, '\x00', GUID_SIZE);
44 }
45
46 int
47 guid_is_set(const struct guid *guid)
48 {
49 unsigned int i;
50 int rv = 0;
51 if (guid != NULL)
52 {
53 for (i = 0 ; i < GUID_SIZE; ++i)
54 {
55 if (guid->g[i] != '\x00')
56 {
57 rv = 1;
58 break;
59 }
60 }
61 }
62
63 return rv;
64
65 }
66
67 const char *guid_to_str(const struct guid *guid, char *str)
68 {
69 g_bytes_to_hexstr(guid->g, GUID_SIZE, str, GUID_STR_SIZE);
70 return str;
71 }
0 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * Copyright (C) Jay Sorg 2004-2021
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 */
18
19 /**
20 * @file common/guid.h
21 * @brief GUID manipulation declarations
22 */
23
24 #ifndef GUID_H
25 #define GUID_H
26
27 #include "arch.h"
28
29 #define GUID_SIZE 16 /* bytes */
30 #define GUID_STR_SIZE (GUID_SIZE * 2 + 1) /* Size for string representation */
31
32 /**
33 * Use a struct for the guid so we can easily copy by assignment
34 */
35 struct guid
36 {
37 char g[GUID_SIZE];
38 };
39
40 /**
41 * Get an initialised GUID
42 *
43 * @return new GUID
44 */
45 struct guid guid_new(void);
46
47 /**
48 * Clears an initialised GUID, so guid_is_set() returns true
49 *
50 * @param guid GUID to clear
51 */
52 void
53 guid_clear(struct guid *guid);
54
55 /**
56 * Checks if a GUID is initialised
57 *
58 * @param guid GUID to check (can be NULL)
59 * @return non-zero if GUID is set
60 */
61 int
62 guid_is_set(const struct guid *guid);
63
64 /**
65 * Converts a GUID to a string representation
66 *
67 * @param guid GUID to represent
68 * @param str pointer to at least GUID_STR_SIZE bytes to store the
69 * representation
70 * @return str is returned for convenience
71 */
72 const char *guid_to_str(const struct guid *guid, char *str);
73
74 #endif
223223 }
224224
225225 /**
226 * Converts a string representing th log level to a value
226 * Converts a string representing the log level to a value
227227 * @param buf
228228 * @return
229229 */
469469 {
470470 ret->fd = -1;
471471 ret->enable_syslog = 0;
472 #ifdef LOG_PER_LOGGER_LEVEL
472473 ret->per_logger_level = list_create();
473474 if (ret->per_logger_level != NULL)
474475 {
480481 g_free(ret);
481482 ret = NULL;
482483 }
484 #endif
483485 }
484486 else
485487 {
489491 return ret;
490492 }
491493
492 void
493 internal_log_config_copy(struct log_config *dest, const struct log_config *src)
494 {
495 int i;
496
497 dest->enable_syslog = src->enable_syslog;
498 dest->fd = src->fd;
499 dest->log_file = g_strdup(src->log_file);
494 /**
495 * Copies logging levels only from one log_config structure to another
496 **/
497
498 static void
499 internal_log_config_copy_levels(struct log_config *dest,
500 const struct log_config *src)
501 {
500502 dest->log_level = src->log_level;
501 dest->log_lock = src->log_lock;
502 dest->log_lock_attr = src->log_lock_attr;
503 dest->program_name = src->program_name;
504503 dest->enable_syslog = src->enable_syslog;
505504 dest->syslog_level = src->syslog_level;
506505 dest->enable_console = src->enable_console;
507506 dest->console_level = src->console_level;
508 dest->enable_pid = src->enable_pid;
509 dest->dump_on_start = src->dump_on_start;
507
508 #ifdef LOG_PER_LOGGER_LEVEL
509 if (dest->per_logger_level == NULL)
510 {
511 dest->per_logger_level = list_create();
512 if (dest->per_logger_level == NULL)
513 {
514 return;
515 }
516 dest->per_logger_level->auto_free = 1;
517 }
518 else
519 {
520 list_clear(dest->per_logger_level);
521 }
522
523 if (src->per_logger_level == NULL)
524 {
525 return;
526 }
527
528 int i;
529
510530 for (i = 0; i < src->per_logger_level->count; ++i)
511531 {
512532 struct log_logger_level *dst_logger =
513533 (struct log_logger_level *)g_malloc(sizeof(struct log_logger_level), 1);
514534
515 g_memcpy(dst_logger,
516 (struct log_logger_level *) list_get_item(src->per_logger_level, i),
517 sizeof(struct log_logger_level));
518
519 list_add_item(dest->per_logger_level, (tbus) dst_logger);
535 *dst_logger = *(struct log_logger_level *) list_get_item(src->per_logger_level, i),
536
537 list_add_item(dest->per_logger_level, (tbus) dst_logger);
538 }
539 #endif
540 }
541
542 void
543 internal_log_config_copy(struct log_config *dest, const struct log_config *src)
544 {
545 if (src != NULL && dest != NULL)
546 {
547 dest->fd = src->fd;
548 g_free(dest->log_file);
549 dest->log_file = g_strdup(src->log_file);
550 #ifdef LOG_ENABLE_THREAD
551 dest->log_lock = src->log_lock;
552 dest->log_lock_attr = src->log_lock_attr;
553 #endif
554 dest->program_name = src->program_name;
555 dest->enable_pid = src->enable_pid;
556 dest->dump_on_start = src->dump_on_start;
557
558 internal_log_config_copy_levels(dest, src);
520559 }
521560 }
522561
570609 const char *file_name,
571610 enum logLevels *log_level_return)
572611 {
612 #ifdef LOG_PER_LOGGER_LEVEL
573613 struct log_logger_level *logger = NULL;
574614 int i;
575615
590630 return 1;
591631 }
592632 }
633 #endif
593634
594635 return 0;
595636 }
661702 {
662703 if (config != NULL)
663704 {
705 #ifdef LOG_PER_LOGGER_LEVEL
664706 if (config->per_logger_level != NULL)
665707 {
666708 list_delete(config->per_logger_level);
667709 config->per_logger_level = NULL;
668710 }
711 #endif
712
713 if (0 != config->log_file)
714 {
715 g_free(config->log_file);
716 config->log_file = 0;
717 }
718
669719 g_free(config);
670720 }
671721
672722 return LOG_STARTUP_OK;
723 }
724
725 /**
726 * Restarts the logging.
727 *
728 * The logging file is never changed, as it is common in xrdp to share a
729 * log file between parents and children. The end result would be
730 * confusing for the user.
731 */
732 static enum logReturns
733 log_restart_from_param(const struct log_config *lc)
734 {
735 enum logReturns rv = LOG_GENERAL_ERROR;
736
737 if (g_staticLogConfig == NULL)
738 {
739 log_message(LOG_LEVEL_ALWAYS, "Log not already initialized");
740 }
741 else if (lc == NULL)
742 {
743 g_writeln("lc to log_start_from_param is NULL");
744 }
745 else
746 {
747 if (g_staticLogConfig->fd >= 0 &&
748 g_strcmp(g_staticLogConfig->log_file, lc->log_file) != 0)
749 {
750 log_message(LOG_LEVEL_WARNING,
751 "Unable to change log file name from %s to %s",
752 g_staticLogConfig->log_file,
753 lc->log_file);
754 }
755 /* Reconfigure syslog logging, allowing for a program_name change */
756 if (g_staticLogConfig->enable_syslog)
757 {
758 closelog();
759 }
760 if (lc->enable_syslog)
761 {
762 openlog(lc->program_name, LOG_CONS | LOG_PID, LOG_DAEMON);
763 }
764
765 /* Copy over simple values... */
766 #ifdef LOG_ENABLE_THREAD
767 g_staticLogConfig->log_lock = lc->log_lock;
768 g_staticLogConfig->log_lock_attr = lc->log_lock_attr;
769 #endif
770 g_staticLogConfig->program_name = lc->program_name;
771 g_staticLogConfig->enable_pid = lc->enable_pid;
772 g_staticLogConfig->dump_on_start = lc->dump_on_start;
773
774 /* ... and the log levels */
775 internal_log_config_copy_levels(g_staticLogConfig, lc);
776 rv = LOG_STARTUP_OK;
777 }
778 return rv;
673779 }
674780
675781 enum logReturns
720826 */
721827 enum logReturns
722828 log_start(const char *iniFile, const char *applicationName,
723 bool_t dump_on_start)
829 unsigned int flags)
724830 {
725831 enum logReturns ret = LOG_GENERAL_ERROR;
726832 struct log_config *config;
729835
730836 if (config != NULL)
731837 {
732 config->dump_on_start = dump_on_start;
733 ret = log_start_from_param(config);
838 config->dump_on_start = (flags & LOG_START_DUMP_CONFIG) ? 1 : 0;
839 if (flags & LOG_START_RESTART)
840 {
841 ret = log_restart_from_param(config);
842 if (ret != LOG_STARTUP_OK)
843 {
844 g_writeln("Could not restart log");
845 }
846 }
847 else
848 {
849 ret = log_start_from_param(config);
850 if (ret != LOG_STARTUP_OK)
851 {
852 g_writeln("Could not start log");
853 }
854 }
734855 log_config_free(config);
735
736 if (ret != LOG_STARTUP_OK)
737 {
738 g_writeln("Could not start log");
739 }
740856 }
741857 else
742858 {
786902 {
787903 char *dump_buffer;
788904 enum logReturns rv = LOG_STARTUP_OK;
789 enum logLevels override_log_level;
905 enum logLevels override_log_level = LOG_LEVEL_NEVER;
790906 bool_t override_destination_level = 0;
791907
792908 override_destination_level = internal_log_location_overrides_level(
161161
162162 #endif
163163
164 /* Flags values for log_start() */
165
166 /**
167 * Dump the log config on startup
168 */
169 #define LOG_START_DUMP_CONFIG (1<<0)
170
171 /**
172 * Restart the logging system.
173 *
174 * On a restart, existing files are not closed. This is because the
175 * files may be shared by sub-processes, and the result will not be what the
176 * user expects
177 */
178 #define LOG_START_RESTART (1<<1)
179
180 #ifdef LOG_PER_LOGGER_LEVEL
164181 enum log_logger_type
165182 {
166183 LOG_TYPE_FILE = 0,
173190 enum log_logger_type logger_type;
174191 char logger_name[LOGGER_NAME_SIZE + 1];
175192 };
193 #endif
176194
177195 struct log_config
178196 {
179 const char *program_name;
180 char *log_file;
197 const char *program_name; /* Pointer to static storage */
198 char *log_file; /* Dynamically allocated */
181199 int fd;
182200 enum logLevels log_level;
183201 int enable_console;
184202 enum logLevels console_level;
185203 int enable_syslog;
186204 enum logLevels syslog_level;
205 #ifdef LOG_PER_LOGGER_LEVEL
187206 struct list *per_logger_level;
207 #endif
188208 int dump_on_start;
189209 int enable_pid;
210 #ifdef LOG_ENABLE_THREAD
190211 pthread_mutex_t log_lock;
191212 pthread_mutexattr_t log_lock_attr;
213 #endif
192214 };
193215
194216 /* internal functions, only used in log.c if this ifdef is defined.*/
293315 * @param iniFile
294316 * @param applicationName the name that is used in the log for the running
295317 * application
296 * @param dump_on_start Whether to dump the config on stdout before
297 * logging is started
318 * @param flags Flags to affect the operation of the call
298319 * @return LOG_STARTUP_OK on success
299320 */
300321 enum logReturns
301322 log_start(const char *iniFile, const char *applicationName,
302 bool_t dump_on_start);
323 unsigned int flags);
303324
304325 /**
305326 * An alternative log_start where the caller gives the params directly.
13881388 }
13891389
13901390 /*****************************************************************************/
1391 /*
1392 * TODO: this function writes not only IP address, name is confusing
1393 */
1391
13941392 void
1395 g_write_ip_address(int rcv_sck, char *ip_address, int bytes)
1393 g_write_connection_description(int rcv_sck, char *description, int bytes)
13961394 {
13971395 char *addr;
13981396 int port;
14531451
14541452 if (ok)
14551453 {
1456 g_snprintf(ip_address, bytes, "%s:%d - socket: %d", addr, port, rcv_sck);
1454 g_snprintf(description, bytes, "%s:%d - socket: %d", addr, port, rcv_sck);
14571455 }
14581456 }
14591457
14601458 if (!ok)
14611459 {
1462 g_snprintf(ip_address, bytes, "NULL:NULL - socket: %d", rcv_sck);
1460 g_snprintf(description, bytes, "NULL:NULL - socket: %d", rcv_sck);
14631461 }
14641462
14651463 g_free(addr);
1464 }
1465
1466 /*****************************************************************************/
1467
1468 const char *g_get_ip_from_description(const char *description,
1469 char *ip, int bytes)
1470 {
1471 if (bytes > 0)
1472 {
1473 /* Look for the space after ip:port */
1474 const char *end = g_strchr(description, ' ');
1475 if (end == NULL)
1476 {
1477 end = description; /* Means we've failed */
1478 }
1479 else
1480 {
1481 /* Look back for the last ':' */
1482 while (end > description && *end != ':')
1483 {
1484 --end;
1485 }
1486 }
1487
1488 if (end == description)
1489 {
1490 g_snprintf(ip, bytes, "<unknown>");
1491 }
1492 else if ((end - description) < (bytes - 1))
1493 {
1494 g_strncpy(ip, description, end - description);
1495 }
1496 else
1497 {
1498 g_strncpy(ip, description, bytes - 1);
1499 }
1500 }
1501
1502 return ip;
14661503 }
14671504
14681505 /*****************************************************************************/
25102547 }
25112548
25122549 /*****************************************************************************/
2550 /* returns device number, -1 on error */
2551 int
2552 g_file_get_device_number(const char *filename)
2553 {
2554 #if defined(_WIN32)
2555 return -1;
2556 #else
2557 struct stat st;
2558
2559 if (stat(filename, &st) == 0)
2560 {
2561 return (int)(st.st_dev);
2562 }
2563 else
2564 {
2565 return -1;
2566 }
2567
2568 #endif
2569 }
2570
2571 /*****************************************************************************/
2572 /* returns inode number, -1 on error */
2573 int
2574 g_file_get_inode_num(const char *filename)
2575 {
2576 #if defined(_WIN32)
2577 return -1;
2578 #else
2579 struct stat st;
2580
2581 if (stat(filename, &st) == 0)
2582 {
2583 return (int)(st.st_ino);
2584 }
2585 else
2586 {
2587 return -1;
2588 }
2589
2590 #endif
2591 }
2592
2593 /*****************************************************************************/
25132594 long
25142595 g_load_library(char *in)
25152596 {
28912972
28922973 /*****************************************************************************/
28932974 /* does not work in win32
2894 returns pid of process that exits or zero if signal occurred */
2975 returns pid of process that exits or <= 0 if no process was found */
28952976 int
28962977 g_waitpid(int pid)
28972978 {
29072988 else
29082989 {
29092990 rv = waitpid(pid, 0, 0);
2910
2911 if (rv == -1)
2912 {
2913 if (errno == EINTR) /* signal occurred */
2914 {
2915 rv = 0;
2916 }
2917 }
29182991 }
29192992
29202993 return rv;
9292 int g_sck_can_send(int sck, int millis);
9393 int g_sck_can_recv(int sck, int millis);
9494 int g_sck_select(int sck1, int sck2);
95 void g_write_ip_address(int rcv_sck, char *ip_address, int bytes);
95 void g_write_connection_description(int rcv_sck,
96 char *description, int bytes);
97 /**
98 * Extracts the IP address from the connection description
99 * @param description Connection description (from
100 * g_write_connection_description())
101 * @param ip buffer to write IP address to
102 * @param bytes Size of ip buffer
103 * @return Pointer to IP for convenience
104 */
105 const char *g_get_ip_from_description(const char *description,
106 char *ip, int bytes);
96107 void g_sleep(int msecs);
97108 tintptr g_create_wait_obj(const char *name);
98109 tintptr g_create_wait_obj_from_socket(tintptr socket, int write);
127138 int g_remove_dir(const char *dirname);
128139 int g_file_delete(const char *filename);
129140 int g_file_get_size(const char *filename);
141 int g_file_get_device_number(const char *filename);
142 int g_file_get_inode_num(const char *filename);
130143 long g_load_library(char *in);
131144 int g_free_library(long lib);
132145 void *g_get_proc_address(long lib, const char *name);
8989 #endif
9090
9191 /******************************************************************************/
92 #define s_check(s) s_check_rem(s, 0)
93
94 /******************************************************************************/
9592 #define s_check_rem(s, n) ((s)->p + (n) <= (s)->end)
9693
9794 /******************************************************************************/
497494 *****************************************************************************/
498495 #define xstream_free(_s) free_stream(_s)
499496
497 #define xstream_skip_u8(_s, _n) in_uint8s(_s, _n)
498
500499 #define xstream_rd_u8(_s, _var) in_uint8(_s, _var)
501500 #define xstream_rd_u16_le(_s, _var) in_uint16_le(_s, _var)
502501 #define xstream_rd_u32_le(_s, _var) in_uint32_le(_s, _var)
4343
4444 #define SSL_WANT_READ_WRITE_TIMEOUT 100
4545
46 /*
47 * Globals used by openssl 3 and later */
48 #if OPENSSL_VERSION_NUMBER >= 0x30000000L
49 static EVP_MD *g_md_md5; /* MD5 message digest */
50 static EVP_MD *g_md_sha1; /* SHA1 message digest */
51 static EVP_CIPHER *g_cipher_des_ede3_cbc; /* DES3 CBC cipher */
52 static EVP_MAC *g_mac_hmac; /* HMAC MAC */
53 #endif
54
55 /* definition of ssl_tls */
56 struct ssl_tls
57 {
58 SSL *ssl; /* SSL * */
59 SSL_CTX *ctx; /* SSL_CTX * */
60 char *cert;
61 char *key;
62 struct trans *trans;
63 tintptr rwo; /* wait obj */
64 int error_logged; /* Error has already been logged */
65 };
66
4667 #if OPENSSL_VERSION_NUMBER < 0x10100000L
4768 static inline HMAC_CTX *
4869 HMAC_CTX_new(void)
105126 #endif /* OPENSSL_VERSION_NUMBER >= 0x10100000L */
106127
107128
129
130 /*****************************************************************************/
131 static void
132 dump_error_stack(const char *prefix)
133 {
134 /* Dump the error stack from the SSL library */
135 unsigned long code;
136 char buff[256];
137 while ((code = ERR_get_error()) != 0L)
138 {
139 ERR_error_string_n(code, buff, sizeof(buff));
140 LOG(LOG_LEVEL_ERROR, "%s: %s", prefix, buff);
141 }
142 }
143
144 /*****************************************************************************/
145 /* As above, but used for TLS connection errors where only the first
146 error is logged */
147 static void
148 dump_ssl_error_stack(struct ssl_tls *self)
149 {
150 if (!self->error_logged)
151 {
152 dump_error_stack("SSL");
153 self->error_logged = 1;
154 }
155 }
156
108157 /*****************************************************************************/
109158 int
110159 ssl_init(void)
111160 {
112161 SSL_load_error_strings();
113162 SSL_library_init();
163
114164 return 0;
115165 }
116166
118168 int
119169 ssl_finish(void)
120170 {
171 #if OPENSSL_VERSION_NUMBER >= 0x30000000L
172 /* De-allocate any allocated globals
173 * For OpenSSL 3, these can all safely be passed a NULL pointer */
174 EVP_MD_free(g_md_md5);
175 EVP_MD_free(g_md_sha1);
176 EVP_CIPHER_free(g_cipher_des_ede3_cbc);
177 EVP_MAC_free(g_mac_hmac);
178 #endif
121179 return 0;
122180 }
123181
124 /* rc4 stuff */
182 /* rc4 stuff
183 *
184 * For OpenSSL 3.0, the rc4 encryption algorithm is only provided by the
185 * legacy provider (see crypto(7)). Since RC4 is so simple, we can implement
186 * it directly rather than having to load the legacy provider. This will
187 * avoids problems if running on a system where openssl has been built
188 * without the legacy provider */
189
190 #if OPENSSL_VERSION_NUMBER >= 0x30000000L
191 struct rc4_data
192 {
193 /* See https://en.wikipedia.org/wiki/RC4 */
194 unsigned char S[256];
195 int i;
196 int j;
197 };
198 #endif
125199
126200 /*****************************************************************************/
127201 void *
128202 ssl_rc4_info_create(void)
129203 {
204 #if OPENSSL_VERSION_NUMBER < 0x30000000L
130205 return g_malloc(sizeof(RC4_KEY), 1);
206 #else
207 return g_malloc(sizeof(struct rc4_data), 1);
208 #endif
131209 }
132210
133211 /*****************************************************************************/
139217
140218 /*****************************************************************************/
141219 void
142 ssl_rc4_set_key(void *rc4_info, char *key, int len)
143 {
220 ssl_rc4_set_key(void *rc4_info, const char *key, int len)
221 {
222 #if OPENSSL_VERSION_NUMBER < 0x30000000L
144223 RC4_set_key((RC4_KEY *)rc4_info, len, (tui8 *)key);
224 #else
225 unsigned char *S = ((struct rc4_data *)rc4_info)->S;
226 int i;
227 int j = 0;
228 unsigned char t;
229 for (i = 0 ; i < 256; ++i)
230 {
231 S[i] = i;
232 }
233 for (i = 0 ; i < 256; ++i)
234 {
235 j = (j + S[i] + key[i % len]) & 0xff;
236 t = S[i];
237 S[i] = S[j];
238 S[j] = t;
239 }
240 ((struct rc4_data *)rc4_info)->i = 0;
241 ((struct rc4_data *)rc4_info)->j = 0;
242 #endif
145243 }
146244
147245 /*****************************************************************************/
148246 void
149247 ssl_rc4_crypt(void *rc4_info, char *data, int len)
150248 {
249 #if OPENSSL_VERSION_NUMBER < 0x30000000L
151250 RC4((RC4_KEY *)rc4_info, len, (tui8 *)data, (tui8 *)data);
251 #else
252 unsigned char *S = ((struct rc4_data *)rc4_info)->S;
253 int i = ((struct rc4_data *)rc4_info)->i;
254 int j = ((struct rc4_data *)rc4_info)->j;
255 unsigned char *p = (unsigned char *)data;
256 unsigned char t;
257 unsigned char k;
258
259 /*
260 * Do some loop-unrolling for performance. Here are the steps
261 * for each byte */
262 #define RC4_ROUND \
263 i = (i + 1) & 0xff; \
264 j = (j + S[i]) & 0xff; \
265 t = S[i]; \
266 S[i] = S[j]; \
267 S[j] = t; \
268 k = S[(S[i] + S[j]) & 0xff]; \
269 *p++ ^= k
270
271 while (len >= 8)
272 {
273 RC4_ROUND;
274 RC4_ROUND;
275 RC4_ROUND;
276 RC4_ROUND;
277 RC4_ROUND;
278 RC4_ROUND;
279 RC4_ROUND;
280 RC4_ROUND;
281 len -= 8;
282 }
283 while (len-- > 0)
284 {
285 RC4_ROUND;
286 }
287
288 ((struct rc4_data *)rc4_info)->i = i;
289 ((struct rc4_data *)rc4_info)->j = j;
290 #endif
152291 }
153292
154293 /* sha1 stuff */
157296 void *
158297 ssl_sha1_info_create(void)
159298 {
299 #if OPENSSL_VERSION_NUMBER < 0x30000000L
160300 return g_malloc(sizeof(SHA_CTX), 1);
301 #else
302 /*
303 * If we can't get the digest loaded, there's a problem with the
304 * library providers, so there's no point in us returning anything useful.
305 * If we do load the digest, it's used later */
306 if (g_md_sha1 == NULL)
307 {
308 if ((g_md_sha1 = EVP_MD_fetch(NULL, "sha1", NULL)) == NULL)
309 {
310 dump_error_stack("sha1");
311 return NULL;
312 }
313 }
314
315 return (void *)EVP_MD_CTX_new();
316 #endif
161317 }
162318
163319 /*****************************************************************************/
164320 void
165321 ssl_sha1_info_delete(void *sha1_info)
166322 {
323 #if OPENSSL_VERSION_NUMBER < 0x30000000L
167324 g_free(sha1_info);
325 #else
326 EVP_MD_CTX_free((EVP_MD_CTX *)sha1_info);
327 #endif
168328 }
169329
170330 /*****************************************************************************/
171331 void
172332 ssl_sha1_clear(void *sha1_info)
173333 {
334 #if OPENSSL_VERSION_NUMBER < 0x30000000L
174335 SHA1_Init((SHA_CTX *)sha1_info);
336 #else
337 if (sha1_info != NULL)
338 {
339 EVP_DigestInit_ex(sha1_info, g_md_sha1, NULL);
340 }
341 #endif
175342 }
176343
177344 /*****************************************************************************/
178345 void
179346 ssl_sha1_transform(void *sha1_info, const char *data, int len)
180347 {
348 #if OPENSSL_VERSION_NUMBER < 0x30000000L
181349 SHA1_Update((SHA_CTX *)sha1_info, data, len);
350 #else
351 if (sha1_info != NULL)
352 {
353 EVP_DigestUpdate((EVP_MD_CTX *)sha1_info, data, len);
354 }
355 #endif
182356 }
183357
184358 /*****************************************************************************/
185359 void
186360 ssl_sha1_complete(void *sha1_info, char *data)
187361 {
362 #if OPENSSL_VERSION_NUMBER < 0x30000000L
188363 SHA1_Final((tui8 *)data, (SHA_CTX *)sha1_info);
364 #else
365 if (sha1_info != NULL)
366 {
367 EVP_DigestFinal_ex((EVP_MD_CTX *)sha1_info, (unsigned char *)data,
368 NULL);
369 }
370 #endif
189371 }
190372
191373 /* md5 stuff */
194376 void *
195377 ssl_md5_info_create(void)
196378 {
379 #if OPENSSL_VERSION_NUMBER < 0x30000000L
197380 return g_malloc(sizeof(MD5_CTX), 1);
381 #else
382 /*
383 * If we can't get the digest loaded, there's a problem with the
384 * library providers, so there's no point in us returning anything useful.
385 * If we do load the digest, it's used later */
386 if (g_md_md5 == NULL)
387 {
388 if ((g_md_md5 = EVP_MD_fetch(NULL, "md5", NULL)) == NULL)
389 {
390 dump_error_stack("md5");
391 return NULL;
392 }
393 }
394
395 return (void *)EVP_MD_CTX_new();
396 #endif
198397 }
199398
200399 /*****************************************************************************/
201400 void
202401 ssl_md5_info_delete(void *md5_info)
203402 {
403 #if OPENSSL_VERSION_NUMBER < 0x30000000L
204404 g_free(md5_info);
405 #else
406 EVP_MD_CTX_free((EVP_MD_CTX *)md5_info);
407 #endif
205408 }
206409
207410 /*****************************************************************************/
208411 void
209412 ssl_md5_clear(void *md5_info)
210413 {
414 #if OPENSSL_VERSION_NUMBER < 0x30000000L
211415 MD5_Init((MD5_CTX *)md5_info);
212 }
213
214 /*****************************************************************************/
215 void
216 ssl_md5_transform(void *md5_info, char *data, int len)
217 {
416 #else
417 if (md5_info != NULL)
418 {
419 EVP_DigestInit_ex(md5_info, g_md_md5, NULL);
420 }
421 #endif
422 }
423
424 /*****************************************************************************/
425 void
426 ssl_md5_transform(void *md5_info, const char *data, int len)
427 {
428 #if OPENSSL_VERSION_NUMBER < 0x30000000L
218429 MD5_Update((MD5_CTX *)md5_info, data, len);
430 #else
431 if (md5_info != NULL)
432 {
433 EVP_DigestUpdate((EVP_MD_CTX *)md5_info, data, len);
434 }
435 #endif
219436 }
220437
221438 /*****************************************************************************/
222439 void
223440 ssl_md5_complete(void *md5_info, char *data)
224441 {
442 #if OPENSSL_VERSION_NUMBER < 0x30000000L
225443 MD5_Final((tui8 *)data, (MD5_CTX *)md5_info);
444 #else
445 if (md5_info != NULL)
446 {
447 EVP_DigestFinal_ex((EVP_MD_CTX *)md5_info, (unsigned char *)data, NULL);
448 }
449 #endif
226450 }
227451
228452 /* FIPS stuff */
235459 const tui8 *lkey;
236460 const tui8 *livec;
237461
462 #if OPENSSL_VERSION_NUMBER >= 0x30000000L
463 /*
464 * For these versions of OpenSSL, there are no long-term guarantees the
465 * DES3 cipher will be available. We'll try to load it here so we
466 * can log any errors */
467 if (g_cipher_des_ede3_cbc == NULL)
468 {
469 g_cipher_des_ede3_cbc = EVP_CIPHER_fetch(NULL, "des-ede3-cbc", NULL);
470 if (g_cipher_des_ede3_cbc == NULL)
471 {
472 dump_error_stack("DES-EDE3-CBC");
473 return NULL;
474 }
475 }
476 #endif
477
238478 des3_ctx = EVP_CIPHER_CTX_new();
239479 lkey = (const tui8 *) key;
240480 livec = (const tui8 *) ivec;
481 #if OPENSSL_VERSION_NUMBER < 0x30000000L
241482 EVP_EncryptInit_ex(des3_ctx, EVP_des_ede3_cbc(), NULL, lkey, livec);
483 #else
484 EVP_EncryptInit_ex(des3_ctx, g_cipher_des_ede3_cbc, NULL, lkey, livec);
485 #endif
242486 EVP_CIPHER_CTX_set_padding(des3_ctx, 0);
243487 return des3_ctx;
244488 }
251495 const tui8 *lkey;
252496 const tui8 *livec;
253497
498 #if OPENSSL_VERSION_NUMBER >= 0x30000000L
499 /*
500 * For these versions of OpenSSL, there are no long-term guarantees the
501 * DES3 cipher will be available. We'll try to load it here so we
502 * can log any errors */
503 if (g_cipher_des_ede3_cbc == NULL)
504 {
505 g_cipher_des_ede3_cbc = EVP_CIPHER_fetch(NULL, "des-ede3-cbc", NULL);
506 if (g_cipher_des_ede3_cbc == NULL)
507 {
508 dump_error_stack("DES-EDE3-CBC");
509 return NULL;
510 }
511 }
512 #endif
513
254514 des3_ctx = EVP_CIPHER_CTX_new();
255515 lkey = (const tui8 *) key;
256516 livec = (const tui8 *) ivec;
517 #if OPENSSL_VERSION_NUMBER < 0x30000000L
257518 EVP_DecryptInit_ex(des3_ctx, EVP_des_ede3_cbc(), NULL, lkey, livec);
519 #else
520 EVP_DecryptInit_ex(des3_ctx, g_cipher_des_ede3_cbc, NULL, lkey, livec);
521 #endif
258522 EVP_CIPHER_CTX_set_padding(des3_ctx, 0);
259523 return des3_ctx;
260524 }
282546 tui8 *lout_data;
283547
284548 des3_ctx = (EVP_CIPHER_CTX *) des3;
285 lin_data = (const tui8 *) in_data;
286 lout_data = (tui8 *) out_data;
287 len = 0;
288 EVP_EncryptUpdate(des3_ctx, lout_data, &len, lin_data, length);
549 if (des3_ctx != NULL)
550 {
551 lin_data = (const tui8 *) in_data;
552 lout_data = (tui8 *) out_data;
553 len = 0;
554 EVP_EncryptUpdate(des3_ctx, lout_data, &len, lin_data, length);
555 }
289556 return 0;
290557 }
291558
299566 tui8 *lout_data;
300567
301568 des3_ctx = (EVP_CIPHER_CTX *) des3;
302 lin_data = (const tui8 *) in_data;
303 lout_data = (tui8 *) out_data;
304 len = 0;
305 EVP_DecryptUpdate(des3_ctx, lout_data, &len, lin_data, length);
569 if (des3_ctx != NULL)
570 {
571 lin_data = (const tui8 *) in_data;
572 lout_data = (tui8 *) out_data;
573 len = 0;
574 EVP_DecryptUpdate(des3_ctx, lout_data, &len, lin_data, length);
575 }
306576 return 0;
307577 }
308578
310580 void *
311581 ssl_hmac_info_create(void)
312582 {
313 HMAC_CTX *hmac_ctx;
314
315 hmac_ctx = HMAC_CTX_new();
316 return hmac_ctx;
583 #if OPENSSL_VERSION_NUMBER < 0x30000000L
584 return (HMAC_CTX *)HMAC_CTX_new();
585 #else
586 /* Need a MAC algorithm loaded */
587 if (g_mac_hmac == NULL)
588 {
589 if ((g_mac_hmac = EVP_MAC_fetch(NULL, "hmac", NULL)) == NULL)
590 {
591 dump_error_stack("hmac");
592 return NULL;
593 }
594 }
595
596 return (void *)EVP_MAC_CTX_new(g_mac_hmac);
597 #endif
317598 }
318599
319600 /*****************************************************************************/
320601 void
321602 ssl_hmac_info_delete(void *hmac)
322603 {
604 #if OPENSSL_VERSION_NUMBER < 0x30000000L
323605 HMAC_CTX *hmac_ctx;
324606
325607 hmac_ctx = (HMAC_CTX *) hmac;
327609 {
328610 HMAC_CTX_free(hmac_ctx);
329611 }
612 #else
613 EVP_MAC_CTX_free((EVP_MAC_CTX *)hmac);
614 #endif
330615 }
331616
332617 /*****************************************************************************/
333618 void
334619 ssl_hmac_sha1_init(void *hmac, const char *data, int len)
335620 {
621 #if OPENSSL_VERSION_NUMBER < 0x30000000L
336622 HMAC_CTX *hmac_ctx;
337623
338624 hmac_ctx = (HMAC_CTX *) hmac;
339625 HMAC_Init_ex(hmac_ctx, data, len, EVP_sha1(), NULL);
626 #else
627 if (hmac != NULL)
628 {
629 char digest[] = "sha1";
630 OSSL_PARAM params[3];
631 size_t n = 0;
632 params[n++] = OSSL_PARAM_construct_utf8_string("digest", digest, 0);
633 params[n++] = OSSL_PARAM_construct_end();
634 if (EVP_MAC_init((EVP_MAC_CTX *)hmac, (unsigned char *)data,
635 len, params) == 0)
636 {
637 dump_error_stack("hmac-sha1");
638 }
639 }
640 #endif
340641 }
341642
342643 /*****************************************************************************/
343644 void
344645 ssl_hmac_transform(void *hmac, const char *data, int len)
345646 {
647 #if OPENSSL_VERSION_NUMBER < 0x30000000L
346648 HMAC_CTX *hmac_ctx;
347649 const tui8 *ldata;
348650
349651 hmac_ctx = (HMAC_CTX *) hmac;
350652 ldata = (const tui8 *) data;
351653 HMAC_Update(hmac_ctx, ldata, len);
654 #else
655 if (hmac != NULL)
656 {
657 EVP_MAC_update((EVP_MAC_CTX *)hmac, (unsigned char *)data, len);
658 }
659 #endif
352660 }
353661
354662 /*****************************************************************************/
355663 void
356664 ssl_hmac_complete(void *hmac, char *data, int len)
357665 {
666 #if OPENSSL_VERSION_NUMBER < 0x30000000L
358667 HMAC_CTX *hmac_ctx;
359668 tui8 *ldata;
360669 tui32 llen;
363672 ldata = (tui8 *) data;
364673 llen = len;
365674 HMAC_Final(hmac_ctx, ldata, &llen);
675 #else
676 if (hmac != NULL)
677 {
678 EVP_MAC_final((EVP_MAC_CTX *)hmac, (unsigned char *)data, NULL, len);
679 }
680 #endif
366681 }
367682
368683 /*****************************************************************************/
454769 char *mod, int mod_len, char *pri, int pri_len)
455770 {
456771 BIGNUM *my_e;
457 RSA *my_key;
458772 char *lexp;
459773 char *lmod;
460774 char *lpri;
476790 ssl_reverse_it(lexp, exp_len);
477791 my_e = BN_new();
478792 BN_bin2bn((tui8 *)lexp, exp_len, my_e);
479 my_key = RSA_new();
793
794 #if OPENSSL_VERSION_NUMBER < 0x30000000L
795 const BIGNUM *n = NULL;
796 const BIGNUM *d = NULL;
797 RSA *my_key = RSA_new();
480798 error = RSA_generate_key_ex(my_key, key_size_in_bits, my_e, 0) == 0;
481799
482 const BIGNUM *n;
483 const BIGNUM *d;
800 /* After this call, n and d point directly into my_key, and are valid
801 * until my_key is free'd */
484802 RSA_get0_key(my_key, &n, NULL, &d);
803 #else
804 BIGNUM *n = NULL;
805 BIGNUM *d = NULL;
806 OSSL_PARAM params[] =
807 {
808 OSSL_PARAM_construct_int("bits", &key_size_in_bits),
809 OSSL_PARAM_construct_end()
810 };
811 EVP_PKEY_CTX *pctx = EVP_PKEY_CTX_new_from_name(NULL, "RSA", NULL);
812 EVP_PKEY *pkey = NULL;
813
814 if (pctx != NULL &&
815 EVP_PKEY_keygen_init(pctx) > 0 &&
816 EVP_PKEY_CTX_set_params(pctx, params) > 0 &&
817 EVP_PKEY_generate(pctx, &pkey) > 0 &&
818 EVP_PKEY_get_bn_param(pkey, "n", &n) > 0 &&
819 EVP_PKEY_get_bn_param(pkey, "d", &d) > 0)
820 {
821 error = 0;
822 }
823 else
824 {
825 error = 1;
826 }
827
828 EVP_PKEY_CTX_free(pctx);
829 EVP_PKEY_free(pkey);
830 #endif
485831
486832 if (error == 0)
487833 {
516862 }
517863
518864 BN_free(my_e);
865 #if OPENSSL_VERSION_NUMBER < 0x30000000L
519866 RSA_free(my_key);
867 #else
868 BN_free(n);
869 BN_clear_free(d);
870 #endif
520871 g_free(lexp);
521872 g_free(lmod);
522873 g_free(lpri);
528879 see also
529880 * https://wiki.openssl.org/index.php/Diffie-Hellman_parameters
530881 * https://wiki.openssl.org/index.php/Manual:SSL_CTX_set_tmp_dh_callback(3)
882 *
883 * We dont do this for OpenSSL 3 - we use SSL_CTX_set_dh_auto() instead, as this
884 * can cater for different key sizes on the certificate
531885 */
886 #if OPENSSL_VERSION_NUMBER < 0x30000000L
532887 static DH *ssl_get_dh2236()
533888 {
534889 static unsigned char dh2236_p[] =
590945
591946 return dh;
592947 }
948 #endif /* OPENSSL_VERSION_NUMBER < 0x30000000L */
593949
594950 /*****************************************************************************/
595951 struct ssl_tls *
612968
613969 return self;
614970 }
615
616 /*****************************************************************************/
617 static void
618 dump_ssl_error_stack(struct ssl_tls *self)
619 {
620 if (!self->error_logged)
621 {
622 /* Dump the error stack from the SSL library */
623 unsigned long code;
624 char buff[256];
625 while ((code = ERR_get_error()) != 0L)
626 {
627 ERR_error_string_n(code, buff, sizeof(buff));
628 LOG(LOG_LEVEL_ERROR, "SSL: %s", buff);
629 }
630 self->error_logged = 1;
631 }
632 }
633
634971 /*****************************************************************************/
635972 static int
636973 ssl_tls_log_error(struct ssl_tls *self, const char *func, int value)
7511088 SSL_CTX_set_options(self->ctx, options);
7521089
7531090 /* set DH parameters */
1091 #if OPENSSL_VERSION_NUMBER < 0x30000000L
7541092 DH *dh = ssl_get_dh2236();
7551093 if (dh == NULL)
7561094 {
7651103 return 1;
7661104 }
7671105 DH_free(dh); // ok to free, copied into ctx by SSL_CTX_set_tmp_dh()
768
1106 #else
1107 if (!SSL_CTX_set_dh_auto(self->ctx, 1))
1108 {
1109 LOG(LOG_LEVEL_ERROR, "TLS DHE auto failed to be enabled");
1110 dump_ssl_error_stack(self);
1111 return 1;
1112 }
1113 #endif
7691114 #if defined(SSL_CTX_set_ecdh_auto)
7701115 if (!SSL_CTX_set_ecdh_auto(self->ctx, 1))
7711116 {
10571402
10581403 /*****************************************************************************/
10591404 const char *
1060 ssl_get_version(const struct ssl_st *ssl)
1061 {
1062 return SSL_get_version(ssl);
1405 ssl_get_version(const struct ssl_tls *ssl)
1406 {
1407 return SSL_get_version(ssl->ssl);
10631408 }
10641409
10651410 /*****************************************************************************/
10661411 const char *
1067 ssl_get_cipher_name(const struct ssl_st *ssl)
1068 {
1069 return SSL_get_cipher_name(ssl);
1412 ssl_get_cipher_name(const struct ssl_tls *ssl)
1413 {
1414 return SSL_get_cipher_name(ssl->ssl);
1415 }
1416
1417 /*****************************************************************************/
1418 tintptr
1419 ssl_get_rwo(const struct ssl_tls *ssl)
1420 {
1421 return ssl->rwo;
10701422 }
10711423
10721424 /*****************************************************************************/
2121
2222 #include "arch.h"
2323
24 /* Incomplete types */
25 struct ssl_tls;
26 struct trans;
27
2428 int
2529 ssl_init(void);
2630 int
3034 void
3135 ssl_rc4_info_delete(void *rc4_info);
3236 void
33 ssl_rc4_set_key(void *rc4_info, char *key, int len);
37 ssl_rc4_set_key(void *rc4_info, const char *key, int len);
3438 void
3539 ssl_rc4_crypt(void *rc4_info, char *data, int len);
3640 void *
5054 void
5155 ssl_md5_clear(void *md5_info);
5256 void
53 ssl_md5_transform(void *md5_info, char *data, int len);
57 ssl_md5_transform(void *md5_info, const char *data, int len);
5458 void
5559 ssl_md5_complete(void *md5_info, char *data);
5660 void *
8084 ssl_gen_key_xrdp1(int key_size_in_bits, const char *exp, int exp_len,
8185 char *mod, int mod_len, char *pri, int pri_len);
8286
83 /* ssl_tls */
84 struct ssl_tls
85 {
86 struct ssl_st *ssl; /* SSL * */
87 struct ssl_ctx_st *ctx; /* SSL_CTX * */
88 char *cert;
89 char *key;
90 struct trans *trans;
91 tintptr rwo; /* wait obj */
92 int error_logged; /* Error has already been logged */
93 };
94
9587 /* xrdp_tls.c */
9688 struct ssl_tls *
9789 ssl_tls_create(struct trans *trans, const char *key, const char *cert);
109101 int
110102 ssl_tls_can_recv(struct ssl_tls *tls, int sck, int millis);
111103 const char *
112 ssl_get_version(const struct ssl_st *ssl);
104 ssl_get_version(const struct ssl_tls *ssl);
113105 const char *
114 ssl_get_cipher_name(const struct ssl_st *ssl);
106 ssl_get_cipher_name(const struct ssl_tls *ssl);
115107 int
116108 ssl_get_protocols_from_string(const char *str, long *ssl_protocols);
117109 const char *
118110 get_openssl_version();
111 tintptr
112 ssl_get_rwo(const struct ssl_tls *ssl);
119113
120114 #endif
187187
188188 /*****************************************************************************/
189189 /* locates char in text */
190 const char *
190 char *
191191 g_strchr(const char *text, int c)
192192 {
193193 if (text == NULL)
195195 return 0;
196196 }
197197
198 return strchr(text, c);
198 /* Cast needed to compile with C++ */
199 return (char *)strchr(text, c);
200 }
201
202 /*****************************************************************************/
203 /* locates char in text */
204 char *
205 g_strrchr(const char *text, int c)
206 {
207 if (text == NULL)
208 {
209 return 0;
210 }
211
212 /* Cast needed to compile with C++ */
213 return (char *)strrchr(text, c);
199214 }
200215
201216 /*****************************************************************************/
202217 /* locates char in text with length */
203 const char *
218 char *
204219 g_strnchr(const char *text, int c, int len)
205220 {
206221 if (text == NULL || len <= 0)
208223 return NULL;
209224 }
210225
211 return (const char *)memchr(text, c, len);
226 return (char *)memchr(text, c, len);
212227 }
213228
214229 /*****************************************************************************/
677692 }
678693
679694 return (pp - str);
695 }
696
697 /*****************************************************************************/
698
699 char *
700 g_strstr(const char *haystack, const char *needle)
701 {
702 if (haystack == NULL || needle == NULL)
703 {
704 return NULL;
705 }
706
707 /* Cast needed to compile with C++ */
708 return (char *)strstr(haystack, needle);
680709 }
681710
682711 /*****************************************************************************/
890919
891920 return dest;
892921 }
922
923 int
924 g_bitmask_to_str(int bitmask, const struct bitmask_string bitdefs[],
925 char delim, char *buff, int bufflen)
926 {
927 int rlen = 0; /* Returned length */
928
929 if (bufflen <= 0) /* Caller error */
930 {
931 rlen = -1;
932 }
933 else
934 {
935 char *p = buff;
936 /* Find the last writeable character in the buffer */
937 const char *last = buff + (bufflen - 1);
938
939 const struct bitmask_string *b;
940
941 for (b = &bitdefs[0] ; b->mask != 0; ++b)
942 {
943 if ((bitmask & b->mask) != 0)
944 {
945 if (p > buff)
946 {
947 /* Not first item - append separator */
948 if (p < last)
949 {
950 *p++ = delim;
951 }
952 ++rlen;
953 }
954
955 int slen = g_strlen(b->str);
956 int copylen = MIN(slen, last - p);
957 g_memcpy(p, b->str, copylen);
958 p += copylen;
959 rlen += slen;
960
961 /* Remove the bit so we can check for undefined bits later*/
962 bitmask &= ~b->mask;
963 }
964 }
965
966 if (bitmask != 0)
967 {
968 /* Bits left which aren't named by the user */
969 if (p > buff)
970 {
971 if (p < last)
972 {
973 *p++ = delim;
974 }
975 ++rlen;
976 }
977 /* This call will terminate the return buffer */
978 rlen += g_snprintf(p, last - p + 1, "0x%x", bitmask);
979 }
980 else
981 {
982 *p = '\0';
983 }
984 }
985
986 return rlen;
987 }
988
989 int
990 g_str_to_bitmask(const char *str, const struct bitmask_string bitdefs[],
991 const char *delim, char *unrecognised, int unrecognised_len)
992 {
993 char *properties = NULL;
994 char *p = NULL;
995 int mask = 0;
996
997 if (unrecognised_len < 1)
998 {
999 /* No space left to tell unrecognised tokens */
1000 return 0;
1001 }
1002 if (!unrecognised)
1003 {
1004 return 0;
1005 }
1006 /* ensure not to return with uninitialized buffer */
1007 unrecognised[0] = '\0';
1008 if (!str || !bitdefs || !delim)
1009 {
1010 return 0;
1011 }
1012 properties = g_strdup(str);
1013 if (!properties)
1014 {
1015 return 0;
1016 }
1017 p = strtok(properties, delim);
1018 while (p != NULL)
1019 {
1020 g_strtrim(p, 3);
1021 const struct bitmask_string *b;
1022 int found = 0;
1023 for (b = &bitdefs[0] ; b->str != NULL; ++b)
1024 {
1025 if (0 == g_strcasecmp(p, b->str))
1026 {
1027 mask |= b->mask;
1028 found = 1;
1029 break;
1030 }
1031 }
1032 if (found == 0)
1033 {
1034 int length = g_strlen(unrecognised);
1035 if (length > 0)
1036 {
1037 /* adding ",property" */
1038 if (length + g_strlen(p) + 1 < unrecognised_len)
1039 {
1040 unrecognised[length] = delim[0];
1041 length += 1;
1042 g_strcpy(unrecognised + length, p);
1043 }
1044 }
1045 else if (g_strlen(p) < unrecognised_len)
1046 {
1047 g_strcpy(unrecognised, p);
1048 }
1049 }
1050 p = strtok(NULL, delim);
1051 }
1052
1053 g_free(properties);
1054 return mask;
1055 }
1056
3535 };
3636
3737 #define INFO_STRING_END_OF_LIST { '\0', NULL }
38
39 /**
40 * Map a bitmask to a string value
41 *
42 *
43 * This structure is used by g_bitmask_to_str() to specify the
44 * string for each bit in the bitmask
45 */
46 struct bitmask_string
47 {
48 int mask;
49 const char *str;
50 };
51
52 #define BITMASK_STRING_END_OF_LIST { 0, NULL }
3853
3954 /**
4055 * Processes a format string for general info
139154 int
140155 g_get_display_num_from_display(const char *display_text);
141156
157 /**
158 * Converts a bitmask into a string for output purposes
159 *
160 * @param bitmask Bitmask to convert
161 * @param bitdefs Definitions for strings for bits
162 * @param delim Delimiter to use between strings
163 * @param buff Output buff
164 * @param bufflen Length of buff, including terminator '`\0'
165 *
166 * @return Total length excluding terminator which would be written, as
167 * in snprintf(). Can be used to check for overflow
168 *
169 * @note Any undefined bits in the bitmask are appended to the output as
170 * a hexadecimal constant.
171 */
172 int
173 g_bitmask_to_str(int bitmask, const struct bitmask_string[],
174 char delim, char *buff, int bufflen);
175
176 /***
177 * Converts a string containing a series of tokens to a bitmask.
178 * @param str Input string
179 * @param bitmask_string Array mapping tokens to bitmask values
180 * @param delim Delimiter for tokens in str
181 * @param[out] unrecognised Buffer for any unrecognised tokens
182 * @param unrecognised_len Length of unrecognised including '\0';
183 * @return bitmask value for recognised tokens
184 */
185 int
186 g_str_to_bitmask(const char *str, const struct bitmask_string[],
187 const char *delim, char *unrecognised,
188 int unrecognised_len);
189
142190 int g_strlen(const char *text);
143 const char *g_strchr(const char *text, int c);
144 const char *g_strnchr(const char *text, int c, int len);
191 char *g_strchr(const char *text, int c);
192 char *g_strrchr(const char *text, int c);
193 char *g_strnchr(const char *text, int c, int len);
145194 char *g_strcpy(char *dest, const char *src);
146195 char *g_strncpy(char *dest, const char *src, int len);
147196 char *g_strcat(char *dest, const char *src);
167216 int g_bytes_to_hexstr(const void *bytes, int num_bytes, char *out_str,
168217 int bytes_out_str);
169218 int g_pos(const char *str, const char *to_find);
219 char *g_strstr(const char *haystack, const char *needle);
170220 int g_mbstowcs(twchar *dest, const char *src, int n);
171221 int g_wcstombs(char *dest, const twchar *src, int n);
172222 int g_strtrim(char *str, int trim_flags);
178178 objs[*count] = self->sck;
179179 (*count)++;
180180
181 if (self->tls != 0)
182 {
183 if (self->tls->rwo != 0)
184 {
185 objs[*count] = self->tls->rwo;
186 (*count)++;
187 }
181 if (self->tls != NULL && (objs[*count] = ssl_get_rwo(self->tls)) != 0)
182 {
183 (*count)++;
188184 }
189185
190186 return 0;
994990 self->trans_send = trans_tls_send;
995991 self->trans_can_recv = trans_tls_can_recv;
996992
997 self->ssl_protocol = ssl_get_version(self->tls->ssl);
998 self->cipher_name = ssl_get_cipher_name(self->tls->ssl);
993 self->ssl_protocol = ssl_get_version(self->tls);
994 self->cipher_name = ssl_get_cipher_name(self->tls);
999995
1000996 return 0;
1001997 }
9090 int rdp5_performanceflags;
9191 int brush_cache_code; /* 0 = no cache 1 = 8x8 standard cache
9292 2 = arbitrary dimensions */
93 char client_ip[256];
93 char connection_description[256];
9494 int max_bpp;
9595 int jpeg; /* non standard bitmap cache v2 cap */
9696 int offscreen_support_level;
22
33 scriptversion=2018-03-07.03; # UTC
44
5 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
5 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
66 # Written by Tom Tromey <tromey@cygnus.com>.
77 #
88 # This program is free software; you can redistribute it and/or modify
8383 /* Enable development stream checking */
8484 #undef USE_DEVEL_STREAMCHECK
8585
86 /* Compile with imlib2 support */
87 #undef USE_IMLIB2
88
8689 /* Enable PAM */
8790 #undef USE_PAM
8891
00 #! /bin/sh
11 # Guess values for system-dependent variables and create Makefiles.
2 # Generated by GNU Autoconf 2.69 for xrdp 0.9.17.
2 # Generated by GNU Autoconf 2.69 for xrdp 0.9.19.
33 #
44 # Report bugs to <xrdp-devel@googlegroups.com>.
55 #
589589 # Identity of this package.
590590 PACKAGE_NAME='xrdp'
591591 PACKAGE_TARNAME='xrdp'
592 PACKAGE_VERSION='0.9.17'
593 PACKAGE_STRING='xrdp 0.9.17'
592 PACKAGE_VERSION='0.9.19'
593 PACKAGE_STRING='xrdp 0.9.19'
594594 PACKAGE_BUGREPORT='xrdp-devel@googlegroups.com'
595595 PACKAGE_URL=''
596596
655655 FREERDP_LIBS
656656 FREERDP_CFLAGS
657657 PAM_RULES
658 IMLIB2_LIBS
659 IMLIB2_CFLAGS
658660 OPENSSL
659661 OPENSSL_LIBS
660662 OPENSSL_CFLAGS
762764 AM_DEFAULT_VERBOSITY
763765 AM_DEFAULT_V
764766 AM_V
767 CSCOPE
768 ETAGS
769 CTAGS
765770 am__untar
766771 am__tar
767772 AMTAR
864869 enable_painter
865870 enable_rfxcodec
866871 enable_rdpsndaudin
872 with_imlib2
867873 enable_xrdpdebug
868874 with_x
869875 enable_strict_locations
884890 PKG_CONFIG_LIBDIR
885891 OPENSSL_CFLAGS
886892 OPENSSL_LIBS
893 IMLIB2_CFLAGS
894 IMLIB2_LIBS
887895 FREERDP_CFLAGS
888896 FREERDP_LIBS
889897 FUSE_CFLAGS
14351443 # Omit some internal or obsolete options to make the list less imposing.
14361444 # This message is too long to be a string in the A/UX 3.1 sh.
14371445 cat <<_ACEOF
1438 \`configure' configures xrdp 0.9.17 to adapt to many kinds of systems.
1446 \`configure' configures xrdp 0.9.19 to adapt to many kinds of systems.
14391447
14401448 Usage: $0 [OPTION]... [VAR=VALUE]...
14411449
15091517
15101518 if test -n "$ac_init_help"; then
15111519 case $ac_init_help in
1512 short | recursive ) echo "Configuration of xrdp 0.9.17:";;
1520 short | recursive ) echo "Configuration of xrdp 0.9.19:";;
15131521 esac
15141522 cat <<\_ACEOF
15151523
15811589 --with-socketdir=DIR Use directory for UNIX sockets (default: /tmp/.xrdp)
15821590 --with-systemdsystemunitdir=DIR
15831591 Directory for systemd service files, no to disable
1592 --with-imlib2=ARG imlib2 library to use for non-BMP backgrounds
1593 (ARG=yes/no/<abs-path>)
15841594 --with-x use the X Window System
15851595 --with-pkgconfigdir pkg-config installation directory
15861596 ['${libdir}/pkgconfig']
16051615 C compiler flags for OPENSSL, overriding pkg-config
16061616 OPENSSL_LIBS
16071617 linker flags for OPENSSL, overriding pkg-config
1618 IMLIB2_CFLAGS
1619 C compiler flags for IMLIB2, overriding pkg-config
1620 IMLIB2_LIBS linker flags for IMLIB2, overriding pkg-config
16081621 FREERDP_CFLAGS
16091622 C compiler flags for FREERDP, overriding pkg-config
16101623 FREERDP_LIBS
16881701 test -n "$ac_init_help" && exit $ac_status
16891702 if $ac_init_version; then
16901703 cat <<\_ACEOF
1691 xrdp configure 0.9.17
1704 xrdp configure 0.9.19
16921705 generated by GNU Autoconf 2.69
16931706
16941707 Copyright (C) 2012 Free Software Foundation, Inc.
20572070 This file contains any messages produced by compilers while
20582071 running configure, to aid debugging if configure makes a mistake.
20592072
2060 It was created by xrdp $as_me 0.9.17, which was
2073 It was created by xrdp $as_me 0.9.19, which was
20612074 generated by GNU Autoconf 2.69. Invocation command line was
20622075
20632076 $ $0 $@
29172930
29182931 # Define the identity of the package.
29192932 PACKAGE='xrdp'
2920 VERSION='0.9.17'
2933 VERSION='0.9.19'
29212934
29222935
29232936 cat >>confdefs.h <<_ACEOF
29652978
29662979
29672980
2981
2982
2983 # Variables for tags utilities; see am/tags.am
2984 if test -z "$CTAGS"; then
2985 CTAGS=ctags
2986 fi
2987
2988 if test -z "$ETAGS"; then
2989 ETAGS=etags
2990 fi
2991
2992 if test -z "$CSCOPE"; then
2993 CSCOPE=cscope
2994 fi
29682995
29692996
29702997
1278512812 fi
1278612813
1278712814
12815
12816 # Check whether --with-imlib2 was given.
12817 if test "${with_imlib2+set}" = set; then :
12818 withval=$with_imlib2;
12819 fi
12820
12821
1278812822 # Obsolete options
1278912823 # Check whether --enable-xrdpdebug was given.
1279012824 if test "${enable_xrdpdebug+set}" = set; then :
1347013504 fi
1347113505
1347213506
13507
13508 # Find imlib2
13509 case "$with_imlib2" in
13510 '' | no) { $as_echo "$as_me:${as_lineno-$LINENO}: imlib2 will not be supported" >&5
13511 $as_echo "$as_me: imlib2 will not be supported" >&6;}
13512 use_imlib2=no
13513 ;;
13514 yes)
13515
13516 pkg_failed=no
13517 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for IMLIB2" >&5
13518 $as_echo_n "checking for IMLIB2... " >&6; }
13519
13520 if test -n "$IMLIB2_CFLAGS"; then
13521 pkg_cv_IMLIB2_CFLAGS="$IMLIB2_CFLAGS"
13522 elif test -n "$PKG_CONFIG"; then
13523 if test -n "$PKG_CONFIG" && \
13524 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"imlib2 >= 1.4.5\""; } >&5
13525 ($PKG_CONFIG --exists --print-errors "imlib2 >= 1.4.5") 2>&5
13526 ac_status=$?
13527 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
13528 test $ac_status = 0; }; then
13529 pkg_cv_IMLIB2_CFLAGS=`$PKG_CONFIG --cflags "imlib2 >= 1.4.5" 2>/dev/null`
13530 test "x$?" != "x0" && pkg_failed=yes
13531 else
13532 pkg_failed=yes
13533 fi
13534 else
13535 pkg_failed=untried
13536 fi
13537 if test -n "$IMLIB2_LIBS"; then
13538 pkg_cv_IMLIB2_LIBS="$IMLIB2_LIBS"
13539 elif test -n "$PKG_CONFIG"; then
13540 if test -n "$PKG_CONFIG" && \
13541 { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"imlib2 >= 1.4.5\""; } >&5
13542 ($PKG_CONFIG --exists --print-errors "imlib2 >= 1.4.5") 2>&5
13543 ac_status=$?
13544 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
13545 test $ac_status = 0; }; then
13546 pkg_cv_IMLIB2_LIBS=`$PKG_CONFIG --libs "imlib2 >= 1.4.5" 2>/dev/null`
13547 test "x$?" != "x0" && pkg_failed=yes
13548 else
13549 pkg_failed=yes
13550 fi
13551 else
13552 pkg_failed=untried
13553 fi
13554
13555
13556
13557 if test $pkg_failed = yes; then
13558 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
13559 $as_echo "no" >&6; }
13560
13561 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
13562 _pkg_short_errors_supported=yes
13563 else
13564 _pkg_short_errors_supported=no
13565 fi
13566 if test $_pkg_short_errors_supported = yes; then
13567 IMLIB2_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "imlib2 >= 1.4.5" 2>&1`
13568 else
13569 IMLIB2_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "imlib2 >= 1.4.5" 2>&1`
13570 fi
13571 # Put the nasty error message in config.log where it belongs
13572 echo "$IMLIB2_PKG_ERRORS" >&5
13573
13574 as_fn_error $? "please install libimlib2-dev or imlib2-devel" "$LINENO" 5
13575 elif test $pkg_failed = untried; then
13576 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
13577 $as_echo "no" >&6; }
13578 as_fn_error $? "please install libimlib2-dev or imlib2-devel" "$LINENO" 5
13579 else
13580 IMLIB2_CFLAGS=$pkg_cv_IMLIB2_CFLAGS
13581 IMLIB2_LIBS=$pkg_cv_IMLIB2_LIBS
13582 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
13583 $as_echo "yes" >&6; }
13584 use_imlib2=yes
13585 fi
13586 ;;
13587 /*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for imlib2 in $with_imlib2" >&5
13588 $as_echo_n "checking for imlib2 in $with_imlib2... " >&6; }
13589 if test -d $with_imlib2/lib; then
13590 IMLIB2_LIBS="-L$with_imlib2/lib -lImlib2"
13591 elif test -d $with_imlib2/lib64; then
13592 IMLIB2_LIBS="-L$with_imlib2/lib64 -lImlib2"
13593 else
13594 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
13595 $as_echo "no" >&6; }
13596 as_fn_error $? "Can't find libImlib2 in $with_imlib2" "$LINENO" 5
13597 fi
13598
13599 if test -f $with_imlib2/include/Imlib2.h; then
13600 IMLIB2_CFLAGS="-I $with_imlib2/include"
13601 else
13602 { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
13603 $as_echo "no" >&6; }
13604 as_fn_error $? "Can't find $with_imlib2/include/Imlib2.h" "$LINENO" 5
13605 fi
13606 { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
13607 $as_echo "yes" >&6; }
13608
13609
13610 use_imlib2=yes
13611 ;;
13612 *) as_fn_error $? "--with-imlib2 needs yes/no or absolute path" "$LINENO" 5
13613 esac
13614
13615 if test x$use_imlib2 = xyes; then
13616
13617 $as_echo "#define USE_IMLIB2 1" >>confdefs.h
13618
13619 fi
1347313620
1347413621 # Check only one auth mechanism is specified, and give it a name
1347513622 auth_cnt=0
1493415081 done
1493515082
1493615083
14937 ac_config_files="$ac_config_files common/Makefile docs/Makefile docs/man/Makefile genkeymap/Makefile instfiles/default/Makefile instfiles/init.d/Makefile instfiles/Makefile instfiles/pam.d/Makefile instfiles/pulse/Makefile instfiles/rc.d/Makefile keygen/Makefile libxrdp/Makefile Makefile mc/Makefile neutrinordp/Makefile pkgconfig/Makefile pkgconfig/xrdp.pc pkgconfig/xrdp-uninstalled.pc sesman/chansrv/Makefile sesman/libscp/Makefile sesman/Makefile sesman/tools/Makefile tests/Makefile tests/common/Makefile tests/memtest/Makefile tools/Makefile tools/devel/Makefile tools/devel/tcp_proxy/Makefile vnc/Makefile xrdpapi/Makefile xrdp/Makefile xrdpvr/Makefile xup/Makefile"
15084 ac_config_files="$ac_config_files common/Makefile docs/Makefile docs/man/Makefile genkeymap/Makefile instfiles/default/Makefile instfiles/init.d/Makefile instfiles/Makefile instfiles/pam.d/Makefile instfiles/pulse/Makefile instfiles/rc.d/Makefile keygen/Makefile libxrdp/Makefile Makefile mc/Makefile neutrinordp/Makefile pkgconfig/Makefile pkgconfig/xrdp.pc pkgconfig/xrdp-uninstalled.pc sesman/chansrv/Makefile sesman/libscp/Makefile sesman/Makefile sesman/tools/Makefile tests/Makefile tests/common/Makefile tests/libxrdp/Makefile tests/memtest/Makefile tests/xrdp/Makefile tools/Makefile tools/devel/Makefile tools/devel/tcp_proxy/Makefile vnc/Makefile xrdpapi/Makefile xrdp/Makefile xrdpvr/Makefile xup/Makefile"
1493815085
1493915086
1494015087
1556015707 # report actual input values of CONFIG_FILES etc. instead of their
1556115708 # values after options handling.
1556215709 ac_log="
15563 This file was extended by xrdp $as_me 0.9.17, which was
15710 This file was extended by xrdp $as_me 0.9.19, which was
1556415711 generated by GNU Autoconf 2.69. Invocation command line was
1556515712
1556615713 CONFIG_FILES = $CONFIG_FILES
1562615773 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1562715774 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
1562815775 ac_cs_version="\\
15629 xrdp config.status 0.9.17
15776 xrdp config.status 0.9.19
1563015777 configured by $0, generated by GNU Autoconf 2.69,
1563115778 with options \\"\$ac_cs_config\\"
1563215779
1606516212 "sesman/tools/Makefile") CONFIG_FILES="$CONFIG_FILES sesman/tools/Makefile" ;;
1606616213 "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
1606716214 "tests/common/Makefile") CONFIG_FILES="$CONFIG_FILES tests/common/Makefile" ;;
16215 "tests/libxrdp/Makefile") CONFIG_FILES="$CONFIG_FILES tests/libxrdp/Makefile" ;;
1606816216 "tests/memtest/Makefile") CONFIG_FILES="$CONFIG_FILES tests/memtest/Makefile" ;;
16217 "tests/xrdp/Makefile") CONFIG_FILES="$CONFIG_FILES tests/xrdp/Makefile" ;;
1606916218 "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;
1607016219 "tools/devel/Makefile") CONFIG_FILES="$CONFIG_FILES tools/devel/Makefile" ;;
1607116220 "tools/devel/tcp_proxy/Makefile") CONFIG_FILES="$CONFIG_FILES tools/devel/tcp_proxy/Makefile" ;;
1751017659 echo " auth mechanism $auth_mech"
1751117660 echo " rdpsndaudin $enable_rdpsndaudin"
1751217661 echo
17662 if test x$use_imlib2 = xyes; then
17663 echo " with imlib2 yes"
17664 else
17665 echo " with imlib2 no"
17666 fi
17667 echo
1751317668 echo " development logging $devel_logging"
1751417669 echo " development streamcheck $devel_streamcheck"
1751517670 echo ""
00 # Process this file with autoconf to produce a configure script
11
22 AC_PREREQ(2.65)
3 AC_INIT([xrdp], [0.9.17], [xrdp-devel@googlegroups.com])
3 AC_INIT([xrdp], [0.9.19], [xrdp-devel@googlegroups.com])
44 AC_CONFIG_HEADERS(config_ac.h:config_ac-h.in)
55 AM_INIT_AUTOMAKE([1.7.2 foreign])
66 AC_CONFIG_MACRO_DIR([m4])
165165 [], [enable_rdpsndaudin=no])
166166 AM_CONDITIONAL(XRDP_RDPSNDAUDIN, [test x$enable_rdpsndaudin = xyes])
167167
168 AC_ARG_WITH(imlib2, AC_HELP_STRING([--with-imlib2=ARG], [imlib2 library to use for non-BMP backgrounds (ARG=yes/no/<abs-path>)]),,)
169
168170 # Obsolete options
169171 AC_ARG_ENABLE(xrdpdebug, AS_HELP_STRING([--enable-xrdpdebug],
170172 [This option is no longer supported - use --enable-devel-all]))
214216 [AC_DEFINE([HAVE__PAM_TYPES_H], 1, [Using Linux-PAM], [])])
215217 AC_CHECK_HEADER([security/pam_constants.h],
216218 [AC_DEFINE([HAVE_PAM_CONSTANTS_H], 1, [Using OpenPAM], [])])
219
220 # Find imlib2
221 case "$with_imlib2" in
222 '' | no) AC_MSG_NOTICE([imlib2 will not be supported])
223 use_imlib2=no
224 ;;
225 yes)
226 PKG_CHECK_MODULES([IMLIB2], [imlib2 >= 1.4.5],
227 [use_imlib2=yes],
228 [AC_MSG_ERROR([please install libimlib2-dev or imlib2-devel])])
229 ;;
230 /*) AC_MSG_CHECKING([for imlib2 in $with_imlib2])
231 if test -d $with_imlib2/lib; then
232 IMLIB2_LIBS="-L$with_imlib2/lib -lImlib2"
233 elif test -d $with_imlib2/lib64; then
234 IMLIB2_LIBS="-L$with_imlib2/lib64 -lImlib2"
235 else
236 AC_MSG_RESULT([no])
237 AC_MSG_ERROR([Can't find libImlib2 in $with_imlib2])
238 fi
239
240 if test -f $with_imlib2/include/Imlib2.h; then
241 IMLIB2_CFLAGS="-I $with_imlib2/include"
242 else
243 AC_MSG_RESULT([no])
244 AC_MSG_ERROR([Can't find $with_imlib2/include/Imlib2.h])
245 fi
246 AC_MSG_RESULT([yes])
247 AC_SUBST([IMLIB2_LIBS])
248 AC_SUBST([IMLIB2_CFLAGS])
249 use_imlib2=yes
250 ;;
251 *) AC_MSG_ERROR([--with-imlib2 needs yes/no or absolute path])
252 esac
253
254 if test x$use_imlib2 = xyes; then
255 AC_DEFINE([USE_IMLIB2],1, [Compile with imlib2 support])
256 fi
217257
218258 # Check only one auth mechanism is specified, and give it a name
219259 auth_cnt=0
452492 sesman/tools/Makefile
453493 tests/Makefile
454494 tests/common/Makefile
495 tests/libxrdp/Makefile
455496 tests/memtest/Makefile
497 tests/xrdp/Makefile
456498 tools/Makefile
457499 tools/devel/Makefile
458500 tools/devel/tcp_proxy/Makefile
484526 echo " auth mechanism $auth_mech"
485527 echo " rdpsndaudin $enable_rdpsndaudin"
486528 echo
529 if test x$use_imlib2 = xyes; then
530 echo " with imlib2 yes"
531 else
532 echo " with imlib2 no"
533 fi
534 echo
487535 echo " development logging $devel_logging"
488536 echo " development streamcheck $devel_streamcheck"
489537 echo ""
22
33 scriptversion=2018-03-07.03; # UTC
44
5 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
5 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
66
77 # This program is free software; you can redistribute it and/or modify
88 # it under the terms of the GNU General Public License as published by
+0
-1
description-pak less more
0 RDP server for Linux
+0
-35
design.txt less more
0
1 This document is intended to explain xrdp server design.
2
3 Many connections, all capable of running different modules
4 one connection could be using a vnc connection
5 one could be running a custom app made for xrdp
6 one could be running a X11 session
7 clients control the screen size and color depth
8
9 all controlled by a configuration file.
10
11 you can create a lib or use a lib with your executable that talks
12 to xrdp server.
13
14 ------ ----------
15 -xrdp---linked-------mylib.so- session 1
16 ------ ----------
17 |
18 | -------------------------
19 |----unix socket--myapp linked to libxrdp- session 2
20 | -------------------------
21 |
22 | -----------
23 |----linked-------mylib2.so- session 3
24 -----------
25
26 Any of the above sessions can repeat or have different session
27 numbers or not even be used.
28 If a session is disconnected, all that changes is the rdp connection
29 is lost, the session remains.
30
31 For X11, start the XServer after the user is
32 authenticated. First check for the next available X11 display,
33 create a user session, start the XServer and set the DISPLAY environment
34 variable.
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
158158 unique=`for i in $$list; do \
159159 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
160160 done | $(am__uniquify_input)`
161 ETAGS = etags
162 CTAGS = ctags
163161 DIST_SUBDIRS = $(SUBDIRS)
164162 am__DIST_COMMON = $(srcdir)/Makefile.in
165163 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
203201 CHECK_LIBS = @CHECK_LIBS@
204202 CPP = @CPP@
205203 CPPFLAGS = @CPPFLAGS@
204 CSCOPE = @CSCOPE@
205 CTAGS = @CTAGS@
206206 CYGPATH_W = @CYGPATH_W@
207207 DEFS = @DEFS@
208208 DEPDIR = @DEPDIR@
214214 ECHO_N = @ECHO_N@
215215 ECHO_T = @ECHO_T@
216216 EGREP = @EGREP@
217 ETAGS = @ETAGS@
217218 EXEEXT = @EXEEXT@
218219 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
219220 FDKAAC_LIBS = @FDKAAC_LIBS@
223224 FUSE_CFLAGS = @FUSE_CFLAGS@
224225 FUSE_LIBS = @FUSE_LIBS@
225226 GREP = @GREP@
227 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
228 IMLIB2_LIBS = @IMLIB2_LIBS@
226229 INSTALL = @INSTALL@
227230 INSTALL_DATA = @INSTALL_DATA@
228231 INSTALL_PROGRAM = @INSTALL_PROGRAM@
473476
474477 distclean-tags:
475478 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
476
477479 distdir: $(BUILT_SOURCES)
478480 $(MAKE) $(AM_MAKEFLAGS) distdir-am
479481
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
177177 CHECK_LIBS = @CHECK_LIBS@
178178 CPP = @CPP@
179179 CPPFLAGS = @CPPFLAGS@
180 CSCOPE = @CSCOPE@
181 CTAGS = @CTAGS@
180182 CYGPATH_W = @CYGPATH_W@
181183 DEFS = @DEFS@
182184 DEPDIR = @DEPDIR@
188190 ECHO_N = @ECHO_N@
189191 ECHO_T = @ECHO_T@
190192 EGREP = @EGREP@
193 ETAGS = @ETAGS@
191194 EXEEXT = @EXEEXT@
192195 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
193196 FDKAAC_LIBS = @FDKAAC_LIBS@
197200 FUSE_CFLAGS = @FUSE_CFLAGS@
198201 FUSE_LIBS = @FUSE_LIBS@
199202 GREP = @GREP@
203 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
204 IMLIB2_LIBS = @IMLIB2_LIBS@
200205 INSTALL = @INSTALL@
201206 INSTALL_DATA = @INSTALL_DATA@
202207 INSTALL_PROGRAM = @INSTALL_PROGRAM@
509514
510515 cscope cscopelist:
511516
512
513517 distdir: $(BUILT_SOURCES)
514518 $(MAKE) $(AM_MAKEFLAGS) distdir-am
515519
220220 have session management rights.
221221
222222 .TP
223 \fBRestrictOutboundClipboard\fR=\fI[true|false]\fR
224 If set to \fB1\fR, \fBtrue\fR or \fByes\fR, will restrict the clipboard
223 \fBRestrictOutboundClipboard\fR=\fI[all|none|text|file|image]\fR
224 If set to \fBall\fR, will restrict the clipboard
225225 outbound from the server, to prevent data copied inside the xrdp session
226 to be be pasted in the client host. Default value is \fBfalse\fR.
226 to be pasted in the client. Default value is \fBnone\fR.
227 In addition, you can control text/file/image transfer restrictions
228 respectively. It also accepts comma separated list such as text,file,image.
229 .br
230
231 .br
232 \fBnone\fR - No restriction about copying inbound clipboard data.
233 .br
234 \fBall\fR - Restrict to copy inbound clipboard data.
235 .br
236 \fBtext\fR - Restrict to copy only inbound text clipboard data.
237 .br
238 \fBfile\fR - Restrict to copy only inbound file clipboard data.
239 .br
240 \fBimage\fR - Restrict to copy only inbound image clipboard data.
241 .br
242
243 To keep compatibility, the following aliases are also available.
244 .br
245 \fBtrue\fR - an alias of \fBall\fR.
246 .br
247 \fBfalse\fR - an alias of \fBnone\fR.
248 .br
249 \fByes\fR - an alias of \fBall\fR.
250
251 .TP
252 \fBRestrictInboundClipboard\fR=\fI[none|all|text|file|image]\fR
253 If set to \fBall\fR, will restrict the clipboard
254 inbound from the client, to prevent data copied inside the client
255 to be pasted in the xrdp session. Default value is \fBnone\fR.
256 In addition, you can control text/file/image transfer restrictions
257 respectively. It also accepts comma separated list such as text,file,image.
258 .br
259
260 .br
261 \fBnone\fR - No restriction about copying inbound clipboard data.
262 .br
263 \fBall\fR - Restrict to copy inbound clipboard data.
264 .br
265 \fBtext\fR - Restrict to copy only inbound text clipboard data.
266 .br
267 \fBfile\fR - Restrict to copy only inbound file clipboard data.
268 .br
269 \fBimage\fR - Restrict to copy only inbound image clipboard data.
270 .br
271
272 To keep compatibility, the following aliases are also available.
273 .br
274 \fBtrue\fR - an alias of \fBall\fR.
275 .br
276 \fBfalse\fR - an alias of \fBnone\fR.
277 .br
278 \fByes\fR - an alias of \fBall\fR.
227279
228280 .TP
229281 \fBAlwaysGroupCheck\fR=\fI[true|false]\fR
289341 .P
290342 - copying-and-pasting of files
291343 .RE
344 .TP
345 \fBUseNautilus3FlistFormat\fR=\fI[false|true]\fR
346 Defaults to \fIfalse\fR.
347 Set to \fItrue\fR to make file copy-paste compatible with Nautilus from
348 GNOME 3 versions later than 3.29.92. Do not use this for any other reason.
349
350 This setting will be removed in a later version of xrdp, when GNOME 3 is
351 no longer supported.
292352
293353 .SH "SESSIONS VARIABLES"
294354 All entries in the \fB[SessionVariables]\fR section are set as
+0
-56
faq-compile.txt less more
0 Compile FAQ
1
2 Q. I get one of the following errors:
3 - "security/pam_appl.h: File or directory doesn't exist"
4 - "configure: error: please install libpam0g-dev or pam-devel"
5 What is wrong?
6
7 A. You need to install the pam development package.
8 For Debian / Ubuntu this package is called libpam0g-dev.
9 For Red Hat / SUSE this package is called pam-devel.
10
11
12 Q. I get an error: "configure: error: please install libssl-dev or openssl-devel"
13
14 A. You need to install the openssl development package.
15 For Debian / Ubuntu this package is called libssl-dev.
16 For Red Hat / Fedora this package is called openssl-devel.
17 For SUSE / openSUSE this package is called libopenssl-devel.
18
19
20 Q. I get one of the following errors:
21 - "configure: error: please install libx11-dev or libX11-devel"
22 - "configure: error: please install libx11-dev and libxfixes-dev or libXfixes-devel"
23
24 A. You need to install the X11 and X11 Xfixes development package(s).
25 For Debian: libx11-dev and libxfixes-dev.
26 For Red Hat / SUSE: libX11-devel and libXfixes-devel.
27
28
29 Q. I get an error: "rail.c:31:35: fatal error: X11/extensions/Xrandr.h: No such file or directory"
30
31 A. You need to install the Xrandr development package.
32 For Debian / Ubuntu this package is called libxrandr-dev.
33 For SUSE / openSUSE this package is called libXrandr-devel.
34
35 Q. How do I configure the same continuous integration bulids for my XRDP fork as the official XRDP repository?
36
37 A. The XRDP project uses both Travis-CI.org and Cirrus-CI.com for continuous integration.
38 Both of these services are free for open source projects (both the official
39 repository and forks), and these services integrate with Github to build any
40 changes pushed to public Github repositories.
41
42 To configure Travis CI for your XRDP fork on github:
43 1. Follow Travis CI instructions for connecting your github account to Travis CI
44 https://docs.travis-ci.com/user/tutorial/#to-get-started-with-travis-ci-using-github
45 2. In the Travis CI dashboard setting page select your XRDP fork repository for building pushed branches.
46 3. Push a commit to a branch in your XRDP fork on github and Travis CI should
47 start building the branch because the XRDP repository already contain a .travis.yml file.
48
49 To configure Cirrus CI for your XRDP fork on github:
50 1. Follow Cirrus CI instructions for connecting your github account to Cirrus CI
51 https://cirrus-ci.org/guide/quick-start/
52 2. In the Github setting page for the Cirrus CI application, enable Cirrus CI
53 access to your XRDP fork repository.
54 3. Push a commit to a branch in your XRDP fork on github and Cirrus CI should
55 start building the branch because the XRDP repository already contain a .cirrus.yml file.
+0
-22
faq-general.txt less more
0 General FAQ
1
2 Q. What is RDP?
3
4 A. RDP stands for Remote Desktop Protocol. It's the protocol used by Windows
5 terminal servers to talk to the terminal server clients.
6
7
8 Q. What is xrdp?
9
10 A. xrdp, usually spelled in lower case, is as open source implementation of the
11 RDP protocol.
12
13
14 Q. I can't get xrdp to compile in Ubuntu. What can I do?
15
16 A. See faq-compile.txt.
17
18
19 Q. Can I use LDAP?
20
21 A. Yes, xrdp uses PAM and thus can be configured to use LDAP for authentication.
+0
-78
file-loc.txt less more
0
1 default build will install the following
2
3 /usr/local/lib/xrdp
4 libcommon.so
5 libmc.so
6 libscp.so
7 libvnc.so
8 libxrdp.so
9 libxrdpapi.so
10 libxup.so
11
12 /usr/local/bin
13 xrdp-dis
14 xrdp-genkeymap
15 xrdp-keygen
16 xrdp-sesadmin
17 xrdp-sesrun
18
19 /usr/local/sbin
20 xrdp
21 xrdp-sesman
22 xrdp-sessvc
23 xrdp-chansrv
24
25 /etc/xrdp
26 km-xxxxxxxx.ini
27 sesman.ini
28 rsakeys.ini
29 startwm.sh
30 xrdp.ini
31 xrdp_keyboard.ini
32
33 /etc/xrdp/pulse
34 default.pa
35
36 /etc/pam.d
37 xrdp-sesman
38
39 /usr/local/share/man/man1
40 xrdp-dis.1
41
42 /usr/local/share/man/man5
43 sesman.ini.5
44 xrdp.ini.5
45
46 /usr/local/share/man/man8
47 xrdp-chansrv.8
48 xrdp-genkeymap.8
49 xrdp-keygen.8
50 xrdp-sesadmin.8
51 xrdp-sesman.8
52 xrdp-sesrun.8
53 xrdp-sessvc.8
54 xrdp.8
55
56 /usr/local/share/xrdp
57 ad24b.bmp
58 ad256.bmp
59 cursor0.cur
60 cursor1.cur
61 sans-10.fv1
62 xrdp24b.bmp
63 xrdp256.bmp
64 xrdp_logo.bmp
65
66 when running, the following are created and written to
67
68 /var/run
69 xrdp.pid
70 sesman.pid
71
72 /var/log
73 xrdp.log
74 xrdp-sesman.log
75
76 /tmp/.xrdp
77 xrdp*
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
183183 unique=`for i in $$list; do \
184184 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
185185 done | $(am__uniquify_input)`
186 ETAGS = etags
187 CTAGS = ctags
188186 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
189187 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
190188 ACLOCAL = @ACLOCAL@
202200 CHECK_LIBS = @CHECK_LIBS@
203201 CPP = @CPP@
204202 CPPFLAGS = @CPPFLAGS@
203 CSCOPE = @CSCOPE@
204 CTAGS = @CTAGS@
205205 CYGPATH_W = @CYGPATH_W@
206206 DEFS = @DEFS@
207207 DEPDIR = @DEPDIR@
213213 ECHO_N = @ECHO_N@
214214 ECHO_T = @ECHO_T@
215215 EGREP = @EGREP@
216 ETAGS = @ETAGS@
216217 EXEEXT = @EXEEXT@
217218 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
218219 FDKAAC_LIBS = @FDKAAC_LIBS@
222223 FUSE_CFLAGS = @FUSE_CFLAGS@
223224 FUSE_LIBS = @FUSE_LIBS@
224225 GREP = @GREP@
226 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
227 IMLIB2_LIBS = @IMLIB2_LIBS@
225228 INSTALL = @INSTALL@
226229 INSTALL_DATA = @INSTALL_DATA@
227230 INSTALL_PROGRAM = @INSTALL_PROGRAM@
524527
525528 distclean-tags:
526529 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
527
528530 distdir: $(BUILT_SOURCES)
529531 $(MAKE) $(AM_MAKEFLAGS) distdir-am
530532
00 #!/bin/sh
11
2 which setxkbmap
2 command -v setxkbmap
33 if test $? -ne 0
44 then
55 echo "error, setxkbmap not found"
+0
-54
install.txt less more
0
1 Installation directions for xrdp.
2
3 Things you need to compile and install. Most systems don't
4 have these installed by default.
5 gcc and make
6 Header files for pam
7 Header files for openssl
8
9 You can build sesman without pam, there is a Makefile parameter
10 for that.
11 I also have a replacement ssl_calls.c to avoid the openssl dependency
12 email me(Jay) for it or see http://server1.xrdp.org/xrdp/openssl.
13 Due to the license, I can't include it in this project.
14
15 http://server1.xrdp.org/xrdp/openssl/
16
17 unpack the tarball
18
19 tar -zxvf xrdp-0.1.tar.gz
20
21 this will create a folder xrdp
22
23 switch to the xrdp folder(cd xrdp)
24
25 run make
26
27 as root, run make install
28
29 This will install most of the files in /usr/local/xrdp.
30 Some files install in /etc/xrdp. These are configuration
31 files.
32
33 files and location
34 /usr/local/xrdp/startwm.sh - script that starts the window manager
35 You may need to edit this file to run your window manager.
36 /etc/sesman.ini - sesman configuration file
37 /etc/rsakeys.ini - rsa stuff
38 /etc/xrdp.ini - xrdp configuration file
39 /var/run/sesman.pid
40 /var/rub/xrdp.pid
41
42 Sesman and xrdp both have to be running as root.
43 You should set them to start when the system starts.
44 You can use xrdp_control.sh script to start them.
45
46 To completely remove xrdp
47 remove directory /usr/local/xrdp
48 remove directory /etc/xrdp
49 remove file /var/run/xrdp.pid
50 remove file /var/run/sesman.pid
51 remove any startup links added to /etc/init.d or /etc/rcX.d
52
53 jay.sorg@gmail.com
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
204204 unique=`for i in $$list; do \
205205 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
206206 done | $(am__uniquify_input)`
207 ETAGS = etags
208 CTAGS = ctags
209207 DIST_SUBDIRS = pam.d pulse default init.d rc.d
210208 am__DIST_COMMON = $(srcdir)/Makefile.in
211209 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
249247 CHECK_LIBS = @CHECK_LIBS@
250248 CPP = @CPP@
251249 CPPFLAGS = @CPPFLAGS@
250 CSCOPE = @CSCOPE@
251 CTAGS = @CTAGS@
252252 CYGPATH_W = @CYGPATH_W@
253253 DEFS = @DEFS@
254254 DEPDIR = @DEPDIR@
260260 ECHO_N = @ECHO_N@
261261 ECHO_T = @ECHO_T@
262262 EGREP = @EGREP@
263 ETAGS = @ETAGS@
263264 EXEEXT = @EXEEXT@
264265 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
265266 FDKAAC_LIBS = @FDKAAC_LIBS@
269270 FUSE_CFLAGS = @FUSE_CFLAGS@
270271 FUSE_LIBS = @FUSE_LIBS@
271272 GREP = @GREP@
273 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
274 IMLIB2_LIBS = @IMLIB2_LIBS@
272275 INSTALL = @INSTALL@
273276 INSTALL_DATA = @INSTALL_DATA@
274277 INSTALL_PROGRAM = @INSTALL_PROGRAM@
621624
622625 distclean-tags:
623626 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
624
625627 distdir: $(BUILT_SOURCES)
626628 $(MAKE) $(AM_MAKEFLAGS) distdir-am
627629
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
174174 CHECK_LIBS = @CHECK_LIBS@
175175 CPP = @CPP@
176176 CPPFLAGS = @CPPFLAGS@
177 CSCOPE = @CSCOPE@
178 CTAGS = @CTAGS@
177179 CYGPATH_W = @CYGPATH_W@
178180 DEFS = @DEFS@
179181 DEPDIR = @DEPDIR@
185187 ECHO_N = @ECHO_N@
186188 ECHO_T = @ECHO_T@
187189 EGREP = @EGREP@
190 ETAGS = @ETAGS@
188191 EXEEXT = @EXEEXT@
189192 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
190193 FDKAAC_LIBS = @FDKAAC_LIBS@
194197 FUSE_CFLAGS = @FUSE_CFLAGS@
195198 FUSE_LIBS = @FUSE_LIBS@
196199 GREP = @GREP@
200 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
201 IMLIB2_LIBS = @IMLIB2_LIBS@
197202 INSTALL = @INSTALL@
198203 INSTALL_DATA = @INSTALL_DATA@
199204 INSTALL_PROGRAM = @INSTALL_PROGRAM@
371376
372377 cscope cscopelist:
373378
374
375379 distdir: $(BUILT_SOURCES)
376380 $(MAKE) $(AM_MAKEFLAGS) distdir-am
377381
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
174174 CHECK_LIBS = @CHECK_LIBS@
175175 CPP = @CPP@
176176 CPPFLAGS = @CPPFLAGS@
177 CSCOPE = @CSCOPE@
178 CTAGS = @CTAGS@
177179 CYGPATH_W = @CYGPATH_W@
178180 DEFS = @DEFS@
179181 DEPDIR = @DEPDIR@
185187 ECHO_N = @ECHO_N@
186188 ECHO_T = @ECHO_T@
187189 EGREP = @EGREP@
190 ETAGS = @ETAGS@
188191 EXEEXT = @EXEEXT@
189192 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
190193 FDKAAC_LIBS = @FDKAAC_LIBS@
194197 FUSE_CFLAGS = @FUSE_CFLAGS@
195198 FUSE_LIBS = @FUSE_LIBS@
196199 GREP = @GREP@
200 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
201 IMLIB2_LIBS = @IMLIB2_LIBS@
197202 INSTALL = @INSTALL@
198203 INSTALL_DATA = @INSTALL_DATA@
199204 INSTALL_PROGRAM = @INSTALL_PROGRAM@
385390
386391 cscope cscopelist:
387392
388
389393 distdir: $(BUILT_SOURCES)
390394 $(MAKE) $(AM_MAKEFLAGS) distdir-am
391395
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
173173 CHECK_LIBS = @CHECK_LIBS@
174174 CPP = @CPP@
175175 CPPFLAGS = @CPPFLAGS@
176 CSCOPE = @CSCOPE@
177 CTAGS = @CTAGS@
176178 CYGPATH_W = @CYGPATH_W@
177179 DEFS = @DEFS@
178180 DEPDIR = @DEPDIR@
184186 ECHO_N = @ECHO_N@
185187 ECHO_T = @ECHO_T@
186188 EGREP = @EGREP@
189 ETAGS = @ETAGS@
187190 EXEEXT = @EXEEXT@
188191 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
189192 FDKAAC_LIBS = @FDKAAC_LIBS@
193196 FUSE_CFLAGS = @FUSE_CFLAGS@
194197 FUSE_LIBS = @FUSE_LIBS@
195198 GREP = @GREP@
199 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
200 IMLIB2_LIBS = @IMLIB2_LIBS@
196201 INSTALL = @INSTALL@
197202 INSTALL_DATA = @INSTALL_DATA@
198203 INSTALL_PROGRAM = @INSTALL_PROGRAM@
387392
388393 cscope cscopelist:
389394
390
391395 distdir: $(BUILT_SOURCES)
392396 $(MAKE) $(AM_MAKEFLAGS) distdir-am
393397
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
174174 CHECK_LIBS = @CHECK_LIBS@
175175 CPP = @CPP@
176176 CPPFLAGS = @CPPFLAGS@
177 CSCOPE = @CSCOPE@
178 CTAGS = @CTAGS@
177179 CYGPATH_W = @CYGPATH_W@
178180 DEFS = @DEFS@
179181 DEPDIR = @DEPDIR@
185187 ECHO_N = @ECHO_N@
186188 ECHO_T = @ECHO_T@
187189 EGREP = @EGREP@
190 ETAGS = @ETAGS@
188191 EXEEXT = @EXEEXT@
189192 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
190193 FDKAAC_LIBS = @FDKAAC_LIBS@
194197 FUSE_CFLAGS = @FUSE_CFLAGS@
195198 FUSE_LIBS = @FUSE_LIBS@
196199 GREP = @GREP@
200 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
201 IMLIB2_LIBS = @IMLIB2_LIBS@
197202 INSTALL = @INSTALL@
198203 INSTALL_DATA = @INSTALL_DATA@
199204 INSTALL_PROGRAM = @INSTALL_PROGRAM@
371376
372377 cscope cscopelist:
373378
374
375379 distdir: $(BUILT_SOURCES)
376380 $(MAKE) $(AM_MAKEFLAGS) distdir-am
377381
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
174174 CHECK_LIBS = @CHECK_LIBS@
175175 CPP = @CPP@
176176 CPPFLAGS = @CPPFLAGS@
177 CSCOPE = @CSCOPE@
178 CTAGS = @CTAGS@
177179 CYGPATH_W = @CYGPATH_W@
178180 DEFS = @DEFS@
179181 DEPDIR = @DEPDIR@
185187 ECHO_N = @ECHO_N@
186188 ECHO_T = @ECHO_T@
187189 EGREP = @EGREP@
190 ETAGS = @ETAGS@
188191 EXEEXT = @EXEEXT@
189192 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
190193 FDKAAC_LIBS = @FDKAAC_LIBS@
194197 FUSE_CFLAGS = @FUSE_CFLAGS@
195198 FUSE_LIBS = @FUSE_LIBS@
196199 GREP = @GREP@
200 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
201 IMLIB2_LIBS = @IMLIB2_LIBS@
197202 INSTALL = @INSTALL@
198203 INSTALL_DATA = @INSTALL_DATA@
199204 INSTALL_PROGRAM = @INSTALL_PROGRAM@
385390
386391 cscope cscopelist:
387392
388
389393 distdir: $(BUILT_SOURCES)
390394 $(MAKE) $(AM_MAKEFLAGS) distdir-am
391395
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
176176 unique=`for i in $$list; do \
177177 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
178178 done | $(am__uniquify_input)`
179 ETAGS = etags
180 CTAGS = ctags
181179 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
182180 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
183181 ACLOCAL = @ACLOCAL@
195193 CHECK_LIBS = @CHECK_LIBS@
196194 CPP = @CPP@
197195 CPPFLAGS = @CPPFLAGS@
196 CSCOPE = @CSCOPE@
197 CTAGS = @CTAGS@
198198 CYGPATH_W = @CYGPATH_W@
199199 DEFS = @DEFS@
200200 DEPDIR = @DEPDIR@
206206 ECHO_N = @ECHO_N@
207207 ECHO_T = @ECHO_T@
208208 EGREP = @EGREP@
209 ETAGS = @ETAGS@
209210 EXEEXT = @EXEEXT@
210211 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
211212 FDKAAC_LIBS = @FDKAAC_LIBS@
215216 FUSE_CFLAGS = @FUSE_CFLAGS@
216217 FUSE_LIBS = @FUSE_LIBS@
217218 GREP = @GREP@
219 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
220 IMLIB2_LIBS = @IMLIB2_LIBS@
218221 INSTALL = @INSTALL@
219222 INSTALL_DATA = @INSTALL_DATA@
220223 INSTALL_PROGRAM = @INSTALL_PROGRAM@
517520
518521 distclean-tags:
519522 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
520
521523 distdir: $(BUILT_SOURCES)
522524 $(MAKE) $(AM_MAKEFLAGS) distdir-am
523525
(New empty file)
(New empty file)
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
161161 unique=`for i in $$list; do \
162162 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
163163 done | $(am__uniquify_input)`
164 ETAGS = etags
165 CTAGS = ctags
166 CSCOPE = cscope
167164 DIST_SUBDIRS = src include pkgconfig tests
168165 am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config_ac-h.in \
169 compile config.guess config.sub install-sh ltmain.sh missing
166 AUTHORS ChangeLog NEWS README compile config.guess config.sub \
167 install-sh ltmain.sh missing
170168 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
171169 distdir = $(PACKAGE)-$(VERSION)
172170 top_distdir = $(distdir)
224222 CFLAGS = @CFLAGS@
225223 CPP = @CPP@
226224 CPPFLAGS = @CPPFLAGS@
225 CSCOPE = @CSCOPE@
226 CTAGS = @CTAGS@
227227 CYGPATH_W = @CYGPATH_W@
228228 DEFS = @DEFS@
229229 DEPDIR = @DEPDIR@
234234 ECHO_N = @ECHO_N@
235235 ECHO_T = @ECHO_T@
236236 EGREP = @EGREP@
237 ETAGS = @ETAGS@
237238 EXEEXT = @EXEEXT@
238239 FGREP = @FGREP@
239240 GREP = @GREP@
503504 distclean-tags:
504505 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
505506 -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
506
507507 distdir: $(BUILT_SOURCES)
508508 $(MAKE) $(AM_MAKEFLAGS) distdir-am
509509
(New empty file)
(New empty file)
0 # generated automatically by aclocal 1.16.3 -*- Autoconf -*-
1
2 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
0 # generated automatically by aclocal 1.16.5 -*- Autoconf -*-
1
2 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
33
44 # This file is free software; the Free Software Foundation
55 # gives unlimited permission to copy and/or distribute it,
1919 If you have problems, you may need to regenerate the build system entirely.
2020 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
2121
22 # Copyright (C) 2002-2020 Free Software Foundation, Inc.
22 # Copyright (C) 2002-2021 Free Software Foundation, Inc.
2323 #
2424 # This file is free software; the Free Software Foundation
2525 # gives unlimited permission to copy and/or distribute it,
3434 [am__api_version='1.16'
3535 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
3636 dnl require some minimum version. Point them to the right macro.
37 m4_if([$1], [1.16.3], [],
37 m4_if([$1], [1.16.5], [],
3838 [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
3939 ])
4040
5050 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
5151 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
5252 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
53 [AM_AUTOMAKE_VERSION([1.16.3])dnl
53 [AM_AUTOMAKE_VERSION([1.16.5])dnl
5454 m4_ifndef([AC_AUTOCONF_VERSION],
5555 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
5656 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
5757
5858 # AM_AUX_DIR_EXPAND -*- Autoconf -*-
5959
60 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
60 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
6161 #
6262 # This file is free software; the Free Software Foundation
6363 # gives unlimited permission to copy and/or distribute it,
109109
110110 # AM_CONDITIONAL -*- Autoconf -*-
111111
112 # Copyright (C) 1997-2020 Free Software Foundation, Inc.
112 # Copyright (C) 1997-2021 Free Software Foundation, Inc.
113113 #
114114 # This file is free software; the Free Software Foundation
115115 # gives unlimited permission to copy and/or distribute it,
140140 Usually this means the macro was only invoked conditionally.]])
141141 fi])])
142142
143 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
143 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
144144 #
145145 # This file is free software; the Free Software Foundation
146146 # gives unlimited permission to copy and/or distribute it,
331331
332332 # Generate code to set up dependency tracking. -*- Autoconf -*-
333333
334 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
334 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
335335 #
336336 # This file is free software; the Free Software Foundation
337337 # gives unlimited permission to copy and/or distribute it,
399399
400400 # Do all the work for Automake. -*- Autoconf -*-
401401
402 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
402 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
403403 #
404404 # This file is free software; the Free Software Foundation
405405 # gives unlimited permission to copy and/or distribute it,
427427 # release and drop the old call support.
428428 AC_DEFUN([AM_INIT_AUTOMAKE],
429429 [AC_PREREQ([2.65])dnl
430 m4_ifdef([_$0_ALREADY_INIT],
431 [m4_fatal([$0 expanded multiple times
432 ]m4_defn([_$0_ALREADY_INIT]))],
433 [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl
430434 dnl Autoconf wants to disallow AM_ names. We explicitly allow
431435 dnl the ones we care about.
432436 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
463467 [_AM_SET_OPTIONS([$1])dnl
464468 dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
465469 m4_if(
466 m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
470 m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]),
467471 [ok:ok],,
468472 [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
469473 AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
515519 [m4_define([AC_PROG_OBJCXX],
516520 m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
517521 ])
522 # Variables for tags utilities; see am/tags.am
523 if test -z "$CTAGS"; then
524 CTAGS=ctags
525 fi
526 AC_SUBST([CTAGS])
527 if test -z "$ETAGS"; then
528 ETAGS=etags
529 fi
530 AC_SUBST([ETAGS])
531 if test -z "$CSCOPE"; then
532 CSCOPE=cscope
533 fi
534 AC_SUBST([CSCOPE])
535
518536 AC_REQUIRE([AM_SILENT_RULES])dnl
519537 dnl The testsuite driver may need to know about EXEEXT, so add the
520538 dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
596614 done
597615 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
598616
599 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
617 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
600618 #
601619 # This file is free software; the Free Software Foundation
602620 # gives unlimited permission to copy and/or distribute it,
617635 fi
618636 AC_SUBST([install_sh])])
619637
620 # Copyright (C) 2003-2020 Free Software Foundation, Inc.
638 # Copyright (C) 2003-2021 Free Software Foundation, Inc.
621639 #
622640 # This file is free software; the Free Software Foundation
623641 # gives unlimited permission to copy and/or distribute it,
638656
639657 # Check to see how 'make' treats includes. -*- Autoconf -*-
640658
641 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
659 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
642660 #
643661 # This file is free software; the Free Software Foundation
644662 # gives unlimited permission to copy and/or distribute it,
681699
682700 # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
683701
684 # Copyright (C) 1997-2020 Free Software Foundation, Inc.
702 # Copyright (C) 1997-2021 Free Software Foundation, Inc.
685703 #
686704 # This file is free software; the Free Software Foundation
687705 # gives unlimited permission to copy and/or distribute it,
715733
716734 # Helper functions for option handling. -*- Autoconf -*-
717735
718 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
736 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
719737 #
720738 # This file is free software; the Free Software Foundation
721739 # gives unlimited permission to copy and/or distribute it,
744762 AC_DEFUN([_AM_IF_OPTION],
745763 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
746764
747 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
765 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
748766 #
749767 # This file is free software; the Free Software Foundation
750768 # gives unlimited permission to copy and/or distribute it,
791809 # For backward compatibility.
792810 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
793811
794 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
812 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
795813 #
796814 # This file is free software; the Free Software Foundation
797815 # gives unlimited permission to copy and/or distribute it,
810828
811829 # Check to make sure that the build environment is sane. -*- Autoconf -*-
812830
813 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
831 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
814832 #
815833 # This file is free software; the Free Software Foundation
816834 # gives unlimited permission to copy and/or distribute it,
891909 rm -f conftest.file
892910 ])
893911
894 # Copyright (C) 2009-2020 Free Software Foundation, Inc.
912 # Copyright (C) 2009-2021 Free Software Foundation, Inc.
895913 #
896914 # This file is free software; the Free Software Foundation
897915 # gives unlimited permission to copy and/or distribute it,
951969 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
952970 ])
953971
954 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
972 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
955973 #
956974 # This file is free software; the Free Software Foundation
957975 # gives unlimited permission to copy and/or distribute it,
979997 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
980998 AC_SUBST([INSTALL_STRIP_PROGRAM])])
981999
982 # Copyright (C) 2006-2020 Free Software Foundation, Inc.
1000 # Copyright (C) 2006-2021 Free Software Foundation, Inc.
9831001 #
9841002 # This file is free software; the Free Software Foundation
9851003 # gives unlimited permission to copy and/or distribute it,
9981016
9991017 # Check how to create a tarball. -*- Autoconf -*-
10001018
1001 # Copyright (C) 2004-2020 Free Software Foundation, Inc.
1019 # Copyright (C) 2004-2021 Free Software Foundation, Inc.
10021020 #
10031021 # This file is free software; the Free Software Foundation
10041022 # gives unlimited permission to copy and/or distribute it,
00 #!/bin/sh
11
2 which autoconf
2 command -v autoconf
33 if ! test $? -eq 0
44 then
55 echo "error, install autoconf"
66 exit 1
77 fi
88
9 which automake
9 command -v automake
1010 if ! test $? -eq 0
1111 then
1212 echo "error, install automake"
1313 exit 1
1414 fi
1515
16 which libtool || which libtoolize
16 command -v libtool || command -v libtoolize
1717 if ! test $? -eq 0
1818 then
1919 echo "error, install libtool"
2020 exit 1
2121 fi
2222
23 which pkg-config
23 command -v pkg-config
2424 if ! test $? -eq 0
2525 then
2626 echo "error, install pkg-config"
22
33 scriptversion=2018-03-07.03; # UTC
44
5 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
5 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
66 # Written by Tom Tromey <tromey@cygnus.com>.
77 #
88 # This program is free software; you can redistribute it and/or modify
688688 AM_DEFAULT_VERBOSITY
689689 AM_DEFAULT_V
690690 AM_V
691 CSCOPE
692 ETAGS
693 CTAGS
691694 am__untar
692695 am__tar
693696 AMTAR
26852688
26862689
26872690
2691
2692
2693 # Variables for tags utilities; see am/tags.am
2694 if test -z "$CTAGS"; then
2695 CTAGS=ctags
2696 fi
2697
2698 if test -z "$ETAGS"; then
2699 ETAGS=etags
2700 fi
2701
2702 if test -z "$CSCOPE"; then
2703 CSCOPE=cscope
2704 fi
26882705
26892706
26902707
22
33 scriptversion=2018-03-07.03; # UTC
44
5 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
5 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
66
77 # This program is free software; you can redistribute it and/or modify
88 # it under the terms of the GNU General Public License as published by
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
171171 unique=`for i in $$list; do \
172172 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
173173 done | $(am__uniquify_input)`
174 ETAGS = etags
175 CTAGS = ctags
176174 am__DIST_COMMON = $(srcdir)/Makefile.in
177175 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
178176 ACLOCAL = @ACLOCAL@
188186 CFLAGS = @CFLAGS@
189187 CPP = @CPP@
190188 CPPFLAGS = @CPPFLAGS@
189 CSCOPE = @CSCOPE@
190 CTAGS = @CTAGS@
191191 CYGPATH_W = @CYGPATH_W@
192192 DEFS = @DEFS@
193193 DEPDIR = @DEPDIR@
198198 ECHO_N = @ECHO_N@
199199 ECHO_T = @ECHO_T@
200200 EGREP = @EGREP@
201 ETAGS = @ETAGS@
201202 EXEEXT = @EXEEXT@
202203 FGREP = @FGREP@
203204 GREP = @GREP@
404405
405406 distclean-tags:
406407 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
407
408408 distdir: $(BUILT_SOURCES)
409409 $(MAKE) $(AM_MAKEFLAGS) distdir-am
410410
2323 #define LIBPAINTER_VERSION_MICRO 0
2424
2525 #define PT_FORMAT_a8b8g8r8 \
26 ((32 << 24) | (3 << 16) | (8 << 12) | (8 << 8) | (8 << 4) | 8)
26 ((32 << 24) | (3 << 16) | (8 << 12) | (8 << 8) | (8 << 4) | 8)
2727 #define PT_FORMAT_a8r8g8b8 \
28 ((32 << 24) | (2 << 16) | (8 << 12) | (8 << 8) | (8 << 4) | 8)
28 ((32 << 24) | (2 << 16) | (8 << 12) | (8 << 8) | (8 << 4) | 8)
2929 #define PT_FORMAT_r5g6b5 \
30 ((16 << 24) | (2 << 16) | (0 << 12) | (5 << 8) | (6 << 4) | 5)
30 ((16 << 24) | (2 << 16) | (0 << 12) | (5 << 8) | (6 << 4) | 5)
3131 #define PT_FORMAT_a1r5g5b5 \
32 ((16 << 24) | (2 << 16) | (1 << 12) | (5 << 8) | (5 << 4) | 5)
32 ((16 << 24) | (2 << 16) | (1 << 12) | (5 << 8) | (5 << 4) | 5)
3333 #define PT_FORMAT_r3g3b2 \
34 ((8 << 24) | (2 << 16) | (0 << 12) | (3 << 8) | (3 << 4) | 2)
34 ((8 << 24) | (2 << 16) | (0 << 12) | (3 << 8) | (3 << 4) | 2)
3535
3636 #define PT_FORMAT_c1 \
37 ((1 << 24) | (4 << 16) | (0 << 12) | (0 << 8) | (0 << 4) | 0)
37 ((1 << 24) | (4 << 16) | (0 << 12) | (0 << 8) | (0 << 4) | 0)
3838 #define PT_FORMAT_c8 \
39 ((8 << 24) | (4 << 16) | (0 << 12) | (0 << 8) | (0 << 4) | 0)
39 ((8 << 24) | (4 << 16) | (0 << 12) | (0 << 8) | (0 << 4) | 0)
4040
4141 struct painter_bitmap
4242 {
5757
5858 #define PT_LINE_FLAGS_NONE 0
5959
60 /* reverse Windows X11 */
61 /* polish */
60 /* reverse Windows X11 */
61 /* polish */
6262 #define PT_ROP_0 0x00 /* 0 BLACKNESS GXclear */
6363 #define PT_ROP_DSon 0x11 /* DSon NOTSRCERASE GXnor */
6464 #define PT_ROP_DSna 0x22 /* DSna GXandInverted */
22
33 scriptversion=2018-03-07.03; # UTC
44
5 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
5 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
66 # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
77
88 # This program is free software; you can redistribute it and/or modify
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
171171 CFLAGS = @CFLAGS@
172172 CPP = @CPP@
173173 CPPFLAGS = @CPPFLAGS@
174 CSCOPE = @CSCOPE@
175 CTAGS = @CTAGS@
174176 CYGPATH_W = @CYGPATH_W@
175177 DEFS = @DEFS@
176178 DEPDIR = @DEPDIR@
181183 ECHO_N = @ECHO_N@
182184 ECHO_T = @ECHO_T@
183185 EGREP = @EGREP@
186 ETAGS = @ETAGS@
184187 EXEEXT = @EXEEXT@
185188 FGREP = @FGREP@
186189 GREP = @GREP@
344347
345348 cscope cscopelist:
346349
347
348350 distdir: $(BUILT_SOURCES)
349351 $(MAKE) $(AM_MAKEFLAGS) distdir-am
350352
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
204204 unique=`for i in $$list; do \
205205 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
206206 done | $(am__uniquify_input)`
207 ETAGS = etags
208 CTAGS = ctags
209207 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
210208 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
211209 ACLOCAL = @ACLOCAL@
221219 CFLAGS = @CFLAGS@
222220 CPP = @CPP@
223221 CPPFLAGS = @CPPFLAGS@
222 CSCOPE = @CSCOPE@
223 CTAGS = @CTAGS@
224224 CYGPATH_W = @CYGPATH_W@
225225 DEFS = @DEFS@
226226 DEPDIR = @DEPDIR@
231231 ECHO_N = @ECHO_N@
232232 ECHO_T = @ECHO_T@
233233 EGREP = @EGREP@
234 ETAGS = @ETAGS@
234235 EXEEXT = @EXEEXT@
235236 FGREP = @FGREP@
236237 GREP = @GREP@
503504
504505 distclean-tags:
505506 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
506
507507 distdir: $(BUILT_SOURCES)
508508 $(MAKE) $(AM_MAKEFLAGS) distdir-am
509509
3333 {
3434 switch (rop)
3535 {
36 case PT_ROP_0: return 0;
37 case PT_ROP_DSon: return ~(src | dst);
38 case PT_ROP_DSna: return (~src) & dst;
39 case PT_ROP_Sn: return ~src;
40 case PT_ROP_SDna: return src & (~dst);
41 case PT_ROP_Dn: return ~(dst);
42 case PT_ROP_DSx: return src ^ dst;
43 case PT_ROP_DSan: return ~(src & dst);
44 case PT_ROP_DSa: return src & dst;
45 case PT_ROP_DSxn: return ~(src) ^ dst;
46 case PT_ROP_D: return dst;
47 case PT_ROP_DSno: return (~src) | dst;
48 case PT_ROP_S: return src;
49 case PT_ROP_SDno: return src | (~dst);
50 case PT_ROP_DSo: return src | dst;
51 case PT_ROP_1: return ~0;
36 case PT_ROP_0:
37 return 0;
38 case PT_ROP_DSon:
39 return ~(src | dst);
40 case PT_ROP_DSna:
41 return (~src) & dst;
42 case PT_ROP_Sn:
43 return ~src;
44 case PT_ROP_SDna:
45 return src & (~dst);
46 case PT_ROP_Dn:
47 return ~(dst);
48 case PT_ROP_DSx:
49 return src ^ dst;
50 case PT_ROP_DSan:
51 return ~(src & dst);
52 case PT_ROP_DSa:
53 return src & dst;
54 case PT_ROP_DSxn:
55 return ~(src) ^ dst;
56 case PT_ROP_D:
57 return dst;
58 case PT_ROP_DSno:
59 return (~src) | dst;
60 case PT_ROP_S:
61 return src;
62 case PT_ROP_SDno:
63 return src | (~dst);
64 case PT_ROP_DSo:
65 return src | dst;
66 case PT_ROP_1:
67 return ~0;
5268 }
5369 return dst;
5470 }
6278 int Bpp;
6379
6480 if ((x >= 0) && (x < bitmap->width) &&
65 (y >= 0) && (y < bitmap->height))
81 (y >= 0) && (y < bitmap->height))
6682 {
6783 bpp = bitmap->format >> 24;
6884 if (bpp < 8)
238254 int x, int y, int pixel, int pixel_format)
239255 {
240256 if ((painter->clip_valid == 0) ||
241 ((x >= painter->clip.x1) && (x < painter->clip.x2) &&
242 (y >= painter->clip.y1) && (y < painter->clip.y2)))
257 ((x >= painter->clip.x1) && (x < painter->clip.x2) &&
258 (y >= painter->clip.y1) && (y < painter->clip.y2)))
243259 {
244260 if ((x >= 0) && (x < bitmap->width) &&
245 (y >= 0) && (y < bitmap->height))
261 (y >= 0) && (y < bitmap->height))
246262 {
247263 pixel = pixel_convert(pixel, pixel_format, bitmap->format,
248264 painter->palette);
1919 #define __PAINTER_UTILS_H
2020
2121 #define SPLIT_a8r8g8b8(_c, _a, _r, _g, _b) \
22 do { \
23 _a = ((_c) & 0xff000000) >> 24; \
24 _r = ((_c) & 0x00ff0000) >> 16; \
25 _g = ((_c) & 0x0000ff00) >> 8; \
26 _b = ((_c) & 0x000000ff) >> 0; \
27 } while (0)
22 do { \
23 _a = ((_c) & 0xff000000) >> 24; \
24 _r = ((_c) & 0x00ff0000) >> 16; \
25 _g = ((_c) & 0x0000ff00) >> 8; \
26 _b = ((_c) & 0x000000ff) >> 0; \
27 } while (0)
2828
2929 #define SPLIT_a8b8g8r8(_c, _a, _r, _g, _b) \
30 do { \
31 _a = ((_c) & 0xff000000) >> 24; \
32 _b = ((_c) & 0x00ff0000) >> 16; \
33 _g = ((_c) & 0x0000ff00) >> 8; \
34 _r = ((_c) & 0x000000ff) >> 0; \
35 } while (0)
30 do { \
31 _a = ((_c) & 0xff000000) >> 24; \
32 _b = ((_c) & 0x00ff0000) >> 16; \
33 _g = ((_c) & 0x0000ff00) >> 8; \
34 _r = ((_c) & 0x000000ff) >> 0; \
35 } while (0)
3636
3737 #define SPLIT_a1r5g5b5(_c, _a, _r, _g, _b) \
38 do { \
39 _a = (((_c) >> 15) & 1) * 0xff; \
40 _r = (((_c) >> 7) & 0xf8) | (((_c) >> 12) & 0x7); \
41 _g = (((_c) >> 2) & 0xf8) | (((_c) >> 8) & 0x7); \
42 _b = (((_c) << 3) & 0xf8) | (((_c) >> 2) & 0x7); \
43 } while (0)
38 do { \
39 _a = (((_c) >> 15) & 1) * 0xff; \
40 _r = (((_c) >> 7) & 0xf8) | (((_c) >> 12) & 0x7); \
41 _g = (((_c) >> 2) & 0xf8) | (((_c) >> 8) & 0x7); \
42 _b = (((_c) << 3) & 0xf8) | (((_c) >> 2) & 0x7); \
43 } while (0)
4444
4545 #define SPLIT_r5g6b5(_c, _a, _r, _g, _b) \
46 do { \
47 _a = 0xff; \
48 _r = (((_c) >> 8) & 0xf8) | (((_c) >> 13) & 0x7); \
49 _g = (((_c) >> 3) & 0xfc) | (((_c) >> 9) & 0x3); \
50 _b = (((_c) << 3) & 0xf8) | (((_c) >> 2) & 0x7); \
51 } while (0)
46 do { \
47 _a = 0xff; \
48 _r = (((_c) >> 8) & 0xf8) | (((_c) >> 13) & 0x7); \
49 _g = (((_c) >> 3) & 0xfc) | (((_c) >> 9) & 0x3); \
50 _b = (((_c) << 3) & 0xf8) | (((_c) >> 2) & 0x7); \
51 } while (0)
5252
5353 #define SPLIT_r3g3b2(_c, _a, _r, _g, _b) \
54 do { \
55 _a = 0xff; \
56 _r = 0; \
57 _g = 0; \
58 _b = 0; \
59 } while (0)
54 do { \
55 _a = 0xff; \
56 _r = 0; \
57 _g = 0; \
58 _b = 0; \
59 } while (0)
6060
6161 #define MAKE_a1r5g5b5(_c, _a, _r, _g, _b) \
62 do { \
63 _c = (((_a) & 0xff) >> 7) << 15 | \
64 (((_r) & 0xff) >> 3) << 10 | \
65 (((_g) & 0xff) >> 3) << 5 | \
66 (((_b) & 0xff) >> 3) << 0; \
67 } while (0)
62 do { \
63 _c = (((_a) & 0xff) >> 7) << 15 | \
64 (((_r) & 0xff) >> 3) << 10 | \
65 (((_g) & 0xff) >> 3) << 5 | \
66 (((_b) & 0xff) >> 3) << 0; \
67 } while (0)
6868
6969 #define MAKE_r5g6b5(_c, _a, _r, _g, _b) \
70 do { \
71 _c = \
72 (((_r) & 0xff) >> 3) << 11 | \
73 (((_g) & 0xff) >> 2) << 5 | \
74 (((_b) & 0xff) >> 3) << 0; \
75 } while (0)
70 do { \
71 _c = \
72 (((_r) & 0xff) >> 3) << 11 | \
73 (((_g) & 0xff) >> 2) << 5 | \
74 (((_b) & 0xff) >> 3) << 0; \
75 } while (0)
7676
7777 #define MAKE_a8r8g8b8(_c, _a, _r, _g, _b) \
78 do { \
79 _c = ((_a) & 0xff) << 24 | \
80 ((_r) & 0xff) << 16 | \
81 ((_g) & 0xff) << 8 | \
82 ((_b) & 0xff) << 0; \
83 } while (0)
78 do { \
79 _c = ((_a) & 0xff) << 24 | \
80 ((_r) & 0xff) << 16 | \
81 ((_g) & 0xff) << 8 | \
82 ((_b) & 0xff) << 0; \
83 } while (0)
8484
8585 #define MAKE_a8b8g8r8(_c, _a, _r, _g, _b) \
86 do { \
87 _c = ((_a) & 0xff) << 24 | \
88 ((_b) & 0xff) << 16 | \
89 ((_g) & 0xff) << 8 | \
90 ((_r) & 0xff) << 0; \
91 } while (0)
86 do { \
87 _c = ((_a) & 0xff) << 24 | \
88 ((_b) & 0xff) << 16 | \
89 ((_g) & 0xff) << 8 | \
90 ((_r) & 0xff) << 0; \
91 } while (0)
9292
9393 struct painter_rect
9494 {
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
179179 unique=`for i in $$list; do \
180180 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
181181 done | $(am__uniquify_input)`
182 ETAGS = etags
183 CTAGS = ctags
184182 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
185183 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
186184 ACLOCAL = @ACLOCAL@
196194 CFLAGS = @CFLAGS@
197195 CPP = @CPP@
198196 CPPFLAGS = @CPPFLAGS@
197 CSCOPE = @CSCOPE@
198 CTAGS = @CTAGS@
199199 CYGPATH_W = @CYGPATH_W@
200200 DEFS = @DEFS@
201201 DEPDIR = @DEPDIR@
206206 ECHO_N = @ECHO_N@
207207 ECHO_T = @ECHO_T@
208208 EGREP = @EGREP@
209 ETAGS = @ETAGS@
209210 EXEEXT = @EXEEXT@
210211 FGREP = @FGREP@
211212 GREP = @GREP@
491492
492493 distclean-tags:
493494 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
494
495495 distdir: $(BUILT_SOURCES)
496496 $(MAKE) $(AM_MAKEFLAGS) distdir-am
497497
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
190190 unique=`for i in $$list; do \
191191 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
192192 done | $(am__uniquify_input)`
193 ETAGS = etags
194 CTAGS = ctags
195 CSCOPE = cscope
196193 DIST_SUBDIRS = $(SUBDIRS)
197194 am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config_ac-h.in \
198195 $(srcdir)/rfxcodec-uninstalled.pc.in $(srcdir)/rfxcodec.pc.in \
254251 CFLAGS = @CFLAGS@
255252 CPP = @CPP@
256253 CPPFLAGS = @CPPFLAGS@
254 CSCOPE = @CSCOPE@
255 CTAGS = @CTAGS@
257256 CYGPATH_W = @CYGPATH_W@
258257 DEFS = @DEFS@
259258 DEPDIR = @DEPDIR@
264263 ECHO_N = @ECHO_N@
265264 ECHO_T = @ECHO_T@
266265 EGREP = @EGREP@
266 ETAGS = @ETAGS@
267267 EXEEXT = @EXEEXT@
268268 FGREP = @FGREP@
269269 GREP = @GREP@
559559 distclean-tags:
560560 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
561561 -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
562
563562 distdir: $(BUILT_SOURCES)
564563 $(MAKE) $(AM_MAKEFLAGS) distdir-am
565564
0 # generated automatically by aclocal 1.16.3 -*- Autoconf -*-
1
2 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
0 # generated automatically by aclocal 1.16.5 -*- Autoconf -*-
1
2 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
33
44 # This file is free software; the Free Software Foundation
55 # gives unlimited permission to copy and/or distribute it,
1919 If you have problems, you may need to regenerate the build system entirely.
2020 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
2121
22 # Copyright (C) 2002-2020 Free Software Foundation, Inc.
22 # Copyright (C) 2002-2021 Free Software Foundation, Inc.
2323 #
2424 # This file is free software; the Free Software Foundation
2525 # gives unlimited permission to copy and/or distribute it,
3434 [am__api_version='1.16'
3535 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
3636 dnl require some minimum version. Point them to the right macro.
37 m4_if([$1], [1.16.3], [],
37 m4_if([$1], [1.16.5], [],
3838 [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
3939 ])
4040
5050 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
5151 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
5252 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
53 [AM_AUTOMAKE_VERSION([1.16.3])dnl
53 [AM_AUTOMAKE_VERSION([1.16.5])dnl
5454 m4_ifndef([AC_AUTOCONF_VERSION],
5555 [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
5656 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
5757
5858 # AM_AUX_DIR_EXPAND -*- Autoconf -*-
5959
60 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
60 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
6161 #
6262 # This file is free software; the Free Software Foundation
6363 # gives unlimited permission to copy and/or distribute it,
107107 am_aux_dir=`cd "$ac_aux_dir" && pwd`
108108 ])
109109
110 # AM_COND_IF -*- Autoconf -*-
111
112 # Copyright (C) 2008-2021 Free Software Foundation, Inc.
113 #
114 # This file is free software; the Free Software Foundation
115 # gives unlimited permission to copy and/or distribute it,
116 # with or without modifications, as long as this notice is preserved.
117
118 # _AM_COND_IF
119 # _AM_COND_ELSE
120 # _AM_COND_ENDIF
121 # --------------
122 # These macros are only used for tracing.
123 m4_define([_AM_COND_IF])
124 m4_define([_AM_COND_ELSE])
125 m4_define([_AM_COND_ENDIF])
126
127 # AM_COND_IF(COND, [IF-TRUE], [IF-FALSE])
128 # ---------------------------------------
129 # If the shell condition COND is true, execute IF-TRUE, otherwise execute
130 # IF-FALSE. Allow automake to learn about conditional instantiating macros
131 # (the AC_CONFIG_FOOS).
132 AC_DEFUN([AM_COND_IF],
133 [m4_ifndef([_AM_COND_VALUE_$1],
134 [m4_fatal([$0: no such condition "$1"])])dnl
135 _AM_COND_IF([$1])dnl
136 if test -z "$$1_TRUE"; then :
137 m4_n([$2])[]dnl
138 m4_ifval([$3],
139 [_AM_COND_ELSE([$1])dnl
140 else
141 $3
142 ])dnl
143 _AM_COND_ENDIF([$1])dnl
144 fi[]dnl
145 ])
146
110147 # AM_CONDITIONAL -*- Autoconf -*-
111148
112 # Copyright (C) 1997-2020 Free Software Foundation, Inc.
149 # Copyright (C) 1997-2021 Free Software Foundation, Inc.
113150 #
114151 # This file is free software; the Free Software Foundation
115152 # gives unlimited permission to copy and/or distribute it,
140177 Usually this means the macro was only invoked conditionally.]])
141178 fi])])
142179
143 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
180 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
144181 #
145182 # This file is free software; the Free Software Foundation
146183 # gives unlimited permission to copy and/or distribute it,
331368
332369 # Generate code to set up dependency tracking. -*- Autoconf -*-
333370
334 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
371 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
335372 #
336373 # This file is free software; the Free Software Foundation
337374 # gives unlimited permission to copy and/or distribute it,
399436
400437 # Do all the work for Automake. -*- Autoconf -*-
401438
402 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
439 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
403440 #
404441 # This file is free software; the Free Software Foundation
405442 # gives unlimited permission to copy and/or distribute it,
427464 # release and drop the old call support.
428465 AC_DEFUN([AM_INIT_AUTOMAKE],
429466 [AC_PREREQ([2.65])dnl
467 m4_ifdef([_$0_ALREADY_INIT],
468 [m4_fatal([$0 expanded multiple times
469 ]m4_defn([_$0_ALREADY_INIT]))],
470 [m4_define([_$0_ALREADY_INIT], m4_expansion_stack)])dnl
430471 dnl Autoconf wants to disallow AM_ names. We explicitly allow
431472 dnl the ones we care about.
432473 m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
463504 [_AM_SET_OPTIONS([$1])dnl
464505 dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
465506 m4_if(
466 m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
507 m4_ifset([AC_PACKAGE_NAME], [ok]):m4_ifset([AC_PACKAGE_VERSION], [ok]),
467508 [ok:ok],,
468509 [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
469510 AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
515556 [m4_define([AC_PROG_OBJCXX],
516557 m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
517558 ])
559 # Variables for tags utilities; see am/tags.am
560 if test -z "$CTAGS"; then
561 CTAGS=ctags
562 fi
563 AC_SUBST([CTAGS])
564 if test -z "$ETAGS"; then
565 ETAGS=etags
566 fi
567 AC_SUBST([ETAGS])
568 if test -z "$CSCOPE"; then
569 CSCOPE=cscope
570 fi
571 AC_SUBST([CSCOPE])
572
518573 AC_REQUIRE([AM_SILENT_RULES])dnl
519574 dnl The testsuite driver may need to know about EXEEXT, so add the
520575 dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
596651 done
597652 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
598653
599 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
654 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
600655 #
601656 # This file is free software; the Free Software Foundation
602657 # gives unlimited permission to copy and/or distribute it,
617672 fi
618673 AC_SUBST([install_sh])])
619674
620 # Copyright (C) 2003-2020 Free Software Foundation, Inc.
675 # Copyright (C) 2003-2021 Free Software Foundation, Inc.
621676 #
622677 # This file is free software; the Free Software Foundation
623678 # gives unlimited permission to copy and/or distribute it,
638693
639694 # Check to see how 'make' treats includes. -*- Autoconf -*-
640695
641 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
696 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
642697 #
643698 # This file is free software; the Free Software Foundation
644699 # gives unlimited permission to copy and/or distribute it,
681736
682737 # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
683738
684 # Copyright (C) 1997-2020 Free Software Foundation, Inc.
739 # Copyright (C) 1997-2021 Free Software Foundation, Inc.
685740 #
686741 # This file is free software; the Free Software Foundation
687742 # gives unlimited permission to copy and/or distribute it,
715770
716771 # Helper functions for option handling. -*- Autoconf -*-
717772
718 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
773 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
719774 #
720775 # This file is free software; the Free Software Foundation
721776 # gives unlimited permission to copy and/or distribute it,
744799 AC_DEFUN([_AM_IF_OPTION],
745800 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
746801
747 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
802 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
748803 #
749804 # This file is free software; the Free Software Foundation
750805 # gives unlimited permission to copy and/or distribute it,
791846 # For backward compatibility.
792847 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
793848
794 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
849 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
795850 #
796851 # This file is free software; the Free Software Foundation
797852 # gives unlimited permission to copy and/or distribute it,
810865
811866 # Check to make sure that the build environment is sane. -*- Autoconf -*-
812867
813 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
868 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
814869 #
815870 # This file is free software; the Free Software Foundation
816871 # gives unlimited permission to copy and/or distribute it,
891946 rm -f conftest.file
892947 ])
893948
894 # Copyright (C) 2009-2020 Free Software Foundation, Inc.
949 # Copyright (C) 2009-2021 Free Software Foundation, Inc.
895950 #
896951 # This file is free software; the Free Software Foundation
897952 # gives unlimited permission to copy and/or distribute it,
9511006 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
9521007 ])
9531008
954 # Copyright (C) 2001-2020 Free Software Foundation, Inc.
1009 # Copyright (C) 2001-2021 Free Software Foundation, Inc.
9551010 #
9561011 # This file is free software; the Free Software Foundation
9571012 # gives unlimited permission to copy and/or distribute it,
9791034 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
9801035 AC_SUBST([INSTALL_STRIP_PROGRAM])])
9811036
982 # Copyright (C) 2006-2020 Free Software Foundation, Inc.
1037 # Copyright (C) 2006-2021 Free Software Foundation, Inc.
9831038 #
9841039 # This file is free software; the Free Software Foundation
9851040 # gives unlimited permission to copy and/or distribute it,
9981053
9991054 # Check how to create a tarball. -*- Autoconf -*-
10001055
1001 # Copyright (C) 2004-2020 Free Software Foundation, Inc.
1056 # Copyright (C) 2004-2021 Free Software Foundation, Inc.
10021057 #
10031058 # This file is free software; the Free Software Foundation
10041059 # gives unlimited permission to copy and/or distribute it,
00 #!/bin/sh
11
2 which autoconf
2 command -v autoconf
33 if ! test $? -eq 0
44 then
55 echo "error, install autoconf"
66 exit 1
77 fi
88
9 which automake
9 command -v automake
1010 if ! test $? -eq 0
1111 then
1212 echo "error, install automake"
1313 exit 1
1414 fi
1515
16 which libtool || which libtoolize
16 command -v libtool || command -v libtoolize
1717 if ! test $? -eq 0
1818 then
1919 echo "error, install libtool"
2020 exit 1
2121 fi
2222
23 which pkg-config
23 command -v pkg-config
2424 if ! test $? -eq 0
2525 then
2626 echo "error, install pkg-config"
22
33 scriptversion=2018-03-07.03; # UTC
44
5 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
5 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
66 # Written by Tom Tromey <tromey@cygnus.com>.
77 #
88 # This program is free software; you can redistribute it and/or modify
634634 am__EXEEXT_TRUE
635635 LTLIBOBJS
636636 LIBOBJS
637 DEVEL_DEBUG_FALSE
638 DEVEL_DEBUG_TRUE
637639 WITH_SIMD_X86_FALSE
638640 WITH_SIMD_X86_TRUE
639641 WITH_SIMD_AMD64_FALSE
692694 AM_DEFAULT_VERBOSITY
693695 AM_DEFAULT_V
694696 AM_V
697 CSCOPE
698 ETAGS
699 CTAGS
695700 am__untar
696701 am__tar
697702 AMTAR
769774 enable_libtool_lock
770775 with_pkgconfigdir
771776 with_simd
777 enable_devel_all
778 enable_devel_debug
772779 '
773780 ac_precious_vars='build_alias
774781 host_alias
14091416 --enable-fast-install[=PKGS]
14101417 optimize for fast installation [default=yes]
14111418 --disable-libtool-lock avoid locking (might break parallel builds)
1419 --enable-devel-all
1420 --enable-devel-debug Build library with support for getting better
1421 backtraces [default=no]
14121422
14131423 Optional Packages:
14141424 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
26892699
26902700
26912701
2702
2703
2704 # Variables for tags utilities; see am/tags.am
2705 if test -z "$CTAGS"; then
2706 CTAGS=ctags
2707 fi
2708
2709 if test -z "$ETAGS"; then
2710 ETAGS=etags
2711 fi
2712
2713 if test -z "$CSCOPE"; then
2714 CSCOPE=cscope
2715 fi
26922716
26932717
26942718
1230212326 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the assembler ($NASM $NAFLAGS) works" >&5
1230312327 $as_echo_n "checking whether the assembler ($NASM $NAFLAGS) works... " >&6; }
1230412328 cat > conftest.asm <<EOF
12305 %line 12306 "configure"
12329 %line 12330 "configure"
1230612330 section .text
1230712331 global _nasmfunc, nasmfunc
1230812332 _nasmfunc:
1252112545 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the assembler ($NASM $NAFLAGS) works" >&5
1252212546 $as_echo_n "checking whether the assembler ($NASM $NAFLAGS) works... " >&6; }
1252312547 cat > conftest.asm <<EOF
12524 %line 12525 "configure"
12548 %line 12549 "configure"
1252512549 section .text
1252612550 global _nasmfunc, nasmfunc
1252712551 _nasmfunc:
1261212636 WITH_SIMD_X86_FALSE=
1261312637 fi
1261412638
12639
12640 # parent project will propagate these options to us when building
12641 # Check whether --enable-devel_all was given.
12642 if test "${enable_devel_all+set}" = set; then :
12643 enableval=$enable_devel_all; devel_all=$enableval
12644 else
12645 devel_all=no
12646 fi
12647
12648 # Check whether --enable-devel_debug was given.
12649 if test "${enable_devel_debug+set}" = set; then :
12650 enableval=$enable_devel_debug; devel_debug=$enableval
12651 else
12652 devel_debug=$devel_all
12653 fi
12654
12655 if test x$devel_debug = xyes ; then
12656 DEVEL_DEBUG_TRUE=
12657 DEVEL_DEBUG_FALSE='#'
12658 else
12659 DEVEL_DEBUG_TRUE='#'
12660 DEVEL_DEBUG_FALSE=
12661 fi
12662
12663
12664 # pass debug option to the assembler if specified
12665 if test -z "$DEVEL_DEBUG_TRUE"; then :
12666
12667
12668
12669
12670 for flag in -DDEBUG; do
12671 as_CACHEVAR=`$as_echo "ax_cv_check_cflags__$flag" | $as_tr_sh`
12672 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts $flag" >&5
12673 $as_echo_n "checking whether C compiler accepts $flag... " >&6; }
12674 if eval \${$as_CACHEVAR+:} false; then :
12675 $as_echo_n "(cached) " >&6
12676 else
12677
12678 ax_check_save_flags=$CFLAGS
12679 CFLAGS="$CFLAGS $flag"
12680 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
12681 /* end confdefs.h. */
12682
12683 int
12684 main ()
12685 {
12686
12687 ;
12688 return 0;
12689 }
12690 _ACEOF
12691 if ac_fn_c_try_compile "$LINENO"; then :
12692 eval "$as_CACHEVAR=yes"
12693 else
12694 eval "$as_CACHEVAR=no"
12695 fi
12696 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
12697 CFLAGS=$ax_check_save_flags
12698 fi
12699 eval ac_res=\$$as_CACHEVAR
12700 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
12701 $as_echo "$ac_res" >&6; }
12702 if eval test \"x\$"$as_CACHEVAR"\" = x"yes"; then :
12703
12704 if ${NAFLAGS+:} false; then :
12705
12706 case " $NAFLAGS " in #(
12707 *" $flag "*) :
12708 { { $as_echo "$as_me:${as_lineno-$LINENO}: : NAFLAGS already contains \$flag"; } >&5
12709 (: NAFLAGS already contains $flag) 2>&5
12710 ac_status=$?
12711 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
12712 test $ac_status = 0; } ;; #(
12713 *) :
12714
12715 as_fn_append NAFLAGS " $flag"
12716 { { $as_echo "$as_me:${as_lineno-$LINENO}: : NAFLAGS=\"\$NAFLAGS\""; } >&5
12717 (: NAFLAGS="$NAFLAGS") 2>&5
12718 ac_status=$?
12719 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
12720 test $ac_status = 0; }
12721 ;;
12722 esac
12723
12724 else
12725
12726 NAFLAGS=$flag
12727 { { $as_echo "$as_me:${as_lineno-$LINENO}: : NAFLAGS=\"\$NAFLAGS\""; } >&5
12728 (: NAFLAGS="$NAFLAGS") 2>&5
12729 ac_status=$?
12730 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
12731 test $ac_status = 0; }
12732
12733 fi
12734
12735 else
12736 :
12737 fi
12738
12739 done
12740
12741 fi
1261512742
1261612743 ac_config_files="$ac_config_files Makefile include/Makefile src/Makefile src/amd64/Makefile src/x86/Makefile tests/Makefile rfxcodec.pc rfxcodec-uninstalled.pc"
1261712744
1275512882 fi
1275612883 if test -z "${WITH_SIMD_X86_TRUE}" && test -z "${WITH_SIMD_X86_FALSE}"; then
1275712884 as_fn_error $? "conditional \"WITH_SIMD_X86\" was never defined.
12885 Usually this means the macro was only invoked conditionally." "$LINENO" 5
12886 fi
12887 if test -z "${DEVEL_DEBUG_TRUE}" && test -z "${DEVEL_DEBUG_FALSE}"; then
12888 as_fn_error $? "conditional \"DEVEL_DEBUG\" was never defined.
1275812889 Usually this means the macro was only invoked conditionally." "$LINENO" 5
1275912890 fi
1276012891
4242 AM_CONDITIONAL(WITH_SIMD_AMD64, [test x$simd_arch = xx86_64])
4343 AM_CONDITIONAL(WITH_SIMD_X86, [test x$simd_arch = xi386])
4444
45 # parent project will propagate these options to us when building
46 AC_ARG_ENABLE(devel_all, AS_HELP_STRING([--enable-devel-all]),
47 [devel_all=$enableval], [devel_all=no])
48 AC_ARG_ENABLE(devel_debug, AS_HELP_STRING([--enable-devel-debug],
49 [Build library with support for getting better backtraces [default=no]]),
50 [devel_debug=$enableval], [devel_debug=$devel_all])
51 AM_CONDITIONAL(DEVEL_DEBUG, [test x$devel_debug = xyes ])
52
53 # pass debug option to the assembler if specified
54 AM_COND_IF([DEVEL_DEBUG],
55 [AX_APPEND_COMPILE_FLAGS([-DDEBUG], [NAFLAGS])])
56
4557 AC_CONFIG_FILES([Makefile
4658 include/Makefile
4759 src/Makefile
22
33 scriptversion=2018-03-07.03; # UTC
44
5 # Copyright (C) 1999-2020 Free Software Foundation, Inc.
5 # Copyright (C) 1999-2021 Free Software Foundation, Inc.
66
77 # This program is free software; you can redistribute it and/or modify
88 # it under the terms of the GNU General Public License as published by
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
171171 unique=`for i in $$list; do \
172172 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
173173 done | $(am__uniquify_input)`
174 ETAGS = etags
175 CTAGS = ctags
176174 am__DIST_COMMON = $(srcdir)/Makefile.in
177175 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
178176 ACLOCAL = @ACLOCAL@
188186 CFLAGS = @CFLAGS@
189187 CPP = @CPP@
190188 CPPFLAGS = @CPPFLAGS@
189 CSCOPE = @CSCOPE@
190 CTAGS = @CTAGS@
191191 CYGPATH_W = @CYGPATH_W@
192192 DEFS = @DEFS@
193193 DEPDIR = @DEPDIR@
198198 ECHO_N = @ECHO_N@
199199 ECHO_T = @ECHO_T@
200200 EGREP = @EGREP@
201 ETAGS = @ETAGS@
201202 EXEEXT = @EXEEXT@
202203 FGREP = @FGREP@
203204 GREP = @GREP@
409410
410411 distclean-tags:
411412 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
412
413413 distdir: $(BUILT_SOURCES)
414414 $(MAKE) $(AM_MAKEFLAGS) distdir-am
415415
22
33 scriptversion=2018-03-07.03; # UTC
44
5 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
5 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
66 # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
77
88 # This program is free software; you can redistribute it and/or modify
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
241241 unique=`for i in $$list; do \
242242 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
243243 done | $(am__uniquify_input)`
244 ETAGS = etags
245 CTAGS = ctags
246244 DIST_SUBDIRS = amd64 x86
247245 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
248246 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
284282 CFLAGS = @CFLAGS@
285283 CPP = @CPP@
286284 CPPFLAGS = @CPPFLAGS@
285 CSCOPE = @CSCOPE@
286 CTAGS = @CTAGS@
287287 CYGPATH_W = @CYGPATH_W@
288288 DEFS = @DEFS@
289289 DEPDIR = @DEPDIR@
294294 ECHO_N = @ECHO_N@
295295 ECHO_T = @ECHO_T@
296296 EGREP = @EGREP@
297 ETAGS = @ETAGS@
297298 EXEEXT = @EXEEXT@
298299 FGREP = @FGREP@
299300 GREP = @GREP@
641642
642643 distclean-tags:
643644 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
644
645645 distdir: $(BUILT_SOURCES)
646646 $(MAKE) $(AM_MAKEFLAGS) distdir-am
647647
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
175175 unique=`for i in $$list; do \
176176 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
177177 done | $(am__uniquify_input)`
178 ETAGS = etags
179 CTAGS = ctags
180178 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
181179 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
182180 ACLOCAL = @ACLOCAL@
192190 CFLAGS = @CFLAGS@
193191 CPP = @CPP@
194192 CPPFLAGS = @CPPFLAGS@
193 CSCOPE = @CSCOPE@
194 CTAGS = @CTAGS@
195195 CYGPATH_W = @CYGPATH_W@
196196 DEFS = @DEFS@
197197 DEPDIR = @DEPDIR@
202202 ECHO_N = @ECHO_N@
203203 ECHO_T = @ECHO_T@
204204 EGREP = @EGREP@
205 ETAGS = @ETAGS@
205206 EXEEXT = @EXEEXT@
206207 FGREP = @FGREP@
207208 GREP = @GREP@
455456
456457 distclean-tags:
457458 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
458
459459 distdir: $(BUILT_SOURCES)
460460 $(MAKE) $(AM_MAKEFLAGS) distdir-am
461461
13241324 movdqa xmm10, [rdx]
13251325 ret
13261326
1327 ;The first six integer or pointer arguments are passed in registers
1328 ;RDI, RSI, RDX, RCX, R8, and R9
1327 ; Per System V AMD64 ABI, the first six integer or pointer arguments are
1328 ; passed in registers RDI, RSI, RDX, RCX, R8, and R9
13291329
13301330 ;int
13311331 ;rfxcodec_encode_dwt_shift_amd64_sse2(const char *qtable,
13351335
13361336 ;******************************************************************************
13371337 PROC rfxcodec_encode_dwt_shift_amd64_sse2
1338 ; prologue. this will make the function appear to the debugger as
1339 ; having a stack frame, so that a backtrace can be obtained
1340 %ifdef DEBUG
1341 push rbp
1342 mov rbp, rsp
1343 %endif
1344
13381345 ; save registers
13391346 push rbx
1340 push rdx
1341 push rcx
1342 push rsi
1343 push rdi
1347 push rdx ; rsp+24: out_buffer
1348 push rcx ; rsp+16: work_buffer
1349 push rsi ; rsp+ 8: in_buffer
1350 push rdi ; rsp+ 0: qtable
13441351 pxor xmm0, xmm0
13451352
13461353 ; verical DWT to work buffer, level 1
14821489 pop rcx
14831490 pop rdx
14841491 pop rbx
1492
1493 ; epilogue
1494 %ifdef DEBUG
1495 mov rsp, rbp
1496 pop rbp
1497 %endif
1498
14851499 ret
14861500 END_OF_FILE
11921192 movdqa xmm10, [rdx]
11931193 ret
11941194
1195 ;The first six integer or pointer arguments are passed in registers
1196 ;RDI, RSI, RDX, RCX, R8, and R9
1195 ; Per System V AMD64 ABI, the first six integer or pointer arguments are
1196 ; passed in registers RDI, RSI, RDX, RCX, R8, and R9
11971197
11981198 ;int
11991199 ;rfxcodec_encode_dwt_shift_amd64_sse41(const char *qtable,
12031203
12041204 ;******************************************************************************
12051205 PROC rfxcodec_encode_dwt_shift_amd64_sse41
1206 ; prologue. this will make the function appear to the debugger as
1207 ; having a stack frame, so that a backtrace can be obtained
1208 %ifdef DEBUG
1209 push rbp
1210 mov rbp, rsp
1211 %endif
1212
12061213 ; save registers
12071214 push rbx
1208 push rdx
1209 push rcx
1210 push rsi
1211 push rdi
1215 push rdx ; rsp+24: out_buffer
1216 push rcx ; rsp+16: work_buffer
1217 push rsi ; rsp+ 8: in_buffer
1218 push rdi ; rsp+ 0: qtable
12121219 pxor xmm0, xmm0
12131220
12141221 ; verical DWT to work buffer, level 1
13501357 pop rcx
13511358 pop rdx
13521359 pop rbx
1360
1361 ; epilogue
1362 %ifdef DEBUG
1363 mov rsp, rbp
1364 pop rbp
1365 %endif
1366
13531367 ret
13541368 END_OF_FILE
313313 const char *quants, int num_quants, int flags)
314314 {
315315 struct rfxencode *enc;
316 int tiles_written;
316317 STREAM s;
317318
318319 enc = (struct rfxencode *) handle;
326327 {
327328 if (rfx_compose_message_header(enc, &s) != 0)
328329 {
329 return 1;
330 }
331 }
332 if (rfx_compose_message_data(enc, &s, regions, num_regions,
333 buf, width, height, stride_bytes,
334 tiles, num_tiles, quants, num_quants,
335 flags) != 0)
336 {
337 return 1;
338 }
330 return -1;
331 }
332 }
333 tiles_written = rfx_compose_message_data(enc, &s, regions, num_regions,
334 buf, width, height, stride_bytes,
335 tiles, num_tiles,
336 quants, num_quants, flags);
339337 *cdata_bytes = (int) (s.p - s.data);
340 return 0;
338 return tiles_written;
341339 }
342340
343341 /******************************************************************************/
398398 int size;
399399 int start_pos;
400400 int end_pos;
401 int tiles_end_checkpoint;
402 int tiles_written;
401403 int index;
402404 int numQuants;
403405 const char *quantVals;
448450 memcpy(s->p, quantVals, numQuants * 5);
449451 s->p += numQuants * 5;
450452 end_pos = stream_get_pos(s);
453 tiles_written = 0;
454 tiles_end_checkpoint = stream_get_pos(s);
455
451456 if (enc->format == RFX_FORMAT_YUV)
452457 {
453458 if (flags & RFX_FLAGS_ALPHAV1)
468473 quantIdxY, quantIdxCb, quantIdxCr,
469474 x / 64, y / 64) != 0)
470475 {
471 return 1;
476 break;
472477 }
478 tiles_end_checkpoint = stream_get_pos(s);
479 tiles_written += 1;
473480 }
474481 }
475482 else
490497 quantIdxY, quantIdxCb, quantIdxCr,
491498 x / 64, y / 64) != 0)
492499 {
493 return 1;
500 break;
494501 }
502 tiles_end_checkpoint = stream_get_pos(s);
503 tiles_written += 1;
495504 }
496505 }
497506 }
515524 quantIdxY, quantIdxCb, quantIdxCr,
516525 x / 64, y / 64) != 0)
517526 {
518 return 1;
527 break;
519528 }
529 tiles_end_checkpoint = stream_get_pos(s);
530 tiles_written += 1;
520531 }
521532 }
522533 else
537548 quantIdxY, quantIdxCb, quantIdxCr,
538549 x / 64, y / 64) != 0)
539550 {
540 return 1;
551 break;
541552 }
553 tiles_end_checkpoint = stream_get_pos(s);
554 tiles_written += 1;
542555 }
543556 }
544557 }
545 tilesDataSize = stream_get_pos(s) - end_pos;
558 tilesDataSize = tiles_end_checkpoint - end_pos;
546559 size += tilesDataSize;
547 end_pos = stream_get_pos(s);
560 end_pos = tiles_end_checkpoint;
548561 stream_set_pos(s, start_pos + 2);
549562 stream_write_uint32(s, size); /* CodecChannelT.blockLen */
563 stream_set_pos(s, start_pos + 16);
564 stream_write_uint16(s, tiles_written);
550565 stream_set_pos(s, start_pos + 18);
551566 stream_write_uint32(s, tilesDataSize);
552567 stream_set_pos(s, end_pos);
553 return 0;
568 return tiles_written;
554569 }
555570
556571 /******************************************************************************/
577592 const struct rfx_tile *tiles, int num_tiles,
578593 const char *quants, int num_quants, int flags)
579594 {
595 int tiles_written;
580596 if (rfx_compose_message_frame_begin(enc, s) != 0)
581597 {
582 return 1;
598 return -1;
583599 }
584600 if (rfx_compose_message_region(enc, s, regions, num_regions) != 0)
585601 {
586 return 1;
587 }
588 if (rfx_compose_message_tileset(enc, s, buf, width, height, stride_bytes,
589 tiles, num_tiles, quants, num_quants,
590 flags) != 0)
591 {
592 return 1;
593 }
602 return -1;
603 }
604 tiles_written = rfx_compose_message_tileset(enc, s, buf, width, height, stride_bytes,
605 tiles, num_tiles, quants, num_quants, flags);
594606 if (rfx_compose_message_frame_end(enc, s) != 0)
595607 {
596 return 1;
597 }
598 return 0;
599 }
608 return -1;
609 }
610 return tiles_written;
611 }
5050 #define LLOGLN(_level, _args) \
5151 do { if (_level < LLOG_LEVEL) { printf _args ; printf("\n"); } } while (0)
5252
53 /**
54 * In order not to overflow the output buffer, we need to have an
55 * upper limit on the size of a tile which could possibly be written to
56 * the buffer.
57 *
58 * The tile data structure (TS_RFX_TILE) is defined in [MS-RDPRFX]
59 * 2.2.2.3.4.1
60 *
61 * We make the conservative assumption that the RLGR1/RLGL3 algorithm
62 * worst case results in a doubling of the YCbCr data for each pixel.
63 * This is likely to be far higher than necessary.
64 */
65 #define RLGR_WORST_CASE_SIZE_FACTOR 2
66 #define TILE_SIZE_UPPER_LIMIT (6 + 1 + 1 + 1 + 2 + 2 + 2 + 2 + 2 + \
67 (64 * 64) * 3 * RLGR_WORST_CASE_SIZE_FACTOR)
68
69
5370 /******************************************************************************/
5471 int
5572 rfx_encode_component_rlgr1(struct rfxencode *enc, const char *qtable,
94111 }
95112 *size = rfx_rlgr3_encode(enc->dwt_buffer1, buffer, buffer_size);
96113 return 0;
114 }
115
116 /******************************************************************************/
117 static int
118 check_and_rfx_encode(struct rfxencode *enc, const char *qtable,
119 const uint8 *data,
120 uint8 *buffer, int buffer_size, int *size)
121 {
122 if (buffer_size < TILE_SIZE_UPPER_LIMIT)
123 {
124 return 1;
125 }
126 return enc->rfx_encode(enc, qtable, data, buffer, buffer_size, size);
97127 }
98128
99129 /******************************************************************************/
117147 y_r_buffer = enc->y_r_buffer;
118148 u_g_buffer = enc->u_g_buffer;
119149 v_b_buffer = enc->v_b_buffer;
120 if (enc->rfx_encode(enc, y_quants, y_r_buffer,
121 stream_get_tail(data_out),
122 stream_get_left(data_out),
123 y_size) != 0)
150 if (check_and_rfx_encode(enc, y_quants, y_r_buffer,
151 stream_get_tail(data_out),
152 stream_get_left(data_out),
153 y_size) != 0)
124154 {
125155 return 1;
126156 }
127157 LLOGLN(10, ("rfx_encode_rgb: y_size %d", *y_size));
128158 stream_seek(data_out, *y_size);
129 if (enc->rfx_encode(enc, u_quants, u_g_buffer,
130 stream_get_tail(data_out),
131 stream_get_left(data_out),
132 u_size) != 0)
159 if (check_and_rfx_encode(enc, u_quants, u_g_buffer,
160 stream_get_tail(data_out),
161 stream_get_left(data_out),
162 u_size) != 0)
133163 {
134164 return 1;
135165 }
136166 LLOGLN(10, ("rfx_encode_rgb: u_size %d", *u_size));
137167 stream_seek(data_out, *u_size);
138 if (enc->rfx_encode(enc, v_quants, v_b_buffer,
139 stream_get_tail(data_out),
140 stream_get_left(data_out),
141 v_size) != 0)
168 if (check_and_rfx_encode(enc, v_quants, v_b_buffer,
169 stream_get_tail(data_out),
170 stream_get_left(data_out),
171 v_size) != 0)
142172 {
143173 return 1;
144174 }
171201 y_r_buffer = enc->y_r_buffer;
172202 u_g_buffer = enc->u_g_buffer;
173203 v_b_buffer = enc->v_b_buffer;
174 if (enc->rfx_encode(enc, y_quants, y_r_buffer,
175 stream_get_tail(data_out),
176 stream_get_left(data_out),
177 y_size) != 0)
204 if (check_and_rfx_encode(enc, y_quants, y_r_buffer,
205 stream_get_tail(data_out),
206 stream_get_left(data_out),
207 y_size) != 0)
178208 {
179209 return 1;
180210 }
181211 LLOGLN(10, ("rfx_encode_rgb: y_size %d", *y_size));
182212 stream_seek(data_out, *y_size);
183 if (enc->rfx_encode(enc, u_quants, u_g_buffer,
184 stream_get_tail(data_out),
185 stream_get_left(data_out),
186 u_size) != 0)
213 if (check_and_rfx_encode(enc, u_quants, u_g_buffer,
214 stream_get_tail(data_out),
215 stream_get_left(data_out),
216 u_size) != 0)
187217 {
188218 return 1;
189219 }
190220 LLOGLN(10, ("rfx_encode_rgb: u_size %d", *u_size));
191221 stream_seek(data_out, *u_size);
192 if (enc->rfx_encode(enc, v_quants, v_b_buffer,
193 stream_get_tail(data_out),
194 stream_get_left(data_out),
195 v_size) != 0)
222 if (check_and_rfx_encode(enc, v_quants, v_b_buffer,
223 stream_get_tail(data_out),
224 stream_get_left(data_out),
225 v_size) != 0)
196226 {
197227 return 1;
198228 }
217247 y_buffer = (const uint8 *) yuv_data;
218248 u_buffer = (const uint8 *) (yuv_data + RFX_YUV_BTES);
219249 v_buffer = (const uint8 *) (yuv_data + RFX_YUV_BTES * 2);
220 if (enc->rfx_encode(enc, y_quants, y_buffer,
221 stream_get_tail(data_out),
222 stream_get_left(data_out),
223 y_size) != 0)
250 if (check_and_rfx_encode(enc, y_quants, y_buffer,
251 stream_get_tail(data_out),
252 stream_get_left(data_out),
253 y_size) != 0)
224254 {
225255 return 1;
226256 }
227257 stream_seek(data_out, *y_size);
228 if (enc->rfx_encode(enc, u_quants, u_buffer,
229 stream_get_tail(data_out),
230 stream_get_left(data_out),
231 u_size) != 0)
258 if (check_and_rfx_encode(enc, u_quants, u_buffer,
259 stream_get_tail(data_out),
260 stream_get_left(data_out),
261 u_size) != 0)
232262 {
233263 return 1;
234264 }
235265 stream_seek(data_out, *u_size);
236 if (enc->rfx_encode(enc, v_quants, v_buffer,
237 stream_get_tail(data_out),
238 stream_get_left(data_out),
239 v_size) != 0)
266 if (check_and_rfx_encode(enc, v_quants, v_buffer,
267 stream_get_tail(data_out),
268 stream_get_left(data_out),
269 v_size) != 0)
240270 {
241271 return 1;
242272 }
262292 u_buffer = (const uint8 *) (yuva_data + RFX_YUV_BTES);
263293 v_buffer = (const uint8 *) (yuva_data + RFX_YUV_BTES * 2);
264294 a_buffer = (const uint8 *) (yuva_data + RFX_YUV_BTES * 3);
265 if (enc->rfx_encode(enc, y_quants, y_buffer,
266 stream_get_tail(data_out),
267 stream_get_left(data_out),
268 y_size) != 0)
295 if (check_and_rfx_encode(enc, y_quants, y_buffer,
296 stream_get_tail(data_out),
297 stream_get_left(data_out),
298 y_size) != 0)
269299 {
270300 return 1;
271301 }
272302 stream_seek(data_out, *y_size);
273 if (enc->rfx_encode(enc, u_quants, u_buffer,
274 stream_get_tail(data_out),
275 stream_get_left(data_out),
276 u_size) != 0)
303 if (check_and_rfx_encode(enc, u_quants, u_buffer,
304 stream_get_tail(data_out),
305 stream_get_left(data_out),
306 u_size) != 0)
277307 {
278308 return 1;
279309 }
280310 stream_seek(data_out, *u_size);
281 if (enc->rfx_encode(enc, v_quants, v_buffer,
282 stream_get_tail(data_out),
283 stream_get_left(data_out),
284 v_size) != 0)
311 if (check_and_rfx_encode(enc, v_quants, v_buffer,
312 stream_get_tail(data_out),
313 stream_get_left(data_out),
314 v_size) != 0)
285315 {
286316 return 1;
287317 }
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
175175 unique=`for i in $$list; do \
176176 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
177177 done | $(am__uniquify_input)`
178 ETAGS = etags
179 CTAGS = ctags
180178 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
181179 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
182180 ACLOCAL = @ACLOCAL@
192190 CFLAGS = @CFLAGS@
193191 CPP = @CPP@
194192 CPPFLAGS = @CPPFLAGS@
193 CSCOPE = @CSCOPE@
194 CTAGS = @CTAGS@
195195 CYGPATH_W = @CYGPATH_W@
196196 DEFS = @DEFS@
197197 DEPDIR = @DEPDIR@
202202 ECHO_N = @ECHO_N@
203203 ECHO_T = @ECHO_T@
204204 EGREP = @EGREP@
205 ETAGS = @ETAGS@
205206 EXEEXT = @EXEEXT@
206207 FGREP = @FGREP@
207208 GREP = @GREP@
455456
456457 distclean-tags:
457458 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
458
459459 distdir: $(BUILT_SOURCES)
460460 $(MAKE) $(AM_MAKEFLAGS) distdir-am
461461
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
175175 unique=`for i in $$list; do \
176176 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
177177 done | $(am__uniquify_input)`
178 ETAGS = etags
179 CTAGS = ctags
180178 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
181179 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
182180 ACLOCAL = @ACLOCAL@
192190 CFLAGS = @CFLAGS@
193191 CPP = @CPP@
194192 CPPFLAGS = @CPPFLAGS@
193 CSCOPE = @CSCOPE@
194 CTAGS = @CTAGS@
195195 CYGPATH_W = @CYGPATH_W@
196196 DEFS = @DEFS@
197197 DEPDIR = @DEPDIR@
202202 ECHO_N = @ECHO_N@
203203 ECHO_T = @ECHO_T@
204204 EGREP = @EGREP@
205 ETAGS = @ETAGS@
205206 EXEEXT = @EXEEXT@
206207 FGREP = @FGREP@
207208 GREP = @GREP@
453454
454455 distclean-tags:
455456 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
456
457457 distdir: $(BUILT_SOURCES)
458458 $(MAKE) $(AM_MAKEFLAGS) distdir-am
459459
124124 error = rfxcodec_encode_ex(han, cdata, &cdata_bytes, buf, 64, 64, 64 * 4,
125125 regions, num_regions, tiles, num_tiles,
126126 quants, num_quants, flags);
127 if (error != 0)
127 if (error < num_tiles)
128128 {
129129 break;
130130 }
294294 error = rfxcodec_encode_ex(han, cdata, cdata_bytes, data, width, height, width * 4,
295295 regions, num_regions, tiles, num_tiles,
296296 quants, num_quants, 0);
297 if (error != 0)
297 if (error < num_tiles)
298298 {
299299 printf("encode_file: rfxcodec_encode failed error %d\n", error);
300300 return 1;
247247 error = rfxcodec_encode(han, out_data, &out_bytes, bmp_data,
248248 width, height, width * 4,
249249 &region, 1, tiles, num_tiles, NULL, 0);
250 if (error != 0)
250 if (error < num_tiles)
251251 {
252252 break;
253253 }
4444 xrdp_bitmap_compress.c \
4545 xrdp_caps.c \
4646 xrdp_channel.c \
47 xrdp_channel.h \
4748 xrdp_fastpath.c \
4849 xrdp_iso.c \
4950 xrdp_jpeg_compress.c \
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
226226 unique=`for i in $$list; do \
227227 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
228228 done | $(am__uniquify_input)`
229 ETAGS = etags
230 CTAGS = ctags
231229 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
232230 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
233231 ACLOCAL = @ACLOCAL@
245243 CHECK_LIBS = @CHECK_LIBS@
246244 CPP = @CPP@
247245 CPPFLAGS = @CPPFLAGS@
246 CSCOPE = @CSCOPE@
247 CTAGS = @CTAGS@
248248 CYGPATH_W = @CYGPATH_W@
249249 DEFS = @DEFS@
250250 DEPDIR = @DEPDIR@
256256 ECHO_N = @ECHO_N@
257257 ECHO_T = @ECHO_T@
258258 EGREP = @EGREP@
259 ETAGS = @ETAGS@
259260 EXEEXT = @EXEEXT@
260261 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
261262 FDKAAC_LIBS = @FDKAAC_LIBS@
265266 FUSE_CFLAGS = @FUSE_CFLAGS@
266267 FUSE_LIBS = @FUSE_LIBS@
267268 GREP = @GREP@
269 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
270 IMLIB2_LIBS = @IMLIB2_LIBS@
268271 INSTALL = @INSTALL@
269272 INSTALL_DATA = @INSTALL_DATA@
270273 INSTALL_PROGRAM = @INSTALL_PROGRAM@
398401 xrdp_bitmap_compress.c \
399402 xrdp_caps.c \
400403 xrdp_channel.c \
404 xrdp_channel.h \
401405 xrdp_fastpath.c \
402406 xrdp_iso.c \
403407 xrdp_jpeg_compress.c \
590594
591595 distclean-tags:
592596 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
593
594597 distdir: $(BUILT_SOURCES)
595598 $(MAKE) $(AM_MAKEFLAGS) distdir-am
596599
16721672 s->sec_hdr = s->data;
16731673 s->rdp_hdr = s->sec_hdr + sec_bytes;
16741674 s->end = data_pad + pad_bytes + data_bytes;
1675 s->size = s->end - s->data;
16751676 s->p = s->data + (rdp_bytes + sec_bytes);
16761677 /* TS_SURFCMD_STREAM_SURF_BITS */
16771678 out_uint16_le(s, CMDTYPE_STREAM_SURFACE_BITS);
2222 #include <config_ac.h>
2323 #endif
2424
25 #include <limits.h>
26
2527 #include "libxrdp.h"
2628 #include "ms-rdpbcgr.h"
2729 #include "ms-rdperp.h"
30
31 /**
32 * The largest supported size for a fastpath update
33 * (TS_MULTIFRAGMENTUPDATE_CAPABILITYSET) we advertise to the client. This
34 * size is big enough for the tiles required for two 3840x2160 monitors
35 * without using multiple update PDUS.
36 *
37 * Consult calculate_multifragmentupdate_len() below before changing this
38 * value.
39 */
40 #define MAX_MULTIFRAGMENTUPDATE_SIZE (2U * (3840 * 2160) * 16384 + 16384)
2841
2942 /*****************************************************************************/
3043 static int
843856 LOG_DEVEL(LOG_LEVEL_TRACE, "Completed processing received [MS-RDPBCGR] TS_CONFIRM_ACTIVE_PDU");
844857 return 0;
845858 }
859
860 /**************************************************************************//**
861 * Calculate the multifragmentupdate len we advertised to the client
862 * for fastpath updates
863 *
864 * See [MS-RDPBCGR] 2.2.7.2.6
865 *
866 * The basic logic is taken from freerdp 2.4. We try to use the highest
867 * useful request size that will allow us to pack a complete screen
868 * update into a single fast path PDU using any of the supported codecs.
869 * For RemoteFX, the client MUST use at least this value
870 *
871 * A backstop on the maximum advertised size is implemented to prevent
872 * extreme memory usage for large screen configurations. RDP supports a
873 * maximum desktop size of 32768x32768, which would cause overflow for
874 * 32-bit integers using a simple calculation.
875 *
876 * The codecs have to deal with the value returned by the client after
877 * we advertise our own value, and must not assume a complete update
878 * will fit in a single PDU
879 */
880 static
881 unsigned int calculate_multifragmentupdate_len(const struct xrdp_rdp *self)
882 {
883 unsigned int result = MAX_MULTIFRAGMENTUPDATE_SIZE;
884
885 unsigned int x_tiles = (self->client_info.width + 63) / 64;
886 unsigned int y_tiles = (self->client_info.height + 63) / 64;
887
888 /* Check for overflow on calculation if bad parameters are supplied */
889 if ((x_tiles * y_tiles + 1) < (UINT_MAX / 16384))
890 {
891 result = x_tiles * y_tiles * 16384;
892 /* and add room for headers, regions, frame markers, etc. */
893 result += 16384;
894 }
895
896 return result;
897 }
898
846899 /*****************************************************************************/
847900 int
848901 xrdp_caps_send_demand_active(struct xrdp_rdp *self)
11361189
11371190 if (self->client_info.use_fast_path & FASTPATH_OUTPUT_SUPPORTED) /* fastpath output on */
11381191 {
1139 /* multifragment update */
1192 unsigned int max_request_size = calculate_multifragmentupdate_len(self);
11401193 caps_count++;
11411194 out_uint16_le(s, CAPSSETTYPE_MULTIFRAGMENTUPDATE);
11421195 out_uint16_le(s, CAPSSETTYPE_MULTIFRAGMENTUPDATE_LEN);
1143 out_uint32_le(s, 3 * 1024 * 1024); /* 3MB */
1196 out_uint32_le(s, max_request_size);
11441197 LOG_DEVEL(LOG_LEVEL_TRACE, "xrdp_caps_send_demand_active: Server Capability "
1145 "CAPSSETTYPE_MULTIFRAGMENTUPDATE = 3MB");
1198 "CAPSSETTYPE_MULTIFRAGMENTUPDATE = %d", max_request_size);
11461199
11471200 /* frame acks */
11481201 caps_count++;
2323
2424 #include "libxrdp.h"
2525 #include "string_calls.h"
26 #include "xrdp_channel.h"
2627
2728 #define CMD_DVC_OPEN_CHANNEL 0x10
2829 #define CMD_DVC_DATA_FIRST 0x20
2930 #define CMD_DVC_DATA 0x30
3031 #define CMD_DVC_CLOSE_CHANNEL 0x40
3132 #define CMD_DVC_CAPABILITY 0x50
32
33 #define XRDP_DRDYNVC_STATUS_CLOSED 0
34 #define XRDP_DRDYNVC_STATUS_OPEN_SENT 1
35 #define XRDP_DRDYNVC_STATUS_OPEN 2
36 #define XRDP_DRDYNVC_STATUS_CLOSE_SENT 3
37
38 #define XRDP_DRDYNVC_STATUS_TO_STR(status) \
39 ((status) == XRDP_DRDYNVC_STATUS_CLOSED ? "CLOSED" : \
40 (status) == XRDP_DRDYNVC_STATUS_OPEN_SENT ? "OPEN_SENT" : \
41 (status) == XRDP_DRDYNVC_STATUS_OPEN ? "OPEN" : \
42 (status) == XRDP_DRDYNVC_STATUS_CLOSE_SENT ? "CLOSE_SENT" : \
43 "unknown" \
44 )
4533
4634 #define XRDP_DRDYNVC_CHANNEL_ID_TO_NAME(self, chan_id) \
4735 (xrdp_channel_get_item((self), (chan_id)) != NULL \
934922
935923 LOG_DEVEL(LOG_LEVEL_TRACE, "Sending [MS-RDPEDYC] DYNVC_CLOSE "
936924 "cbId %d, Sp 0, Cmd 0x%2.2x, ChannelId %d",
937 cbChId, CMD_DVC_OPEN_CHANNEL, ChId);
925 cbChId, CMD_DVC_CLOSE_CHANNEL, ChId);
938926 if (xrdp_channel_send(self, s, static_channel_id, total_data_len,
939927 static_flags) != 0)
940928 {
0 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * MS-RDPEDYC : Definitions related to documentation in [MS-RDPEDYC]
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * References to MS-RDPEDYC are currently correct for v20210406 of that
18 * document
19 */
20
21 #if !defined(XRDP_CHANNEL_H)
22 #define XRDP_CHANNEL_H
23
24 /*
25 These are not directly defined in MS-RDPEDYC, but
26 they are derived statuses needed to implement it.
27 */
28 #define XRDP_DRDYNVC_STATUS_CLOSED 0
29 #define XRDP_DRDYNVC_STATUS_OPEN_SENT 1
30 #define XRDP_DRDYNVC_STATUS_OPEN 2
31 #define XRDP_DRDYNVC_STATUS_CLOSE_SENT 3
32
33 #define XRDP_DRDYNVC_STATUS_TO_STR(status) \
34 ((status) == XRDP_DRDYNVC_STATUS_CLOSED ? "CLOSED" : \
35 (status) == XRDP_DRDYNVC_STATUS_OPEN_SENT ? "OPEN_SENT" : \
36 (status) == XRDP_DRDYNVC_STATUS_OPEN ? "OPEN" : \
37 (status) == XRDP_DRDYNVC_STATUS_CLOSE_SENT ? "CLOSE_SENT" : \
38 "unknown" \
39 )
40
41 #endif /* XRDP_CHANNEL_H */
2929
3030 #include "libxrdp.h"
3131 #include "ms-rdpbcgr.h"
32 #include "string_calls.h"
3233 #include "log.h"
3334
3435
35
36 /*****************************************************************************/
37 /**
38 * Converts a protocol mask ([MS-RDPBCGR] 2.2.1.1.1 to a string)
39 *
40 * @param protocol Protocol mask
41 * @param buff Output buffer
42 * @param bufflen total length of buff
43 * @return As for snprintf()
44 *
45 * The string "RDP" is always added to the output, even if other bits
46 * are set
47 */
48 static int
49 protocol_mask_to_str(int protocol, char *buff, int bufflen)
50 {
51 char delim = '|';
52
53 static const struct bitmask_string bits[] =
54 {
55 { PROTOCOL_SSL, "SSL" },
56 { PROTOCOL_HYBRID, "HYBRID" },
57 { PROTOCOL_RDSTLS, "RDSTLS" },
58 { PROTOCOL_HYBRID_EX, "HYBRID_EX"},
59 BITMASK_STRING_END_OF_LIST
60 };
61
62 int rlen = g_bitmask_to_str(protocol, bits, delim, buff, bufflen);
63
64 /* Append "RDP" */
65 if (rlen == 0)
66 {
67 /* String is empty */
68 rlen = g_snprintf(buff, bufflen, "RDP");
69 }
70 else if (rlen < bufflen)
71 {
72 rlen += g_snprintf(buff + rlen, bufflen - rlen, "%cRDP", delim);
73 }
74
75 return rlen;
76 }
3677
3778 /*****************************************************************************/
3879 struct xrdp_iso *
63104 static int
64105 xrdp_iso_negotiate_security(struct xrdp_iso *self)
65106 {
107 char requested_str[64];
108 const char *selected_str = "";
109 const char *configured_str = "";
110
66111 int rv = 0;
67112 struct xrdp_client_info *client_info = &(self->mcs_layer->sec_layer->rdp_layer->client_info);
68113
69 self->selectedProtocol = client_info->security_layer;
70
114 /* Can we do TLS/SSL? (basic check) */
115 int ssl_capable = g_file_readable(client_info->certificate) &&
116 g_file_readable(client_info->key_file);
117
118 /* Work out what's actually configured in xrdp.ini. The
119 * selection happens later, but we can do some error checking here */
71120 switch (client_info->security_layer)
72121 {
73122 case PROTOCOL_RDP:
123 configured_str = "RDP";
74124 break;
125
75126 case PROTOCOL_SSL:
76 if (self->requestedProtocol & PROTOCOL_SSL)
127 /* We *must* use TLS. Check we can offer it, and it's requested */
128 if (ssl_capable)
77129 {
78 if (!g_file_readable(client_info->certificate) ||
79 !g_file_readable(client_info->key_file))
130 configured_str = "SSL";
131 if ((self->requestedProtocol & PROTOCOL_SSL) == 0)
80132 {
81 /* certificate or privkey is not readable */
82 LOG(LOG_LEVEL_ERROR, "Cannot accept TLS connections because "
83 "certificate or private key file is not readable. "
84 "certificate file: [%s], private key file: [%s]",
85 client_info->certificate, client_info->key_file);
86 self->failureCode = SSL_CERT_NOT_ON_SERVER;
133 LOG(LOG_LEVEL_ERROR, "Server requires TLS for security, "
134 "but the client did not request TLS.");
135 self->failureCode = SSL_REQUIRED_BY_SERVER;
87136 rv = 1; /* error */
88 }
89 else
90 {
91 self->selectedProtocol = PROTOCOL_SSL;
92137 }
93138 }
94139 else
95140 {
96 LOG(LOG_LEVEL_ERROR, "Server requires TLS for security, "
97 "but the client did not request TLS.");
98 self->failureCode = SSL_REQUIRED_BY_SERVER;
141 configured_str = "";
142 LOG(LOG_LEVEL_ERROR, "Cannot accept TLS connections because "
143 "certificate or private key file is not readable. "
144 "certificate file: [%s], private key file: [%s]",
145 client_info->certificate, client_info->key_file);
146 self->failureCode = SSL_CERT_NOT_ON_SERVER;
99147 rv = 1; /* error */
100148 }
101149 break;
102150 case PROTOCOL_HYBRID:
103151 case PROTOCOL_HYBRID_EX:
104152 default:
105 if ((self->requestedProtocol & PROTOCOL_SSL) &&
106 g_file_readable(client_info->certificate) &&
107 g_file_readable(client_info->key_file))
153 /* We don't yet support CredSSP */
154 if (ssl_capable)
108155 {
109 /* that's a patch since we don't support CredSSP for now */
110 self->selectedProtocol = PROTOCOL_SSL;
156 configured_str = "SSL|RDP";
111157 }
112158 else
113159 {
114 self->selectedProtocol = PROTOCOL_RDP;
160 /*
161 * Tell the user we can't offer TLS, but this isn't fatal */
162 configured_str = "RDP";
163 LOG(LOG_LEVEL_WARNING, "Cannot accept TLS connections because "
164 "certificate or private key file is not readable. "
165 "certificate file: [%s], private key file: [%s]",
166 client_info->certificate, client_info->key_file);
115167 }
116168 break;
117169 }
118170
119 LOG(LOG_LEVEL_DEBUG, "Security layer: requested %d, selected %d",
120 self->requestedProtocol, self->selectedProtocol);
171 /* Currently the choice comes down to RDP or SSL */
172 if (rv != 0)
173 {
174 self->selectedProtocol = PROTOCOL_RDP;
175 selected_str = "";
176 }
177 else if (ssl_capable && (self->requestedProtocol &
178 client_info->security_layer &
179 PROTOCOL_SSL) != 0)
180 {
181 self->selectedProtocol = PROTOCOL_SSL;
182 selected_str = "SSL";
183 }
184 else
185 {
186 self->selectedProtocol = PROTOCOL_RDP;
187 selected_str = "RDP";
188 }
189
190 protocol_mask_to_str(self->requestedProtocol,
191 requested_str, sizeof(requested_str));
192
193 LOG(LOG_LEVEL_INFO, "Security protocol: configured [%s], requested [%s],"
194 " selected [%s]",
195 configured_str, requested_str, selected_str);
196
121197 return rv;
122198 }
123199
351427 out_uint16_le(s, 8); /* length (must be 8) */
352428 out_uint32_le(s, self->selectedProtocol); /* selectedProtocol */
353429 LOG_DEVEL(LOG_LEVEL_TRACE, "Adding structure [MS-RDPBCGR] RDP_NEG_RSP "
354 "flags 0, length 8, selectedProtocol 0x%8.8x",
430 "flags 0x%02x, length 8, selectedProtocol 0x%8.8x",
431 EXTENDED_CLIENT_DATA_SUPPORTED,
355432 self->selectedProtocol);
356433 }
357434 }
377377 self->client_info.cache3_entries = 262;
378378 self->client_info.cache3_size = 4096;
379379 /* load client ip info */
380 bytes = sizeof(self->client_info.client_ip) - 1;
381 g_write_ip_address(trans->sck, self->client_info.client_ip, bytes);
380 bytes = sizeof(self->client_info.connection_description) - 1;
381 g_write_connection_description(trans->sck,
382 self->client_info.connection_description,
383 bytes);
382384 self->mppc_enc = mppc_enc_new(PROTO_RDP_50);
383385 #if defined(XRDP_NEUTRINORDP)
384386 self->rfx_enc = rfx_context_new();
813815 updateHeader = (updateCode & 15) |
814816 ((fragmentation & 3) << 4) |
815817 ((compression & 3) << 6);
818
819 send_s.end = send_s.p + send_len;
820 send_s.size = send_s.end - send_s.data;
816821 out_uint8(&send_s, updateHeader);
817822 if (compression != 0)
818823 {
821826 }
822827 send_len -= header_bytes;
823828 out_uint16_le(&send_s, send_len);
824 send_s.end = send_s.p + send_len;
825829 LOG_DEVEL(LOG_LEVEL_TRACE, "Adding header [MS-RDPBCGR] TS_FP_UPDATE "
826830 "updateCode %d, fragmentation %d, compression %d, compressionFlags %s, size %d",
827831 updateCode, fragmentation, compression,
937941 /* log non-TLS connections */
938942 else
939943 {
944 int crypt_level = self->sec_layer->crypt_level;
945 const char *security_level =
946 (crypt_level == CRYPT_LEVEL_NONE) ? "none" :
947 (crypt_level == CRYPT_LEVEL_LOW) ? "low" :
948 (crypt_level == CRYPT_LEVEL_CLIENT_COMPATIBLE) ? "medium" :
949 (crypt_level == CRYPT_LEVEL_HIGH) ? "high" :
950 (crypt_level == CRYPT_LEVEL_FIPS) ? "fips" :
951 /* default */ "unknown";
952
940953 LOG(LOG_LEVEL_INFO,
941954 "Non-TLS connection established from %s port %s: "
942 "encrypted with standard RDP security",
955 "with security level : %s",
943956 self->client_info.client_addr,
944 self->client_info.client_port);
957 self->client_info.client_port,
958 security_level);
945959 }
946960
947961 return 0;
23292329 /*****************************************************************************/
23302330 /* Process a [MS-RDPBCGR] TS_UD_CS_MONITOR message.
23312331 reads the client monitors data */
2332 static int
2332 int
23332333 xrdp_sec_process_mcs_data_monitors(struct xrdp_sec *self, struct stream *s)
23342334 {
23352335 int index;
23732373 LOG(LOG_LEVEL_ERROR,
23742374 "[MS-RDPBCGR] Protocol error: TS_UD_CS_MONITOR monitorCount "
23752375 "MUST be less than 16, received: %d", monitorCount);
2376 return 1;
2376 return 2;
23772377 }
23782378
23792379 client_info->monitorCount = monitorCount;
24672467 "Allowed height range: min %d, max %d. Height received: %d",
24682468 0xC8, 0x7FFE, client_info->width,
24692469 0xC8, 0x7FFE, client_info->height);
2470 return 1; /* error */
2470 return 3; /* error */
24712471 }
24722472
24732473 /* keep a copy of non negative monitor info values for xrdp_wm usage */
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
205205 unique=`for i in $$list; do \
206206 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
207207 done | $(am__uniquify_input)`
208 ETAGS = etags
209 CTAGS = ctags
210208 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
211209 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
212210 ACLOCAL = @ACLOCAL@
224222 CHECK_LIBS = @CHECK_LIBS@
225223 CPP = @CPP@
226224 CPPFLAGS = @CPPFLAGS@
225 CSCOPE = @CSCOPE@
226 CTAGS = @CTAGS@
227227 CYGPATH_W = @CYGPATH_W@
228228 DEFS = @DEFS@
229229 DEPDIR = @DEPDIR@
235235 ECHO_N = @ECHO_N@
236236 ECHO_T = @ECHO_T@
237237 EGREP = @EGREP@
238 ETAGS = @ETAGS@
238239 EXEEXT = @EXEEXT@
239240 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
240241 FDKAAC_LIBS = @FDKAAC_LIBS@
244245 FUSE_CFLAGS = @FUSE_CFLAGS@
245246 FUSE_LIBS = @FUSE_LIBS@
246247 GREP = @GREP@
248 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
249 IMLIB2_LIBS = @IMLIB2_LIBS@
247250 INSTALL = @INSTALL@
248251 INSTALL_DATA = @INSTALL_DATA@
249252 INSTALL_PROGRAM = @INSTALL_PROGRAM@
536539
537540 distclean-tags:
538541 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
539
540542 distdir: $(BUILT_SOURCES)
541543 $(MAKE) $(AM_MAKEFLAGS) distdir-am
542544
7878 int box_right, int box_bottom,
7979 int x, int y, char *data, int data_len);
8080 int (*server_reset)(struct mod *v, int width, int height, int bpp);
81 int (*server_get_channel_count)(struct mod *v);
8182 int (*server_query_channel)(struct mod *v, int index,
8283 char *channel_name,
8384 int *channel_flags);
8788 int total_data_len, int flags);
8889 int (*server_bell_trigger)(struct mod *v);
8990 int (*server_chansrv_in_use)(struct mod *v);
90 tintptr server_dumby[100 - 26]; /* align, 100 minus the number of server
91 tintptr server_dumby[100 - 27]; /* align, 100 minus the number of server
9192 functions above */
9293 /* common */
9394 tintptr handle; /* pointer to self as long */
22
33 scriptversion=2018-03-07.03; # UTC
44
5 # Copyright (C) 1996-2020 Free Software Foundation, Inc.
5 # Copyright (C) 1996-2021 Free Software Foundation, Inc.
66 # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
77
88 # This program is free software; you can redistribute it and/or modify
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
209209 unique=`for i in $$list; do \
210210 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
211211 done | $(am__uniquify_input)`
212 ETAGS = etags
213 CTAGS = ctags
214212 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
215213 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
216214 ACLOCAL = @ACLOCAL@
228226 CHECK_LIBS = @CHECK_LIBS@
229227 CPP = @CPP@
230228 CPPFLAGS = @CPPFLAGS@
229 CSCOPE = @CSCOPE@
230 CTAGS = @CTAGS@
231231 CYGPATH_W = @CYGPATH_W@
232232 DEFS = @DEFS@
233233 DEPDIR = @DEPDIR@
239239 ECHO_N = @ECHO_N@
240240 ECHO_T = @ECHO_T@
241241 EGREP = @EGREP@
242 ETAGS = @ETAGS@
242243 EXEEXT = @EXEEXT@
243244 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
244245 FDKAAC_LIBS = @FDKAAC_LIBS@
248249 FUSE_CFLAGS = @FUSE_CFLAGS@
249250 FUSE_LIBS = @FUSE_LIBS@
250251 GREP = @GREP@
252 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
253 IMLIB2_LIBS = @IMLIB2_LIBS@
251254 INSTALL = @INSTALL@
252255 INSTALL_DATA = @INSTALL_DATA@
253256 INSTALL_PROGRAM = @INSTALL_PROGRAM@
545548
546549 distclean-tags:
547550 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
548
549551 distdir: $(BUILT_SOURCES)
550552 $(MAKE) $(AM_MAKEFLAGS) distdir-am
551553
256256 LOG(LOG_LEVEL_INFO, buf);
257257 mod->server_msg(mod, buf, 0);
258258 }
259
259 #else
260 {
261 /* This version of freerdp returns no useful information at
262 * all */
263 mod->server_msg(mod, "Neutrinordp connect failed.", 0);
264 mod->server_msg(mod, "No more information is available", 0);
265 mod->server_msg(mod, "Check host is up"
266 " and credentials are correct", 0);
267 }
260268 #endif
261269 LOG(LOG_LEVEL_ERROR, "NeutrinoRDP proxy connection: status [Failed],"
262270 " RDP client [%s:%s], RDP server [%s:%d], RDP server username [%s],"
17481756 LOG_DEVEL(LOG_LEVEL_INFO, "lfreerdp_pre_connect:");
17491757 mod = ((struct mod_context *)(instance->context))->modi;
17501758 verifyColorMap(mod);
1751 num_chans = 0;
1752 index = 0;
1753 error = mod->server_query_channel(mod, index, ch_name, &ch_flags);
1754
1755 while (error == 0)
1756 {
1757 num_chans++;
1758 LOG_DEVEL(LOG_LEVEL_DEBUG, "lfreerdp_pre_connect: got channel [%s], id [%d], flags [0x%8.8x]",
1759 ch_name, index, ch_flags);
1760 dst_ch_name = instance->settings->channels[index].name;
1761 g_memset(dst_ch_name, 0, 8);
1762 g_snprintf(dst_ch_name, 8, "%s", ch_name);
1763 instance->settings->channels[index].options = ch_flags;
1764 index++;
1759
1760 num_chans = mod->server_get_channel_count(mod);
1761 if (num_chans < 0)
1762 {
1763 LOG(LOG_LEVEL_ERROR, "lfreerdp_pre_connect: Can't get channel count");
1764 num_chans = 0;
1765 }
1766
1767 for (index = 0 ; index < num_chans; ++index)
1768 {
17651769 error = mod->server_query_channel(mod, index, ch_name, &ch_flags);
1770 if (error == 0)
1771 {
1772 LOG_DEVEL(LOG_LEVEL_DEBUG, "lfreerdp_pre_connect: "
1773 "got channel [%s], id [%d], flags [0x%8.8x]",
1774 ch_name, index, ch_flags);
1775 dst_ch_name = instance->settings->channels[index].name;
1776 g_memset(dst_ch_name, 0, 8);
1777 g_snprintf(dst_ch_name, 8, "%s", ch_name);
1778 instance->settings->channels[index].options = ch_flags;
1779 }
1780 else
1781 {
1782 LOG(LOG_LEVEL_ERROR, "lfreerdp_pre_connect: "
1783 "Expected %d channels, got %d",
1784 num_chans, index);
1785 num_chans = index;
1786 }
17661787 }
17671788
17681789 instance->settings->num_channels = num_chans;
107107 char *data, int width, int height, int srcx, int srcy);
108108 int (*server_set_pointer)(struct mod *v, int x, int y, char *data, char *mask);
109109 int (*server_palette)(struct mod *v, int *palette);
110 int (*server_msg)(struct mod *v, char *msg, int code);
110 int (*server_msg)(struct mod *v, const char *msg, int code);
111111 int (*server_is_term)(struct mod *v);
112112 int (*server_set_clip)(struct mod *v, int x, int y, int cx, int cy);
113113 int (*server_reset_clip)(struct mod *v);
130130 int box_right, int box_bottom,
131131 int x, int y, char *data, int data_len);
132132 int (*server_reset)(struct mod *v, int width, int height, int bpp);
133 int (*server_get_channel_count)(struct mod *v);
133134 int (*server_query_channel)(struct mod *v, int index,
134135 char *channel_name,
135136 int *channel_flags);
193194 int flags, int frame_id);
194195 int (*server_session_info)(struct mod *v, const char *data,
195196 int data_bytes);
196 tintptr server_dumby[100 - 45]; /* align, 100 minus the number of server
197 tintptr server_dumby[100 - 46]; /* align, 100 minus the number of server
197198 functions above */
198199 /* common */
199200 tintptr handle; /* pointer to self as long */
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
174174 CHECK_LIBS = @CHECK_LIBS@
175175 CPP = @CPP@
176176 CPPFLAGS = @CPPFLAGS@
177 CSCOPE = @CSCOPE@
178 CTAGS = @CTAGS@
177179 CYGPATH_W = @CYGPATH_W@
178180 DEFS = @DEFS@
179181 DEPDIR = @DEPDIR@
185187 ECHO_N = @ECHO_N@
186188 ECHO_T = @ECHO_T@
187189 EGREP = @EGREP@
190 ETAGS = @ETAGS@
188191 EXEEXT = @EXEEXT@
189192 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
190193 FDKAAC_LIBS = @FDKAAC_LIBS@
194197 FUSE_CFLAGS = @FUSE_CFLAGS@
195198 FUSE_LIBS = @FUSE_LIBS@
196199 GREP = @GREP@
200 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
201 IMLIB2_LIBS = @IMLIB2_LIBS@
197202 INSTALL = @INSTALL@
198203 INSTALL_DATA = @INSTALL_DATA@
199204 INSTALL_PROGRAM = @INSTALL_PROGRAM@
374379
375380 cscope cscopelist:
376381
377
378382 distdir: $(BUILT_SOURCES)
379383 $(MAKE) $(AM_MAKEFLAGS) distdir-am
380384
+0
-21
postinstall-pak less more
0 #!/bin/sh -e
1
2 if ! ([ "$1" = "configure" ] || [ "$1" = "reconfigure" ]); then
3 exit 0
4 fi
5
6
7 XRDP="xrdp"
8 ADDUSER="/usr/sbin/adduser"
9 XRDPLOG="/var/log/xrdp-sesman.log"
10 SESMANLOG="/var/log/xrdp-sesman.log"
11
12 [ -d /var/run/xrdp ] || mkdir -p /var/run/xrdp
13 $ADDUSER --system --disabled-password --disabled-login --home /var/run/xrdp \
14 --no-create-home --quiet --group $XRDP
15
16 touch $SESMANLOG $XRDPLOG
17 chown $XRDP:$XRDP $SESMANLOG
18 chown $XRDP:$XRDP $XRDPLOG
19
20 #DEBHELPER#
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
250250 unique=`for i in $$list; do \
251251 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
252252 done | $(am__uniquify_input)`
253 ETAGS = etags
254 CTAGS = ctags
255253 DIST_SUBDIRS = $(SUBDIRS)
256254 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
257255 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
295293 CHECK_LIBS = @CHECK_LIBS@
296294 CPP = @CPP@
297295 CPPFLAGS = @CPPFLAGS@
296 CSCOPE = @CSCOPE@
297 CTAGS = @CTAGS@
298298 CYGPATH_W = @CYGPATH_W@
299299 DEFS = @DEFS@
300300 DEPDIR = @DEPDIR@
306306 ECHO_N = @ECHO_N@
307307 ECHO_T = @ECHO_T@
308308 EGREP = @EGREP@
309 ETAGS = @ETAGS@
309310 EXEEXT = @EXEEXT@
310311 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
311312 FDKAAC_LIBS = @FDKAAC_LIBS@
315316 FUSE_CFLAGS = @FUSE_CFLAGS@
316317 FUSE_LIBS = @FUSE_LIBS@
317318 GREP = @GREP@
319 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
320 IMLIB2_LIBS = @IMLIB2_LIBS@
318321 INSTALL = @INSTALL@
319322 INSTALL_DATA = @INSTALL_DATA@
320323 INSTALL_PROGRAM = @INSTALL_PROGRAM@
797800
798801 distclean-tags:
799802 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
800
801803 distdir: $(BUILT_SOURCES)
802804 $(MAKE) $(AM_MAKEFLAGS) distdir-am
803805
2929
3030 #include "sesman.h"
3131 #include "string_calls.h"
32
33 extern struct config_sesman *g_cfg; /* in sesman.c */
3432
3533 /******************************************************************************/
3634 int
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
208208 unique=`for i in $$list; do \
209209 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
210210 done | $(am__uniquify_input)`
211 ETAGS = etags
212 CTAGS = ctags
213211 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
214212 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
215213 ACLOCAL = @ACLOCAL@
227225 CHECK_LIBS = @CHECK_LIBS@
228226 CPP = @CPP@
229227 CPPFLAGS = @CPPFLAGS@
228 CSCOPE = @CSCOPE@
229 CTAGS = @CTAGS@
230230 CYGPATH_W = @CYGPATH_W@
231231 DEFS = @DEFS@
232232 DEPDIR = @DEPDIR@
238238 ECHO_N = @ECHO_N@
239239 ECHO_T = @ECHO_T@
240240 EGREP = @EGREP@
241 ETAGS = @ETAGS@
241242 EXEEXT = @EXEEXT@
242243 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
243244 FDKAAC_LIBS = @FDKAAC_LIBS@
247248 FUSE_CFLAGS = @FUSE_CFLAGS@
248249 FUSE_LIBS = @FUSE_LIBS@
249250 GREP = @GREP@
251 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
252 IMLIB2_LIBS = @IMLIB2_LIBS@
250253 INSTALL = @INSTALL@
251254 INSTALL_DATA = @INSTALL_DATA@
252255 INSTALL_PROGRAM = @INSTALL_PROGRAM@
609612
610613 distclean-tags:
611614 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
612
613615 distdir: $(BUILT_SOURCES)
614616 $(MAKE) $(AM_MAKEFLAGS) distdir-am
615617
2121 #include "parse.h"
2222 #include "os_calls.h"
2323
24 /* Define bitmask values for restricting the clipboard */
25 #define CLIP_RESTRICT_NONE 0
26 #define CLIP_RESTRICT_TEXT (1<<0)
27 #define CLIP_RESTRICT_FILE (1<<1)
28 #define CLIP_RESTRICT_IMAGE (1<<2)
29 #define CLIP_RESTRICT_ALL 0x7fffffff
30
2431 int read_entire_packet(struct stream *src, struct stream **dest, int chan_flags, int length, int total_length);
2532
2633 #endif
2929 #include "file.h"
3030 #include "os_calls.h"
3131
32 #include "chansrv_common.h"
3233 #include "chansrv_config.h"
3334 #include "string_calls.h"
3435
3536 /* Default settings */
3637 #define DEFAULT_USE_UNIX_SOCKET 0
3738 #define DEFAULT_RESTRICT_OUTBOUND_CLIPBOARD 0
39 #define DEFAULT_RESTRICT_INBOUND_CLIPBOARD 0
3840 #define DEFAULT_ENABLE_FUSE_MOUNT 1
3941 #define DEFAULT_FUSE_MOUNT_NAME "xrdp-client"
4042 #define DEFAULT_FILE_UMASK 077
41
43 #define DEFAULT_USE_NAUTILUS3_FLIST_FORMAT 0
4244 /**
4345 * Type used for passing a logging function about
4446 */
4749 enum logReturns (*log_func_t)(const enum logLevels lvl,
4850 const char *msg, ...);
4951
52 /* Map clipboard strings into bitmask values */
53 static const struct bitmask_string clip_restrict_map[] =
54 {
55 { CLIP_RESTRICT_TEXT, "text"},
56 { CLIP_RESTRICT_FILE, "file"},
57 { CLIP_RESTRICT_IMAGE, "image"},
58 { CLIP_RESTRICT_ALL, "all"},
59 { CLIP_RESTRICT_NONE, "none"},
60 /* Compatibility values */
61 { CLIP_RESTRICT_ALL, "true"},
62 { CLIP_RESTRICT_ALL, "yes"},
63 { CLIP_RESTRICT_NONE, "false"},
64 BITMASK_STRING_END_OF_LIST
65 };
66
5067 /***************************************************************************//**
5168 * @brief Error logging function to use to log to stdout
5269 *
124141 const char *name = (const char *)list_get_item(names, index);
125142 const char *value = (const char *)list_get_item(values, index);
126143
144 char unrecognised[256];
127145 if (g_strcasecmp(name, "RestrictOutboundClipboard") == 0)
128146 {
129 cfg->restrict_outbound_clipboard = g_text2bool(value);
147 cfg->restrict_outbound_clipboard =
148 g_str_to_bitmask(value, clip_restrict_map, ",",
149 unrecognised, sizeof(unrecognised));
150 if (unrecognised[0] != '\0')
151 {
152 LOG(LOG_LEVEL_WARNING,
153 "Unrecognised tokens parsing 'RestrictOutboundClipboard' %s",
154 unrecognised);
155 }
156 }
157 if (g_strcasecmp(name, "RestrictInboundClipboard") == 0)
158 {
159 cfg->restrict_inbound_clipboard =
160 g_str_to_bitmask(value, clip_restrict_map, ",",
161 unrecognised, sizeof(unrecognised));
162 if (unrecognised[0] != '\0')
163 {
164 LOG(LOG_LEVEL_WARNING,
165 "Unrecognised tokens parsing 'RestrictInboundClipboard' %s",
166 unrecognised);
167 }
130168 }
131169 }
132170
160198 {
161199 cfg->enable_fuse_mount = g_text2bool(value);
162200 }
163 if (g_strcasecmp(name, "FuseMountName") == 0)
201 else if (g_strcasecmp(name, "FuseMountName") == 0)
164202 {
165203 g_free(cfg->fuse_mount_name);
166204 cfg->fuse_mount_name = g_strdup(value);
174212 else if (g_strcasecmp(name, "FileUmask") == 0)
175213 {
176214 cfg->file_umask = strtol(value, NULL, 0);
215 }
216 else if (g_strcasecmp(name, "UseNautilus3FlistFormat") == 0)
217 {
218 cfg->use_nautilus3_flist_format = g_text2bool(value);
177219 }
178220 }
179221
203245 cfg->use_unix_socket = DEFAULT_USE_UNIX_SOCKET;
204246 cfg->enable_fuse_mount = DEFAULT_ENABLE_FUSE_MOUNT;
205247 cfg->restrict_outbound_clipboard = DEFAULT_RESTRICT_OUTBOUND_CLIPBOARD;
248 cfg->restrict_inbound_clipboard = DEFAULT_RESTRICT_INBOUND_CLIPBOARD;
206249 cfg->fuse_mount_name = fuse_mount_name;
207250 cfg->file_umask = DEFAULT_FILE_UMASK;
251 cfg->use_nautilus3_flist_format = DEFAULT_USE_NAUTILUS3_FLIST_FORMAT;
208252 }
209253
210254 return cfg;
280324 g_writeln(" UseUnixSocket (derived): %s",
281325 g_bool2text(config->use_unix_socket));
282326
327 char buf[256];
283328 g_writeln("\nSecurity configuration:");
284 g_writeln(" RestrictOutboundClipboard: %s",
285 g_bool2text(config->restrict_outbound_clipboard));
286
329 if (config->restrict_outbound_clipboard == CLIP_RESTRICT_NONE)
330 {
331 g_writeln(" RestrictOutboundClipboard: %s", "none");
332 }
333 else if (config->restrict_outbound_clipboard == CLIP_RESTRICT_ALL)
334 {
335 g_writeln(" RestrictOutboundClipboard: %s", "all");
336 }
337 else
338 {
339 g_bitmask_to_str(config->restrict_outbound_clipboard,
340 clip_restrict_map, ',', buf, sizeof(buf));
341 g_writeln(" RestrictOutboundClipboard: %s", buf);
342 }
343
344 if (config->restrict_inbound_clipboard == CLIP_RESTRICT_NONE)
345 {
346 g_writeln(" RestrictInboundClipboard: %s", "none");
347 }
348 else if (config->restrict_inbound_clipboard == CLIP_RESTRICT_ALL)
349 {
350 g_writeln(" RestrictInboundClipboard: %s", "all");
351 }
352 else
353 {
354 g_bitmask_to_str(config->restrict_inbound_clipboard,
355 clip_restrict_map, ',', buf, sizeof(buf));
356 g_writeln(" RestrictInboundClipboard: %s", buf);
357 }
287358 g_writeln("\nChansrv configuration:");
288359 g_writeln(" EnableFuseMount %s",
289360 g_bool2text(config->enable_fuse_mount));
290361 g_writeln(" FuseMountName: %s", config->fuse_mount_name);
291362 g_writeln(" FileMask: 0%o", config->file_umask);
363 g_writeln(" Nautilus 3 Flist Format: %s",
364 g_bool2text(config->use_nautilus3_flist_format));
292365 }
293366
294367 /******************************************************************************/
3030
3131 /** RestrictOutboundClipboard setting from sesman.ini */
3232 int restrict_outbound_clipboard;
33 /** RestrictInboundClipboard setting from sesman.ini */
34 int restrict_inbound_clipboard;
3335
3436 /** * FuseMountName from sesman.ini */
3537 char *fuse_mount_name;
3638 /** FileUmask from sesman.ini */
3739 mode_t file_umask;
40
41 /** Whether to use nautilus3-compatible file lists for the clipboard */
42 int use_nautilus3_flist_format;
3843 };
3944
4045
1717
1818 /* FUSE mount point */
1919 char g_fuse_root_path[256] = "";
20 #ifdef XRDP_FUSE
21 static const char *g_fuse_root_path_basename; /* See xfuse_path_in_xfuse_fs() */
22 static int g_fuse_root_parent_dev; /* Ditto */
23 static int g_fuse_root_parent_ino; /* Ditto */
24 #endif
2025 char g_fuse_clipboard_path[256] = ""; /* for clipboard use */
2126
2227 #if defined(HAVE_CONFIG_H)
121126 void xfuse_devredir_cb_file_close(struct state_close *fip)
122127 {}
123128
129 int xfuse_path_in_xfuse_fs(const char *path)
130 {
131 return 0;
132 }
133
124134 #else
125135
126136 /******************************************************************************
323333 static int g_fd = 0;
324334 static tintptr g_bufsize = 0;
325335
336
326337 /* forward declarations for internal access */
327338 static int xfuse_init_xrdp_fs(void);
328339 static int xfuse_deinit_xrdp_fs(void);
460471 xfuse_init(void)
461472 {
462473 struct fuse_args args = FUSE_ARGS_INIT(0, NULL);
474 char *p;
463475
464476 /* if already inited, just return */
465477 if (g_xfuse_inited)
506518 g_snprintf(g_fuse_root_path, sizeof(g_fuse_root_path), "%s/%s",
507519 g_getenv("HOME"), g_cfg->fuse_mount_name);
508520 }
521
522 /* Remove all trailing '/' from the root path */
523 p = g_fuse_root_path + g_strlen(g_fuse_root_path);
524 while ( p > g_fuse_root_path && *(p - 1) == '/')
525 {
526 --p;
527 *p = '\0';
528 }
529
530 /* This shouldn't happen */
531 if (g_strlen(g_fuse_root_path) == 0)
532 {
533 LOG(LOG_LEVEL_ERROR,
534 "Fuse root path is empty after removing trailing '/'");
535 return -1;
536 }
537
509538 g_snprintf(g_fuse_clipboard_path, 255, "%s/.clipboard", g_fuse_root_path);
539
540 /* Get the characteristics of the parent directory of the FUSE mount
541 * point. Used by xfuse_path_in_xfuse_fs() */
542 p = (char *)g_strrchr(g_fuse_root_path, '/');
543 if (p != NULL)
544 {
545 /* Temporarily finish the root path at this point */
546 *p = '\0';
547 g_fuse_root_path_basename = p + 1;
548 g_fuse_root_parent_dev = g_file_get_device_number(g_fuse_root_path);
549 g_fuse_root_parent_ino = g_file_get_inode_num(g_fuse_root_path);
550 *p = '/';
551 }
552 else
553 {
554 g_fuse_root_parent_dev = -1;
555 g_fuse_root_parent_ino = -1;
556 }
557
558 if (g_fuse_root_parent_dev == -1 || g_fuse_root_parent_ino == -1)
559 {
560 LOG(LOG_LEVEL_ERROR,
561 "Unable to obtain characteristics of directory containing %s",
562 g_fuse_root_path);
563 return -1;
564 }
510565
511566 /* if FUSE mount point does not exist, create it */
512567 if (!g_directory_exist(g_fuse_root_path))
514569 (void)g_create_path(g_fuse_root_path);
515570 if (!g_create_dir(g_fuse_root_path))
516571 {
517 LOG_DEVEL(LOG_LEVEL_ERROR, "mkdir %s failed. If %s is already mounted, you must "
518 "first unmount it", g_fuse_root_path, g_fuse_root_path);
572 LOG(LOG_LEVEL_ERROR, "mkdir %s failed. If %s is already mounted, you must "
573 "first unmount it", g_fuse_root_path, g_fuse_root_path);
519574 return -1;
520575 }
521576 }
14901545 free(fip);
14911546 }
14921547
1548 /*
1549 * Determine is a file is in the FUSE filesystem
1550 *
1551 * The whole purpose of this function is to avoid deadlocks. If we try
1552 * to determine the size (or any other attribute) of a file in the FUSE
1553 * filesystem, the kernel will block the calling thread and send a message
1554 * to libfuse. Since we're single-threaded, this will result in deadlock.
1555 *
1556 * Ideally we'd use a stat() of the file to compare with a stat() of
1557 * the mountpoint. This won't work however, for the reasons outline above.
1558 *
1559 * A simple implementation might be to compare the start of the filename
1560 * with the FUSE mount point. This will work, but can easily be defeated,
1561 * (perhaps unintentionally) by symlinks in the path.
1562 *
1563 * The approach taken here is to record the basename of the FUSE mount
1564 * point directory (e.g. 'thinclient_drives') and look for that in the
1565 * passed-in filename as a directory element. If we find it, we look
1566 * at the device name and inode number of the parent directory of the
1567 * FUSE mount point. If these match we consider the filename to be in
1568 * the FUSE filesystem.
1569 */
1570 int xfuse_path_in_xfuse_fs(const char *path)
1571 {
1572 char *wpath = NULL; /* Writeable copy of path */
1573 char *p;
1574 int blen = g_strlen(g_fuse_root_path_basename);
1575 int rv = 0;
1576
1577 if ((wpath = g_strdup(path)) == NULL)
1578 {
1579 LOG(LOG_LEVEL_ERROR, "system out of memory");
1580 }
1581 else
1582 {
1583 /* Look ahead in the string for the basename of the FUSE mount point */
1584 for (p = wpath;
1585 (p = g_strstr(p, g_fuse_root_path_basename)) != NULL ;
1586 p = p + 1)
1587 {
1588 /* Is this string preceded by a '/' ? */
1589 if (p == wpath || *(p - 1) != '/')
1590 {
1591 continue;
1592 }
1593
1594 /* Is the string followed by a '/' or '\0' ? We know it's
1595 * valid to look ahead this far in the string, as g_strstr()
1596 * tells us it is */
1597 if (*(p + blen) != '/' && *(p + blen) != '\0')
1598 {
1599 continue;
1600 }
1601
1602 /* Temporarily terminate the string early, and check the
1603 * file system characteristics of the preceding directory */
1604 *(p - 1) = '\0';
1605
1606 if (g_file_get_device_number(wpath) == g_fuse_root_parent_dev &&
1607 g_file_get_inode_num(wpath) == g_fuse_root_parent_ino)
1608 {
1609 rv = 1;
1610 break;
1611 }
1612 *(p - 1) = '/';
1613 }
1614 g_free(wpath);
1615 }
1616 return rv;
1617 }
1618
14931619 /******************************************************************************
14941620 ** **
14951621 ** callbacks for fuse **
113113
114114 void xfuse_devredir_cb_file_close(struct state_close *fip);
115115
116 /*
117 * Returns true if a filesystem path lies in the FUSE filesystem
118 *
119 * Use to prevent deadlocks. For example, if chansrv tries to open
120 * a file in the FUSE filesystem it will fail, as it will call back
121 * into itself to handle the I/O
122 */
123 int xfuse_path_in_xfuse_fs(const char *path);
124
116125 #endif
170170 #include "os_calls.h"
171171 #include "string_calls.h"
172172 #include "chansrv.h"
173 #include "chansrv_common.h"
173174 #include "chansrv_config.h"
174175 #include "clipboard.h"
175176 #include "clipboard_file.h"
11981199 return 0;
11991200 }
12001201
1202 /**************************************************************************//**
1203 * Process a CB_FORMAT_DATA_RESPONSE for an X client requesting a file list
1204 *
1205 * @param s Stream containing CLIPRDR_FILELIST ([MS-RDPECLIP])
1206 * @param clip_msg_status msgFlags from Clipboard PDU Header
1207 * @param clip_msg_len dataLen from Clipboard PDU Header
1208 *
1209 * @return Status
1210 */
1211 static int
1212 clipboard_process_data_response_for_file(struct stream *s,
1213 int clip_msg_status,
1214 int clip_msg_len)
1215 {
1216 XSelectionRequestEvent *lxev;
1217 int rv = 0;
1218
1219 LOG_DEVEL(LOG_LEVEL_TRACE, "clipboard_process_data_response_for_file: ");
1220 lxev = &g_saved_selection_req_event;
1221
1222 const int flist_size = 1024 * 1024;
1223 g_free(g_clip_c2s.data);
1224 g_clip_c2s.data = (char *)g_malloc(flist_size, 0);
1225 if (g_clip_c2s.data == NULL)
1226 {
1227 LOG(LOG_LEVEL_ERROR, "clipboard_process_data_response_for_file: "
1228 "Can't allocate memory");
1229 rv = 1;
1230 }
1231 /* text/uri-list */
1232 else if (g_clip_c2s.type == g_file_atom1)
1233 {
1234 rv = clipboard_c2s_in_files(s, g_clip_c2s.data, flist_size,
1235 "file://");
1236 }
1237 /* x-special/gnome-copied-files */
1238 else if (g_clip_c2s.type == g_file_atom2)
1239 {
1240 g_strcpy(g_clip_c2s.data, "copy\n");
1241 rv = clipboard_c2s_in_files(s, g_clip_c2s.data + 5, flist_size - 5,
1242 "file://");
1243 }
1244 else if ((g_clip_c2s.type == XA_STRING) ||
1245 (g_clip_c2s.type == g_utf8_atom))
1246 {
1247 if (g_cfg->use_nautilus3_flist_format)
1248 {
1249 /*
1250 * This file list format is only used by GNOME 3
1251 * versions >= 3.29.92. It is not used by GNOME 4. Remove
1252 * this workaround when GNOME 3 is no longer supported by
1253 * long-term distros */
1254 #define LIST_PREFIX "x-special/nautilus-clipboard\ncopy\n"
1255 #define LIST_PREFIX_LEN (sizeof(LIST_PREFIX) - 1)
1256 g_strcpy(g_clip_c2s.data, LIST_PREFIX);
1257 rv = clipboard_c2s_in_files(s,
1258 g_clip_c2s.data + LIST_PREFIX_LEN,
1259 flist_size - LIST_PREFIX_LEN - 1,
1260 "file://");
1261 g_strcat(g_clip_c2s.data, "\n");
1262 #undef LIST_PREFIX_LEN
1263 #undef LIST_PREFIX
1264 }
1265 else
1266 {
1267 rv = clipboard_c2s_in_files(s, g_clip_c2s.data, flist_size, "");
1268 }
1269 }
1270 else
1271 {
1272 LOG_DEVEL(LOG_LEVEL_ERROR,
1273 "clipboard_process_data_response_for_file: "
1274 "Unrecognised target");
1275 rv = 1;
1276 }
1277
1278 if (rv != 0 && g_clip_c2s.data != NULL)
1279 {
1280 g_clip_c2s.data[0] = '\0';
1281 }
1282
1283 g_clip_c2s.total_bytes =
1284 (g_clip_c2s.data == NULL) ? 0 : g_strlen(g_clip_c2s.data);
1285 g_clip_c2s.read_bytes_done = g_clip_c2s.total_bytes;
1286 clipboard_provide_selection_c2s(lxev, lxev->target);
1287
1288 return rv;
1289 }
1290
12011291 /*****************************************************************************/
12021292 /* client to server */
12031293 /* sent as a reply to CB_FORMAT_DATA_REQUEST; used to indicate whether
12261316 }
12271317 if (g_clip_c2s.xrdp_clip_type == XRDP_CB_FILE)
12281318 {
1229 g_free(g_clip_c2s.data);
1230 g_clip_c2s.data = (char *)g_malloc(1024 * 1024, 1);
1231 /* text/uri-list */
1232 if (g_clip_c2s.type == g_file_atom1)
1233 {
1234 clipboard_c2s_in_files(s, g_clip_c2s.data);
1235 }
1236 /* x-special/gnome-copied-files */
1237 else if (g_clip_c2s.type == g_file_atom2)
1238 {
1239 g_strcpy(g_clip_c2s.data, "copy\n");
1240 clipboard_c2s_in_files(s, g_clip_c2s.data + 5);
1241 }
1242 else
1243 {
1244 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_process_data_response: error");
1245 }
1246 g_clip_c2s.total_bytes = g_strlen(g_clip_c2s.data);
1247 g_clip_c2s.read_bytes_done = g_clip_c2s.total_bytes;
1248 clipboard_provide_selection_c2s(lxev, lxev->target);
1319 clipboard_process_data_response_for_file(s, clip_msg_status,
1320 clip_msg_len);
12491321 return 0;
12501322 }
12511323 LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_process_data_response: "
12611333 return 0;
12621334 }
12631335 index = 0;
1264 while (s_check(s))
1336 while (s_check_rem(s, 2))
12651337 {
12661338 in_uint16_le(s, wchr);
12671339 wtext[index] = wchr;
19332005 g_clip_s2c.data[g_clip_s2c.total_bytes] = 0;
19342006 if (g_clip_s2c.xrdp_clip_type == XRDP_CB_FILE)
19352007 {
1936 clipboard_send_data_response_for_file(g_clip_s2c.data,
1937 g_clip_s2c.total_bytes);
2008 if (g_cfg->restrict_outbound_clipboard & CLIP_RESTRICT_FILE)
2009 {
2010 LOG(LOG_LEVEL_DEBUG,
2011 "outbound clipboard(file) UTF8_STRING(%s) is restricted because of config",
2012 g_clip_s2c.data);
2013 }
2014 else
2015 {
2016 clipboard_send_data_response_for_file(g_clip_s2c.data,
2017 g_clip_s2c.total_bytes);
2018 }
19382019 }
19392020 else
19402021 {
1941 clipboard_send_data_response_for_text(g_clip_s2c.data,
1942 g_clip_s2c.total_bytes);
2022 if (g_cfg->restrict_outbound_clipboard & CLIP_RESTRICT_TEXT)
2023 {
2024 LOG(LOG_LEVEL_DEBUG,
2025 "outbound clipboard(text) UTF8_STRING(%s) is restricted because of config",
2026 g_clip_s2c.data);
2027 }
2028 else
2029 {
2030 clipboard_send_data_response_for_text(g_clip_s2c.data,
2031 g_clip_s2c.total_bytes);
2032 }
19432033 }
2034
19442035 }
19452036 }
19462037 else if (lxevent->target == XA_STRING)
19542045 g_clip_s2c.data = (char *) g_malloc(g_clip_s2c.total_bytes + 1, 0);
19552046 g_memcpy(g_clip_s2c.data, data, g_clip_s2c.total_bytes);
19562047 g_clip_s2c.data[g_clip_s2c.total_bytes] = 0;
1957 clipboard_send_data_response_for_text(g_clip_s2c.data,
1958 g_clip_s2c.total_bytes);
2048 if (g_cfg->restrict_outbound_clipboard & CLIP_RESTRICT_TEXT)
2049 {
2050 LOG(LOG_LEVEL_DEBUG,
2051 "outbound clipboard(text) XA_STRING(%s) is restricted because of config",
2052 g_clip_s2c.data);
2053 }
2054 else
2055 {
2056 clipboard_send_data_response_for_text(g_clip_s2c.data,
2057 g_clip_s2c.total_bytes);
2058 }
2059
19592060 }
19602061 }
19612062 else if (lxevent->target == g_image_bmp_atom)
19652066 if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 14))
19662067 {
19672068 g_free(g_clip_s2c.data);
1968 g_clip_s2c.total_bytes = data_size;
1969 g_clip_s2c.data = (char *) g_malloc(data_size, 0);
1970 g_memcpy(g_clip_s2c.data, data, data_size);
1971 clipboard_send_data_response_for_image(g_clip_s2c.data + 14,
1972 data_size - 14);
2069
2070 if (g_cfg->restrict_outbound_clipboard & CLIP_RESTRICT_IMAGE)
2071 {
2072 LOG(LOG_LEVEL_DEBUG,
2073 "outbound clipboard(image) image/bmp is restricted because of config");
2074 }
2075 else
2076 {
2077 g_clip_s2c.total_bytes = data_size;
2078 g_clip_s2c.data = (char *) g_malloc(data_size, 0);
2079 g_memcpy(g_clip_s2c.data, data, data_size);
2080 clipboard_send_data_response_for_image(g_clip_s2c.data + 14,
2081 data_size - 14);
2082 }
2083
19732084 }
19742085 }
19752086 else if (lxevent->target == g_file_atom1)
19832094 g_clip_s2c.data = (char *) g_malloc(g_clip_s2c.total_bytes + 1, 0);
19842095 g_memcpy(g_clip_s2c.data, data, g_clip_s2c.total_bytes);
19852096 g_clip_s2c.data[g_clip_s2c.total_bytes] = 0;
1986 clipboard_send_data_response_for_file(g_clip_s2c.data,
1987 g_clip_s2c.total_bytes);
2097 if (g_cfg->restrict_outbound_clipboard & CLIP_RESTRICT_FILE)
2098 {
2099 LOG(LOG_LEVEL_DEBUG,
2100 "outbound clipboard(file) text/uri-list(%s) is restricted because of config",
2101 g_clip_s2c.data);
2102 }
2103 else
2104 {
2105 clipboard_send_data_response_for_file(g_clip_s2c.data,
2106 g_clip_s2c.total_bytes);
2107
2108 }
2109
19882110 }
19892111 }
19902112 else if (lxevent->target == g_file_atom2)
19912113 {
1992 LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_event_selection_notify: text/uri-list "
2114 LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_event_selection_notify: x-special/gnome-copied-files "
19932115 "data_size %d", data_size);
19942116 if ((g_clip_s2c.incr_in_progress == 0) && (data_size > 0))
19952117 {
19982120 g_clip_s2c.data = (char *) g_malloc(g_clip_s2c.total_bytes + 1, 0);
19992121 g_memcpy(g_clip_s2c.data, data, g_clip_s2c.total_bytes);
20002122 g_clip_s2c.data[g_clip_s2c.total_bytes] = 0;
2001 clipboard_send_data_response_for_file(g_clip_s2c.data,
2002 g_clip_s2c.total_bytes);
2123 if (g_cfg->restrict_outbound_clipboard & CLIP_RESTRICT_FILE)
2124 {
2125 LOG(LOG_LEVEL_DEBUG,
2126 "outbound clipboard(file) x-special/gnome-copied-files(%s) is restricted because of config",
2127 g_clip_s2c.data);
2128 }
2129 else
2130 {
2131 clipboard_send_data_response_for_file(g_clip_s2c.data,
2132 g_clip_s2c.total_bytes);
2133 }
2134
20032135 }
20042136 }
20052137 else
20182150 if (got_file_atom != 0)
20192151 {
20202152 /* text/uri-list or x-special/gnome-copied-files */
2021 g_clip_s2c.type = got_file_atom;
2022 g_clip_s2c.xrdp_clip_type = XRDP_CB_FILE;
2023 g_clip_s2c.converted = 0;
2024 g_clip_s2c.clip_time = lxevent->time;
2025 send_format_announce = 1;
2153
2154 if (g_cfg->restrict_outbound_clipboard & CLIP_RESTRICT_FILE)
2155 {
2156 LOG(LOG_LEVEL_DEBUG,
2157 "outbound clipboard(file) is restricted because of config");
2158 }
2159 else
2160 {
2161 g_clip_s2c.type = got_file_atom;
2162 g_clip_s2c.xrdp_clip_type = XRDP_CB_FILE;
2163 g_clip_s2c.converted = 0;
2164 g_clip_s2c.clip_time = lxevent->time;
2165 send_format_announce = 1;
2166 }
2167
20262168 }
20272169 else if (got_utf8)
20282170 {
2029 g_clip_s2c.type = g_utf8_atom;
2030 g_clip_s2c.xrdp_clip_type = XRDP_CB_TEXT;
2031 g_clip_s2c.converted = 0;
2032 g_clip_s2c.clip_time = lxevent->time;
2033 send_format_announce = 1;
2171
2172 if (g_cfg->restrict_outbound_clipboard & CLIP_RESTRICT_TEXT)
2173 {
2174 LOG(LOG_LEVEL_DEBUG,
2175 "outbound clipboard(text) is restricted because of config");
2176 }
2177 else
2178 {
2179 g_clip_s2c.type = g_utf8_atom;
2180 g_clip_s2c.xrdp_clip_type = XRDP_CB_TEXT;
2181 g_clip_s2c.converted = 0;
2182 g_clip_s2c.clip_time = lxevent->time;
2183 send_format_announce = 1;
2184 }
2185
20342186 }
20352187 else if (got_string)
20362188 {
2037 g_clip_s2c.type = XA_STRING;
2038 g_clip_s2c.xrdp_clip_type = XRDP_CB_TEXT;
2039 g_clip_s2c.converted = 0;
2040 g_clip_s2c.clip_time = lxevent->time;
2041 send_format_announce = 1;
2189
2190 /*
2191 * In most cases, when copying text, TARGETS atom and UTF8_STRING atom exists,
2192 * it means that this code block which checks STRING atom might not be never executed
2193 * in recent platforms.
2194 * Use echo foo | xclip -selection clipboard -noutf8 to reproduce it.
2195 */
2196 if (g_cfg->restrict_outbound_clipboard & CLIP_RESTRICT_TEXT)
2197 {
2198 LOG(LOG_LEVEL_DEBUG,
2199 "outbound clipboard(text) is restricted because of config");
2200 }
2201 else
2202 {
2203 g_clip_s2c.type = XA_STRING;
2204 g_clip_s2c.xrdp_clip_type = XRDP_CB_TEXT;
2205 g_clip_s2c.converted = 0;
2206 g_clip_s2c.clip_time = lxevent->time;
2207 send_format_announce = 1;
2208 }
2209
20422210 }
20432211 else if (got_bmp_image)
20442212 {
2045 g_clip_s2c.type = g_image_bmp_atom;
2046 g_clip_s2c.xrdp_clip_type = XRDP_CB_BITMAP;
2047 g_clip_s2c.converted = 0;
2048 g_clip_s2c.clip_time = lxevent->time;
2049 send_format_announce = 1;
2213
2214 if (g_cfg->restrict_outbound_clipboard & CLIP_RESTRICT_IMAGE)
2215 {
2216 LOG(LOG_LEVEL_DEBUG,
2217 "outbound clipboard(image) is restricted because of config");
2218 }
2219 else
2220 {
2221 g_clip_s2c.type = g_image_bmp_atom;
2222 g_clip_s2c.xrdp_clip_type = XRDP_CB_BITMAP;
2223 g_clip_s2c.converted = 0;
2224 g_clip_s2c.clip_time = lxevent->time;
2225 send_format_announce = 1;
2226 }
2227
20502228 }
20512229
20522230 if (send_format_announce)
21152293 atom_buf[0] = g_targets_atom;
21162294 atom_buf[1] = g_timestamp_atom;
21172295 atom_buf[2] = g_multiple_atom;
2118 atom_buf[3] = XA_STRING;
2119 atom_buf[4] = g_utf8_atom;
2120 atom_count = 5;
2121 if (clipboard_find_format_id(CB_FORMAT_DIB) >= 0)
2296 atom_count = 3;
2297 if ((g_cfg->restrict_inbound_clipboard & CLIP_RESTRICT_TEXT) == 0)
2298 {
2299 atom_buf[atom_count] = XA_STRING;
2300 atom_count++;
2301 atom_buf[atom_count] = g_utf8_atom;
2302 atom_count++;
2303 }
2304 if (clipboard_find_format_id(CB_FORMAT_DIB) >= 0 &&
2305 (g_cfg->restrict_inbound_clipboard & CLIP_RESTRICT_IMAGE) == 0)
21222306 {
21232307 LOG_DEVEL(LOG_LEVEL_DEBUG, " reporting image/bmp");
21242308 atom_buf[atom_count] = g_image_bmp_atom;
21252309 atom_count++;
21262310 }
2127 if (clipboard_find_format_id(g_file_format_id) >= 0)
2311 if (clipboard_find_format_id(g_file_format_id) >= 0 &&
2312 (g_cfg->restrict_inbound_clipboard & CLIP_RESTRICT_FILE) == 0)
21282313 {
21292314 LOG_DEVEL(LOG_LEVEL_DEBUG, " reporting text/uri-list");
21302315 atom_buf[atom_count] = g_file_atom1;
21672352 }
21682353 else if ((lxev->target == XA_STRING) || (lxev->target == g_utf8_atom))
21692354 {
2170 g_memcpy(&g_saved_selection_req_event, lxev,
2171 sizeof(g_saved_selection_req_event));
2172 g_clip_c2s.type = lxev->target;
2173 g_clip_c2s.xrdp_clip_type = XRDP_CB_TEXT;
2174 clipboard_send_data_request(CB_FORMAT_UNICODETEXT);
2355 if (clipboard_find_format_id(g_file_format_id) >= 0)
2356 {
2357 LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
2358 "text requested when files available");
2359
2360 if (g_cfg->restrict_inbound_clipboard & CLIP_RESTRICT_FILE)
2361 {
2362 LOG(LOG_LEVEL_DEBUG,
2363 "inbound clipboard %s is restricted because of config",
2364 lxev->target == XA_STRING ? "XA_STRING" : "UTF8_STRING");
2365 clipboard_refuse_selection(lxev);
2366 }
2367 else
2368 {
2369 g_memcpy(&g_saved_selection_req_event, lxev,
2370 sizeof(g_saved_selection_req_event));
2371 g_clip_c2s.type = lxev->target;
2372 g_clip_c2s.xrdp_clip_type = XRDP_CB_FILE;
2373 clipboard_send_data_request(g_file_format_id);
2374 }
2375
2376 }
2377 else
2378 {
2379
2380 if (g_cfg->restrict_inbound_clipboard & CLIP_RESTRICT_TEXT)
2381 {
2382 LOG(LOG_LEVEL_DEBUG,
2383 "inbound clipboard %s is restricted because of config",
2384 lxev->target == XA_STRING ? "XA_STRING" : "UTF8_STRING");
2385 clipboard_refuse_selection(lxev);
2386 }
2387 else
2388 {
2389 g_memcpy(&g_saved_selection_req_event, lxev,
2390 sizeof(g_saved_selection_req_event));
2391 g_clip_c2s.type = lxev->target;
2392 g_clip_c2s.xrdp_clip_type = XRDP_CB_TEXT;
2393 clipboard_send_data_request(CB_FORMAT_UNICODETEXT);
2394 }
2395
2396 }
21752397 return 0;
21762398 }
21772399 else if (lxev->target == g_image_bmp_atom)
21802402 if ((g_clip_c2s.type == lxev->target) && g_clip_c2s.converted)
21812403 {
21822404 LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_event_selection_request: -------------------------------------------");
2183 clipboard_provide_selection_c2s(lxev, lxev->target);
2405
2406 if (g_cfg->restrict_inbound_clipboard & CLIP_RESTRICT_IMAGE)
2407 {
2408 LOG(LOG_LEVEL_DEBUG,
2409 "inbound clipboard image/bmp converted is restricted because of config");
2410 clipboard_refuse_selection(lxev);
2411 }
2412 else
2413 {
2414 clipboard_provide_selection_c2s(lxev, lxev->target);
2415 }
21842416 return 0;
2185 }
2186 g_memcpy(&g_saved_selection_req_event, lxev,
2187 sizeof(g_saved_selection_req_event));
2188 g_clip_c2s.type = g_image_bmp_atom;
2189 g_clip_c2s.xrdp_clip_type = XRDP_CB_BITMAP;
2190 clipboard_send_data_request(CB_FORMAT_DIB);
2417
2418 }
2419
2420 if (g_cfg->restrict_inbound_clipboard & CLIP_RESTRICT_IMAGE)
2421 {
2422 LOG(LOG_LEVEL_DEBUG,
2423 "inbound clipboard image/bmp is restricted because of config");
2424 clipboard_refuse_selection(lxev);
2425 }
2426 else
2427 {
2428 g_memcpy(&g_saved_selection_req_event, lxev,
2429 sizeof(g_saved_selection_req_event));
2430 g_clip_c2s.type = g_image_bmp_atom;
2431 g_clip_c2s.xrdp_clip_type = XRDP_CB_BITMAP;
2432 clipboard_send_data_request(CB_FORMAT_DIB);
2433 }
21912434 return 0;
2435
21922436 }
21932437 else if (lxev->target == g_file_atom1)
21942438 {
21962440 if ((g_clip_c2s.type == lxev->target) && g_clip_c2s.converted)
21972441 {
21982442 LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_event_selection_request: -------------------------------------------");
2199 clipboard_provide_selection_c2s(lxev, lxev->target);
2443 if (g_cfg->restrict_inbound_clipboard & CLIP_RESTRICT_FILE)
2444 {
2445 LOG(LOG_LEVEL_DEBUG,
2446 "inbound clipboard text/uri-list is restricted because of config");
2447 clipboard_refuse_selection(lxev);
2448 return 0;
2449 }
2450 else
2451 {
2452 clipboard_provide_selection_c2s(lxev, lxev->target);
2453 return 0;
2454 }
2455 }
2456 if (g_cfg->restrict_inbound_clipboard & CLIP_RESTRICT_FILE)
2457 {
2458 LOG(LOG_LEVEL_DEBUG,
2459 "inbound clipboard text/uri-list is restricted because of config");
2460 clipboard_refuse_selection(lxev);
22002461 return 0;
22012462 }
2202 g_memcpy(&g_saved_selection_req_event, lxev,
2203 sizeof(g_saved_selection_req_event));
2204 g_clip_c2s.type = g_file_atom1;
2205 g_clip_c2s.xrdp_clip_type = XRDP_CB_FILE;
2206 clipboard_send_data_request(g_file_format_id);
2207 return 0;
2463 else
2464 {
2465 g_memcpy(&g_saved_selection_req_event, lxev,
2466 sizeof(g_saved_selection_req_event));
2467 g_clip_c2s.type = g_file_atom1;
2468 g_clip_c2s.xrdp_clip_type = XRDP_CB_FILE;
2469 clipboard_send_data_request(g_file_format_id);
2470 return 0;
2471 }
2472
22082473 }
22092474 else if (lxev->target == g_file_atom2)
22102475 {
22112476 LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_event_selection_request: g_file_atom2");
2477
22122478 if ((g_clip_c2s.type == lxev->target) && g_clip_c2s.converted)
22132479 {
22142480 LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_event_selection_request: -------------------------------------------");
2215 clipboard_provide_selection_c2s(lxev, lxev->target);
2481 if (g_cfg->restrict_inbound_clipboard & CLIP_RESTRICT_FILE)
2482 {
2483 LOG(LOG_LEVEL_DEBUG,
2484 "inbound clipboard x-special/gnome-copied-files converted is restricted because of config");
2485 clipboard_refuse_selection(lxev);
2486 return 0;
2487 }
2488 else
2489 {
2490 clipboard_provide_selection_c2s(lxev, lxev->target);
2491 return 0;
2492 }
2493 }
2494 if (g_cfg->restrict_inbound_clipboard & CLIP_RESTRICT_FILE)
2495 {
2496 LOG(LOG_LEVEL_DEBUG,
2497 "inbound clipboard x-special/gnome-copied-files is restricted because of config");
2498 clipboard_refuse_selection(lxev);
22162499 return 0;
22172500 }
2218 g_memcpy(&g_saved_selection_req_event, lxev,
2219 sizeof(g_saved_selection_req_event));
2220 g_clip_c2s.type = g_file_atom2;
2221 g_clip_c2s.xrdp_clip_type = XRDP_CB_FILE;
2222 clipboard_send_data_request(g_file_format_id);
2223 return 0;
2501 else
2502 {
2503 g_memcpy(&g_saved_selection_req_event, lxev,
2504 sizeof(g_saved_selection_req_event));
2505 g_clip_c2s.type = g_file_atom2;
2506 g_clip_c2s.xrdp_clip_type = XRDP_CB_FILE;
2507 clipboard_send_data_request(g_file_format_id);
2508 return 0;
2509 }
22242510 }
22252511 else
22262512 {
24422728 switch (lxevent->type)
24432729 {
24442730 case SelectionNotify:
2445 if (g_cfg->restrict_outbound_clipboard == 0)
2446 {
2447 clipboard_event_selection_notify(lxevent);
2448 }
2449 else
2450 {
2451 LOG_DEVEL(LOG_LEVEL_DEBUG, "outbound clipboard is restricted because of config");
2452 return 1;
2453 }
2731 clipboard_event_selection_notify(lxevent);
24542732 break;
24552733 case SelectionRequest:
24562734 clipboard_event_selection_request(lxevent);
7676 tui32 lastWriteTimeHigh;
7777 tui32 fileSizeHigh;
7878 tui32 fileSizeLow;
79 char cFileName[256];
79 char cFileName[260 * 4]; /* Allow each UCS-16 char to become 32 bits */
8080 };
8181
8282 int clipboard_out_unicode(struct stream *s, const char *text,
8181 }
8282 #endif
8383
84 /***
85 * See MS-RDPECLIP 3.1.5.4.7
86 *
87 * Sends a failure response to a CLIPRDR_FILECONTENTS_REQUEST
88 * @param streamId Stream ID from CLIPRDR_FILECONTENTS_REQUEST
89 * @return 0 for success
90 */
91
92 static int
93 clipboard_send_filecontents_response_fail(int streamId)
94 {
95 LOG_DEVEL(LOG_LEVEL_TRACE, "clipboardn_send_filecontents_response_fail:");
96
97 struct stream *s;
98 int size;
99 int rv;
100
101 make_stream(s);
102 init_stream(s, 64);
103
104 out_uint16_le(s, CB_FILECONTENTS_RESPONSE);
105 out_uint16_le(s, CB_RESPONSE_FAIL);
106 out_uint32_le(s, 4);
107 out_uint32_le(s, streamId);
108 s_mark_end(s);
109 size = (int)(s->end - s->data);
110 rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
111 free_stream(s);
112 return rv;
113 }
114
84115 /*****************************************************************************/
85116 /* this will replace %20 or any hex with the space or correct char
86117 * returns error */
168199 clipboard_check_file(pathname);
169200 clipboard_check_file(filename);
170201 g_snprintf(full_fn, 255, "%s/%s", pathname, filename);
202
203 /*
204 * Before we look at the file, see if it's in the FUSE filesystem. If it is,
205 * we can't call normal file checking functions, as these will result in
206 * a deadlock */
207 if (xfuse_path_in_xfuse_fs(full_fn))
208 {
209 LOG(LOG_LEVEL_ERROR, "clipboard_get_file: Can't add client-side file "
210 "%s to clipboard", full_fn);
211 return 1;
212 }
171213 if (g_directory_exist(full_fn))
172214 {
173 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_get_file: file [%s] is a directory, "
174 "not supported", full_fn);
215 LOG(LOG_LEVEL_ERROR, "clipboard_get_file: file [%s] is a directory, "
216 "not supported", full_fn);
175217 flags |= CB_FILE_ATTRIBUTE_DIRECTORY;
176218 return 1;
177219 }
178220 if (!g_file_exist(full_fn))
179221 {
180 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_get_file: file [%s] does not exist",
181 full_fn);
222 LOG(LOG_LEVEL_ERROR, "clipboard_get_file: file [%s] does not exist",
223 full_fn);
182224 return 1;
183225 }
184226 else
317359 if (g_files_list == 0)
318360 {
319361 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_send_file_size: error g_files_list is nil");
362 clipboard_send_filecontents_response_fail(streamId);
320363 return 1;
321364 }
322365 cfi = (struct cb_file_info *)list_get_item(g_files_list, lindex);
323366 if (cfi == 0)
324367 {
325368 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_send_file_size: error cfi is nil");
369 clipboard_send_filecontents_response_fail(streamId);
370 return 1;
371 }
372 if (cfi->size < 0)
373 {
374 LOG(LOG_LEVEL_ERROR, "clipboard_send_file_size: error cfi->size is negative"
375 "value [%d]", cfi->size);
376 clipboard_send_filecontents_response_fail(streamId);
326377 return 1;
327378 }
328379 file_size = cfi->size;
396447 if (g_files_list == 0)
397448 {
398449 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_send_file_data: error g_files_list is nil");
450 clipboard_send_filecontents_response_fail(streamId);
399451 return 1;
400452 }
401453 cfi = (struct cb_file_info *)list_get_item(g_files_list, lindex);
402454 if (cfi == 0)
403455 {
404456 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_send_file_data: error cfi is nil");
457 clipboard_send_filecontents_response_fail(streamId);
405458 return 1;
406459 }
407460 LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_send_file_data: streamId %d lindex %d "
411464 fd = g_file_open_ex(full_fn, 1, 0, 0, 0);
412465 if (fd == -1)
413466 {
414 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_send_file_data: file open [%s] failed",
415 full_fn);
467 LOG(LOG_LEVEL_ERROR, "clipboard_send_file_data: file open [%s] failed: %s",
468 full_fn, g_get_strerror());
469 clipboard_send_filecontents_response_fail(streamId);
416470 return 1;
417471 }
418472 if (g_file_seek(fd, nPositionLow) < 0)
419473 {
420 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_send_file_data: seek error "
421 "in file: %s", full_fn);
474 LOG(LOG_LEVEL_ERROR, "clipboard_send_file_data: seek error in file [%s]: %s",
475 full_fn, g_get_strerror());
422476 g_file_close(fd);
477 clipboard_send_filecontents_response_fail(streamId);
423478 return 1;
424479 }
425480 make_stream(s);
431486 cbRequested, size);
432487 free_stream(s);
433488 g_file_close(fd);
489 clipboard_send_filecontents_response_fail(streamId);
434490 return 1;
435491 }
436492 out_uint16_le(s, CB_FILECONTENTS_RESPONSE); /* 9 */
559615 }
560616
561617 /*****************************************************************************/
562 /* read in CLIPRDR_FILEDESCRIPTOR */
618 /* read in CLIPRDR_FILEDESCRIPTOR [MS-RDPECLIP] 2.2.5.2.3.1 */
563619 static int
564620 clipboard_c2s_in_file_info(struct stream *s, struct clip_file_desc *cfd)
565621 {
566622 int num_chars;
623 int filename_bytes;
567624 int ex_bytes;
568625
626 if (!s_check_rem_and_log(s, 4 + 32 + 4 + 16 + 8 + 8 + 520,
627 "Parsing [MS-RDPECLIP] CLIPRDR_FILEDESCRIPTOR"))
628 {
629 return 1;
630 }
569631 in_uint32_le(s, cfd->flags);
570632 in_uint8s(s, 32); /* reserved1 */
571633 in_uint32_le(s, cfd->fileAttributes);
574636 in_uint32_le(s, cfd->lastWriteTimeHigh);
575637 in_uint32_le(s, cfd->fileSizeHigh);
576638 in_uint32_le(s, cfd->fileSizeLow);
577 num_chars = 256;
578 clipboard_in_unicode(s, cfd->cFileName, &num_chars);
579 ex_bytes = 512 - num_chars * 2;
580 ex_bytes -= 2;
639 num_chars = sizeof(cfd->cFileName);
640 filename_bytes = clipboard_in_unicode(s, cfd->cFileName, &num_chars);
641 ex_bytes = 520 - filename_bytes;
581642 in_uint8s(s, ex_bytes);
582 in_uint8s(s, 8); /* pad */
583643 LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_c2s_in_file_info:");
584644 LOG_DEVEL(LOG_LEVEL_DEBUG, " flags 0x%8.8x", cfd->flags);
585645 LOG_DEVEL(LOG_LEVEL_DEBUG, " fileAttributes 0x%8.8x", cfd->fileAttributes);
593653
594654 /*****************************************************************************/
595655 int
596 clipboard_c2s_in_files(struct stream *s, char *file_list)
597 {
598 int cItems;
656 clipboard_c2s_in_files(struct stream *s, char *file_list, int file_list_size,
657 const char *fprefix)
658 {
659 int citems;
599660 int lindex;
600661 int str_len;
601 int file_count;
602 struct clip_file_desc *cfd;
662 struct clip_file_desc cfd;
603663 char *ptr;
604
664 char *last; /* Last writeable char in buffer */
665 int dropped_files = 0; /* # files we can't add to buffer */
666
667 if (file_list_size < 1)
668 {
669 LOG(LOG_LEVEL_ERROR, "clipboard_c2s_in_files: No space in string");
670 return 1;
671 }
605672 if (!s_check_rem(s, 4))
606673 {
607 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_c2s_in_files: parse error");
608 return 1;
609 }
610 in_uint32_le(s, cItems);
611 if (cItems > 64 * 1024) /* sanity check */
612 {
613 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_c2s_in_files: error cItems %d too big", cItems);
674 LOG(LOG_LEVEL_ERROR, "clipboard_c2s_in_files: parse error");
675 return 1;
676 }
677 in_uint32_le(s, citems);
678 if (citems < 0 || citems > 64 * 1024) /* sanity check */
679 {
680 LOG(LOG_LEVEL_ERROR, "clipboard_c2s_in_files: "
681 "Bad number of files in list (%d)", citems);
614682 return 1;
615683 }
616684 xfuse_clear_clip_dir();
617 LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_c2s_in_files: cItems %d", cItems);
618 cfd = (struct clip_file_desc *)
619 g_malloc(sizeof(struct clip_file_desc), 0);
620 file_count = 0;
685 LOG_DEVEL(LOG_LEVEL_DEBUG, "clipboard_c2s_in_files: cItems %d", citems);
621686 ptr = file_list;
622 for (lindex = 0; lindex < cItems; lindex++)
623 {
624 g_memset(cfd, 0, sizeof(struct clip_file_desc));
625 clipboard_c2s_in_file_info(s, cfd);
626 if ((g_pos(cfd->cFileName, "\\") >= 0) ||
627 (cfd->fileAttributes & CB_FILE_ATTRIBUTE_DIRECTORY))
628 {
629 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_c2s_in_files: skipping directory not "
630 "supported [%s]", cfd->cFileName);
687 last = file_list + file_list_size - 1;
688
689 for (lindex = 0; lindex < citems; lindex++)
690 {
691 g_memset(&cfd, 0, sizeof(struct clip_file_desc));
692 if (clipboard_c2s_in_file_info(s, &cfd) != 0)
693 {
694 return 1;
695 }
696 if ((g_pos(cfd.cFileName, "\\") >= 0) ||
697 (cfd.fileAttributes & CB_FILE_ATTRIBUTE_DIRECTORY))
698 {
699 LOG(LOG_LEVEL_WARNING, "clipboard_c2s_in_files: skipping "
700 "directory not supported [%s]", cfd.cFileName);
631701 continue;
632702 }
633 if (xfuse_add_clip_dir_item(cfd->cFileName, 0, cfd->fileSizeLow, lindex) == -1)
634 {
635 LOG_DEVEL(LOG_LEVEL_ERROR, "clipboard_c2s_in_files: failed to add clip dir item");
703
704 /* Have we already run out of room in the list? */
705 if (dropped_files > 0)
706 {
707 dropped_files += 1;
636708 continue;
637709 }
638710
639 if (file_count > 0)
640 {
641 *ptr = '\n';
642 ptr++;
643 }
644 file_count++;
645
646 g_strcpy(ptr, "file://");
647 ptr += 7;
711 /* Room for this file? */
712 str_len = (ptr == file_list) ? 0 : 1; /* Delimiter */
713 str_len += g_strlen(fprefix); /* e.g. "file://" */
714 str_len += g_strlen(g_fuse_clipboard_path);
715 str_len += 1; /* '/' */
716 str_len += g_strlen(cfd.cFileName);
717 if (str_len > (last - ptr))
718 {
719 dropped_files += 1;
720 continue;
721 }
722
723 if (xfuse_add_clip_dir_item(cfd.cFileName, 0, cfd.fileSizeLow, lindex) == -1)
724 {
725 LOG(LOG_LEVEL_WARNING, "clipboard_c2s_in_files: "
726 "failed to add clip dir item %s", cfd.cFileName);
727 continue;
728 }
729
730 if (ptr > file_list)
731 {
732 *ptr++ = '\n';
733 }
734
735 str_len = g_strlen(fprefix);
736 g_strcpy(ptr, fprefix);
737 ptr += str_len;
648738
649739 str_len = g_strlen(g_fuse_clipboard_path);
650740 g_strcpy(ptr, g_fuse_clipboard_path);
651741 ptr += str_len;
652
653 *ptr = '/';
654 ptr++;
655
656 str_len = g_strlen(cfd->cFileName);
657 g_strcpy(ptr, cfd->cFileName);
742 *ptr++ = '/';
743
744 str_len = g_strlen(cfd.cFileName);
745 g_strcpy(ptr, cfd.cFileName);
658746 ptr += str_len;
659747 }
660 *ptr = 0;
661 g_free(cfd);
748 *ptr = '\0';
749
750 if (dropped_files > 0)
751 {
752 LOG(LOG_LEVEL_WARNING, "clipboard_c2s_in_files: "
753 "Dropped %d files from the clip buffer due to insufficient space",
754 dropped_files);
755 }
662756 return 0;
663757 }
2929 int
3030 clipboard_process_file_response(struct stream *s, int clip_msg_status,
3131 int clip_msg_len);
32 /**
33 * Process a CLIPRDR_FILELIST - see [MS-RDPECLIP] 2.2.5.2.3
34 *
35 * Files in the list are added to the xfs filesystem in the clipboard
36 * directory. The filenames names are added to the 'file_list' for the user.
37 * Files are prefixed with '<fprefix><clipboard_dir>/' and separated by '\n'.
38 *
39 * If the list is not big enough, whole filenames are omitted, and a warning
40 * message is logged. This is not an error.
41 *
42 * @param s Input stream containing CLIPRDR_FILELIST
43 * @param file_list Output buffer for filenames
44 * @param file_list_size Size of buffer, including space for '\0'.
45 * @param fprefix Prefix for each file in the file list (e.g. "file://")
46 *
47 * @return Zero for success.
48 */
3249 int
33 clipboard_c2s_in_files(struct stream *s, char *file_list);
50 clipboard_c2s_in_files(struct stream *s, char *file_list, int file_list_size,
51 const char *fprefix);
3452
3553 int
3654 clipboard_request_file_size(int stream_id, int lindex);
55
3756 int
3857 clipboard_request_file_data(int stream_id, int lindex, int offset,
3958 int request_bytes);
813813 /* Assume this device isn't supported by us */
814814 response_status = STATUS_NOT_SUPPORTED;
815815
816 /* Read the device data length from the stream */
817 xstream_rd_u32_le(s, device_data_len);
818
816819 switch (device_type)
817820 {
818821 case RDPDR_DTYP_FILESYSTEM:
819822 /* get device data len */
820 xstream_rd_u32_le(s, device_data_len);
821823 if (device_data_len)
822824 {
823825 xstream_rd_string(g_full_name_for_filesystem, s,
824826 device_data_len);
825827 }
826828
827 LOG_DEVEL(LOG_LEVEL_DEBUG, "device_type=FILE_SYSTEM device_id=0x%x dosname=%s "
829 LOG(LOG_LEVEL_INFO, "Detected remote drive '%s'",
830 preferred_dos_name);
831
832 LOG_DEVEL(LOG_LEVEL_DEBUG,
833 "device_type=FILE_SYSTEM device_id=0x%x dosname=%s "
828834 "device_data_len=%d full_name=%s", g_device_id,
829835 preferred_dos_name,
830836 device_data_len, g_full_name_for_filesystem);
837843 break;
838844
839845 case RDPDR_DTYP_SMARTCARD:
840 /* for smart cards, device data len always 0 */
841
842 LOG_DEVEL(LOG_LEVEL_DEBUG, "device_type=SMARTCARD device_id=0x%x dosname=%s",
846 xstream_skip_u8(s, device_data_len);
847
848 LOG(LOG_LEVEL_INFO, "Detected remote smartcard '%s'",
849 preferred_dos_name);
850
851 LOG_DEVEL(LOG_LEVEL_DEBUG,
852 "device_type=SMARTCARD device_id=0x%x dosname=%s",
843853 g_device_id, preferred_dos_name);
844854
845855 response_status = STATUS_SUCCESS;
847857 scard_device_announce(g_device_id);
848858 break;
849859
850 case RDPDR_DTYP_SERIAL:
860 default:
861 {
862 /* All other devices are unsupported */
863 const char *description =
864 (device_type == RDPDR_DTYP_SERIAL) ? "serial port" :
865 (device_type == RDPDR_DTYP_PARALLEL) ? "parallel port" :
866 (device_type == RDPDR_DTYP_PRINT) ? "printer" :
867 /* default */ "unknown device";
868
869 xstream_skip_u8(s, device_data_len);
870 LOG(LOG_LEVEL_INFO, "Detected remote %s '%s' (not supported)",
871 description, preferred_dos_name);
851872 LOG_DEVEL(LOG_LEVEL_DEBUG,
852 "device_type=SERIAL device_id=0x%x dosname=%s",
853 g_device_id, preferred_dos_name);
854 break;
855
856 case RDPDR_DTYP_PARALLEL:
857 LOG_DEVEL(LOG_LEVEL_DEBUG,
858 "device_type=PARALLEL device_id=0x%x dosname=%s",
859 g_device_id, preferred_dos_name);
860 break;
861
862 case RDPDR_DTYP_PRINT:
863 LOG_DEVEL(LOG_LEVEL_DEBUG,
864 "device_type=PRINT device_id=0x%x dosname=%s",
865 g_device_id, preferred_dos_name);
866 break;
867
868 default:
869 LOG_DEVEL(LOG_LEVEL_DEBUG,
870 "device_type=UNKNOWN device_id=0x%x dosname=%s",
871 g_device_id, preferred_dos_name);
872 break;
873 "description=%s dosname=%s device_id=0x%x",
874 description, preferred_dos_name, g_device_id);
875 }
876 break;
873877 }
874878
875879 /* Tell the client wheth or not we're supporting this one */
3333 #include "sesman.h"
3434 #include "log.h"
3535 #include "string_calls.h"
36 #include "chansrv/chansrv_common.h"
3637
3738 /***************************************************************************//**
3839 *
161162 return 0;
162163 }
163164
165 /*
166 Map clipboard strings into bitmask values.
167 Duplicated definition exists in chansrv_config,
168 because it avoids build failure for xrdp-sesman and xrdp-sesrun.
169 It should be unified in the future.
170 */
171 static const struct bitmask_string clip_restrict_map[] =
172 {
173 { CLIP_RESTRICT_TEXT, "text"},
174 { CLIP_RESTRICT_FILE, "file"},
175 { CLIP_RESTRICT_IMAGE, "image"},
176 { CLIP_RESTRICT_ALL, "all"},
177 { CLIP_RESTRICT_NONE, "none"},
178 /* Compatibility values */
179 { CLIP_RESTRICT_ALL, "true"},
180 { CLIP_RESTRICT_ALL, "yes"},
181 { CLIP_RESTRICT_NONE, "false"},
182 BITMASK_STRING_END_OF_LIST
183 };
184
164185 /***************************************************************************//**
165186 *
166187 * @brief Reads sesman [Security] configuration section
189210 sc->ts_users_enable = 0;
190211 sc->ts_admins_enable = 0;
191212 sc->restrict_outbound_clipboard = 0;
213 sc->restrict_inbound_clipboard = 0;
192214
193215 file_read_section(file, SESMAN_CFG_SECURITY, param_n, param_v);
194216
230252
231253 if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_RESTRICT_OUTBOUND_CLIPBOARD))
232254 {
233 sc->restrict_outbound_clipboard = g_text2bool((char *)list_get_item(param_v, i));
255 char unrecognised[256];
256 sc->restrict_outbound_clipboard =
257 g_str_to_bitmask((const char *)list_get_item(param_v, i),
258 clip_restrict_map, ",",
259 unrecognised, sizeof(unrecognised));
260 if (unrecognised[0] != '\0')
261 {
262 LOG(LOG_LEVEL_WARNING,
263 "Unrecognised tokens parsing 'RestrictOutboundClipboard' %s",
264 unrecognised);
265 }
266 }
267 if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_RESTRICT_INBOUND_CLIPBOARD))
268 {
269 char unrecognised[256];
270 sc->restrict_inbound_clipboard =
271 g_str_to_bitmask((const char *)list_get_item(param_v, i),
272 clip_restrict_map, ",",
273 unrecognised, sizeof(unrecognised));
274 if (unrecognised[0] != '\0')
275 {
276 LOG(LOG_LEVEL_WARNING,
277 "Unrecognised tokens parsing 'RestrictInboundClipboard' %s",
278 unrecognised);
279 }
234280 }
235281
236282 }
552598
553599 /* Security configuration */
554600 g_writeln("Security configuration:");
555 g_writeln(" AllowRootLogin: %d", sc->allow_root);
556 g_writeln(" MaxLoginRetry: %d", sc->login_retry);
557 g_writeln(" AlwaysGroupCheck: %d", sc->ts_always_group_check);
558 g_writeln(" RestrictOutboundClipboard: %d", sc->restrict_outbound_clipboard);
559
560 g_printf( " TSUsersGroup: ");
601 g_writeln(" AllowRootLogin: %d", sc->allow_root);
602 g_writeln(" MaxLoginRetry: %d", sc->login_retry);
603 g_writeln(" AlwaysGroupCheck: %d", sc->ts_always_group_check);
604 if (sc->restrict_outbound_clipboard == CLIP_RESTRICT_NONE)
605 {
606 g_writeln(" RestrictOutboundClipboard: %s", "none");
607 }
608 else if (sc->restrict_outbound_clipboard == CLIP_RESTRICT_ALL)
609 {
610 g_writeln(" RestrictOutboundClipboard: %s", "all");
611 }
612 else
613 {
614 char buf[256];
615 g_bitmask_to_str(sc->restrict_outbound_clipboard,
616 clip_restrict_map, ',', buf, sizeof(buf));
617 g_writeln(" RestrictOutboundClipboard: %s", buf);
618 }
619 if (sc->restrict_inbound_clipboard == CLIP_RESTRICT_NONE)
620 {
621 g_writeln(" RestrictInboundClipboard: %s", "none");
622 }
623 else if (sc->restrict_inbound_clipboard == CLIP_RESTRICT_ALL)
624 {
625 g_writeln(" RestrictInboundClipboard: %s", "all");
626 }
627 else
628 {
629 char buf[256];
630 g_bitmask_to_str(sc->restrict_inbound_clipboard,
631 clip_restrict_map, ',', buf, sizeof(buf));
632 g_writeln(" RestrictInboundClipboard: %s", buf);
633 }
634
635 g_printf( " TSUsersGroup: ");
561636 if (sc->ts_users_enable)
562637 {
563638 g_printf("%d", sc->ts_users);
568643 }
569644 g_writeln("%s", "");
570645
571 g_printf( " TSAdminsGroup: ");
646 g_printf( " TSAdminsGroup: ");
572647 if (sc->ts_admins_enable)
573648 {
574649 g_printf("%d", sc->ts_admins);
6060 #define SESMAN_CFG_SEC_ADM_GROUP "TerminalServerAdmins"
6161 #define SESMAN_CFG_SEC_ALWAYSGROUPCHECK "AlwaysGroupCheck"
6262 #define SESMAN_CFG_SEC_RESTRICT_OUTBOUND_CLIPBOARD "RestrictOutboundClipboard"
63 #define SESMAN_CFG_SEC_RESTRICT_INBOUND_CLIPBOARD "RestrictInboundClipboard"
6364
6465 #define SESMAN_CFG_SESSIONS "Sessions"
6566 #define SESMAN_CFG_SESS_MAX "MaxSessions"
133134 * @brief if the clipboard should be enforced restricted. If true only allow client -> server, not vice versa.
134135 */
135136 int restrict_outbound_clipboard;
137
138 /**
139 * @var restrict_inbound_clipboard
140 * @brief if the clipboard should be enforced restricted. If true only allow server -> client, not vice versa.
141 */
142 int restrict_inbound_clipboard;
136143 };
137144
138145 /**
3434 #include "sesman.h"
3535 #include "ssl_calls.h"
3636 #include "string_calls.h"
37
38 extern unsigned char g_fixedkey[8]; /* in sesman.c */
39 extern struct config_sesman *g_cfg; /* in sesman.c */
4037
4138 /******************************************************************************/
4239 int
5451 /* create password hash from password */
5552 passwd_bytes = g_strlen(passwd);
5653 sha1 = ssl_sha1_info_create();
54 ssl_sha1_clear(sha1);
5755 ssl_sha1_transform(sha1, "xrdp_vnc", 8);
5856 ssl_sha1_transform(sha1, passwd, passwd_bytes);
5957 ssl_sha1_transform(sha1, passwd, passwd_bytes);
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
210210 unique=`for i in $$list; do \
211211 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
212212 done | $(am__uniquify_input)`
213 ETAGS = etags
214 CTAGS = ctags
215213 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
216214 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
217215 ACLOCAL = @ACLOCAL@
229227 CHECK_LIBS = @CHECK_LIBS@
230228 CPP = @CPP@
231229 CPPFLAGS = @CPPFLAGS@
230 CSCOPE = @CSCOPE@
231 CTAGS = @CTAGS@
232232 CYGPATH_W = @CYGPATH_W@
233233 DEFS = @DEFS@
234234 DEPDIR = @DEPDIR@
240240 ECHO_N = @ECHO_N@
241241 ECHO_T = @ECHO_T@
242242 EGREP = @EGREP@
243 ETAGS = @ETAGS@
243244 EXEEXT = @EXEEXT@
244245 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
245246 FDKAAC_LIBS = @FDKAAC_LIBS@
249250 FUSE_CFLAGS = @FUSE_CFLAGS@
250251 FUSE_LIBS = @FUSE_LIBS@
251252 GREP = @GREP@
253 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
254 IMLIB2_LIBS = @IMLIB2_LIBS@
252255 INSTALL = @INSTALL@
253256 INSTALL_DATA = @INSTALL_DATA@
254257 INSTALL_PROGRAM = @INSTALL_PROGRAM@
576579
577580 distclean-tags:
578581 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
579
580582 distdir: $(BUILT_SOURCES)
581583 $(MAKE) $(AM_MAKEFLAGS) distdir-am
582584
2828 #endif
2929
3030 #include "libscp_connection.h"
31 #include "string_calls.h"
32 #include "trans.h"
3133
32 //extern struct log_config* s_log;
34 /*****************************************************************************/
35 struct trans *
36 scp_connect(const char *host, const char *port,
37 tis_term term_func,
38 ttrans_data_in data_in_func,
39 void *callback_data)
40 {
41 struct trans *t = trans_create(TRANS_MODE_TCP, 8192, 8192);
42 int index;
3343
34 struct trans *
35 scp_trans_create(int sck)
44 if (host == NULL)
45 {
46 host = "localhost";
47 }
48
49 if (port == NULL)
50 {
51 port = "3350";
52 }
53
54 t->is_term = term_func;
55
56 t->trans_data_in = data_in_func;
57 t->header_size = 8;
58 t->no_stream_init_on_data_in = 1;
59 t->callback_data = callback_data;
60
61 /* try to connect up to 4 times
62 *
63 * term_func can be NULL, so check before calling it */
64 index = 4;
65 while (trans_connect(t, host, port, 3000) != 0 &&
66 !(term_func && term_func()) &&
67 --index > 0)
68 {
69 g_sleep(1000);
70 LOG_DEVEL(LOG_LEVEL_DEBUG, "Connect failed. Trying again...");
71 }
72
73 if (t->status != TRANS_STATUS_UP)
74 {
75 trans_delete(t);
76 t = NULL;
77 }
78
79 return t;
80 }
81
82 /*****************************************************************************/
83
84 const char *
85 scp_client_state_to_str(enum SCP_CLIENT_STATES_E e)
3686 {
37 struct trans *result = trans_create(TRANS_MODE_TCP, 8192, 8192);
38 if (result != NULL)
87 const char *result = "SCP_CLIENT_STATE_????";
88
89 /* Some compilers will warn if this switch is missing states */
90 switch (e)
3991 {
40 result->sck = sck;
92 case SCP_CLIENT_STATE_OK:
93 result = "SCP_CLIENT_STATE_OK";
94 break;
95 case SCP_CLIENT_STATE_NETWORK_ERR:
96 result = "SCP_CLIENT_STATE_NETWORK_ERR";
97 break;
98 case SCP_CLIENT_STATE_VERSION_ERR:
99 result = "SCP_CLIENT_STATE_VERSION_ERR";
100 break;
101 case SCP_CLIENT_STATE_SEQUENCE_ERR:
102 result = "SCP_CLIENT_STATE_SEQUENCE_ERR";
103 break;
104 case SCP_CLIENT_STATE_SIZE_ERR:
105 result = "SCP_CLIENT_STATE_SIZE_ERR";
106 break;
107 case SCP_CLIENT_STATE_INTERNAL_ERR:
108 result = "SCP_CLIENT_STATE_INTERNAL_ERR";
109 break;
110 case SCP_CLIENT_STATE_SESSION_LIST:
111 result = "SCP_CLIENT_STATE_SESSION_LIST";
112 break;
113 case SCP_CLIENT_STATE_LIST_OK:
114 result = "SCP_CLIENT_STATE_LIST_OK";
115 break;
116 case SCP_CLIENT_STATE_RESEND_CREDENTIALS:
117 result = "SCP_CLIENT_STATE_RESEND_CREDENTIALS";
118 break;
119 case SCP_CLIENT_STATE_CONNECTION_DENIED:
120 result = "SCP_CLIENT_STATE_CONNECTION_DENIED";
121 break;
122 case SCP_CLIENT_STATE_PWD_CHANGE_REQ:
123 result = "SCP_CLIENT_STATE_PWD_CHANGE_REQ";
124 break;
125 case SCP_CLIENT_STATE_RECONNECT_SINGLE:
126 result = "SCP_CLIENT_STATE_RECONNECT_SINGLE";
127 break;
128 case SCP_CLIENT_STATE_SELECTION_CANCEL:
129 result = "SCP_CLIENT_STATE_SELECTION_CANCEL";
130 break;
131 case SCP_CLIENT_STATE_END:
132 result = "SCP_CLIENT_STATE_END";
133 break;
41134 }
42135
43136 return result;
3030
3131 /**
3232 *
33 * @brief creates a new SCP transport object
34 * @param sck the connection socket
35 *
36 * This is a convenience function which calls trans_create() with the
37 * correct parameters.
33 * @brief creates a new SCP connection
34 * @param host Hostname to connect to (NULL for default)
35 * @param port Port to connect to (NULL for default)
36 * @param term_func Transport termination function (or NULL)
37 * @param data_in_func Transport 'data in' function
38 * @param callback_data Closure data for data in function
3839 *
3940 * Returned object can be freed with trans_delete()
4041 *
4243 *
4344 */
4445 struct trans *
45 scp_trans_create(int sck);
46 scp_connect(const char *host, const char *port,
47 tis_term term_func,
48 ttrans_data_in data_in_func,
49 void *callback_data);
50
51 /**
52 * @brief Maps SCP_CLIENT_TYPES_E to a string
53 * @param e
54 *
55 * @return Pointer to a string
56 *
57 */
58 const char *scp_client_state_to_str(enum SCP_CLIENT_STATES_E e);
4659
4760 #endif
306306
307307 /*******************************************************************/
308308 int
309 scp_session_set_client_ip(struct SCP_SESSION *s, const char *str)
310 {
311 if (0 == str)
312 {
313 LOG(LOG_LEVEL_WARNING, "[session:%d] set_client_ip: null ip", __LINE__);
314 return 1;
315 }
316
317 if (0 != s->client_ip)
318 {
319 g_free(s->client_ip);
320 }
321
322 s->client_ip = g_strdup(str);
323
324 if (0 == s->client_ip)
325 {
326 LOG(LOG_LEVEL_WARNING, "[session:%d] set_client_ip: strdup error", __LINE__);
309 scp_session_set_connection_description(struct SCP_SESSION *s, const char *str)
310 {
311 if (0 == str)
312 {
313 LOG(LOG_LEVEL_WARNING, "[session:%d] set_connection_description: null description", __LINE__);
314 return 1;
315 }
316
317 if (0 != s->connection_description)
318 {
319 g_free(s->connection_description);
320 }
321
322 s->connection_description = g_strdup(str);
323
324 if (0 == s->connection_description)
325 {
326 LOG(LOG_LEVEL_WARNING, "[session:%d] set_connection_description: strdup error", __LINE__);
327327 return 1;
328328 }
329329
413413
414414 /*******************************************************************/
415415 int
416 scp_session_set_guid(struct SCP_SESSION *s, const tui8 *guid)
416 scp_session_set_guid(struct SCP_SESSION *s, const struct guid *guid)
417417 {
418418 if (0 == guid)
419419 {
421421 return 1;
422422 }
423423
424 g_memcpy(s->guid, guid, 16);
424 s->guid = *guid;
425425
426426 return 0;
427427 }
438438 g_free(s->domain);
439439 g_free(s->program);
440440 g_free(s->directory);
441 g_free(s->client_ip);
441 g_free(s->connection_description);
442442 g_free(s->errstr);
443443 g_free(s);
444444 }
463463 result->domain = g_strdup(s->domain);
464464 result->program = g_strdup(s->program);
465465 result->directory = g_strdup(s->directory);
466 result->client_ip = g_strdup(s->client_ip);
466 result->connection_description = g_strdup(s->connection_description);
467467
468468 /* Did all the string copies succeed? */
469469 if ((s->username != NULL && result->username == NULL) ||
473473 (s->domain != NULL && result->domain == NULL) ||
474474 (s->program != NULL && result->program == NULL) ||
475475 (s->directory != NULL && result->directory == NULL) ||
476 (s->client_ip != NULL && result->client_ip == NULL))
476 (s->connection_description != NULL && result->connection_description == NULL))
477477 {
478478 scp_session_destroy(result);
479479 result = NULL;
8484 scp_session_set_directory(struct SCP_SESSION *s, const char *str);
8585
8686 int
87 scp_session_set_client_ip(struct SCP_SESSION *s, const char *str);
87 scp_session_set_connection_description(struct SCP_SESSION *s, const char *str);
8888
8989 int
9090 scp_session_set_hostname(struct SCP_SESSION *s, const char *str);
9999 scp_session_set_errstr(struct SCP_SESSION *s, const char *str);
100100
101101 int
102 scp_session_set_guid(struct SCP_SESSION *s, const tui8 *guid);
102 scp_session_set_guid(struct SCP_SESSION *s, const struct guid *guid);
103103
104104 /**
105105 *
2929 #include "os_calls.h"
3030 #include "parse.h"
3131 #include "arch.h"
32 #include "guid.h"
3233 #include "log.h"
3334 #include "trans.h"
3435
8384 char *domain;
8485 char *program;
8586 char *directory;
86 char *client_ip;
87 tui8 guid[16];
87 char *connection_description;
88 struct guid guid;
8889 /* added for state */
8990 int current_cmd;
9091 int return_sid;
4646 * Buffer is null-terminated on success
4747 *
4848 * @param s Input stream
49 * @param [out] Output buffer (must be >= (STRING16_MAX_LEN+1) chars)
50 * @param param Parameter we're reading
49 * @param [out] str Output buffer (must be >= (STRING16_MAX_LEN+1) chars)
50 * @param prefix Logging prefix for errors
5151 * @return != 0 if string read OK
5252 */
5353 static
54 int in_string16(struct stream *s, char str[], const char *param)
54 int in_string16(struct stream *s, char str[], const char *prefix)
5555 {
5656 int result;
57
58 if (!s_check_rem(s, 2))
59 {
60 LOG(LOG_LEVEL_WARNING, "connection aborted: %s len missing", param);
61 result = 0;
62 }
63 else
64 {
65 unsigned int sz;
66
57 unsigned int sz;
58
59 if ((result = s_check_rem_and_log(s, 2, prefix)) != 0)
60 {
6761 in_uint16_be(s, sz);
6862 if (sz > STRING16_MAX_LEN)
6963 {
70 LOG(LOG_LEVEL_WARNING,
71 "connection aborted: %s too long (%u chars)", param, sz);
64 LOG(LOG_LEVEL_ERROR, "%s input string too long (%u chars)",
65 prefix, sz);
7266 result = 0;
7367 }
68 else if ((result = s_check_rem_and_log(s, sz, prefix)) != 0)
69 {
70 in_uint8a(s, str, sz);
71 str[sz] = '\0';
72 }
73 }
74 return result;
75 }
76
77 /**
78 * Writes a big-endian uint16 followed by a string into a buffer
79 *
80 * @param s Output stream
81 * @param[in] str output string (must be <= (STRING16_MAX_LEN+1) chars)
82 * @param param Parameter we're sending
83 * @return != 0 if string written OK
84 */
85 static
86 int out_string16(struct stream *out_s, const char *str, const char *prefix)
87 {
88 int result;
89
90 unsigned int sz = g_strlen(str);
91 if (sz > STRING16_MAX_LEN)
92 {
93 LOG(LOG_LEVEL_WARNING, "%s String too long (%u chars)", prefix, sz);
94 result = 0;
95 }
96 else if ((result = s_check_rem_out_and_log(out_s, 2 + sz, prefix)) != 0)
97 {
98 out_uint16_be(out_s, sz);
99 out_uint8a(out_s, str, sz);
100 }
101
102 return result;
103 }
104
105 /***
106 * Terminates a V0 request, adds the header and sends it.
107 *
108 * On entry, channel_hdr on the transport output stream is expected to
109 * contain the location for the SCP header
110 *
111 * @param atrans Transport for the message
112 * @return error code
113 */
114 static enum SCP_CLIENT_STATES_E
115 terminate_and_send_v0_request(struct trans *atrans)
116 {
117 enum SCP_CLIENT_STATES_E e;
118
119 struct stream *s = atrans->out_s;
120 s_mark_end(s);
121 s_pop_layer(s, channel_hdr);
122
123 /* version */
124 out_uint32_be(s, 0);
125 /* size */
126 out_uint32_be(s, s->end - s->data);
127
128 if (trans_force_write_s(atrans, s) == 0)
129 {
130 e = SCP_CLIENT_STATE_OK;
131 }
132 else
133 {
134 LOG(LOG_LEVEL_ERROR, "connection aborted: network error");
135 e = SCP_CLIENT_STATE_NETWORK_ERR;
136 }
137
138 return e;
139 }
140
141 /* client API */
142 /******************************************************************************/
143 enum SCP_CLIENT_STATES_E
144 scp_v0c_create_session_request(struct trans *atrans,
145 const char *username,
146 const char *password,
147 unsigned short code,
148 unsigned short width,
149 unsigned short height,
150 unsigned short bpp,
151 const char *domain,
152 const char *shell,
153 const char *directory,
154 const char *client_ip)
155 {
156 enum SCP_CLIENT_STATES_E e;
157
158 struct stream *s = trans_get_out_s(atrans, 8192);
159 s_push_layer(s, channel_hdr, 8);
160
161 out_uint16_be(s, code);
162 if (!out_string16(s, username, "Session username") ||
163 !out_string16(s, password, "Session passwd"))
164 {
165 e = SCP_CLIENT_STATE_SIZE_ERR;
166 }
167 else
168 {
169 out_uint16_be(s, width);
170 out_uint16_be(s, height);
171 out_uint16_be(s, bpp);
172 if (!out_string16(s, domain, "Session domain") ||
173 !out_string16(s, shell, "Session shell") ||
174 !out_string16(s, directory, "Session directory") ||
175 !out_string16(s, client_ip, "Session client IP"))
176 {
177 e = SCP_CLIENT_STATE_SIZE_ERR;
178 }
74179 else
75180 {
76 result = s_check_rem(s, sz);
77 if (!result)
78 {
79 LOG(LOG_LEVEL_WARNING, "connection aborted: %s data missing", param);
181 e = terminate_and_send_v0_request(atrans);
182 }
183 }
184
185 return e;
186 }
187
188 enum SCP_CLIENT_STATES_E
189 scp_v0c_gateway_request(struct trans *atrans,
190 const char *username,
191 const char *password)
192 {
193 enum SCP_CLIENT_STATES_E e;
194
195 struct stream *s = trans_get_out_s(atrans, 500);
196 s_push_layer(s, channel_hdr, 8);
197
198 out_uint16_be(s, SCP_GW_AUTHENTICATION);
199 if (!out_string16(s, username, "Gateway username") ||
200 !out_string16(s, password, "Gateway passwd"))
201 {
202 e = SCP_CLIENT_STATE_SIZE_ERR;
203 }
204 else
205 {
206 e = terminate_and_send_v0_request(atrans);
207 }
208
209 return e;
210 }
211
212 /**************************************************************************//**
213 * Is a reply available from the other end?
214 *
215 * Returns true if it is, or if an error has occurred which needs handling.
216 *
217 * @param trans Transport to be polled
218 * @return True if scp_v0c_get_reply() should be called
219 */
220 int
221 scp_v0c_reply_available(struct trans *trans)
222 {
223 int result = 1;
224 if (trans != NULL && trans->status == TRANS_STATUS_UP)
225 {
226 /* Have we read enough data from the stream? */
227 if ((trans->in_s->end - trans->in_s->data) < trans->header_size)
228 {
229 result = 0;
230 }
231 else if (trans->extra_flags == 0)
232 {
233 int version;
234 int size;
235
236 /* We've read the header only */
237 in_uint32_be(trans->in_s, version);
238 in_uint32_be(trans->in_s, size);
239
240 if (version != 0)
241 {
242 LOG(LOG_LEVEL_ERROR, "Unexpected version number %d from SCP",
243 version);
244 trans->status = TRANS_STATUS_DOWN;
245 }
246 else if (size <= 8 || size > trans->in_s->size)
247 {
248 LOG(LOG_LEVEL_ERROR,
249 "Invalid V0 message length %d from SCP",
250 size);
251 trans->status = TRANS_STATUS_DOWN;
80252 }
81253 else
82254 {
83 in_uint8a(s, str, sz);
84 str[sz] = '\0';
85 }
86 }
87 }
255 /* Read the rest of the message */
256 trans->header_size = size;
257 trans->extra_flags = 1;
258 result = 0;
259 }
260 }
261 }
262
263
88264 return result;
89265 }
90 /* client API */
91 #if 0
92 /******************************************************************************/
93 static enum SCP_CLIENT_STATES_E
94 scp_v0c_connect(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
95 {
96 tui32 version;
97 int size;
98 tui16 sz;
99
100 init_stream(c->in_s, c->in_s->size);
101 init_stream(c->out_s, c->in_s->size);
102
103 LOG_DEVEL(LOG_LEVEL_DEBUG, "starting connection");
104 g_tcp_set_non_blocking(c->in_sck);
105 g_tcp_set_no_delay(c->in_sck);
106 s_push_layer(c->out_s, channel_hdr, 8);
107
108 /* code */
109 if (s->type == SCP_SESSION_TYPE_XVNC)
110 {
111 out_uint16_be(c->out_s, 0);
112 }
113 else if (s->type == SCP_SESSION_TYPE_XRDP)
114 {
115 out_uint16_be(c->out_s, 10);
116 }
117 else if (s->type == SCP_SESSION_TYPE_XORG)
118 {
119 out_uint16_be(c->out_s, 20);
266 /**************************************************************************//**
267 * Get a reply from the V0 transport
268 *
269 * Only call this once scp_v0c_reply_available() has returned true
270 *
271 * After a successful call, the transport is ready to be used for the
272 * next incoming message
273 *
274 * @param trans Transport containing the reply
275 * @param[out] reply, provided result is SCP_CLIENT_STATE_OK
276 * @return SCP client state
277 */
278 enum SCP_CLIENT_STATES_E
279 scp_v0c_get_reply(struct trans *trans, struct scp_v0_reply_type *reply)
280 {
281 enum SCP_CLIENT_STATES_E e;
282
283 if (trans == NULL || trans->status != TRANS_STATUS_UP)
284 {
285 e = SCP_CLIENT_STATE_NETWORK_ERR;
286 }
287 else if (!s_check_rem_and_log(trans->in_s, 6, "SCPV0 reply"))
288 {
289 trans->status = TRANS_STATUS_DOWN;
290 e = SCP_CLIENT_STATE_NETWORK_ERR;
120291 }
121292 else
122293 {
123 LOG(LOG_LEVEL_WARNING, "connection aborted: network error");
124 return SCP_CLIENT_STATE_INTERNAL_ERR;
125 }
126
127 sz = g_strlen(s->username);
128 if (sz > STRING16_MAX_LEN)
129 {
130 LOG(LOG_LEVEL_WARNING, "connection aborted: username too long");
131 return SCP_CLIENT_STATE_SIZE_ERR;
132 }
133 out_uint16_be(c->out_s, sz);
134 out_uint8a(c->out_s, s->username, sz);
135
136 sz = g_strlen(s->password);
137 if (sz > STRING16_MAX_LEN)
138 {
139 LOG(LOG_LEVEL_WARNING, "connection aborted: password too long");
140 return SCP_CLIENT_STATE_SIZE_ERR;
141 }
142 out_uint16_be(c->out_s, sz);
143 out_uint8a(c->out_s, s->password, sz);
144 out_uint16_be(c->out_s, s->width);
145 out_uint16_be(c->out_s, s->height);
146 out_uint16_be(c->out_s, s->bpp);
147
148 s_mark_end(c->out_s);
149 s_pop_layer(c->out_s, channel_hdr);
150
151 /* version */
152 out_uint32_be(c->out_s, 0);
153 /* size */
154 out_uint32_be(c->out_s, c->out_s->end - c->out_s->data);
155
156 if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data))
157 {
158 LOG(LOG_LEVEL_WARNING, "connection aborted: network error");
159 return SCP_CLIENT_STATE_NETWORK_ERR;
160 }
161
162 if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
163 {
164 LOG(LOG_LEVEL_WARNING, "connection aborted: network error");
165 return SCP_CLIENT_STATE_NETWORK_ERR;
166 }
167
168 in_uint32_be(c->in_s, version);
169
170 if (0 != version)
171 {
172 LOG(LOG_LEVEL_WARNING, "connection aborted: version error");
173 return SCP_CLIENT_STATE_VERSION_ERR;
174 }
175
176 in_uint32_be(c->in_s, size);
177
178 if (size < (8 + 2 + 2 + 2) || size > SCP_MAX_MESSAGE_SIZE)
179 {
180 LOG(LOG_LEVEL_WARNING, "connection aborted: msg size = %d", size);
181 return SCP_CLIENT_STATE_SIZE_ERR;
182 }
183
184 /* getting payload */
185 init_stream(c->in_s, size - 8);
186
187 if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
188 {
189 LOG(LOG_LEVEL_WARNING, "connection aborted: network error");
190 return SCP_CLIENT_STATE_NETWORK_ERR;
191 }
192
193 c->in_s->end = c->in_s->data + (size - 8);
194
195 /* check code */
196 in_uint16_be(c->in_s, sz);
197
198 if (3 != sz)
199 {
200 LOG(LOG_LEVEL_WARNING, "connection aborted: sequence error");
201 return SCP_CLIENT_STATE_SEQUENCE_ERR;
202 }
203
204 /* message payload */
205 in_uint16_be(c->in_s, sz);
206
207 if (1 != sz)
208 {
209 LOG(LOG_LEVEL_WARNING, "connection aborted: connection denied");
210 return SCP_CLIENT_STATE_CONNECTION_DENIED;
211 }
212
213 in_uint16_be(c->in_s, sz);
214 s->display = sz;
215
216 LOG_DEVEL(LOG_LEVEL_DEBUG, "connection terminated");
217 return SCP_CLIENT_STATE_END;
218 }
219 #endif
294 int word1;
295 int word2;
296 int word3;
297 in_uint16_be(trans->in_s, word1);
298 in_uint16_be(trans->in_s, word2);
299 in_uint16_be(trans->in_s, word3);
300
301 if (word1 == SCP_GW_AUTHENTICATION)
302 {
303 reply->is_gw_auth_response = 1;
304 reply->auth_result = word2;
305 reply->display = 0;
306 guid_clear(&reply->guid);
307 }
308 else
309 {
310 reply->is_gw_auth_response = 0;
311 reply->auth_result = word2;
312 reply->display = word3;
313 if (s_check_rem(trans->in_s, GUID_SIZE))
314 {
315 in_uint8a(trans->in_s, reply->guid.g, GUID_SIZE);
316 }
317 else
318 {
319 guid_clear(&reply->guid);
320 }
321 }
322
323 e = SCP_CLIENT_STATE_OK;
324
325 /* Reset the input stream for the next message */
326 trans->header_size = 8;
327 trans->extra_flags = 0;
328 init_stream(trans->in_s, 0);
329 }
330
331 return e;
332 }
220333
221334 /* server API */
222335
264377 scp_session_set_type(session, session_type);
265378
266379 /* reading username */
267 if (!in_string16(in_s, buf, "username"))
380 if (!in_string16(in_s, buf, "Session username"))
268381 {
269382 return SCP_SERVER_STATE_SIZE_ERR;
270383 }
275388 }
276389
277390 /* reading password */
278 if (!in_string16(in_s, buf, "passwd"))
391 if (!in_string16(in_s, buf, "Session passwd"))
279392 {
280393 return SCP_SERVER_STATE_SIZE_ERR;
281394 }
296409 in_uint16_be(in_s, height);
297410 scp_session_set_height(session, height);
298411 in_uint16_be(in_s, bpp);
299 if (session_type == SCP_SESSION_TYPE_XORG && bpp != 24)
300 {
301 LOG(LOG_LEVEL_WARNING,
302 "Setting bpp to 24 from %d for Xorg session", bpp);
412 if (session_type == SCP_SESSION_TYPE_XORG)
413 {
414 /* Client value is ignored */
303415 bpp = 24;
304416 }
305417 if (0 != scp_session_set_bpp(session, (tui8)bpp))
312424 if (s_check_rem(in_s, 2))
313425 {
314426 /* reading domain */
315 if (!in_string16(in_s, buf, "domain"))
427 if (!in_string16(in_s, buf, "Session domain"))
316428 {
317429 return SCP_SERVER_STATE_SIZE_ERR;
318430 }
326438 if (s_check_rem(in_s, 2))
327439 {
328440 /* reading program */
329 if (!in_string16(in_s, buf, "program"))
441 if (!in_string16(in_s, buf, "Session program"))
330442 {
331443 return SCP_SERVER_STATE_SIZE_ERR;
332444 }
340452 if (s_check_rem(in_s, 2))
341453 {
342454 /* reading directory */
343 if (!in_string16(in_s, buf, "directory"))
455 if (!in_string16(in_s, buf, "Session directory"))
344456 {
345457 return SCP_SERVER_STATE_SIZE_ERR;
346458 }
354466 if (s_check_rem(in_s, 2))
355467 {
356468 /* reading client IP address */
357 if (!in_string16(in_s, buf, "client IP"))
469 if (!in_string16(in_s, buf, "connection description"))
358470 {
359471 return SCP_SERVER_STATE_SIZE_ERR;
360472 }
361473 if (buf[0] != '\0')
362474 {
363 scp_session_set_client_ip(session, buf);
475 scp_session_set_connection_description(session, buf);
364476 }
365477 }
366478 }
368480 {
369481 scp_session_set_type(session, SCP_GW_AUTHENTICATION);
370482 /* reading username */
371 if (!in_string16(in_s, buf, "username"))
483 if (!in_string16(in_s, buf, "Session username"))
372484 {
373485 return SCP_SERVER_STATE_SIZE_ERR;
374486 }
380492 }
381493
382494 /* reading password */
383 if (!in_string16(in_s, buf, "passwd"))
495 if (!in_string16(in_s, buf, "Session passwd"))
384496 {
385497 return SCP_SERVER_STATE_SIZE_ERR;
386498 }
402514
403515 /******************************************************************************/
404516 enum SCP_SERVER_STATES_E
405 scp_v0s_allow_connection(struct trans *atrans, SCP_DISPLAY d, const tui8 *guid)
517 scp_v0s_allow_connection(struct trans *atrans, SCP_DISPLAY d,
518 const struct guid *guid)
406519 {
407520 int msg_size;
408521 struct stream *out_s;
409522
410523 out_s = trans_get_out_s(atrans, 0);
411 msg_size = guid == 0 ? 14 : 14 + 16;
524 msg_size = guid_is_set(guid) ? 14 + GUID_SIZE : 14;
412525 out_uint32_be(out_s, 0); /* version */
413526 out_uint32_be(out_s, msg_size); /* size */
414527 out_uint16_be(out_s, 3); /* cmd */
416529 out_uint16_be(out_s, d); /* data */
417530 if (msg_size > 14)
418531 {
419 out_uint8a(out_s, guid, 16);
532 out_uint8a(out_s, guid->g, GUID_SIZE);
420533 }
421534 s_mark_end(out_s);
422535 if (0 != trans_write_copy(atrans))
2727 #define LIBSCP_V0_H
2828
2929 #include "libscp.h"
30 #include "guid.h"
3031
31 /*TODO : Replace this (unused) function with something that can be used
32 * by xrdp_mm.c and sesrun.c */
33 #if 0
3432 /* client API */
35 /**
36 *
37 * @brief connects to sesman using scp v0
38 * @param c connection descriptor
39 * @param s session descriptor
40 * @param d display
41 *
33
34 struct scp_v0_reply_type
35 {
36 /**
37 * True if this is a reply to a gateway authentication request
38 */
39 int is_gw_auth_response;
40
41 /**
42 * Authentication result. PAM code for gateway request, boolean otherwise
43 */
44 int auth_result;
45
46 /**
47 * Display number for successful non-gateway requests
48 */
49 int display;
50
51 /**
52 * GUID for successful non-gateway requests
53 */
54 struct guid guid;
55 };
56
57 enum SCP_CLIENT_STATES_E
58 scp_v0c_gateway_request(struct trans *atrans,
59 const char *username,
60 const char *password);
61
62 /*
63 * Note client bpp is ignored by the sesman for Xorg sessions
4264 */
4365 enum SCP_CLIENT_STATES_E
44 scp_v0c_connect(struct SCP_CONNECTION *c, struct SCP_SESSION *s);
45 #endif
66 scp_v0c_create_session_request(struct trans *atrans,
67 const char *username,
68 const char *password,
69 unsigned short code,
70 unsigned short width,
71 unsigned short height,
72 unsigned short bpp,
73 const char *domain,
74 const char *shell,
75 const char *directory,
76 const char *client_ip);
77
78 int
79 scp_v0c_reply_available(struct trans *atrans);
80
81 enum SCP_CLIENT_STATES_E
82 scp_v0c_get_reply(struct trans *atrans, struct scp_v0_reply_type *reply);
4683
4784 /* server API */
4885 /**
6299 *
63100 */
64101 enum SCP_SERVER_STATES_E
65 scp_v0s_allow_connection(struct trans *atrans, SCP_DISPLAY d, const tui8 *guid);
102 scp_v0s_allow_connection(struct trans *atrans, SCP_DISPLAY d,
103 const struct guid *guid);
66104
67105 /**
68106 *
3131 #endif
3232
3333 #include "sesman.h"
34
35 extern struct config_sesman *g_cfg; /* in sesman.c */
3634
3735 /******************************************************************************/
3836 enum SCP_SERVER_STATES_E
2828 #endif
2929
3030 #include "sesman.h"
31
32 extern struct config_sesman *g_cfg; /* in sesman.c */
3331
3432 /******************************************************************************/
3533 enum SCP_SERVER_STATES_E
7674 else if (data)
7775 {
7876 s_item = session_get_bydata(s->username, s->width, s->height,
79 s->bpp, s->type, s->client_ip);
77 s->bpp, s->type, s->connection_description);
8078
8179 if (s_item != 0)
8280 {
8381 display = s_item->display;
84 g_memcpy(s->guid, s_item->guid, 16);
85 if (0 != s->client_ip)
82 s->guid = s_item->guid;
83 if (0 != s->connection_description)
8684 {
8785 LOG( LOG_LEVEL_INFO, "++ reconnected session: username %s, "
8886 "display :%d.0, session_pid %d, ip %s",
89 s->username, display, s_item->pid, s->client_ip);
87 s->username, display, s_item->pid,
88 s->connection_description);
9089 }
9190 else
9291 {
103102
104103 if (1 == access_login_allowed(s->username))
105104 {
106 tui8 guid[16];
105 struct guid guid = guid_new();
107106
108 g_random((char *)guid, 16);
109 scp_session_set_guid(s, guid);
107 scp_session_set_guid(s, &guid);
110108
111 if (0 != s->client_ip)
109 if (0 != s->connection_description)
112110 {
113111 LOG(LOG_LEVEL_INFO, "++ created session (access granted): "
114 "username %s, ip %s", s->username, s->client_ip);
112 "username %s, ip %s", s->username, s->connection_description);
115113 }
116114 else
117115 {
151149 }
152150 else
153151 {
154 scp_v0s_allow_connection(t, display, s->guid);
152 scp_v0s_allow_connection(t, display, &s->guid);
155153 }
156154 }
157155 else
158156 {
159 LOG(LOG_LEVEL_INFO, "Username or password error for user: %s",
160 s->username);
157 char ip[64];
158 g_get_ip_from_description(s->connection_description, ip, sizeof(ip));
159 /*
160 * The message is intended for use by fail2ban, so for
161 * future-proofing we only log the IP address rather than the
162 * connection description */
163 LOG(LOG_LEVEL_INFO,
164 "AUTHFAIL: user=%s ip=%s time=%d",
165 s->username, ip, g_time1());
161166 scp_v0s_deny_connection(t);
162167 }
163168 if (do_auth_end)
3131
3232 //#include "libscp_types.h"
3333 #include "libscp.h"
34
35 extern struct config_sesman *g_cfg; /* in sesman.c */
3634
3735 static void
3836 parseCommonStates(enum SCP_SERVER_STATES_E e, const char *f);
7876 }
7977 else
8078 {
79 char ip[64];
80 g_get_ip_from_description(s->connection_description,
81 ip, sizeof(ip));
82 /*
83 * The message is intended for use by fail2ban, so for
84 * future-proofing we only log the IP address rather than the
85 * connection description */
86 LOG(LOG_LEVEL_INFO,
87 "AUTHFAIL: user=%s ip=%s time=%d",
88 s->username, ip, g_time1());
8189 scp_v1s_deny_connection(t, "Login failed");
82 LOG(LOG_LEVEL_INFO, "Login failed for user %s. "
83 "Connection terminated", s->username);
8490 return SCP_SERVER_STATE_END;
8591 }
8692 return SCP_SERVER_STATE_OK;
107113 LOG(LOG_LEVEL_DEBUG, "No disconnected sessions for this user "
108114 "- we create a new one");
109115
110 if (0 != s->client_ip)
116 if (0 != s->connection_description)
111117 {
112118 LOG(LOG_LEVEL_INFO, "++ created session (access granted): "
113 "username %s, ip %s", s->username, s->client_ip);
119 "username %s, ip %s", s->username, s->connection_description);
114120 }
115121 else
116122 {
218224 {
219225 LOG(LOG_LEVEL_ERROR, "scp_v1s_reconnect_session failed");
220226 }
221 if (0 != s->client_ip)
222 {
223 LOG(LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d, ip %s", s->username, display, sitem->pid, s->client_ip);
227 if (0 != s->connection_description)
228 {
229 LOG(LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d, ip %s", s->username, display, sitem->pid, s->connection_description);
224230 }
225231 else
226232 {
3030 #include "sesman.h"
3131
3232 #include "libscp.h"
33
34 extern struct config_sesman *g_cfg; /* in sesman.c */
3533
3634 static void parseCommonStates(enum SCP_SERVER_STATES_E e, const char *f);
3735
5151 int dump_config;
5252 };
5353
54 int g_pid;
54 struct config_sesman *g_cfg;
5555 unsigned char g_fixedkey[8] = { 23, 82, 107, 6, 35, 78, 88, 7 };
56 struct config_sesman *g_cfg; /* defined in config.h */
57
5856 tintptr g_term_event = 0;
57 tintptr g_sigchld_event = 0;
58 tintptr g_reload_event = 0;
5959
6060 /**
6161 * Items stored on the g_con_list
6666 struct SCP_SESSION *s;
6767 };
6868
69 static struct trans *g_list_trans = NULL;
69 static struct trans *g_list_trans;
7070 static struct list *g_con_list = NULL;
71 static int g_pid;
7172
7273 /*****************************************************************************/
7374 /**
262263 struct sesman_con *sc;
263264
264265 LOG_DEVEL(LOG_LEVEL_TRACE, "sesman_close_all:");
265 trans_delete(g_list_trans);
266 sesman_delete_listening_transport();
266267 for (index = 0; index < g_con_list->count; index++)
267268 {
268269 sc = (struct sesman_con *) list_get_item(g_con_list, index);
275276 static int
276277 sesman_data_in(struct trans *self)
277278 {
279 #define HEADER_SIZE 8
278280 int version;
279281 int size;
280282
282284 {
283285 in_uint32_be(self->in_s, version);
284286 in_uint32_be(self->in_s, size);
285 if (size > self->in_s->size)
286 {
287 LOG(LOG_LEVEL_ERROR, "sesman_data_in: bad message size");
287 if (size < HEADER_SIZE || size > self->in_s->size)
288 {
289 LOG(LOG_LEVEL_ERROR, "sesman_data_in: bad message size %d", size);
288290 return 1;
289291 }
290292 self->header_size = size;
301303 return 1;
302304 }
303305 /* reset for next message */
304 self->header_size = 8;
306 self->header_size = HEADER_SIZE;
305307 self->extra_flags = 0;
306308 init_stream(self->in_s, 0); /* Reset input stream pointers */
307309 }
308310 return 0;
311 #undef HEADER_SIZE
309312 }
310313
311314 /******************************************************************************/
339342
340343 /******************************************************************************/
341344 /**
345 * Informs the main loop a termination signal has been received
346 */
347 static void
348 set_term_event(int sig)
349 {
350 /* Don't try to use a wait obj in a child process */
351 if (g_getpid() == g_pid)
352 {
353 g_set_wait_obj(g_term_event);
354 }
355 }
356
357 /******************************************************************************/
358 /**
359 * Informs the main loop a SIGCHLD has been received
360 */
361 static void
362 set_sigchld_event(int sig)
363 {
364 /* Don't try to use a wait obj in a child process */
365 if (g_getpid() == g_pid)
366 {
367 g_set_wait_obj(g_sigchld_event);
368 }
369 }
370
371 /******************************************************************************/
372 /**
373 * Informs the main loop a SIGHUP has been received
374 */
375 static void
376 set_reload_event(int sig)
377 {
378 /* Don't try to use a wait obj in a child process */
379 if (g_getpid() == g_pid)
380 {
381 g_set_wait_obj(g_reload_event);
382 }
383 }
384
385 /******************************************************************************/
386 void
387 sesman_delete_listening_transport(void)
388 {
389 trans_delete(g_list_trans);
390 g_list_trans = NULL;
391 }
392
393 /******************************************************************************/
394 int
395 sesman_create_listening_transport(const struct config_sesman *cfg)
396 {
397 int rv = 1;
398 g_list_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
399 if (g_list_trans == NULL)
400 {
401 LOG(LOG_LEVEL_ERROR, "%s: trans_create failed", __func__);
402 }
403 else
404 {
405 LOG(LOG_LEVEL_DEBUG, "%s: address %s port %s",
406 __func__, cfg->listen_address, cfg->listen_port);
407 rv = trans_listen_address(g_list_trans, cfg->listen_port,
408 cfg->listen_address);
409 if (rv != 0)
410 {
411 LOG(LOG_LEVEL_ERROR, "%s: trans_listen_address failed", __func__);
412 sesman_delete_listening_transport();
413 }
414 else
415 {
416 g_list_trans->trans_conn_in = sesman_listen_conn_in;
417 }
418 }
419
420 return rv;
421 }
422
423 /******************************************************************************/
424 /**
342425 *
343426 * @brief Starts sesman main loop
344427 *
349432 int error;
350433 int robjs_count;
351434 int wobjs_count;
352 int cont;
353435 int timeout;
354436 int index;
355437 intptr_t robjs[32];
362444 LOG(LOG_LEVEL_ERROR, "sesman_main_loop: list_create failed");
363445 return 1;
364446 }
365 g_list_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
366 if (g_list_trans == NULL)
367 {
368 LOG(LOG_LEVEL_ERROR, "sesman_main_loop: trans_create failed");
447 if (sesman_create_listening_transport(g_cfg) != 0)
448 {
449 LOG(LOG_LEVEL_ERROR,
450 "sesman_main_loop: sesman_create_listening_transport failed");
369451 list_delete(g_con_list);
370452 return 1;
371453 }
372454
373 LOG(LOG_LEVEL_DEBUG, "sesman_main_loop: address %s port %s",
374 g_cfg->listen_address, g_cfg->listen_port);
375 error = trans_listen_address(g_list_trans, g_cfg->listen_port,
376 g_cfg->listen_address);
377 if (error != 0)
378 {
379 LOG(LOG_LEVEL_ERROR, "sesman_main_loop: trans_listen_address "
380 "failed");
381 trans_delete(g_list_trans);
382 list_delete(g_con_list);
383 return 1;
384 }
385 g_list_trans->trans_conn_in = sesman_listen_conn_in;
386 cont = 1;
387 while (cont)
455 error = 0;
456 while (!error)
388457 {
389458 timeout = -1;
390459 robjs_count = 0;
391460 robjs[robjs_count++] = g_term_event;
461 robjs[robjs_count++] = g_sigchld_event;
462 robjs[robjs_count++] = g_reload_event;
392463 wobjs_count = 0;
393464 for (index = 0; index < g_con_list->count; index++)
394465 {
410481 {
411482 break;
412483 }
413 error = trans_get_wait_objs_rw(g_list_trans, robjs, &robjs_count,
414 wobjs, &wobjs_count, &timeout);
415 if (error != 0)
416 {
417 LOG(LOG_LEVEL_ERROR, "sesman_main_loop: "
418 "trans_get_wait_objs_rw failed");
484 if (g_list_trans != NULL)
485 {
486 /* g_list_trans might be NULL on a reconfigure if sesman
487 * is unable to listen again */
488 error = trans_get_wait_objs_rw(g_list_trans, robjs, &robjs_count,
489 wobjs, &wobjs_count, &timeout);
490 if (error != 0)
491 {
492 LOG(LOG_LEVEL_ERROR, "sesman_main_loop: "
493 "trans_get_wait_objs_rw failed");
494 break;
495 }
496 }
497
498 if (g_obj_wait(robjs, robjs_count, wobjs, wobjs_count, timeout) != 0)
499 {
500 /* should not get here */
501 LOG(LOG_LEVEL_WARNING, "sesman_main_loop: "
502 "Unexpected error from g_obj_wait()");
503 g_sleep(100);
504 }
505
506 if (g_is_wait_obj_set(g_term_event)) /* term */
507 {
508 LOG(LOG_LEVEL_INFO, "sesman_main_loop: "
509 "sesman asked to terminate");
419510 break;
420511 }
421512
422 error = g_obj_wait(robjs, robjs_count, wobjs, wobjs_count, timeout);
423 if (error != 0)
424 {
425 /* error, should not get here */
426 g_sleep(100);
427 }
428
429 if (g_is_wait_obj_set(g_term_event)) /* term */
430 {
431 break;
513 if (g_is_wait_obj_set(g_sigchld_event)) /* A child has exited */
514 {
515 g_reset_wait_obj(g_sigchld_event);
516 sig_sesman_session_end();
517 }
518
519 if (g_is_wait_obj_set(g_reload_event)) /* We're asked to reload */
520 {
521 g_reset_wait_obj(g_reload_event);
522 sig_sesman_reload_cfg();
432523 }
433524
434525 for (index = 0; index < g_con_list->count; index++)
436527 scon = (struct sesman_con *)list_get_item(g_con_list, index);
437528 if (scon != NULL)
438529 {
439 error = trans_check_wait_objs(scon->t);
440 if (error != 0)
530 if (trans_check_wait_objs(scon->t) != 0)
441531 {
442532 LOG(LOG_LEVEL_ERROR, "sesman_main_loop: "
443533 "trans_check_wait_objs failed, removing trans");
448538 }
449539 }
450540 }
451 error = trans_check_wait_objs(g_list_trans);
452 if (error != 0)
453 {
454 LOG(LOG_LEVEL_ERROR, "sesman_main_loop: "
455 "trans_check_wait_objs failed");
456 break;
541
542 if (g_list_trans != NULL)
543 {
544 error = trans_check_wait_objs(g_list_trans);
545 if (error != 0)
546 {
547 LOG(LOG_LEVEL_ERROR, "sesman_main_loop: "
548 "trans_check_wait_objs failed");
549 break;
550 }
457551 }
458552 }
459553 for (index = 0; index < g_con_list->count; index++)
462556 delete_connection(scon);
463557 }
464558 list_delete(g_con_list);
465 trans_delete(g_list_trans);
559 sesman_delete_listening_transport();
466560 return 0;
467561 }
468562
624718 }
625719
626720 /* starting logging subsystem */
627 log_error = log_start(startup_params.sesman_ini, "xrdp-sesman",
628 startup_params.dump_config);
721 log_error = log_start(
722 startup_params.sesman_ini, "xrdp-sesman",
723 (startup_params.dump_config) ? LOG_START_DUMP_CONFIG : 0);
629724
630725 if (log_error != LOG_STARTUP_OK)
631726 {
706801
707802 /* signal handling */
708803 g_pid = g_getpid();
709 /* old style signal handling is now managed synchronously by a
710 * separate thread. uncomment this block if you need old style
711 * signal handling and comment out thread_sighandler_start()
712 * going back to old style for the time being
713 * problem with the sigaddset functions in sig.c - jts */
714 #if 1
715 g_signal_hang_up(sig_sesman_reload_cfg); /* SIGHUP */
716 g_signal_user_interrupt(sig_sesman_shutdown); /* SIGINT */
717 g_signal_terminate(sig_sesman_shutdown); /* SIGTERM */
718 g_signal_child_stop(sig_sesman_session_end); /* SIGCHLD */
719 #endif
720 #if 0
721 thread_sighandler_start();
722 #endif
804 g_snprintf(text, 255, "xrdp_sesman_%8.8x_main_term", g_pid);
805 g_term_event = g_create_wait_obj(text);
806 g_snprintf(text, 255, "xrdp_sesman_%8.8x_sigchld", g_pid);
807 g_sigchld_event = g_create_wait_obj(text);
808 g_snprintf(text, 255, "xrdp_sesman_%8.8x_reload", g_pid);
809 g_reload_event = g_create_wait_obj(text);
810
811 g_signal_hang_up(set_reload_event); /* SIGHUP */
812 g_signal_user_interrupt(set_term_event); /* SIGINT */
813 g_signal_terminate(set_term_event); /* SIGTERM */
814 g_signal_child_stop(set_sigchld_event); /* SIGCHLD */
723815
724816 if (daemon)
725817 {
761853 g_chmod_hex("/tmp/.X11-unix", 0x1777);
762854 }
763855
764 g_snprintf(text, 255, "xrdp_sesman_%8.8x_main_term", g_pid);
765 g_term_event = g_create_wait_obj(text);
766
767856 error = sesman_main_loop();
768857
769858 /* clean up PID file on exit */
772861 g_file_delete(pid_file);
773862 }
774863
864 g_delete_wait_obj(g_reload_event);
865 g_delete_wait_obj(g_sigchld_event);
775866 g_delete_wait_obj(g_term_event);
776867
777868 if (!daemon)
4040
4141 #include "libscp.h"
4242
43 /* Globals */
44 extern struct config_sesman *g_cfg;
45 extern unsigned char g_fixedkey[8];
46 extern tintptr g_term_event;
47 extern tintptr g_sigchld_event;
48 extern tintptr g_reload_event;
49
4350 /*
4451 * Close all file descriptors used by sesman.
4552 *
5259 int
5360 sesman_close_all(void);
5461
62 /*
63 * Remove the listening transport
64 *
65 * Needed if reloading the config and the listener has changed
66 */
67 void
68 sesman_delete_listening_transport(void);
69
70 /*
71 * Create the listening socket transport
72 *
73 * @return 0 for success
74 */
75 int
76 sesman_create_listening_transport(const struct config_sesman *cfg);
77
5578 #endif
1818 ; When AlwaysGroupCheck=false access will be permitted
1919 ; if the group TerminalServerUsers is not defined.
2020 AlwaysGroupCheck=false
21 ; When RestrictOutboundClipboard=true clipboard from the
21 ; When RestrictOutboundClipboard=all clipboard from the
2222 ; server is not pushed to the client.
23 RestrictOutboundClipboard=false
23 ; In addition, you can control text/file/image transfer restrictions
24 ; respectively. It also accepts comma separated list such as text,file,image.
25 ; To keep compatibility, some aliases are also available:
26 ; true: an alias of all
27 ; false: an alias of none
28 ; yes: an alias of all
29 RestrictOutboundClipboard=none
30 ; When RestrictInboundClipboard=all clipboard from the
31 ; client is not pushed to the server.
32 ; In addition, you can control text/file/image transfer restrictions
33 ; respectively. It also accepts comma separated list such as text,file,image.
34 ; To keep compatibility, some aliases are also available:
35 ; true: an alias of all
36 ; false: an alias of none
37 ; yes: an alias of all
38 RestrictInboundClipboard=none
2439
2540 [Sessions]
2641 ;; X11DisplayOffset - x11 display number offset
124139 FileUmask=077
125140 ; Can be used to disable FUSE functionality - see sesman.ini(5)
126141 #EnableFuseMount=false
142 ; Uncomment this line only if you are using GNOME 3 versions 3.29.92
143 ; and up, and you wish to cut-paste files between Nautilus and Windows. Do
144 ; not use this setting for GNOME 4, or other file managers
145 #UseNautilus3FlistFormat=true
127146
128147 [ChansrvLogging]
129148 ; Note: one log file is created per display and the LogFile config value
4646 #define PR_SET_NO_NEW_PRIVS 38
4747 #endif
4848
49 extern unsigned char g_fixedkey[8];
50 extern struct config_sesman *g_cfg; /* in sesman.c */
51 struct session_chain *g_sessions;
52 int g_session_count;
53
54 extern tbus g_term_event; /* in sesman.c */
49 static struct session_chain *g_sessions;
50 static int g_session_count;
5551
5652 /**
5753 * Creates a string consisting of all parameters that is hosted in the param list
9187 /******************************************************************************/
9288 struct session_item *
9389 session_get_bydata(const char *name, int width, int height, int bpp, int type,
94 const char *client_ip)
90 const char *connection_description)
9591 {
9692 struct session_chain *tmp;
9793 enum SESMAN_CFG_SESS_POLICY policy = g_cfg->sess.policy;
94 char ip[64];
9895
9996 tmp = g_sessions;
10097
114111 return 0;
115112 }
116113
114 if ((policy & SESMAN_CFG_SESS_POLICY_I) != 0)
115 {
116 /* We'll need to compare on IP addresses */
117 g_get_ip_from_description(connection_description, ip, sizeof(ip));
118 }
119 else
120 {
121 ip[0] = '\0';
122 }
123
117124 LOG(LOG_LEVEL_DEBUG,
118125 "session_get_bydata: search policy %d U %s W %d H %d bpp %d T %d IP %s",
119 policy, name, width, height, bpp, type, client_ip);
126 policy, name, width, height, bpp, type, connection_description);
120127
121128 while (tmp != 0)
122129 {
130 char tmp_ip[64];
131
132 if ((policy & SESMAN_CFG_SESS_POLICY_I) != 0)
133 {
134 g_get_ip_from_description(tmp->item->connection_description,
135 tmp_ip, sizeof (tmp_ip));
136 }
137 else
138 {
139 tmp_ip[0] = '\0';
140 }
141
123142 LOG(LOG_LEVEL_DEBUG,
124143 "session_get_bydata: try %p U %s W %d H %d bpp %d T %d IP %s",
125144 tmp->item,
126145 tmp->item->name,
127146 tmp->item->width, tmp->item->height,
128147 tmp->item->bpp, tmp->item->type,
129 tmp->item->client_ip);
148 tmp->item->connection_description);
130149
131150 if (g_strncmp(name, tmp->item->name, 255) == 0 &&
132151 (!(policy & SESMAN_CFG_SESS_POLICY_D) ||
133152 (tmp->item->width == width && tmp->item->height == height)) &&
134153 (!(policy & SESMAN_CFG_SESS_POLICY_I) ||
135 (g_strncmp_d(client_ip, tmp->item->client_ip, ':', 255) == 0)) &&
154 (g_strcmp(ip, tmp_ip) == 0)) &&
136155 (!(policy & SESMAN_CFG_SESS_POLICY_C) ||
137 (g_strncmp(client_ip, tmp->item->client_ip, 255) == 0)) &&
156 (g_strncmp(connection_description, tmp->item->connection_description, 255) == 0)) &&
138157 tmp->item->bpp == bpp &&
139158 tmp->item->type == type)
140159 {
500519 "Failed to clone the session data - out of memory");
501520 g_exit(1);
502521 }
522
523 /* Wait objects created in a parent are not valid in a child */
524 g_delete_wait_obj(g_reload_event);
525 g_delete_wait_obj(g_sigchld_event);
526 g_delete_wait_obj(g_term_event);
527
503528 auth_start_session(data, display);
504 g_delete_wait_obj(g_term_event);
505529 sesman_close_all();
506530 g_sprintf(geometry, "%dx%d", s->width, s->height);
507531 g_sprintf(depth, "%d", s->bpp);
755779 }
756780 else if (type == SESMAN_SESSION_TYPE_XVNC)
757781 {
758 char guid_str[64];
759 g_bytes_to_hexstr(s->guid, 16, guid_str, 64);
782 char guid_str[GUID_STR_SIZE];
783 guid_to_str(&s->guid, guid_str);
760784 env_check_password_file(passwd_file, guid_str);
761785 xserver_params = list_create();
762786 xserver_params->auto_free = 1;
924948 LOG(LOG_LEVEL_INFO, "Starting session: session_pid %d, "
925949 "display :%d.0, width %d, height %d, bpp %d, client ip %s, "
926950 "user name %s",
927 pid, display, s->width, s->height, s->bpp, s->client_ip, s->username);
951 pid, display, s->width, s->height, s->bpp, s->connection_description, s->username);
928952 temp->item->pid = pid;
929953 temp->item->display = display;
930954 temp->item->width = s->width;
931955 temp->item->height = s->height;
932956 temp->item->bpp = s->bpp;
933957 temp->item->data = data;
934 g_strncpy(temp->item->client_ip, s->client_ip, 255); /* store client ip data */
958 g_strncpy(temp->item->connection_description, s->connection_description, 255); /* store client ip data */
935959 g_strncpy(temp->item->name, s->username, 255);
936 g_memcpy(temp->item->guid, s->guid, 16);
960 temp->item->guid = s->guid;
937961
938962 ltime = g_time1();
939963 localtime_r(&ltime, &stime);
10631087 /* deleting the session */
10641088 LOG(LOG_LEVEL_INFO,
10651089 "++ terminated session: username %s, display :%d.0, session_pid %d, ip %s",
1066 tmp->item->name, tmp->item->display, tmp->item->pid, tmp->item->client_ip);
1090 tmp->item->name, tmp->item->display, tmp->item->pid, tmp->item->connection_description);
10671091 g_free(tmp->item);
10681092
10691093 if (prev == 0)
2828 #define SESSION_H
2929
3030 #include "libscp_types.h"
31 #include "guid.h"
3132
3233 #define SESMAN_SESSION_TYPE_XRDP 1
3334 #define SESMAN_SESSION_TYPE_XVNC 2
7475 struct session_date connect_time;
7576 struct session_date disconnect_time;
7677 struct session_date idle_time;
77 char client_ip[256];
78 tui8 guid[16];
78 char connection_description[256];
79 struct guid guid;
7980 };
8081
8182 struct session_chain
9293 */
9394 struct session_item *
9495 session_get_bydata(const char *name, int width, int height, int bpp, int type,
95 const char *client_ip);
96 const char *connection_description);
9697 #ifndef session_find_item
9798 #define session_find_item(a, b, c, d, e, f) session_get_bydata(a, b, c, d, e, f);
9899 #endif
2727 #include <config_ac.h>
2828 #endif
2929
30 #include <signal.h>
31
30 #include "string_calls.h"
3231 #include "sesman.h"
33
34 extern int g_pid;
35 extern struct config_sesman *g_cfg; /* in sesman.c */
36 extern tbus g_term_event;
3732
3833 /******************************************************************************/
3934 void
40 sig_sesman_shutdown(int sig)
41 {
42 char pid_file[256];
43
44 LOG(LOG_LEVEL_INFO, "shutting down sesman %d", 1);
45
46 if (g_getpid() != g_pid)
47 {
48 LOG_DEVEL(LOG_LEVEL_DEBUG, "g_getpid() [%d] differs from g_pid [%d]", (g_getpid()), g_pid);
49 return;
50 }
51
52 LOG_DEVEL(LOG_LEVEL_DEBUG, " - getting signal %d pid %d", sig, g_getpid());
53
54 g_set_wait_obj(g_term_event);
55
56 session_sigkill_all();
57
58 g_snprintf(pid_file, 255, "%s/xrdp-sesman.pid", XRDP_PID_PATH);
59 g_file_delete(pid_file);
60 }
61
62 /******************************************************************************/
63 void
64 sig_sesman_reload_cfg(int sig)
35 sig_sesman_reload_cfg(void)
6536 {
6637 int error;
6738 struct config_sesman *cfg;
6839
69 LOG(LOG_LEVEL_WARNING, "receiving SIGHUP %d", 1);
70
71 if (g_getpid() != g_pid)
72 {
73 LOG_DEVEL(LOG_LEVEL_DEBUG, "g_getpid() [%d] differs from g_pid [%d]", g_getpid(), g_pid);
74 return;
75 }
40 LOG(LOG_LEVEL_INFO, "receiving SIGHUP");
7641
7742 if ((cfg = config_read(g_cfg->sesman_ini)) == NULL)
7843 {
8045 return;
8146 }
8247
83 /* stop logging subsystem */
84 log_end();
48 /* Deal with significant config changes */
49 if (g_strcmp(g_cfg->listen_address, cfg->listen_address) != 0 ||
50 g_strcmp(g_cfg->listen_port, cfg->listen_port) != 0)
51 {
52 LOG(LOG_LEVEL_INFO, "sesman listen address changed to %s:%s",
53 cfg->listen_address, cfg->listen_port);
54
55 /* We have to delete the old port before listening to the new one
56 * in case they overlap in scope */
57 sesman_delete_listening_transport();
58 sesman_create_listening_transport(cfg);
59 }
8560
8661 /* free old config data */
8762 config_free(g_cfg);
8964 /* replace old config with newly read one */
9065 g_cfg = cfg;
9166
92 /* start again logging subsystem */
93 error = log_start(g_cfg->sesman_ini, "xrdp-sesman", 0);
67 /* Restart logging subsystem */
68 error = log_start(g_cfg->sesman_ini, "xrdp-sesman", LOG_START_RESTART);
9469
9570 if (error != LOG_STARTUP_OK)
9671 {
11287
11388 /******************************************************************************/
11489 void
115 sig_sesman_session_end(int sig)
90 sig_sesman_session_end(void)
11691 {
11792 int pid;
11893
119 if (g_getpid() != g_pid)
120 {
121 return;
122 }
123
124 pid = g_waitchild();
125
126 if (pid > 0)
127 {
128 session_kill(pid);
129 }
130 }
131
132 /******************************************************************************/
133 void *
134 sig_handler_thread(void *arg)
135 {
136 int recv_signal;
137 sigset_t sigmask;
138 sigset_t oldmask;
139 sigset_t waitmask;
140
141 /* mask signals to be able to wait for them... */
142 sigfillset(&sigmask);
143 /* it is a good idea not to block SIGILL SIGSEGV */
144 /* SIGFPE -- see sigaction(2) NOTES */
145 pthread_sigmask(SIG_BLOCK, &sigmask, &oldmask);
146
147 /* building the signal wait mask... */
148 sigemptyset(&waitmask);
149 sigaddset(&waitmask, SIGHUP);
150 sigaddset(&waitmask, SIGCHLD);
151 sigaddset(&waitmask, SIGTERM);
152 sigaddset(&waitmask, SIGINT);
153
154 // sigaddset(&waitmask, SIGFPE);
155 // sigaddset(&waitmask, SIGILL);
156 // sigaddset(&waitmask, SIGSEGV);
157
94 LOG(LOG_LEVEL_DEBUG, "receiving SIGCHLD");
15895 do
15996 {
160 LOG_DEVEL(LOG_LEVEL_DEBUG, "calling sigwait()");
161 sigwait(&waitmask, &recv_signal);
97 pid = g_waitchild();
16298
163 switch (recv_signal)
99 if (pid > 0)
164100 {
165 case SIGHUP:
166 //reload cfg
167 //we must stop & restart logging, or copy logging cfg!!!!
168 LOG_DEVEL(LOG_LEVEL_DEBUG, "sesman received SIGHUP");
169 //return 0;
170 break;
171 case SIGCHLD:
172 /* a session died */
173 LOG_DEVEL(LOG_LEVEL_DEBUG, "sesman received SIGCHLD");
174 sig_sesman_session_end(SIGCHLD);
175 break;
176 case SIGINT:
177 /* we die */
178 LOG_DEVEL(LOG_LEVEL_DEBUG, "sesman received SIGINT");
179 sig_sesman_shutdown(recv_signal);
180 break;
181 case SIGTERM:
182 /* we die */
183 LOG_DEVEL(LOG_LEVEL_DEBUG, "sesman received SIGTERM");
184 sig_sesman_shutdown(recv_signal);
185 break;
101 LOG(LOG_LEVEL_INFO, "Process %d has exited", pid);
102
103 session_kill(pid);
186104 }
187105 }
188 while (1);
189
190 return 0;
106 while (pid > 0);
191107 }
2828
2929 /**
3030 *
31 * @brief Shutdown signal code
32 * @param sig The received signal
31 * @brief SIGHUP handling code
3332 *
3433 */
3534 void
36 sig_sesman_shutdown(int sig);
37
38 /**
39 *
40 * @brief SIGHUP handling code
41 * @param sig The received signal
42 *
43 */
44 void
45 sig_sesman_reload_cfg(int sig);
35 sig_sesman_reload_cfg(void);
4636
4737 /**
4838 *
4939 * @brief SIGCHLD handling code
50 * @param sig The received signal
5140 *
5241 */
5342 void
54 sig_sesman_session_end(int sig);
55
56 /**
57 *
58 * @brief signal handling thread
59 *
60 */
61 void *
62 sig_handler_thread(void *arg);
43 sig_sesman_session_end(void);
6344
6445 #endif
7070 exit 0
7171 fi
7272
73 # alpine
74 # Don't use /etc/X11/xinit/Xsession - it doesn't work
75 if [ -f /etc/alpine-release ]; then
76 if [ -f /etc/X11/xinit/xinitrc ]; then
77 pre_start
78 /etc/X11/xinit/xinitrc
79 post_start
80 else
81 echo "** xinit package isn't installed" >&2
82 exit 1
83 fi
84 fi
85
7386 # el
7487 if [ -r /etc/X11/xinit/Xsession ]; then
7588 pre_start
8699 exit 0
87100 elif [ -r /usr/etc/X11/xdm/Xsession ]; then
88101 . /usr/etc/X11/xdm/Xsession
89 exit 0
90 fi
91
92 # alpine
93 if [ -r /etc/X11/xinit/xinitrc ]; then
94 pre_start
95 . /etc/X11/xinit/xinitrc
96 post_start
97102 exit 0
98103 fi
99104
4040 xcon.c
4141
4242 xrdp_sesrun_LDADD = \
43 $(top_builddir)/common/libcommon.la
43 $(top_builddir)/common/libcommon.la \
44 $(top_builddir)/sesman/libscp/libscp.la
4445
4546 xrdp_sestest_LDADD = \
4647 $(top_builddir)/common/libcommon.la \
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
126126 am_xrdp_sesrun_OBJECTS = config.$(OBJEXT) sesrun.$(OBJEXT) \
127127 tcp.$(OBJEXT)
128128 xrdp_sesrun_OBJECTS = $(am_xrdp_sesrun_OBJECTS)
129 xrdp_sesrun_DEPENDENCIES = $(top_builddir)/common/libcommon.la
129 xrdp_sesrun_DEPENDENCIES = $(top_builddir)/common/libcommon.la \
130 $(top_builddir)/sesman/libscp/libscp.la
130131 am_xrdp_sestest_OBJECTS = sestest.$(OBJEXT)
131132 xrdp_sestest_OBJECTS = $(am_xrdp_sestest_OBJECTS)
132133 xrdp_sestest_DEPENDENCIES = $(top_builddir)/common/libcommon.la \
203204 unique=`for i in $$list; do \
204205 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
205206 done | $(am__uniquify_input)`
206 ETAGS = etags
207 CTAGS = ctags
208207 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
209208 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
210209 ACLOCAL = @ACLOCAL@
222221 CHECK_LIBS = @CHECK_LIBS@
223222 CPP = @CPP@
224223 CPPFLAGS = @CPPFLAGS@
224 CSCOPE = @CSCOPE@
225 CTAGS = @CTAGS@
225226 CYGPATH_W = @CYGPATH_W@
226227 DEFS = @DEFS@
227228 DEPDIR = @DEPDIR@
233234 ECHO_N = @ECHO_N@
234235 ECHO_T = @ECHO_T@
235236 EGREP = @EGREP@
237 ETAGS = @ETAGS@
236238 EXEEXT = @EXEEXT@
237239 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
238240 FDKAAC_LIBS = @FDKAAC_LIBS@
242244 FUSE_CFLAGS = @FUSE_CFLAGS@
243245 FUSE_LIBS = @FUSE_LIBS@
244246 GREP = @GREP@
247 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
248 IMLIB2_LIBS = @IMLIB2_LIBS@
245249 INSTALL = @INSTALL@
246250 INSTALL_DATA = @INSTALL_DATA@
247251 INSTALL_PROGRAM = @INSTALL_PROGRAM@
385389 xcon.c
386390
387391 xrdp_sesrun_LDADD = \
388 $(top_builddir)/common/libcommon.la
392 $(top_builddir)/common/libcommon.la \
393 $(top_builddir)/sesman/libscp/libscp.la
389394
390395 xrdp_sestest_LDADD = \
391396 $(top_builddir)/common/libcommon.la \
611616
612617 distclean-tags:
613618 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
614
615619 distdir: $(BUILT_SOURCES)
616620 $(MAKE) $(AM_MAKEFLAGS) distdir-am
617621
5252 //int end;
5353 int idx;
5454 //int sel;
55 int sock;
5655 char *pwd;
5756 struct log_config *logging;
5857
127126
128127 scp_init();
129128
130 sock = g_tcp_socket();
131 if (sock < 0)
132 {
133 LOG_DEVEL(LOG_LEVEL_DEBUG, "Socket open error, g_tcp_socket() failed");
134 return 1;
135 }
136
137129 s = scp_session_create();
138 t = scp_trans_create(sock);
139
140 LOG_DEVEL(LOG_LEVEL_DEBUG, "Connecting to %s:%s with user %s (%s)", serv, port, user, pass);
141
142 if (0 != trans_connect(t, serv, port, 3000))
143 {
144 LOG(LOG_LEVEL_ERROR, "trans_connect() error");
130 LOG_DEVEL(LOG_LEVEL_DEBUG, "Connecting to %s:%s)", serv, port);
131 t = scp_connect(serv, port, NULL, NULL, NULL);
132
133
134 if (t == NULL)
135 {
136 LOG(LOG_LEVEL_ERROR, "scp_connect() error");
145137 return 1;
146138 }
147139
3737 #include "log.h"
3838 #include "tcp.h"
3939 #include "string_calls.h"
40 #include "guid.h"
41
42 #include "libscp_connection.h"
4043
4144 #if !defined(PACKAGE_VERSION)
4245 #define PACKAGE_VERSION "???"
413416 }
414417
415418 /**************************************************************************//**
416 * Helper function for send_scpv0_auth_request()
417 *
418 * @param s Output string
419 * @param str String to write to s
420 */
421 static void
422 out_string16(struct stream *s, const char *str)
423 {
424 int i = g_strlen(str);
425 out_uint16_be(s, i);
426 out_uint8a(s, str, i);
427 }
428
429 /**************************************************************************//**
430419 * Sends an SCP V0 authorization request
431420 *
432421 * @param sck file descriptor to send request on
436425 * xrdp_mm_send_login(). When SCP is reworked, a common library
437426 * function should be used
438427 */
439 static void
440 send_scpv0_auth_request(int sck, const struct session_params *sp)
441 {
442 struct stream *out_s;
443
428 static enum SCP_CLIENT_STATES_E
429 send_scpv0_auth_request(struct trans *t, const struct session_params *sp)
430 {
444431 LOG(LOG_LEVEL_DEBUG,
445432 "width:%d height:%d bpp:%d code:%d\n"
446433 "server:\"%s\" domain:\"%s\" directory:\"%s\"\n"
451438 /* Only log the password in development builds */
452439 LOG_DEVEL(LOG_LEVEL_DEBUG, "password:\"%s\"", sp->password);
453440
454 make_stream(out_s);
455 init_stream(out_s, 8192);
456
457 s_push_layer(out_s, channel_hdr, 8);
458 out_uint16_be(out_s, sp->session_code);
459 out_string16(out_s, sp->username);
460 out_string16(out_s, sp->password);
461 out_uint16_be(out_s, sp->width);
462 out_uint16_be(out_s, sp->height);
463 out_uint16_be(out_s, sp->bpp);
464 out_string16(out_s, sp->domain);
465 out_string16(out_s, sp->shell);
466 out_string16(out_s, sp->directory);
467 out_string16(out_s, sp->client_ip);
468 s_mark_end(out_s);
469
470 s_pop_layer(out_s, channel_hdr);
471 out_uint32_be(out_s, 0); /* version */
472 out_uint32_be(out_s, out_s->end - out_s->data); /* size */
473 tcp_force_send(sck, out_s->data, out_s->end - out_s->data);
474
475 free_stream(out_s);
441 return scp_v0c_create_session_request(
442 t, sp->username, sp->password, sp->session_code, sp->width, sp->height,
443 sp->bpp, sp->domain, sp->shell, sp->directory, sp->client_ip);
476444 }
477445
478446 /**************************************************************************//**
479447 * Receives an SCP V0 authorization reply
480448 *
481 * @param sck file descriptor to receive reply on
482 *
483 * @todo This code duplicates functionality in the XRDP function
484 * xrdp_mm_process_login_response(). When SCP is reworked, a
485 * common library function should be used
449 * @param t SCP transport to receive reply on
450 * @return 0 for success
486451 */
487452 static int
488 handle_scpv0_auth_reply(int sck)
489 {
490 int result = 1;
491 int packet_ok = 0;
492
493 struct stream *in_s;
494
495 make_stream(in_s);
496 init_stream(in_s, 8192);
497
498 if (tcp_force_recv(sck, in_s->data, 8) == 0)
499 {
500 int version;
501 int size;
502 int code;
503 int data;
504 int display;
505
506 in_s->end = in_s->data + 8;
507 in_uint32_be(in_s, version);
508 in_uint32_be(in_s, size);
509 if (version == 0 && size >= 14)
510 {
511 init_stream(in_s, 8192);
512 if (tcp_force_recv(sck, in_s->data, size - 8) == 0)
453 handle_scpv0_auth_reply(struct trans *t)
454 {
455 tbus wobj[1];
456 int ocnt = 0;
457
458 int rv = 1;
459
460 if (trans_get_wait_objs(t, wobj, &ocnt) != 0)
461 {
462 LOG(LOG_LEVEL_ERROR, "Can't get wait object for sesman transport");
463 }
464 else
465 {
466 while (t->status == TRANS_STATUS_UP)
467 {
468 g_obj_wait(wobj, ocnt, NULL, 0, -1);
469 if (trans_check_wait_objs(t) != 0)
513470 {
514 in_s->end = in_s->data + (size - 8);
515
516 in_uint16_be(in_s, code);
517 in_uint16_be(in_s, data);
518 in_uint16_be(in_s, display);
519
520 if (code == 3)
521 {
522 packet_ok = 1;
523
524 if (data == 0)
471 LOG(LOG_LEVEL_ERROR, "sesman transport down");
472 break;
473 }
474
475 if (scp_v0c_reply_available(t))
476 {
477 struct scp_v0_reply_type msg;
478 enum SCP_CLIENT_STATES_E e = scp_v0c_get_reply(t, &msg);
479 if (e != SCP_CLIENT_STATE_OK)
480 {
481 LOG(LOG_LEVEL_ERROR,
482 "Error reading response from sesman [%s]",
483 scp_client_state_to_str(e));
484 }
485 else
486 {
487 if (msg.auth_result == 0)
525488 {
526489 g_printf("Connection denied (authentication error)\n");
527490 }
528491 else
529492 {
530 char guid[16];
531 char guid_str[64];
532 if (s_check_rem(in_s, 16) != 0)
533 {
534 in_uint8a(in_s, guid, 16);
535 g_bytes_to_hexstr(guid, 16, guid_str, 64);
536 }
537 else
538 {
539 g_strcpy(guid_str, "<none>");
540 }
541
493 char guid_str[GUID_STR_SIZE];
542494 g_printf("ok data=%d display=:%d GUID=%s\n",
543 (int)data, display, guid_str);
544 result = 0;
495 msg.auth_result,
496 msg.display,
497 guid_to_str(&msg.guid, guid_str));
545498 }
546 }
499 rv = 0;
500 }
501 break;
547502 }
548503 }
549504 }
550505
551 if (!packet_ok)
552 {
553 LOG(LOG_LEVEL_ERROR, "Corrupt reply packet");
554 }
555 free_stream(in_s);
556
557 return result;
506 return rv;
558507 }
559508
560509 /******************************************************************************/
564513 const char *sesman_ini = XRDP_CFG_PATH "/sesman.ini";
565514 struct config_sesman *cfg = NULL;
566515
567 int sck = -1;
516 struct trans *t = NULL;
517 enum SCP_CLIENT_STATES_E e;
568518 struct session_params sp;
569519
570520 struct log_config *logging;
571 int status = 1;
521 int rv = 1;
572522
573523 logging = log_config_init_for_console(LOG_LEVEL_WARNING,
574524 g_getenv("SESRUN_LOG_LEVEL"));
584534 LOG(LOG_LEVEL_ERROR, "error reading config file %s : %s",
585535 sesman_ini, g_get_strerror());
586536 }
537 else if (!(t = scp_connect(sp.server, cfg->listen_port, NULL, NULL, NULL)))
538 {
539 LOG(LOG_LEVEL_ERROR, "connect error - %s", g_get_strerror());
540 }
587541 else
588542 {
589 sck = g_tcp_socket();
590 if (sck < 0)
591 {
592 LOG(LOG_LEVEL_ERROR, "socket error - %s", g_get_strerror());
593 }
594 else if (g_tcp_connect(sck, sp.server, cfg->listen_port) != 0)
595 {
596 LOG(LOG_LEVEL_ERROR, "connect error - %s", g_get_strerror());
543 e = send_scpv0_auth_request(t, &sp);
544 if (e != SCP_CLIENT_STATE_OK)
545 {
546 LOG(LOG_LEVEL_ERROR,
547 "Error sending create session to sesman [%s]",
548 scp_client_state_to_str(e));
549 rv = 1;
597550 }
598551 else
599552 {
600 send_scpv0_auth_request(sck, &sp);
601 status = handle_scpv0_auth_reply(sck);
602 }
603 }
604
605 if (sck >= 0)
606 {
607 g_tcp_close(sck);
553 rv = handle_scpv0_auth_reply(t);
554 }
555 trans_delete(t);
608556 }
609557
610558 g_memset(sp.password, '\0', sizeof(sp.password));
611559 config_free(cfg);
612560 log_end();
613561
614 return status;
615 }
562 return rv;
563 }
4545 int scnt;
4646 int idx;
4747 int sel;
48 int sock;
4948
5049 logging = log_config_init_for_console(LOG_LEVEL_INFO, NULL);
5150 log_start_from_param(logging);
5352
5453 scp_init();
5554
56 sock = g_tcp_socket();
57 if (sock < 0)
58 {
59 return 1;
60 }
61
6255 s = scp_session_create();
63 t = scp_trans_create(sock);
64
65 if (0 != trans_connect(t, "localhost", "3350", 3000))
56 t = scp_connect("localhost", "3350", NULL, NULL, NULL);
57 if (t == NULL)
6658 {
6759 g_printf("error connecting");
6860 return 1;
4040 #ifndef SECS_PER_DAY
4141 #define SECS_PER_DAY (24L*3600L)
4242 #endif
43
44 extern struct config_sesman *g_cfg; /* in sesman.c */
4543
4644 static int
4745 auth_crypt_pwd(const char *pwd, const char *pln, char *crp);
4141 #ifndef SECS_PER_DAY
4242 #define SECS_PER_DAY (24L*3600L)
4343 #endif
44
45 extern struct config_sesman *g_cfg; /* in sesman.c */
4644
4745 /******************************************************************************/
4846 /* returns boolean */
00 #! /bin/sh
1 # Copyright (C) 2011-2020 Free Software Foundation, Inc.
1 # Copyright (C) 2011-2021 Free Software Foundation, Inc.
22 #
33 # This program is free software; you can redistribute it and/or modify
44 # it under the terms of the GNU General Public License as published by
22
33 scriptversion=2018-03-07.03; # UTC
44
5 # Copyright (C) 2011-2020 Free Software Foundation, Inc.
5 # Copyright (C) 2011-2021 Free Software Foundation, Inc.
66 #
77 # This program is free software; you can redistribute it and/or modify
88 # it under the terms of the GNU General Public License as published by
104104 trap "st=141; $do_exit" 13
105105 trap "st=143; $do_exit" 15
106106
107 # Test script is run here.
108 "$@" >$log_file 2>&1
107 # Test script is run here. We create the file first, then append to it,
108 # to ameliorate tests themselves also writing to the log file. Our tests
109 # don't, but others can (automake bug#35762).
110 : >"$log_file"
111 "$@" >>"$log_file" 2>&1
109112 estatus=$?
110113
111114 if test $enable_hard_errors = no && test $estatus -eq 99; then
127130 # know whether the test passed or failed simply by looking at the '.log'
128131 # file, without the need of also peaking into the corresponding '.trs'
129132 # file (automake bug#11814).
130 echo "$res $test_name (exit status: $estatus)" >>$log_file
133 echo "$res $test_name (exit status: $estatus)" >>"$log_file"
131134
132135 # Report outcome to console.
133136 echo "${col}${res}${std}: $test_name"
33
44 SUBDIRS = \
55 common \
6 memtest
6 libxrdp \
7 memtest \
8 xrdp
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
158158 unique=`for i in $$list; do \
159159 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
160160 done | $(am__uniquify_input)`
161 ETAGS = etags
162 CTAGS = ctags
163161 DIST_SUBDIRS = $(SUBDIRS)
164162 am__DIST_COMMON = $(srcdir)/Makefile.in
165163 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
203201 CHECK_LIBS = @CHECK_LIBS@
204202 CPP = @CPP@
205203 CPPFLAGS = @CPPFLAGS@
204 CSCOPE = @CSCOPE@
205 CTAGS = @CTAGS@
206206 CYGPATH_W = @CYGPATH_W@
207207 DEFS = @DEFS@
208208 DEPDIR = @DEPDIR@
214214 ECHO_N = @ECHO_N@
215215 ECHO_T = @ECHO_T@
216216 EGREP = @EGREP@
217 ETAGS = @ETAGS@
217218 EXEEXT = @EXEEXT@
218219 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
219220 FDKAAC_LIBS = @FDKAAC_LIBS@
223224 FUSE_CFLAGS = @FUSE_CFLAGS@
224225 FUSE_LIBS = @FUSE_LIBS@
225226 GREP = @GREP@
227 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
228 IMLIB2_LIBS = @IMLIB2_LIBS@
226229 INSTALL = @INSTALL@
227230 INSTALL_DATA = @INSTALL_DATA@
228231 INSTALL_PROGRAM = @INSTALL_PROGRAM@
338341
339342 SUBDIRS = \
340343 common \
341 memtest
344 libxrdp \
345 memtest \
346 xrdp
342347
343348 all: all-recursive
344349
477482
478483 distclean-tags:
479484 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
480
481485 distdir: $(BUILT_SOURCES)
482486 $(MAKE) $(AM_MAKEFLAGS) distdir-am
483487
55 LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
66 $(top_srcdir)/tap-driver.sh
77
8 PACKAGE_STRING = "libcommon"
9
810 TESTS = test_common
911 check_PROGRAMS = test_common
1012
1113 test_common_SOURCES = \
1214 test_common.h \
1315 test_common_main.c \
14 test_string_calls.c
16 test_string_calls.c \
17 test_os_calls.c \
18 test_ssl_calls.c \
19 test_base64.c
1520
1621 test_common_CFLAGS = \
17 @CHECK_CFLAGS@
22 @CHECK_CFLAGS@ \
23 -D TOP_SRCDIR=\"$(top_srcdir)\"
1824
1925 test_common_LDADD = \
2026 $(top_builddir)/common/libcommon.la \
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
109109 CONFIG_CLEAN_FILES =
110110 CONFIG_CLEAN_VPATH_FILES =
111111 am_test_common_OBJECTS = test_common-test_common_main.$(OBJEXT) \
112 test_common-test_string_calls.$(OBJEXT)
112 test_common-test_string_calls.$(OBJEXT) \
113 test_common-test_os_calls.$(OBJEXT) \
114 test_common-test_ssl_calls.$(OBJEXT) \
115 test_common-test_base64.$(OBJEXT)
113116 test_common_OBJECTS = $(am_test_common_OBJECTS)
114117 test_common_DEPENDENCIES = $(top_builddir)/common/libcommon.la
115118 AM_V_lt = $(am__v_lt_@AM_V@)
134137 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
135138 depcomp = $(SHELL) $(top_srcdir)/depcomp
136139 am__maybe_remake_depfiles = depfiles
137 am__depfiles_remade = ./$(DEPDIR)/test_common-test_common_main.Po \
140 am__depfiles_remade = ./$(DEPDIR)/test_common-test_base64.Po \
141 ./$(DEPDIR)/test_common-test_common_main.Po \
142 ./$(DEPDIR)/test_common-test_os_calls.Po \
143 ./$(DEPDIR)/test_common-test_ssl_calls.Po \
138144 ./$(DEPDIR)/test_common-test_string_calls.Po
139145 am__mv = mv -f
140146 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
179185 unique=`for i in $$list; do \
180186 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
181187 done | $(am__uniquify_input)`
182 ETAGS = etags
183 CTAGS = ctags
184188 am__tty_colors_dummy = \
185189 mgn= red= grn= lgn= blu= brg= std=; \
186190 am__color_tests=no
403407 CHECK_LIBS = @CHECK_LIBS@
404408 CPP = @CPP@
405409 CPPFLAGS = @CPPFLAGS@
410 CSCOPE = @CSCOPE@
411 CTAGS = @CTAGS@
406412 CYGPATH_W = @CYGPATH_W@
407413 DEFS = @DEFS@
408414 DEPDIR = @DEPDIR@
414420 ECHO_N = @ECHO_N@
415421 ECHO_T = @ECHO_T@
416422 EGREP = @EGREP@
423 ETAGS = @ETAGS@
417424 EXEEXT = @EXEEXT@
418425 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
419426 FDKAAC_LIBS = @FDKAAC_LIBS@
423430 FUSE_CFLAGS = @FUSE_CFLAGS@
424431 FUSE_LIBS = @FUSE_LIBS@
425432 GREP = @GREP@
433 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
434 IMLIB2_LIBS = @IMLIB2_LIBS@
426435 INSTALL = @INSTALL@
427436 INSTALL_DATA = @INSTALL_DATA@
428437 INSTALL_PROGRAM = @INSTALL_PROGRAM@
452461 PACKAGE = @PACKAGE@
453462 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
454463 PACKAGE_NAME = @PACKAGE_NAME@
455 PACKAGE_STRING = @PACKAGE_STRING@
464 PACKAGE_STRING = "libcommon"
456465 PACKAGE_TARNAME = @PACKAGE_TARNAME@
457466 PACKAGE_URL = @PACKAGE_URL@
458467 PACKAGE_VERSION = @PACKAGE_VERSION@
543552 test_common_SOURCES = \
544553 test_common.h \
545554 test_common_main.c \
546 test_string_calls.c
555 test_string_calls.c \
556 test_os_calls.c \
557 test_ssl_calls.c \
558 test_base64.c
547559
548560 test_common_CFLAGS = \
549 @CHECK_CFLAGS@
561 @CHECK_CFLAGS@ \
562 -D TOP_SRCDIR=\"$(top_srcdir)\"
550563
551564 test_common_LDADD = \
552565 $(top_builddir)/common/libcommon.la \
605618 distclean-compile:
606619 -rm -f *.tab.c
607620
621 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_common-test_base64.Po@am__quote@ # am--include-marker
608622 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_common-test_common_main.Po@am__quote@ # am--include-marker
623 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_common-test_os_calls.Po@am__quote@ # am--include-marker
624 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_common-test_ssl_calls.Po@am__quote@ # am--include-marker
609625 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_common-test_string_calls.Po@am__quote@ # am--include-marker
610626
611627 $(am__depfiles_remade):
662678 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_string_calls.c' object='test_common-test_string_calls.obj' libtool=no @AMDEPBACKSLASH@
663679 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
664680 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -c -o test_common-test_string_calls.obj `if test -f 'test_string_calls.c'; then $(CYGPATH_W) 'test_string_calls.c'; else $(CYGPATH_W) '$(srcdir)/test_string_calls.c'; fi`
681
682 test_common-test_os_calls.o: test_os_calls.c
683 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -MT test_common-test_os_calls.o -MD -MP -MF $(DEPDIR)/test_common-test_os_calls.Tpo -c -o test_common-test_os_calls.o `test -f 'test_os_calls.c' || echo '$(srcdir)/'`test_os_calls.c
684 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_common-test_os_calls.Tpo $(DEPDIR)/test_common-test_os_calls.Po
685 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_os_calls.c' object='test_common-test_os_calls.o' libtool=no @AMDEPBACKSLASH@
686 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
687 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -c -o test_common-test_os_calls.o `test -f 'test_os_calls.c' || echo '$(srcdir)/'`test_os_calls.c
688
689 test_common-test_os_calls.obj: test_os_calls.c
690 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -MT test_common-test_os_calls.obj -MD -MP -MF $(DEPDIR)/test_common-test_os_calls.Tpo -c -o test_common-test_os_calls.obj `if test -f 'test_os_calls.c'; then $(CYGPATH_W) 'test_os_calls.c'; else $(CYGPATH_W) '$(srcdir)/test_os_calls.c'; fi`
691 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_common-test_os_calls.Tpo $(DEPDIR)/test_common-test_os_calls.Po
692 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_os_calls.c' object='test_common-test_os_calls.obj' libtool=no @AMDEPBACKSLASH@
693 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
694 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -c -o test_common-test_os_calls.obj `if test -f 'test_os_calls.c'; then $(CYGPATH_W) 'test_os_calls.c'; else $(CYGPATH_W) '$(srcdir)/test_os_calls.c'; fi`
695
696 test_common-test_ssl_calls.o: test_ssl_calls.c
697 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -MT test_common-test_ssl_calls.o -MD -MP -MF $(DEPDIR)/test_common-test_ssl_calls.Tpo -c -o test_common-test_ssl_calls.o `test -f 'test_ssl_calls.c' || echo '$(srcdir)/'`test_ssl_calls.c
698 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_common-test_ssl_calls.Tpo $(DEPDIR)/test_common-test_ssl_calls.Po
699 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_ssl_calls.c' object='test_common-test_ssl_calls.o' libtool=no @AMDEPBACKSLASH@
700 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
701 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -c -o test_common-test_ssl_calls.o `test -f 'test_ssl_calls.c' || echo '$(srcdir)/'`test_ssl_calls.c
702
703 test_common-test_ssl_calls.obj: test_ssl_calls.c
704 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -MT test_common-test_ssl_calls.obj -MD -MP -MF $(DEPDIR)/test_common-test_ssl_calls.Tpo -c -o test_common-test_ssl_calls.obj `if test -f 'test_ssl_calls.c'; then $(CYGPATH_W) 'test_ssl_calls.c'; else $(CYGPATH_W) '$(srcdir)/test_ssl_calls.c'; fi`
705 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_common-test_ssl_calls.Tpo $(DEPDIR)/test_common-test_ssl_calls.Po
706 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_ssl_calls.c' object='test_common-test_ssl_calls.obj' libtool=no @AMDEPBACKSLASH@
707 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
708 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -c -o test_common-test_ssl_calls.obj `if test -f 'test_ssl_calls.c'; then $(CYGPATH_W) 'test_ssl_calls.c'; else $(CYGPATH_W) '$(srcdir)/test_ssl_calls.c'; fi`
709
710 test_common-test_base64.o: test_base64.c
711 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -MT test_common-test_base64.o -MD -MP -MF $(DEPDIR)/test_common-test_base64.Tpo -c -o test_common-test_base64.o `test -f 'test_base64.c' || echo '$(srcdir)/'`test_base64.c
712 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_common-test_base64.Tpo $(DEPDIR)/test_common-test_base64.Po
713 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_base64.c' object='test_common-test_base64.o' libtool=no @AMDEPBACKSLASH@
714 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
715 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -c -o test_common-test_base64.o `test -f 'test_base64.c' || echo '$(srcdir)/'`test_base64.c
716
717 test_common-test_base64.obj: test_base64.c
718 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -MT test_common-test_base64.obj -MD -MP -MF $(DEPDIR)/test_common-test_base64.Tpo -c -o test_common-test_base64.obj `if test -f 'test_base64.c'; then $(CYGPATH_W) 'test_base64.c'; else $(CYGPATH_W) '$(srcdir)/test_base64.c'; fi`
719 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_common-test_base64.Tpo $(DEPDIR)/test_common-test_base64.Po
720 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_base64.c' object='test_common-test_base64.obj' libtool=no @AMDEPBACKSLASH@
721 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
722 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_common_CFLAGS) $(CFLAGS) -c -o test_common-test_base64.obj `if test -f 'test_base64.c'; then $(CYGPATH_W) 'test_base64.c'; else $(CYGPATH_W) '$(srcdir)/test_base64.c'; fi`
665723
666724 mostlyclean-libtool:
667725 -rm -f *.lo
883941 @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
884942 @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
885943 @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
886
887944 distdir: $(BUILT_SOURCES)
888945 $(MAKE) $(AM_MAKEFLAGS) distdir-am
889946
9621019 mostlyclean-am
9631020
9641021 distclean: distclean-am
965 -rm -f ./$(DEPDIR)/test_common-test_common_main.Po
1022 -rm -f ./$(DEPDIR)/test_common-test_base64.Po
1023 -rm -f ./$(DEPDIR)/test_common-test_common_main.Po
1024 -rm -f ./$(DEPDIR)/test_common-test_os_calls.Po
1025 -rm -f ./$(DEPDIR)/test_common-test_ssl_calls.Po
9661026 -rm -f ./$(DEPDIR)/test_common-test_string_calls.Po
9671027 -rm -f Makefile
9681028 distclean-am: clean-am distclean-compile distclean-generic \
10091069 installcheck-am:
10101070
10111071 maintainer-clean: maintainer-clean-am
1012 -rm -f ./$(DEPDIR)/test_common-test_common_main.Po
1072 -rm -f ./$(DEPDIR)/test_common-test_base64.Po
1073 -rm -f ./$(DEPDIR)/test_common-test_common_main.Po
1074 -rm -f ./$(DEPDIR)/test_common-test_os_calls.Po
1075 -rm -f ./$(DEPDIR)/test_common-test_ssl_calls.Po
10131076 -rm -f ./$(DEPDIR)/test_common-test_string_calls.Po
10141077 -rm -f Makefile
10151078 maintainer-clean-am: distclean-am maintainer-clean-generic
0
1 #if defined(HAVE_CONFIG_H)
2 #include "config_ac.h"
3 #endif
4
5 #include "os_calls.h"
6 #include "string_calls.h"
7 #include "base64.h"
8
9 #include "test_common.h"
10 /*
11 * These are the example test strings in RFC4648(10)
12 */
13 static const char *rfc4648_ex1_text = "";
14 static const char *rfc4648_ex1_b64 = "";
15 static const char *rfc4648_ex2_text = "f";
16 static const char *rfc4648_ex2_b64 = "Zg==";
17 static const char *rfc4648_ex3_text = "fo";
18 static const char *rfc4648_ex3_b64 = "Zm8=";
19 static const char *rfc4648_ex4_text = "foo";
20 static const char *rfc4648_ex4_b64 = "Zm9v";
21 static const char *rfc4648_ex5_text = "foob";
22 static const char *rfc4648_ex5_b64 = "Zm9vYg==";
23 static const char *rfc4648_ex6_text = "fooba";
24 static const char *rfc4648_ex6_b64 = "Zm9vYmE=";
25 static const char *rfc4648_ex7_text = "foobar";
26 static const char *rfc4648_ex7_b64 = "Zm9vYmFy";
27
28 /* Every single valid base64 character, except padding */
29 static const char *all_b64 =
30 "ABCDEFGHIJKL"
31 "MNOPQRSTUVWX"
32 "YZabcdefghij"
33 "klmnopqrstuv"
34 "wxyz01234567"
35 "89+/";
36
37 /* What we should get as binary if we decode this */
38 static const char all_b64_decoded[] =
39 {
40 '\x00', '\x10', '\x83', '\x10', '\x51', '\x87', '\x20', '\x92', '\x8b',
41 '\x30', '\xd3', '\x8f', '\x41', '\x14', '\x93', '\x51', '\x55', '\x97',
42 '\x61', '\x96', '\x9b', '\x71', '\xd7', '\x9f', '\x82', '\x18', '\xa3',
43 '\x92', '\x59', '\xa7', '\xa2', '\x9a', '\xab', '\xb2', '\xdb', '\xaf',
44 '\xc3', '\x1c', '\xb3', '\xd3', '\x5d', '\xb7', '\xe3', '\x9e', '\xbb',
45 '\xf3', '\xdf', '\xbf'
46 };
47
48 static void
49 test_rfc4648_to_b64(const char *plaintext, size_t len, const char *b64)
50 {
51 char buff[256];
52 size_t result;
53
54 result = base64_encode(plaintext, len, buff, sizeof(buff));
55 ck_assert_int_eq(result, len);
56 ck_assert_str_eq(buff, b64);
57
58 }
59
60 /* Text-only encoder wrapper */
61 static void
62 test_rfc4648_to_b64_text(const char *plaintext, const char *b64)
63 {
64 test_rfc4648_to_b64(plaintext, g_strlen(plaintext), b64);
65 }
66
67 /* Text-only decoder wrapper for valid base64 */
68 static void
69 test_rfc4648_from_b64_text(const char *b64, const char *text)
70 {
71 char buff[256];
72 size_t actual_len;
73 int result;
74
75 result = base64_decode(b64, buff, sizeof(buff), &actual_len);
76 ck_assert_int_eq(result, 0);
77 ck_assert_int_lt(actual_len, sizeof(buff));
78 buff[actual_len] = '\0';
79 ck_assert_str_eq(buff, text);
80 }
81
82 /******************************************************************************/
83 START_TEST(test_b64_rfc4648_ex1_to)
84 {
85 test_rfc4648_to_b64_text(rfc4648_ex1_text, rfc4648_ex1_b64);
86 }
87 END_TEST
88
89 /******************************************************************************/
90 START_TEST(test_b64_rfc4648_ex1_from)
91 {
92 test_rfc4648_from_b64_text(rfc4648_ex1_b64, rfc4648_ex1_text);
93 }
94 END_TEST
95
96 /******************************************************************************/
97 START_TEST(test_b64_rfc4648_ex2_to)
98 {
99 test_rfc4648_to_b64_text(rfc4648_ex2_text, rfc4648_ex2_b64);
100 }
101 END_TEST
102
103 /******************************************************************************/
104 START_TEST(test_b64_rfc4648_ex2_from)
105 {
106 test_rfc4648_from_b64_text(rfc4648_ex2_b64, rfc4648_ex2_text);
107 }
108 END_TEST
109
110 /******************************************************************************/
111 START_TEST(test_b64_rfc4648_ex3_to)
112 {
113 test_rfc4648_to_b64_text(rfc4648_ex3_text, rfc4648_ex3_b64);
114 }
115 END_TEST
116
117 /******************************************************************************/
118 START_TEST(test_b64_rfc4648_ex3_from)
119 {
120 test_rfc4648_from_b64_text(rfc4648_ex3_b64, rfc4648_ex3_text);
121 }
122 END_TEST
123
124 /******************************************************************************/
125 START_TEST(test_b64_rfc4648_ex4_to)
126 {
127 test_rfc4648_to_b64_text(rfc4648_ex4_text, rfc4648_ex4_b64);
128 }
129 END_TEST
130
131 /******************************************************************************/
132 START_TEST(test_b64_rfc4648_ex4_from)
133 {
134 test_rfc4648_from_b64_text(rfc4648_ex4_b64, rfc4648_ex4_text);
135 }
136 END_TEST
137
138 /******************************************************************************/
139 START_TEST(test_b64_rfc4648_ex5_to)
140 {
141 test_rfc4648_to_b64_text(rfc4648_ex5_text, rfc4648_ex5_b64);
142 }
143 END_TEST
144
145 /******************************************************************************/
146 START_TEST(test_b64_rfc4648_ex5_from)
147 {
148 test_rfc4648_from_b64_text(rfc4648_ex5_b64, rfc4648_ex5_text);
149 }
150 END_TEST
151
152 /******************************************************************************/
153 START_TEST(test_b64_rfc4648_ex6_to)
154 {
155 test_rfc4648_to_b64_text(rfc4648_ex6_text, rfc4648_ex6_b64);
156 }
157 END_TEST
158
159 /******************************************************************************/
160 START_TEST(test_b64_rfc4648_ex6_from)
161 {
162 test_rfc4648_from_b64_text(rfc4648_ex6_b64, rfc4648_ex6_text);
163 }
164 END_TEST
165
166 /******************************************************************************/
167 START_TEST(test_b64_rfc4648_ex7_to)
168 {
169 test_rfc4648_to_b64_text(rfc4648_ex7_text, rfc4648_ex7_b64);
170 }
171 END_TEST
172
173 /******************************************************************************/
174 START_TEST(test_b64_rfc4648_ex7_from)
175 {
176 test_rfc4648_from_b64_text(rfc4648_ex7_b64, rfc4648_ex7_text);
177 }
178 END_TEST
179
180 /******************************************************************************/
181 START_TEST(test_b64_all_valid_from)
182 {
183 char buff[256];
184 size_t actual_len;
185 int result;
186 char *str_result;
187 char *str_expected;
188
189 result = base64_decode(all_b64, buff, sizeof(buff), &actual_len);
190 ck_assert_int_eq(result, 0);
191 ck_assert_int_eq(actual_len, sizeof(all_b64_decoded));
192 str_result = bin_to_hex(buff, actual_len);
193 str_expected = bin_to_hex(all_b64_decoded, sizeof(all_b64_decoded));
194 ck_assert_str_eq(str_result, str_expected);
195 free(str_result);
196 free(str_expected);
197 }
198 END_TEST
199
200 /******************************************************************************/
201 START_TEST(test_b64_all_valid_to)
202 {
203 char buff[256];
204 size_t result;
205
206 result = base64_encode(all_b64_decoded, sizeof(all_b64_decoded),
207 buff, sizeof(buff));
208 ck_assert_int_eq(result, sizeof(all_b64_decoded));
209 ck_assert_str_eq(buff, all_b64);
210 }
211 END_TEST
212
213 /******************************************************************************/
214 START_TEST(test_b64_all_invalid)
215 {
216 char buff[256];
217 size_t actual_len;
218 char valid[256] = {0};
219 char encoded[5] = { "T0sh" }; /* Decodes to 'OK!' */
220 int result;
221
222 /* Make a note of all the valid b64 characters */
223 unsigned int i = 0;
224 unsigned char c;
225 while ((c = all_b64[i]) != '\0')
226 {
227 valid[c] = 1;
228 ++i;
229 }
230
231 /* Check the decoder's working on a simple string...*/
232 result = base64_decode(encoded, buff, sizeof(buff), &actual_len);
233 ck_assert_int_eq(result, 0);
234 ck_assert_int_eq(actual_len, 3);
235 buff[actual_len] = '\0';
236 ck_assert_str_eq(buff, "OK!");
237
238 /* Now replace the 1st character with all invalid characters in turn,
239 * and check they're rejected */
240 for (i = 0 ; i < 256; ++i)
241 {
242 if (i != '\0' && !valid[i]) /* Don't try the string terminator char! */
243 {
244 encoded[0] = i;
245 result = base64_decode(encoded, buff, sizeof(buff), &actual_len);
246 if (result == 0)
247 {
248 ck_abort_msg("Character 0x%02x was not rejected", i);
249 }
250 }
251 }
252 }
253 END_TEST
254
255 /******************************************************************************/
256 START_TEST(test_b64_small_buffer_encode)
257 {
258 char buff[10 * 4 + 1]; /* Enough space for 10 quanta */
259
260 size_t result;
261
262 result = base64_encode(all_b64_decoded, sizeof(all_b64_decoded),
263 buff, sizeof(buff));
264 /* Should have read 10 lots of 24 bits from the input */
265 ck_assert_int_eq(result, 10 * 3);
266 ck_assert_str_eq(buff, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn");
267 }
268 END_TEST
269
270 /******************************************************************************/
271 START_TEST(test_b64_small_buffer_decode)
272 {
273 char buff[10]; /* Enough space for 10 chars */
274
275 size_t actual_len;
276 int result;
277 char *str_result;
278 char *str_expected;
279
280 result = base64_decode(all_b64, buff, sizeof(buff), &actual_len);
281 ck_assert_int_eq(result, 0);
282 ck_assert_int_eq(actual_len, sizeof(all_b64_decoded));
283 str_result = bin_to_hex(buff, sizeof(buff));
284 str_expected = bin_to_hex(all_b64_decoded, sizeof(buff));
285 ck_assert_str_eq(str_result, str_expected);
286 free(str_result);
287 free(str_expected);
288 }
289 END_TEST
290
291 /******************************************************************************/
292 START_TEST(test_b64_add_pad_one)
293 {
294 /* Check that a missing trailing '=' is added when decoding */
295 test_rfc4648_from_b64_text("Zm8", "fo"); /* RFC4648 example 3 */
296 }
297 END_TEST
298
299 /******************************************************************************/
300 START_TEST(test_b64_add_pad_two)
301 {
302 /* Check that two missing trailing '=' chars are added when decoding */
303 test_rfc4648_from_b64_text("Zg", "f"); /* RFC4648 example 2 */
304 }
305 END_TEST
306
307 /******************************************************************************/
308 START_TEST(test_b64_bad_pad)
309 {
310 char buff[16];
311 size_t actual_len;
312
313 /* Check all bad quanta with padding chars */
314 static const char *bad_pad[] =
315 {
316 "=AAA",
317 "A=AA",
318 "AA=A",
319 "==AA",
320 "=A=A",
321 "=AA=",
322 "A==A",
323 "A=A=",
324 "===A",
325 "A===",
326 NULL
327 };
328 const char **p;
329
330 for (p = bad_pad ; *p != NULL ; ++p)
331 {
332 int result = base64_decode(*p, buff, sizeof(buff), &actual_len);
333 if (result == 0)
334 {
335 ck_abort_msg("Padding '%s' was not rejected", *p);
336 }
337 }
338 }
339 END_TEST
340
341 /******************************************************************************/
342 START_TEST(test_b64_concat_pad)
343 {
344 const char *src =
345 "VGVzdA==" /* Test */
346 "IA==" /* <space> */
347 "Y29uY2F0ZW5hdGVk" /* concatenated */
348 "IA==" /* <space> */
349 "cGFkZGluZw=="; /*padding */
350 const char *expected = "Test concatenated padding";
351 char buff[64];
352 size_t actual_len;
353 int result;
354
355 result = base64_decode(src, buff, sizeof(buff), &actual_len);
356 ck_assert_int_eq(result, 0);
357 ck_assert_int_eq(actual_len, g_strlen(expected));
358 buff[actual_len] = '\0';
359 ck_assert_str_eq(buff, expected);
360 }
361 END_TEST
362
363 /******************************************************************************/
364 Suite *
365 make_suite_test_base64(void)
366 {
367 Suite *s;
368 TCase *tc_b64;
369
370 s = suite_create("base64");
371
372 tc_b64 = tcase_create("base64");
373 suite_add_tcase(s, tc_b64);
374 tcase_add_test(tc_b64, test_b64_rfc4648_ex1_to);
375 tcase_add_test(tc_b64, test_b64_rfc4648_ex1_from);
376 tcase_add_test(tc_b64, test_b64_rfc4648_ex2_to);
377 tcase_add_test(tc_b64, test_b64_rfc4648_ex2_from);
378 tcase_add_test(tc_b64, test_b64_rfc4648_ex3_to);
379 tcase_add_test(tc_b64, test_b64_rfc4648_ex3_from);
380 tcase_add_test(tc_b64, test_b64_rfc4648_ex4_to);
381 tcase_add_test(tc_b64, test_b64_rfc4648_ex4_from);
382 tcase_add_test(tc_b64, test_b64_rfc4648_ex5_to);
383 tcase_add_test(tc_b64, test_b64_rfc4648_ex5_from);
384 tcase_add_test(tc_b64, test_b64_rfc4648_ex6_to);
385 tcase_add_test(tc_b64, test_b64_rfc4648_ex6_from);
386 tcase_add_test(tc_b64, test_b64_rfc4648_ex7_to);
387 tcase_add_test(tc_b64, test_b64_rfc4648_ex7_from);
388 tcase_add_test(tc_b64, test_b64_all_valid_from);
389 tcase_add_test(tc_b64, test_b64_all_valid_to);
390 tcase_add_test(tc_b64, test_b64_all_invalid);
391 tcase_add_test(tc_b64, test_b64_small_buffer_encode);
392 tcase_add_test(tc_b64, test_b64_small_buffer_decode);
393 tcase_add_test(tc_b64, test_b64_add_pad_one);
394 tcase_add_test(tc_b64, test_b64_add_pad_two);
395 tcase_add_test(tc_b64, test_b64_bad_pad);
396 tcase_add_test(tc_b64, test_b64_concat_pad);
397
398 return s;
399 }
33
44 #include <check.h>
55
6 char *
7 bin_to_hex(const char *input, int length);
8
69 Suite *make_suite_test_string(void);
10 Suite *make_suite_test_os_calls(void);
11 Suite *make_suite_test_ssl_calls(void);
12 Suite *make_suite_test_base64(void);
713
8 #endif /* TEST_COMMON_H */
14 #endif /* TEST_COMMON_H */
33 #endif
44
55 #include <stdlib.h>
6 #include <check.h>
6
7 #include "log.h"
8 #include "ssl_calls.h"
9
710 #include "test_common.h"
11
12 /**
13 * Converts a binary buffer to a hexadecimal representation
14 *
15 * Result must be free'd after use
16 */
17 char *
18 bin_to_hex(const char *input, int length)
19 {
20 int i;
21 char *result = (char *)malloc(length * 2 + 1);
22 if (result != NULL)
23 {
24 char *p = result;
25 const char *hexdigit = "0123456789abcdef";
26 for (i = 0 ; i < length ; ++i)
27 {
28 int c = input[i];
29 if (c < 0)
30 {
31 c += 256;
32 }
33 *p++ = hexdigit[ c / 16];
34 *p++ = hexdigit[ c % 16];
35 }
36 *p = '\0';
37 }
38
39 return result;
40 }
841
942 int main (void)
1043 {
1245 SRunner *sr;
1346
1447 sr = srunner_create (make_suite_test_string());
48 srunner_add_suite(sr, make_suite_test_os_calls());
49 srunner_add_suite(sr, make_suite_test_ssl_calls());
50 srunner_add_suite(sr, make_suite_test_base64());
1551 // srunner_add_suite(sr, make_list_suite());
1652
1753 srunner_set_tap(sr, "-");
54 /*
55 * Set up console logging */
56 struct log_config *lc = log_config_init_for_console(LOG_LEVEL_INFO, NULL);
57 log_start_from_param(lc);
58 log_config_free(lc);
59
60 /* Initialise the ssl module */
61 ssl_init();
62
1863 srunner_run_all (sr, CK_ENV);
1964 number_failed = srunner_ntests_failed(sr);
2065 srunner_free(sr);
66
67 ssl_finish();
68 log_end();
2169 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
2270 }
0
1 #if defined(HAVE_CONFIG_H)
2 #include "config_ac.h"
3 #endif
4
5 #include <stdlib.h>
6 #include "os_calls.h"
7
8 #include "test_common.h"
9
10 #ifndef TOP_SRCDIR
11 #define TOP_SRCDIR "."
12 #endif
13
14 START_TEST(test_g_file_get_size__returns_file_size)
15 {
16 unsigned long long size;
17
18 size = g_file_get_size(TOP_SRCDIR "/xrdp/xrdp256.bmp");
19 ck_assert_int_eq(size, 49278);
20
21
22 size = g_file_get_size(TOP_SRCDIR "/xrdp/ad256.bmp");
23 ck_assert_int_eq(size, 19766);
24
25 }
26 END_TEST
27
28 START_TEST(test_g_file_get_size__1GiB)
29 {
30 const char *file = "./file_1GiB.dat";
31 unsigned int block_size = 4096;
32 unsigned int block_count = 262144;
33 /* C90 5.2.4.2.1 guarantees long long is at least 64 bits */
34 const long long expected_size =
35 (long long)block_size * block_count;
36 long long size;
37 int system_rv;
38
39 char cmd[256];
40
41 /* Create a sparse file of the expected size with one block of data
42 * at the end */
43 g_snprintf(cmd, sizeof(cmd),
44 "dd if=/dev/zero of=%s bs=%u seek=%u count=1",
45 file,
46 block_size,
47 block_count - 1);
48
49 system_rv = system(cmd);
50 size = g_file_get_size(file);
51 g_file_delete(file);
52 ck_assert_int_eq(system_rv, 0);
53 ck_assert_int_eq(size, expected_size);
54 }
55 END_TEST
56
57 START_TEST(test_g_file_get_size__just_less_than_2GiB)
58 {
59 const char *file = "./file_2GiB.dat";
60 unsigned int block_size = 4096;
61 unsigned int block_count = 524287; /* 4096 * 52428__8__ = 2GiB */
62 /* C90 5.2.4.2.1 guarantees long long is at least 64 bits */
63 const long long expected_size =
64 (long long)block_size * block_count;
65 long long size;
66 int system_rv;
67
68 char cmd[256];
69
70 /* Create a sparse file of the expected size with one block of data
71 * at the end */
72 g_snprintf(cmd, sizeof(cmd),
73 "dd if=/dev/zero of=%s bs=%u seek=%u count=1",
74 file,
75 block_size,
76 block_count - 1);
77
78 system_rv = system(cmd);
79 size = g_file_get_size(file);
80 g_file_delete(file);
81 ck_assert_int_eq(system_rv, 0);
82 ck_assert_int_eq(size, expected_size);
83 }
84 END_TEST
85
86 /* skip these tests until g_file_get_size() supports large files*/
87 #if 0
88 START_TEST(test_g_file_get_size__2GiB)
89 {
90 const char *file = "./file_2GiB.dat";
91 unsigned int block_size = 4096;
92 unsigned int block_count = 524288;
93 /* C90 5.2.4.2.1 guarantees long long is at least 64 bits */
94 const long long expected_size =
95 (long long)block_size * block_count;
96 long long size;
97 int system_rv;
98
99 char cmd[256];
100
101 /* Create a sparse file of the expected size with one block of data
102 * at the end */
103 g_snprintf(cmd, sizeof(cmd),
104 "dd if=/dev/zero of=%s bs=%u seek=%u count=1",
105 file,
106 block_size,
107 block_count - 1);
108
109 system_rv = system(cmd);
110 size = g_file_get_size(file);
111 g_file_delete(file);
112 ck_assert_int_eq(system_rv, 0);
113 ck_assert_int_eq(size, expected_size);
114 }
115 END_TEST
116
117 START_TEST(test_g_file_get_size__5GiB)
118 {
119 const char *file = "./file_5GiB.dat";
120 unsigned int block_size = 4096;
121 unsigned int block_count = 1310720;
122 /* C90 5.2.4.2.1 guarantees long long is at least 64 bits */
123 const long long expected_size =
124 (long long)block_size * block_count;
125 long long size;
126 int system_rv;
127
128 char cmd[256];
129
130 /* Create a sparse file of the expected size with one block of data
131 * at the end */
132 g_snprintf(cmd, sizeof(cmd),
133 "dd if=/dev/zero of=%s bs=%u seek=%u count=1",
134 file,
135 block_size,
136 block_count - 1);
137
138 system_rv = system(cmd);
139 size = g_file_get_size(file);
140 g_file_delete(file);
141 ck_assert_int_eq(system_rv, 0);
142 ck_assert_int_eq(size, expected_size);
143 }
144 END_TEST
145 #endif
146
147 /******************************************************************************/
148 Suite *
149 make_suite_test_os_calls(void)
150 {
151 Suite *s;
152 TCase *tc_os_calls;
153
154 s = suite_create("OS-Calls");
155
156 tc_os_calls = tcase_create("oscalls-file");
157 suite_add_tcase(s, tc_os_calls);
158 tcase_add_test(tc_os_calls, test_g_file_get_size__returns_file_size);
159 tcase_add_test(tc_os_calls, test_g_file_get_size__1GiB);
160 tcase_add_test(tc_os_calls, test_g_file_get_size__just_less_than_2GiB);
161 #if 0
162 tcase_add_test(tc_os_calls, test_g_file_get_size__2GiB);
163 tcase_add_test(tc_os_calls, test_g_file_get_size__5GiB);
164 #endif
165
166 return s;
167 }
0
1 #if defined(HAVE_CONFIG_H)
2 #include "config_ac.h"
3 #endif
4
5 #include "os_calls.h"
6 #include "string_calls.h"
7 #include "ssl_calls.h"
8
9 #include "test_common.h"
10
11 START_TEST(test_rc4_enc_ok)
12 {
13 const char *key = "16_byte_key-----";
14 char text[] = "xrdp-test-suite-rc4-encryption";
15 char *result;
16
17 void *info = ssl_rc4_info_create();
18 ssl_rc4_set_key(info, key, g_strlen(key));
19 ssl_rc4_crypt(info, text, sizeof(text) - 1);
20 ssl_rc4_info_delete(info);
21 result = bin_to_hex(text, sizeof(text) - 1);
22 ck_assert(result != NULL);
23 /* Result should be the same as
24 * echo -n '<text>' | \
25 * openssl rc4 -K <hex-key> -e [-provider legacy] | \
26 * xxd -g0
27 *
28 * where <hex-key> is the string above in hexadecimal */
29 ck_assert_str_eq(result, "c080f175b2d85802dbf1042f07180ddc4be1d9bd4a44158f0aebf11c961b");
30 g_free(result);
31 }
32 END_TEST
33
34 START_TEST(test_rc4_enc_tv0_ok)
35 {
36 /*
37 * This is one of the 5 original RC4 test vectors posted in response to
38 * the 'RC4 Algorithm revealed' sci.crypt usenet posting */
39 unsigned char key[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
40 unsigned char text[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
41 const char *expected = "75b7878099e0c596";
42 char *result;
43
44 void *info = ssl_rc4_info_create();
45 ssl_rc4_set_key(info, (char *)key, sizeof(key));
46 ssl_rc4_crypt(info, (char *)text, sizeof(text));
47 ssl_rc4_info_delete(info);
48
49 result = bin_to_hex((char *)text, sizeof(text));
50 ck_assert(result != NULL);
51 ck_assert_str_eq(result, expected);
52 g_free(result);
53 }
54 END_TEST
55
56 START_TEST(test_rc4_enc_tv1_ok)
57 {
58 /*
59 * This is one of the 5 original RC4 test vectors posted in response to
60 * the 'RC4 Algorithm revealed' sci.crypt usenet posting */
61 unsigned char key[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
62 unsigned char text[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
63 const char *expected = "7494c2e7104b0879";
64 char *result;
65
66 void *info = ssl_rc4_info_create();
67 ssl_rc4_set_key(info, (char *)key, sizeof(key));
68 ssl_rc4_crypt(info, (char *)text, sizeof(text));
69 ssl_rc4_info_delete(info);
70
71 result = bin_to_hex((char *)text, sizeof(text));
72 ck_assert(result != NULL);
73 ck_assert_str_eq(result, expected);
74 g_free(result);
75 }
76 END_TEST
77
78 START_TEST(test_rc4_enc_tv2_ok)
79 {
80 /*
81 * This is one of the 5 original RC4 test vectors posted in response to
82 * the 'RC4 Algorithm revealed' sci.crypt usenet posting */
83 unsigned char key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
84 unsigned char text[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
85 const char *expected = "de188941a3375d3a";
86 char *result;
87
88 void *info = ssl_rc4_info_create();
89 ssl_rc4_set_key(info, (char *)key, sizeof(key));
90 ssl_rc4_crypt(info, (char *)text, sizeof(text));
91 ssl_rc4_info_delete(info);
92
93 result = bin_to_hex((char *)text, sizeof(text));
94 ck_assert(result != NULL);
95 ck_assert_str_eq(result, expected);
96 g_free(result);
97 }
98 END_TEST
99
100 START_TEST(test_rc4_enc_tv3_ok)
101 {
102 /*
103 * This is one of the 5 original RC4 test vectors posted in response to
104 * the 'RC4 Algorithm revealed' sci.crypt usenet posting */
105 unsigned char key[] = {0xef, 0x01, 0x23, 0x45};
106 unsigned char text[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
107 const char *expected = "d6a141a7ec3c38dfbd61";
108 char *result;
109
110 void *info = ssl_rc4_info_create();
111 ssl_rc4_set_key(info, (char *)key, sizeof(key));
112 ssl_rc4_crypt(info, (char *)text, sizeof(text));
113 ssl_rc4_info_delete(info);
114
115 result = bin_to_hex((char *)text, sizeof(text));
116 ck_assert(result != NULL);
117 ck_assert_str_eq(result, expected);
118 g_free(result);
119 }
120 END_TEST
121
122 START_TEST(test_rc4_enc_tv4_ok)
123 {
124 /*
125 * This is one of the 5 original RC4 test vectors posted in response to
126 * the 'RC4 Algorithm revealed' sci.crypt usenet posting */
127 unsigned char key[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
128 unsigned char text[] =
129 {
130 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
131 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
132 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
133 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
134 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
135 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
136 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
137 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
138 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
139 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
140 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
141 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
142 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
143 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
144 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
145 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
146 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
147 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
148 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
149 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
150 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
151 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
152 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
153 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
154 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
155 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
156 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
157 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
158 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
159 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
160 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
161 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
162 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
163 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
164 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
165 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
166 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
167 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
168 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
169 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
170 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
171 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
172 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
173 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
174 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
175 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
176 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
177 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
178 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
179 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
180 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
181 0x01, 0x01
182 };
183 const char *expected =
184 "7595c3e6114a09780c4ad452338e1ffd9a1be9498f813d76533449b6778dca"
185 "d8c78a8d2ba9ac66085d0e53d59c26c2d1c490c1ebbe0ce66d1b6b1b13b6"
186 "b919b847c25a91447a95e75e4ef16779cde8bf0a95850e32af9689444fd3"
187 "77108f98fdcbd4e726567500990bcc7e0ca3c4aaa304a387d20f3b8fbbcd"
188 "42a1bd311d7a4303dda5ab078896ae80c18b0af66dff319616eb784e495a"
189 "d2ce90d7f772a81747b65f62093b1e0db9e5ba532fafec47508323e67132"
190 "7df9444432cb7367cec82f5d44c0d00b67d650a075cd4b70dedd77eb9b10"
191 "231b6b5b741347396d62897421d43df9b42e446e358e9c11a9b2184ecbef"
192 "0cd8e7a877ef968f1390ec9b3d35a5585cb009290e2fcde7b5ec66d9084b"
193 "e44055a619d9dd7fc3166f9487f7cb272912426445998514c15d53a18c86"
194 "4ce3a2b7555793988126520eacf2e3066e230c91bee4dd5304f5fd0405b3"
195 "5bd99c73135d3d9bc335ee049ef69b3867bf2d7bd1eaa595d8bfc0066ff8"
196 "d31509eb0c6caa006c807a623ef84c3d33c195d23ee320c40de0558157c8"
197 "22d4b8c569d849aed59d4e0fd7f379586b4b7ff684ed6a189f7486d49b9c"
198 "4bad9ba24b96abf924372c8a8fffb10d55354900a77a3db5f205e1b99fcd"
199 "8660863a159ad4abe40fa48934163ddde542a6585540fd683cbfd8c00f12"
200 "129a284deacc4cdefe58be7137541c047126c8d49e2755ab181ab7e940b0c0";
201
202 char *result;
203
204 void *info = ssl_rc4_info_create();
205 ssl_rc4_set_key(info, (char *)key, sizeof(key));
206 ssl_rc4_crypt(info, (char *)text, sizeof(text));
207 ssl_rc4_info_delete(info);
208
209 result = bin_to_hex((char *)text, sizeof(text));
210 ck_assert(result != NULL);
211 ck_assert_str_eq(result, expected);
212 g_free(result);
213 }
214 END_TEST
215
216 START_TEST(test_sha1_hash_ok)
217 {
218 const char *hash_string = "xrdp-test-suite-sha1-hash";
219 char digest[20];
220 char *result1;
221 char *result2;
222
223 void *info = ssl_sha1_info_create();
224 ssl_sha1_clear(info);
225 ssl_sha1_transform(info, hash_string, g_strlen(hash_string));
226 ssl_sha1_complete(info, digest);
227 result1 = bin_to_hex(digest, sizeof(digest));
228 ck_assert(result1 != NULL);
229 /* Check result with echo -n '<hash_string>' | sha1sum */
230 ck_assert_str_eq(result1, "3ea0ae84e97e6262c7cfe79ccd7ad2094c06885d");
231
232 /* Check a clear has the desired effect */
233 ssl_sha1_clear(info);
234 ssl_sha1_transform(info, hash_string, g_strlen(hash_string));
235 ssl_sha1_complete(info, digest);
236 result2 = bin_to_hex(digest, sizeof(digest));
237 ck_assert(result2 != NULL);
238 ck_assert_str_eq(result1, result2);
239
240 ssl_sha1_info_delete(info);
241 g_free(result1);
242 g_free(result2);
243 }
244 END_TEST
245
246 START_TEST(test_md5_hash_ok)
247 {
248 const char *hash_string = "xrdp-test-suite-md5-hash";
249 char digest[16];
250 char *result1;
251 char *result2;
252
253 void *info = ssl_md5_info_create();
254
255 ssl_md5_clear(info);
256 ssl_md5_transform(info, hash_string, g_strlen(hash_string));
257 ssl_md5_complete(info, digest);
258 result1 = bin_to_hex(digest, sizeof(digest));
259 ck_assert(result1 != NULL);
260 /* Check result with echo -n '<hash_string>' | md5sum */
261 ck_assert_str_eq(result1, "ddc599dc7ec62b8f78760b071704c007");
262
263 /* Check a clear has the desired effect */
264 ssl_md5_clear(info);
265 ssl_md5_transform(info, hash_string, g_strlen(hash_string));
266 ssl_md5_complete(info, digest);
267 result2 = bin_to_hex(digest, sizeof(digest));
268 ck_assert(result2 != NULL);
269 ck_assert_str_eq(result1, result2);
270
271 ssl_md5_info_delete(info);
272 g_free(result1);
273 g_free(result2);
274 }
275 END_TEST
276
277 START_TEST(test_des3_enc_ok)
278 {
279 const char *key = "24_byte_key-------------";
280 char plaintext[] = "xrdp-test-suite-des3-encryption-must-be-multiple-of-8-chars-long--------";
281 char ciphertext[sizeof(plaintext) - 1]; /* No terminator needed */
282 char plaintext2[sizeof(plaintext)];
283
284 char *result;
285
286 void *info = ssl_des3_encrypt_info_create(key, 0);
287 ssl_des3_encrypt(info, sizeof(plaintext) - 1, plaintext, ciphertext);
288 ssl_des3_info_delete(info);
289 result = bin_to_hex(ciphertext, sizeof(ciphertext));
290 ck_assert(result != NULL);
291 /* Result should be the same as
292 * echo -n '<text>' | \
293 * openssl des3 -iv 0000000000000000 -K <hex-key> -e -nopad | \
294 * od -t x1
295 *
296 * where <hex-key> is the string above in hexadecimal */
297 ck_assert_str_eq(result,
298 "856d70861827365e188781616e4f9dcc3009b2c5dc7785edcbc05fa825a4ea5e10b23735c0e971ca20f895f455b8845418963af6dd8e649719790eed6cbcee0fb97b743c60e32e8b");
299 g_free(result);
300
301 /* Let's go back again */
302 info = ssl_des3_decrypt_info_create(key, 0);
303 ssl_des3_decrypt(info, sizeof(ciphertext), ciphertext, plaintext2);
304 ssl_des3_info_delete(info);
305 plaintext2[sizeof(plaintext2) - 1] = '\0';
306
307 ck_assert_str_eq(plaintext, plaintext2);
308 }
309 END_TEST
310
311 START_TEST(test_hmac_sha1_dgst_ok)
312 {
313 const char *key = "20_byte_key---------";
314 const char *hash_string = "xrdp-test-suite-hmac-sha1-dgst";
315 char hmac[20];
316
317 char *result;
318
319 void *info = ssl_hmac_info_create();
320 ssl_hmac_sha1_init(info, key, g_strlen(key));
321 ssl_hmac_transform(info, hash_string, g_strlen(hash_string));
322 ssl_hmac_complete(info, hmac, sizeof(hmac));
323 ssl_hmac_info_delete(info);
324 result = bin_to_hex(hmac, sizeof(hmac));
325 ck_assert(result != NULL);
326 /* Result should be the same as
327 * echo -n '<text>' | openssl dgst -sha1 -hmac '<key>'
328 *
329 * or:-
330 *
331 * echo -n '<text>' | openssl mac -digest sha1 -macopt key:'<key>' hmac
332 */
333 ck_assert_str_eq(result, "af8c04e609e9f3cba53ad7815b60160dc69a9936");
334 g_free(result);
335
336 }
337 END_TEST
338
339 START_TEST(test_gen_key_xrdp1)
340 {
341 #define RSA_TEST_BITS 2048
342 char modulus[RSA_TEST_BITS / 8] = {0};
343 char private_key[RSA_TEST_BITS / 8] = {0};
344 unsigned char exponent[4] =
345 {
346 0x01, 0x00, 0x01, 0x00 /* 65537 in little-endian format */
347 };
348
349 /*
350 * We can't do much here because of the nature of the call, but we can
351 * at least check it completes without error */
352 int error;
353 error = ssl_gen_key_xrdp1(RSA_TEST_BITS,
354 (const char *)exponent, sizeof(exponent),
355 modulus, sizeof(modulus),
356 private_key, sizeof(private_key));
357 ck_assert(error == 0);
358
359 /* Both the modulus and the privatekey should be odd */
360 ck_assert((modulus[0] & 1) == 1);
361 ck_assert((private_key[0] & 1) == 1);
362 #undef RSA_TEST_BITS
363 }
364 END_TEST
365
366 /******************************************************************************/
367 Suite *
368 make_suite_test_ssl_calls(void)
369 {
370 Suite *s;
371 TCase *tc_ssl_calls;
372
373 s = suite_create("SSL-Calls");
374
375 tc_ssl_calls = tcase_create("ssl_calls");
376 suite_add_tcase(s, tc_ssl_calls);
377 tcase_add_test(tc_ssl_calls, test_rc4_enc_ok);
378 tcase_add_test(tc_ssl_calls, test_rc4_enc_tv0_ok);
379 tcase_add_test(tc_ssl_calls, test_rc4_enc_tv1_ok);
380 tcase_add_test(tc_ssl_calls, test_rc4_enc_tv2_ok);
381 tcase_add_test(tc_ssl_calls, test_rc4_enc_tv3_ok);
382 tcase_add_test(tc_ssl_calls, test_rc4_enc_tv4_ok);
383 tcase_add_test(tc_ssl_calls, test_sha1_hash_ok);
384 tcase_add_test(tc_ssl_calls, test_md5_hash_ok);
385 tcase_add_test(tc_ssl_calls, test_des3_enc_ok);
386 tcase_add_test(tc_ssl_calls, test_hmac_sha1_dgst_ok);
387 tcase_add_test(tc_ssl_calls, test_gen_key_xrdp1);
388
389 return s;
390 }
22 #include "config_ac.h"
33 #endif
44
5 #include "string_calls.h"
6
57 #include "test_common.h"
6 #include "string_calls.h"
78
89 #define RESULT_LEN 1024
910
213214 END_TEST
214215
215216 /******************************************************************************/
217 START_TEST(test_bm2str__no_bits_defined)
218 {
219 int rv;
220 char buff[64];
221
222 static const struct bitmask_string bits[] =
223 {
224 BITMASK_STRING_END_OF_LIST
225 };
226
227 rv = g_bitmask_to_str(0xffff, bits, ',', buff, sizeof(buff));
228
229 ck_assert_str_eq(buff, "0xffff");
230 ck_assert_int_eq(rv, 6);
231 }
232 END_TEST
233
234 START_TEST(test_bm2str__all_bits_defined)
235 {
236 int rv;
237 char buff[64];
238
239 static const struct bitmask_string bits[] =
240 {
241 {1 << 0, "BIT_0"},
242 {1 << 1, "BIT_1"},
243 {1 << 6, "BIT_6"},
244 {1 << 7, "BIT_7"},
245 BITMASK_STRING_END_OF_LIST
246 };
247
248 int bitmask = 1 << 0 | 1 << 1 | 1 << 6 | 1 << 7;
249
250 rv = g_bitmask_to_str(bitmask, bits, '|', buff, sizeof(buff));
251
252 ck_assert_str_eq(buff, "BIT_0|BIT_1|BIT_6|BIT_7");
253 ck_assert_int_eq(rv, (6 * 4) - 1);
254 }
255 END_TEST
256
257 START_TEST(test_bm2str__some_bits_undefined)
258 {
259 int rv;
260 char buff[64];
261
262 static const struct bitmask_string bits[] =
263 {
264 {1 << 0, "BIT_0"},
265 {1 << 1, "BIT_1"},
266 {1 << 6, "BIT_6"},
267 {1 << 7, "BIT_7"},
268 BITMASK_STRING_END_OF_LIST
269 };
270
271 int bitmask = 1 << 0 | 1 << 1 | 1 << 16;
272
273 rv = g_bitmask_to_str(bitmask, bits, ':', buff, sizeof(buff));
274
275 ck_assert_str_eq(buff, "BIT_0:BIT_1:0x10000");
276 ck_assert_int_eq(rv, (6 * 2) + 7);
277 }
278 END_TEST
279
280 START_TEST(test_bm2str__overflow_all_bits_defined)
281 {
282 int rv;
283 char buff[10];
284
285 static const struct bitmask_string bits[] =
286 {
287 {1 << 0, "BIT_0"},
288 {1 << 1, "BIT_1"},
289 {1 << 6, "BIT_6"},
290 {1 << 7, "BIT_7"},
291 BITMASK_STRING_END_OF_LIST
292 };
293
294 int bitmask = 1 << 0 | 1 << 1 | 1 << 6 | 1 << 7;
295
296 rv = g_bitmask_to_str(bitmask, bits, '+', buff, sizeof(buff));
297
298 ck_assert_str_eq(buff, "BIT_0+BIT");
299 ck_assert_int_eq(rv, (4 * 6) - 1);
300 }
301 END_TEST
302
303 START_TEST(test_bm2str__overflow_some_bits_undefined)
304 {
305 int rv;
306 char buff[16];
307
308 static const struct bitmask_string bits[] =
309 {
310 {1 << 0, "BIT_0"},
311 {1 << 1, "BIT_1"},
312 {1 << 6, "BIT_6"},
313 {1 << 7, "BIT_7"},
314 BITMASK_STRING_END_OF_LIST
315 };
316
317 int bitmask = 1 << 0 | 1 << 1 | 1 << 16;
318
319 rv = g_bitmask_to_str(bitmask, bits, '#', buff, sizeof(buff));
320
321 ck_assert_str_eq(buff, "BIT_0#BIT_1#0x1");
322 ck_assert_int_eq(rv, (6 * 2) + 7);
323 }
324 END_TEST
325
326 START_TEST(test_str2bm__null_string)
327 {
328 int rv;
329 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
330
331 static const struct bitmask_string bits[] =
332 {
333 {1 << 0, "BIT_0"},
334 BITMASK_STRING_END_OF_LIST
335 };
336
337 rv = g_str_to_bitmask(NULL, bits, ",", buff, sizeof(buff));
338
339 ck_assert_str_eq(buff, "");
340 ck_assert_int_eq(rv, 0);
341 }
342 END_TEST
343
344 START_TEST(test_str2bm__empty_string)
345 {
346 int rv;
347 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
348
349 static const struct bitmask_string bits[] =
350 {
351 {1 << 0, "BIT_0"},
352 BITMASK_STRING_END_OF_LIST
353 };
354
355 rv = g_str_to_bitmask("", bits, ",", buff, sizeof(buff));
356
357 ck_assert_str_eq(buff, "");
358 ck_assert_int_eq(rv, 0);
359 }
360 END_TEST
361
362 START_TEST(test_str2bm__null_bitdefs)
363 {
364 int rv;
365 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
366
367 rv = g_str_to_bitmask("BIT_0", NULL, ",", buff, sizeof(buff));
368
369 ck_assert_str_eq(buff, "");
370 ck_assert_int_eq(rv, 0);
371 }
372 END_TEST
373
374 START_TEST(test_str2bm__null_delim)
375 {
376 int rv;
377 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
378
379 static const struct bitmask_string bits[] =
380 {
381 {1 << 0, "BIT_0"},
382 BITMASK_STRING_END_OF_LIST
383 };
384
385 rv = g_str_to_bitmask("BIT_0", bits, NULL, buff, sizeof(buff));
386
387 ck_assert_str_eq(buff, "");
388 ck_assert_int_eq(rv, 0);
389 }
390 END_TEST
391
392 START_TEST(test_str2bm__null_buffer)
393 {
394 int rv;
395 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
396
397 static const struct bitmask_string bits[] =
398 {
399 {1 << 0, "BIT_0"},
400 BITMASK_STRING_END_OF_LIST
401 };
402
403 rv = g_str_to_bitmask("BIT_0", bits, ",", NULL, sizeof(buff));
404
405 ck_assert_str_eq(buff, "dummy");
406 ck_assert_int_eq(rv, 0);
407 }
408 END_TEST
409
410 START_TEST(test_str2bm__zero_buffer)
411 {
412 int rv;
413 char buff[1];
414
415 static const struct bitmask_string bits[] =
416 {
417 {1 << 0, "BIT_0"},
418 BITMASK_STRING_END_OF_LIST
419 };
420
421 rv = g_str_to_bitmask("BIT_0", bits, ",", buff, 0);
422
423 ck_assert_int_eq(rv, 0);
424 }
425 END_TEST
426
427 START_TEST(test_str2bm__zero_mask)
428 {
429 int rv;
430 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
431
432 static const struct bitmask_string bits[] =
433 {
434 {0, "ZERO MASK"}, /* mask 0 should not be detected as end of list */
435 {1 << 0, "BIT_0"},
436 BITMASK_STRING_END_OF_LIST
437 };
438
439 int bitmask = 1 << 0;
440 rv = g_str_to_bitmask("BIT_0", bits, ",", buff, sizeof(buff));
441
442 ck_assert_str_eq(buff, "");
443 ck_assert_int_eq(rv, bitmask);
444 }
445 END_TEST
446
447 START_TEST(test_str2bm__all_defined)
448 {
449 int rv;
450 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
451
452 static const struct bitmask_string bits[] =
453 {
454 {1 << 0, "BIT_0"},
455 {1 << 1, "BIT_1"},
456 BITMASK_STRING_END_OF_LIST
457 };
458
459 int bitmask = 1 << 0 | 1 << 1;
460 rv = g_str_to_bitmask("BIT_0,BIT_1", bits, ",", buff, sizeof(buff));
461
462 ck_assert_str_eq(buff, "");
463 ck_assert_int_eq(rv, bitmask);
464 }
465 END_TEST
466
467 START_TEST(test_str2bm__no_defined)
468 {
469 int rv;
470 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
471
472 static const struct bitmask_string bits[] =
473 {
474 {1 << 0, "BIT_0"},
475 {1 << 1, "BIT_1"},
476 BITMASK_STRING_END_OF_LIST
477 };
478
479 int bitmask = 0;
480 rv = g_str_to_bitmask("BIT_2,BIT_3", bits, ",", buff, sizeof(buff));
481
482 ck_assert_str_eq(buff, "BIT_2,BIT_3");
483 ck_assert_int_eq(rv, bitmask);
484 }
485 END_TEST
486
487 START_TEST(test_str2bm__some_defined)
488 {
489 int rv;
490 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
491
492 static const struct bitmask_string bits[] =
493 {
494 {1 << 0, "BIT_0"},
495 {1 << 1, "BIT_1"},
496 {1 << 2, "BIT_2"},
497 BITMASK_STRING_END_OF_LIST
498 };
499
500 int bitmask = 1 << 1;
501 rv = g_str_to_bitmask("a,BIT_1,b", bits, ",", buff, sizeof(buff));
502
503 ck_assert_str_eq(buff, "a,b");
504 ck_assert_int_eq(rv, bitmask);
505 }
506 END_TEST
507
508 START_TEST(test_str2bm__trim_space)
509 {
510 int rv;
511 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
512
513 static const struct bitmask_string bits[] =
514 {
515 {1 << 0, "BIT_0"},
516 {1 << 1, "BIT_1"},
517 {1 << 2, "BIT_2"},
518 BITMASK_STRING_END_OF_LIST
519 };
520
521 int bitmask = 1 << 0 | 1 << 1 | 1 << 2;
522 rv = g_str_to_bitmask("BIT_0 , BIT_1 , BIT_2", bits, ",", buff, sizeof(buff));
523
524 ck_assert_str_eq(buff, "");
525 ck_assert_int_eq(rv, bitmask);
526 }
527 END_TEST
528
529 START_TEST(test_str2bm__overflow_undefined)
530 {
531 int rv;
532 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
533
534 static const struct bitmask_string bits[] =
535 {
536 {1 << 0, "BIT_0"},
537 {1 << 1, "BIT_1"},
538 {1 << 2, "BIT_2"},
539 BITMASK_STRING_END_OF_LIST
540 };
541
542 int bitmask = 1 << 1;
543 rv = g_str_to_bitmask("123456789,BIT_1,abcdef", bits, ",", buff, sizeof(buff));
544
545 /* abcdef is not filled */
546 ck_assert_str_eq(buff, "123456789");
547 ck_assert_int_eq(rv, bitmask);
548 }
549 END_TEST
550
551 START_TEST(test_str2bm__delim_slash)
552 {
553 int rv;
554 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
555
556 static const struct bitmask_string bits[] =
557 {
558 {1 << 0, "BIT_0"},
559 {1 << 1, "BIT_1"},
560 {1 << 2, "BIT_2"},
561 BITMASK_STRING_END_OF_LIST
562 };
563
564 int bitmask = 1 << 0 | 1 << 1 | 1 << 2;
565 rv = g_str_to_bitmask("BIT_0/BIT_1/BIT_2", bits, "/", buff, sizeof(buff));
566
567 ck_assert_str_eq(buff, "");
568 ck_assert_int_eq(rv, bitmask);
569 }
570 END_TEST
571
572 START_TEST(test_str2bm__no_delim)
573 {
574 int rv;
575 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
576
577 static const struct bitmask_string bits[] =
578 {
579 {1 << 0, "BIT_0"},
580 {1 << 1, "BIT_1"},
581 BITMASK_STRING_END_OF_LIST
582 };
583
584 rv = g_str_to_bitmask("BIT_0,BIT_1", bits, "", buff, sizeof(buff));
585
586 ck_assert_str_eq(buff, "BIT_0,BIT_1");
587 ck_assert_int_eq(rv, 0);
588 }
589 END_TEST
590
591 START_TEST(test_str2bm__multiple_delim)
592 {
593 int rv;
594 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
595
596 static const struct bitmask_string bits[] =
597 {
598 {1 << 0, "BIT_0"},
599 {1 << 1, "BIT_1"},
600 {1 << 2, "BIT_2"},
601 BITMASK_STRING_END_OF_LIST
602 };
603
604 int bitmask = 1 << 0 | 1 << 1 | 1 << 2;
605 rv = g_str_to_bitmask("BIT_0/BIT_1,BIT_2", bits, ",/", buff, sizeof(buff));
606
607 ck_assert_str_eq(buff, "");
608 ck_assert_int_eq(rv, bitmask);
609 }
610 END_TEST
611
612 START_TEST(test_str2bm__first_delim_is_semicolon)
613 {
614 int rv;
615 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
616
617 static const struct bitmask_string bits[] =
618 {
619 {1 << 0, "BIT_0"},
620 {1 << 1, "BIT_1"},
621 BITMASK_STRING_END_OF_LIST
622 };
623
624 int bitmask = 1 << 1;
625 rv = g_str_to_bitmask("a;b;BIT_1;c", bits, ";,", buff, sizeof(buff));
626
627 ck_assert_str_eq(buff, "a;b;c");
628 ck_assert_int_eq(rv, bitmask);
629 }
630 END_TEST
631
632 START_TEST(test_str2bm__empty_token)
633 {
634 int rv;
635 char buff[16] = { 'd', 'u', 'm', 'm', 'y' };
636
637 static const struct bitmask_string bits[] =
638 {
639 {1 << 0, "BIT_0"},
640 BITMASK_STRING_END_OF_LIST
641 };
642
643 int bitmask = 1 << 0;
644 rv = g_str_to_bitmask(",BIT_0, ,", bits, ",", buff, sizeof(buff));
645
646 ck_assert_str_eq(buff, "");
647 ck_assert_int_eq(rv, bitmask);
648 }
649 END_TEST
650
651 /******************************************************************************/
652
653 START_TEST(test_strtrim__trim_left)
654 {
655 /* setup */
656 char output[] = "\t\t \tDone is better than perfect.\t\t \n\n";
657
658 /* test */
659 g_strtrim(output, 1);
660
661 /* verify */
662 ck_assert_str_eq(output, "Done is better than perfect.\t\t \n\n");
663 }
664 END_TEST
665
666 START_TEST(test_strtrim__trim_right)
667 {
668 /* setup */
669 char output[] = "\t\t \tDone is better than perfect.\t\t \n\n";
670
671 /* test */
672 g_strtrim(output, 2);
673
674 /* verify */
675 ck_assert_str_eq(output, "\t\t \tDone is better than perfect.");
676 }
677 END_TEST
678
679 START_TEST(test_strtrim__trim_both)
680 {
681 /* setup */
682 char output[] = "\t\t \tDone is better than perfect.\t\t \n\n";
683
684 /* test */
685 g_strtrim(output, 3);
686
687 /* verify */
688 ck_assert_str_eq(output, "Done is better than perfect.");
689 }
690 END_TEST
691
692 START_TEST(test_strtrim__trim_through)
693 {
694 /* setup */
695 char output[] = "\t\t \tDone is better than perfect.\t\t \n\n";
696
697 /* test */
698 g_strtrim(output, 4);
699
700 /* verify */
701 ck_assert_str_eq(output, "Doneisbetterthanperfect.");
702 }
703 END_TEST
704
705 /******************************************************************************/
706
216707 Suite *
217708 make_suite_test_string(void)
218709 {
219710 Suite *s;
220711 TCase *tc_strnjoin;
712 TCase *tc_bm2str;
713 TCase *tc_str2bm;
714 TCase *tc_strtrim;
221715
222716 s = suite_create("String");
223717
235729 tcase_add_test(tc_strnjoin, test_strnjoin__when_destination_has_contents__returns_joined_string_with_content_overwritten);
236730 tcase_add_test(tc_strnjoin, test_strnjoin__when_always__then_doesnt_write_beyond_end_of_destination);
237731
732 tc_bm2str = tcase_create("bm2str");
733 suite_add_tcase(s, tc_bm2str);
734 tcase_add_test(tc_bm2str, test_bm2str__no_bits_defined);
735 tcase_add_test(tc_bm2str, test_bm2str__all_bits_defined);
736 tcase_add_test(tc_bm2str, test_bm2str__some_bits_undefined);
737 tcase_add_test(tc_bm2str, test_bm2str__overflow_all_bits_defined);
738 tcase_add_test(tc_bm2str, test_bm2str__overflow_some_bits_undefined);
739 tc_str2bm = tcase_create("str2bm");
740 suite_add_tcase(s, tc_str2bm);
741 tcase_add_test(tc_str2bm, test_str2bm__null_string);
742 tcase_add_test(tc_str2bm, test_str2bm__empty_string);
743 tcase_add_test(tc_str2bm, test_str2bm__null_bitdefs);
744 tcase_add_test(tc_str2bm, test_str2bm__null_delim);
745 tcase_add_test(tc_str2bm, test_str2bm__null_buffer);
746 tcase_add_test(tc_str2bm, test_str2bm__zero_buffer);
747 tcase_add_test(tc_str2bm, test_str2bm__zero_mask);
748 tcase_add_test(tc_str2bm, test_str2bm__all_defined);
749 tcase_add_test(tc_str2bm, test_str2bm__no_defined);
750 tcase_add_test(tc_str2bm, test_str2bm__some_defined);
751 tcase_add_test(tc_str2bm, test_str2bm__trim_space);
752 tcase_add_test(tc_str2bm, test_str2bm__overflow_undefined);
753 tcase_add_test(tc_str2bm, test_str2bm__no_delim);
754 tcase_add_test(tc_str2bm, test_str2bm__delim_slash);
755 tcase_add_test(tc_str2bm, test_str2bm__multiple_delim);
756 tcase_add_test(tc_str2bm, test_str2bm__first_delim_is_semicolon);
757 tcase_add_test(tc_str2bm, test_str2bm__empty_token);
758
759 tc_strtrim = tcase_create("strtrim");
760 suite_add_tcase(s, tc_strtrim);
761 tcase_add_test(tc_strtrim, test_strtrim__trim_left);
762 tcase_add_test(tc_strtrim, test_strtrim__trim_right);
763 tcase_add_test(tc_strtrim, test_strtrim__trim_both);
764 tcase_add_test(tc_strtrim, test_strtrim__trim_through);
765
238766 return s;
239767 }
0 AM_CPPFLAGS = \
1 -I$(top_builddir) \
2 -I$(top_srcdir)/libxrdp \
3 -I$(top_srcdir)/common
4
5 LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
6 $(top_srcdir)/tap-driver.sh
7
8 PACKAGE_STRING = "libxrdp"
9
10 TESTS = test_libxrdp
11 check_PROGRAMS = test_libxrdp
12
13 test_libxrdp_SOURCES = \
14 test_libxrdp.h \
15 test_libxrdp_main.c \
16 test_monitor_processing.c
17
18 test_libxrdp_CFLAGS = \
19 @CHECK_CFLAGS@
20
21 test_libxrdp_LDADD = \
22 $(top_builddir)/common/libcommon.la \
23 $(top_builddir)/libxrdp/libxrdp.la \
24 @CHECK_LIBS@
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = { \
17 if test -z '$(MAKELEVEL)'; then \
18 false; \
19 elif test -n '$(MAKE_HOST)'; then \
20 true; \
21 elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
22 true; \
23 else \
24 false; \
25 fi; \
26 }
27 am__make_running_with_option = \
28 case $${target_option-} in \
29 ?) ;; \
30 *) echo "am__make_running_with_option: internal error: invalid" \
31 "target option '$${target_option-}' specified" >&2; \
32 exit 1;; \
33 esac; \
34 has_opt=no; \
35 sane_makeflags=$$MAKEFLAGS; \
36 if $(am__is_gnu_make); then \
37 sane_makeflags=$$MFLAGS; \
38 else \
39 case $$MAKEFLAGS in \
40 *\\[\ \ ]*) \
41 bs=\\; \
42 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
43 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
44 esac; \
45 fi; \
46 skip_next=no; \
47 strip_trailopt () \
48 { \
49 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
50 }; \
51 for flg in $$sane_makeflags; do \
52 test $$skip_next = yes && { skip_next=no; continue; }; \
53 case $$flg in \
54 *=*|--*) continue;; \
55 -*I) strip_trailopt 'I'; skip_next=yes;; \
56 -*I?*) strip_trailopt 'I';; \
57 -*O) strip_trailopt 'O'; skip_next=yes;; \
58 -*O?*) strip_trailopt 'O';; \
59 -*l) strip_trailopt 'l'; skip_next=yes;; \
60 -*l?*) strip_trailopt 'l';; \
61 -[dEDm]) skip_next=yes;; \
62 -[JT]) skip_next=yes;; \
63 esac; \
64 case $$flg in \
65 *$$target_option*) has_opt=yes; break;; \
66 esac; \
67 done; \
68 test $$has_opt = yes
69 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
70 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
71 pkgdatadir = $(datadir)/@PACKAGE@
72 pkgincludedir = $(includedir)/@PACKAGE@
73 pkglibdir = $(libdir)/@PACKAGE@
74 pkglibexecdir = $(libexecdir)/@PACKAGE@
75 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
76 install_sh_DATA = $(install_sh) -c -m 644
77 install_sh_PROGRAM = $(install_sh) -c
78 install_sh_SCRIPT = $(install_sh) -c
79 INSTALL_HEADER = $(INSTALL_DATA)
80 transform = $(program_transform_name)
81 NORMAL_INSTALL = :
82 PRE_INSTALL = :
83 POST_INSTALL = :
84 NORMAL_UNINSTALL = :
85 PRE_UNINSTALL = :
86 POST_UNINSTALL = :
87 build_triplet = @build@
88 host_triplet = @host@
89 TESTS = test_libxrdp$(EXEEXT)
90 check_PROGRAMS = test_libxrdp$(EXEEXT)
91 subdir = tests/libxrdp
92 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
93 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \
94 $(top_srcdir)/m4/ax_append_flag.m4 \
95 $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
96 $(top_srcdir)/m4/ax_check_compile_flag.m4 \
97 $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
98 $(top_srcdir)/m4/ax_require_defined.m4 \
99 $(top_srcdir)/m4/ax_type_socklen_t.m4 \
100 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
101 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
102 $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pkg.m4 \
103 $(top_srcdir)/configure.ac
104 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
105 $(ACLOCAL_M4)
106 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
107 mkinstalldirs = $(install_sh) -d
108 CONFIG_HEADER = $(top_builddir)/config_ac.h
109 CONFIG_CLEAN_FILES =
110 CONFIG_CLEAN_VPATH_FILES =
111 am_test_libxrdp_OBJECTS = test_libxrdp-test_libxrdp_main.$(OBJEXT) \
112 test_libxrdp-test_monitor_processing.$(OBJEXT)
113 test_libxrdp_OBJECTS = $(am_test_libxrdp_OBJECTS)
114 test_libxrdp_DEPENDENCIES = $(top_builddir)/common/libcommon.la \
115 $(top_builddir)/libxrdp/libxrdp.la
116 AM_V_lt = $(am__v_lt_@AM_V@)
117 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
118 am__v_lt_0 = --silent
119 am__v_lt_1 =
120 test_libxrdp_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
121 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_libxrdp_CFLAGS) \
122 $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
123 AM_V_P = $(am__v_P_@AM_V@)
124 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
125 am__v_P_0 = false
126 am__v_P_1 = :
127 AM_V_GEN = $(am__v_GEN_@AM_V@)
128 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
129 am__v_GEN_0 = @echo " GEN " $@;
130 am__v_GEN_1 =
131 AM_V_at = $(am__v_at_@AM_V@)
132 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
133 am__v_at_0 = @
134 am__v_at_1 =
135 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
136 depcomp = $(SHELL) $(top_srcdir)/depcomp
137 am__maybe_remake_depfiles = depfiles
138 am__depfiles_remade = ./$(DEPDIR)/test_libxrdp-test_libxrdp_main.Po \
139 ./$(DEPDIR)/test_libxrdp-test_monitor_processing.Po
140 am__mv = mv -f
141 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
142 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
143 LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
144 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
145 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
146 $(AM_CFLAGS) $(CFLAGS)
147 AM_V_CC = $(am__v_CC_@AM_V@)
148 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
149 am__v_CC_0 = @echo " CC " $@;
150 am__v_CC_1 =
151 CCLD = $(CC)
152 LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
153 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
154 $(AM_LDFLAGS) $(LDFLAGS) -o $@
155 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
156 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
157 am__v_CCLD_0 = @echo " CCLD " $@;
158 am__v_CCLD_1 =
159 SOURCES = $(test_libxrdp_SOURCES)
160 DIST_SOURCES = $(test_libxrdp_SOURCES)
161 am__can_run_installinfo = \
162 case $$AM_UPDATE_INFO_DIR in \
163 n|no|NO) false;; \
164 *) (install-info --version) >/dev/null 2>&1;; \
165 esac
166 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
167 # Read a list of newline-separated strings from the standard input,
168 # and print each of them once, without duplicates. Input order is
169 # *not* preserved.
170 am__uniquify_input = $(AWK) '\
171 BEGIN { nonempty = 0; } \
172 { items[$$0] = 1; nonempty = 1; } \
173 END { if (nonempty) { for (i in items) print i; }; } \
174 '
175 # Make sure the list of sources is unique. This is necessary because,
176 # e.g., the same source file might be shared among _SOURCES variables
177 # for different programs/libraries.
178 am__define_uniq_tagged_files = \
179 list='$(am__tagged_files)'; \
180 unique=`for i in $$list; do \
181 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
182 done | $(am__uniquify_input)`
183 am__tty_colors_dummy = \
184 mgn= red= grn= lgn= blu= brg= std=; \
185 am__color_tests=no
186 am__tty_colors = { \
187 $(am__tty_colors_dummy); \
188 if test "X$(AM_COLOR_TESTS)" = Xno; then \
189 am__color_tests=no; \
190 elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
191 am__color_tests=yes; \
192 elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
193 am__color_tests=yes; \
194 fi; \
195 if test $$am__color_tests = yes; then \
196 red=''; \
197 grn=''; \
198 lgn=''; \
199 blu=''; \
200 mgn=''; \
201 brg=''; \
202 std=''; \
203 fi; \
204 }
205 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
206 am__vpath_adj = case $$p in \
207 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
208 *) f=$$p;; \
209 esac;
210 am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
211 am__install_max = 40
212 am__nobase_strip_setup = \
213 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
214 am__nobase_strip = \
215 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
216 am__nobase_list = $(am__nobase_strip_setup); \
217 for p in $$list; do echo "$$p $$p"; done | \
218 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
219 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
220 if (++n[$$2] == $(am__install_max)) \
221 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
222 END { for (dir in files) print dir, files[dir] }'
223 am__base_list = \
224 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
225 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
226 am__uninstall_files_from_dir = { \
227 test -z "$$files" \
228 || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
229 || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
230 $(am__cd) "$$dir" && rm -f $$files; }; \
231 }
232 am__recheck_rx = ^[ ]*:recheck:[ ]*
233 am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
234 am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
235 # A command that, given a newline-separated list of test names on the
236 # standard input, print the name of the tests that are to be re-run
237 # upon "make recheck".
238 am__list_recheck_tests = $(AWK) '{ \
239 recheck = 1; \
240 while ((rc = (getline line < ($$0 ".trs"))) != 0) \
241 { \
242 if (rc < 0) \
243 { \
244 if ((getline line2 < ($$0 ".log")) < 0) \
245 recheck = 0; \
246 break; \
247 } \
248 else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
249 { \
250 recheck = 0; \
251 break; \
252 } \
253 else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
254 { \
255 break; \
256 } \
257 }; \
258 if (recheck) \
259 print $$0; \
260 close ($$0 ".trs"); \
261 close ($$0 ".log"); \
262 }'
263 # A command that, given a newline-separated list of test names on the
264 # standard input, create the global log from their .trs and .log files.
265 am__create_global_log = $(AWK) ' \
266 function fatal(msg) \
267 { \
268 print "fatal: making $@: " msg | "cat >&2"; \
269 exit 1; \
270 } \
271 function rst_section(header) \
272 { \
273 print header; \
274 len = length(header); \
275 for (i = 1; i <= len; i = i + 1) \
276 printf "="; \
277 printf "\n\n"; \
278 } \
279 { \
280 copy_in_global_log = 1; \
281 global_test_result = "RUN"; \
282 while ((rc = (getline line < ($$0 ".trs"))) != 0) \
283 { \
284 if (rc < 0) \
285 fatal("failed to read from " $$0 ".trs"); \
286 if (line ~ /$(am__global_test_result_rx)/) \
287 { \
288 sub("$(am__global_test_result_rx)", "", line); \
289 sub("[ ]*$$", "", line); \
290 global_test_result = line; \
291 } \
292 else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
293 copy_in_global_log = 0; \
294 }; \
295 if (copy_in_global_log) \
296 { \
297 rst_section(global_test_result ": " $$0); \
298 while ((rc = (getline line < ($$0 ".log"))) != 0) \
299 { \
300 if (rc < 0) \
301 fatal("failed to read from " $$0 ".log"); \
302 print line; \
303 }; \
304 printf "\n"; \
305 }; \
306 close ($$0 ".trs"); \
307 close ($$0 ".log"); \
308 }'
309 # Restructured Text title.
310 am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
311 # Solaris 10 'make', and several other traditional 'make' implementations,
312 # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
313 # by disabling -e (using the XSI extension "set +e") if it's set.
314 am__sh_e_setup = case $$- in *e*) set +e;; esac
315 # Default flags passed to test drivers.
316 am__common_driver_flags = \
317 --color-tests "$$am__color_tests" \
318 --enable-hard-errors "$$am__enable_hard_errors" \
319 --expect-failure "$$am__expect_failure"
320 # To be inserted before the command running the test. Creates the
321 # directory for the log if needed. Stores in $dir the directory
322 # containing $f, in $tst the test, in $log the log. Executes the
323 # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
324 # passes TESTS_ENVIRONMENT. Set up options for the wrapper that
325 # will run the test scripts (or their associated LOG_COMPILER, if
326 # thy have one).
327 am__check_pre = \
328 $(am__sh_e_setup); \
329 $(am__vpath_adj_setup) $(am__vpath_adj) \
330 $(am__tty_colors); \
331 srcdir=$(srcdir); export srcdir; \
332 case "$@" in \
333 */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
334 *) am__odir=.;; \
335 esac; \
336 test "x$$am__odir" = x"." || test -d "$$am__odir" \
337 || $(MKDIR_P) "$$am__odir" || exit $$?; \
338 if test -f "./$$f"; then dir=./; \
339 elif test -f "$$f"; then dir=; \
340 else dir="$(srcdir)/"; fi; \
341 tst=$$dir$$f; log='$@'; \
342 if test -n '$(DISABLE_HARD_ERRORS)'; then \
343 am__enable_hard_errors=no; \
344 else \
345 am__enable_hard_errors=yes; \
346 fi; \
347 case " $(XFAIL_TESTS) " in \
348 *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
349 am__expect_failure=yes;; \
350 *) \
351 am__expect_failure=no;; \
352 esac; \
353 $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
354 # A shell command to get the names of the tests scripts with any registered
355 # extension removed (i.e., equivalently, the names of the test logs, with
356 # the '.log' extension removed). The result is saved in the shell variable
357 # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
358 # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
359 # since that might cause problem with VPATH rewrites for suffix-less tests.
360 # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
361 am__set_TESTS_bases = \
362 bases='$(TEST_LOGS)'; \
363 bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
364 bases=`echo $$bases`
365 AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)'
366 RECHECK_LOGS = $(TEST_LOGS)
367 AM_RECURSIVE_TARGETS = check recheck
368 TEST_SUITE_LOG = test-suite.log
369 TEST_EXTENSIONS = @EXEEXT@ .test
370 LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
371 am__set_b = \
372 case '$@' in \
373 */*) \
374 case '$*' in \
375 */*) b='$*';; \
376 *) b=`echo '$@' | sed 's/\.log$$//'`; \
377 esac;; \
378 *) \
379 b='$*';; \
380 esac
381 am__test_logs1 = $(TESTS:=.log)
382 am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
383 TEST_LOGS = $(am__test_logs2:.test.log=.log)
384 TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
385 TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
386 $(TEST_LOG_FLAGS)
387 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \
388 $(top_srcdir)/test-driver
389 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
390 ACLOCAL = @ACLOCAL@
391 AMTAR = @AMTAR@
392 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
393 AR = @AR@
394 AUTOCONF = @AUTOCONF@
395 AUTOHEADER = @AUTOHEADER@
396 AUTOMAKE = @AUTOMAKE@
397 AWK = @AWK@
398 CC = @CC@
399 CCDEPMODE = @CCDEPMODE@
400 CFLAGS = @CFLAGS@
401 CHECK_CFLAGS = @CHECK_CFLAGS@
402 CHECK_LIBS = @CHECK_LIBS@
403 CPP = @CPP@
404 CPPFLAGS = @CPPFLAGS@
405 CSCOPE = @CSCOPE@
406 CTAGS = @CTAGS@
407 CYGPATH_W = @CYGPATH_W@
408 DEFS = @DEFS@
409 DEPDIR = @DEPDIR@
410 DLLTOOL = @DLLTOOL@
411 DLOPEN_LIBS = @DLOPEN_LIBS@
412 DSYMUTIL = @DSYMUTIL@
413 DUMPBIN = @DUMPBIN@
414 ECHO_C = @ECHO_C@
415 ECHO_N = @ECHO_N@
416 ECHO_T = @ECHO_T@
417 EGREP = @EGREP@
418 ETAGS = @ETAGS@
419 EXEEXT = @EXEEXT@
420 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
421 FDKAAC_LIBS = @FDKAAC_LIBS@
422 FGREP = @FGREP@
423 FREERDP_CFLAGS = @FREERDP_CFLAGS@
424 FREERDP_LIBS = @FREERDP_LIBS@
425 FUSE_CFLAGS = @FUSE_CFLAGS@
426 FUSE_LIBS = @FUSE_LIBS@
427 GREP = @GREP@
428 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
429 IMLIB2_LIBS = @IMLIB2_LIBS@
430 INSTALL = @INSTALL@
431 INSTALL_DATA = @INSTALL_DATA@
432 INSTALL_PROGRAM = @INSTALL_PROGRAM@
433 INSTALL_SCRIPT = @INSTALL_SCRIPT@
434 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
435 LD = @LD@
436 LDFLAGS = @LDFLAGS@
437 LIBOBJS = @LIBOBJS@
438 LIBS = @LIBS@
439 LIBTOOL = @LIBTOOL@
440 LIPO = @LIPO@
441 LN_S = @LN_S@
442 LTLIBOBJS = @LTLIBOBJS@
443 LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
444 MAKEINFO = @MAKEINFO@
445 MANIFEST_TOOL = @MANIFEST_TOOL@
446 MKDIR_P = @MKDIR_P@
447 NM = @NM@
448 NMEDIT = @NMEDIT@
449 OBJDUMP = @OBJDUMP@
450 OBJEXT = @OBJEXT@
451 OPENSSL = @OPENSSL@
452 OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
453 OPENSSL_LIBS = @OPENSSL_LIBS@
454 OTOOL = @OTOOL@
455 OTOOL64 = @OTOOL64@
456 PACKAGE = @PACKAGE@
457 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
458 PACKAGE_NAME = @PACKAGE_NAME@
459 PACKAGE_STRING = "libxrdp"
460 PACKAGE_TARNAME = @PACKAGE_TARNAME@
461 PACKAGE_URL = @PACKAGE_URL@
462 PACKAGE_VERSION = @PACKAGE_VERSION@
463 PAM_RULES = @PAM_RULES@
464 PATH_SEPARATOR = @PATH_SEPARATOR@
465 PIXMAN_CFLAGS = @PIXMAN_CFLAGS@
466 PIXMAN_LIBS = @PIXMAN_LIBS@
467 PKG_CONFIG = @PKG_CONFIG@
468 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
469 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
470 RANLIB = @RANLIB@
471 SED = @SED@
472 SET_MAKE = @SET_MAKE@
473 SHELL = @SHELL@
474 STRIP = @STRIP@
475 TurboJpegIncDir = @TurboJpegIncDir@
476 TurboJpegLibDir = @TurboJpegLibDir@
477 VERSION = @VERSION@
478 XMKMF = @XMKMF@
479 X_CFLAGS = @X_CFLAGS@
480 X_EXTRA_LIBS = @X_EXTRA_LIBS@
481 X_LIBS = @X_LIBS@
482 X_PRE_LIBS = @X_PRE_LIBS@
483 abs_builddir = @abs_builddir@
484 abs_srcdir = @abs_srcdir@
485 abs_top_builddir = @abs_top_builddir@
486 abs_top_srcdir = @abs_top_srcdir@
487 ac_ct_AR = @ac_ct_AR@
488 ac_ct_CC = @ac_ct_CC@
489 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
490 am__include = @am__include@
491 am__leading_dot = @am__leading_dot@
492 am__quote = @am__quote@
493 am__tar = @am__tar@
494 am__untar = @am__untar@
495 bindir = @bindir@
496 build = @build@
497 build_alias = @build_alias@
498 build_cpu = @build_cpu@
499 build_os = @build_os@
500 build_vendor = @build_vendor@
501 builddir = @builddir@
502 datadir = @datadir@
503 datarootdir = @datarootdir@
504 docdir = @docdir@
505 dvidir = @dvidir@
506 exec_prefix = @exec_prefix@
507 host = @host@
508 host_alias = @host_alias@
509 host_cpu = @host_cpu@
510 host_os = @host_os@
511 host_vendor = @host_vendor@
512 htmldir = @htmldir@
513 includedir = @includedir@
514 infodir = @infodir@
515 install_sh = @install_sh@
516 libdir = @libdir@
517 libexecdir = @libexecdir@
518 localedir = @localedir@
519 localstatedir = @localstatedir@
520 mandir = @mandir@
521 mkdir_p = @mkdir_p@
522 moduledir = @moduledir@
523 oldincludedir = @oldincludedir@
524 pdfdir = @pdfdir@
525 pkgconfigdir = @pkgconfigdir@
526 prefix = @prefix@
527 program_transform_name = @program_transform_name@
528 psdir = @psdir@
529 sbindir = @sbindir@
530 sharedstatedir = @sharedstatedir@
531 socketdir = @socketdir@
532 srcdir = @srcdir@
533 subdirs = @subdirs@
534 sysconfdir = @sysconfdir@
535 systemdsystemunitdir = @systemdsystemunitdir@
536 target_alias = @target_alias@
537 top_build_prefix = @top_build_prefix@
538 top_builddir = @top_builddir@
539 top_srcdir = @top_srcdir@
540 AM_CPPFLAGS = \
541 -I$(top_builddir) \
542 -I$(top_srcdir)/libxrdp \
543 -I$(top_srcdir)/common
544
545 LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
546 $(top_srcdir)/tap-driver.sh
547
548 test_libxrdp_SOURCES = \
549 test_libxrdp.h \
550 test_libxrdp_main.c \
551 test_monitor_processing.c
552
553 test_libxrdp_CFLAGS = \
554 @CHECK_CFLAGS@
555
556 test_libxrdp_LDADD = \
557 $(top_builddir)/common/libcommon.la \
558 $(top_builddir)/libxrdp/libxrdp.la \
559 @CHECK_LIBS@
560
561 all: all-am
562
563 .SUFFIXES:
564 .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs
565 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
566 @for dep in $?; do \
567 case '$(am__configure_deps)' in \
568 *$$dep*) \
569 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
570 && { if test -f $@; then exit 0; else break; fi; }; \
571 exit 1;; \
572 esac; \
573 done; \
574 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/libxrdp/Makefile'; \
575 $(am__cd) $(top_srcdir) && \
576 $(AUTOMAKE) --foreign tests/libxrdp/Makefile
577 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
578 @case '$?' in \
579 *config.status*) \
580 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
581 *) \
582 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
583 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
584 esac;
585
586 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
587 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
588
589 $(top_srcdir)/configure: $(am__configure_deps)
590 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
591 $(ACLOCAL_M4): $(am__aclocal_m4_deps)
592 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
593 $(am__aclocal_m4_deps):
594
595 clean-checkPROGRAMS:
596 @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
597 echo " rm -f" $$list; \
598 rm -f $$list || exit $$?; \
599 test -n "$(EXEEXT)" || exit 0; \
600 list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
601 echo " rm -f" $$list; \
602 rm -f $$list
603
604 test_libxrdp$(EXEEXT): $(test_libxrdp_OBJECTS) $(test_libxrdp_DEPENDENCIES) $(EXTRA_test_libxrdp_DEPENDENCIES)
605 @rm -f test_libxrdp$(EXEEXT)
606 $(AM_V_CCLD)$(test_libxrdp_LINK) $(test_libxrdp_OBJECTS) $(test_libxrdp_LDADD) $(LIBS)
607
608 mostlyclean-compile:
609 -rm -f *.$(OBJEXT)
610
611 distclean-compile:
612 -rm -f *.tab.c
613
614 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_libxrdp-test_libxrdp_main.Po@am__quote@ # am--include-marker
615 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_libxrdp-test_monitor_processing.Po@am__quote@ # am--include-marker
616
617 $(am__depfiles_remade):
618 @$(MKDIR_P) $(@D)
619 @echo '# dummy' >$@-t && $(am__mv) $@-t $@
620
621 am--depfiles: $(am__depfiles_remade)
622
623 .c.o:
624 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
625 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
626 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
627 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
628 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
629
630 .c.obj:
631 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
632 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
633 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
634 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
635 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
636
637 .c.lo:
638 @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
639 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
640 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
641 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
642 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
643
644 test_libxrdp-test_libxrdp_main.o: test_libxrdp_main.c
645 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libxrdp_CFLAGS) $(CFLAGS) -MT test_libxrdp-test_libxrdp_main.o -MD -MP -MF $(DEPDIR)/test_libxrdp-test_libxrdp_main.Tpo -c -o test_libxrdp-test_libxrdp_main.o `test -f 'test_libxrdp_main.c' || echo '$(srcdir)/'`test_libxrdp_main.c
646 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_libxrdp-test_libxrdp_main.Tpo $(DEPDIR)/test_libxrdp-test_libxrdp_main.Po
647 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_libxrdp_main.c' object='test_libxrdp-test_libxrdp_main.o' libtool=no @AMDEPBACKSLASH@
648 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
649 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libxrdp_CFLAGS) $(CFLAGS) -c -o test_libxrdp-test_libxrdp_main.o `test -f 'test_libxrdp_main.c' || echo '$(srcdir)/'`test_libxrdp_main.c
650
651 test_libxrdp-test_libxrdp_main.obj: test_libxrdp_main.c
652 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libxrdp_CFLAGS) $(CFLAGS) -MT test_libxrdp-test_libxrdp_main.obj -MD -MP -MF $(DEPDIR)/test_libxrdp-test_libxrdp_main.Tpo -c -o test_libxrdp-test_libxrdp_main.obj `if test -f 'test_libxrdp_main.c'; then $(CYGPATH_W) 'test_libxrdp_main.c'; else $(CYGPATH_W) '$(srcdir)/test_libxrdp_main.c'; fi`
653 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_libxrdp-test_libxrdp_main.Tpo $(DEPDIR)/test_libxrdp-test_libxrdp_main.Po
654 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_libxrdp_main.c' object='test_libxrdp-test_libxrdp_main.obj' libtool=no @AMDEPBACKSLASH@
655 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
656 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libxrdp_CFLAGS) $(CFLAGS) -c -o test_libxrdp-test_libxrdp_main.obj `if test -f 'test_libxrdp_main.c'; then $(CYGPATH_W) 'test_libxrdp_main.c'; else $(CYGPATH_W) '$(srcdir)/test_libxrdp_main.c'; fi`
657
658 test_libxrdp-test_monitor_processing.o: test_monitor_processing.c
659 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libxrdp_CFLAGS) $(CFLAGS) -MT test_libxrdp-test_monitor_processing.o -MD -MP -MF $(DEPDIR)/test_libxrdp-test_monitor_processing.Tpo -c -o test_libxrdp-test_monitor_processing.o `test -f 'test_monitor_processing.c' || echo '$(srcdir)/'`test_monitor_processing.c
660 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_libxrdp-test_monitor_processing.Tpo $(DEPDIR)/test_libxrdp-test_monitor_processing.Po
661 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_monitor_processing.c' object='test_libxrdp-test_monitor_processing.o' libtool=no @AMDEPBACKSLASH@
662 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
663 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libxrdp_CFLAGS) $(CFLAGS) -c -o test_libxrdp-test_monitor_processing.o `test -f 'test_monitor_processing.c' || echo '$(srcdir)/'`test_monitor_processing.c
664
665 test_libxrdp-test_monitor_processing.obj: test_monitor_processing.c
666 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libxrdp_CFLAGS) $(CFLAGS) -MT test_libxrdp-test_monitor_processing.obj -MD -MP -MF $(DEPDIR)/test_libxrdp-test_monitor_processing.Tpo -c -o test_libxrdp-test_monitor_processing.obj `if test -f 'test_monitor_processing.c'; then $(CYGPATH_W) 'test_monitor_processing.c'; else $(CYGPATH_W) '$(srcdir)/test_monitor_processing.c'; fi`
667 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_libxrdp-test_monitor_processing.Tpo $(DEPDIR)/test_libxrdp-test_monitor_processing.Po
668 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_monitor_processing.c' object='test_libxrdp-test_monitor_processing.obj' libtool=no @AMDEPBACKSLASH@
669 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
670 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_libxrdp_CFLAGS) $(CFLAGS) -c -o test_libxrdp-test_monitor_processing.obj `if test -f 'test_monitor_processing.c'; then $(CYGPATH_W) 'test_monitor_processing.c'; else $(CYGPATH_W) '$(srcdir)/test_monitor_processing.c'; fi`
671
672 mostlyclean-libtool:
673 -rm -f *.lo
674
675 clean-libtool:
676 -rm -rf .libs _libs
677
678 ID: $(am__tagged_files)
679 $(am__define_uniq_tagged_files); mkid -fID $$unique
680 tags: tags-am
681 TAGS: tags
682
683 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
684 set x; \
685 here=`pwd`; \
686 $(am__define_uniq_tagged_files); \
687 shift; \
688 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
689 test -n "$$unique" || unique=$$empty_fix; \
690 if test $$# -gt 0; then \
691 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
692 "$$@" $$unique; \
693 else \
694 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
695 $$unique; \
696 fi; \
697 fi
698 ctags: ctags-am
699
700 CTAGS: ctags
701 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
702 $(am__define_uniq_tagged_files); \
703 test -z "$(CTAGS_ARGS)$$unique" \
704 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
705 $$unique
706
707 GTAGS:
708 here=`$(am__cd) $(top_builddir) && pwd` \
709 && $(am__cd) $(top_srcdir) \
710 && gtags -i $(GTAGS_ARGS) "$$here"
711 cscopelist: cscopelist-am
712
713 cscopelist-am: $(am__tagged_files)
714 list='$(am__tagged_files)'; \
715 case "$(srcdir)" in \
716 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
717 *) sdir=$(subdir)/$(srcdir) ;; \
718 esac; \
719 for i in $$list; do \
720 if test -f "$$i"; then \
721 echo "$(subdir)/$$i"; \
722 else \
723 echo "$$sdir/$$i"; \
724 fi; \
725 done >> $(top_builddir)/cscope.files
726
727 distclean-tags:
728 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
729
730 # Recover from deleted '.trs' file; this should ensure that
731 # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
732 # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
733 # to avoid problems with "make -n".
734 .log.trs:
735 rm -f $< $@
736 $(MAKE) $(AM_MAKEFLAGS) $<
737
738 # Leading 'am--fnord' is there to ensure the list of targets does not
739 # expand to empty, as could happen e.g. with make check TESTS=''.
740 am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
741 am--force-recheck:
742 @:
743
744 $(TEST_SUITE_LOG): $(TEST_LOGS)
745 @$(am__set_TESTS_bases); \
746 am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
747 redo_bases=`for i in $$bases; do \
748 am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
749 done`; \
750 if test -n "$$redo_bases"; then \
751 redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
752 redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
753 if $(am__make_dryrun); then :; else \
754 rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
755 fi; \
756 fi; \
757 if test -n "$$am__remaking_logs"; then \
758 echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
759 "recursion detected" >&2; \
760 elif test -n "$$redo_logs"; then \
761 am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
762 fi; \
763 if $(am__make_dryrun); then :; else \
764 st=0; \
765 errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
766 for i in $$redo_bases; do \
767 test -f $$i.trs && test -r $$i.trs \
768 || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
769 test -f $$i.log && test -r $$i.log \
770 || { echo "$$errmsg $$i.log" >&2; st=1; }; \
771 done; \
772 test $$st -eq 0 || exit 1; \
773 fi
774 @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
775 ws='[ ]'; \
776 results=`for b in $$bases; do echo $$b.trs; done`; \
777 test -n "$$results" || results=/dev/null; \
778 all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
779 pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
780 fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
781 skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
782 xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
783 xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
784 error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
785 if test `expr $$fail + $$xpass + $$error` -eq 0; then \
786 success=true; \
787 else \
788 success=false; \
789 fi; \
790 br='==================='; br=$$br$$br$$br$$br; \
791 result_count () \
792 { \
793 if test x"$$1" = x"--maybe-color"; then \
794 maybe_colorize=yes; \
795 elif test x"$$1" = x"--no-color"; then \
796 maybe_colorize=no; \
797 else \
798 echo "$@: invalid 'result_count' usage" >&2; exit 4; \
799 fi; \
800 shift; \
801 desc=$$1 count=$$2; \
802 if test $$maybe_colorize = yes && test $$count -gt 0; then \
803 color_start=$$3 color_end=$$std; \
804 else \
805 color_start= color_end=; \
806 fi; \
807 echo "$${color_start}# $$desc $$count$${color_end}"; \
808 }; \
809 create_testsuite_report () \
810 { \
811 result_count $$1 "TOTAL:" $$all "$$brg"; \
812 result_count $$1 "PASS: " $$pass "$$grn"; \
813 result_count $$1 "SKIP: " $$skip "$$blu"; \
814 result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
815 result_count $$1 "FAIL: " $$fail "$$red"; \
816 result_count $$1 "XPASS:" $$xpass "$$red"; \
817 result_count $$1 "ERROR:" $$error "$$mgn"; \
818 }; \
819 { \
820 echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
821 $(am__rst_title); \
822 create_testsuite_report --no-color; \
823 echo; \
824 echo ".. contents:: :depth: 2"; \
825 echo; \
826 for b in $$bases; do echo $$b; done \
827 | $(am__create_global_log); \
828 } >$(TEST_SUITE_LOG).tmp || exit 1; \
829 mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
830 if $$success; then \
831 col="$$grn"; \
832 else \
833 col="$$red"; \
834 test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
835 fi; \
836 echo "$${col}$$br$${std}"; \
837 echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \
838 echo "$${col}$$br$${std}"; \
839 create_testsuite_report --maybe-color; \
840 echo "$$col$$br$$std"; \
841 if $$success; then :; else \
842 echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
843 if test -n "$(PACKAGE_BUGREPORT)"; then \
844 echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
845 fi; \
846 echo "$$col$$br$$std"; \
847 fi; \
848 $$success || exit 1
849
850 check-TESTS: $(check_PROGRAMS)
851 @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
852 @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
853 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
854 @set +e; $(am__set_TESTS_bases); \
855 log_list=`for i in $$bases; do echo $$i.log; done`; \
856 trs_list=`for i in $$bases; do echo $$i.trs; done`; \
857 log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
858 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
859 exit $$?;
860 recheck: all $(check_PROGRAMS)
861 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
862 @set +e; $(am__set_TESTS_bases); \
863 bases=`for i in $$bases; do echo $$i; done \
864 | $(am__list_recheck_tests)` || exit 1; \
865 log_list=`for i in $$bases; do echo $$i.log; done`; \
866 log_list=`echo $$log_list`; \
867 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
868 am__force_recheck=am--force-recheck \
869 TEST_LOGS="$$log_list"; \
870 exit $$?
871 test_libxrdp.log: test_libxrdp$(EXEEXT)
872 @p='test_libxrdp$(EXEEXT)'; \
873 b='test_libxrdp'; \
874 $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
875 --log-file $$b.log --trs-file $$b.trs \
876 $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
877 "$$tst" $(AM_TESTS_FD_REDIRECT)
878 .test.log:
879 @p='$<'; \
880 $(am__set_b); \
881 $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
882 --log-file $$b.log --trs-file $$b.trs \
883 $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
884 "$$tst" $(AM_TESTS_FD_REDIRECT)
885 @am__EXEEXT_TRUE@.test$(EXEEXT).log:
886 @am__EXEEXT_TRUE@ @p='$<'; \
887 @am__EXEEXT_TRUE@ $(am__set_b); \
888 @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
889 @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
890 @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
891 @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
892 distdir: $(BUILT_SOURCES)
893 $(MAKE) $(AM_MAKEFLAGS) distdir-am
894
895 distdir-am: $(DISTFILES)
896 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
897 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
898 list='$(DISTFILES)'; \
899 dist_files=`for file in $$list; do echo $$file; done | \
900 sed -e "s|^$$srcdirstrip/||;t" \
901 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
902 case $$dist_files in \
903 */*) $(MKDIR_P) `echo "$$dist_files" | \
904 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
905 sort -u` ;; \
906 esac; \
907 for file in $$dist_files; do \
908 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
909 if test -d $$d/$$file; then \
910 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
911 if test -d "$(distdir)/$$file"; then \
912 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
913 fi; \
914 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
915 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
916 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
917 fi; \
918 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
919 else \
920 test -f "$(distdir)/$$file" \
921 || cp -p $$d/$$file "$(distdir)/$$file" \
922 || exit 1; \
923 fi; \
924 done
925 check-am: all-am
926 $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
927 $(MAKE) $(AM_MAKEFLAGS) check-TESTS
928 check: check-am
929 all-am: Makefile
930 installdirs:
931 install: install-am
932 install-exec: install-exec-am
933 install-data: install-data-am
934 uninstall: uninstall-am
935
936 install-am: all-am
937 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
938
939 installcheck: installcheck-am
940 install-strip:
941 if test -z '$(STRIP)'; then \
942 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
943 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
944 install; \
945 else \
946 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
947 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
948 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
949 fi
950 mostlyclean-generic:
951 -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
952 -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
953 -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
954
955 clean-generic:
956
957 distclean-generic:
958 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
959 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
960
961 maintainer-clean-generic:
962 @echo "This command is intended for maintainers to use"
963 @echo "it deletes files that may require special tools to rebuild."
964 clean: clean-am
965
966 clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
967 mostlyclean-am
968
969 distclean: distclean-am
970 -rm -f ./$(DEPDIR)/test_libxrdp-test_libxrdp_main.Po
971 -rm -f ./$(DEPDIR)/test_libxrdp-test_monitor_processing.Po
972 -rm -f Makefile
973 distclean-am: clean-am distclean-compile distclean-generic \
974 distclean-tags
975
976 dvi: dvi-am
977
978 dvi-am:
979
980 html: html-am
981
982 html-am:
983
984 info: info-am
985
986 info-am:
987
988 install-data-am:
989
990 install-dvi: install-dvi-am
991
992 install-dvi-am:
993
994 install-exec-am:
995
996 install-html: install-html-am
997
998 install-html-am:
999
1000 install-info: install-info-am
1001
1002 install-info-am:
1003
1004 install-man:
1005
1006 install-pdf: install-pdf-am
1007
1008 install-pdf-am:
1009
1010 install-ps: install-ps-am
1011
1012 install-ps-am:
1013
1014 installcheck-am:
1015
1016 maintainer-clean: maintainer-clean-am
1017 -rm -f ./$(DEPDIR)/test_libxrdp-test_libxrdp_main.Po
1018 -rm -f ./$(DEPDIR)/test_libxrdp-test_monitor_processing.Po
1019 -rm -f Makefile
1020 maintainer-clean-am: distclean-am maintainer-clean-generic
1021
1022 mostlyclean: mostlyclean-am
1023
1024 mostlyclean-am: mostlyclean-compile mostlyclean-generic \
1025 mostlyclean-libtool
1026
1027 pdf: pdf-am
1028
1029 pdf-am:
1030
1031 ps: ps-am
1032
1033 ps-am:
1034
1035 uninstall-am:
1036
1037 .MAKE: check-am install-am install-strip
1038
1039 .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \
1040 check-am clean clean-checkPROGRAMS clean-generic clean-libtool \
1041 cscopelist-am ctags ctags-am distclean distclean-compile \
1042 distclean-generic distclean-libtool distclean-tags distdir dvi \
1043 dvi-am html html-am info info-am install install-am \
1044 install-data install-data-am install-dvi install-dvi-am \
1045 install-exec install-exec-am install-html install-html-am \
1046 install-info install-info-am install-man install-pdf \
1047 install-pdf-am install-ps install-ps-am install-strip \
1048 installcheck installcheck-am installdirs maintainer-clean \
1049 maintainer-clean-generic mostlyclean mostlyclean-compile \
1050 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
1051 recheck tags tags-am uninstall uninstall-am
1052
1053 .PRECIOUS: Makefile
1054
1055
1056 # Tell versions [3.59,3.63) of GNU make to not export all variables.
1057 # Otherwise a system limit (for SysV at least) may be exceeded.
1058 .NOEXPORT:
0 #ifndef TEST_LIBXRDP_H
1 #define TEST_LIBXRDP_H
2
3 #include <check.h>
4
5 Suite *make_suite_test_monitor_processing(void);
6
7 #endif /* TEST_LIBXRDP_H */
0 #if defined(HAVE_CONFIG_H)
1 #include "config_ac.h"
2 #endif
3
4 #include <stdlib.h>
5 #include <check.h>
6 #include "test_libxrdp.h"
7
8 int main (void)
9 {
10 int number_failed;
11 SRunner *sr;
12
13 sr = srunner_create (make_suite_test_monitor_processing());
14 // srunner_add_suite(sr, make_list_suite());
15
16 srunner_set_tap(sr, "-");
17 srunner_run_all (sr, CK_ENV);
18 number_failed = srunner_ntests_failed(sr);
19 srunner_free(sr);
20 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
21 }
0 #if defined(HAVE_CONFIG_H)
1 #include "config_ac.h"
2 #endif
3
4 #include "libxrdp.h"
5 #include "os_calls.h"
6
7 #include "test_libxrdp.h"
8
9 struct xrdp_sec *sec_layer;
10 struct xrdp_rdp *rdp_layer;
11 struct xrdp_session *session;
12
13 int
14 xrdp_sec_process_mcs_data_monitors(struct xrdp_sec *self, struct stream *s);
15
16 void setup(void)
17 {
18 rdp_layer = (struct xrdp_rdp *)g_malloc(sizeof(struct xrdp_rdp), 1);
19 session = (struct xrdp_session *)g_malloc(sizeof(struct xrdp_session), 1);
20 session->rdp = rdp_layer;
21 session->client_info = &(((struct xrdp_rdp *)session->rdp)->client_info);
22 session->client_info->multimon = 1;
23 sec_layer = (struct xrdp_sec *) g_malloc(sizeof(struct xrdp_sec), 1);
24 sec_layer->rdp_layer = rdp_layer;
25 }
26
27 void teardown(void)
28 {
29 g_free(sec_layer);
30 g_free(session);
31 g_free(rdp_layer);
32 }
33
34 START_TEST(test_process_monitors__when_flags_is_not_zero__fail)
35 {
36 struct stream *s = (struct stream *)NULL;
37 make_stream(s);
38 init_stream(s, 8);
39
40 out_uint32_le(s, 1);
41 out_uint32_le(s, 0);
42 s_mark_end(s);
43 //Reset the read counter of the stream so the processing function handles it properly.
44 s->p = s->data;
45
46 int error = xrdp_sec_process_mcs_data_monitors(sec_layer, s);
47 ck_assert_int_eq(error, 1);
48
49 free_stream(s);
50 }
51 END_TEST
52
53 START_TEST(test_process_monitors__when_mounter_count_is_greater_than_sixteen__fail)
54 {
55 struct stream *s = (struct stream *)NULL;
56 make_stream(s);
57 init_stream(s, 8);
58
59 out_uint32_le(s, 0);
60 out_uint32_le(s, 17);
61 s_mark_end(s);
62 //Reset the read counter of the stream so the processing function handles it properly.
63 s->p = s->data;
64
65 int error = xrdp_sec_process_mcs_data_monitors(sec_layer, s);
66 ck_assert_int_eq(error, 2);
67
68 free_stream(s);
69 }
70 END_TEST
71
72 START_TEST(test_process_monitors__with_single_monitor_happy_path)
73 {
74 struct xrdp_client_info *client_info = &(rdp_layer->client_info);
75 struct stream *s = (struct stream *)NULL;
76 make_stream(s);
77 init_stream(s, 28);
78
79 out_uint32_le(s, 0); //flags
80 out_uint32_le(s, 1); //monitorCount
81
82 // Pretend we have a 4k monitor
83 out_uint32_le(s, 0); //monitor left
84 out_uint32_le(s, 0); //monitor top
85 out_uint32_le(s, 3840); //monitor right
86 out_uint32_le(s, 2160); //monitor bottom
87 out_uint32_le(s, 1); //is primary
88
89 s_mark_end(s);
90 //Reset the read counter of the stream so the processing function handles it properly.
91 s->p = s->data;
92
93 //Verify function call passed.
94 int error = xrdp_sec_process_mcs_data_monitors(sec_layer, s);
95 ck_assert_int_eq(error, 0);
96
97 ck_assert_int_eq(client_info->monitorCount, 1);
98
99 // Verify normal monitor
100 ck_assert_int_eq(client_info->minfo[0].left, 0);
101 ck_assert_int_eq(client_info->minfo[0].top, 0);
102 ck_assert_int_eq(client_info->minfo[0].right, 3840);
103 ck_assert_int_eq(client_info->minfo[0].bottom, 2160);
104 ck_assert_int_eq(client_info->minfo[0].is_primary, 1);
105
106 // Verify normalized monitor
107 ck_assert_int_eq(client_info->minfo_wm[0].left, 0);
108 ck_assert_int_eq(client_info->minfo_wm[0].top, 0);
109 ck_assert_int_eq(client_info->minfo_wm[0].right, 3840);
110 ck_assert_int_eq(client_info->minfo_wm[0].bottom, 2160);
111 ck_assert_int_eq(client_info->minfo_wm[0].is_primary, 1);
112
113 // Verify geometry (+1 greater than )
114 ck_assert_int_eq(client_info->width, 3841);
115 ck_assert_int_eq(client_info->height, 2161);
116
117 free_stream(s);
118 }
119 END_TEST
120
121 START_TEST(test_process_monitors__when_no_primary_monitor_is_specified_one_is_selected)
122 {
123 struct xrdp_client_info *client_info = &(rdp_layer->client_info);
124 struct stream *s = (struct stream *)NULL;
125 make_stream(s);
126 init_stream(s, 28);
127
128 out_uint32_le(s, 0); //flags
129 out_uint32_le(s, 1); //monitorCount
130
131 // Pretend we have a 4k monitor
132 out_uint32_le(s, 0); //monitor left
133 out_uint32_le(s, 0); //monitor top
134 out_uint32_le(s, 3840); //monitor right
135 out_uint32_le(s, 2160); //monitor bottom
136 out_uint32_le(s, 0); //is primary
137
138 s_mark_end(s);
139 //Reset the read counter of the stream so the processing function handles it properly.
140 s->p = s->data;
141
142 //Verify function call passed.
143 int error = xrdp_sec_process_mcs_data_monitors(sec_layer, s);
144 ck_assert_int_eq(error, 0);
145
146 ck_assert_int_eq(client_info->monitorCount, 1);
147
148 // Verify normal monitor
149 ck_assert_int_eq(client_info->minfo[0].left, 0);
150 ck_assert_int_eq(client_info->minfo[0].top, 0);
151 ck_assert_int_eq(client_info->minfo[0].right, 3840);
152 ck_assert_int_eq(client_info->minfo[0].bottom, 2160);
153 ck_assert_int_eq(client_info->minfo[0].is_primary, 1);
154
155 // Verify normalized monitor
156 ck_assert_int_eq(client_info->minfo_wm[0].left, 0);
157 ck_assert_int_eq(client_info->minfo_wm[0].top, 0);
158 ck_assert_int_eq(client_info->minfo_wm[0].right, 3840);
159 ck_assert_int_eq(client_info->minfo_wm[0].bottom, 2160);
160 ck_assert_int_eq(client_info->minfo_wm[0].is_primary, 1);
161
162 // Verify geometry (+1 greater than )
163 ck_assert_int_eq(client_info->width, 3841);
164 ck_assert_int_eq(client_info->height, 2161);
165
166 free_stream(s);
167 }
168 END_TEST
169
170 START_TEST(test_process_monitors__when_virtual_desktop_width_is_too_large)
171 {
172 struct stream *s = (struct stream *)NULL;
173 make_stream(s);
174 init_stream(s, 28);
175
176 out_uint32_le(s, 0); //flags
177 out_uint32_le(s, 1); //monitorCount
178
179 // Pretend we have a 4k monitor
180 out_uint32_le(s, 0); //monitor left
181 out_uint32_le(s, 0); //monitor top
182 out_uint32_le(s, 33000); //monitor right
183 out_uint32_le(s, 2160); //monitor bottom
184 out_uint32_le(s, 1); //is primary
185
186 s_mark_end(s);
187 //Reset the read counter of the stream so the processing function handles it properly.
188 s->p = s->data;
189
190 //Verify function call passed.
191 int error = xrdp_sec_process_mcs_data_monitors(sec_layer, s);
192 ck_assert_int_eq(error, 3);
193
194 free_stream(s);
195 }
196 END_TEST
197
198 START_TEST(test_process_monitors__when_virtual_desktop_width_is_too_small)
199 {
200 struct stream *s = (struct stream *)NULL;
201 make_stream(s);
202 init_stream(s, 28);
203
204 out_uint32_le(s, 0); //flags
205 out_uint32_le(s, 1); //monitorCount
206
207 // Pretend we have a 4k monitor
208 out_uint32_le(s, 0); //monitor left
209 out_uint32_le(s, 0); //monitor top
210 out_uint32_le(s, 100); //monitor right
211 out_uint32_le(s, 2160); //monitor bottom
212 out_uint32_le(s, 1); //is primary
213
214 s_mark_end(s);
215 //Reset the read counter of the stream so the processing function handles it properly.
216 s->p = s->data;
217
218 //Verify function call passed.
219 int error = xrdp_sec_process_mcs_data_monitors(sec_layer, s);
220 ck_assert_int_eq(error, 3);
221
222 free_stream(s);
223 }
224 END_TEST
225
226 START_TEST(test_process_monitors__when_virtual_desktop_height_is_too_large)
227 {
228 struct stream *s = (struct stream *)NULL;
229 make_stream(s);
230 init_stream(s, 28);
231
232 out_uint32_le(s, 0); //flags
233 out_uint32_le(s, 1); //monitorCount
234
235 // Pretend we have a 4k monitor
236 out_uint32_le(s, 0); //monitor left
237 out_uint32_le(s, 0); //monitor top
238 out_uint32_le(s, 3840); //monitor right
239 out_uint32_le(s, 33000); //monitor bottom
240 out_uint32_le(s, 1); //is primary
241
242 s_mark_end(s);
243 //Reset the read counter of the stream so the processing function handles it properly.
244 s->p = s->data;
245
246 //Verify function call passed.
247 int error = xrdp_sec_process_mcs_data_monitors(sec_layer, s);
248 ck_assert_int_eq(error, 3);
249
250 free_stream(s);
251 }
252 END_TEST
253
254 START_TEST(test_process_monitors__when_virtual_desktop_height_is_too_small)
255 {
256 struct stream *s = (struct stream *)NULL;
257 make_stream(s);
258 init_stream(s, 28);
259
260 out_uint32_le(s, 0); //flags
261 out_uint32_le(s, 1); //monitorCount
262
263 // Pretend we have a 4k monitor
264 out_uint32_le(s, 0); //monitor left
265 out_uint32_le(s, 0); //monitor top
266 out_uint32_le(s, 3840); //monitor right
267 out_uint32_le(s, 100); //monitor bottom
268 out_uint32_le(s, 1); //is primary
269
270 s_mark_end(s);
271 //Reset the read counter of the stream so the processing function handles it properly.
272 s->p = s->data;
273
274 //Verify function call passed.
275 int error = xrdp_sec_process_mcs_data_monitors(sec_layer, s);
276 ck_assert_int_eq(error, 3);
277
278 free_stream(s);
279 }
280 END_TEST
281
282 /******************************************************************************/
283 Suite *
284 make_suite_test_monitor_processing(void)
285 {
286 Suite *s;
287 TCase *tc_process_monitors;
288
289 s = suite_create("Monitor_Processing");
290
291 tc_process_monitors = tcase_create("xrdp_sec_process_mcs_data_monitors");
292 tcase_add_checked_fixture(tc_process_monitors, setup, teardown);
293 tcase_add_test(tc_process_monitors, test_process_monitors__when_flags_is_not_zero__fail);
294 tcase_add_test(tc_process_monitors, test_process_monitors__when_mounter_count_is_greater_than_sixteen__fail);
295 tcase_add_test(tc_process_monitors, test_process_monitors__with_single_monitor_happy_path);
296 tcase_add_test(tc_process_monitors, test_process_monitors__when_no_primary_monitor_is_specified_one_is_selected);
297 tcase_add_test(tc_process_monitors, test_process_monitors__when_virtual_desktop_width_is_too_large);
298 tcase_add_test(tc_process_monitors, test_process_monitors__when_virtual_desktop_width_is_too_small);
299 tcase_add_test(tc_process_monitors, test_process_monitors__when_virtual_desktop_height_is_too_large);
300 tcase_add_test(tc_process_monitors, test_process_monitors__when_virtual_desktop_height_is_too_small);
301
302 suite_add_tcase(s, tc_process_monitors);
303
304 return s;
305 }
00
11 AM_CPPFLAGS = \
22 -I$(top_srcdir)/common
3
4 PACKAGE_STRING = "memtest"
35
46 check_PROGRAMS = \
57 memtest
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
174174 unique=`for i in $$list; do \
175175 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
176176 done | $(am__uniquify_input)`
177 ETAGS = etags
178 CTAGS = ctags
179177 am__tty_colors_dummy = \
180178 mgn= red= grn= lgn= blu= brg= std=; \
181179 am__color_tests=no
399397 CHECK_LIBS = @CHECK_LIBS@
400398 CPP = @CPP@
401399 CPPFLAGS = @CPPFLAGS@
400 CSCOPE = @CSCOPE@
401 CTAGS = @CTAGS@
402402 CYGPATH_W = @CYGPATH_W@
403403 DEFS = @DEFS@
404404 DEPDIR = @DEPDIR@
410410 ECHO_N = @ECHO_N@
411411 ECHO_T = @ECHO_T@
412412 EGREP = @EGREP@
413 ETAGS = @ETAGS@
413414 EXEEXT = @EXEEXT@
414415 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
415416 FDKAAC_LIBS = @FDKAAC_LIBS@
419420 FUSE_CFLAGS = @FUSE_CFLAGS@
420421 FUSE_LIBS = @FUSE_LIBS@
421422 GREP = @GREP@
423 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
424 IMLIB2_LIBS = @IMLIB2_LIBS@
422425 INSTALL = @INSTALL@
423426 INSTALL_DATA = @INSTALL_DATA@
424427 INSTALL_PROGRAM = @INSTALL_PROGRAM@
448451 PACKAGE = @PACKAGE@
449452 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
450453 PACKAGE_NAME = @PACKAGE_NAME@
451 PACKAGE_STRING = @PACKAGE_STRING@
454 PACKAGE_STRING = "memtest"
452455 PACKAGE_TARNAME = @PACKAGE_TARNAME@
453456 PACKAGE_URL = @PACKAGE_URL@
454457 PACKAGE_VERSION = @PACKAGE_VERSION@
843846 @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
844847 @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
845848 @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
846
847849 distdir: $(BUILT_SOURCES)
848850 $(MAKE) $(AM_MAKEFLAGS) distdir-am
849851
0 AM_CPPFLAGS = \
1 -I$(top_builddir) \
2 -I$(top_srcdir)/xrdp \
3 -I$(top_srcdir)/libxrdp \
4 -I$(top_srcdir)/common \
5 $(IMLIB2_CFLAGS)
6
7 LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
8 $(top_srcdir)/tap-driver.sh
9
10 PACKAGE_STRING="XRDP daemon"
11
12 EXTRA_DIST = \
13 test_4bit.bmp \
14 test_8bit.bmp \
15 test_24bit.bmp \
16 test_not4_4bit.bmp \
17 test_not4_8bit.bmp \
18 test_not4_24bit.bmp \
19 test1.jpg \
20 test_alpha_blend.png
21
22 TESTS = test_xrdp
23 check_PROGRAMS = test_xrdp
24
25 test_xrdp_SOURCES = \
26 test_xrdp.h \
27 test_xrdp_main.c \
28 test_bitmap_load.c
29
30 test_xrdp_CFLAGS = \
31 -D IMAGEDIR=\"$(srcdir)\" \
32 @CHECK_CFLAGS@
33
34 test_xrdp_LDADD = \
35 $(top_builddir)/xrdp/xrdp_bitmap_load.o \
36 $(top_builddir)/xrdp/xrdp_bitmap_common.o \
37 $(top_builddir)/xrdp/funcs.o \
38 $(top_builddir)/common/libcommon.la \
39 $(IMLIB2_LIBS) \
40 @CHECK_LIBS@
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
1 # @configure_input@
2
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
4
5 # This Makefile.in is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 @SET_MAKE@
15 VPATH = @srcdir@
16 am__is_gnu_make = { \
17 if test -z '$(MAKELEVEL)'; then \
18 false; \
19 elif test -n '$(MAKE_HOST)'; then \
20 true; \
21 elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
22 true; \
23 else \
24 false; \
25 fi; \
26 }
27 am__make_running_with_option = \
28 case $${target_option-} in \
29 ?) ;; \
30 *) echo "am__make_running_with_option: internal error: invalid" \
31 "target option '$${target_option-}' specified" >&2; \
32 exit 1;; \
33 esac; \
34 has_opt=no; \
35 sane_makeflags=$$MAKEFLAGS; \
36 if $(am__is_gnu_make); then \
37 sane_makeflags=$$MFLAGS; \
38 else \
39 case $$MAKEFLAGS in \
40 *\\[\ \ ]*) \
41 bs=\\; \
42 sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
43 | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
44 esac; \
45 fi; \
46 skip_next=no; \
47 strip_trailopt () \
48 { \
49 flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
50 }; \
51 for flg in $$sane_makeflags; do \
52 test $$skip_next = yes && { skip_next=no; continue; }; \
53 case $$flg in \
54 *=*|--*) continue;; \
55 -*I) strip_trailopt 'I'; skip_next=yes;; \
56 -*I?*) strip_trailopt 'I';; \
57 -*O) strip_trailopt 'O'; skip_next=yes;; \
58 -*O?*) strip_trailopt 'O';; \
59 -*l) strip_trailopt 'l'; skip_next=yes;; \
60 -*l?*) strip_trailopt 'l';; \
61 -[dEDm]) skip_next=yes;; \
62 -[JT]) skip_next=yes;; \
63 esac; \
64 case $$flg in \
65 *$$target_option*) has_opt=yes; break;; \
66 esac; \
67 done; \
68 test $$has_opt = yes
69 am__make_dryrun = (target_option=n; $(am__make_running_with_option))
70 am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
71 pkgdatadir = $(datadir)/@PACKAGE@
72 pkgincludedir = $(includedir)/@PACKAGE@
73 pkglibdir = $(libdir)/@PACKAGE@
74 pkglibexecdir = $(libexecdir)/@PACKAGE@
75 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
76 install_sh_DATA = $(install_sh) -c -m 644
77 install_sh_PROGRAM = $(install_sh) -c
78 install_sh_SCRIPT = $(install_sh) -c
79 INSTALL_HEADER = $(INSTALL_DATA)
80 transform = $(program_transform_name)
81 NORMAL_INSTALL = :
82 PRE_INSTALL = :
83 POST_INSTALL = :
84 NORMAL_UNINSTALL = :
85 PRE_UNINSTALL = :
86 POST_UNINSTALL = :
87 build_triplet = @build@
88 host_triplet = @host@
89 TESTS = test_xrdp$(EXEEXT)
90 check_PROGRAMS = test_xrdp$(EXEEXT)
91 subdir = tests/xrdp
92 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
93 am__aclocal_m4_deps = $(top_srcdir)/m4/ax_append_compile_flags.m4 \
94 $(top_srcdir)/m4/ax_append_flag.m4 \
95 $(top_srcdir)/m4/ax_cflags_warn_all.m4 \
96 $(top_srcdir)/m4/ax_check_compile_flag.m4 \
97 $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
98 $(top_srcdir)/m4/ax_require_defined.m4 \
99 $(top_srcdir)/m4/ax_type_socklen_t.m4 \
100 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
101 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
102 $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/pkg.m4 \
103 $(top_srcdir)/configure.ac
104 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
105 $(ACLOCAL_M4)
106 DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
107 mkinstalldirs = $(install_sh) -d
108 CONFIG_HEADER = $(top_builddir)/config_ac.h
109 CONFIG_CLEAN_FILES =
110 CONFIG_CLEAN_VPATH_FILES =
111 am_test_xrdp_OBJECTS = test_xrdp-test_xrdp_main.$(OBJEXT) \
112 test_xrdp-test_bitmap_load.$(OBJEXT)
113 test_xrdp_OBJECTS = $(am_test_xrdp_OBJECTS)
114 am__DEPENDENCIES_1 =
115 test_xrdp_DEPENDENCIES = $(top_builddir)/xrdp/xrdp_bitmap_load.o \
116 $(top_builddir)/xrdp/xrdp_bitmap_common.o \
117 $(top_builddir)/xrdp/funcs.o \
118 $(top_builddir)/common/libcommon.la $(am__DEPENDENCIES_1)
119 AM_V_lt = $(am__v_lt_@AM_V@)
120 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
121 am__v_lt_0 = --silent
122 am__v_lt_1 =
123 test_xrdp_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
124 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(test_xrdp_CFLAGS) \
125 $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
126 AM_V_P = $(am__v_P_@AM_V@)
127 am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
128 am__v_P_0 = false
129 am__v_P_1 = :
130 AM_V_GEN = $(am__v_GEN_@AM_V@)
131 am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
132 am__v_GEN_0 = @echo " GEN " $@;
133 am__v_GEN_1 =
134 AM_V_at = $(am__v_at_@AM_V@)
135 am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
136 am__v_at_0 = @
137 am__v_at_1 =
138 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
139 depcomp = $(SHELL) $(top_srcdir)/depcomp
140 am__maybe_remake_depfiles = depfiles
141 am__depfiles_remade = ./$(DEPDIR)/test_xrdp-test_bitmap_load.Po \
142 ./$(DEPDIR)/test_xrdp-test_xrdp_main.Po
143 am__mv = mv -f
144 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
145 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
146 LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
147 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
148 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
149 $(AM_CFLAGS) $(CFLAGS)
150 AM_V_CC = $(am__v_CC_@AM_V@)
151 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
152 am__v_CC_0 = @echo " CC " $@;
153 am__v_CC_1 =
154 CCLD = $(CC)
155 LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
156 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
157 $(AM_LDFLAGS) $(LDFLAGS) -o $@
158 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
159 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
160 am__v_CCLD_0 = @echo " CCLD " $@;
161 am__v_CCLD_1 =
162 SOURCES = $(test_xrdp_SOURCES)
163 DIST_SOURCES = $(test_xrdp_SOURCES)
164 am__can_run_installinfo = \
165 case $$AM_UPDATE_INFO_DIR in \
166 n|no|NO) false;; \
167 *) (install-info --version) >/dev/null 2>&1;; \
168 esac
169 am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
170 # Read a list of newline-separated strings from the standard input,
171 # and print each of them once, without duplicates. Input order is
172 # *not* preserved.
173 am__uniquify_input = $(AWK) '\
174 BEGIN { nonempty = 0; } \
175 { items[$$0] = 1; nonempty = 1; } \
176 END { if (nonempty) { for (i in items) print i; }; } \
177 '
178 # Make sure the list of sources is unique. This is necessary because,
179 # e.g., the same source file might be shared among _SOURCES variables
180 # for different programs/libraries.
181 am__define_uniq_tagged_files = \
182 list='$(am__tagged_files)'; \
183 unique=`for i in $$list; do \
184 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
185 done | $(am__uniquify_input)`
186 am__tty_colors_dummy = \
187 mgn= red= grn= lgn= blu= brg= std=; \
188 am__color_tests=no
189 am__tty_colors = { \
190 $(am__tty_colors_dummy); \
191 if test "X$(AM_COLOR_TESTS)" = Xno; then \
192 am__color_tests=no; \
193 elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
194 am__color_tests=yes; \
195 elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
196 am__color_tests=yes; \
197 fi; \
198 if test $$am__color_tests = yes; then \
199 red=''; \
200 grn=''; \
201 lgn=''; \
202 blu=''; \
203 mgn=''; \
204 brg=''; \
205 std=''; \
206 fi; \
207 }
208 am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
209 am__vpath_adj = case $$p in \
210 $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
211 *) f=$$p;; \
212 esac;
213 am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
214 am__install_max = 40
215 am__nobase_strip_setup = \
216 srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
217 am__nobase_strip = \
218 for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
219 am__nobase_list = $(am__nobase_strip_setup); \
220 for p in $$list; do echo "$$p $$p"; done | \
221 sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
222 $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
223 if (++n[$$2] == $(am__install_max)) \
224 { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
225 END { for (dir in files) print dir, files[dir] }'
226 am__base_list = \
227 sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
228 sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
229 am__uninstall_files_from_dir = { \
230 test -z "$$files" \
231 || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
232 || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
233 $(am__cd) "$$dir" && rm -f $$files; }; \
234 }
235 am__recheck_rx = ^[ ]*:recheck:[ ]*
236 am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
237 am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
238 # A command that, given a newline-separated list of test names on the
239 # standard input, print the name of the tests that are to be re-run
240 # upon "make recheck".
241 am__list_recheck_tests = $(AWK) '{ \
242 recheck = 1; \
243 while ((rc = (getline line < ($$0 ".trs"))) != 0) \
244 { \
245 if (rc < 0) \
246 { \
247 if ((getline line2 < ($$0 ".log")) < 0) \
248 recheck = 0; \
249 break; \
250 } \
251 else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
252 { \
253 recheck = 0; \
254 break; \
255 } \
256 else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
257 { \
258 break; \
259 } \
260 }; \
261 if (recheck) \
262 print $$0; \
263 close ($$0 ".trs"); \
264 close ($$0 ".log"); \
265 }'
266 # A command that, given a newline-separated list of test names on the
267 # standard input, create the global log from their .trs and .log files.
268 am__create_global_log = $(AWK) ' \
269 function fatal(msg) \
270 { \
271 print "fatal: making $@: " msg | "cat >&2"; \
272 exit 1; \
273 } \
274 function rst_section(header) \
275 { \
276 print header; \
277 len = length(header); \
278 for (i = 1; i <= len; i = i + 1) \
279 printf "="; \
280 printf "\n\n"; \
281 } \
282 { \
283 copy_in_global_log = 1; \
284 global_test_result = "RUN"; \
285 while ((rc = (getline line < ($$0 ".trs"))) != 0) \
286 { \
287 if (rc < 0) \
288 fatal("failed to read from " $$0 ".trs"); \
289 if (line ~ /$(am__global_test_result_rx)/) \
290 { \
291 sub("$(am__global_test_result_rx)", "", line); \
292 sub("[ ]*$$", "", line); \
293 global_test_result = line; \
294 } \
295 else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
296 copy_in_global_log = 0; \
297 }; \
298 if (copy_in_global_log) \
299 { \
300 rst_section(global_test_result ": " $$0); \
301 while ((rc = (getline line < ($$0 ".log"))) != 0) \
302 { \
303 if (rc < 0) \
304 fatal("failed to read from " $$0 ".log"); \
305 print line; \
306 }; \
307 printf "\n"; \
308 }; \
309 close ($$0 ".trs"); \
310 close ($$0 ".log"); \
311 }'
312 # Restructured Text title.
313 am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
314 # Solaris 10 'make', and several other traditional 'make' implementations,
315 # pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
316 # by disabling -e (using the XSI extension "set +e") if it's set.
317 am__sh_e_setup = case $$- in *e*) set +e;; esac
318 # Default flags passed to test drivers.
319 am__common_driver_flags = \
320 --color-tests "$$am__color_tests" \
321 --enable-hard-errors "$$am__enable_hard_errors" \
322 --expect-failure "$$am__expect_failure"
323 # To be inserted before the command running the test. Creates the
324 # directory for the log if needed. Stores in $dir the directory
325 # containing $f, in $tst the test, in $log the log. Executes the
326 # developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
327 # passes TESTS_ENVIRONMENT. Set up options for the wrapper that
328 # will run the test scripts (or their associated LOG_COMPILER, if
329 # thy have one).
330 am__check_pre = \
331 $(am__sh_e_setup); \
332 $(am__vpath_adj_setup) $(am__vpath_adj) \
333 $(am__tty_colors); \
334 srcdir=$(srcdir); export srcdir; \
335 case "$@" in \
336 */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
337 *) am__odir=.;; \
338 esac; \
339 test "x$$am__odir" = x"." || test -d "$$am__odir" \
340 || $(MKDIR_P) "$$am__odir" || exit $$?; \
341 if test -f "./$$f"; then dir=./; \
342 elif test -f "$$f"; then dir=; \
343 else dir="$(srcdir)/"; fi; \
344 tst=$$dir$$f; log='$@'; \
345 if test -n '$(DISABLE_HARD_ERRORS)'; then \
346 am__enable_hard_errors=no; \
347 else \
348 am__enable_hard_errors=yes; \
349 fi; \
350 case " $(XFAIL_TESTS) " in \
351 *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
352 am__expect_failure=yes;; \
353 *) \
354 am__expect_failure=no;; \
355 esac; \
356 $(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
357 # A shell command to get the names of the tests scripts with any registered
358 # extension removed (i.e., equivalently, the names of the test logs, with
359 # the '.log' extension removed). The result is saved in the shell variable
360 # '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
361 # we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
362 # since that might cause problem with VPATH rewrites for suffix-less tests.
363 # See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
364 am__set_TESTS_bases = \
365 bases='$(TEST_LOGS)'; \
366 bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
367 bases=`echo $$bases`
368 AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)'
369 RECHECK_LOGS = $(TEST_LOGS)
370 AM_RECURSIVE_TARGETS = check recheck
371 TEST_SUITE_LOG = test-suite.log
372 TEST_EXTENSIONS = @EXEEXT@ .test
373 LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
374 am__set_b = \
375 case '$@' in \
376 */*) \
377 case '$*' in \
378 */*) b='$*';; \
379 *) b=`echo '$@' | sed 's/\.log$$//'`; \
380 esac;; \
381 *) \
382 b='$*';; \
383 esac
384 am__test_logs1 = $(TESTS:=.log)
385 am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
386 TEST_LOGS = $(am__test_logs2:.test.log=.log)
387 TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
388 TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
389 $(TEST_LOG_FLAGS)
390 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp \
391 $(top_srcdir)/test-driver
392 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
393 ACLOCAL = @ACLOCAL@
394 AMTAR = @AMTAR@
395 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
396 AR = @AR@
397 AUTOCONF = @AUTOCONF@
398 AUTOHEADER = @AUTOHEADER@
399 AUTOMAKE = @AUTOMAKE@
400 AWK = @AWK@
401 CC = @CC@
402 CCDEPMODE = @CCDEPMODE@
403 CFLAGS = @CFLAGS@
404 CHECK_CFLAGS = @CHECK_CFLAGS@
405 CHECK_LIBS = @CHECK_LIBS@
406 CPP = @CPP@
407 CPPFLAGS = @CPPFLAGS@
408 CSCOPE = @CSCOPE@
409 CTAGS = @CTAGS@
410 CYGPATH_W = @CYGPATH_W@
411 DEFS = @DEFS@
412 DEPDIR = @DEPDIR@
413 DLLTOOL = @DLLTOOL@
414 DLOPEN_LIBS = @DLOPEN_LIBS@
415 DSYMUTIL = @DSYMUTIL@
416 DUMPBIN = @DUMPBIN@
417 ECHO_C = @ECHO_C@
418 ECHO_N = @ECHO_N@
419 ECHO_T = @ECHO_T@
420 EGREP = @EGREP@
421 ETAGS = @ETAGS@
422 EXEEXT = @EXEEXT@
423 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
424 FDKAAC_LIBS = @FDKAAC_LIBS@
425 FGREP = @FGREP@
426 FREERDP_CFLAGS = @FREERDP_CFLAGS@
427 FREERDP_LIBS = @FREERDP_LIBS@
428 FUSE_CFLAGS = @FUSE_CFLAGS@
429 FUSE_LIBS = @FUSE_LIBS@
430 GREP = @GREP@
431 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
432 IMLIB2_LIBS = @IMLIB2_LIBS@
433 INSTALL = @INSTALL@
434 INSTALL_DATA = @INSTALL_DATA@
435 INSTALL_PROGRAM = @INSTALL_PROGRAM@
436 INSTALL_SCRIPT = @INSTALL_SCRIPT@
437 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
438 LD = @LD@
439 LDFLAGS = @LDFLAGS@
440 LIBOBJS = @LIBOBJS@
441 LIBS = @LIBS@
442 LIBTOOL = @LIBTOOL@
443 LIPO = @LIPO@
444 LN_S = @LN_S@
445 LTLIBOBJS = @LTLIBOBJS@
446 LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
447 MAKEINFO = @MAKEINFO@
448 MANIFEST_TOOL = @MANIFEST_TOOL@
449 MKDIR_P = @MKDIR_P@
450 NM = @NM@
451 NMEDIT = @NMEDIT@
452 OBJDUMP = @OBJDUMP@
453 OBJEXT = @OBJEXT@
454 OPENSSL = @OPENSSL@
455 OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
456 OPENSSL_LIBS = @OPENSSL_LIBS@
457 OTOOL = @OTOOL@
458 OTOOL64 = @OTOOL64@
459 PACKAGE = @PACKAGE@
460 PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
461 PACKAGE_NAME = @PACKAGE_NAME@
462 PACKAGE_STRING = "XRDP daemon"
463 PACKAGE_TARNAME = @PACKAGE_TARNAME@
464 PACKAGE_URL = @PACKAGE_URL@
465 PACKAGE_VERSION = @PACKAGE_VERSION@
466 PAM_RULES = @PAM_RULES@
467 PATH_SEPARATOR = @PATH_SEPARATOR@
468 PIXMAN_CFLAGS = @PIXMAN_CFLAGS@
469 PIXMAN_LIBS = @PIXMAN_LIBS@
470 PKG_CONFIG = @PKG_CONFIG@
471 PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
472 PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
473 RANLIB = @RANLIB@
474 SED = @SED@
475 SET_MAKE = @SET_MAKE@
476 SHELL = @SHELL@
477 STRIP = @STRIP@
478 TurboJpegIncDir = @TurboJpegIncDir@
479 TurboJpegLibDir = @TurboJpegLibDir@
480 VERSION = @VERSION@
481 XMKMF = @XMKMF@
482 X_CFLAGS = @X_CFLAGS@
483 X_EXTRA_LIBS = @X_EXTRA_LIBS@
484 X_LIBS = @X_LIBS@
485 X_PRE_LIBS = @X_PRE_LIBS@
486 abs_builddir = @abs_builddir@
487 abs_srcdir = @abs_srcdir@
488 abs_top_builddir = @abs_top_builddir@
489 abs_top_srcdir = @abs_top_srcdir@
490 ac_ct_AR = @ac_ct_AR@
491 ac_ct_CC = @ac_ct_CC@
492 ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
493 am__include = @am__include@
494 am__leading_dot = @am__leading_dot@
495 am__quote = @am__quote@
496 am__tar = @am__tar@
497 am__untar = @am__untar@
498 bindir = @bindir@
499 build = @build@
500 build_alias = @build_alias@
501 build_cpu = @build_cpu@
502 build_os = @build_os@
503 build_vendor = @build_vendor@
504 builddir = @builddir@
505 datadir = @datadir@
506 datarootdir = @datarootdir@
507 docdir = @docdir@
508 dvidir = @dvidir@
509 exec_prefix = @exec_prefix@
510 host = @host@
511 host_alias = @host_alias@
512 host_cpu = @host_cpu@
513 host_os = @host_os@
514 host_vendor = @host_vendor@
515 htmldir = @htmldir@
516 includedir = @includedir@
517 infodir = @infodir@
518 install_sh = @install_sh@
519 libdir = @libdir@
520 libexecdir = @libexecdir@
521 localedir = @localedir@
522 localstatedir = @localstatedir@
523 mandir = @mandir@
524 mkdir_p = @mkdir_p@
525 moduledir = @moduledir@
526 oldincludedir = @oldincludedir@
527 pdfdir = @pdfdir@
528 pkgconfigdir = @pkgconfigdir@
529 prefix = @prefix@
530 program_transform_name = @program_transform_name@
531 psdir = @psdir@
532 sbindir = @sbindir@
533 sharedstatedir = @sharedstatedir@
534 socketdir = @socketdir@
535 srcdir = @srcdir@
536 subdirs = @subdirs@
537 sysconfdir = @sysconfdir@
538 systemdsystemunitdir = @systemdsystemunitdir@
539 target_alias = @target_alias@
540 top_build_prefix = @top_build_prefix@
541 top_builddir = @top_builddir@
542 top_srcdir = @top_srcdir@
543 AM_CPPFLAGS = \
544 -I$(top_builddir) \
545 -I$(top_srcdir)/xrdp \
546 -I$(top_srcdir)/libxrdp \
547 -I$(top_srcdir)/common \
548 $(IMLIB2_CFLAGS)
549
550 LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
551 $(top_srcdir)/tap-driver.sh
552
553 EXTRA_DIST = \
554 test_4bit.bmp \
555 test_8bit.bmp \
556 test_24bit.bmp \
557 test_not4_4bit.bmp \
558 test_not4_8bit.bmp \
559 test_not4_24bit.bmp \
560 test1.jpg \
561 test_alpha_blend.png
562
563 test_xrdp_SOURCES = \
564 test_xrdp.h \
565 test_xrdp_main.c \
566 test_bitmap_load.c
567
568 test_xrdp_CFLAGS = \
569 -D IMAGEDIR=\"$(srcdir)\" \
570 @CHECK_CFLAGS@
571
572 test_xrdp_LDADD = \
573 $(top_builddir)/xrdp/xrdp_bitmap_load.o \
574 $(top_builddir)/xrdp/xrdp_bitmap_common.o \
575 $(top_builddir)/xrdp/funcs.o \
576 $(top_builddir)/common/libcommon.la \
577 $(IMLIB2_LIBS) \
578 @CHECK_LIBS@
579
580 all: all-am
581
582 .SUFFIXES:
583 .SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs
584 $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
585 @for dep in $?; do \
586 case '$(am__configure_deps)' in \
587 *$$dep*) \
588 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
589 && { if test -f $@; then exit 0; else break; fi; }; \
590 exit 1;; \
591 esac; \
592 done; \
593 echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/xrdp/Makefile'; \
594 $(am__cd) $(top_srcdir) && \
595 $(AUTOMAKE) --foreign tests/xrdp/Makefile
596 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
597 @case '$?' in \
598 *config.status*) \
599 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
600 *) \
601 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
602 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
603 esac;
604
605 $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
606 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
607
608 $(top_srcdir)/configure: $(am__configure_deps)
609 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
610 $(ACLOCAL_M4): $(am__aclocal_m4_deps)
611 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
612 $(am__aclocal_m4_deps):
613
614 clean-checkPROGRAMS:
615 @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
616 echo " rm -f" $$list; \
617 rm -f $$list || exit $$?; \
618 test -n "$(EXEEXT)" || exit 0; \
619 list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
620 echo " rm -f" $$list; \
621 rm -f $$list
622
623 test_xrdp$(EXEEXT): $(test_xrdp_OBJECTS) $(test_xrdp_DEPENDENCIES) $(EXTRA_test_xrdp_DEPENDENCIES)
624 @rm -f test_xrdp$(EXEEXT)
625 $(AM_V_CCLD)$(test_xrdp_LINK) $(test_xrdp_OBJECTS) $(test_xrdp_LDADD) $(LIBS)
626
627 mostlyclean-compile:
628 -rm -f *.$(OBJEXT)
629
630 distclean-compile:
631 -rm -f *.tab.c
632
633 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_xrdp-test_bitmap_load.Po@am__quote@ # am--include-marker
634 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test_xrdp-test_xrdp_main.Po@am__quote@ # am--include-marker
635
636 $(am__depfiles_remade):
637 @$(MKDIR_P) $(@D)
638 @echo '# dummy' >$@-t && $(am__mv) $@-t $@
639
640 am--depfiles: $(am__depfiles_remade)
641
642 .c.o:
643 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
644 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
645 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
646 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
647 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
648
649 .c.obj:
650 @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
651 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
652 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
653 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
654 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
655
656 .c.lo:
657 @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
658 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
659 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
660 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
661 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
662
663 test_xrdp-test_xrdp_main.o: test_xrdp_main.c
664 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xrdp_CFLAGS) $(CFLAGS) -MT test_xrdp-test_xrdp_main.o -MD -MP -MF $(DEPDIR)/test_xrdp-test_xrdp_main.Tpo -c -o test_xrdp-test_xrdp_main.o `test -f 'test_xrdp_main.c' || echo '$(srcdir)/'`test_xrdp_main.c
665 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_xrdp-test_xrdp_main.Tpo $(DEPDIR)/test_xrdp-test_xrdp_main.Po
666 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_xrdp_main.c' object='test_xrdp-test_xrdp_main.o' libtool=no @AMDEPBACKSLASH@
667 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
668 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xrdp_CFLAGS) $(CFLAGS) -c -o test_xrdp-test_xrdp_main.o `test -f 'test_xrdp_main.c' || echo '$(srcdir)/'`test_xrdp_main.c
669
670 test_xrdp-test_xrdp_main.obj: test_xrdp_main.c
671 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xrdp_CFLAGS) $(CFLAGS) -MT test_xrdp-test_xrdp_main.obj -MD -MP -MF $(DEPDIR)/test_xrdp-test_xrdp_main.Tpo -c -o test_xrdp-test_xrdp_main.obj `if test -f 'test_xrdp_main.c'; then $(CYGPATH_W) 'test_xrdp_main.c'; else $(CYGPATH_W) '$(srcdir)/test_xrdp_main.c'; fi`
672 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_xrdp-test_xrdp_main.Tpo $(DEPDIR)/test_xrdp-test_xrdp_main.Po
673 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_xrdp_main.c' object='test_xrdp-test_xrdp_main.obj' libtool=no @AMDEPBACKSLASH@
674 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
675 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xrdp_CFLAGS) $(CFLAGS) -c -o test_xrdp-test_xrdp_main.obj `if test -f 'test_xrdp_main.c'; then $(CYGPATH_W) 'test_xrdp_main.c'; else $(CYGPATH_W) '$(srcdir)/test_xrdp_main.c'; fi`
676
677 test_xrdp-test_bitmap_load.o: test_bitmap_load.c
678 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xrdp_CFLAGS) $(CFLAGS) -MT test_xrdp-test_bitmap_load.o -MD -MP -MF $(DEPDIR)/test_xrdp-test_bitmap_load.Tpo -c -o test_xrdp-test_bitmap_load.o `test -f 'test_bitmap_load.c' || echo '$(srcdir)/'`test_bitmap_load.c
679 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_xrdp-test_bitmap_load.Tpo $(DEPDIR)/test_xrdp-test_bitmap_load.Po
680 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_bitmap_load.c' object='test_xrdp-test_bitmap_load.o' libtool=no @AMDEPBACKSLASH@
681 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
682 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xrdp_CFLAGS) $(CFLAGS) -c -o test_xrdp-test_bitmap_load.o `test -f 'test_bitmap_load.c' || echo '$(srcdir)/'`test_bitmap_load.c
683
684 test_xrdp-test_bitmap_load.obj: test_bitmap_load.c
685 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xrdp_CFLAGS) $(CFLAGS) -MT test_xrdp-test_bitmap_load.obj -MD -MP -MF $(DEPDIR)/test_xrdp-test_bitmap_load.Tpo -c -o test_xrdp-test_bitmap_load.obj `if test -f 'test_bitmap_load.c'; then $(CYGPATH_W) 'test_bitmap_load.c'; else $(CYGPATH_W) '$(srcdir)/test_bitmap_load.c'; fi`
686 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/test_xrdp-test_bitmap_load.Tpo $(DEPDIR)/test_xrdp-test_bitmap_load.Po
687 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test_bitmap_load.c' object='test_xrdp-test_bitmap_load.obj' libtool=no @AMDEPBACKSLASH@
688 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
689 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_xrdp_CFLAGS) $(CFLAGS) -c -o test_xrdp-test_bitmap_load.obj `if test -f 'test_bitmap_load.c'; then $(CYGPATH_W) 'test_bitmap_load.c'; else $(CYGPATH_W) '$(srcdir)/test_bitmap_load.c'; fi`
690
691 mostlyclean-libtool:
692 -rm -f *.lo
693
694 clean-libtool:
695 -rm -rf .libs _libs
696
697 ID: $(am__tagged_files)
698 $(am__define_uniq_tagged_files); mkid -fID $$unique
699 tags: tags-am
700 TAGS: tags
701
702 tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
703 set x; \
704 here=`pwd`; \
705 $(am__define_uniq_tagged_files); \
706 shift; \
707 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
708 test -n "$$unique" || unique=$$empty_fix; \
709 if test $$# -gt 0; then \
710 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
711 "$$@" $$unique; \
712 else \
713 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
714 $$unique; \
715 fi; \
716 fi
717 ctags: ctags-am
718
719 CTAGS: ctags
720 ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
721 $(am__define_uniq_tagged_files); \
722 test -z "$(CTAGS_ARGS)$$unique" \
723 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
724 $$unique
725
726 GTAGS:
727 here=`$(am__cd) $(top_builddir) && pwd` \
728 && $(am__cd) $(top_srcdir) \
729 && gtags -i $(GTAGS_ARGS) "$$here"
730 cscopelist: cscopelist-am
731
732 cscopelist-am: $(am__tagged_files)
733 list='$(am__tagged_files)'; \
734 case "$(srcdir)" in \
735 [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
736 *) sdir=$(subdir)/$(srcdir) ;; \
737 esac; \
738 for i in $$list; do \
739 if test -f "$$i"; then \
740 echo "$(subdir)/$$i"; \
741 else \
742 echo "$$sdir/$$i"; \
743 fi; \
744 done >> $(top_builddir)/cscope.files
745
746 distclean-tags:
747 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
748
749 # Recover from deleted '.trs' file; this should ensure that
750 # "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
751 # both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
752 # to avoid problems with "make -n".
753 .log.trs:
754 rm -f $< $@
755 $(MAKE) $(AM_MAKEFLAGS) $<
756
757 # Leading 'am--fnord' is there to ensure the list of targets does not
758 # expand to empty, as could happen e.g. with make check TESTS=''.
759 am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
760 am--force-recheck:
761 @:
762
763 $(TEST_SUITE_LOG): $(TEST_LOGS)
764 @$(am__set_TESTS_bases); \
765 am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
766 redo_bases=`for i in $$bases; do \
767 am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
768 done`; \
769 if test -n "$$redo_bases"; then \
770 redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
771 redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
772 if $(am__make_dryrun); then :; else \
773 rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
774 fi; \
775 fi; \
776 if test -n "$$am__remaking_logs"; then \
777 echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
778 "recursion detected" >&2; \
779 elif test -n "$$redo_logs"; then \
780 am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
781 fi; \
782 if $(am__make_dryrun); then :; else \
783 st=0; \
784 errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
785 for i in $$redo_bases; do \
786 test -f $$i.trs && test -r $$i.trs \
787 || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
788 test -f $$i.log && test -r $$i.log \
789 || { echo "$$errmsg $$i.log" >&2; st=1; }; \
790 done; \
791 test $$st -eq 0 || exit 1; \
792 fi
793 @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
794 ws='[ ]'; \
795 results=`for b in $$bases; do echo $$b.trs; done`; \
796 test -n "$$results" || results=/dev/null; \
797 all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
798 pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
799 fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
800 skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
801 xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
802 xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
803 error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
804 if test `expr $$fail + $$xpass + $$error` -eq 0; then \
805 success=true; \
806 else \
807 success=false; \
808 fi; \
809 br='==================='; br=$$br$$br$$br$$br; \
810 result_count () \
811 { \
812 if test x"$$1" = x"--maybe-color"; then \
813 maybe_colorize=yes; \
814 elif test x"$$1" = x"--no-color"; then \
815 maybe_colorize=no; \
816 else \
817 echo "$@: invalid 'result_count' usage" >&2; exit 4; \
818 fi; \
819 shift; \
820 desc=$$1 count=$$2; \
821 if test $$maybe_colorize = yes && test $$count -gt 0; then \
822 color_start=$$3 color_end=$$std; \
823 else \
824 color_start= color_end=; \
825 fi; \
826 echo "$${color_start}# $$desc $$count$${color_end}"; \
827 }; \
828 create_testsuite_report () \
829 { \
830 result_count $$1 "TOTAL:" $$all "$$brg"; \
831 result_count $$1 "PASS: " $$pass "$$grn"; \
832 result_count $$1 "SKIP: " $$skip "$$blu"; \
833 result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
834 result_count $$1 "FAIL: " $$fail "$$red"; \
835 result_count $$1 "XPASS:" $$xpass "$$red"; \
836 result_count $$1 "ERROR:" $$error "$$mgn"; \
837 }; \
838 { \
839 echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
840 $(am__rst_title); \
841 create_testsuite_report --no-color; \
842 echo; \
843 echo ".. contents:: :depth: 2"; \
844 echo; \
845 for b in $$bases; do echo $$b; done \
846 | $(am__create_global_log); \
847 } >$(TEST_SUITE_LOG).tmp || exit 1; \
848 mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
849 if $$success; then \
850 col="$$grn"; \
851 else \
852 col="$$red"; \
853 test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
854 fi; \
855 echo "$${col}$$br$${std}"; \
856 echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \
857 echo "$${col}$$br$${std}"; \
858 create_testsuite_report --maybe-color; \
859 echo "$$col$$br$$std"; \
860 if $$success; then :; else \
861 echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
862 if test -n "$(PACKAGE_BUGREPORT)"; then \
863 echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
864 fi; \
865 echo "$$col$$br$$std"; \
866 fi; \
867 $$success || exit 1
868
869 check-TESTS: $(check_PROGRAMS)
870 @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
871 @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
872 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
873 @set +e; $(am__set_TESTS_bases); \
874 log_list=`for i in $$bases; do echo $$i.log; done`; \
875 trs_list=`for i in $$bases; do echo $$i.trs; done`; \
876 log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
877 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
878 exit $$?;
879 recheck: all $(check_PROGRAMS)
880 @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
881 @set +e; $(am__set_TESTS_bases); \
882 bases=`for i in $$bases; do echo $$i; done \
883 | $(am__list_recheck_tests)` || exit 1; \
884 log_list=`for i in $$bases; do echo $$i.log; done`; \
885 log_list=`echo $$log_list`; \
886 $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
887 am__force_recheck=am--force-recheck \
888 TEST_LOGS="$$log_list"; \
889 exit $$?
890 test_xrdp.log: test_xrdp$(EXEEXT)
891 @p='test_xrdp$(EXEEXT)'; \
892 b='test_xrdp'; \
893 $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
894 --log-file $$b.log --trs-file $$b.trs \
895 $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
896 "$$tst" $(AM_TESTS_FD_REDIRECT)
897 .test.log:
898 @p='$<'; \
899 $(am__set_b); \
900 $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
901 --log-file $$b.log --trs-file $$b.trs \
902 $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
903 "$$tst" $(AM_TESTS_FD_REDIRECT)
904 @am__EXEEXT_TRUE@.test$(EXEEXT).log:
905 @am__EXEEXT_TRUE@ @p='$<'; \
906 @am__EXEEXT_TRUE@ $(am__set_b); \
907 @am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
908 @am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
909 @am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
910 @am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
911 distdir: $(BUILT_SOURCES)
912 $(MAKE) $(AM_MAKEFLAGS) distdir-am
913
914 distdir-am: $(DISTFILES)
915 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
916 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
917 list='$(DISTFILES)'; \
918 dist_files=`for file in $$list; do echo $$file; done | \
919 sed -e "s|^$$srcdirstrip/||;t" \
920 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
921 case $$dist_files in \
922 */*) $(MKDIR_P) `echo "$$dist_files" | \
923 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
924 sort -u` ;; \
925 esac; \
926 for file in $$dist_files; do \
927 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
928 if test -d $$d/$$file; then \
929 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
930 if test -d "$(distdir)/$$file"; then \
931 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
932 fi; \
933 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
934 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
935 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
936 fi; \
937 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
938 else \
939 test -f "$(distdir)/$$file" \
940 || cp -p $$d/$$file "$(distdir)/$$file" \
941 || exit 1; \
942 fi; \
943 done
944 check-am: all-am
945 $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
946 $(MAKE) $(AM_MAKEFLAGS) check-TESTS
947 check: check-am
948 all-am: Makefile
949 installdirs:
950 install: install-am
951 install-exec: install-exec-am
952 install-data: install-data-am
953 uninstall: uninstall-am
954
955 install-am: all-am
956 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
957
958 installcheck: installcheck-am
959 install-strip:
960 if test -z '$(STRIP)'; then \
961 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
962 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
963 install; \
964 else \
965 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
966 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
967 "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
968 fi
969 mostlyclean-generic:
970 -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
971 -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
972 -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
973
974 clean-generic:
975
976 distclean-generic:
977 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
978 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
979
980 maintainer-clean-generic:
981 @echo "This command is intended for maintainers to use"
982 @echo "it deletes files that may require special tools to rebuild."
983 clean: clean-am
984
985 clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
986 mostlyclean-am
987
988 distclean: distclean-am
989 -rm -f ./$(DEPDIR)/test_xrdp-test_bitmap_load.Po
990 -rm -f ./$(DEPDIR)/test_xrdp-test_xrdp_main.Po
991 -rm -f Makefile
992 distclean-am: clean-am distclean-compile distclean-generic \
993 distclean-tags
994
995 dvi: dvi-am
996
997 dvi-am:
998
999 html: html-am
1000
1001 html-am:
1002
1003 info: info-am
1004
1005 info-am:
1006
1007 install-data-am:
1008
1009 install-dvi: install-dvi-am
1010
1011 install-dvi-am:
1012
1013 install-exec-am:
1014
1015 install-html: install-html-am
1016
1017 install-html-am:
1018
1019 install-info: install-info-am
1020
1021 install-info-am:
1022
1023 install-man:
1024
1025 install-pdf: install-pdf-am
1026
1027 install-pdf-am:
1028
1029 install-ps: install-ps-am
1030
1031 install-ps-am:
1032
1033 installcheck-am:
1034
1035 maintainer-clean: maintainer-clean-am
1036 -rm -f ./$(DEPDIR)/test_xrdp-test_bitmap_load.Po
1037 -rm -f ./$(DEPDIR)/test_xrdp-test_xrdp_main.Po
1038 -rm -f Makefile
1039 maintainer-clean-am: distclean-am maintainer-clean-generic
1040
1041 mostlyclean: mostlyclean-am
1042
1043 mostlyclean-am: mostlyclean-compile mostlyclean-generic \
1044 mostlyclean-libtool
1045
1046 pdf: pdf-am
1047
1048 pdf-am:
1049
1050 ps: ps-am
1051
1052 ps-am:
1053
1054 uninstall-am:
1055
1056 .MAKE: check-am install-am install-strip
1057
1058 .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \
1059 check-am clean clean-checkPROGRAMS clean-generic clean-libtool \
1060 cscopelist-am ctags ctags-am distclean distclean-compile \
1061 distclean-generic distclean-libtool distclean-tags distdir dvi \
1062 dvi-am html html-am info info-am install install-am \
1063 install-data install-data-am install-dvi install-dvi-am \
1064 install-exec install-exec-am install-html install-html-am \
1065 install-info install-info-am install-man install-pdf \
1066 install-pdf-am install-ps install-ps-am install-strip \
1067 installcheck installcheck-am installdirs maintainer-clean \
1068 maintainer-clean-generic mostlyclean mostlyclean-compile \
1069 mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
1070 recheck tags tags-am uninstall uninstall-am
1071
1072 .PRECIOUS: Makefile
1073
1074
1075 # Tell versions [3.59,3.63) of GNU make to not export all variables.
1076 # Otherwise a system limit (for SysV at least) may be exceeded.
1077 .NOEXPORT:
Binary diff not shown
Binary diff not shown
Binary diff not shown
Binary diff not shown
0 #if defined(HAVE_CONFIG_H)
1 #include "config_ac.h"
2 #endif
3
4 #include "xrdp.h"
5
6 #include "test_xrdp.h"
7
8 /* Where the image files are located */
9 #ifndef IMAGEDIR
10 #define IMAGEDIR "."
11 #endif
12
13 /* Handy color definitions. These are variables so they are displayed
14 * in assert messages if tests fail */
15 static int RED = COLOR24RGB(255, 0, 0);
16 static int GREEN = COLOR24RGB(0, 255, 0);
17 static int BLUE = COLOR24RGB(0, 0, 255);
18 static int WHITE = COLOR24RGB(255, 255, 255);
19
20 /* Virtual desktop maxima and minima [MS-RDPBCGR] 2.2.1.3.6 */
21 #define MAX_VDESKTOP_WIDTH 32766
22 #define MAX_VDESKTOP_HEIGHT 32766
23 #define MIN_VDESKTOP_WIDTH 200
24 #define MIN_VDESKTOP_HEIGHT 200
25
26 /* Characteristics of the test bitmap(s) */
27 #define TEST_BM_WIDTH 256
28 #define TEST_BM_HEIGHT 256
29
30 #define TEST_NOT4_BM_WIDTH 62
31 #define TEST_NOT4_BM_HEIGHT 62
32
33 #define TEST_BM_TOP_LEFT_PIXEL RED
34 #define TEST_BM_TOP_RIGHT_PIXEL GREEN
35 #define TEST_BM_BOTTOM_LEFT_PIXEL BLUE
36 #define TEST_BM_BOTTOM_RIGHT_PIXEL WHITE
37
38 /*
39 * Scaling bitmaps properly will introduce color changes with dithering.
40 * Also some filetypes use compression, and these do not represent colors
41 * perfectly.
42 *
43 * This is the Pythagorean distance we allow between two colors for them to
44 * be considered close enough to each other */
45 #define MAX_SIMILAR_COLOR_DISTANCE 3
46
47 void setup(void)
48 {
49 }
50
51 void teardown(void)
52 {
53 }
54
55 /* Tests an error is returned for a non-existent file */
56 START_TEST(test_bitmap_load__with_invalid_image__fail)
57 {
58 struct xrdp_wm *wm = NULL;
59 int result;
60
61 struct xrdp_bitmap *bm = xrdp_bitmap_create(4, 4, 32, WND_TYPE_IMAGE, wm);
62
63 ck_assert_ptr_ne(bm, NULL);
64
65 result = xrdp_bitmap_load(bm, "/dev/null", NULL, 0, XBLT_NONE, 0, 0);
66
67 ck_assert_int_ne(result, 0);
68
69 xrdp_bitmap_delete(bm);
70 }
71 END_TEST
72
73 /* Checks a particular pixmap value is expected */
74 static void
75 check_pixel(struct xrdp_bitmap *bm, int i, int j, int expected)
76 {
77 int pixel = xrdp_bitmap_get_pixel(bm, i, j);
78 if (pixel != expected)
79 {
80 ck_abort_msg("Pixmap (%d,%d) expected 0x%06x, got 0x%06x",
81 i, j, expected, pixel);
82 }
83 }
84
85 /* Calculates whether two colors are close enough to be considered the same */
86 static void
87 check_is_close_color(struct xrdp_bitmap *bm, int i, int j, int expected)
88 {
89 int pixel = xrdp_bitmap_get_pixel(bm, i, j);
90 int r1;
91 int g1;
92 int b1;
93 int r2;
94 int g2;
95 int b2;
96 int variance;
97
98 SPLITCOLOR32(r1, g1, b1, pixel);
99 SPLITCOLOR32(r2, g2, b2, expected);
100
101 variance = ((r1 - r2) * (r1 - r2) +
102 (g1 - g2) * (g1 - g2) +
103 (b1 - b2) * (b1 - b2));
104
105 if (variance > MAX_SIMILAR_COLOR_DISTANCE * MAX_SIMILAR_COLOR_DISTANCE)
106 {
107 ck_abort_msg("Pixmap (%d,%d) expected 0x%06x, got 0x%06x"
108 " which exceeds distance of %d",
109 i, j, expected, pixel, MAX_SIMILAR_COLOR_DISTANCE);
110 }
111 }
112
113 /* Check we can load images of various depths with various transforms */
114 static void
115 load_and_transform_img(const char *name,
116 enum xrdp_bitmap_load_transform transform,
117 int twidth, int theight)
118 {
119 struct xrdp_wm *wm = NULL;
120 int result;
121
122 int width;
123 int height;
124
125 char full_name[256];
126
127 struct xrdp_bitmap *bm = xrdp_bitmap_create(4, 4, 32, WND_TYPE_IMAGE, wm);
128
129 ck_assert_ptr_ne(bm, NULL);
130
131 g_snprintf(full_name, sizeof(full_name), IMAGEDIR "/%s", name);
132 result = xrdp_bitmap_load(bm, full_name, NULL, HCOLOR(bm->bpp, WHITE),
133 transform, twidth, theight);
134
135 ck_assert_int_eq(result, 0);
136
137 /* Bitmap right size? */
138 if (transform == XBLT_NONE)
139 {
140 width = TEST_BM_WIDTH;
141 height = TEST_BM_HEIGHT;
142 ck_assert_int_eq(bm->width, TEST_BM_WIDTH);
143 ck_assert_int_eq(bm->height, TEST_BM_HEIGHT);
144 }
145 else
146 {
147 width = twidth;
148 height = theight;
149 ck_assert_int_eq(bm->width, twidth);
150 ck_assert_int_eq(bm->height, theight);
151 }
152
153 /* Corners OK? Allow for dithering */
154 check_is_close_color(bm, 0, 0, TEST_BM_TOP_LEFT_PIXEL);
155 check_is_close_color(bm, width - 1, 0, TEST_BM_TOP_RIGHT_PIXEL);
156 check_is_close_color(bm, 0, height - 1, TEST_BM_BOTTOM_LEFT_PIXEL);
157 check_is_close_color(bm, width - 1, height - 1, TEST_BM_BOTTOM_RIGHT_PIXEL);
158
159 xrdp_bitmap_delete(bm);
160 }
161
162 /* Check we can load bitmaps that aren't a multiple of 4 pixels wide */
163 static void
164 load_not4_img(const char *name)
165 {
166 struct xrdp_wm *wm = NULL;
167 int result;
168
169 const int width = TEST_NOT4_BM_WIDTH;
170 const int height = TEST_NOT4_BM_HEIGHT;
171
172 char full_name[256];
173 int i;
174 int j;
175
176 struct xrdp_bitmap *bm = xrdp_bitmap_create(4, 4, 32, WND_TYPE_IMAGE, wm);
177
178 ck_assert_ptr_ne(bm, NULL);
179
180 g_snprintf(full_name, sizeof(full_name), IMAGEDIR "/%s", name);
181 result = xrdp_bitmap_load(bm, full_name, NULL, HCOLOR(bm->bpp, WHITE),
182 XBLT_NONE, 0, 0);
183
184 ck_assert_int_eq(result, 0);
185
186 /* Bitmap right size? */
187 ck_assert_int_eq(bm->width, TEST_NOT4_BM_WIDTH);
188 ck_assert_int_eq(bm->height, TEST_NOT4_BM_HEIGHT);
189
190 /* Check all data */
191 for (i = 0 ; i < width / 2 ; ++i)
192 {
193 for (j = 0 ; j < height / 2 ; ++j)
194 {
195 check_pixel(bm, i, j, TEST_BM_TOP_LEFT_PIXEL);
196 check_pixel(bm, i + width / 2, j, TEST_BM_TOP_RIGHT_PIXEL);
197 check_pixel(bm, i, j + height / 2, TEST_BM_BOTTOM_LEFT_PIXEL);
198 check_pixel(bm, i + width / 2, j + height / 2,
199 TEST_BM_BOTTOM_RIGHT_PIXEL);
200 }
201 }
202
203 xrdp_bitmap_delete(bm);
204 }
205
206 START_TEST(test_bitmap_load__4_bit__ok)
207 {
208 load_and_transform_img("test_4bit.bmp", XBLT_NONE, 0, 0);
209 }
210 END_TEST
211
212 START_TEST(test_bitmap_load__8_bit__ok)
213 {
214 load_and_transform_img("test_8bit.bmp", XBLT_NONE, 0, 0);
215 }
216 END_TEST
217
218 START_TEST(test_bitmap_load__24_bit__ok)
219 {
220 load_and_transform_img("test_24bit.bmp", XBLT_NONE, 0, 0);
221 }
222 END_TEST
223
224 START_TEST(test_bitmap_load__max_width_zoom__ok)
225 {
226 load_and_transform_img("test_24bit.bmp",
227 XBLT_ZOOM, MAX_VDESKTOP_WIDTH, MIN_VDESKTOP_HEIGHT);
228 }
229 END_TEST
230
231 START_TEST(test_bitmap_load__max_height_zoom__ok)
232 {
233 load_and_transform_img("test_24bit.bmp",
234 XBLT_ZOOM, MIN_VDESKTOP_WIDTH, MAX_VDESKTOP_HEIGHT);
235 }
236 END_TEST
237
238 START_TEST(test_bitmap_load__min_zoom__ok)
239 {
240 load_and_transform_img("test_24bit.bmp",
241 XBLT_ZOOM, MIN_VDESKTOP_WIDTH, MIN_VDESKTOP_HEIGHT);
242 }
243 END_TEST
244
245 START_TEST(test_bitmap_load__max_width_scale__ok)
246 {
247 load_and_transform_img("test_24bit.bmp",
248 XBLT_SCALE, MAX_VDESKTOP_WIDTH, MIN_VDESKTOP_HEIGHT);
249 }
250 END_TEST
251
252 START_TEST(test_bitmap_load__max_height_scale__ok)
253 {
254 load_and_transform_img("test_24bit.bmp",
255 XBLT_SCALE, MIN_VDESKTOP_WIDTH, MAX_VDESKTOP_HEIGHT);
256 }
257 END_TEST
258
259 START_TEST(test_bitmap_load__min_scale__ok)
260 {
261 load_and_transform_img("test_24bit.bmp",
262 XBLT_SCALE, MIN_VDESKTOP_WIDTH, MIN_VDESKTOP_HEIGHT);
263 }
264 END_TEST
265
266 START_TEST(test_bitmap_load__not_4_pixels_wide_4_bit__ok)
267 {
268 load_not4_img("test_not4_4bit.bmp");
269 }
270 END_TEST
271
272 START_TEST(test_bitmap_load__not_4_pixels_wide_8_bit__ok)
273 {
274 load_not4_img("test_not4_8bit.bmp");
275 }
276 END_TEST
277
278 START_TEST(test_bitmap_load__not_4_pixels_wide_24_bit__ok)
279 {
280 load_not4_img("test_not4_24bit.bmp");
281 }
282 END_TEST
283
284 #ifdef USE_IMLIB2
285 START_TEST(test_png_load__blend_ok)
286 {
287 load_and_transform_img("test_alpha_blend.png", XBLT_NONE, 0, 0);
288 }
289 END_TEST
290
291 START_TEST(test_jpg_load__ok)
292 {
293 load_and_transform_img("test1.jpg", XBLT_NONE, 0, 0);
294 }
295 END_TEST
296 #endif
297
298 /******************************************************************************/
299 Suite *
300 make_suite_test_bitmap_load(void)
301 {
302 Suite *s;
303 TCase *tc_bitmap_load;
304 #ifdef USE_IMLIB2
305 TCase *tc_other_load;
306 #endif
307
308 s = suite_create("BitmapLoad");
309
310 tc_bitmap_load = tcase_create("xrdp_bitmap_load");
311 tcase_add_checked_fixture(tc_bitmap_load, setup, teardown);
312 tcase_add_test(tc_bitmap_load, test_bitmap_load__with_invalid_image__fail);
313 tcase_add_test(tc_bitmap_load, test_bitmap_load__4_bit__ok);
314 tcase_add_test(tc_bitmap_load, test_bitmap_load__8_bit__ok);
315 tcase_add_test(tc_bitmap_load, test_bitmap_load__24_bit__ok);
316 tcase_add_test(tc_bitmap_load, test_bitmap_load__max_width_zoom__ok);
317 tcase_add_test(tc_bitmap_load, test_bitmap_load__max_height_zoom__ok);
318 tcase_add_test(tc_bitmap_load, test_bitmap_load__min_zoom__ok);
319 tcase_add_test(tc_bitmap_load, test_bitmap_load__max_width_scale__ok);
320 tcase_add_test(tc_bitmap_load, test_bitmap_load__max_height_scale__ok);
321 tcase_add_test(tc_bitmap_load, test_bitmap_load__min_scale__ok);
322 tcase_add_test(tc_bitmap_load, test_bitmap_load__not_4_pixels_wide_4_bit__ok);
323 tcase_add_test(tc_bitmap_load, test_bitmap_load__not_4_pixels_wide_8_bit__ok);
324 tcase_add_test(tc_bitmap_load, test_bitmap_load__not_4_pixels_wide_24_bit__ok);
325
326 suite_add_tcase(s, tc_bitmap_load);
327
328 #ifdef USE_IMLIB2
329 tc_other_load = tcase_create("xrdp_other_load");
330 tcase_add_checked_fixture(tc_other_load, setup, teardown);
331 tcase_add_test(tc_other_load, test_png_load__blend_ok);
332 tcase_add_test(tc_other_load, test_jpg_load__ok);
333 suite_add_tcase(s, tc_other_load);
334 #endif
335
336 return s;
337 }
0 #ifndef TEST_XRDP_H
1 #define TEST_XRDP_H
2
3 #include <check.h>
4
5 Suite *make_suite_test_bitmap_load(void);
6
7 #endif /* TEST_XRDP_H */
0 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * Copyright (C) Jay Sorg 2004-2021
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * Test driver for XRDP routines
18 *
19 * If you want to run this driver under valgrind to check for memory leaks,
20 * use the following command line:-
21 *
22 * CK_FORK=no valgrind --leak-check=full --show-leak-kinds=all \
23 * .libs/test_xrdp
24 *
25 * without the 'CK_FORK=no', memory still allocated by the test driver will
26 * be logged
27 */
28
29 #if defined(HAVE_CONFIG_H)
30 #include "config_ac.h"
31 #endif
32
33 #include "log.h"
34 #include "os_calls.h"
35 #include <stdlib.h>
36
37 #include "test_xrdp.h"
38
39 int main (void)
40 {
41 int number_failed;
42 SRunner *sr;
43 struct log_config *logging;
44
45 /* Configure the logging sub-system so that functions can use
46 * the log functions as appropriate */
47 logging = log_config_init_for_console(LOG_LEVEL_INFO,
48 g_getenv("TEST_LOG_LEVEL"));
49 log_start_from_param(logging);
50 log_config_free(logging);
51
52 sr = srunner_create (make_suite_test_bitmap_load());
53
54 srunner_set_tap(sr, "-");
55 srunner_run_all (sr, CK_ENV);
56 number_failed = srunner_ntests_failed(sr);
57 srunner_free(sr);
58
59 log_end();
60
61 return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
62 }
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
158158 unique=`for i in $$list; do \
159159 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
160160 done | $(am__uniquify_input)`
161 ETAGS = etags
162 CTAGS = ctags
163161 DIST_SUBDIRS = $(SUBDIRS)
164162 am__DIST_COMMON = $(srcdir)/Makefile.in
165163 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
203201 CHECK_LIBS = @CHECK_LIBS@
204202 CPP = @CPP@
205203 CPPFLAGS = @CPPFLAGS@
204 CSCOPE = @CSCOPE@
205 CTAGS = @CTAGS@
206206 CYGPATH_W = @CYGPATH_W@
207207 DEFS = @DEFS@
208208 DEPDIR = @DEPDIR@
214214 ECHO_N = @ECHO_N@
215215 ECHO_T = @ECHO_T@
216216 EGREP = @EGREP@
217 ETAGS = @ETAGS@
217218 EXEEXT = @EXEEXT@
218219 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
219220 FDKAAC_LIBS = @FDKAAC_LIBS@
223224 FUSE_CFLAGS = @FUSE_CFLAGS@
224225 FUSE_LIBS = @FUSE_LIBS@
225226 GREP = @GREP@
227 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
228 IMLIB2_LIBS = @IMLIB2_LIBS@
226229 INSTALL = @INSTALL@
227230 INSTALL_DATA = @INSTALL_DATA@
228231 INSTALL_PROGRAM = @INSTALL_PROGRAM@
473476
474477 distclean-tags:
475478 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
476
477479 distdir: $(BUILT_SOURCES)
478480 $(MAKE) $(AM_MAKEFLAGS) distdir-am
479481
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
158158 unique=`for i in $$list; do \
159159 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
160160 done | $(am__uniquify_input)`
161 ETAGS = etags
162 CTAGS = ctags
163161 DIST_SUBDIRS = $(SUBDIRS)
164162 am__DIST_COMMON = $(srcdir)/Makefile.in
165163 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
203201 CHECK_LIBS = @CHECK_LIBS@
204202 CPP = @CPP@
205203 CPPFLAGS = @CPPFLAGS@
204 CSCOPE = @CSCOPE@
205 CTAGS = @CTAGS@
206206 CYGPATH_W = @CYGPATH_W@
207207 DEFS = @DEFS@
208208 DEPDIR = @DEPDIR@
214214 ECHO_N = @ECHO_N@
215215 ECHO_T = @ECHO_T@
216216 EGREP = @EGREP@
217 ETAGS = @ETAGS@
217218 EXEEXT = @EXEEXT@
218219 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
219220 FDKAAC_LIBS = @FDKAAC_LIBS@
223224 FUSE_CFLAGS = @FUSE_CFLAGS@
224225 FUSE_LIBS = @FUSE_LIBS@
225226 GREP = @GREP@
227 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
228 IMLIB2_LIBS = @IMLIB2_LIBS@
226229 INSTALL = @INSTALL@
227230 INSTALL_DATA = @INSTALL_DATA@
228231 INSTALL_PROGRAM = @INSTALL_PROGRAM@
476479
477480 distclean-tags:
478481 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
479
480482 distdir: $(BUILT_SOURCES)
481483 $(MAKE) $(AM_MAKEFLAGS) distdir-am
482484
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
175175 unique=`for i in $$list; do \
176176 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
177177 done | $(am__uniquify_input)`
178 ETAGS = etags
179 CTAGS = ctags
180178 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
181179 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
182180 ACLOCAL = @ACLOCAL@
194192 CHECK_LIBS = @CHECK_LIBS@
195193 CPP = @CPP@
196194 CPPFLAGS = @CPPFLAGS@
195 CSCOPE = @CSCOPE@
196 CTAGS = @CTAGS@
197197 CYGPATH_W = @CYGPATH_W@
198198 DEFS = @DEFS@
199199 DEPDIR = @DEPDIR@
205205 ECHO_N = @ECHO_N@
206206 ECHO_T = @ECHO_T@
207207 EGREP = @EGREP@
208 ETAGS = @ETAGS@
208209 EXEEXT = @EXEEXT@
209210 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
210211 FDKAAC_LIBS = @FDKAAC_LIBS@
214215 FUSE_CFLAGS = @FUSE_CFLAGS@
215216 FUSE_LIBS = @FUSE_LIBS@
216217 GREP = @GREP@
218 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
219 IMLIB2_LIBS = @IMLIB2_LIBS@
217220 INSTALL = @INSTALL@
218221 INSTALL_DATA = @INSTALL_DATA@
219222 INSTALL_PROGRAM = @INSTALL_PROGRAM@
473476
474477 distclean-tags:
475478 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
476
477479 distdir: $(BUILT_SOURCES)
478480 $(MAKE) $(AM_MAKEFLAGS) distdir-am
479481
1010 libvnc_la_SOURCES = \
1111 vnc.c \
1212 vnc_clip.c \
13 rfb.h \
13 rfb.c \
1414 vnc.h \
15 vnc_clip.h
15 vnc_clip.h \
16 rfb.h
1617
1718 libvnc_la_LIBADD = \
1819 $(top_builddir)/common/libcommon.la
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
137137 am__installdirs = "$(DESTDIR)$(moduledir)"
138138 LTLIBRARIES = $(module_LTLIBRARIES)
139139 libvnc_la_DEPENDENCIES = $(top_builddir)/common/libcommon.la
140 am_libvnc_la_OBJECTS = vnc.lo vnc_clip.lo
140 am_libvnc_la_OBJECTS = vnc.lo vnc_clip.lo rfb.lo
141141 libvnc_la_OBJECTS = $(am_libvnc_la_OBJECTS)
142142 AM_V_lt = $(am__v_lt_@AM_V@)
143143 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
161161 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
162162 depcomp = $(SHELL) $(top_srcdir)/depcomp
163163 am__maybe_remake_depfiles = depfiles
164 am__depfiles_remade = ./$(DEPDIR)/vnc.Plo ./$(DEPDIR)/vnc_clip.Plo
164 am__depfiles_remade = ./$(DEPDIR)/rfb.Plo ./$(DEPDIR)/vnc.Plo \
165 ./$(DEPDIR)/vnc_clip.Plo
165166 am__mv = mv -f
166167 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
167168 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
205206 unique=`for i in $$list; do \
206207 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
207208 done | $(am__uniquify_input)`
208 ETAGS = etags
209 CTAGS = ctags
210209 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
211210 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
212211 ACLOCAL = @ACLOCAL@
224223 CHECK_LIBS = @CHECK_LIBS@
225224 CPP = @CPP@
226225 CPPFLAGS = @CPPFLAGS@
226 CSCOPE = @CSCOPE@
227 CTAGS = @CTAGS@
227228 CYGPATH_W = @CYGPATH_W@
228229 DEFS = @DEFS@
229230 DEPDIR = @DEPDIR@
235236 ECHO_N = @ECHO_N@
236237 ECHO_T = @ECHO_T@
237238 EGREP = @EGREP@
239 ETAGS = @ETAGS@
238240 EXEEXT = @EXEEXT@
239241 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
240242 FDKAAC_LIBS = @FDKAAC_LIBS@
244246 FUSE_CFLAGS = @FUSE_CFLAGS@
245247 FUSE_LIBS = @FUSE_LIBS@
246248 GREP = @GREP@
249 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
250 IMLIB2_LIBS = @IMLIB2_LIBS@
247251 INSTALL = @INSTALL@
248252 INSTALL_DATA = @INSTALL_DATA@
249253 INSTALL_PROGRAM = @INSTALL_PROGRAM@
367371 libvnc_la_SOURCES = \
368372 vnc.c \
369373 vnc_clip.c \
370 rfb.h \
374 rfb.c \
371375 vnc.h \
372 vnc_clip.h
376 vnc_clip.h \
377 rfb.h
373378
374379 libvnc_la_LIBADD = \
375380 $(top_builddir)/common/libcommon.la
453458 distclean-compile:
454459 -rm -f *.tab.c
455460
461 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rfb.Plo@am__quote@ # am--include-marker
456462 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vnc.Plo@am__quote@ # am--include-marker
457463 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vnc_clip.Plo@am__quote@ # am--include-marker
458464
540546
541547 distclean-tags:
542548 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
543
544549 distdir: $(BUILT_SOURCES)
545550 $(MAKE) $(AM_MAKEFLAGS) distdir-am
546551
617622 mostlyclean-am
618623
619624 distclean: distclean-am
620 -rm -f ./$(DEPDIR)/vnc.Plo
625 -rm -f ./$(DEPDIR)/rfb.Plo
626 -rm -f ./$(DEPDIR)/vnc.Plo
621627 -rm -f ./$(DEPDIR)/vnc_clip.Plo
622628 -rm -f Makefile
623629 distclean-am: clean-am distclean-compile distclean-generic \
664670 installcheck-am:
665671
666672 maintainer-clean: maintainer-clean-am
667 -rm -f ./$(DEPDIR)/vnc.Plo
673 -rm -f ./$(DEPDIR)/rfb.Plo
674 -rm -f ./$(DEPDIR)/vnc.Plo
668675 -rm -f ./$(DEPDIR)/vnc_clip.Plo
669676 -rm -f Makefile
670677 maintainer-clean-am: distclean-am maintainer-clean-generic
0 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * Copyright (C) Jay Sorg 2004-2015
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * libvnc - RFB specific functions
18 */
19
20 #if defined(HAVE_CONFIG_H)
21 #include <config_ac.h>
22 #endif
23
24 #include "rfb.h"
25
26 /* Messages for ExtendedDesktopSize status code */
27 static const char *eds_status_msg[] =
28 {
29 /* 0 */ "No error",
30 /* 1 */ "Resize is administratively prohibited",
31 /* 2 */ "Out of resources",
32 /* 3 */ "Invalid screen layout",
33 /* others */ "Unknown code"
34 };
35
36 /* elements in above list */
37 #define EDS_STATUS_MSG_COUNT \
38 (sizeof(eds_status_msg) / sizeof(eds_status_msg[0]))
39
40 /**************************************************************************//**
41 * Returns an error string for an ExtendedDesktopSize status code
42 */
43 const char *
44 rfb_get_eds_status_msg(unsigned int response_code)
45 {
46 if (response_code >= EDS_STATUS_MSG_COUNT)
47 {
48 response_code = EDS_STATUS_MSG_COUNT - 1;
49 }
50
51 return eds_status_msg[response_code];
52 }
9393 /* create password hash from password */
9494 passwd_bytes = g_strlen(passwd);
9595 sha1 = ssl_sha1_info_create();
96 ssl_sha1_clear(sha1);
9697 ssl_sha1_transform(sha1, "xrdp_vnc", 8);
9798 ssl_sha1_transform(sha1, passwd, passwd_bytes);
9899 ssl_sha1_transform(sha1, passwd, passwd_bytes);
10051006 }
10061007 }
10071008
1009 free_stream(s);
1010
10081011 return error;
10091012 }
10101013
12071210 {
12081211 int error;
12091212 struct vnc_screen_layout layout = {0};
1210 int response_code;
1213 int response_code = 0;
12111214
12121215 error = find_matching_extended_rect(v,
12131216 rect_is_reply_to_us,
17141717 if (error == 0)
17151718 {
17161719 init_stream(s, 8192);
1717 if (v->got_guid)
1720 if (guid_is_set(&v->guid))
17181721 {
1719 char guid_str[64];
1720 g_bytes_to_hexstr(v->guid, 16, guid_str, 64);
1722 char guid_str[GUID_STR_SIZE];
1723 guid_to_str(&v->guid, guid_str);
17211724 rfbHashEncryptBytes(s->data, guid_str);
17221725 }
17231726 else
20882091 }
20892092 else if (g_strcasecmp(name, "guid") == 0)
20902093 {
2091 v->got_guid = 1;
2092 g_memcpy(v->guid, value, 16);
2094 v->guid = *(struct guid *)value;
20932095 }
20942096 else if (g_strcasecmp(name, "disabled_encodings_mask") == 0)
20952097 {
2525 #include "parse.h"
2626 #include "os_calls.h"
2727 #include "defines.h"
28 #include "guid.h"
2829
2930 #define CURRENT_MOD_VER 4
3031
122123 int box_right, int box_bottom,
123124 int x, int y, char *data, int data_len);
124125 int (*server_reset)(struct vnc *v, int width, int height, int bpp);
126 int (*server_get_channel_count)(struct vnc *v);
125127 int (*server_query_channel)(struct vnc *v, int index,
126128 char *channel_name,
127129 int *channel_flags);
131133 int total_data_len, int flags);
132134 int (*server_bell_trigger)(struct vnc *v);
133135 int (*server_chansrv_in_use)(struct vnc *v);
134 tintptr server_dumby[100 - 26]; /* align, 100 minus the number of server
136 tintptr server_dumby[100 - 27]; /* align, 100 minus the number of server
135137 functions above */
136138 /* common */
137139 tintptr handle; /* pointer to self as long */
157159 struct vnc_clipboard_data *vc;
158160 int delay_ms;
159161 struct trans *trans;
160 int got_guid;
161 tui8 guid[16];
162 struct guid guid;
162163 int suppress_output;
163164 unsigned int enabled_encodings_mask;
164165 /* Resizeable support */
574574 {
575575 case CF_TEXT:
576576 lastc = '\0';
577 while (s_check(s))
577 while (s_check_rem(s, 1))
578578 {
579579 in_uint8(s, c);
580580 if (c == '\n' && lastc == '\r')
11061106 s_mark_end(s);
11071107 send_stream_to_clip_channel(v, s);
11081108
1109 free_stream(s);
11091110 /* Need to complete the startup handshake before we send formats */
11101111 v->vc->startup_complete = 1;
11111112 }
1111 -DXRDP_SOCKET_PATH=\"${socketdir}\" \
1212 -I$(top_builddir) \
1313 -I$(top_srcdir)/common \
14 -I$(top_srcdir)/libxrdp
14 -I$(top_srcdir)/sesman/libscp \
15 -I$(top_srcdir)/libxrdp \
16 $(IMLIB2_CFLAGS)
1517
1618 XRDP_EXTRA_LIBS =
1719
4244 xrdp.c \
4345 xrdp.h \
4446 xrdp_bitmap.c \
47 xrdp_bitmap_load.c \
48 xrdp_bitmap_common.c \
4549 xrdp_cache.c \
4650 xrdp_encoder.c \
4751 xrdp_encoder.h \
5761
5862 xrdp_LDADD = \
5963 $(top_builddir)/common/libcommon.la \
64 $(top_builddir)/sesman/libscp/libscp.la \
6065 $(top_builddir)/libxrdp/libxrdp.la \
66 $(IMLIB2_LIBS) \
6167 $(XRDP_EXTRA_LIBS)
6268
6369 xrdpsysconfdir=$(sysconfdir)/xrdp
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
122122 "$(DESTDIR)$(xrdpsysconfdir)"
123123 PROGRAMS = $(sbin_PROGRAMS)
124124 am_xrdp_OBJECTS = funcs.$(OBJEXT) lang.$(OBJEXT) xrdp.$(OBJEXT) \
125 xrdp_bitmap.$(OBJEXT) xrdp_cache.$(OBJEXT) \
125 xrdp_bitmap.$(OBJEXT) xrdp_bitmap_load.$(OBJEXT) \
126 xrdp_bitmap_common.$(OBJEXT) xrdp_cache.$(OBJEXT) \
126127 xrdp_encoder.$(OBJEXT) xrdp_font.$(OBJEXT) \
127128 xrdp_listen.$(OBJEXT) xrdp_login_wnd.$(OBJEXT) \
128129 xrdp_mm.$(OBJEXT) xrdp_painter.$(OBJEXT) \
133134 am__DEPENDENCIES_3 = $(am__append_2) $(am__DEPENDENCIES_2) \
134135 $(am__append_6)
135136 xrdp_DEPENDENCIES = $(top_builddir)/common/libcommon.la \
136 $(top_builddir)/libxrdp/libxrdp.la $(am__DEPENDENCIES_3)
137 $(top_builddir)/sesman/libscp/libscp.la \
138 $(top_builddir)/libxrdp/libxrdp.la $(am__DEPENDENCIES_1) \
139 $(am__DEPENDENCIES_3)
137140 AM_V_lt = $(am__v_lt_@AM_V@)
138141 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
139142 am__v_lt_0 = --silent
155158 am__maybe_remake_depfiles = depfiles
156159 am__depfiles_remade = ./$(DEPDIR)/funcs.Po ./$(DEPDIR)/lang.Po \
157160 ./$(DEPDIR)/xrdp.Po ./$(DEPDIR)/xrdp_bitmap.Po \
158 ./$(DEPDIR)/xrdp_cache.Po ./$(DEPDIR)/xrdp_encoder.Po \
159 ./$(DEPDIR)/xrdp_font.Po ./$(DEPDIR)/xrdp_listen.Po \
160 ./$(DEPDIR)/xrdp_login_wnd.Po ./$(DEPDIR)/xrdp_mm.Po \
161 ./$(DEPDIR)/xrdp_painter.Po ./$(DEPDIR)/xrdp_process.Po \
162 ./$(DEPDIR)/xrdp_region.Po ./$(DEPDIR)/xrdp_wm.Po
161 ./$(DEPDIR)/xrdp_bitmap_common.Po \
162 ./$(DEPDIR)/xrdp_bitmap_load.Po ./$(DEPDIR)/xrdp_cache.Po \
163 ./$(DEPDIR)/xrdp_encoder.Po ./$(DEPDIR)/xrdp_font.Po \
164 ./$(DEPDIR)/xrdp_listen.Po ./$(DEPDIR)/xrdp_login_wnd.Po \
165 ./$(DEPDIR)/xrdp_mm.Po ./$(DEPDIR)/xrdp_painter.Po \
166 ./$(DEPDIR)/xrdp_process.Po ./$(DEPDIR)/xrdp_region.Po \
167 ./$(DEPDIR)/xrdp_wm.Po
163168 am__mv = mv -f
164169 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
165170 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
231236 unique=`for i in $$list; do \
232237 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
233238 done | $(am__uniquify_input)`
234 ETAGS = etags
235 CTAGS = ctags
236239 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
237240 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
238241 ACLOCAL = @ACLOCAL@
250253 CHECK_LIBS = @CHECK_LIBS@
251254 CPP = @CPP@
252255 CPPFLAGS = @CPPFLAGS@
256 CSCOPE = @CSCOPE@
257 CTAGS = @CTAGS@
253258 CYGPATH_W = @CYGPATH_W@
254259 DEFS = @DEFS@
255260 DEPDIR = @DEPDIR@
261266 ECHO_N = @ECHO_N@
262267 ECHO_T = @ECHO_T@
263268 EGREP = @EGREP@
269 ETAGS = @ETAGS@
264270 EXEEXT = @EXEEXT@
265271 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
266272 FDKAAC_LIBS = @FDKAAC_LIBS@
270276 FUSE_CFLAGS = @FUSE_CFLAGS@
271277 FUSE_LIBS = @FUSE_LIBS@
272278 GREP = @GREP@
279 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
280 IMLIB2_LIBS = @IMLIB2_LIBS@
273281 INSTALL = @INSTALL@
274282 INSTALL_DATA = @INSTALL_DATA@
275283 INSTALL_PROGRAM = @INSTALL_PROGRAM@
391399 -DXRDP_PID_PATH=\"${localstatedir}/run\" \
392400 -DXRDP_MODULE_PATH=\"${moduledir}\" \
393401 -DXRDP_SOCKET_PATH=\"${socketdir}\" -I$(top_builddir) \
394 -I$(top_srcdir)/common -I$(top_srcdir)/libxrdp $(am__append_1) \
402 -I$(top_srcdir)/common -I$(top_srcdir)/sesman/libscp \
403 -I$(top_srcdir)/libxrdp $(IMLIB2_CFLAGS) $(am__append_1) \
395404 $(am__append_3) $(am__append_5)
396405 XRDP_EXTRA_LIBS = $(am__append_2) $(am__append_4) $(am__append_6)
397406 xrdp_SOURCES = \
400409 xrdp.c \
401410 xrdp.h \
402411 xrdp_bitmap.c \
412 xrdp_bitmap_load.c \
413 xrdp_bitmap_common.c \
403414 xrdp_cache.c \
404415 xrdp_encoder.c \
405416 xrdp_encoder.h \
415426
416427 xrdp_LDADD = \
417428 $(top_builddir)/common/libcommon.la \
429 $(top_builddir)/sesman/libscp/libscp.la \
418430 $(top_builddir)/libxrdp/libxrdp.la \
431 $(IMLIB2_LIBS) \
419432 $(XRDP_EXTRA_LIBS)
420433
421434 xrdpsysconfdir = $(sysconfdir)/xrdp
540553 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lang.Po@am__quote@ # am--include-marker
541554 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xrdp.Po@am__quote@ # am--include-marker
542555 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xrdp_bitmap.Po@am__quote@ # am--include-marker
556 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xrdp_bitmap_common.Po@am__quote@ # am--include-marker
557 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xrdp_bitmap_load.Po@am__quote@ # am--include-marker
543558 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xrdp_cache.Po@am__quote@ # am--include-marker
544559 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xrdp_encoder.Po@am__quote@ # am--include-marker
545560 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xrdp_font.Po@am__quote@ # am--include-marker
677692
678693 distclean-tags:
679694 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
680
681695 distdir: $(BUILT_SOURCES)
682696 $(MAKE) $(AM_MAKEFLAGS) distdir-am
683697
758772 -rm -f ./$(DEPDIR)/lang.Po
759773 -rm -f ./$(DEPDIR)/xrdp.Po
760774 -rm -f ./$(DEPDIR)/xrdp_bitmap.Po
775 -rm -f ./$(DEPDIR)/xrdp_bitmap_common.Po
776 -rm -f ./$(DEPDIR)/xrdp_bitmap_load.Po
761777 -rm -f ./$(DEPDIR)/xrdp_cache.Po
762778 -rm -f ./$(DEPDIR)/xrdp_encoder.Po
763779 -rm -f ./$(DEPDIR)/xrdp_font.Po
818834 -rm -f ./$(DEPDIR)/lang.Po
819835 -rm -f ./$(DEPDIR)/xrdp.Po
820836 -rm -f ./$(DEPDIR)/xrdp_bitmap.Po
837 -rm -f ./$(DEPDIR)/xrdp_bitmap_common.Po
838 -rm -f ./$(DEPDIR)/xrdp_bitmap_load.Po
821839 -rm -f ./$(DEPDIR)/xrdp_cache.Po
822840 -rm -f ./$(DEPDIR)/xrdp_encoder.Po
823841 -rm -f ./$(DEPDIR)/xrdp_font.Po
162162 static void
163163 xrdp_child(int sig)
164164 {
165 int safety;
166
167 for (safety = 0; (g_waitchild() >= 0) && (safety <= 10); safety++)
165 while (g_waitchild() > 0)
168166 {
169167 }
170168 }
539537
540538 /* starting logging subsystem */
541539 error = log_start(startup_params.xrdp_ini, "xrdp",
542 startup_params.dump_config);
540 (startup_params.dump_config) ? LOG_START_DUMP_CONFIG : 0);
543541
544542 if (error != LOG_STARTUP_OK)
545543 {
569567
570568 if (g_file_exist(pid_file)) /* xrdp.pid */
571569 {
572 g_writeln("It looks like xrdp is already running.");
573 g_writeln("If not, delete %s and try again.", pid_file);
570 LOG(LOG_LEVEL_ALWAYS, "It looks like xrdp is already running.");
571 LOG(LOG_LEVEL_ALWAYS, "If not, delete %s and try again.", pid_file);
572 log_end();
574573 g_deinit();
575 g_exit(0);
574 g_exit(1);
576575 }
577576
578577 daemon = !startup_params.no_daemon;
589588
590589 if (fd == -1)
591590 {
592 g_writeln("running in daemon mode with no access to pid files, quitting");
591 LOG(LOG_LEVEL_ALWAYS,
592 "running in daemon mode with no access to pid files, quitting");
593 log_end();
593594 g_deinit();
594 g_exit(0);
595 g_exit(1);
595596 }
596597
597598 if (g_file_write(fd, "0", 1) == -1)
598599 {
599 g_writeln("running in daemon mode with no access to pid files, quitting");
600 LOG(LOG_LEVEL_ALWAYS,
601 "running in daemon mode with no access to pid files, quitting");
602 log_end();
600603 g_deinit();
601 g_exit(0);
604 g_exit(1);
602605 }
603606
604607 g_file_close(fd);
610613 /* if can't listen, exit with failure status */
611614 if (xrdp_listen_test(&startup_params) != 0)
612615 {
613 LOG(LOG_LEVEL_ERROR, "Failed to start xrdp daemon, "
616 LOG(LOG_LEVEL_ALWAYS, "Failed to start xrdp daemon, "
614617 "possibly address already in use.");
618 log_end();
615619 g_deinit();
616620 /* must exit with failure status,
617621 or systemd cannot detect xrdp daemon couldn't start properly */
622626
623627 if (pid == -1)
624628 {
625 g_writeln("problem forking");
629 LOG(LOG_LEVEL_ALWAYS, "problem forking [%s]", g_get_strerror());
630 log_end();
626631 g_deinit();
627632 g_exit(1);
628633 }
629634
630635 if (0 != pid)
631636 {
632 g_writeln("daemon process %d started ok", pid);
633637 /* exit, this is the main process */
638 log_end();
634639 g_deinit();
635640 g_exit(0);
636641 }
642647
643648 if (fd == -1)
644649 {
645 g_writeln("trying to write process id to xrdp.pid");
646 g_writeln("problem opening xrdp.pid");
647 g_writeln("maybe no rights");
650 LOG(LOG_LEVEL_WARNING, "Can't open %s for writing [%s]",
651 pid_file, g_get_strerror());
648652 }
649653 else
650654 {
135135 callback(intptr_t id, int msg, intptr_t param1, intptr_t param2,
136136 intptr_t param3, intptr_t param4);
137137 int
138 xrdp_wm_drdynvc_up(intptr_t id);
139 int
140138 xrdp_wm_delete_all_children(struct xrdp_wm *self);
141139 int
142140 xrdp_wm_show_log(struct xrdp_wm *self);
150148 xrdp_wm_check_wait_objs(struct xrdp_wm *self);
151149 int
152150 xrdp_wm_set_login_state(struct xrdp_wm *self, enum wm_login_state login_state);
151 void
152 xrdp_wm_mod_connect_done(struct xrdp_wm *self, int status);
153153
154154 /* xrdp_process.c */
155155 struct xrdp_process *
184184 xrdp_region_get_rect(struct xrdp_region *self, int index,
185185 struct xrdp_rect *rect);
186186
187 /* xrdp_bitmap.c */
187 /* xrdp_bitmap_common.c */
188188 struct xrdp_bitmap *
189189 xrdp_bitmap_create(int width, int height, int bpp,
190190 int type, struct xrdp_wm *wm);
194194 struct xrdp_wm *wm);
195195 void
196196 xrdp_bitmap_delete(struct xrdp_bitmap *self);
197 struct xrdp_bitmap *
198 xrdp_bitmap_get_child_by_id(struct xrdp_bitmap *self, int id);
199 int
200 xrdp_bitmap_set_focus(struct xrdp_bitmap *self, int focused);
201197 int
202198 xrdp_bitmap_resize(struct xrdp_bitmap *self, int width, int height);
203 int
204 xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette);
205199 int
206200 xrdp_bitmap_get_pixel(struct xrdp_bitmap *self, int x, int y);
207201 int
210204 xrdp_bitmap_copy_box(struct xrdp_bitmap *self,
211205 struct xrdp_bitmap *dest,
212206 int x, int y, int cx, int cy);
207
208 /* xrdp_bitmap.c */
209 struct xrdp_bitmap *
210 xrdp_bitmap_get_child_by_id(struct xrdp_bitmap *self, int id);
211 int
212 xrdp_bitmap_set_focus(struct xrdp_bitmap *self, int focused);
213213 int
214214 xrdp_bitmap_hash_crc(struct xrdp_bitmap *self);
215215 int
238238 struct xrdp_rect *rect,
239239 int *dx, int *dy);
240240
241 /* xrdp_bitmap_load.c */
242 /**
243 * Loads a bitmap from a file and (optionally) transforms it
244 *
245 * @param self from rdp_bitmap_create()
246 * @param filename Filename to load
247 * @param[in] palette For 8-bit conversions. Currently unused
248 * @param background Background color for alpha-blending
249 * @param transform Transform to apply to the image after loading
250 * @param twidth target width if transform != XBLT_NONE
251 * @param theight target height if transform != XBLT_NONE
252 * @return 0 for success.
253 *
254 * The background color is only used if the specified image contains
255 * an alpha layer. It is in HCOLOR format, and the bpp must correspond to
256 * the bpp used to create 'self'.
257 *
258 * After a successful call, the bitmap is resized to the image file size.
259 *
260 * If the call is not successful, the bitmap will be in an indeterminate
261 * state and should not be used.
262 */
263 int
264 xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename,
265 const int *palette,
266 int background,
267 enum xrdp_bitmap_load_transform transform,
268 int twidth,
269 int theight);
241270 /* xrdp_painter.c */
242271 struct xrdp_painter *
243272 xrdp_painter_create(struct xrdp_wm *wm, struct xrdp_session *session);
390419 xrdp_mm_create(struct xrdp_wm *owner);
391420 void
392421 xrdp_mm_delete(struct xrdp_mm *self);
393 int
422 void
394423 xrdp_mm_connect(struct xrdp_mm *self);
395424 int
396425 xrdp_mm_process_channel_data(struct xrdp_mm *self, tbus param1, tbus param2,
445474 int
446475 server_palette(struct xrdp_mod *mod, int *palette);
447476 int
448 server_msg(struct xrdp_mod *mod, char *msg, int code);
477 server_msg(struct xrdp_mod *mod, const char *msg, int code);
449478 int
450479 server_is_term(struct xrdp_mod *mod);
451480 int
483512 int
484513 is_channel_allowed(struct xrdp_wm *wm, int channel_id);
485514 int
515 server_get_channel_count(struct xrdp_mod *mod);
516 int
486517 server_query_channel(struct xrdp_mod *mod, int index, char *channel_name,
487518 int *channel_flags);
488519 int
128128 ; login screen background color in RGB format
129129 ls_bg_color=dedede
130130
131 ; optional background image filename (bmp format).
131 ; optional background image filename. BMP format is always supported,
132 ; but other formats will be supported if xrdp is build with imlib2
133 ; The transform can be one of the following:-
134 ; none : No transformation. Image is placed in bottom-right corner
135 ; of the screen.
136 ; scale : Image is scaled to the screen size. The image aspect
137 ; ratio is not preserved.
138 ; zoom : Image is scaled to the screen size. The image aspect
139 ; ratio is preserved by clipping the image.
132140 #ls_background_image=
141 #ls_background_transform=none
133142
134143 ; logo
135 ; full path to bmp-file or file in shared folder
144 ; full path to file or file in shared folder. BMP format is always supported,
145 ; but other formats will be supported if xrdp is build with imlib2
146 ; For transform values, see 'ls_background_transform'. The logo width and
147 ; logo height are ignored for a transform of 'none'.
136148 ls_logo_filename=
149 #ls_logo_transform=none
150 #ls_logo_width=240
151 #ls_logo_height=140
137152 ls_logo_x_pos=55
138153 ls_logo_y_pos=50
139154
2323 #if defined(HAVE_CONFIG_H)
2424 #include <config_ac.h>
2525 #endif
26
27 #include <limits.h>
2826
2927 #include "xrdp.h"
3028 #include "log.h"
8684 #define CRC_END(in_crc) (in_crc) = ((in_crc) ^ 0xFFFFFFFF)
8785
8886 /*****************************************************************************/
89 /* Allocate bitmap for specified dimensions, checking for int overflow */
90 static char *
91 alloc_bitmap_data(int width, int height, int Bpp)
92 {
93 char *result = NULL;
94 if (width > 0 && height > 0 && Bpp > 0)
95 {
96 int len = width;
97 /* g_malloc() currently takes an 'int' size */
98 if (len < INT_MAX / height)
99 {
100 len *= height;
101 if (len < INT_MAX / Bpp)
102 {
103 len *= Bpp;
104 result = (char *)malloc(len);
105 }
106 }
107 }
108
109 return result;
110 }
111
112 /*****************************************************************************/
113 struct xrdp_bitmap *
114 xrdp_bitmap_create(int width, int height, int bpp,
115 int type, struct xrdp_wm *wm)
116 {
117 struct xrdp_bitmap *self = (struct xrdp_bitmap *)NULL;
118 int Bpp = 0;
119
120 self = (struct xrdp_bitmap *)g_malloc(sizeof(struct xrdp_bitmap), 1);
121 self->type = type;
122 self->width = width;
123 self->height = height;
124 self->bpp = bpp;
125 Bpp = 4;
126
127 switch (bpp)
128 {
129 case 8:
130 Bpp = 1;
131 break;
132 case 15:
133 Bpp = 2;
134 break;
135 case 16:
136 Bpp = 2;
137 break;
138 }
139
140 if (self->type == WND_TYPE_BITMAP || self->type == WND_TYPE_IMAGE)
141 {
142 self->data = alloc_bitmap_data(width, height, Bpp);
143 if (self->data == NULL)
144 {
145 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_create: size overflow %dx%dx%d",
146 width, height, Bpp);
147 g_free(self);
148 return NULL;
149 }
150 }
151
152 #if defined(XRDP_PAINTER)
153 if (self->type == WND_TYPE_SCREEN) /* noorders */
154 {
155 LOG_DEVEL(LOG_LEVEL_INFO, "xrdp_bitmap_create: noorders");
156 self->data = alloc_bitmap_data(width, height, Bpp);
157 if (self->data == NULL)
158 {
159 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_create: size overflow %dx%dx%d",
160 width, height, Bpp);
161 g_free(self);
162 return NULL;
163 }
164 }
165 #endif
166
167 if (self->type != WND_TYPE_BITMAP)
168 {
169 self->child_list = list_create();
170 }
171
172 self->line_size = width * Bpp;
173
174 if (self->type == WND_TYPE_COMBO)
175 {
176 self->string_list = list_create();
177 self->string_list->auto_free = 1;
178 self->data_list = list_create();
179 self->data_list->auto_free = 1;
180 }
181
182 self->wm = wm;
183 return self;
184 }
185
186 /*****************************************************************************/
187 struct xrdp_bitmap *
188 xrdp_bitmap_create_with_data(int width, int height,
189 int bpp, char *data,
190 struct xrdp_wm *wm)
191 {
192 struct xrdp_bitmap *self = (struct xrdp_bitmap *)NULL;
193 int Bpp;
194 #if defined(NEED_ALIGN)
195 tintptr data_as_int;
196 #endif
197
198 self = (struct xrdp_bitmap *)g_malloc(sizeof(struct xrdp_bitmap), 1);
199 self->type = WND_TYPE_BITMAP;
200 self->width = width;
201 self->height = height;
202 self->bpp = bpp;
203 self->wm = wm;
204
205 Bpp = 4;
206 switch (bpp)
207 {
208 case 8:
209 Bpp = 1;
210 break;
211 case 15:
212 Bpp = 2;
213 break;
214 case 16:
215 Bpp = 2;
216 break;
217 }
218 self->line_size = width * Bpp;
219
220 #if defined(NEED_ALIGN)
221 data_as_int = (tintptr) data;
222 if (((bpp >= 24) && (data_as_int & 3)) ||
223 (((bpp == 15) || (bpp == 16)) && (data_as_int & 1)))
224 {
225 /* got to copy data here, it's not aligned
226 other calls in this file assume alignment */
227 self->data = (char *)g_malloc(width * height * Bpp, 0);
228 g_memcpy(self->data, data, width * height * Bpp);
229 return self;
230 }
231 #endif
232 self->data = data;
233 self->do_not_free_data = 1;
234 return self;
235 }
236
237 /*****************************************************************************/
238 void
239 xrdp_bitmap_delete(struct xrdp_bitmap *self)
240 {
241 int i = 0;
242 struct xrdp_mod_data *mod_data = (struct xrdp_mod_data *)NULL;
243
244 if (self == 0)
245 {
246 return;
247 }
248
249 if (self->wm != 0)
250 {
251 if (self->wm->focused_window != 0)
252 {
253 if (self->wm->focused_window->focused_control == self)
254 {
255 self->wm->focused_window->focused_control = 0;
256 }
257 }
258
259 if (self->wm->focused_window == self)
260 {
261 self->wm->focused_window = 0;
262 }
263
264 if (self->wm->dragging_window == self)
265 {
266 self->wm->dragging_window = 0;
267 }
268
269 if (self->wm->button_down == self)
270 {
271 self->wm->button_down = 0;
272 }
273
274 if (self->wm->popup_wnd == self)
275 {
276 self->wm->popup_wnd = 0;
277 }
278
279 if (self->wm->login_window == self)
280 {
281 self->wm->login_window = 0;
282 }
283
284 if (self->wm->log_wnd == self)
285 {
286 self->wm->log_wnd = 0;
287 }
288 }
289
290 if (self->child_list != 0)
291 {
292 for (i = self->child_list->count - 1; i >= 0; i--)
293 {
294 xrdp_bitmap_delete((struct xrdp_bitmap *)self->child_list->items[i]);
295 }
296
297 list_delete(self->child_list);
298 }
299
300 if (self->parent != 0)
301 {
302 i = list_index_of(self->parent->child_list, (long)self);
303
304 if (i >= 0)
305 {
306 list_remove_item(self->parent->child_list, i);
307 }
308 }
309
310 if (self->string_list != 0) /* for combo */
311 {
312 list_delete(self->string_list);
313 }
314
315 if (self->data_list != 0) /* for combo */
316 {
317 for (i = 0; i < self->data_list->count; i++)
318 {
319 mod_data = (struct xrdp_mod_data *)list_get_item(self->data_list, i);
320
321 if (mod_data != 0)
322 {
323 list_delete(mod_data->names);
324 list_delete(mod_data->values);
325 }
326 }
327
328 list_delete(self->data_list);
329 }
330
331 if (!self->do_not_free_data)
332 {
333 g_free(self->data);
334 }
335
336 g_free(self->caption1);
337 g_free(self);
338 }
339
340 /*****************************************************************************/
34187 struct xrdp_bitmap *
34288 xrdp_bitmap_get_child_by_id(struct xrdp_bitmap *self, int id)
34389 {
397143 xrdp_painter_draw_text(painter, self, 4, 4, self->caption1);
398144 xrdp_painter_end_update(painter);
399145 xrdp_painter_delete(painter);
400 return 0;
401 }
402
403 /*****************************************************************************/
404 static int
405 xrdp_bitmap_get_index(struct xrdp_bitmap *self, int *palette, int color)
406 {
407 int r = 0;
408 int g = 0;
409 int b = 0;
410
411 r = (color & 0xff0000) >> 16;
412 g = (color & 0x00ff00) >> 8;
413 b = (color & 0x0000ff) >> 0;
414 r = (r >> 5) << 0;
415 g = (g >> 5) << 3;
416 b = (b >> 6) << 6;
417 return (b | g | r);
418 }
419
420 /*****************************************************************************/
421 /* returns error */
422 int
423 xrdp_bitmap_resize(struct xrdp_bitmap *self, int width, int height)
424 {
425 int Bpp = 0;
426
427 if ((width == self->width) && (height == self->height))
428 {
429 return 0;
430 }
431
432 if (self->do_not_free_data)
433 {
434 return 1;
435 }
436
437 self->width = width;
438 self->height = height;
439 Bpp = 4;
440
441 switch (self->bpp)
442 {
443 case 8:
444 Bpp = 1;
445 break;
446 case 15:
447 Bpp = 2;
448 break;
449 case 16:
450 Bpp = 2;
451 break;
452 }
453
454 g_free(self->data);
455 self->data = (char *)g_malloc(width * height * Bpp, 0);
456 self->line_size = width * Bpp;
457 return 0;
458 }
459
460 /*****************************************************************************/
461 /* load a bmp file */
462 /* return 0 ok */
463 /* return 1 error */
464 int
465 xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename, int *palette)
466 {
467 int fd = 0;
468 int len = 0;
469 int i = 0;
470 int j = 0;
471 int k = 0;
472 int color = 0;
473 int size = 0;
474 int palette1[256];
475 char type1[4];
476 struct xrdp_bmp_header header;
477 struct stream *s = (struct stream *)NULL;
478
479 g_memset(palette1, 0, sizeof(int) * 256);
480 g_memset(type1, 0, sizeof(char) * 4);
481 g_memset(&header, 0, sizeof(struct xrdp_bmp_header));
482
483 if (!g_file_exist(filename))
484 {
485 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: error bitmap file [%s] "
486 "does not exist", filename);
487 return 1;
488 }
489
490 fd = g_file_open(filename);
491
492 if (fd != -1)
493 {
494 /* read file type */
495 if (g_file_read(fd, type1, 2) != 2)
496 {
497 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: error bitmap file [%s] "
498 "read error", filename);
499 g_file_close(fd);
500 return 1;
501 }
502
503 if ((type1[0] != 'B') || (type1[1] != 'M'))
504 {
505 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: error bitmap file [%s] "
506 "not BMP file", filename);
507 g_file_close(fd);
508 return 1;
509 }
510
511 /* read file size */
512 make_stream(s);
513 init_stream(s, 8192);
514 if (g_file_read(fd, s->data, 4) != 4)
515 {
516 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: missing length in file %s",
517 filename);
518 free_stream(s);
519 g_file_close(fd);
520 return 1;
521 }
522 s->end = s->data + 4;
523 in_uint32_le(s, size);
524 /* read bmp header */
525 if (g_file_seek(fd, 14) < 0)
526 {
527 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: seek error in file %s",
528 filename);
529 free_stream(s);
530 g_file_close(fd);
531 return 1;
532 }
533 init_stream(s, 8192);
534 len = g_file_read(fd, s->data, 40); /* size better be 40 */
535 if (len != 40)
536 {
537 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: "
538 "unexpected read length %d in file %s",
539 len, filename);
540 free_stream(s);
541 g_file_close(fd);
542 return 1;
543 }
544 s->end = s->data + len;
545 in_uint32_le(s, header.size);
546 in_uint32_le(s, header.image_width);
547 in_uint32_le(s, header.image_height);
548 in_uint16_le(s, header.planes);
549 in_uint16_le(s, header.bit_count);
550 in_uint32_le(s, header.compression);
551 in_uint32_le(s, header.image_size);
552 in_uint32_le(s, header.x_pels_per_meter);
553 in_uint32_le(s, header.y_pels_per_meter);
554 in_uint32_le(s, header.clr_used);
555 in_uint32_le(s, header.clr_important);
556
557 if ((header.bit_count != 4) && (header.bit_count != 8) &&
558 (header.bit_count != 24))
559 {
560 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: error bitmap file [%s] "
561 "bad bpp %d", filename, header.bit_count);
562 free_stream(s);
563 g_file_close(fd);
564 return 1;
565 }
566
567 if (header.bit_count == 24) /* 24 bit bitmap */
568 {
569 if (g_file_seek(fd, 14 + header.size) < 0)
570 {
571 LOG(LOG_LEVEL_WARNING, "xrdp_bitmap_load: seek error in file %s",
572 filename);
573 }
574 xrdp_bitmap_resize(self, header.image_width, header.image_height);
575 size = header.image_width * header.image_height * 3;
576 init_stream(s, size);
577 /* Pre-fill the buffer, so if we get short reads we're
578 * not working with uninitialised data */
579 g_memset(s->data, 0, size);
580 s->end = s->data + size;
581
582 /* read data */
583 for (i = header.image_height - 1; i >= 0; i--)
584 {
585 size = header.image_width * 3;
586 k = g_file_read(fd, s->data + i * size, size);
587
588 if (k != size)
589 {
590 LOG(LOG_LEVEL_WARNING, "xrdp_bitmap_load: error bitmap "
591 "file [%s] read", filename);
592 }
593 }
594
595 for (i = 0; i < self->height; i++)
596 {
597 for (j = 0; j < self->width; j++)
598 {
599 in_uint8(s, k);
600 color = k;
601 in_uint8(s, k);
602 color |= k << 8;
603 in_uint8(s, k);
604 color |= k << 16;
605
606 if (self->bpp == 8)
607 {
608 color = xrdp_bitmap_get_index(self, palette, color);
609 }
610 else if (self->bpp == 15)
611 {
612 color = COLOR15((color & 0xff0000) >> 16,
613 (color & 0x00ff00) >> 8,
614 (color & 0x0000ff) >> 0);
615 }
616 else if (self->bpp == 16)
617 {
618 color = COLOR16((color & 0xff0000) >> 16,
619 (color & 0x00ff00) >> 8,
620 (color & 0x0000ff) >> 0);
621 }
622
623 xrdp_bitmap_set_pixel(self, j, i, color);
624 }
625 }
626 }
627 else if (header.bit_count == 8) /* 8 bit bitmap */
628 {
629 /* read palette */
630 if (g_file_seek(fd, 14 + header.size) < 0)
631 {
632 LOG(LOG_LEVEL_WARNING, "xrdp_bitmap_load: seek error in file %s",
633 filename);
634 }
635 size = header.clr_used * sizeof(int);
636
637 init_stream(s, size);
638 /* Pre-fill the buffer, so if we get short reads we're
639 * not working with uninitialised data */
640 g_memset(s->data, 0, size);
641 s->end = s->data + size;
642
643 len = g_file_read(fd, s->data, size);
644 if (len != size)
645 {
646 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: "
647 "unexpected read length in file %s",
648 filename);
649 }
650
651 for (i = 0; i < header.clr_used; i++)
652 {
653 in_uint32_le(s, palette1[i]);
654 }
655
656 xrdp_bitmap_resize(self, header.image_width, header.image_height);
657 size = header.image_width * header.image_height;
658 init_stream(s, size);
659 /* Pre-fill the buffer, so if we get short reads we're
660 * not working with uninitialised data */
661 g_memset(s->data, 0, size);
662 s->end = s->data + size;
663
664 /* read data */
665 for (i = header.image_height - 1; i >= 0; i--)
666 {
667 size = header.image_width;
668 k = g_file_read(fd, s->data + i * size, size);
669
670 if (k != size)
671 {
672 LOG(LOG_LEVEL_WARNING, "xrdp_bitmap_load: error bitmap "
673 "file [%s] read", filename);
674 }
675 }
676
677 for (i = 0; i < self->height; i++)
678 {
679 for (j = 0; j < self->width; j++)
680 {
681 in_uint8(s, k);
682 color = palette1[k];
683
684 if (self->bpp == 8)
685 {
686 color = xrdp_bitmap_get_index(self, palette, color);
687 }
688 else if (self->bpp == 15)
689 {
690 color = COLOR15((color & 0xff0000) >> 16,
691 (color & 0x00ff00) >> 8,
692 (color & 0x0000ff) >> 0);
693 }
694 else if (self->bpp == 16)
695 {
696 color = COLOR16((color & 0xff0000) >> 16,
697 (color & 0x00ff00) >> 8,
698 (color & 0x0000ff) >> 0);
699 }
700
701 xrdp_bitmap_set_pixel(self, j, i, color);
702 }
703 }
704 }
705 else if (header.bit_count == 4) /* 4 bit bitmap */
706 {
707 /* read palette */
708 if (g_file_seek(fd, 14 + header.size) < 0)
709 {
710 LOG(LOG_LEVEL_WARNING, "xrdp_bitmap_load: seek error in file %s",
711 filename);
712 }
713 size = header.clr_used * sizeof(int);
714
715 init_stream(s, size);
716 /* Pre-fill the buffer, so if we get short reads we're
717 * not working with uninitialised data */
718 g_memset(s->data, 0, size);
719 s->end = s->data + size;
720
721 len = g_file_read(fd, s->data, size);
722 if (len != size)
723 {
724 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: "
725 "unexpected read length in file %s",
726 filename);
727 }
728
729 for (i = 0; i < header.clr_used; i++)
730 {
731 in_uint32_le(s, palette1[i]);
732 }
733
734 xrdp_bitmap_resize(self, header.image_width, header.image_height);
735 size = (header.image_width * header.image_height) / 2;
736 init_stream(s, size);
737 /* Pre-fill the buffer, so if we get short reads we're
738 * not working with uninitialised data */
739 g_memset(s->data, 0, size);
740 s->end = s->data + size;
741
742 /* read data */
743 for (i = header.image_height - 1; i >= 0; i--)
744 {
745 size = header.image_width / 2;
746 k = g_file_read(fd, s->data + i * size, size);
747
748 if (k != size)
749 {
750 LOG(LOG_LEVEL_WARNING, "xrdp_bitmap_load: error bitmap "
751 "file [%s] read", filename);
752 }
753 }
754
755 for (i = 0; i < self->height; i++)
756 {
757 for (j = 0; j < self->width; j++)
758 {
759 if ((j & 1) == 0)
760 {
761 in_uint8(s, k);
762 color = (k >> 4) & 0xf;
763 }
764 else
765 {
766 color = k & 0xf;
767 }
768
769 color = palette1[color];
770
771 if (self->bpp == 8)
772 {
773 color = xrdp_bitmap_get_index(self, palette, color);
774 }
775 else if (self->bpp == 15)
776 {
777 color = COLOR15((color & 0xff0000) >> 16,
778 (color & 0x00ff00) >> 8,
779 (color & 0x0000ff) >> 0);
780 }
781 else if (self->bpp == 16)
782 {
783 color = COLOR16((color & 0xff0000) >> 16,
784 (color & 0x00ff00) >> 8,
785 (color & 0x0000ff) >> 0);
786 }
787
788 xrdp_bitmap_set_pixel(self, j, i, color);
789 }
790 }
791 }
792
793 g_file_close(fd);
794 free_stream(s);
795 }
796 else
797 {
798 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_load: error loading bitmap "
799 "from file [%s]", filename);
800 return 1;
801 }
802
803 return 0;
804 }
805
806 /*****************************************************************************/
807 int
808 xrdp_bitmap_get_pixel(struct xrdp_bitmap *self, int x, int y)
809 {
810 if (self == 0)
811 {
812 return 0;
813 }
814
815 if (self->data == 0)
816 {
817 return 0;
818 }
819
820 if (x >= 0 && x < self->width && y >= 0 && y < self->height)
821 {
822 if (self->bpp == 8)
823 {
824 return GETPIXEL8(self->data, x, y, self->width);
825 }
826 else if (self->bpp == 15 || self->bpp == 16)
827 {
828 return GETPIXEL16(self->data, x, y, self->width);
829 }
830 else if (self->bpp >= 24)
831 {
832 return GETPIXEL32(self->data, x, y, self->width);
833 }
834 }
835
836 return 0;
837 }
838
839 /*****************************************************************************/
840 int
841 xrdp_bitmap_set_pixel(struct xrdp_bitmap *self, int x, int y, int pixel)
842 {
843 if (self == 0)
844 {
845 return 0;
846 }
847
848 if (self->data == 0)
849 {
850 return 0;
851 }
852
853 if (x >= 0 && x < self->width && y >= 0 && y < self->height)
854 {
855 if (self->bpp == 8)
856 {
857 SETPIXEL8(self->data, x, y, self->width, pixel);
858 }
859 else if (self->bpp == 15 || self->bpp == 16)
860 {
861 SETPIXEL16(self->data, x, y, self->width, pixel);
862 }
863 else if (self->bpp >= 24)
864 {
865 SETPIXEL32(self->data, x, y, self->width, pixel);
866 }
867 }
868
869 return 0;
870 }
871
872 /*****************************************************************************/
873 /* copy part of self at x, y to 0, 0 in dest */
874 /* returns error */
875 int
876 xrdp_bitmap_copy_box(struct xrdp_bitmap *self,
877 struct xrdp_bitmap *dest,
878 int x, int y, int cx, int cy)
879 {
880 int i;
881 int destx;
882 int desty;
883 int incs;
884 int incd;
885 tui8 *s8;
886 tui8 *d8;
887 tui16 *s16;
888 tui16 *d16;
889 tui32 *s32;
890 tui32 *d32;
891
892 if (self == 0)
893 {
894 return 1;
895 }
896
897 if (dest == 0)
898 {
899 return 1;
900 }
901
902 if (self->type != WND_TYPE_BITMAP && self->type != WND_TYPE_IMAGE)
903 {
904 return 1;
905 }
906
907 if (dest->type != WND_TYPE_BITMAP && dest->type != WND_TYPE_IMAGE)
908 {
909 return 1;
910 }
911
912 if (self->bpp != dest->bpp)
913 {
914 return 1;
915 }
916
917 destx = 0;
918 desty = 0;
919
920 if (!check_bounds(self, &x, &y, &cx, &cy))
921 {
922 return 1;
923 }
924
925 if (!check_bounds(dest, &destx, &desty, &cx, &cy))
926 {
927 return 1;
928 }
929
930 if (self->bpp >= 24)
931 {
932 s32 = ((tui32 *)(self->data)) + (self->width * y + x);
933 d32 = ((tui32 *)(dest->data)) + (dest->width * desty + destx);
934 incs = self->width - cx;
935 incd = dest->width - cx;
936
937 for (i = 0; i < cy; i++)
938 {
939 g_memcpy(d32, s32, cx * 4);
940 s32 += cx;
941 d32 += cx;
942
943 s32 += incs;
944 d32 += incd;
945 }
946
947 }
948 else if (self->bpp == 15 || self->bpp == 16)
949 {
950 s16 = ((tui16 *)(self->data)) + (self->width * y + x);
951 d16 = ((tui16 *)(dest->data)) + (dest->width * desty + destx);
952 incs = self->width - cx;
953 incd = dest->width - cx;
954
955 for (i = 0; i < cy; i++)
956 {
957 g_memcpy(d16, s16, cx * 2);
958 s16 += cx;
959 d16 += cx;
960
961 s16 += incs;
962 d16 += incd;
963 }
964 }
965 else if (self->bpp == 8)
966 {
967 s8 = ((tui8 *)(self->data)) + (self->width * y + x);
968 d8 = ((tui8 *)(dest->data)) + (dest->width * desty + destx);
969 incs = self->width - cx;
970 incd = dest->width - cx;
971
972 for (i = 0; i < cy; i++)
973 {
974 g_memcpy(d8, s8, cx);
975 s8 += cx;
976 d8 += cx;
977
978 s8 += incs;
979 d8 += incd;
980 }
981 }
982 else
983 {
984 return 1;
985 }
986
987146 return 0;
988147 }
989148
1014173 return 1;
1015174 }
1016175 hash = ssl_md5_info_create();
176 ssl_md5_clear(hash);
1017177 ssl_md5_transform(hash, self->data, bytes);
1018178 ssl_md5_complete(hash, hash_data);
1019179 ssl_md5_info_delete(hash);
1356516 painter->brush.pattern[6] = 0xaa;
1357517 painter->brush.pattern[7] = 0x55;
1358518 painter->brush.x_origin = x;
1359 painter->brush.x_origin = x;
519 painter->brush.y_origin = y;
1360520 painter->brush.style = 3;
1361521 painter->fg_color = self->wm->black;
1362522 painter->bg_color = self->parent->bg_color;
0 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * Copyright (C) Jay Sorg 2004-2014
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * Common bitmap functions for all xrdp_bitmap*.c files
18 */
19
20 #if defined(HAVE_CONFIG_H)
21 #include <config_ac.h>
22 #endif
23
24 #include <limits.h>
25
26 #include "xrdp.h"
27
28 /*****************************************************************************/
29 /* Allocate bitmap for specified dimensions, checking for int overflow */
30 static char *
31 alloc_bitmap_data(int width, int height, int Bpp)
32 {
33 char *result = NULL;
34 if (width > 0 && height > 0 && Bpp > 0)
35 {
36 int len = width;
37 /* g_malloc() currently takes an 'int' size */
38 if (len < INT_MAX / height)
39 {
40 len *= height;
41 if (len < INT_MAX / Bpp)
42 {
43 len *= Bpp;
44 result = (char *)malloc(len);
45 }
46 }
47 }
48
49 return result;
50 }
51
52 /*****************************************************************************/
53 struct xrdp_bitmap *
54 xrdp_bitmap_create(int width, int height, int bpp,
55 int type, struct xrdp_wm *wm)
56 {
57 struct xrdp_bitmap *self = (struct xrdp_bitmap *)NULL;
58 int Bpp = 0;
59
60 self = (struct xrdp_bitmap *)g_malloc(sizeof(struct xrdp_bitmap), 1);
61 if (self == NULL)
62 {
63 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_create: no memory");
64 return self;
65 }
66
67 self->type = type;
68 self->width = width;
69 self->height = height;
70 self->bpp = bpp;
71 Bpp = 4;
72
73 switch (bpp)
74 {
75 case 8:
76 Bpp = 1;
77 break;
78 case 15:
79 Bpp = 2;
80 break;
81 case 16:
82 Bpp = 2;
83 break;
84 }
85
86 if (self->type == WND_TYPE_BITMAP || self->type == WND_TYPE_IMAGE)
87 {
88 self->data = alloc_bitmap_data(width, height, Bpp);
89 if (self->data == NULL)
90 {
91 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_create: size overflow %dx%dx%d",
92 width, height, Bpp);
93 g_free(self);
94 return NULL;
95 }
96 }
97
98 #if defined(XRDP_PAINTER)
99 if (self->type == WND_TYPE_SCREEN) /* noorders */
100 {
101 LOG_DEVEL(LOG_LEVEL_INFO, "xrdp_bitmap_create: noorders");
102 self->data = alloc_bitmap_data(width, height, Bpp);
103 if (self->data == NULL)
104 {
105 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_create: size overflow %dx%dx%d",
106 width, height, Bpp);
107 g_free(self);
108 return NULL;
109 }
110 }
111 #endif
112
113 if (self->type != WND_TYPE_BITMAP)
114 {
115 self->child_list = list_create();
116 }
117
118 self->line_size = width * Bpp;
119
120 if (self->type == WND_TYPE_COMBO)
121 {
122 self->string_list = list_create();
123 self->string_list->auto_free = 1;
124 self->data_list = list_create();
125 self->data_list->auto_free = 1;
126 }
127
128 self->wm = wm;
129 return self;
130 }
131
132 /*****************************************************************************/
133 struct xrdp_bitmap *
134 xrdp_bitmap_create_with_data(int width, int height,
135 int bpp, char *data,
136 struct xrdp_wm *wm)
137 {
138 struct xrdp_bitmap *self = (struct xrdp_bitmap *)NULL;
139 int Bpp;
140 #if defined(NEED_ALIGN)
141 tintptr data_as_int;
142 #endif
143
144 self = (struct xrdp_bitmap *)g_malloc(sizeof(struct xrdp_bitmap), 1);
145 self->type = WND_TYPE_BITMAP;
146 self->width = width;
147 self->height = height;
148 self->bpp = bpp;
149 self->wm = wm;
150
151 Bpp = 4;
152 switch (bpp)
153 {
154 case 8:
155 Bpp = 1;
156 break;
157 case 15:
158 Bpp = 2;
159 break;
160 case 16:
161 Bpp = 2;
162 break;
163 }
164 self->line_size = width * Bpp;
165
166 #if defined(NEED_ALIGN)
167 data_as_int = (tintptr) data;
168 if (((bpp >= 24) && (data_as_int & 3)) ||
169 (((bpp == 15) || (bpp == 16)) && (data_as_int & 1)))
170 {
171 /* got to copy data here, it's not aligned
172 other calls in this file assume alignment */
173 self->data = (char *)g_malloc(width * height * Bpp, 0);
174 g_memcpy(self->data, data, width * height * Bpp);
175 return self;
176 }
177 #endif
178 self->data = data;
179 self->do_not_free_data = 1;
180 return self;
181 }
182
183 /*****************************************************************************/
184 void
185 xrdp_bitmap_delete(struct xrdp_bitmap *self)
186 {
187 int i = 0;
188 struct xrdp_mod_data *mod_data = (struct xrdp_mod_data *)NULL;
189
190 if (self == 0)
191 {
192 return;
193 }
194
195 if (self->wm != 0)
196 {
197 if (self->wm->focused_window != 0)
198 {
199 if (self->wm->focused_window->focused_control == self)
200 {
201 self->wm->focused_window->focused_control = 0;
202 }
203 }
204
205 if (self->wm->focused_window == self)
206 {
207 self->wm->focused_window = 0;
208 }
209
210 if (self->wm->dragging_window == self)
211 {
212 self->wm->dragging_window = 0;
213 }
214
215 if (self->wm->button_down == self)
216 {
217 self->wm->button_down = 0;
218 }
219
220 if (self->wm->popup_wnd == self)
221 {
222 self->wm->popup_wnd = 0;
223 }
224
225 if (self->wm->login_window == self)
226 {
227 self->wm->login_window = 0;
228 }
229
230 if (self->wm->log_wnd == self)
231 {
232 self->wm->log_wnd = 0;
233 }
234 }
235
236 if (self->child_list != 0)
237 {
238 for (i = self->child_list->count - 1; i >= 0; i--)
239 {
240 xrdp_bitmap_delete((struct xrdp_bitmap *)self->child_list->items[i]);
241 }
242
243 list_delete(self->child_list);
244 }
245
246 if (self->parent != 0)
247 {
248 i = list_index_of(self->parent->child_list, (long)self);
249
250 if (i >= 0)
251 {
252 list_remove_item(self->parent->child_list, i);
253 }
254 }
255
256 if (self->string_list != 0) /* for combo */
257 {
258 list_delete(self->string_list);
259 }
260
261 if (self->data_list != 0) /* for combo */
262 {
263 for (i = 0; i < self->data_list->count; i++)
264 {
265 mod_data = (struct xrdp_mod_data *)list_get_item(self->data_list, i);
266
267 if (mod_data != 0)
268 {
269 list_delete(mod_data->names);
270 list_delete(mod_data->values);
271 }
272 }
273
274 list_delete(self->data_list);
275 }
276
277 if (!self->do_not_free_data)
278 {
279 g_free(self->data);
280 }
281
282 g_free(self->caption1);
283 g_free(self);
284 }
285
286 /*****************************************************************************/
287 /* returns error */
288 int
289 xrdp_bitmap_resize(struct xrdp_bitmap *self, int width, int height)
290 {
291 int Bpp = 0;
292
293 if ((width == self->width) && (height == self->height))
294 {
295 return 0;
296 }
297
298 if (self->do_not_free_data)
299 {
300 return 1;
301 }
302
303 self->width = width;
304 self->height = height;
305 Bpp = 4;
306
307 switch (self->bpp)
308 {
309 case 8:
310 Bpp = 1;
311 break;
312 case 15:
313 Bpp = 2;
314 break;
315 case 16:
316 Bpp = 2;
317 break;
318 }
319
320 g_free(self->data);
321 self->data = (char *)g_malloc(width * height * Bpp, 0);
322 self->line_size = width * Bpp;
323 return 0;
324 }
325
326 /*****************************************************************************/
327 int
328 xrdp_bitmap_get_pixel(struct xrdp_bitmap *self, int x, int y)
329 {
330 if (self == 0)
331 {
332 return 0;
333 }
334
335 if (self->data == 0)
336 {
337 return 0;
338 }
339
340 if (x >= 0 && x < self->width && y >= 0 && y < self->height)
341 {
342 if (self->bpp == 8)
343 {
344 return GETPIXEL8(self->data, x, y, self->width);
345 }
346 else if (self->bpp == 15 || self->bpp == 16)
347 {
348 return GETPIXEL16(self->data, x, y, self->width);
349 }
350 else if (self->bpp >= 24)
351 {
352 return GETPIXEL32(self->data, x, y, self->width);
353 }
354 }
355
356 return 0;
357 }
358
359 /*****************************************************************************/
360 int
361 xrdp_bitmap_set_pixel(struct xrdp_bitmap *self, int x, int y, int pixel)
362 {
363 if (self == 0)
364 {
365 return 0;
366 }
367
368 if (self->data == 0)
369 {
370 return 0;
371 }
372
373 if (x >= 0 && x < self->width && y >= 0 && y < self->height)
374 {
375 if (self->bpp == 8)
376 {
377 SETPIXEL8(self->data, x, y, self->width, pixel);
378 }
379 else if (self->bpp == 15 || self->bpp == 16)
380 {
381 SETPIXEL16(self->data, x, y, self->width, pixel);
382 }
383 else if (self->bpp >= 24)
384 {
385 SETPIXEL32(self->data, x, y, self->width, pixel);
386 }
387 }
388
389 return 0;
390 }
391
392 /*****************************************************************************/
393 /* copy part of self at x, y to 0, 0 in dest */
394 /* returns error */
395 int
396 xrdp_bitmap_copy_box(struct xrdp_bitmap *self,
397 struct xrdp_bitmap *dest,
398 int x, int y, int cx, int cy)
399 {
400 int i;
401 int destx;
402 int desty;
403 int incs;
404 int incd;
405 tui8 *s8;
406 tui8 *d8;
407 tui16 *s16;
408 tui16 *d16;
409 tui32 *s32;
410 tui32 *d32;
411
412 if (self == 0)
413 {
414 return 1;
415 }
416
417 if (dest == 0)
418 {
419 return 1;
420 }
421
422 if (self->type != WND_TYPE_BITMAP && self->type != WND_TYPE_IMAGE)
423 {
424 return 1;
425 }
426
427 if (dest->type != WND_TYPE_BITMAP && dest->type != WND_TYPE_IMAGE)
428 {
429 return 1;
430 }
431
432 if (self->bpp != dest->bpp)
433 {
434 return 1;
435 }
436
437 destx = 0;
438 desty = 0;
439
440 if (!check_bounds(self, &x, &y, &cx, &cy))
441 {
442 return 1;
443 }
444
445 if (!check_bounds(dest, &destx, &desty, &cx, &cy))
446 {
447 return 1;
448 }
449
450 if (self->bpp >= 24)
451 {
452 s32 = ((tui32 *)(self->data)) + (self->width * y + x);
453 d32 = ((tui32 *)(dest->data)) + (dest->width * desty + destx);
454 incs = self->width - cx;
455 incd = dest->width - cx;
456
457 for (i = 0; i < cy; i++)
458 {
459 g_memcpy(d32, s32, cx * 4);
460 s32 += cx;
461 d32 += cx;
462
463 s32 += incs;
464 d32 += incd;
465 }
466
467 }
468 else if (self->bpp == 15 || self->bpp == 16)
469 {
470 s16 = ((tui16 *)(self->data)) + (self->width * y + x);
471 d16 = ((tui16 *)(dest->data)) + (dest->width * desty + destx);
472 incs = self->width - cx;
473 incd = dest->width - cx;
474
475 for (i = 0; i < cy; i++)
476 {
477 g_memcpy(d16, s16, cx * 2);
478 s16 += cx;
479 d16 += cx;
480
481 s16 += incs;
482 d16 += incd;
483 }
484 }
485 else if (self->bpp == 8)
486 {
487 s8 = ((tui8 *)(self->data)) + (self->width * y + x);
488 d8 = ((tui8 *)(dest->data)) + (dest->width * desty + destx);
489 incs = self->width - cx;
490 incd = dest->width - cx;
491
492 for (i = 0; i < cy; i++)
493 {
494 g_memcpy(d8, s8, cx);
495 s8 += cx;
496 d8 += cx;
497
498 s8 += incs;
499 d8 += incd;
500 }
501 }
502 else
503 {
504 return 1;
505 }
506
507 return 0;
508 }
0 /**
1 * xrdp: A Remote Desktop Protocol server.
2 *
3 * Copyright (C) Jay Sorg 2004-2014
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * Load xrdp_bitmap from file
18 */
19
20 #if defined(HAVE_CONFIG_H)
21 #include <config_ac.h>
22 #endif
23
24 #ifdef USE_IMLIB2
25 # include <Imlib2.h>
26 #endif
27
28 #include "xrdp.h"
29 #include "log.h"
30
31 /* Rounds up to the nearest multiple of 4 */
32 #define ROUND4(x) (((x) + 3) / 4 * 4)
33
34 /* Are we using the builtin BMP format-only loader */
35
36 #ifdef USE_BUILTIN_LOADER
37 # undef USE_BUILTIN_LOADER
38 #endif
39
40 #ifndef USE_IMLIB2
41 # define USE_BUILTIN_LOADER
42 #endif
43
44 /**
45 * Describes a box within an image
46 */
47 struct box
48 {
49 int left_margin;
50 int width;
51 int top_margin;
52 int height;
53 };
54
55 /**************************************************************************//**
56 * Calculates a zoom box, from source and destination image dimensions
57 *
58 * The zoom box is the largest centred part of the source image which
59 * preserves the aspect ratio of the destination image. We find it
60 * by cutting off the left and right sides of the source, or the top
61 * and bottom.
62 *
63 * @param src_width Width of source image
64 * @param src_height Height of source image
65 * @param dst_width Width of destination image
66 * @param dst_height Height of destination image
67 * @param[out] zb_return Zoom box
68 * @return 0 for success
69 */
70 static int
71 calculate_zoom_box(int src_width, int src_height,
72 int dst_width, int dst_height,
73 struct box *zb_return)
74 {
75 int result = 1;
76 struct box zb;
77
78 if (dst_height == 0 || src_height == 0)
79 {
80 LOG(LOG_LEVEL_ERROR, "Can't zoom to or from zero-width images");
81 }
82 else
83 {
84 double dst_ratio = (double)dst_width / dst_height;
85 double src_ratio = (double)src_width / src_height;
86
87 if (src_ratio > dst_ratio)
88 {
89 /* Source is relatively wider than source. Select a box
90 * narrower than the source, but the same height */
91 zb.width = (int)(dst_ratio * src_height + .5);
92 zb.left_margin = (src_width - zb.width) / 2;
93 zb.height = src_height;
94 zb.top_margin = 0;
95 }
96 else
97 {
98 /* Source is relatively taller than source (or same shape) */
99 zb.width = src_width;
100 zb.left_margin = 0;
101 zb.height = (int)(src_width / dst_ratio + .5);
102 zb.top_margin = (src_height - zb.height) / 2;
103 }
104
105 /* Only allow meaningful zoom boxes */
106 if (zb.width < 1 || zb.height < 1)
107 {
108 LOG(LOG_LEVEL_WARNING, "Ignoring pathological zoom"
109 " request (%dx%d) -> (%dx%d)", src_width, src_height,
110 dst_width, dst_height);
111 }
112 else
113 {
114 *zb_return = zb;
115 result = 0;
116 }
117 }
118
119 return result;
120 }
121
122 /*****************************************************************************/
123 static int
124 xrdp_bitmap_get_index(struct xrdp_bitmap *self, const int *palette, int color)
125 {
126 int r = 0;
127 int g = 0;
128 int b = 0;
129
130 r = (color & 0xff0000) >> 16;
131 g = (color & 0x00ff00) >> 8;
132 b = (color & 0x0000ff) >> 0;
133 r = (r >> 5) << 0;
134 g = (g >> 5) << 3;
135 b = (b >> 6) << 6;
136 return (b | g | r);
137 }
138
139 #ifdef USE_BUILTIN_LOADER
140 /**************************************************************************//**
141 * Private routine to swap pixel data between two pixmaps
142 * @param a First bitmap
143 * @param b Second bitmap
144 *
145 * The main use-case for this routine is to modify an existing bitmap using
146 * the following logic:-
147 * - Create a temporary WND_TYPE_BITMAP
148 * - Process the data in a bitmap in some way, moving it to the temporary
149 * - Call this routine
150 * - Delete the temporary
151 *
152 */
153 static void
154 swap_pixel_data(struct xrdp_bitmap *a, struct xrdp_bitmap *b)
155 {
156 int tmp_width = a->width;
157 int tmp_height = a->height;
158 int tmp_bpp = a->bpp;
159 int tmp_line_size = a->line_size;
160 char *tmp_data = a->data;
161 int tmp_do_not_free_data = a->do_not_free_data;
162
163 a->width = b->width;
164 a->height = b->height;
165 a->bpp = b->bpp;
166 a->line_size = b->line_size;
167 a->data = b->data;
168 a->do_not_free_data = b->do_not_free_data;
169
170 b->width = tmp_width;
171 b->height = tmp_height;
172 b->bpp = tmp_bpp;
173 b->line_size = tmp_line_size;
174 b->data = tmp_data;
175 b->do_not_free_data = tmp_do_not_free_data;
176 }
177 #endif /* USE_BUILTIN_LOADER */
178
179 #ifdef USE_BUILTIN_LOADER
180 /**************************************************************************//**
181 * Scales a bitmap image
182 *
183 * @param self Bitmap to scale
184 * @param target_width target width
185 * @param target_height target height
186 * @return 0 for success
187 */
188 static int
189 xrdp_bitmap_scale(struct xrdp_bitmap *self, int targ_width, int targ_height)
190 {
191 int src_width = self->width;
192 int src_height = self->height;
193
194 if (src_width != targ_width || src_height != targ_height)
195 {
196 struct xrdp_bitmap *target =
197 xrdp_bitmap_create(targ_width, targ_height,
198 self->bpp, WND_TYPE_BITMAP, 0);
199 int targ_x, targ_y;
200
201 if (target == NULL)
202 {
203 /* Error is logged */
204 return 1;
205 }
206
207 /* For each pixel in the target pixmap, scale to one in the source */
208 for (targ_x = 0 ; targ_x < targ_width; ++targ_x)
209 {
210 int src_x = targ_x * src_width / targ_width;
211 for (targ_y = 0 ; targ_y < targ_height; ++targ_y)
212 {
213 int src_y = targ_y * src_height / targ_height;
214 int pixel = xrdp_bitmap_get_pixel(self, src_x, src_y);
215 xrdp_bitmap_set_pixel(target, targ_x, targ_y, pixel);
216 }
217 }
218 swap_pixel_data(self, target);
219 xrdp_bitmap_delete(target);
220 }
221
222 return 0;
223 }
224 #endif /* USE_BUILTIN_LOADER */
225
226
227 #ifdef USE_BUILTIN_LOADER
228 /**************************************************************************//**
229 * Zooms a bitmap image
230 *
231 * @param self Bitmap to zoom
232 * @param target_width target width
233 * @param target_height target height
234 * @return 0 for success
235 *
236 * This works the same way as a scaled image, but the aspect ratio is
237 * maintained by removing pixels from the top-and-bottom,
238 * or the left-and-right before scaling.
239 */
240 static int
241 xrdp_bitmap_zoom(struct xrdp_bitmap *self, int targ_width, int targ_height)
242 {
243 struct box zb;
244
245 int result = 0;
246
247 if (calculate_zoom_box(self->width, self->height,
248 targ_width, targ_height, &zb) == 0)
249 {
250 /* Need to chop anything? */
251 if (zb.top_margin != 0 || zb.left_margin != 0)
252 {
253 struct xrdp_bitmap *zbitmap;
254 zbitmap = xrdp_bitmap_create(zb.width, zb.height, self->bpp,
255 WND_TYPE_BITMAP, 0);
256 if (zbitmap == NULL)
257 {
258 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_zoom: no memory");
259 result = 1;
260 }
261 else
262 {
263 result = xrdp_bitmap_copy_box(self, zbitmap,
264 zb.left_margin, zb.top_margin,
265 zb.width, zb.height);
266 if (result != 0)
267 {
268 LOG(LOG_LEVEL_ERROR, "xrdp_bitmap_zoom: can't copy box");
269 }
270 else
271 {
272 swap_pixel_data(self, zbitmap);
273 }
274 xrdp_bitmap_delete(zbitmap);
275 }
276 }
277 }
278
279 if (result == 0)
280 {
281 result = xrdp_bitmap_scale(self, targ_width, targ_height);
282 }
283
284 return result;
285 }
286 #endif /* USE_BUILTIN_LOADER */
287
288 #ifdef USE_BUILTIN_LOADER
289 /**************************************************************************//**
290 * reads the palette from a bmp file with a palette embedded in it
291 *
292 * @pre The read position in the file is at the end of the bmp DIB header.
293 *
294 * @param filename Name of file
295 * @param fd File descriptor for file
296 * @param header Pointer to BMP header info struct
297 * @param palette output. Must be at least 256 elements
298 */
299 static void
300 read_palette(const char *filename, int fd,
301 const struct xrdp_bmp_header *header, int *palette)
302 {
303 struct stream *s;
304 int clr_used;
305 int palette_size;
306 int len;
307 int i;
308
309 /* Find the number of colors used in the bitmap */
310 if (header->clr_used != 0)
311 {
312 clr_used = header->clr_used;
313 /* Is the header value sane? */
314 if (clr_used < 0 || clr_used > 256)
315 {
316 clr_used = 256;
317 LOG(LOG_LEVEL_WARNING, "%s : Invalid palette size %d in file %s",
318 __func__, header->clr_used, filename);
319 }
320 }
321 else if (header->bit_count == 4)
322 {
323 clr_used = 16;
324 }
325 else
326 {
327 clr_used = 256;
328 }
329
330 palette_size = clr_used * 4;
331
332 make_stream(s);
333 init_stream(s, palette_size);
334
335 /* Pre-fill the buffer, so if we get short reads we're
336 * not working with uninitialised data */
337 g_memset(s->data, 0, palette_size);
338 s->end = s->data + palette_size;
339
340 len = g_file_read(fd, s->data, palette_size);
341 if (len != palette_size)
342 {
343 LOG(LOG_LEVEL_WARNING, "%s: unexpected read length in file %s",
344 __func__, filename);
345 }
346
347 for (i = 0; i < clr_used; ++i)
348 {
349 in_uint32_le(s, palette[i]);
350 }
351
352 free_stream(s);
353 }
354 #endif /* USE_BUILTIN_LOADER */
355
356 #ifdef USE_BUILTIN_LOADER
357 /**************************************************************************//**
358 * Process a row of data from a 24-bit bmp file
359 *
360 * @param self Bitmap we're filling in
361 * @param s Stream containing bitmap data
362 * @param in_palette Palette from bmp file (unused)
363 * @param out_palette Palette for output bitmap
364 * @param row Row number
365 */
366 static void
367 process_row_data_24bit(struct xrdp_bitmap *self,
368 struct stream *s,
369 const int *in_palette,
370 const int *out_palette,
371 int row)
372 {
373 int j;
374 int k;
375 int color;
376
377 for (j = 0; j < self->width; ++j)
378 {
379 in_uint8(s, k);
380 color = k;
381 in_uint8(s, k);
382 color |= k << 8;
383 in_uint8(s, k);
384 color |= k << 16;
385
386 if (self->bpp == 8)
387 {
388 color = xrdp_bitmap_get_index(self, out_palette, color);
389 }
390 else if (self->bpp == 15)
391 {
392 color = COLOR15((color & 0xff0000) >> 16,
393 (color & 0x00ff00) >> 8,
394 (color & 0x0000ff) >> 0);
395 }
396 else if (self->bpp == 16)
397 {
398 color = COLOR16((color & 0xff0000) >> 16,
399 (color & 0x00ff00) >> 8,
400 (color & 0x0000ff) >> 0);
401 }
402
403 xrdp_bitmap_set_pixel(self, j, row, color);
404 }
405 }
406 #endif /* USE_BUILTIN_LOADER */
407
408 #ifdef USE_BUILTIN_LOADER
409 /**************************************************************************//**
410 * Process a row of data from an 8-bit bmp file
411 *
412 * @param self Bitmap we're filling in
413 * @param s Stream containing bitmap data
414 * @param in_palette Palette from bmp file
415 * @param out_palette Palette for output bitmap
416 * @param row Row number
417 */
418 static void
419 process_row_data_8bit(struct xrdp_bitmap *self,
420 struct stream *s,
421 const int *in_palette,
422 const int *out_palette,
423 int row)
424 {
425 int j;
426 int k;
427 int color;
428
429 for (j = 0; j < self->width; ++j)
430 {
431 in_uint8(s, k);
432 color = in_palette[k];
433
434 if (self->bpp == 8)
435 {
436 color = xrdp_bitmap_get_index(self, out_palette, color);
437 }
438 else if (self->bpp == 15)
439 {
440 color = COLOR15((color & 0xff0000) >> 16,
441 (color & 0x00ff00) >> 8,
442 (color & 0x0000ff) >> 0);
443 }
444 else if (self->bpp == 16)
445 {
446 color = COLOR16((color & 0xff0000) >> 16,
447 (color & 0x00ff00) >> 8,
448 (color & 0x0000ff) >> 0);
449 }
450
451 xrdp_bitmap_set_pixel(self, j, row, color);
452 }
453 }
454 #endif /* USE_BUILTIN_LOADER */
455
456 #ifdef USE_BUILTIN_LOADER
457 /**************************************************************************//**
458 * Process a row of data from an 4-bit bmp file
459 *
460 * @param self Bitmap we're filling in
461 * @param s Stream containing bitmap data
462 * @param in_palette Palette from bmp file
463 * @param out_palette Palette for output bitmap
464 * @param row Row number
465 */
466 static void
467 process_row_data_4bit(struct xrdp_bitmap *self,
468 struct stream *s,
469 const int *in_palette,
470 const int *out_palette,
471 int row)
472 {
473 int j;
474 int k = 0;
475 int color;
476
477 for (j = 0; j < self->width; ++j)
478 {
479 if ((j & 1) == 0)
480 {
481 in_uint8(s, k);
482 color = (k >> 4) & 0xf;
483 }
484 else
485 {
486 color = k & 0xf;
487 }
488
489 color = in_palette[color];
490
491 if (self->bpp == 8)
492 {
493 color = xrdp_bitmap_get_index(self, out_palette, color);
494 }
495 else if (self->bpp == 15)
496 {
497 color = COLOR15((color & 0xff0000) >> 16,
498 (color & 0x00ff00) >> 8,
499 (color & 0x0000ff) >> 0);
500 }
501 else if (self->bpp == 16)
502 {
503 color = COLOR16((color & 0xff0000) >> 16,
504 (color & 0x00ff00) >> 8,
505 (color & 0x0000ff) >> 0);
506 }
507
508 xrdp_bitmap_set_pixel(self, j, row, color);
509 }
510 }
511 #endif /* USE_BUILTIN_LOADER */
512
513 #ifdef USE_BUILTIN_LOADER
514 /*****************************************************************************/
515 /* load a bmp file */
516 /* return 0 ok */
517 /* return 1 error */
518 static int
519 xrdp_bitmap_load_bmp(struct xrdp_bitmap *self, const char *filename,
520 const int *out_palette)
521 {
522 int fd = 0;
523 int len = 0;
524 int row = 0;
525 int row_size = 0;
526 int bmp_palette[256] = {0};
527 char fixed_header[14] = {0};
528 struct xrdp_bmp_header header = {0};
529 struct stream *s = (struct stream *)NULL;
530 /* Pointer to row data processing function */
531 void (*process_row_data)(struct xrdp_bitmap * self,
532 struct stream * s,
533 const int *in_palette,
534 const int *out_palette,
535 int row);
536
537 if (!g_file_exist(filename))
538 {
539 LOG(LOG_LEVEL_ERROR, "%s: error bitmap file [%s] does not exist",
540 __func__, filename);
541 return 1;
542 }
543
544 fd = g_file_open(filename);
545
546 if (fd == -1)
547 {
548 LOG(LOG_LEVEL_ERROR, "%s: error loading bitmap from file [%s]",
549 __func__, filename);
550 return 1;
551 }
552
553 /* read the fixed file header */
554 if (g_file_read(fd, fixed_header, 14) != 14)
555 {
556 LOG(LOG_LEVEL_ERROR, "%s: error bitmap file [%s] read error",
557 __func__, filename);
558 g_file_close(fd);
559 return 1;
560 }
561
562 if ((fixed_header[0] != 'B') || (fixed_header[1] != 'M'))
563 {
564 LOG(LOG_LEVEL_ERROR, "%s: error bitmap file [%s] not BMP file",
565 __func__, filename);
566 g_file_close(fd);
567 return 1;
568 }
569
570 /* read information header */
571 make_stream(s);
572 init_stream(s, 8192);
573 len = g_file_read(fd, s->data, 40); /* size better be 40 */
574 if (len != 40)
575 {
576 LOG(LOG_LEVEL_ERROR, "%s: unexpected read length %d in file %s",
577 __func__, len, filename);
578 free_stream(s);
579 g_file_close(fd);
580 return 1;
581 }
582 s->end = s->data + len;
583 in_uint32_le(s, header.size);
584 in_uint32_le(s, header.image_width);
585 in_uint32_le(s, header.image_height);
586 in_uint16_le(s, header.planes);
587 in_uint16_le(s, header.bit_count);
588 in_uint32_le(s, header.compression);
589 in_uint32_le(s, header.image_size);
590 in_uint32_le(s, header.x_pels_per_meter);
591 in_uint32_le(s, header.y_pels_per_meter);
592 in_uint32_le(s, header.clr_used);
593 in_uint32_le(s, header.clr_important);
594
595 if (header.compression != 0)
596 {
597 LOG(LOG_LEVEL_WARNING, "%s: error bitmap file [%s]"
598 " unsupported compression value %d",
599 __func__, filename, header.compression);
600 }
601
602 if (g_file_seek(fd, 14 + header.size) < 0)
603 {
604 LOG(LOG_LEVEL_WARNING, "%s: seek error in file %s",
605 __func__, filename);
606 }
607
608 /* Validate the bit count for the file, read any palette, and
609 * dtermine the row size and row processing function */
610 switch (header.bit_count)
611 {
612 case 24:
613 row_size = ROUND4(header.image_width * 3);
614 process_row_data = process_row_data_24bit;
615 break;
616
617 case 8:
618 read_palette(filename, fd, &header, bmp_palette);
619 row_size = ROUND4(header.image_width);
620 process_row_data = process_row_data_8bit;
621 break;
622
623 case 4:
624 read_palette(filename, fd, &header, bmp_palette);
625 /* The storage for a row is a complex calculation for 4 bit pixels.
626 * a width of 1-8 pixels takes 4 bytes
627 * a width of 9-16 pixels takes 8 bytes, etc
628 * So bytes = (width + 7) / 8 * 4
629 */
630 row_size = ((header.image_width + 7) / 8 * 4);
631 process_row_data = process_row_data_4bit;
632 break;
633
634 default:
635 LOG(LOG_LEVEL_ERROR, "%s: error bitmap file [%s] bad bpp %d",
636 __func__, filename, header.bit_count);
637 free_stream(s);
638 g_file_close(fd);
639 return 1;
640 }
641
642 xrdp_bitmap_resize(self, header.image_width, header.image_height);
643
644 /* Set up the row data buffer. Pre fill it, so if we get short reads
645 * we're not working with uninitialised data */
646 init_stream(s, row_size);
647 g_memset(s->data, 0, row_size);
648 s->end = s->data + row_size;
649
650 /* read and process the pixel data a row at a time */
651 for (row = header.image_height - 1; row >= 0; row--)
652 {
653 len = g_file_read(fd, s->data, row_size);
654
655 if (len != row_size)
656 {
657 LOG(LOG_LEVEL_WARNING, "%s: error bitmap file [%s] read",
658 __func__, filename);
659 }
660
661 s->p = s->data;
662 (*process_row_data)(self, s, bmp_palette, out_palette, row);
663 }
664
665 g_file_close(fd);
666 free_stream(s);
667
668 return 0;
669 }
670 #endif /* USE_BUILTIN_LOADER */
671
672 #ifdef USE_BUILTIN_LOADER
673 /*****************************************************************************/
674 int
675 xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename,
676 const int *palette,
677 int background,
678 enum xrdp_bitmap_load_transform transform,
679 int twidth,
680 int theight)
681 {
682 /* this is the default bmp-only implementation if a graphics library
683 * isn't built in */
684
685 int result = xrdp_bitmap_load_bmp(self, filename, palette);
686 if (result == 0)
687 {
688 switch (transform)
689 {
690 case XBLT_NONE:
691 break;
692
693 case XBLT_SCALE:
694 result = xrdp_bitmap_scale(self, twidth, theight);
695 break;
696
697 case XBLT_ZOOM:
698 result = xrdp_bitmap_zoom(self, twidth, theight);
699 break;
700
701 default:
702 LOG(LOG_LEVEL_WARNING, "Invalid bitmap transform %d specified",
703 transform);
704 }
705 }
706
707 return result;
708 }
709 #endif /* USE_BUILTIN_LOADER */
710
711 #ifdef USE_IMLIB2
712 /**************************************************************************//**
713 * Log an error from the Imlib2 library
714 *
715 * @param level Log level to use
716 * @param filename file we're trying to load
717 * @param lerr Error return from imlib2
718 */
719 static void
720 log_imlib2_error(enum logLevels level, const char *filename,
721 Imlib_Load_Error lerr)
722 {
723 const char *msg;
724 char buff[256];
725
726 switch (lerr)
727 {
728 case IMLIB_LOAD_ERROR_NONE:
729 msg = "No error";
730 break;
731 case IMLIB_LOAD_ERROR_FILE_DOES_NOT_EXIST:
732 msg = "No such file";
733 break;
734 case IMLIB_LOAD_ERROR_PERMISSION_DENIED_TO_READ:
735 msg = "Permission denied";
736 break;
737 case IMLIB_LOAD_ERROR_NO_LOADER_FOR_FILE_FORMAT:
738 msg = "Unrecognised file format";
739 break;
740 case IMLIB_LOAD_ERROR_FILE_IS_DIRECTORY:
741 case IMLIB_LOAD_ERROR_PATH_TOO_LONG:
742 case IMLIB_LOAD_ERROR_PATH_COMPONENT_NON_EXISTANT:
743 case IMLIB_LOAD_ERROR_PATH_POINTS_OUTSIDE_ADDRESS_SPACE:
744 case IMLIB_LOAD_ERROR_TOO_MANY_SYMBOLIC_LINKS:
745 msg = "Bad filename";
746 break;
747 case IMLIB_LOAD_ERROR_OUT_OF_MEMORY:
748 msg = " No memory";
749 break;
750 case IMLIB_LOAD_ERROR_OUT_OF_FILE_DESCRIPTORS:
751 msg = "No file decriptors";
752 break;
753 case IMLIB_LOAD_ERROR_OUT_OF_DISK_SPACE:
754 msg = "No disk space";
755 break;
756 case IMLIB_LOAD_ERROR_UNKNOWN:
757 msg = "Unknown error";
758 break;
759 default:
760 g_snprintf(buff, sizeof(buff), "Unrecognised code %d", lerr);
761 msg = buff;
762 }
763
764 LOG(LOG_LEVEL_ERROR, "Error loading %s [%s]", filename, msg);
765 }
766 #endif /* USE_IMLIB2 */
767
768 #ifdef USE_IMLIB2
769 /**************************************************************************//**
770 * Blend an imlib2 image onto a background of the specified color
771 *
772 * The current context image is merged. On return the new image is the
773 * current context image, and the old image is deleted.
774 *
775 * @param filename Filename we're working on (for error reporting)
776 * @param r Background red
777 * @param g Background green
778 * @param g Background blue
779 *
780 * @return 0 for success. On failure the current context image is unchanged.
781 */
782 static int
783 blend_imlib_image_onto_background(const char *filename, int r, int g, int b)
784 {
785 int result = 0;
786 Imlib_Image img = imlib_context_get_image();
787
788 if (img == NULL)
789 {
790 LOG(LOG_LEVEL_ERROR, "No context for blending image");
791 result = 1;
792 }
793 else
794 {
795 int width = imlib_image_get_width();
796 int height = imlib_image_get_height();
797
798 /* Create a suitable image to merge this one onto */
799 Imlib_Image bg = imlib_create_image(width, height);
800 if (bg == NULL)
801 {
802 log_imlib2_error(LOG_LEVEL_ERROR, filename,
803 IMLIB_LOAD_ERROR_OUT_OF_MEMORY);
804 result = 1;
805 }
806 else
807 {
808 imlib_context_set_image(bg);
809 imlib_context_set_color(r, g, b, 0xff);
810 imlib_image_fill_rectangle(0, 0, width, height);
811 imlib_blend_image_onto_image(img, 0,
812 0, 0, width, height,
813 0, 0, width, height);
814 imlib_context_set_image(img);
815 imlib_free_image();
816 imlib_context_set_image(bg);
817 }
818 }
819 return result;
820 }
821 #endif /* USE_IMLIB2 */
822
823 #ifdef USE_IMLIB2
824 /**************************************************************************//**
825 * Scales an imlib2 image
826 *
827 * The current context image is scaled. On return the new image is the
828 * current context image, and the old image is deleted.
829 *
830 * @param filename Filename we're working on (for error reporting)
831 * @param twidth target width
832 * @param theight target height
833 * @return 0 for success
834 */
835 static int
836 scale_imlib_image(const char *filename, int twidth, int theight)
837 {
838 int result = 0;
839 Imlib_Image img = imlib_context_get_image();
840
841 if (img == NULL)
842 {
843 LOG(LOG_LEVEL_ERROR, "No context for scaling image");
844 result = 1;
845 }
846 else
847 {
848 int width = imlib_image_get_width();
849 int height = imlib_image_get_height();
850
851 Imlib_Image newimg = imlib_create_cropped_scaled_image(
852 0, 0, width, height, twidth, theight);
853 if (newimg == NULL)
854 {
855 log_imlib2_error(LOG_LEVEL_ERROR, filename,
856 IMLIB_LOAD_ERROR_OUT_OF_MEMORY);
857 result = 1;
858 }
859 else
860 {
861 imlib_free_image();
862 imlib_context_set_image(newimg);
863 }
864 }
865 return result;
866 }
867 #endif /* USE_IMLIB2 */
868
869 #ifdef USE_IMLIB2
870 /**************************************************************************//**
871 * Zooms an imlib2 image
872 *
873 * @param filename Filename we're working on (for error reporting)
874 * @param twidth target width
875 * @param theight target height
876 * @return 0 for success
877 */
878 static int
879 zoom_imlib_image(const char *filename, int twidth, int theight)
880 {
881 int result = 0;
882 Imlib_Image img = imlib_context_get_image();
883
884 if (img == NULL)
885 {
886 LOG(LOG_LEVEL_ERROR, "No context for zooming image");
887 result = 1;
888 }
889 else
890 {
891 struct box zb;
892 Imlib_Image newimg = NULL;
893 int width = imlib_image_get_width();
894 int height = imlib_image_get_height();
895
896 if (calculate_zoom_box(width, height,
897 twidth, theight, &zb) == 0)
898 {
899 newimg = imlib_create_cropped_scaled_image(
900 zb.left_margin, zb.top_margin,
901 zb.width, zb.height, twidth, theight);
902 }
903 else
904 {
905 /* Can't zoom - scale the image instead */
906 newimg = imlib_create_cropped_scaled_image(
907 0, 0, width, height, twidth, theight);
908 }
909 if (newimg == NULL)
910
911 {
912 log_imlib2_error(LOG_LEVEL_ERROR, filename,
913 IMLIB_LOAD_ERROR_OUT_OF_MEMORY);
914 result = 1;
915 }
916 else
917 {
918 imlib_free_image();
919 imlib_context_set_image(newimg);
920 }
921 }
922 return result;
923 }
924 #endif /* USE_IMLIB2 */
925
926 #ifdef USE_IMLIB2
927 /**************************************************************************//**
928 * Copies imlib2 image data to a bitmap
929 *
930 * @param self bitmap to copy data to
931 * @param out_palette Palette for output bitmap
932 * @return 0 for success
933 */
934 static int
935 copy_imlib_data_to_bitmap(struct xrdp_bitmap *self,
936 const int *out_palette)
937 {
938 int result = 0;
939 Imlib_Image img = imlib_context_get_image();
940
941 if (img == NULL)
942 {
943 LOG(LOG_LEVEL_ERROR, "No context for zooming image");
944 result = 1;
945 }
946 else
947 {
948 int width = imlib_image_get_width();
949 int height = imlib_image_get_height();
950 int i;
951 int j;
952 DATA32 *bdata;
953 int color;
954 xrdp_bitmap_resize(self, width, height);
955
956 bdata = imlib_image_get_data_for_reading_only();
957 for (j = 0 ; j < height; ++j)
958 {
959 for (i = 0 ; i < width ; ++i)
960 {
961 color = (*bdata++ & 0xffffff);
962
963 if (self->bpp == 8)
964 {
965 color = xrdp_bitmap_get_index(self, out_palette, color);
966 }
967 else if (self->bpp == 15)
968 {
969 color = COLOR15((color & 0xff0000) >> 16,
970 (color & 0x00ff00) >> 8,
971 (color & 0x0000ff) >> 0);
972 }
973 else if (self->bpp == 16)
974 {
975 color = COLOR16((color & 0xff0000) >> 16,
976 (color & 0x00ff00) >> 8,
977 (color & 0x0000ff) >> 0);
978 }
979
980 xrdp_bitmap_set_pixel(self, i, j, color);
981 }
982 }
983 }
984
985 return result;
986 }
987 #endif /* USE_IMLIB2 */
988
989 #ifdef USE_IMLIB2
990 /**
991 * Converts an xrdp HCOLOR into RGB values used by imlib2
992 *
993 * @param hcolor Color to convert
994 * @param bpp Bits-per-pixel for the hcolor
995 * @param[out] r Red value
996 * @param[out] g Green value
997 * @param[out] b Blue value
998 */
999 static void hcolor_to_rgb(int hcolor, int bpp, int *r, int *g, int *b)
1000 {
1001 switch (bpp)
1002 {
1003 case 8:
1004 *r = (hcolor & 0x7) << 5;
1005 *g = (hcolor & 0x38) << 2;
1006 *b = (hcolor & 0xc0);
1007 break;
1008
1009 case 15:
1010 SPLITCOLOR15(*r, *g, *b, hcolor);
1011 break;
1012
1013 case 16:
1014 SPLITCOLOR16(*r, *g, *b, hcolor);
1015 break;
1016
1017 default:
1018 /* Beware : HCOLOR is BGR, not RGB */
1019 *r = hcolor & 0xff;
1020 *g = (hcolor >> 8) & 0xff;
1021 *b = (hcolor >> 16) & 0xff;
1022 break;
1023 }
1024 }
1025 #endif
1026
1027 #ifdef USE_IMLIB2
1028 /*****************************************************************************/
1029 int
1030 xrdp_bitmap_load(struct xrdp_bitmap *self, const char *filename,
1031 const int *palette,
1032 int background,
1033 enum xrdp_bitmap_load_transform transform,
1034 int twidth,
1035 int theight)
1036 {
1037 int result = 0;
1038 Imlib_Load_Error lerr;
1039 int free_context_image = 0; /* Set if we've got an image loaded */
1040 Imlib_Image img = imlib_load_image_with_error_return(filename, &lerr);
1041
1042 /* Load the image */
1043 if (img == NULL)
1044 {
1045 log_imlib2_error(LOG_LEVEL_ERROR, filename, lerr);
1046 result = 1;
1047 }
1048 else
1049 {
1050 imlib_context_set_image(img);
1051 free_context_image = 1;
1052 }
1053
1054 /* Sort out the background */
1055 if (result == 0 && imlib_image_has_alpha())
1056 {
1057 int r;
1058 int g;
1059 int b;
1060 hcolor_to_rgb(background, self->bpp, &r, &g, &b);
1061
1062 result = blend_imlib_image_onto_background(filename, r, g, b);
1063 }
1064
1065 if (result == 0)
1066 {
1067 switch (transform)
1068 {
1069 case XBLT_NONE:
1070 break;
1071
1072 case XBLT_SCALE:
1073 result = scale_imlib_image(filename, twidth, theight);
1074 break;
1075
1076 case XBLT_ZOOM:
1077 result = zoom_imlib_image(filename, twidth, theight);
1078 break;
1079
1080 default:
1081 LOG(LOG_LEVEL_WARNING, "Invalid bitmap transform %d specified",
1082 transform);
1083 }
1084 }
1085
1086 if (result == 0)
1087 {
1088 result = copy_imlib_data_to_bitmap(self, palette);
1089 }
1090
1091 if (free_context_image)
1092 {
1093 imlib_free_image();
1094 }
1095
1096 return result;
1097 }
1098 #endif /* USE_IMLIB2 */
119119 }
120120
121121 /*****************************************************************************/
122 static void
123 clear_all_cached_items(struct xrdp_cache *self)
124 {
125 int i;
126 int j;
127
128 if (self == 0)
129 {
130 return;
131 }
132
133 /* free all the cached bitmaps */
134 for (i = 0; i < XRDP_MAX_BITMAP_CACHE_ID; i++)
135 {
136 for (j = 0; j < XRDP_MAX_BITMAP_CACHE_IDX; j++)
137 {
138 xrdp_bitmap_delete(self->bitmap_items[i][j].bitmap);
139 }
140 }
141
142 /* free all the cached font items */
143 for (i = 0; i < 12; i++)
144 {
145 for (j = 0; j < 256; j++)
146 {
147 g_free(self->char_items[i][j].font_item.data);
148 }
149 }
150
151 /* free all the off screen bitmaps */
152 for (i = 0; i < 2000; i++)
153 {
154 xrdp_bitmap_delete(self->os_bitmap_items[i].bitmap);
155 }
156
157 list_delete(self->xrdp_os_del_list);
158
159 /* free all crc lists */
160 for (i = 0; i < XRDP_MAX_BITMAP_CACHE_ID; i++)
161 {
162 for (j = 0; j < 64 * 1024; j++)
163 {
164 list16_deinit(&(self->crc16[i][j]));
165 }
166 }
167 }
168
169 /*****************************************************************************/
122170 void
123171 xrdp_cache_delete(struct xrdp_cache *self)
124172 {
125 int i;
126 int j;
127
128 if (self == 0)
129 {
130 return;
131 }
132
133 /* free all the cached bitmaps */
134 for (i = 0; i < XRDP_MAX_BITMAP_CACHE_ID; i++)
135 {
136 for (j = 0; j < XRDP_MAX_BITMAP_CACHE_IDX; j++)
137 {
138 xrdp_bitmap_delete(self->bitmap_items[i][j].bitmap);
139 }
140 }
141
142 /* free all the cached font items */
143 for (i = 0; i < 12; i++)
144 {
145 for (j = 0; j < 256; j++)
146 {
147 g_free(self->char_items[i][j].font_item.data);
148 }
149 }
150
151 /* free all the off screen bitmaps */
152 for (i = 0; i < 2000; i++)
153 {
154 xrdp_bitmap_delete(self->os_bitmap_items[i].bitmap);
155 }
156
157 list_delete(self->xrdp_os_del_list);
158
159 /* free all crc lists */
160 for (i = 0; i < XRDP_MAX_BITMAP_CACHE_ID; i++)
161 {
162 for (j = 0; j < 64 * 1024; j++)
163 {
164 list16_deinit(&(self->crc16[i][j]));
165 }
166 }
167
173 clear_all_cached_items(self);
168174 g_free(self);
169175 }
170176
175181 {
176182 struct xrdp_wm *wm;
177183 struct xrdp_session *session;
178 int i;
179 int j;
180
181 /* free all the cached bitmaps */
182 for (i = 0; i < XRDP_MAX_BITMAP_CACHE_ID; i++)
183 {
184 for (j = 0; j < XRDP_MAX_BITMAP_CACHE_IDX; j++)
185 {
186 xrdp_bitmap_delete(self->bitmap_items[i][j].bitmap);
187 }
188 }
189
190 /* free all the cached font items */
191 for (i = 0; i < 12; i++)
192 {
193 for (j = 0; j < 256; j++)
194 {
195 g_free(self->char_items[i][j].font_item.data);
196 }
197 }
198184
199185 /* save these */
200186 wm = self->wm;
201187 session = self->session;
188 /* De-allocate any allocated memory */
189 clear_all_cached_items(self);
202190 /* set whole struct to zero */
203191 g_memset(self, 0, sizeof(struct xrdp_cache));
204192 /* set some stuff back */
315315 int cy;
316316 int out_data_bytes;
317317 int count;
318 int error;
318 int tiles_written;
319 int all_tiles_written;
320 int tiles_left;
321 int finished;
319322 char *out_data;
320323 XRDP_ENC_DATA_DONE *enc_done;
321324 FIFO *fifo_processed;
332335 mutex = self->mutex;
333336 event_processed = self->xrdp_encoder_event_processed;
334337
335 error = 1;
336 out_data = NULL;
337 out_data_bytes = 0;
338
339 if ((enc->num_crects > 0) && (enc->num_drects > 0))
340 {
341 alloc_bytes = XRDP_SURCMD_PREFIX_BYTES;
342 alloc_bytes += self->max_compressed_bytes;
343 alloc_bytes += sizeof(struct rfx_tile) * enc->num_crects +
344 sizeof(struct rfx_rect) * enc->num_drects;
345 out_data = g_new(char, alloc_bytes);
346 if (out_data != NULL)
347 {
348 tiles = (struct rfx_tile *)
349 (out_data + XRDP_SURCMD_PREFIX_BYTES +
350 self->max_compressed_bytes);
351 rfxrects = (struct rfx_rect *) (tiles + enc->num_crects);
352
353 count = enc->num_crects;
354 for (index = 0; index < count; index++)
338 all_tiles_written = 0;
339 do
340 {
341 tiles_written = 0;
342 tiles_left = enc->num_crects - all_tiles_written;
343 out_data = NULL;
344 out_data_bytes = 0;
345
346 if ((tiles_left > 0) && (enc->num_drects > 0))
347 {
348 alloc_bytes = XRDP_SURCMD_PREFIX_BYTES;
349 alloc_bytes += self->max_compressed_bytes;
350 alloc_bytes += sizeof(struct rfx_tile) * tiles_left +
351 sizeof(struct rfx_rect) * enc->num_drects;
352 out_data = g_new(char, alloc_bytes);
353 if (out_data != NULL)
355354 {
356 x = enc->crects[index * 4 + 0];
357 y = enc->crects[index * 4 + 1];
358 cx = enc->crects[index * 4 + 2];
359 cy = enc->crects[index * 4 + 3];
360 tiles[index].x = x;
361 tiles[index].y = y;
362 tiles[index].cx = cx;
363 tiles[index].cy = cy;
364 tiles[index].quant_y = 0;
365 tiles[index].quant_cb = 0;
366 tiles[index].quant_cr = 0;
355 tiles = (struct rfx_tile *)
356 (out_data + XRDP_SURCMD_PREFIX_BYTES +
357 self->max_compressed_bytes);
358 rfxrects = (struct rfx_rect *) (tiles + tiles_left);
359
360 count = tiles_left;
361 for (index = 0; index < count; index++)
362 {
363 x = enc->crects[(index + all_tiles_written) * 4 + 0];
364 y = enc->crects[(index + all_tiles_written) * 4 + 1];
365 cx = enc->crects[(index + all_tiles_written) * 4 + 2];
366 cy = enc->crects[(index + all_tiles_written) * 4 + 3];
367 tiles[index].x = x;
368 tiles[index].y = y;
369 tiles[index].cx = cx;
370 tiles[index].cy = cy;
371 tiles[index].quant_y = 0;
372 tiles[index].quant_cb = 0;
373 tiles[index].quant_cr = 0;
374 }
375
376 count = enc->num_drects;
377 for (index = 0; index < count; index++)
378 {
379 x = enc->drects[index * 4 + 0];
380 y = enc->drects[index * 4 + 1];
381 cx = enc->drects[index * 4 + 2];
382 cy = enc->drects[index * 4 + 3];
383 rfxrects[index].x = x;
384 rfxrects[index].y = y;
385 rfxrects[index].cx = cx;
386 rfxrects[index].cy = cy;
387 }
388
389 out_data_bytes = self->max_compressed_bytes;
390 tiles_written = rfxcodec_encode(self->codec_handle,
391 out_data + XRDP_SURCMD_PREFIX_BYTES,
392 &out_data_bytes, enc->data,
393 enc->width, enc->height, enc->width * 4,
394 rfxrects, enc->num_drects,
395 tiles, tiles_left, 0, 0);
367396 }
368
369 count = enc->num_drects;
370 for (index = 0; index < count; index++)
371 {
372 x = enc->drects[index * 4 + 0];
373 y = enc->drects[index * 4 + 1];
374 cx = enc->drects[index * 4 + 2];
375 cy = enc->drects[index * 4 + 3];
376 rfxrects[index].x = x;
377 rfxrects[index].y = y;
378 rfxrects[index].cx = cx;
379 rfxrects[index].cy = cy;
380 }
381
382 out_data_bytes = self->max_compressed_bytes;
383 error = rfxcodec_encode(self->codec_handle,
384 out_data + XRDP_SURCMD_PREFIX_BYTES,
385 &out_data_bytes, enc->data,
386 enc->width, enc->height, enc->width * 4,
387 rfxrects, enc->num_drects,
388 tiles, enc->num_crects, 0, 0);
389 }
390 }
391
392 LOG_DEVEL(LOG_LEVEL_DEBUG, "process_enc_rfx: rfxcodec_encode rv %d", error);
393 /* only if enc_done->comp_bytes is not zero is something sent
394 to the client but you must always send something back even
395 on error so Xorg can get ack */
396 enc_done = g_new0(XRDP_ENC_DATA_DONE, 1);
397 if (enc_done == NULL)
398 {
399 return 1;
400 }
401 enc_done->comp_bytes = error == 0 ? out_data_bytes : 0;
402 enc_done->pad_bytes = XRDP_SURCMD_PREFIX_BYTES;
403 enc_done->comp_pad_data = out_data;
404 enc_done->enc = enc;
405 enc_done->last = 1;
406 enc_done->cx = self->mm->wm->screen->width;
407 enc_done->cy = self->mm->wm->screen->height;
408
409 /* done with msg */
410 /* inform main thread done */
411 tc_mutex_lock(mutex);
412 fifo_add_item(fifo_processed, enc_done);
413 tc_mutex_unlock(mutex);
414 /* signal completion for main thread */
415 g_set_wait_obj(event_processed);
397 }
398
399 LOG_DEVEL(LOG_LEVEL_DEBUG,
400 "process_enc_rfx: rfxcodec_encode tiles_written %d",
401 tiles_written);
402 /* only if enc_done->comp_bytes is not zero is something sent
403 to the client but you must always send something back even
404 on error so Xorg can get ack */
405 enc_done = g_new0(XRDP_ENC_DATA_DONE, 1);
406 if (enc_done == NULL)
407 {
408 return 1;
409 }
410 enc_done->comp_bytes = tiles_written > 0 ? out_data_bytes : 0;
411 enc_done->pad_bytes = XRDP_SURCMD_PREFIX_BYTES;
412 enc_done->comp_pad_data = out_data;
413 enc_done->enc = enc;
414 enc_done->cx = self->mm->wm->screen->width;
415 enc_done->cy = self->mm->wm->screen->height;
416
417 enc_done->continuation = all_tiles_written > 0;
418 if (tiles_written > 0)
419 {
420 all_tiles_written += tiles_written;
421 }
422 finished =
423 (all_tiles_written == enc->num_crects) || (tiles_written < 0);
424 enc_done->last = finished;
425
426 /* done with msg */
427 /* inform main thread done */
428 tc_mutex_lock(mutex);
429 fifo_add_item(fifo_processed, enc_done);
430 tc_mutex_unlock(mutex);
431 /* signal completion for main thread */
432 g_set_wait_obj(event_processed);
433
434 }
435 while (!finished);
416436
417437 return 0;
418438 }
5353 char *comp_pad_data;
5454 struct xrdp_enc_data *enc;
5555 int last; /* true is this is last message for enc */
56 int continuation; /* true if this isn't the start of a frame */
5657 int x;
5758 int y;
5859 int cx;
345345 struct xrdp_cfg_globals *globals;
346346 char resultIP[256];
347347 char *plain; /* base64 decoded string */
348 size_t plain_length; /* length of decoded base64 string */
348349 size_t base64_length; /* length of base64 string */
349350
350351 globals = &self->xrdp_config->cfg_globals;
378379 {
379380 base64_length = g_strlen(value + BASE64PREFIX_LEN);
380381 plain = (char *)g_malloc(base64_length, 0);
381 base64_decode(plain, value + BASE64PREFIX_LEN, base64_length);
382 g_strncpy(value, plain, g_strlen(plain));
382 base64_decode(value + BASE64PREFIX_LEN,
383 plain, base64_length, &plain_length);
384 g_strncpy(value, plain, plain_length);
383385 g_free(plain);
384386 }
385387 else if (g_strncmp(ASK, value, ASK_LEN) == 0)
420422 {
421423 base64_length = g_strlen(value + ASK_LEN + BASE64PREFIX_LEN);
422424 plain = (char *)g_malloc(base64_length, 0);
423 base64_decode(plain, value + ASK_LEN + BASE64PREFIX_LEN, base64_length);
425 base64_decode(value + ASK_LEN + BASE64PREFIX_LEN,
426 plain, base64_length, &plain_length);
427 plain[plain_length] = '\0';
424428 g_strncpy(b->caption1, plain, 255);
425429 g_free(plain);
426430 }
437441
438442 /* Use the domain name as the destination IP/DNS
439443 This is useful in a gateway setup. */
440 if (g_strncmp(name, "ip", 255) == 0)
444 if (g_strncasecmp(name, "ip", 255) == 0)
441445 {
442446 /* If the first char in the domain name is '_' we use the
443447 domain name as IP */
452456
453457 }
454458
455 if (g_strncmp(name, "username", 255) == 0 &&
459 if (g_strncasecmp(name, "username", 255) == 0 &&
456460 self->session->client_info->username[0])
457461 {
458462 g_strncpy(b->caption1, self->session->client_info->username, 255);
464468 }
465469 }
466470
467 if ((g_strncmp(name, "password", 255) == 0) || (g_strncmp(name, "pampassword", 255) == 0))
471 if ((g_strncasecmp(name, "password", 255) == 0) ||
472 (g_strncasecmp(name, "pampassword", 255) == 0))
468473 {
469474 b->password_char = '*';
470475
642647 int log_width;
643648 int log_height;
644649 int regular;
645 int primary_x_offset;
650 int primary_width; /* Dimensions of primary screen */
651 int primary_height;
652 int primary_x_offset; /* Offset of centre of primary screen */
646653 int primary_y_offset;
647654 int index;
648655 int x;
652659
653660 globals = &self->xrdp_config->cfg_globals;
654661
655 primary_x_offset = self->screen->width / 2;
656 primary_y_offset = self->screen->height / 2;
662 primary_width = self->screen->width;
663 primary_height = self->screen->height;
664 primary_x_offset = primary_width / 2;
665 primary_y_offset = primary_height / 2;
657666
658667 log_width = globals->ls_width;
659668 log_height = globals->ls_height;
685694 cx = self->client_info->minfo_wm[index].right;
686695 cy = self->client_info->minfo_wm[index].bottom;
687696
688 primary_x_offset = x + ((cx - x) / 2);
689 primary_y_offset = y + ((cy - y) / 2);
697 primary_width = cx - x;
698 primary_height = cy - y;
699 primary_x_offset = x + (primary_width / 2);
700 primary_y_offset = y + (primary_height / 2);
690701 break;
691702 }
692703 }
724735 {
725736 /* Load the background image. */
726737 /* If no file is specified no default image will be loaded. */
727 /* We only load the image if bpp > 8 */
728 if (globals->ls_background_image[0] != 0 && self->screen->bpp > 8)
729 {
730 char fileName[256] ;
731 but = xrdp_bitmap_create(4, 4, self->screen->bpp, WND_TYPE_IMAGE, self);
732 if (globals->ls_background_image[0] == '/')
738 /* We only load the image if bpp > 8, and if the user hasn't
739 * disabled wallpaer in the performance settings */
740 if (globals->ls_background_image[0] != 0)
741 {
742 if (self->screen->bpp <= 8)
733743 {
734 g_snprintf(fileName, 255, "%s", globals->ls_background_image);
744 LOG(LOG_LEVEL_INFO, "Login background not loaded for bpp=%d",
745 self->screen->bpp);
746 }
747 else if ((self->client_info->rdp5_performanceflags &
748 RDP5_NO_WALLPAPER) != 0)
749 {
750 LOG(LOG_LEVEL_INFO, "Login background not loaded as client "
751 "has requested PERF_DISABLE_WALLPAPER");
735752 }
736753 else
737754 {
738 g_snprintf(fileName, 255, "%s/%s",
739 XRDP_SHARE_PATH, globals->ls_background_image);
755 char fileName[256] ;
756 but = xrdp_bitmap_create(4, 4, self->screen->bpp,
757 WND_TYPE_IMAGE, self);
758 if (globals->ls_background_image[0] == '/')
759 {
760 g_snprintf(fileName, 255, "%s",
761 globals->ls_background_image);
762 }
763 else
764 {
765 g_snprintf(fileName, 255, "%s/%s",
766 XRDP_SHARE_PATH, globals->ls_background_image);
767 }
768 LOG(LOG_LEVEL_DEBUG, "We try to load the following background file: %s", fileName);
769 if (globals->ls_background_transform == XBLT_NONE)
770 {
771 xrdp_bitmap_load(but, fileName, self->palette,
772 globals->ls_top_window_bg_color,
773 globals->ls_background_transform,
774 0, 0);
775 /* Place the background in the bottom right corner */
776 but->left = primary_x_offset + (primary_width / 2) -
777 but->width;
778 but->top = primary_y_offset + (primary_height / 2) -
779 but->height;
780 }
781 else
782 {
783 xrdp_bitmap_load(but, fileName, self->palette,
784 globals->ls_top_window_bg_color,
785 globals->ls_background_transform,
786 primary_width, primary_height);
787 but->left = primary_x_offset - (primary_width / 2);
788 but->top = primary_y_offset - (primary_height / 2);
789 }
790 but->parent = self->screen;
791 but->owner = self->screen;
792 list_add_item(self->screen->child_list, (long)but);
740793 }
741 LOG(LOG_LEVEL_DEBUG, "We try to load the following background file: %s", fileName);
742 xrdp_bitmap_load(but, fileName, self->palette);
743 but->parent = self->screen;
744 but->owner = self->screen;
745 but->left = self->screen->width - but->width;
746 but->top = self->screen->height - but->height;
747 list_add_item(self->screen->child_list, (long)but);
748794 }
749795
750796 /* if logo image not specified, use default */
761807 g_snprintf(globals->ls_logo_filename, 255, "%s/ad256.bmp", XRDP_SHARE_PATH);
762808 }
763809
764 xrdp_bitmap_load(but, globals->ls_logo_filename, self->palette);
810 xrdp_bitmap_load(but, globals->ls_logo_filename, self->palette,
811 globals->ls_bg_color,
812 globals->ls_logo_transform,
813 globals->ls_logo_width,
814 globals->ls_logo_height);
765815 but->parent = self->login_window;
766816 but->owner = self->login_window;
767817 but->left = globals->ls_logo_x_pos;
831881 }
832882
833883 /**
884 * Map a bitmap transform string to a value
885 *
886 * @param param Param we're trying to read
887 * @param str String we're trying to map
888 *
889 * @return enum xrdp_bitmap_load_transform value
890 *
891 * A warning is logged if the string is not recognised
892 *****************************************************************************/
893 static enum xrdp_bitmap_load_transform
894 bitmap_transform_str_to_val(const char *param, const char *str)
895 {
896 enum xrdp_bitmap_load_transform rv;
897 if (g_strcmp(str, "none") == 0)
898 {
899 rv = XBLT_NONE;
900 }
901 else if (g_strcmp(str, "scale") == 0)
902 {
903 rv = XBLT_SCALE;
904 }
905 else if (g_strcmp(str, "zoom") == 0)
906 {
907 rv = XBLT_ZOOM;
908 }
909 else
910 {
911 LOG(LOG_LEVEL_WARNING, "Param '%s' has unrecognised value '%s'"
912 " - assuming 'none'", param, str);
913 rv = XBLT_NONE;
914 }
915
916 return rv;
917 }
918
919 /**
834920 * Load configuration from xrdp.ini file
835921 *
836922 * @param config XRDP configuration to initialise
865951 globals->ls_bg_color = HCOLOR(bpp, xrdp_wm_htoi("dedede"));
866952 globals->ls_width = 350;
867953 globals->ls_height = 350;
954 globals->ls_background_transform = XBLT_NONE;
955 globals->ls_logo_transform = XBLT_NONE;
868956 globals->ls_logo_x_pos = 63;
869957 globals->ls_logo_y_pos = 50;
870958 globals->ls_label_x_pos = 30;
11021190 globals->ls_title[255] = 0;
11031191 }
11041192
1193 else if (g_strncmp(n, "ls_background_image", 255) == 0)
1194 {
1195 g_strncpy(globals->ls_background_image, v, 255);
1196 globals->ls_background_image[255] = 0;
1197 }
1198
1199 else if (g_strncmp(n, "ls_background_transform", 255) == 0)
1200 {
1201 globals->ls_background_transform =
1202 bitmap_transform_str_to_val(n, v);
1203 }
1204
11051205 else if (g_strncmp(n, "ls_logo_filename", 255) == 0)
11061206 {
11071207 g_strncpy(globals->ls_logo_filename, v, 255);
11081208 globals->ls_logo_filename[255] = 0;
11091209 }
1110 else if (g_strncmp(n, "ls_background_image", 255) == 0)
1111 {
1112 g_strncpy(globals->ls_background_image, v, 255);
1113 globals->ls_background_image[255] = 0;
1114 }
1210
1211 else if (g_strncmp(n, "ls_logo_transform", 255) == 0)
1212 {
1213 globals->ls_logo_transform = bitmap_transform_str_to_val(n, v);
1214 }
1215
1216 else if (g_strncmp(n, "ls_logo_width", 64) == 0)
1217 {
1218 globals->ls_logo_width = g_atoi(v);
1219 }
1220
1221 else if (g_strncmp(n, "ls_logo_height", 64) == 0)
1222 {
1223 globals->ls_logo_height = g_atoi(v);
1224 }
1225
11151226 else if (g_strncmp(n, "ls_logo_x_pos", 64) == 0)
11161227 {
11171228 globals->ls_logo_x_pos = g_atoi(v);
2323 #include "xrdp.h"
2424 #include "log.h"
2525 #include "string_calls.h"
26 #include "guid.h"
2627 #include "ms-rdpedisp.h"
2728 #include "ms-rdpbcgr.h"
29
30 #include "libscp_connection.h"
2831
2932 #ifdef USE_PAM
3033 #if defined(HAVE__PAM_TYPES_H)
4144 #include "xrdp_sockets.h"
4245
4346
47 /* Forward declarations */
48 static const char *
49 getPAMError(const int pamError, char *text, int text_bytes);
50 static const char *
51 getPAMAdditionalErrorInfo(const int pamError, struct xrdp_mm *self);
52 static int
53 xrdp_mm_chansrv_connect(struct xrdp_mm *self, const char *ip, const char *port);
54 static void
55 xrdp_mm_connect_sm(struct xrdp_mm *self);
56
4457
4558 /*****************************************************************************/
4659 struct xrdp_mm *
114127
115128 trans_delete(self->chan_trans);
116129 self->chan_trans = 0;
117 self->chan_trans_up = 0;
118130 self->mod_init = 0;
119131 self->mod_exit = 0;
120132 self->mod = 0;
146158
147159 trans_delete(self->sesman_trans);
148160 self->sesman_trans = 0;
149 self->sesman_trans_up = 0;
161 trans_delete(self->pam_auth_trans);
162 self->pam_auth_trans = 0;
150163 list_delete(self->login_names);
151164 list_delete(self->login_values);
152165 g_free(self);
153166 }
154167
168 /**************************************************************************//**
169 * Looks for a string value in the login_names/login_values array
170 *
171 * In the event of multiple matches, the LAST value matched is returned.
172 * This currently allows for values to be replaced by writing a new value
173 * to the end of the list
174 *
175 * Returned strings are valid until the module is destroyed.
176 *
177 * @param self This module
178 * @param aname Name to lookup (case-insensitive)
179 *
180 * @return pointer to value, or NULL if not found.
181 */
182 static const char *
183 xrdp_mm_get_value(struct xrdp_mm *self, const char *aname)
184 {
185 const char *name;
186 const char *value = NULL;
187 unsigned int index = self->login_names->count;
188
189 while (index > 0 && value == NULL)
190 {
191 --index;
192 name = (const char *)list_get_item(self->login_names, index);
193
194 if (name != NULL && g_strcasecmp(name, aname) == 0)
195 {
196 value = (const char *)list_get_item(self->login_values, index);
197 }
198 }
199
200 return value;
201 }
202 /**************************************************************************//**
203 * Looks for a numeric value in the login_names/login_values array
204 *
205 * Returned strings are valid until the module is destroyed.
206 *
207 * @param self This module
208 * @param aname Name to lookup (case-insensitive)
209 * @param def Default to return if value not found.
210 *
211 * @return value from name, or the specified default.
212 */
213 static int
214 xrdp_mm_get_value_int(struct xrdp_mm *self, const char *aname, int def)
215 {
216 const char *value = xrdp_mm_get_value(self, aname);
217
218 return (value == NULL) ? def : g_atoi(value);
219 }
220
221 /*****************************************************************************/
222 /* Send gateway login information to sesman */
223 static int
224 xrdp_mm_send_gateway_login(struct xrdp_mm *self, const char *username,
225 const char *password)
226 {
227 int rv = 0;
228 enum SCP_CLIENT_STATES_E e;
229
230 xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
231 "sending login info to session manager, please wait...");
232
233 e = scp_v0c_gateway_request(self->pam_auth_trans, username, password);
234
235 if (e != SCP_CLIENT_STATE_OK)
236 {
237 xrdp_wm_log_msg(self->wm, LOG_LEVEL_WARNING,
238 "Error sending gateway login request to sesman [%s]",
239 scp_client_state_to_str(e));
240 rv = 1;
241 }
242
243 return rv;
244 }
245
155246 /*****************************************************************************/
156247 /* Send login information to sesman */
157 /* FIXME : This code duplicates functionality in the sesman tools sesrun.c.
158 * When SCP is reworked, a common library function should be used */
159
160248 static int
161249 xrdp_mm_send_login(struct xrdp_mm *self)
162250 {
163 struct stream *s;
164 int rv;
165 int index;
166 int count;
251 enum SCP_CLIENT_STATES_E e;
252 int rv = 0;
167253 int xserverbpp;
168 char *username;
169 char *password;
170 char *name;
171 char *value;
172
173 xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
174 "sending login info to session manager, please wait...");
175 username = 0;
176 password = 0;
177 self->code = 0;
178 xserverbpp = 0;
179 count = self->login_names->count;
180
181 for (index = 0; index < count; index++)
182 {
183 name = (char *)list_get_item(self->login_names, index);
184 value = (char *)list_get_item(self->login_values, index);
185
186 if (g_strcasecmp(name, "username") == 0)
187 {
188 username = value;
189 }
190 else if (g_strcasecmp(name, "password") == 0)
191 {
192 password = value;
193 }
194 else if (g_strcasecmp(name, "code") == 0)
195 {
196 /* this code is either 0 for Xvnc, 10 for X11rdp or 20 for Xorg */
197 self->code = g_atoi(value);
198 }
199 else if (g_strcasecmp(name, "xserverbpp") == 0)
200 {
201 xserverbpp = g_atoi(value);
202 }
203 }
204
205 if ((username == 0) || (password == 0))
206 {
254 const char *username;
255 const char *password;
256
257 username = xrdp_mm_get_value(self, "username");
258 password = xrdp_mm_get_value(self, "password");
259 if (username == NULL || username[0] == '\0')
260 {
261 xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR, "No username is available");
262 rv = 1;
263 }
264 else if (password == NULL)
265 {
266 /* Can't find a password definition at all - even an empty one */
207267 xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
208 "Error finding username and password");
209 return 1;
210 }
211
212 s = trans_get_out_s(self->sesman_trans, 8192);
213 s_push_layer(s, channel_hdr, 8);
214 /* this code is either 0 for Xvnc, 10 for X11rdp or 20 for Xorg */
215 out_uint16_be(s, self->code);
216 index = g_strlen(username);
217 out_uint16_be(s, index);
218 out_uint8a(s, username, index);
219 index = g_strlen(password);
220
221 out_uint16_be(s, index);
222 out_uint8a(s, password, index);
223 out_uint16_be(s, self->wm->screen->width);
224 out_uint16_be(s, self->wm->screen->height);
225
226 /* select and send X server bpp */
227 if (xserverbpp == 0)
228 {
229 if (self->code == 20)
230 {
231 xserverbpp = 24; /* xorgxrdp is always at 24 bpp */
232 }
233 else
234 {
235 xserverbpp = self->wm->screen->bpp; /* use client's bpp */
236 }
237 }
238 out_uint16_be(s, xserverbpp);
239
240 /* send domain */
241 if (self->wm->client_info->domain[0] != '_')
242 {
243 index = g_strlen(self->wm->client_info->domain);
244 out_uint16_be(s, index);
245 out_uint8a(s, self->wm->client_info->domain, index);
268 "No password field is available");
269 rv = 1;
246270 }
247271 else
248272 {
249 out_uint16_be(s, 0);
250 /* out_uint8a(s, "", 0); */
251 }
252
253 /* send program / shell */
254 index = g_strlen(self->wm->client_info->program);
255 out_uint16_be(s, index);
256 out_uint8a(s, self->wm->client_info->program, index);
257
258 /* send directory */
259 index = g_strlen(self->wm->client_info->directory);
260 out_uint16_be(s, index);
261 out_uint8a(s, self->wm->client_info->directory, index);
262
263 /* send client ip */
264 index = g_strlen(self->wm->client_info->client_ip);
265 out_uint16_be(s, index);
266 out_uint8a(s, self->wm->client_info->client_ip, index);
267
268 s_mark_end(s);
269
270 s_pop_layer(s, channel_hdr);
271 /* Version 0 of the protocol to sesman is currently used by XRDP */
272 out_uint32_be(s, 0); /* version */
273 index = (int)(s->end - s->data);
274 out_uint32_be(s, index); /* size */
275
276 rv = trans_force_write(self->sesman_trans);
277
278 if (rv != 0)
279 {
280 xrdp_wm_log_msg(self->wm, LOG_LEVEL_WARNING,
281 "xrdp_mm_send_login: xrdp_mm_send_login failed");
282 }
283
284 return rv;
285 }
286
287 /*****************************************************************************/
288 /* returns error */
289 /* this goes through the login_names looking for one called 'aname'
290 then it copies the corresponding login_values item into 'dest'
291 'dest' must be at least 'dest_len' + 1 bytes in size */
292 static int
293 xrdp_mm_get_value(struct xrdp_mm *self, const char *aname, char *dest,
294 int dest_len)
295 {
296 char *name;
297 char *value;
298 int index;
299 int count;
300 int rv;
301
302 rv = 1;
303 /* find the library name */
304 dest[0] = 0;
305 count = self->login_names->count;
306
307 for (index = 0; index < count; index++)
308 {
309 name = (char *)list_get_item(self->login_names, index);
310 value = (char *)list_get_item(self->login_values, index);
311
312 if ((name == 0) || (value == 0))
313 {
314 break;
315 }
316
317 if (g_strcasecmp(name, aname) == 0)
318 {
319 g_strncpy(dest, value, dest_len);
320 rv = 0;
273 const char *domain;
274
275 /* this code is either 0 for Xvnc, 10 for X11rdp or 20 for Xorg */
276 self->code = xrdp_mm_get_value_int(self, "code", 0);
277
278 xserverbpp = xrdp_mm_get_value_int(self, "xserverbpp",
279 self->wm->screen->bpp);
280
281 domain = self->wm->client_info->domain;
282 /* Don't send domains starting with '_' - see
283 * xrdp_login_wnd.c:xrdp_wm_parse_domain_information()
284 */
285 if (domain[0] == '_')
286 {
287 domain = "";
288 }
289
290 xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
291 "sending login info to session manager. "
292 "Please wait...");
293 e = scp_v0c_create_session_request(self->sesman_trans,
294 username,
295 password,
296 self->code,
297 self->wm->screen->width,
298 self->wm->screen->height,
299 xserverbpp,
300 domain,
301 self->wm->client_info->program,
302 self->wm->client_info->directory,
303 self->wm->client_info->connection_description);
304
305 if (e != SCP_CLIENT_STATE_OK)
306 {
307 xrdp_wm_log_msg(self->wm, LOG_LEVEL_WARNING,
308 "Error sending create session to sesman [%s]",
309 scp_client_state_to_str(e));
310 rv = 1;
321311 }
322312 }
323313
329319 xrdp_mm_setup_mod1(struct xrdp_mm *self)
330320 {
331321 void *func;
332 char lib[256];
322 const char *lib;
333323 char text[256];
334324
335325 if (self == 0)
337327 return 1;
338328 }
339329
340 lib[0] = 0;
341
342 if (xrdp_mm_get_value(self, "lib", lib, 255) != 0)
330 if ((lib = xrdp_mm_get_value(self, "lib")) == NULL)
343331 {
344332 xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
345333 "no library name specified in xrdp.ini, please add "
359347
360348 if (self->mod_handle == 0)
361349 {
362 g_snprintf(text, 255, "%s/%s", XRDP_MODULE_PATH, lib);
350 g_snprintf(text, sizeof(text), "%s/%s", XRDP_MODULE_PATH, lib);
363351 /* Let the main thread load the lib,*/
364352 self->mod_handle = g_xrdp_sync(xrdp_mm_sync_load, (tintptr)text, 0);
365353
447435 self->mod->server_add_char = server_add_char;
448436 self->mod->server_draw_text = server_draw_text;
449437 self->mod->server_reset = server_reset;
438 self->mod->server_get_channel_count = server_get_channel_count;
450439 self->mod->server_query_channel = server_query_channel;
451440 self->mod->server_get_channel_id = server_get_channel_id;
452441 self->mod->server_send_to_channel = server_send_to_channel;
484473
485474 /*****************************************************************************/
486475 static int
487 xrdp_mm_setup_mod2(struct xrdp_mm *self, tui8 *guid)
476 xrdp_mm_setup_mod2(struct xrdp_mm *self)
488477 {
489478 char text[256];
490479 const char *name;
520509 {
521510 use_uds = 1;
522511
523 if (xrdp_mm_get_value(self, "ip", text, 255) == 0)
512 if ((value = xrdp_mm_get_value(self, "ip")) != NULL &&
513 g_strcmp(value, "127.0.0.1") != 0)
524514 {
525 if (g_strcmp(text, "127.0.0.1") != 0)
526 {
527 use_uds = 0;
528 }
515 use_uds = 0;
529516 }
530517
531518 if (use_uds)
564551 self->mod->mod_set_param(self->mod, "hostname", name);
565552 g_snprintf(text, 255, "%d", self->wm->session->client_info->keylayout);
566553 self->mod->mod_set_param(self->mod, "keylayout", text);
567 if (guid != 0)
568 {
569 self->mod->mod_set_param(self->mod, "guid", (char *) guid);
554 if (guid_is_set(&self->guid))
555 {
556 self->mod->mod_set_param(self->mod, "guid", (char *) &self->guid);
570557 }
571558
572559 for (i = 0; i < self->login_names->count; i++)
11761163 int
11771164 xrdp_mm_drdynvc_up(struct xrdp_mm *self)
11781165 {
1179 char enable_dynamic_resize[32];
1166 const char *enable_dynamic_resize;
11801167 int error = 0;
11811168
11821169 LOG_DEVEL(LOG_LEVEL_TRACE, "xrdp_mm_drdynvc_up:");
11831170
1184 xrdp_mm_get_value(self, "enable_dynamic_resizing",
1185 enable_dynamic_resize,
1186 sizeof(enable_dynamic_resize) - 1);
1187
1171 enable_dynamic_resize = xrdp_mm_get_value(self, "enable_dynamic_resizing");
11881172 /*
11891173 * User can disable dynamic resizing if necessary
11901174 */
1191 if (enable_dynamic_resize[0] != '\0' && !g_text2bool(enable_dynamic_resize))
1175 if (enable_dynamic_resize != NULL && enable_dynamic_resize[0] != '\0' &&
1176 !g_text2bool(enable_dynamic_resize))
11921177 {
11931178 LOG(LOG_LEVEL_INFO, "User has disabled dynamic resizing.");
11941179 }
15861571 int size;
15871572 int error;
15881573
1589 if (trans == 0)
1574 if (trans == NULL)
15901575 {
15911576 return 1;
15921577 }
16221607 }
16231608
16241609 /*****************************************************************************/
1625 /* connect to chansrv */
1626 static int
1627 xrdp_mm_connect_chansrv(struct xrdp_mm *self, const char *ip, const char *port)
1628 {
1629 int index;
1630
1631 if (self->wm->client_info->channels_allowed == 0)
1632 {
1633 LOG(LOG_LEVEL_DEBUG, "%s: "
1634 "skip connecting to chansrv because all channels are disabled",
1635 __func__);
1636 return 0;
1637 }
1638
1639 /* connect channel redir */
1640 if ((g_strcmp(ip, "127.0.0.1") == 0) || (ip[0] == 0))
1641 {
1642 /* unix socket */
1643 self->chan_trans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
1644 }
1645 else
1646 {
1647 /* tcp */
1648 self->chan_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
1649 }
1650
1651 self->chan_trans->is_term = g_is_term;
1652 self->chan_trans->si = &(self->wm->session->si);
1653 self->chan_trans->my_source = XRDP_SOURCE_CHANSRV;
1654 self->chan_trans->trans_data_in = xrdp_mm_chan_data_in;
1655 self->chan_trans->header_size = 8;
1656 self->chan_trans->callback_data = self;
1657 self->chan_trans->no_stream_init_on_data_in = 1;
1658 self->chan_trans->extra_flags = 0;
1659
1660 /* try to connect up to 4 times */
1661 for (index = 0; index < 4; index++)
1662 {
1663 if (trans_connect(self->chan_trans, ip, port, 3000) == 0)
1664 {
1665 self->chan_trans_up = 1;
1666 break;
1667 }
1668 if (g_is_term())
1669 {
1670 break;
1671 }
1672 g_sleep(1000);
1673 LOG(LOG_LEVEL_WARNING, "xrdp_mm_connect_chansrv: connect failed "
1674 "trying again...");
1675 }
1676
1677 if (!(self->chan_trans_up))
1678 {
1679 LOG(LOG_LEVEL_ERROR, "xrdp_mm_connect_chansrv: error in "
1680 "trans_connect chan");
1681 }
1682
1683 if (self->chan_trans_up)
1684 {
1685 if (xrdp_mm_trans_send_channel_setup(self, self->chan_trans) != 0)
1686 {
1687 LOG(LOG_LEVEL_ERROR, "xrdp_mm_connect_chansrv: error in "
1688 "xrdp_mm_trans_send_channel_setup");
1689 }
1690 else
1691 {
1692 LOG(LOG_LEVEL_DEBUG, "xrdp_mm_connect_chansrv: chansrv "
1693 "connect successful");
1694 }
1695 }
1696
1697 return 0;
1698 }
16991610
17001611 static void cleanup_sesman_connection(struct xrdp_mm *self)
17011612 {
1613 /* Don't delete these transports here - we may be in
1614 * an auth callback from one of them */
17021615 self->delete_sesman_trans = 1;
1703 self->connected_state = 0;
1616 self->delete_pam_auth_trans = 1;
17041617
17051618 if (self->wm->login_state != WMLS_CLEANUP)
17061619 {
17511664 }
17521665
17531666 /*****************************************************************************/
1754 /* FIXME : This code duplicates functionality in the sesman tools sesrun.c.
1755 * When SCP is reworked, a common library function should be used */
1756 static int
1757 xrdp_mm_process_login_response(struct xrdp_mm *self, struct stream *s)
1758 {
1759 int ok;
1760 int display;
1761 int rv;
1762 char ip[256];
1763 char port[256];
1764 tui8 guid[16];
1765 tui8 *pguid;
1766
1767 rv = 0;
1768 in_uint16_be(s, ok);
1769 in_uint16_be(s, display);
1770 pguid = 0;
1771 if (s_check_rem(s, 16))
1772 {
1773 in_uint8a(s, guid, 16);
1774 pguid = guid;
1775 }
1776 if (ok)
1777 {
1778 self->display = display;
1779 xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
1780 "login successful for display %d", display);
1781
1782 if (xrdp_mm_setup_mod1(self) == 0)
1783 {
1784 if (xrdp_mm_setup_mod2(self, pguid) == 0)
1785 {
1786 xrdp_mm_get_value(self, "ip", ip, 255);
1787 xrdp_wm_set_login_state(self->wm, WMLS_CLEANUP);
1788 self->wm->dragging = 0;
1789
1790 /* connect channel redir */
1791 if ((g_strcmp(ip, "127.0.0.1") == 0) || (ip[0] == 0))
1792 {
1793 g_snprintf(port, 255, XRDP_CHANSRV_STR, display);
1794 }
1795 else
1796 {
1797 g_snprintf(port, 255, "%d", 7200 + display);
1798 }
1799 xrdp_mm_connect_chansrv(self, ip, port);
1800 }
1801 }
1802 }
1803 else
1804 {
1805 xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
1806 "login failed for display %d", display);
1807 xrdp_wm_show_log(self->wm);
1808 if (self->wm->hide_log_window)
1809 {
1810 rv = 1;
1811 }
1812 }
1813
1814 cleanup_sesman_connection(self);
1815 return rv;
1816 }
1817
1818 /*****************************************************************************/
18191667 static int
18201668 xrdp_mm_get_sesman_port(char *port, int port_bytes)
18211669 {
18901738
18911739 rv = 0;
18921740
1893 if ((self->chan_trans != 0) && self->chan_trans_up)
1741 if ((self->chan_trans != 0) && self->chan_trans->status == TRANS_STATUS_UP)
18941742 {
18951743 s = trans_get_out_s(self->chan_trans, 8192);
18961744
19261774 }
19271775
19281776 /*****************************************************************************/
1777 static void
1778 xrdp_mm_scp_process_msg(struct xrdp_mm *self,
1779 const struct scp_v0_reply_type *msg)
1780 {
1781 if (msg->is_gw_auth_response)
1782 {
1783 const char *additionalError;
1784 char pam_error[128];
1785
1786 /* We no longer need the pam_auth transport - it's only used
1787 * for the one message */
1788 self->delete_pam_auth_trans = 1;
1789
1790 xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
1791 "Reply from access control: %s",
1792 getPAMError(msg->auth_result,
1793 pam_error, sizeof(pam_error)));
1794
1795 if (msg->auth_result != 0)
1796 {
1797 additionalError = getPAMAdditionalErrorInfo(msg->auth_result, self);
1798 if (additionalError && additionalError[0])
1799 {
1800 xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, "%s",
1801 additionalError);
1802 }
1803
1804 /* TODO : Check this is displayed */
1805 cleanup_sesman_connection(self);
1806 xrdp_wm_mod_connect_done(self->wm, 1);
1807 }
1808 else
1809 {
1810 /* Authentication successful */
1811 xrdp_mm_connect_sm(self);
1812 }
1813 }
1814 else
1815 {
1816 const char *username;
1817 char displayinfo[64];
1818 int auth_successful = (msg->auth_result != 0);
1819
1820 /* Sort out some logging information */
1821 if ((username = xrdp_mm_get_value(self, "username")) == NULL)
1822 {
1823 username = "???";
1824 }
1825
1826 if (msg->display == 0)
1827 {
1828 /* A returned display of zero doesn't mean anything useful, and
1829 * can confuse the user. It's most likely authentication has
1830 * failed and no display was allocated */
1831 displayinfo[0] = '\0';
1832 }
1833 else
1834 {
1835 g_snprintf(displayinfo, sizeof(displayinfo),
1836 " on display %d", msg->display);
1837 }
1838
1839 xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
1840 "login %s for user %s%s",
1841 (auth_successful ? "successful" : "failed"),
1842 username, displayinfo);
1843
1844 if (!auth_successful)
1845 {
1846 /* Authentication failure */
1847 cleanup_sesman_connection(self);
1848 xrdp_wm_mod_connect_done(self->wm, 1);
1849 }
1850 else
1851 {
1852 /* Authentication successful - carry on with the connect
1853 * state machine */
1854 self->display = msg->display;
1855 self->guid = msg->guid;
1856 xrdp_mm_connect_sm(self);
1857 }
1858 }
1859 }
1860
1861 /*****************************************************************************/
19291862 /* This is the callback registered for sesman communication replies. */
19301863 static int
1931 xrdp_mm_sesman_data_in(struct trans *trans)
1932 {
1933 struct xrdp_mm *self;
1934 struct stream *s;
1935 int version;
1936 int size;
1937 int error;
1938 int code;
1939
1940 if (trans == 0)
1941 {
1942 return 1;
1943 }
1944
1945 self = (struct xrdp_mm *)(trans->callback_data);
1946 s = trans_get_in_s(trans);
1947
1948 if (s == 0)
1949 {
1950 return 1;
1951 }
1952
1953 in_uint32_be(s, version);
1954 in_uint32_be(s, size);
1955 error = trans_force_read(trans, size - 8);
1956
1957 if (error == 0)
1958 {
1959 in_uint16_be(s, code);
1960
1961 switch (code)
1962 {
1963 /* even when the request is denied the reply will hold 3 as the command. */
1964 case 3:
1965 error = xrdp_mm_process_login_response(self, s);
1966 break;
1967 default:
1968 xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
1969 "Undefined reply code %d received from sesman",
1970 code);
1971 cleanup_sesman_connection(self);
1972 break;
1973 }
1974 }
1975
1976 return error;
1977 }
1978
1979 #ifdef USE_PAM
1980 /*********************************************************************/
1981 /* return 0 on success */
1982 static int
1983 access_control(char *username, char *password, char *srv)
1984 {
1985 int reply;
1986 int rec = 32 + 1; /* 32 is reserved for PAM failures this means connect failure */
1987 struct stream *in_s;
1988 struct stream *out_s;
1989 unsigned long version;
1990 unsigned short int dummy;
1991 unsigned short int pAM_errorcode;
1992 unsigned short int code;
1993 unsigned long size;
1994 int index;
1995 int socket = g_tcp_socket();
1996 char port[8];
1997
1998 if (socket != -1)
1999 {
2000 xrdp_mm_get_sesman_port(port, sizeof(port));
2001 /* we use a blocking socket here */
2002 reply = g_tcp_connect(socket, srv, port);
2003
2004 if (reply == 0)
2005 {
2006 make_stream(in_s);
2007 init_stream(in_s, 500);
2008 make_stream(out_s);
2009 init_stream(out_s, 500);
2010 s_push_layer(out_s, channel_hdr, 8);
2011 out_uint16_be(out_s, 4); /*0x04 means SCP_GW_AUTHENTICATION*/
2012 index = g_strlen(username);
2013 out_uint16_be(out_s, index);
2014 out_uint8a(out_s, username, index);
2015
2016 index = g_strlen(password);
2017 out_uint16_be(out_s, index);
2018 out_uint8a(out_s, password, index);
2019 s_mark_end(out_s);
2020 s_pop_layer(out_s, channel_hdr);
2021 out_uint32_be(out_s, 0); /* version */
2022 index = (int)(out_s->end - out_s->data);
2023 out_uint32_be(out_s, index); /* size */
2024 LOG(LOG_LEVEL_DEBUG, "Number of data to send : %d", index);
2025 reply = g_tcp_send(socket, out_s->data, index, 0);
2026 free_stream(out_s);
2027
2028 if (reply > 0)
2029 {
2030 /* We wait in 5 sec for a reply from sesman*/
2031 if (g_sck_can_recv(socket, 5000))
2032 {
2033 reply = g_tcp_recv(socket, in_s->end, 500, 0);
2034
2035 if (reply > 0)
2036 {
2037 in_s->end = in_s->end + reply;
2038 in_uint32_be(in_s, version);
2039 LOG(LOG_LEVEL_INFO, "Version number in reply from sesman: %lu", version);
2040 in_uint32_be(in_s, size);
2041
2042 if ((size == 14) && (version == 0))
2043 {
2044 in_uint16_be(in_s, code);
2045 in_uint16_be(in_s, pAM_errorcode); /* this variable holds the PAM error code if the variable is >32 it is a "invented" code */
2046 in_uint16_be(in_s, dummy);
2047
2048 if (code != 4) /*0x04 means SCP_GW_AUTHENTICATION*/
2049 {
2050 LOG(LOG_LEVEL_ERROR, "Returned cmd code from "
2051 "sesman is corrupt");
2052 }
2053 else
2054 {
2055 rec = pAM_errorcode; /* here we read the reply from the access control */
2056 }
2057 }
2058 else
2059 {
2060 LOG(LOG_LEVEL_ERROR, "Corrupt reply size or "
2061 "version from sesman: %ld", size);
2062 }
2063 }
2064 else
2065 {
2066 LOG(LOG_LEVEL_ERROR, "No data received from sesman");
2067 }
2068 }
2069 else
2070 {
2071 LOG(LOG_LEVEL_ERROR, "Timeout when waiting for sesman");
2072 }
2073 }
2074 else
2075 {
2076 LOG(LOG_LEVEL_ERROR, "No success sending to sesman");
2077 }
2078
2079 free_stream(in_s);
2080 g_tcp_close(socket);
1864 xrdp_mm_scp_data_in(struct trans *trans)
1865 {
1866 int rv = 0;
1867
1868 if (trans == NULL)
1869 {
1870 rv = 1;
1871 }
1872 else if (scp_v0c_reply_available(trans))
1873 {
1874 struct scp_v0_reply_type reply;
1875 struct xrdp_mm *self = (struct xrdp_mm *)(trans->callback_data);
1876 enum SCP_CLIENT_STATES_E e = scp_v0c_get_reply(trans, &reply);
1877 if (e != SCP_CLIENT_STATE_OK)
1878 {
1879 const char *src = (trans == self->pam_auth_trans)
1880 ? "PAM authenticator"
1881 : "sesman";
1882 xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
1883 "Error reading response from %s [%s]",
1884 src, scp_client_state_to_str(e));
1885 rv = 1;
20811886 }
20821887 else
20831888 {
2084 LOG(LOG_LEVEL_ERROR, "Failure connecting to socket sesman");
2085 }
2086 }
2087 else
2088 {
2089 LOG(LOG_LEVEL_ERROR, "Failure creating socket - for access control");
2090 }
2091
2092 if (socket != -1)
2093 {
2094 g_tcp_close(socket);
2095 }
2096
2097 return rec;
2098 }
2099 #endif
1889 xrdp_mm_scp_process_msg(self, &reply);
1890 }
1891 }
1892
1893 return rv;
1894 }
21001895
21011896 /*****************************************************************************/
21021897 /* This routine clears all states to make sure that our next login will be
21071902 {
21081903 if (self != NULL)
21091904 {
2110 self-> connected_state = 0; /* true if connected to sesman else false */
2111 self-> sesman_trans = NULL; /* connection to sesman */
2112 self-> sesman_trans_up = 0; /* true once connected to sesman */
2113 self-> delete_sesman_trans = 0; /* boolean set when done with sesman connection */
2114 self-> display = 0; /* 10 for :10.0, 11 for :11.0, etc */
2115 self-> code = 0; /* 0 Xvnc session, 10 X11rdp session, 20 Xorg session */
2116 self-> sesman_controlled = 0; /* true if this is a sesman session */
2117 self-> chan_trans = NULL; /* connection to chansrv */
2118 self-> chan_trans_up = 0; /* true once connected to chansrv */
2119 self-> delete_chan_trans = 0; /* boolean set when done with channel connection */
2120 self-> usechansrv = 0; /* true if chansrvport is set in xrdp.ini or using sesman */
2121 }
2122 }
2123
2124 #ifdef USE_PAM
1905 self->connect_state = MMCS_CONNECT_TO_SESMAN;
1906 self->use_sesman = 0; /* true if this is a sesman session */
1907 self->use_chansrv = 0; /* true if chansrvport is set in xrdp.ini or using sesman */
1908 self->use_pam_auth = 0; /* true if we're to use the PAM authentication facility */
1909 self->sesman_trans = NULL; /* connection to sesman */
1910 self->pam_auth_trans = NULL; /* connection to PAM authenticator */
1911 self->chan_trans = NULL; /* connection to chansrv */
1912 self->delete_sesman_trans = 0;
1913 self->delete_pam_auth_trans = 0;
1914 self->display = 0; /* 10 for :10.0, 11 for :11.0, etc */
1915 guid_clear(&self->guid);
1916 self->code = 0; /* 0 Xvnc session, 10 X11rdp session, 20 Xorg session */
1917 }
1918 }
1919
21251920 static const char *
21261921 getPAMError(const int pamError, char *text, int text_bytes)
21271922 {
21901985 return "Error connecting to PAM";
21911986 case 32 + 3:
21921987 return "Username okey but group problem";
2193 default:
2194 g_snprintf(text, text_bytes, "Not defined PAM error:%d", pamError);
2195 return text;
21961988 #elif defined(OPENPAM)
21971989 case PAM_SUCCESS: /* 0 */
21981990 return "Success";
22542046 return "Module is unknown";
22552047 case PAM_DOMAIN_UNKNOWN: /* 29 */
22562048 return "Unknown authentication domain";
2049 #endif
22572050 default:
22582051 g_snprintf(text, text_bytes, "Not defined PAM error:%d", pamError);
22592052 return text;
2260 #endif
22612053 }
22622054 }
22632055
23082100 {
23092101 return "Authentication error - Verify that user/password is valid";
23102102 }
2311 default:
2312 return "No expected error";
23132103 #elif defined(OPENPAM)
23142104 case PAM_SUCCESS: /* 0 */
23152105 return NULL;
23502140 {
23512141 return "Authentication error - Verify that user/password is valid";
23522142 }
2143 #endif
23532144 default:
23542145 return "No expected error";
2355 #endif
2356 }
2357 }
2358 #endif
2146 }
2147 }
23592148
23602149 /*************************************************************************//**
23612150 * Parses a chansrvport string
24062195 }
24072196
24082197 /*****************************************************************************/
2409 int
2198 static struct trans *
2199 xrdp_mm_scp_connect(struct xrdp_mm *self, const char *target, const char *ip)
2200 {
2201 char port[128];
2202 struct trans *t;
2203
2204 xrdp_mm_get_sesman_port(port, sizeof(port));
2205 xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
2206 "connecting to %s on %s:%s", target, ip, port);
2207 t = scp_connect(ip, port, g_is_term,
2208 xrdp_mm_scp_data_in, self);
2209 if (t != NULL)
2210 {
2211 /* fully connect */
2212 xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, "%s connect ok", target);
2213 }
2214 else
2215 {
2216 xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
2217 "Error connecting to %s on %s:%s",
2218 target, ip, port);
2219 trans_delete(t);
2220 t = NULL;
2221 }
2222 return t;
2223 }
2224
2225 /*****************************************************************************/
2226 static int
2227 xrdp_mm_pam_auth_connect(struct xrdp_mm *self, const char *ip)
2228 {
2229 trans_delete(self->pam_auth_trans);
2230 self->pam_auth_trans = xrdp_mm_scp_connect(self, "PAM authenticator", ip);
2231
2232 return (self->pam_auth_trans == NULL); /* 0 for success */
2233 }
2234
2235 /*****************************************************************************/
2236 static int
2237 xrdp_mm_sesman_connect(struct xrdp_mm *self, const char *ip)
2238 {
2239 trans_delete(self->sesman_trans);
2240 self->sesman_trans = xrdp_mm_scp_connect(self, "sesman", ip);
2241
2242 return (self->sesman_trans == NULL); /* 0 for success */
2243 }
2244
2245 /*****************************************************************************/
2246 static int
2247 xrdp_mm_chansrv_connect(struct xrdp_mm *self, const char *ip, const char *port)
2248 {
2249 int index;
2250
2251 if (self->wm->client_info->channels_allowed == 0)
2252 {
2253 LOG(LOG_LEVEL_DEBUG, "%s: "
2254 "skip connecting to chansrv because all channels are disabled",
2255 __func__);
2256 return 0;
2257 }
2258
2259 /* connect channel redir */
2260 if ((g_strcmp(ip, "127.0.0.1") == 0) || (ip[0] == 0))
2261 {
2262 /* unix socket */
2263 self->chan_trans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
2264 }
2265 else
2266 {
2267 /* tcp */
2268 self->chan_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
2269 }
2270
2271 self->chan_trans->is_term = g_is_term;
2272 self->chan_trans->si = &(self->wm->session->si);
2273 self->chan_trans->my_source = XRDP_SOURCE_CHANSRV;
2274 self->chan_trans->trans_data_in = xrdp_mm_chan_data_in;
2275 self->chan_trans->header_size = 8;
2276 self->chan_trans->callback_data = self;
2277 self->chan_trans->no_stream_init_on_data_in = 1;
2278 self->chan_trans->extra_flags = 0;
2279
2280 /* try to connect up to 4 times */
2281 for (index = 0; index < 4; index++)
2282 {
2283 if (trans_connect(self->chan_trans, ip, port, 3000) == 0)
2284 {
2285 break;
2286 }
2287 if (g_is_term())
2288 {
2289 break;
2290 }
2291 g_sleep(1000);
2292 LOG(LOG_LEVEL_WARNING, "xrdp_mm_chansrv_connect: connect failed "
2293 "trying again...");
2294 }
2295
2296 if (self->chan_trans->status != TRANS_STATUS_UP)
2297 {
2298 LOG(LOG_LEVEL_ERROR, "xrdp_mm_chansrv_connect: error in "
2299 "trans_connect chan");
2300 }
2301 else if (xrdp_mm_trans_send_channel_setup(self, self->chan_trans) != 0)
2302 {
2303 LOG(LOG_LEVEL_ERROR, "xrdp_mm_chansrv_connect: error in "
2304 "xrdp_mm_trans_send_channel_setup");
2305 trans_delete(self->chan_trans);
2306 self->chan_trans = NULL;
2307 }
2308 else
2309 {
2310 LOG(LOG_LEVEL_DEBUG, "xrdp_mm_chansrv_connect: chansrv "
2311 "connect successful");
2312 }
2313
2314 return 0;
2315 }
2316
2317 /*****************************************************************************/
2318 static int
2319 xrdp_mm_user_session_connect(struct xrdp_mm *self)
2320 {
2321 int rv = 0;
2322
2323 if (xrdp_mm_setup_mod1(self) != 0)
2324 {
2325 LOG(LOG_LEVEL_ERROR, "Failure setting up module");
2326 xrdp_mm_module_cleanup(self);
2327 rv = 1;
2328 }
2329 else if (xrdp_mm_setup_mod2(self) != 0)
2330 {
2331 /* connect error */
2332 xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
2333 "Error connecting to user session");
2334 xrdp_mm_module_cleanup(self);
2335 rv = 1; /* failure */
2336 }
2337
2338 LOG_DEVEL(LOG_LEVEL_DEBUG, "return value from %s %d", __func__, rv);
2339
2340 return rv;
2341 }
2342
2343 /**************************************************************************//**
2344 * Initialise and start the connect sequence
2345 *
2346 * @param self This object
2347 */
2348 void
24102349 xrdp_mm_connect(struct xrdp_mm *self)
24112350 {
2412 struct list *names;
2413 struct list *values;
2414 int index;
2415 int count;
2416 int ok;
2417 int rv;
2418 char *name;
2419 char *value;
2420 char ip[256];
2421 char port[8];
2422 char chansrvport[256];
2423 #ifdef USE_PAM
2424 int use_pam_auth = 0;
2425 char pam_auth_sessionIP[256];
2426 char pam_auth_password[256];
2427 char pam_auth_username[256];
2428 #endif
2429 char username[256];
2430 char password[256];
2431 username[0] = 0;
2432 password[0] = 0;
2351 const char *port = xrdp_mm_get_value(self, "port");
2352 const char *gateway_username = xrdp_mm_get_value(self, "pamusername");
24332353
24342354 /* make sure we start in correct state */
24352355 cleanup_states(self);
2436 g_memset(ip, 0, sizeof(ip));
2437 g_memset(port, 0, sizeof(port));
2438 g_memset(chansrvport, 0, sizeof(chansrvport));
2439 rv = 0; /* success */
2440 names = self->login_names;
2441 values = self->login_values;
2442 count = names->count;
2443
2444 for (index = 0; index < count; index++)
2445 {
2446 name = (char *)list_get_item(names, index);
2447 value = (char *)list_get_item(values, index);
2448
2449 if (g_strcasecmp(name, "ip") == 0)
2450 {
2451 g_strncpy(ip, value, 255);
2452 }
2453 else if (g_strcasecmp(name, "port") == 0)
2454 {
2455 if (g_strcasecmp(value, "-1") == 0)
2356
2357 /* Look at our module parameters to decide if we need to connect
2358 * to sesman or not */
2359
2360 if (port != NULL && g_strcmp(port, "-1") == 0)
2361 {
2362 self->use_sesman = 1;
2363 }
2364
2365 if (gateway_username != NULL)
2366 {
2367 #ifdef USE_PAM
2368 self->use_pam_auth = 1;
2369 #else
2370 xrdp_wm_log_msg(self->wm, LOG_LEVEL_WARNING,
2371 "pamusername parameter ignored - "
2372 "xrdp is compiled without PAM support");
2373 #endif
2374 }
2375
2376 /* Will we need chansrv ? We use it unconditionally for a
2377 * sesman session, but the user can also request it separately */
2378 if (self->use_sesman)
2379 {
2380 self->use_chansrv = 1;
2381 }
2382 else
2383 {
2384 const char *csp = xrdp_mm_get_value(self, "chansrvport");
2385 /* It's defined, but is it a valid string? */
2386 if (csp != NULL && parse_chansrvport(csp, NULL, 0) == 0)
2387 {
2388 self->use_chansrv = 1;
2389 }
2390 }
2391
2392 xrdp_mm_connect_sm(self);
2393 }
2394
2395 /*****************************************************************************/
2396 static void
2397 xrdp_mm_connect_sm(struct xrdp_mm *self)
2398 {
2399 int status = 0;
2400 int waiting_for_msg = 0; /* Set this to leave the sm to wait for a reply */
2401
2402 while (status == 0 && !waiting_for_msg && self->connect_state != MMCS_DONE)
2403 {
2404 switch (self->connect_state)
2405 {
2406 case MMCS_CONNECT_TO_SESMAN:
24562407 {
2457 self->sesman_controlled = 1;
2458 self->usechansrv = 1;
2408 if (self->use_sesman)
2409 {
2410 /* Synchronous call */
2411 const char *ip = xrdp_mm_get_value(self, "ip");
2412 status = xrdp_mm_sesman_connect(self, ip);
2413 }
2414
2415 if (status == 0 && self->use_pam_auth)
2416 {
2417 /* Synchronous call */
2418 const char *ip = xrdp_mm_get_value(self, "pamsessionmng");
2419 if (ip == NULL)
2420 {
2421 ip = xrdp_mm_get_value(self, "ip");
2422 }
2423 status = xrdp_mm_pam_auth_connect(self, ip);
2424 }
24592425 }
2460 }
2461
2462 #ifdef USE_PAM
2463 else if (g_strcasecmp(name, "pamusername") == 0)
2464 {
2465 use_pam_auth = 1;
2466 g_strncpy(pam_auth_username, value, 255);
2467 }
2468 else if (g_strcasecmp(name, "pamsessionmng") == 0)
2469 {
2470 g_strncpy(pam_auth_sessionIP, value, 255);
2471 }
2472 else if (g_strcasecmp(name, "pampassword") == 0)
2473 {
2474 g_strncpy(pam_auth_password, value, 255);
2475 }
2476 #endif
2477 else if (g_strcasecmp(name, "password") == 0)
2478 {
2479 g_strncpy(password, value, 255);
2480 }
2481 else if (g_strcasecmp(name, "username") == 0)
2482 {
2483 g_strncpy(username, value, 255);
2484 }
2485 else if (g_strcasecmp(name, "chansrvport") == 0)
2486 {
2487 if (parse_chansrvport(value, chansrvport, sizeof(chansrvport)) == 0)
2426 break;
2427
2428 case MMCS_PAM_AUTH:
24882429 {
2489 self->usechansrv = 1;
2430 if (self->use_pam_auth)
2431 {
2432 const char *gateway_username;
2433 const char *gateway_password;
2434
2435 gateway_username = xrdp_mm_get_value(self, "pamusername");
2436 gateway_password = xrdp_mm_get_value(self, "pampassword");
2437 if (!g_strcmp(gateway_username, "same"))
2438 {
2439 gateway_username = xrdp_mm_get_value(self, "username");
2440 }
2441
2442 if (gateway_password == NULL ||
2443 !g_strcmp(gateway_password, "same"))
2444 {
2445 gateway_password = xrdp_mm_get_value(self, "password");
2446 }
2447
2448 if (gateway_username == NULL || gateway_password == NULL)
2449 {
2450 xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
2451 "Can't determine username and/or "
2452 "password for gateway authorization");
2453 status = 1;
2454 }
2455 else
2456 {
2457 xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
2458 "Performing access control for %s",
2459 gateway_username);
2460
2461 status = xrdp_mm_send_gateway_login(self,
2462 gateway_username,
2463 gateway_password);
2464 if (status == 0)
2465 {
2466 /* Now waiting for a reply from sesman */
2467 waiting_for_msg = 1;
2468 }
2469 }
2470 }
24902471 }
2491 }
2492 }
2493
2494 xrdp_mm_update_allowed_channels(self);
2495
2496 #ifdef USE_PAM
2497 if (use_pam_auth)
2498 {
2499 int reply;
2500 char pam_error[128];
2501 const char *additionalError;
2502 xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
2503 "Please wait, we now perform access control...");
2504
2505 LOG(LOG_LEVEL_DEBUG, "we use pam modules to check if we can approve this user");
2506 if (!g_strncmp(pam_auth_username, "same", 255))
2507 {
2508 LOG(LOG_LEVEL_DEBUG, "pamusername copied from username - same: %s", username);
2509 g_strncpy(pam_auth_username, username, 255);
2510 }
2511
2512 if (!g_strncmp(pam_auth_password, "same", 255))
2513 {
2514 LOG(LOG_LEVEL_DEBUG, "pam_auth_password copied from username - same: %s", password);
2515 g_strncpy(pam_auth_password, password, 255);
2516 }
2517
2518 /* access_control return 0 on success */
2519 reply = access_control(pam_auth_username, pam_auth_password, pam_auth_sessionIP);
2520
2521 xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO,
2522 "Reply from access control: %s",
2523 getPAMError(reply, pam_error, 127));
2524
2525 additionalError = getPAMAdditionalErrorInfo(reply, self);
2526 if (additionalError && additionalError[0])
2527 {
2528 xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, "%s", additionalError);
2529 }
2530
2531 if (reply != 0)
2532 {
2533 rv = 1;
2534 return rv;
2535 }
2536 }
2537 #endif
2538
2539 if (self->sesman_controlled)
2540 {
2541 ok = 0;
2542 trans_delete(self->sesman_trans);
2543 self->sesman_trans = trans_create(TRANS_MODE_TCP, 8192, 8192);
2544 self->sesman_trans->is_term = g_is_term;
2545 xrdp_mm_get_sesman_port(port, sizeof(port));
2546 xrdp_wm_log_msg(self->wm, LOG_LEVEL_DEBUG,
2547 "connecting to sesman ip %s port %s", ip, port);
2548 /* xrdp_mm_sesman_data_in is the callback that is called when data arrives */
2549 self->sesman_trans->trans_data_in = xrdp_mm_sesman_data_in;
2550 self->sesman_trans->header_size = 8;
2551 self->sesman_trans->callback_data = self;
2552
2553 /* try to connect up to 4 times */
2554 for (index = 0; index < 4; index++)
2555 {
2556 if (trans_connect(self->sesman_trans, ip, port, 3000) == 0)
2472 break;
2473
2474 case MMCS_SESSION_AUTH:
25572475 {
2558 self->sesman_trans_up = 1;
2559 ok = 1;
2560 break;
2476 if (self->use_sesman)
2477 {
2478 if ((status = xrdp_mm_send_login(self)) == 0)
2479 {
2480 /* Now waiting for a reply from sesman */
2481 waiting_for_msg = 1;
2482 }
2483 }
25612484 }
2562 if (g_is_term())
2485 break;
2486
2487 case MMCS_CONNECT_TO_SESSION:
25632488 {
2564 break;
2489 /* This is synchronous - no reply message expected */
2490 status = xrdp_mm_user_session_connect(self);
25652491 }
2566 g_sleep(1000);
2567 LOG(LOG_LEVEL_INFO, "xrdp_mm_connect: connect failed "
2568 "trying again...");
2569 }
2570
2571 if (ok)
2572 {
2573 /* fully connect */
2574 xrdp_wm_log_msg(self->wm, LOG_LEVEL_INFO, "sesman connect ok");
2575 self->connected_state = 1;
2576 rv = xrdp_mm_send_login(self);
2577 }
2578 else
2579 {
2580 xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
2581 "Error connecting to sesman: %s port: %s",
2582 ip, port);
2583 trans_delete(self->sesman_trans);
2584 self->sesman_trans = 0;
2585 self->sesman_trans_up = 0;
2586 rv = 1;
2587 }
2588 }
2589 else /* no sesman */
2590 {
2591 if (xrdp_mm_setup_mod1(self) == 0)
2592 {
2593 if (xrdp_mm_setup_mod2(self, 0) == 0)
2492 break;
2493
2494 case MMCS_CONNECT_TO_CHANSRV:
25942495 {
2595 xrdp_wm_set_login_state(self->wm, WMLS_CLEANUP);
2596 rv = 0; /*success*/
2496 if (self->use_chansrv)
2497 {
2498 const char *ip = "";
2499 char portbuff[256];
2500
2501 if (self->use_sesman)
2502 {
2503 ip = xrdp_mm_get_value(self, "ip");
2504
2505 /* connect channel redir */
2506 if (ip == NULL || (ip[0] == '\0') ||
2507 (g_strcmp(ip, "127.0.0.1") == 0))
2508 {
2509 g_snprintf(portbuff, sizeof(portbuff),
2510 XRDP_CHANSRV_STR, self->display);
2511 }
2512 else
2513 {
2514 g_snprintf(portbuff, sizeof(portbuff),
2515 "%d", 7200 + self->display);
2516 }
2517 }
2518 else
2519 {
2520 const char *cp = xrdp_mm_get_value(self, "chansrvport");
2521 portbuff[0] = '\0';
2522 parse_chansrvport(cp, portbuff, sizeof(portbuff));
2523
2524 }
2525 xrdp_mm_update_allowed_channels(self);
2526 xrdp_mm_chansrv_connect(self, ip, portbuff);
2527 }
25972528 }
2598 else
2529 break;
2530
2531 case MMCS_DONE:
25992532 {
2600 /* connect error */
2601 xrdp_wm_log_msg(self->wm, LOG_LEVEL_ERROR,
2602 "Error connecting to: %s", ip);
2603 rv = 1; /* failure */
2533 /* Shouldn't get here */
2534 LOG(LOG_LEVEL_ERROR, "xrdp_mm_connect_sm: state machine error");
2535 status = 1;
26042536 }
2605 }
2606 else
2607 {
2608 LOG(LOG_LEVEL_ERROR, "Failure setting up module");
2609 }
2610
2611 if (self->wm->login_state != WMLS_CLEANUP)
2612 {
2613 xrdp_wm_set_login_state(self->wm, WMLS_INACTIVE);
2614 xrdp_mm_module_cleanup(self);
2615 rv = 1; /* failure */
2616 }
2617 }
2618
2619 if ((self->wm->login_state == WMLS_CLEANUP) && (self->sesman_controlled == 0) &&
2620 (self->usechansrv != 0))
2621 {
2622 /* if sesman controlled, this will connect later */
2623 xrdp_mm_connect_chansrv(self, "", chansrvport);
2624 }
2625
2626 LOG(LOG_LEVEL_DEBUG, "return value from xrdp_mm_connect %d", rv);
2627
2628 return rv;
2629 }
2537 break;
2538 }
2539
2540 /* Move to the next state */
2541 if (self->connect_state < MMCS_DONE)
2542 {
2543 self->connect_state = (enum mm_connect_state)
2544 (self->connect_state + 1);
2545 }
2546 }
2547
2548 if (!waiting_for_msg)
2549 {
2550 xrdp_wm_mod_connect_done(self->wm, status);
2551 cleanup_sesman_connection(self);
2552 }
2553 }
2554
26302555
26312556 /*****************************************************************************/
26322557 int
26432568
26442569 rv = 0;
26452570
2646 if ((self->sesman_trans != 0) && self->sesman_trans_up)
2571 if (self->sesman_trans != 0 &&
2572 self->sesman_trans->status == TRANS_STATUS_UP)
26472573 {
26482574 trans_get_wait_objs(self->sesman_trans, read_objs, rcount);
26492575 }
26502576
2651 if ((self->chan_trans != 0) && self->chan_trans_up)
2577 if (self->pam_auth_trans != 0 &&
2578 self->pam_auth_trans->status == TRANS_STATUS_UP)
2579 {
2580 trans_get_wait_objs(self->pam_auth_trans, read_objs, rcount);
2581 }
2582
2583 if ((self->chan_trans != 0) && self->chan_trans->status == TRANS_STATUS_UP)
26522584 {
26532585 trans_get_wait_objs_rw(self->chan_trans, read_objs, rcount,
26542586 write_objs, wcount, timeout);
27312663 xrdp_mm_check_chan(struct xrdp_mm *self)
27322664 {
27332665 LOG(LOG_LEVEL_TRACE, "xrdp_mm_check_chan:");
2734 if ((self->chan_trans != 0) && self->chan_trans_up)
2666 if ((self->chan_trans != 0) && self->chan_trans->status == TRANS_STATUS_UP)
27352667 {
27362668 if (trans_check_wait_objs(self->chan_trans) != 0)
27372669 {
2738 self->delete_chan_trans = 1;
2739 }
2740 }
2741 if (self->delete_chan_trans)
2742 {
2743 trans_delete(self->chan_trans);
2744 self->chan_trans = 0;
2745 self->chan_trans_up = 0;
2746 self->delete_chan_trans = 0;
2747 }
2670 /* This is safe to do here, as we're not in a chansrv
2671 * transport callback */
2672 trans_delete(self->chan_trans);
2673 self->chan_trans = 0;
2674 }
2675 }
2676
27482677 return 0;
27492678 }
27502679
27992728 cy = enc_done->cy;
28002729 if (enc_done->comp_bytes > 0)
28012730 {
2802 libxrdp_fastpath_send_frame_marker(self->wm->session, 0,
2803 enc_done->enc->frame_id);
2731 if (!enc_done->continuation)
2732 {
2733 libxrdp_fastpath_send_frame_marker(self->wm->session, 0,
2734 enc_done->enc->frame_id);
2735 }
28042736 libxrdp_fastpath_send_surface(self->wm->session,
28052737 enc_done->comp_pad_data,
28062738 enc_done->pad_bytes,
28082740 x, y, x + cx, y + cy,
28092741 32, self->encoder->codec_id,
28102742 cx, cy);
2811 libxrdp_fastpath_send_frame_marker(self->wm->session, 1,
2812 enc_done->enc->frame_id);
2743 if (enc_done->last)
2744 {
2745 libxrdp_fastpath_send_frame_marker(self->wm->session, 1,
2746 enc_done->enc->frame_id);
2747 }
28132748 }
28142749 /* free enc_done */
28152750 if (enc_done->last)
28492784
28502785 rv = 0;
28512786
2852 if ((self->sesman_trans != NULL) && self->sesman_trans_up)
2787 if (self->sesman_trans != NULL &&
2788 !self->delete_sesman_trans &&
2789 self->sesman_trans->status == TRANS_STATUS_UP)
28532790 {
28542791 if (trans_check_wait_objs(self->sesman_trans) != 0)
28552792 {
28612798 }
28622799 }
28632800 }
2864
2865 if ((self->chan_trans != NULL) && self->chan_trans_up)
2866 {
2867 if (trans_check_wait_objs(self->chan_trans) != 0)
2868 {
2869 self->delete_chan_trans = 1;
2870 }
2871 }
2872
2873 if (self->mod != NULL)
2874 {
2875 if (self->mod->mod_check_wait_objs != NULL)
2876 {
2877 rv = self->mod->mod_check_wait_objs(self->mod);
2878 }
2879 }
2880
28812801 if (self->delete_sesman_trans)
28822802 {
28832803 trans_delete(self->sesman_trans);
28842804 self->sesman_trans = NULL;
2885 self->sesman_trans_up = 0;
2886 self->delete_sesman_trans = 0;
2887 }
2888
2889 if (self->delete_chan_trans)
2890 {
2891 trans_delete(self->chan_trans);
2892 self->chan_trans = NULL;
2893 self->chan_trans_up = 0;
2894 self->delete_chan_trans = 0;
2805 }
2806
2807 if (self->pam_auth_trans != NULL &&
2808 !self->delete_pam_auth_trans &&
2809 self->pam_auth_trans->status == TRANS_STATUS_UP)
2810 {
2811 if (trans_check_wait_objs(self->pam_auth_trans) != 0)
2812 {
2813 self->delete_pam_auth_trans = 1;
2814 }
2815 }
2816 if (self->delete_pam_auth_trans)
2817 {
2818 trans_delete(self->pam_auth_trans);
2819 self->pam_auth_trans = NULL;
2820 }
2821
2822
2823 if (self->chan_trans != NULL &&
2824 self->chan_trans->status == TRANS_STATUS_UP)
2825 {
2826 if (trans_check_wait_objs(self->chan_trans) != 0)
2827 {
2828 /* This is safe to do here, as we're not in a chansrv
2829 * transport callback */
2830 trans_delete(self->chan_trans);
2831 self->chan_trans = NULL;
2832 }
2833 }
2834
2835 if (self->mod != NULL)
2836 {
2837 if (self->mod->mod_check_wait_objs != NULL)
2838 {
2839 rv = self->mod->mod_check_wait_objs(self->mod);
2840 }
28952841 }
28962842
28972843 if (self->encoder != NULL)
30112957 struct xrdp_wm *wm;
30122958
30132959 wm = (struct xrdp_wm *)(mod->wm);
3014 return wm->mm->usechansrv;
2960 return wm->mm->use_chansrv;
30152961 }
30162962
30172963
32983244
32993245 /*****************************************************************************/
33003246 int
3301 server_msg(struct xrdp_mod *mod, char *msg, int code)
3247 server_msg(struct xrdp_mod *mod, const char *msg, int code)
33023248 {
33033249 struct xrdp_wm *wm;
33043250
35733519 }
35743520
35753521 /*****************************************************************************/
3522 /*return -1 if channels are controlled by chansrv */
3523 int
3524 server_get_channel_count(struct xrdp_mod *mod)
3525 {
3526 struct xrdp_wm *wm;
3527
3528 wm = (struct xrdp_wm *)(mod->wm);
3529
3530 if (wm->mm->use_chansrv)
3531 {
3532 return -1;
3533 }
3534
3535 return libxrdp_get_channel_count(wm->session);
3536 }
3537
3538
3539 /*****************************************************************************/
35763540 /*return 0 if the index is not found*/
35773541 int
35783542 server_query_channel(struct xrdp_mod *mod, int index, char *channel_name,
35823546
35833547 wm = (struct xrdp_wm *)(mod->wm);
35843548
3585 if (wm->mm->usechansrv)
3549 if (wm->mm->use_chansrv)
35863550 {
35873551 return 1;
35883552 }
36003564
36013565 wm = (struct xrdp_wm *)(mod->wm);
36023566
3603 if (wm->mm->usechansrv)
3567 if (wm->mm->use_chansrv)
36043568 {
36053569 return -1;
36063570 }
36183582
36193583 wm = (struct xrdp_wm *)(mod->wm);
36203584
3621 if (wm->mm->usechansrv)
3585 if (wm->mm->use_chansrv)
36223586 {
36233587 /* Modules should not be calling this if chansrv is running -
36243588 * they can use server_chansrv_in_use() to avoid doing this */
2626 #include "xrdp_rail.h"
2727 #include "xrdp_constants.h"
2828 #include "fifo.h"
29 #include "guid.h"
2930
3031 #define MAX_NR_CHANNELS 16
3132 #define MAX_CHANNEL_NAME 16
7172 int (*server_set_pointer)(struct xrdp_mod *v, int x, int y,
7273 char *data, char *mask);
7374 int (*server_palette)(struct xrdp_mod *v, int *palette);
74 int (*server_msg)(struct xrdp_mod *v, char *msg, int code);
75 int (*server_msg)(struct xrdp_mod *v, const char *msg, int code);
7576 int (*server_is_term)(struct xrdp_mod *v);
7677 int (*server_set_clip)(struct xrdp_mod *v, int x, int y, int cx, int cy);
7778 int (*server_reset_clip)(struct xrdp_mod *v);
9495 int box_right, int box_bottom,
9596 int x, int y, char *data, int data_len);
9697 int (*server_reset)(struct xrdp_mod *v, int width, int height, int bpp);
98 int (*server_get_channel_count)(struct xrdp_mod *v);
9799 int (*server_query_channel)(struct xrdp_mod *v, int index,
98100 char *channel_name,
99101 int *channel_flags);
158160 int flags, int frame_id);
159161 int (*server_session_info)(struct xrdp_mod *v, const char *data,
160162 int data_bytes);
161 tintptr server_dumby[100 - 45]; /* align, 100 minus the number of server
163 tintptr server_dumby[100 - 46]; /* align, 100 minus the number of server
162164 functions above */
163165 /* common */
164166 tintptr handle; /* pointer to self as int */
165167 tintptr wm; /* struct xrdp_wm* */
166168 tintptr painter;
167169 struct source_info *si;
170 };
171
172 /**
173 * Transform to apply to loaded images
174 */
175 enum xrdp_bitmap_load_transform
176 {
177 XBLT_NONE = 0,
178 XBLT_SCALE,
179 XBLT_ZOOM
168180 };
169181
170182 /* header for bmp file */
283295 /* defined later */
284296 struct xrdp_enc_data;
285297
298 /**
299 * Stages we go through connecting to the session
300 */
301 enum mm_connect_state
302 {
303 MMCS_CONNECT_TO_SESMAN,
304 MMCS_PAM_AUTH,
305 MMCS_SESSION_AUTH,
306 MMCS_CONNECT_TO_SESSION,
307 MMCS_CONNECT_TO_CHANSRV,
308 MMCS_DONE
309 };
310
286311 struct xrdp_mm
287312 {
288313 struct xrdp_wm *wm; /* owner */
289 int connected_state; /* true if connected to sesman else false */
314 enum mm_connect_state connect_state; /* State of connection */
315 /* Other processes we connect to */
316 /* NB : When we move to UDS, the sesman and pam_auth
317 * connection be merged */
318 int use_sesman; /* true if this is a sesman session */
319 int use_pam_auth; /* True if we're to authenticate using PAM */
320 int use_chansrv; /* true if chansrvport is set in xrdp.ini or using sesman */
290321 struct trans *sesman_trans; /* connection to sesman */
291 int sesman_trans_up; /* true once connected to sesman */
292 int delete_sesman_trans; /* boolean set when done with sesman connection */
322 struct trans *pam_auth_trans; /* connection to pam authenticator */
323 struct trans *chan_trans; /* connection to chansrv */
324
325 /* We can't delete transports while we're in a callback for that
326 * transport, as this causes trans.c to reference undefined memory.
327 * These flags mark transports as needing to be deleted when
328 * we are definitely not in a transport callback */
329 int delete_sesman_trans;
330 int delete_pam_auth_trans;
331
293332 struct list *login_names;
294333 struct list *login_values;
295334 /* mod vars */
298337 int (*mod_exit)(struct xrdp_mod *);
299338 struct xrdp_mod *mod; /* module interface */
300339 int display; /* 10 for :10.0, 11 for :11.0, etc */
340 struct guid guid; /* GUID for the session, or all zeros */
301341 int code; /* 0=Xvnc session, 10=X11rdp session, 20=xorg driver mode */
302 int sesman_controlled; /* true if this is a sesman session */
303 struct trans *chan_trans; /* connection to chansrv */
304 int chan_trans_up; /* true once connected to chansrv */
305 int delete_chan_trans; /* boolean set when done with channel connection */
306 int usechansrv; /* true if chansrvport is set in xrdp.ini or using sesman */
307342 struct xrdp_encoder *encoder;
308343 int cs2xr_cid_map[256];
309344 int xr2cr_cid_map[256];
633668 int ls_width; /* window width */
634669 int ls_height; /* window height */
635670 int ls_bg_color; /* background color */
671 char ls_background_image[256]; /* background image file name */
672 enum xrdp_bitmap_load_transform ls_background_transform;
673 /* transform to apply to background image */
636674 char ls_logo_filename[256]; /* logo filename */
637 char ls_background_image[256]; /* background image file name */
675 enum xrdp_bitmap_load_transform ls_logo_transform;
676 /* transform to apply to logo */
677 int ls_logo_width; /* logo width (optional) */
678 int ls_logo_height; /* logo height (optional) */
638679 int ls_logo_x_pos; /* logo x co-ordinate */
639680 int ls_logo_y_pos; /* logo y co-ordinate */
640681 int ls_label_x_pos; /* x pos of labels */
703703 q = (char *)list_get_item(names, index);
704704 r = (char *)list_get_item(values, index);
705705
706 if (g_strncmp("password", q, 255) == 0)
706 if (g_strncasecmp("password", q, 255) == 0)
707707 {
708708 /* if the password has been asked for by the module, use what the
709709 client says.
714714 r = self->session->client_info->password;
715715 }
716716 }
717 else if (g_strncmp("username", q, 255) == 0)
717 else if (g_strncasecmp("username", q, 255) == 0)
718718 {
719719 /* if the username has been asked for by the module, use what the
720720 client says.
725725 r = self->session->client_info->username;
726726 }
727727 }
728 else if (g_strncmp("ip", q, 255) == 0)
728 else if (g_strncasecmp("ip", q, 255) == 0)
729729 {
730730 /* if the ip has been asked for by the module, use what the
731731 client says (target ip should be in 'domain' field, when starting with "_")
741741
742742 }
743743 }
744 else if (g_strncmp("port", q, 255) == 0)
744 else if (g_strncasecmp("port", q, 255) == 0)
745745 {
746746 if (g_strncmp("ask3389", r, 7) == 0)
747747 {
18441844
18451845 if (self->mm->mod != 0)
18461846 {
1847 if (self->mm->usechansrv)
1847 if (self->mm->use_chansrv)
18481848 {
18491849 rv = xrdp_mm_process_channel_data(self->mm, param1, param2,
18501850 param3, param4);
19551955 }
19561956 else if (self->login_state == WMLS_START_CONNECT)
19571957 {
1958 if (xrdp_mm_connect(self->mm) == 0)
1959 {
1960 xrdp_wm_set_login_state(self, WMLS_CONNECT_IN_PROGRESS);
1961 xrdp_wm_delete_all_children(self);
1962 self->dragging = 0;
1963 }
1964 else
1965 {
1966 /* we do nothing on connect error so far */
1967 }
1958 xrdp_wm_delete_all_children(self);
1959 self->dragging = 0;
1960 xrdp_wm_set_login_state(self, WMLS_CONNECT_IN_PROGRESS);
1961
1962 /* This calls back to xrdp_wm_mod_connect_done() when the
1963 * connect is finished*/
1964 xrdp_mm_connect(self->mm);
19681965 }
19691966 else if (self->login_state == WMLS_CLEANUP)
19701967 {
19741971 }
19751972
19761973 return 0;
1974 }
1975
1976 /******************************************************************************/
1977 /* this gets called when the module manager finishes a connect
1978 * which was initiated by xrdp_mm_connect()
1979 */
1980 void
1981 xrdp_wm_mod_connect_done(struct xrdp_wm *self, int status)
1982 {
1983 LOG(LOG_LEVEL_DEBUG, "status from xrdp_mm_connect() : %d", status);
1984 if (status == 0)
1985 {
1986 xrdp_wm_set_login_state(self, WMLS_CLEANUP);
1987 self->dragging = 0;
1988 }
1989 else
1990 {
1991 xrdp_wm_set_login_state(self, WMLS_INACTIVE);
1992 xrdp_wm_show_log(self);
1993 }
19771994 }
19781995
19791996 /*****************************************************************************/
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
202202 unique=`for i in $$list; do \
203203 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
204204 done | $(am__uniquify_input)`
205 ETAGS = etags
206 CTAGS = ctags
207205 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
208206 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
209207 ACLOCAL = @ACLOCAL@
221219 CHECK_LIBS = @CHECK_LIBS@
222220 CPP = @CPP@
223221 CPPFLAGS = @CPPFLAGS@
222 CSCOPE = @CSCOPE@
223 CTAGS = @CTAGS@
224224 CYGPATH_W = @CYGPATH_W@
225225 DEFS = @DEFS@
226226 DEPDIR = @DEPDIR@
232232 ECHO_N = @ECHO_N@
233233 ECHO_T = @ECHO_T@
234234 EGREP = @EGREP@
235 ETAGS = @ETAGS@
235236 EXEEXT = @EXEEXT@
236237 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
237238 FDKAAC_LIBS = @FDKAAC_LIBS@
241242 FUSE_CFLAGS = @FUSE_CFLAGS@
242243 FUSE_LIBS = @FUSE_LIBS@
243244 GREP = @GREP@
245 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
246 IMLIB2_LIBS = @IMLIB2_LIBS@
244247 INSTALL = @INSTALL@
245248 INSTALL_DATA = @INSTALL_DATA@
246249 INSTALL_PROGRAM = @INSTALL_PROGRAM@
531534
532535 distclean-tags:
533536 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
534
535537 distdir: $(BUILT_SOURCES)
536538 $(MAKE) $(AM_MAKEFLAGS) distdir-am
537539
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
202202 unique=`for i in $$list; do \
203203 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
204204 done | $(am__uniquify_input)`
205 ETAGS = etags
206 CTAGS = ctags
207205 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
208206 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
209207 ACLOCAL = @ACLOCAL@
221219 CHECK_LIBS = @CHECK_LIBS@
222220 CPP = @CPP@
223221 CPPFLAGS = @CPPFLAGS@
222 CSCOPE = @CSCOPE@
223 CTAGS = @CTAGS@
224224 CYGPATH_W = @CYGPATH_W@
225225 DEFS = @DEFS@
226226 DEPDIR = @DEPDIR@
232232 ECHO_N = @ECHO_N@
233233 ECHO_T = @ECHO_T@
234234 EGREP = @EGREP@
235 ETAGS = @ETAGS@
235236 EXEEXT = @EXEEXT@
236237 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
237238 FDKAAC_LIBS = @FDKAAC_LIBS@
241242 FUSE_CFLAGS = @FUSE_CFLAGS@
242243 FUSE_LIBS = @FUSE_LIBS@
243244 GREP = @GREP@
245 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
246 IMLIB2_LIBS = @IMLIB2_LIBS@
244247 INSTALL = @INSTALL@
245248 INSTALL_DATA = @INSTALL_DATA@
246249 INSTALL_PROGRAM = @INSTALL_PROGRAM@
523526
524527 distclean-tags:
525528 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
526
527529 distdir: $(BUILT_SOURCES)
528530 $(MAKE) $(AM_MAKEFLAGS) distdir-am
529531
0 # Makefile.in generated by automake 1.16.3 from Makefile.am.
0 # Makefile.in generated by automake 1.16.5 from Makefile.am.
11 # @configure_input@
22
3 # Copyright (C) 1994-2020 Free Software Foundation, Inc.
3 # Copyright (C) 1994-2021 Free Software Foundation, Inc.
44
55 # This Makefile.in is free software; the Free Software Foundation
66 # gives unlimited permission to copy and/or distribute it,
205205 unique=`for i in $$list; do \
206206 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
207207 done | $(am__uniquify_input)`
208 ETAGS = etags
209 CTAGS = ctags
210208 am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
211209 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
212210 ACLOCAL = @ACLOCAL@
224222 CHECK_LIBS = @CHECK_LIBS@
225223 CPP = @CPP@
226224 CPPFLAGS = @CPPFLAGS@
225 CSCOPE = @CSCOPE@
226 CTAGS = @CTAGS@
227227 CYGPATH_W = @CYGPATH_W@
228228 DEFS = @DEFS@
229229 DEPDIR = @DEPDIR@
235235 ECHO_N = @ECHO_N@
236236 ECHO_T = @ECHO_T@
237237 EGREP = @EGREP@
238 ETAGS = @ETAGS@
238239 EXEEXT = @EXEEXT@
239240 FDKAAC_CFLAGS = @FDKAAC_CFLAGS@
240241 FDKAAC_LIBS = @FDKAAC_LIBS@
244245 FUSE_CFLAGS = @FUSE_CFLAGS@
245246 FUSE_LIBS = @FUSE_LIBS@
246247 GREP = @GREP@
248 IMLIB2_CFLAGS = @IMLIB2_CFLAGS@
249 IMLIB2_LIBS = @IMLIB2_LIBS@
247250 INSTALL = @INSTALL@
248251 INSTALL_DATA = @INSTALL_DATA@
249252 INSTALL_PROGRAM = @INSTALL_PROGRAM@
536539
537540 distclean-tags:
538541 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
539
540542 distdir: $(BUILT_SOURCES)
541543 $(MAKE) $(AM_MAKEFLAGS) distdir-am
542544
12011201 bmpdata = 0;
12021202 if (flags == 0) /* screen */
12031203 {
1204 if (amod->screen_shmem_id_mapped == 0)
1205 {
1206 amod->screen_shmem_id = shmem_id;
1207 amod->screen_shmem_pixels = (char *) g_shmat(amod->screen_shmem_id);
1204 /* Do we need to map (or remap) the memory
1205 * area shared with the X server ? */
1206 if (amod->screen_shmem_id_mapped == 0 ||
1207 amod->screen_shmem_id != shmem_id)
1208 {
1209 if (amod->screen_shmem_id_mapped != 0)
1210 {
1211 g_shmdt(amod->screen_shmem_pixels);
1212 }
1213 amod->screen_shmem_pixels = (char *) g_shmat(shmem_id);
12081214 if (amod->screen_shmem_pixels == (void *) -1)
12091215 {
12101216 /* failed */
1217 if (amod->screen_shmem_id_mapped == 0)
1218 {
1219 LOG(LOG_LEVEL_ERROR,
1220 "Can't attach to shared memory id %d [%s]",
1221 shmem_id, g_get_strerror());
1222 }
1223 else
1224 {
1225 LOG(LOG_LEVEL_ERROR,
1226 "Can't attach to shared memory id %d from id %d [%s]",
1227 shmem_id, amod->screen_shmem_id, g_get_strerror());
1228 }
12111229 amod->screen_shmem_id = 0;
12121230 amod->screen_shmem_pixels = 0;
12131231 amod->screen_shmem_id_mapped = 0;
12141232 }
12151233 else
12161234 {
1235 amod->screen_shmem_id = shmem_id;
12171236 amod->screen_shmem_id_mapped = 1;
12181237 }
12191238 }
1220 else if (amod->screen_shmem_id != shmem_id)
1221 {
1222 amod->screen_shmem_id = shmem_id;
1223 g_shmdt(amod->screen_shmem_pixels);
1224 amod->screen_shmem_pixels = (char *) g_shmat(amod->screen_shmem_id);
1225 if (amod->screen_shmem_pixels == (void *) -1)
1226 {
1227 /* failed */
1228 amod->screen_shmem_id = 0;
1229 amod->screen_shmem_pixels = 0;
1230 amod->screen_shmem_id_mapped = 0;
1231 }
1232 }
1239
12331240 if (amod->screen_shmem_pixels != 0)
12341241 {
12351242 bmpdata = amod->screen_shmem_pixels + shmem_offset;
12361243 }
12371244 }
1245 else
1246 {
1247 LOG_DEVEL(LOG_LEVEL_ERROR, "process_server_paint_rect_shmem_ex:"
1248 " flags=%d frame_id=%d, shmem_id=%d, shmem_offset=%d,"
1249 " width=%d, height=%d",
1250 flags, frame_id, shmem_id, shmem_offset,
1251 width, height);
1252 }
1253
12381254 if (bmpdata != 0)
12391255 {
1240
12411256 rv = amod->server_paint_rects(amod, num_drects, ldrects,
12421257 num_crects, lcrects,
12431258 bmpdata, width, height,
9191 int box_right, int box_bottom,
9292 int x, int y, char *data, int data_len);
9393 int (*server_reset)(struct mod *v, int width, int height, int bpp);
94 int (*server_get_channel_count)(struct mod *v);
9495 int (*server_query_channel)(struct mod *v, int index,
9596 char *channel_name,
9697 int *channel_flags);
151152 char *data, int width, int height,
152153 int flags, int frame_id);
153154
154 tintptr server_dumby[100 - 44]; /* align, 100 minus the number of server
155 tintptr server_dumby[100 - 45]; /* align, 100 minus the number of server
155156 functions above */
156157 /* common */
157158 tintptr handle; /* pointer to self as long */