o moved from GNU General Public License to Apache License, Version 2.0
o applied new coding standards to all .c files o moved some files around
This commit is contained in:
parent
3cedfae76a
commit
1123323fda
480
COPYING
480
COPYING
@ -1,372 +1,176 @@
|
||||
Apache License, Version 2.0
|
||||
|
||||
special clause for libxrdp and librdp, both based on rdesktop
|
||||
these libraries link to openssl
|
||||
Version 2.0, January 2004
|
||||
|
||||
This software is released under the GNU General Public License
|
||||
(reproduced below) with the additional exemption that compiling,
|
||||
linking, and/or using OpenSSL together with this software is
|
||||
allowed.
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
---
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
special clause for xrdp, that main executable
|
||||
for linking with proprietary modules
|
||||
1. Definitions.
|
||||
|
||||
Linking this library statically or dynamically with other modules
|
||||
is making a combined work based on this library. Thus, the terms
|
||||
and conditions of the GNU General Public License cover the whole
|
||||
combination.
|
||||
"License" shall mean the terms and conditions for use, reproduction, and
|
||||
distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
As a special exception, the copyright holders of this library
|
||||
give you permission to link this library with independent modules
|
||||
to produce an executable, regardless of the license terms of
|
||||
these independent modules, and to copy and distribute the resulting
|
||||
executable under terms of your choice, provided that you also meet,
|
||||
for each linked independent module, the terms and conditions of the
|
||||
license of that module. An independent module is a module which is
|
||||
not derived from or based on this library. If you modify this
|
||||
library, you may extend this exception to your version of the
|
||||
library, but you are not obliged to do so. If you do not wish
|
||||
to do so, delete this exception statement from your version.
|
||||
"Licensor" shall mean the copyright owner or entity authorized by the
|
||||
copyright owner that is granting the License.
|
||||
|
||||
---
|
||||
"Legal Entity" shall mean the union of the acting entity and all other
|
||||
entities that control, are controlled by, or are under common control
|
||||
with that entity. For the purposes of this definition, "control" means
|
||||
(i) the power, direct or indirect, to cause the direction or management
|
||||
of such entity, whether by contract or otherwise, or (ii) ownership of
|
||||
fifty percent (50%) or more of the outstanding shares, or
|
||||
(iii) beneficial ownership of such entity.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
"You" (or "Your") shall mean an individual or Legal Entity exercising
|
||||
permissions granted by this License.
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
675 Mass Ave, Cambridge, MA 02139, USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation source,
|
||||
and configuration files.
|
||||
|
||||
Preamble
|
||||
"Object" form shall mean any form resulting from mechanical transformation
|
||||
or translation of a Source form, including but not limited to compiled
|
||||
object code, generated documentation, and conversions to other media types.
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
"Work" shall mean the work of authorship, whether in Source or Object form,
|
||||
made available under the License, as indicated by a copyright notice that is
|
||||
included in or attached to the work (an example is provided in the Appendix below).
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
"Derivative Works" shall mean any work, whether in Source or Object form,
|
||||
that is based on (or derived from) the Work and for which the editorial
|
||||
revisions, annotations, elaborations, or other modifications represent, as a
|
||||
whole, an original work of authorship. For the purposes of this License,
|
||||
Derivative Works shall not include works that remain separable from, or
|
||||
merely link (or bind by name) to the interfaces of, the Work and
|
||||
Derivative Works thereof.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
"Contribution" shall mean any work of authorship, including the original
|
||||
version of the Work and any modifications or additions to that Work or Derivative
|
||||
Works thereof, that is intentionally submitted to Licensor for inclusion in the
|
||||
Work by the copyright owner or by an individual or Legal Entity authorized to
|
||||
submit on behalf of the copyright owner. For the purposes of this definition,
|
||||
"submitted" means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems, and
|
||||
issue tracking systems that are managed by, or on behalf of, the Licensor for
|
||||
the purpose of discussing and improving the Work, but excluding communication
|
||||
that is conspicuously marked or otherwise designated in writing by the copyright
|
||||
owner as "Not a Contribution."
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf
|
||||
of whom a Contribution has been received by Licensor and subsequently incorporated
|
||||
within the Work.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of this License,
|
||||
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||
no-charge, royalty-free, irrevocable copyright license to reproduce, prepare
|
||||
Derivative Works of, publicly display, publicly perform, sublicense, and distribute
|
||||
the Work and such Derivative Works in Source or Object form.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
3. Grant of Patent License. Subject to the terms and conditions of this License,
|
||||
each Contributor hereby grants to You a perpetual, worldwide, non-exclusive,
|
||||
no-charge, royalty-free, irrevocable (except as stated in this section) patent
|
||||
license to make, have made, use, offer to sell, sell, import, and otherwise transfer
|
||||
the Work, where such license applies only to those patent claims licensable by such
|
||||
Contributor that are necessarily infringed by their Contribution(s) alone or by
|
||||
combination of their Contribution(s) with the Work to which such Contribution(s) was
|
||||
submitted. If You institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution
|
||||
incorporated within the Work constitutes direct or contributory patent infringement,
|
||||
then any patent licenses granted to You under this License for that Work shall
|
||||
terminate as of the date such litigation is filed.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative
|
||||
Works thereof in any medium, with or without modifications, and in Source or Object
|
||||
form, provided that You meet the following conditions:
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
You must give any other recipients of the Work or Derivative Works a copy of this
|
||||
License; and
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
You must cause any modified files to carry prominent notices stating that You changed
|
||||
the files; and
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
You must retain, in the Source form of any Derivative Works that You distribute,
|
||||
all copyright, patent, trademark, and attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
If the Work includes a "NOTICE" text file as part of its distribution, then any
|
||||
Derivative Works that You distribute must include a readable copy of the attribution
|
||||
notices contained within such NOTICE file, excluding those notices that do not pertain
|
||||
to any part of the Derivative Works, in at least one of the following places: within a
|
||||
NOTICE text file distributed as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or, within a display
|
||||
generated by the Derivative Works, if and wherever such third-party notices normally
|
||||
appear. The contents of the NOTICE file are for informational purposes only and do not
|
||||
modify the License. You may add Your own attribution notices within Derivative Works
|
||||
that You distribute, alongside or as an addendum to the NOTICE text from the Work,
|
||||
provided that such additional attribution notices cannot be construed as modifying
|
||||
the License. You may add Your own copyright statement to Your modifications and may
|
||||
provide additional or different license terms and conditions for use, reproduction,
|
||||
or distribution of Your modifications, or for any such Derivative Works as a whole,
|
||||
provided Your use, reproduction, and distribution of the Work otherwise complies
|
||||
with the conditions stated in this License.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution
|
||||
intentionally submitted for inclusion in the Work by You to the Licensor shall be under
|
||||
the terms and conditions of this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify the terms of any
|
||||
separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
6. Trademarks. This License does not grant permission to use the trade names, trademarks,
|
||||
service marks, or product names of the Licensor, except as required for reasonable and
|
||||
customary use in describing the origin of the Work and reproducing the content of
|
||||
the NOTICE file.
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing,
|
||||
Licensor provides the Work (and each Contributor provides its Contributions) on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
|
||||
including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT,
|
||||
MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for
|
||||
determining the appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
8. Limitation of Liability. In no event and under no legal theory, whether in tort
|
||||
(including negligence), contract, or otherwise, unless required by applicable law
|
||||
(such as deliberate and grossly negligent acts) or agreed to in writing, shall any
|
||||
Contributor be liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a result of this
|
||||
License or out of the use or inability to use the Work (including but not limited to
|
||||
damages for loss of goodwill, work stoppage, computer failure or malfunction, or any
|
||||
and all other commercial damages or losses), even if such Contributor has been advised
|
||||
of the possibility of such damages.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
9. Accepting Warranty or Additional Liability. While redistributing the Work or
|
||||
Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance
|
||||
of support, warranty, indemnity, or other liability obligations and/or rights consistent
|
||||
with this License. However, in accepting such obligations, You may act only on Your
|
||||
own behalf and on Your sole responsibility, not on behalf of any other Contributor,
|
||||
and only if You agree to indemnify, defend, and hold each Contributor harmless for any
|
||||
liability incurred by, or claims asserted against, such Contributor by reason of your
|
||||
accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
APPENDIX: How to apply the Apache License to your work
|
||||
To apply the Apache License to your work, attach the following boilerplate notice,
|
||||
with the fields enclosed by brackets "[]" replaced with your own identifying
|
||||
information. (Don't include the brackets!) The text should be enclosed in the
|
||||
appropriate comment syntax for the file format. We also recommend that a file or class
|
||||
name and description of purpose be included on the same "printed page" as the
|
||||
copyright notice for easier identification within third-party archives.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
BIN
Coding_Style.odt
Normal file
BIN
Coding_Style.odt
Normal file
Binary file not shown.
59
astyle_config.as
Normal file
59
astyle_config.as
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
# detached brackets
|
||||
--style=allman
|
||||
|
||||
# 4 spaces, no tabs
|
||||
--indent=spaces=4
|
||||
|
||||
# for C++ files only
|
||||
--indent-classes
|
||||
|
||||
# Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block.
|
||||
# The entire case block is indented.
|
||||
--indent-switches
|
||||
|
||||
# Add extra indentation to namespace blocks. This option has no effect on Java files.
|
||||
--indent-namespaces
|
||||
|
||||
# Converts tabs into spaces in the non-indentation part of the line.
|
||||
--convert-tabs
|
||||
|
||||
# requires --convert-tabs to work properly
|
||||
--indent-preprocessor
|
||||
|
||||
--indent-col1-comments
|
||||
|
||||
--min-conditional-indent=2
|
||||
|
||||
--max-instatement-indent=40
|
||||
|
||||
# Pad empty lines around header blocks (e.g. 'if', 'for', 'while'...).
|
||||
--break-blocks
|
||||
|
||||
# Insert space padding around operators.
|
||||
--pad-oper
|
||||
|
||||
# Insert space padding after paren headers only (e.g. 'if', 'for', 'while'...).
|
||||
--pad-header
|
||||
|
||||
|
||||
# Add brackets to unbracketed one line conditional statements (e.g. 'if', 'for', 'while'...).
|
||||
--add-brackets
|
||||
|
||||
--align-pointer=name
|
||||
|
||||
# Do not retain a backup of the original file. The original file is purged after it is formatted.
|
||||
--suffix=none
|
||||
|
||||
# For each directory in the command line, process all subdirectories recursively.
|
||||
--recursive
|
||||
|
||||
# Preserve the original file's date and time modified.
|
||||
--preserve-date
|
||||
|
||||
# Formatted files display mode. Display only the files that have been formatted.
|
||||
# Do not display files that are unchanged.
|
||||
--formatted
|
||||
|
||||
--lineend=linux
|
||||
|
@ -1,24 +1,19 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if !defined(ARCH_H)
|
||||
|
164
common/d3des.c
164
common/d3des.c
@ -43,33 +43,43 @@ static unsigned char Df_Key[24] = {
|
||||
0x89,0xab,0xcd,0xef,0x01,0x23,0x45,0x67 };
|
||||
*/
|
||||
|
||||
static unsigned short bytebit[8] = {
|
||||
01, 02, 04, 010, 020, 040, 0100, 0200 };
|
||||
static unsigned short bytebit[8] =
|
||||
{
|
||||
01, 02, 04, 010, 020, 040, 0100, 0200
|
||||
};
|
||||
|
||||
static unsigned long bigbyte[24] = {
|
||||
static unsigned long bigbyte[24] =
|
||||
{
|
||||
0x800000L, 0x400000L, 0x200000L, 0x100000L,
|
||||
0x80000L, 0x40000L, 0x20000L, 0x10000L,
|
||||
0x8000L, 0x4000L, 0x2000L, 0x1000L,
|
||||
0x800L, 0x400L, 0x200L, 0x100L,
|
||||
0x80L, 0x40L, 0x20L, 0x10L,
|
||||
0x8L, 0x4L, 0x2L, 0x1L };
|
||||
0x8L, 0x4L, 0x2L, 0x1L
|
||||
};
|
||||
|
||||
/* Use the key schedule specified in the Standard (ANSI X3.92-1981). */
|
||||
|
||||
static unsigned char pc1[56] = {
|
||||
static unsigned char pc1[56] =
|
||||
{
|
||||
56, 48, 40, 32, 24, 16, 8, 0, 57, 49, 41, 33, 25, 17,
|
||||
9, 1, 58, 50, 42, 34, 26, 18, 10, 2, 59, 51, 43, 35,
|
||||
62, 54, 46, 38, 30, 22, 14, 6, 61, 53, 45, 37, 29, 21,
|
||||
13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3 };
|
||||
13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3
|
||||
};
|
||||
|
||||
static unsigned char totrot[16] = {
|
||||
1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 };
|
||||
static unsigned char totrot[16] =
|
||||
{
|
||||
1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28
|
||||
};
|
||||
|
||||
static unsigned char pc2[48] = {
|
||||
static unsigned char pc2[48] =
|
||||
{
|
||||
13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9,
|
||||
22, 18, 11, 3, 25, 7, 15, 6, 26, 19, 12, 1,
|
||||
40, 51, 30, 36, 46, 54, 29, 39, 50, 44, 32, 47,
|
||||
43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31 };
|
||||
43, 48, 38, 55, 33, 52, 45, 41, 49, 35, 28, 31
|
||||
};
|
||||
|
||||
/* Thanks to James Gillogly & Phil Karn! */
|
||||
void rfbDesKey(unsigned char *key, int edf)
|
||||
@ -78,31 +88,69 @@ void rfbDesKey(unsigned char *key, int edf)
|
||||
unsigned char pc1m[56], pcr[56];
|
||||
unsigned long kn[32];
|
||||
|
||||
for ( j = 0; j < 56; j++ ) {
|
||||
for ( j = 0; j < 56; j++ )
|
||||
{
|
||||
l = pc1[j];
|
||||
m = l & 07;
|
||||
pc1m[j] = (key[l >> 3] & bytebit[m]) ? 1 : 0;
|
||||
}
|
||||
for( i = 0; i < 16; i++ ) {
|
||||
if( edf == DE1 ) m = (15 - i) << 1;
|
||||
else m = i << 1;
|
||||
|
||||
for ( i = 0; i < 16; i++ )
|
||||
{
|
||||
if ( edf == DE1 )
|
||||
{
|
||||
m = (15 - i) << 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
m = i << 1;
|
||||
}
|
||||
|
||||
n = m + 1;
|
||||
kn[m] = kn[n] = 0L;
|
||||
for( j = 0; j < 28; j++ ) {
|
||||
|
||||
for ( j = 0; j < 28; j++ )
|
||||
{
|
||||
l = j + totrot[i];
|
||||
if( l < 28 ) pcr[j] = pc1m[l];
|
||||
else pcr[j] = pc1m[l - 28];
|
||||
|
||||
if ( l < 28 )
|
||||
{
|
||||
pcr[j] = pc1m[l];
|
||||
}
|
||||
for( j = 28; j < 56; j++ ) {
|
||||
else
|
||||
{
|
||||
pcr[j] = pc1m[l - 28];
|
||||
}
|
||||
}
|
||||
|
||||
for ( j = 28; j < 56; j++ )
|
||||
{
|
||||
l = j + totrot[i];
|
||||
if( l < 56 ) pcr[j] = pc1m[l];
|
||||
else pcr[j] = pc1m[l - 28];
|
||||
|
||||
if ( l < 56 )
|
||||
{
|
||||
pcr[j] = pc1m[l];
|
||||
}
|
||||
for( j = 0; j < 24; j++ ) {
|
||||
if( pcr[pc2[j]] ) kn[m] |= bigbyte[j];
|
||||
if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j];
|
||||
else
|
||||
{
|
||||
pcr[j] = pc1m[l - 28];
|
||||
}
|
||||
}
|
||||
|
||||
for ( j = 0; j < 24; j++ )
|
||||
{
|
||||
if ( pcr[pc2[j]] )
|
||||
{
|
||||
kn[m] |= bigbyte[j];
|
||||
}
|
||||
|
||||
if ( pcr[pc2[j + 24]] )
|
||||
{
|
||||
kn[n] |= bigbyte[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cookey(kn);
|
||||
return;
|
||||
}
|
||||
@ -114,7 +162,9 @@ static void cookey(register unsigned long *raw1)
|
||||
register int i;
|
||||
|
||||
cook = dough;
|
||||
for( i = 0; i < 16; i++, raw1++ ) {
|
||||
|
||||
for ( i = 0; i < 16; i++, raw1++ )
|
||||
{
|
||||
raw0 = raw1++;
|
||||
*cook = (*raw0 & 0x00fc0000L) << 6;
|
||||
*cook |= (*raw0 & 0x00000fc0L) << 10;
|
||||
@ -125,6 +175,7 @@ static void cookey(register unsigned long *raw1)
|
||||
*cook |= (*raw1 & 0x0003f000L) >> 4;
|
||||
*cook++ |= (*raw1 & 0x0000003fL);
|
||||
}
|
||||
|
||||
rfbUseKey(dough);
|
||||
return;
|
||||
}
|
||||
@ -134,7 +185,12 @@ void rfbCPKey(register unsigned long *into)
|
||||
register unsigned long *from, *endp;
|
||||
|
||||
from = KnL, endp = &KnL[32];
|
||||
while( from < endp ) *into++ = *from++;
|
||||
|
||||
while ( from < endp )
|
||||
{
|
||||
*into++ = *from++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -143,7 +199,12 @@ void rfbUseKey(register unsigned long *from)
|
||||
register unsigned long *to, *endp;
|
||||
|
||||
to = KnL, endp = &KnL[32];
|
||||
while( to < endp ) *to++ = *from++;
|
||||
|
||||
while ( to < endp )
|
||||
{
|
||||
*to++ = *from++;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -183,7 +244,8 @@ static void unscrun(register unsigned long *outof, register unsigned char *into)
|
||||
return;
|
||||
}
|
||||
|
||||
static unsigned long SP1[64] = {
|
||||
static unsigned long SP1[64] =
|
||||
{
|
||||
0x01010400L, 0x00000000L, 0x00010000L, 0x01010404L,
|
||||
0x01010004L, 0x00010404L, 0x00000004L, 0x00010000L,
|
||||
0x00000400L, 0x01010400L, 0x01010404L, 0x00000400L,
|
||||
@ -199,9 +261,11 @@ static unsigned long SP1[64] = {
|
||||
0x01010404L, 0x00010004L, 0x01010000L, 0x01000404L,
|
||||
0x01000004L, 0x00000404L, 0x00010404L, 0x01010400L,
|
||||
0x00000404L, 0x01000400L, 0x01000400L, 0x00000000L,
|
||||
0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L };
|
||||
0x00010004L, 0x00010400L, 0x00000000L, 0x01010004L
|
||||
};
|
||||
|
||||
static unsigned long SP2[64] = {
|
||||
static unsigned long SP2[64] =
|
||||
{
|
||||
0x80108020L, 0x80008000L, 0x00008000L, 0x00108020L,
|
||||
0x00100000L, 0x00000020L, 0x80100020L, 0x80008020L,
|
||||
0x80000020L, 0x80108020L, 0x80108000L, 0x80000000L,
|
||||
@ -217,9 +281,11 @@ static unsigned long SP2[64] = {
|
||||
0x00008020L, 0x80108000L, 0x00100000L, 0x80000020L,
|
||||
0x00100020L, 0x80008020L, 0x80000020L, 0x00100020L,
|
||||
0x00108000L, 0x00000000L, 0x80008000L, 0x00008020L,
|
||||
0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L };
|
||||
0x80000000L, 0x80100020L, 0x80108020L, 0x00108000L
|
||||
};
|
||||
|
||||
static unsigned long SP3[64] = {
|
||||
static unsigned long SP3[64] =
|
||||
{
|
||||
0x00000208L, 0x08020200L, 0x00000000L, 0x08020008L,
|
||||
0x08000200L, 0x00000000L, 0x00020208L, 0x08000200L,
|
||||
0x00020008L, 0x08000008L, 0x08000008L, 0x00020000L,
|
||||
@ -235,9 +301,11 @@ static unsigned long SP3[64] = {
|
||||
0x08000208L, 0x00020000L, 0x08000000L, 0x08020208L,
|
||||
0x00000008L, 0x00020208L, 0x00020200L, 0x08000008L,
|
||||
0x08020000L, 0x08000208L, 0x00000208L, 0x08020000L,
|
||||
0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L };
|
||||
0x00020208L, 0x00000008L, 0x08020008L, 0x00020200L
|
||||
};
|
||||
|
||||
static unsigned long SP4[64] = {
|
||||
static unsigned long SP4[64] =
|
||||
{
|
||||
0x00802001L, 0x00002081L, 0x00002081L, 0x00000080L,
|
||||
0x00802080L, 0x00800081L, 0x00800001L, 0x00002001L,
|
||||
0x00000000L, 0x00802000L, 0x00802000L, 0x00802081L,
|
||||
@ -253,9 +321,11 @@ static unsigned long SP4[64] = {
|
||||
0x00802081L, 0x00000081L, 0x00000001L, 0x00002000L,
|
||||
0x00800001L, 0x00002001L, 0x00802080L, 0x00800081L,
|
||||
0x00002001L, 0x00002080L, 0x00800000L, 0x00802001L,
|
||||
0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L };
|
||||
0x00000080L, 0x00800000L, 0x00002000L, 0x00802080L
|
||||
};
|
||||
|
||||
static unsigned long SP5[64] = {
|
||||
static unsigned long SP5[64] =
|
||||
{
|
||||
0x00000100L, 0x02080100L, 0x02080000L, 0x42000100L,
|
||||
0x00080000L, 0x00000100L, 0x40000000L, 0x02080000L,
|
||||
0x40080100L, 0x00080000L, 0x02000100L, 0x40080100L,
|
||||
@ -271,9 +341,11 @@ static unsigned long SP5[64] = {
|
||||
0x42080100L, 0x00080100L, 0x42000000L, 0x42080100L,
|
||||
0x02080000L, 0x00000000L, 0x40080000L, 0x42000000L,
|
||||
0x00080100L, 0x02000100L, 0x40000100L, 0x00080000L,
|
||||
0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L };
|
||||
0x00000000L, 0x40080000L, 0x02080100L, 0x40000100L
|
||||
};
|
||||
|
||||
static unsigned long SP6[64] = {
|
||||
static unsigned long SP6[64] =
|
||||
{
|
||||
0x20000010L, 0x20400000L, 0x00004000L, 0x20404010L,
|
||||
0x20400000L, 0x00000010L, 0x20404010L, 0x00400000L,
|
||||
0x20004000L, 0x00404010L, 0x00400000L, 0x20000010L,
|
||||
@ -289,9 +361,11 @@ static unsigned long SP6[64] = {
|
||||
0x00404010L, 0x20404000L, 0x00000000L, 0x20400010L,
|
||||
0x00000010L, 0x00004000L, 0x20400000L, 0x00404010L,
|
||||
0x00004000L, 0x00400010L, 0x20004010L, 0x00000000L,
|
||||
0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L };
|
||||
0x20404000L, 0x20000000L, 0x00400010L, 0x20004010L
|
||||
};
|
||||
|
||||
static unsigned long SP7[64] = {
|
||||
static unsigned long SP7[64] =
|
||||
{
|
||||
0x00200000L, 0x04200002L, 0x04000802L, 0x00000000L,
|
||||
0x00000800L, 0x04000802L, 0x00200802L, 0x04200800L,
|
||||
0x04200802L, 0x00200000L, 0x00000000L, 0x04000002L,
|
||||
@ -307,9 +381,11 @@ static unsigned long SP7[64] = {
|
||||
0x00000802L, 0x04000002L, 0x04200802L, 0x04200000L,
|
||||
0x00200800L, 0x00000000L, 0x00000002L, 0x04200802L,
|
||||
0x00000000L, 0x00200802L, 0x04200000L, 0x00000800L,
|
||||
0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L };
|
||||
0x04000002L, 0x04000800L, 0x00000800L, 0x00200002L
|
||||
};
|
||||
|
||||
static unsigned long SP8[64] = {
|
||||
static unsigned long SP8[64] =
|
||||
{
|
||||
0x10001040L, 0x00001000L, 0x00040000L, 0x10041040L,
|
||||
0x10000000L, 0x10001040L, 0x00000040L, 0x10000000L,
|
||||
0x00040040L, 0x10040000L, 0x10041040L, 0x00041000L,
|
||||
@ -325,7 +401,8 @@ static unsigned long SP8[64] = {
|
||||
0x00000000L, 0x10041040L, 0x00040040L, 0x10000040L,
|
||||
0x10040000L, 0x10001000L, 0x10001040L, 0x00000000L,
|
||||
0x10041040L, 0x00041000L, 0x00041000L, 0x00001040L,
|
||||
0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L };
|
||||
0x00001040L, 0x00040040L, 0x10000000L, 0x10041000L
|
||||
};
|
||||
|
||||
static void desfunc(register unsigned long *block, register unsigned long *keys)
|
||||
{
|
||||
@ -352,7 +429,8 @@ static void desfunc(register unsigned long* block, register unsigned long *keys)
|
||||
right ^= work;
|
||||
leftt = ((leftt << 1) | ((leftt >> 31) & 1L)) & 0xffffffffL;
|
||||
|
||||
for( round = 0; round < 8; round++ ) {
|
||||
for ( round = 0; round < 8; round++ )
|
||||
{
|
||||
work = (right << 28) | (right >> 4);
|
||||
work ^= *keys++;
|
||||
fval = SP7[ work & 0x3fL];
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2009
|
||||
|
||||
main define/macro file
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* main define/macro file
|
||||
*/
|
||||
|
||||
#ifndef DEFINES_H
|
||||
|
@ -1,25 +1,21 @@
|
||||
/*
|
||||
Copyright (c) 2004-2012 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
read a config file
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* read a config file
|
||||
*/
|
||||
|
||||
#include "arch.h"
|
||||
@ -53,12 +49,15 @@ l_file_read_sections(int fd, int max_file_size, struct list* names)
|
||||
make_stream(s);
|
||||
init_stream(s, max_file_size);
|
||||
len = g_file_read(fd, s->data, max_file_size);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
s->end = s->p + len;
|
||||
|
||||
for (index = 0; index < len; index++)
|
||||
{
|
||||
in_uint8(s, c);
|
||||
|
||||
if (c == '[')
|
||||
{
|
||||
in_it = 1;
|
||||
@ -81,6 +80,7 @@ l_file_read_sections(int fd, int max_file_size, struct list* names)
|
||||
{
|
||||
rv = 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return rv;
|
||||
}
|
||||
@ -96,24 +96,29 @@ file_read_line(struct stream* s, char* text)
|
||||
char *hold;
|
||||
|
||||
skip_to_end = 0;
|
||||
|
||||
if (!s_check_rem(s, 1))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
hold = s->p;
|
||||
i = 0;
|
||||
in_uint8(s, c);
|
||||
|
||||
while (c != 10 && c != 13)
|
||||
{
|
||||
if (c == '#' || c == '!' || c == ';')
|
||||
{
|
||||
skip_to_end = 1;
|
||||
}
|
||||
|
||||
if (!skip_to_end)
|
||||
{
|
||||
text[i] = c;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (s_check_rem(s, 1))
|
||||
{
|
||||
in_uint8(s, c);
|
||||
@ -124,9 +129,11 @@ file_read_line(struct stream* s, char* text)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (c == 10 || c == 13)
|
||||
{
|
||||
at_end = 0;
|
||||
|
||||
while (c == 10 || c == 13)
|
||||
{
|
||||
if (s_check_rem(s, 1))
|
||||
@ -139,17 +146,21 @@ file_read_line(struct stream* s, char* text)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!at_end)
|
||||
{
|
||||
s->p--;
|
||||
}
|
||||
}
|
||||
|
||||
text[i] = 0;
|
||||
|
||||
if (text[0] == '[')
|
||||
{
|
||||
s->p = hold;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -170,6 +181,7 @@ file_split_name_value(char* text, char* name, char* value)
|
||||
name[0] = 0;
|
||||
value[0] = 0;
|
||||
len = g_strlen(text);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
if (text[i] == '=')
|
||||
@ -189,6 +201,7 @@ file_split_name_value(char* text, char* name, char* value)
|
||||
name[name_index] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
g_strtrim(name, 3); /* trim both right and left */
|
||||
g_strtrim(value, 3); /* trim both right and left */
|
||||
return 0;
|
||||
@ -222,12 +235,15 @@ l_file_read_section(int fd, int max_file_size, const char* section,
|
||||
make_stream(s);
|
||||
init_stream(s, file_size);
|
||||
len = g_file_read(fd, s->data, file_size);
|
||||
|
||||
if (len > 0)
|
||||
{
|
||||
s->end = s->p + len;
|
||||
|
||||
for (index = 0; index < len; index++)
|
||||
{
|
||||
in_uint8(s, c);
|
||||
|
||||
if (c == '[')
|
||||
{
|
||||
in_it = 1;
|
||||
@ -237,15 +253,18 @@ l_file_read_section(int fd, int max_file_size, const char* section,
|
||||
if (g_strcasecmp(section, text) == 0)
|
||||
{
|
||||
file_read_line(s, text);
|
||||
|
||||
while (file_read_line(s, text) == 0)
|
||||
{
|
||||
if (g_strlen(text) > 0)
|
||||
{
|
||||
file_split_name_value(text, name, value);
|
||||
list_add_item(names, (tbus)g_strdup(name));
|
||||
|
||||
if (value[0] == '$')
|
||||
{
|
||||
lvalue = g_getenv(value + 1);
|
||||
|
||||
if (lvalue != 0)
|
||||
{
|
||||
list_add_item(values, (tbus)g_strdup(lvalue));
|
||||
@ -261,9 +280,11 @@ l_file_read_section(int fd, int max_file_size, const char* section,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_it = 0;
|
||||
in_it_index = 0;
|
||||
g_memset(text, 0, 512);
|
||||
@ -275,6 +296,7 @@ l_file_read_section(int fd, int max_file_size, const char* section,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
@ -302,15 +324,19 @@ file_by_name_read_sections(const char* file_name, struct list* names)
|
||||
int rv;
|
||||
|
||||
file_size = g_file_get_size(file_name);
|
||||
|
||||
if (file_size < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
fd = g_file_open(file_name);
|
||||
|
||||
if (fd < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = l_file_read_sections(fd, file_size, names);
|
||||
g_file_close(fd);
|
||||
return rv;
|
||||
@ -339,15 +365,19 @@ file_by_name_read_section(const char* file_name, const char* section,
|
||||
int rv;
|
||||
|
||||
file_size = g_file_get_size(file_name);
|
||||
|
||||
if (file_size < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
fd = g_file_open(file_name);
|
||||
|
||||
if (fd < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = l_file_read_section(fd, file_size, section, names, values);
|
||||
g_file_close(fd);
|
||||
return rv;
|
||||
|
@ -1,25 +1,21 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
read a config file
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* read a config file
|
||||
*/
|
||||
|
||||
#if !defined(FILE_H)
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
default file locations for log, config, etc
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* default file locations for log, config, etc
|
||||
*/
|
||||
|
||||
#if !defined(FILE_LOC_H)
|
||||
|
@ -1,25 +1,21 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
simple list
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* simple list
|
||||
*/
|
||||
|
||||
#include "arch.h"
|
||||
@ -49,6 +45,7 @@ list_delete(struct list* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (self->auto_free)
|
||||
{
|
||||
for (i = 0; i < self->count; i++)
|
||||
@ -57,6 +54,7 @@ list_delete(struct list* self)
|
||||
self->items[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
g_free(self->items);
|
||||
g_free(self);
|
||||
}
|
||||
@ -77,6 +75,7 @@ list_add_item(struct list* self, tbus item)
|
||||
g_free(self->items);
|
||||
self->items = p;
|
||||
}
|
||||
|
||||
self->items[self->count] = item;
|
||||
self->count++;
|
||||
}
|
||||
@ -89,6 +88,7 @@ list_get_item(struct list* self, int index)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return self->items[index];
|
||||
}
|
||||
|
||||
@ -106,6 +106,7 @@ list_clear(struct list* self)
|
||||
self->items[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
g_free(self->items);
|
||||
self->count = 0;
|
||||
self->grow_by = 10;
|
||||
@ -126,6 +127,7 @@ list_index_of(struct list* self, tbus item)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -142,10 +144,12 @@ list_remove_item(struct list* self, int index)
|
||||
g_free((void *)self->items[index]);
|
||||
self->items[index] = 0;
|
||||
}
|
||||
|
||||
for (i = index; i < (self->count - 1); i++)
|
||||
{
|
||||
self->items[i] = self->items[i + 1];
|
||||
}
|
||||
|
||||
self->count--;
|
||||
}
|
||||
}
|
||||
@ -162,9 +166,11 @@ list_insert_item(struct list* self, int index, tbus item)
|
||||
list_add_item(self, item);
|
||||
return;
|
||||
}
|
||||
|
||||
if (index >= 0 && index < self->count)
|
||||
{
|
||||
self->count++;
|
||||
|
||||
if (self->count > self->alloc_size)
|
||||
{
|
||||
i = self->alloc_size;
|
||||
@ -174,10 +180,12 @@ list_insert_item(struct list* self, int index, tbus item)
|
||||
g_free(self->items);
|
||||
self->items = p;
|
||||
}
|
||||
|
||||
for (i = (self->count - 2); i >= index; i--)
|
||||
{
|
||||
self->items[i + 1] = self->items[i];
|
||||
}
|
||||
|
||||
self->items[index] = item;
|
||||
}
|
||||
}
|
||||
@ -210,6 +218,7 @@ list_dump_items(struct list* self)
|
||||
{
|
||||
g_writeln("List is empty");
|
||||
}
|
||||
|
||||
for (index = 0; index < self->count; index++)
|
||||
{
|
||||
g_writeln("%d: %s", index, list_get_item(self, index));
|
||||
|
@ -1,25 +1,21 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
simple list
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* simple list
|
||||
*/
|
||||
|
||||
#if !defined(LIST_H)
|
||||
|
81
common/log.c
81
common/log.c
@ -1,24 +1,19 @@
|
||||
/*
|
||||
Copyright (c) 2005-2012 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -57,11 +52,13 @@ int DEFAULT_CC
|
||||
internal_log_file_open(const char *fname)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (fname != NULL)
|
||||
{
|
||||
ret = open(fname, O_WRONLY | O_CREAT | O_APPEND | O_SYNC,
|
||||
S_IRUSR | S_IWUSR);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -131,6 +128,7 @@ enum logReturns DEFAULT_CC
|
||||
internal_log_start(struct log_config *l_cfg)
|
||||
{
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
|
||||
if (0 == l_cfg)
|
||||
{
|
||||
ret = LOG_ERROR_MALLOC;
|
||||
@ -178,6 +176,7 @@ enum logReturns DEFAULT_CC
|
||||
internal_log_end(struct log_config *l_cfg)
|
||||
{
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
|
||||
/* if log is closed, quit silently */
|
||||
if (0 == l_cfg)
|
||||
{
|
||||
@ -205,11 +204,13 @@ internal_log_end(struct log_config* l_cfg)
|
||||
g_free(l_cfg->log_file);
|
||||
l_cfg->log_file = 0;
|
||||
}
|
||||
|
||||
if (0 != l_cfg->program_name)
|
||||
{
|
||||
g_free(l_cfg->program_name);
|
||||
l_cfg->program_name = 0;
|
||||
}
|
||||
|
||||
ret = LOG_STARTUP_OK;
|
||||
return ret;
|
||||
}
|
||||
@ -248,6 +249,7 @@ internal_log_text2level(char* buf)
|
||||
{
|
||||
return LOG_LEVEL_DEBUG;
|
||||
}
|
||||
|
||||
g_writeln("Your configured log level is corrupt - we use debug log level");
|
||||
return LOG_LEVEL_DEBUG;
|
||||
}
|
||||
@ -266,16 +268,20 @@ internalReadConfiguration(const char* inFilename, const char* applicationName)
|
||||
g_writeln("The inifile is null to readConfiguration!");
|
||||
return ret;
|
||||
}
|
||||
|
||||
fd = g_file_open(inFilename);
|
||||
|
||||
if (-1 == fd)
|
||||
{
|
||||
ret = LOG_ERROR_NO_CFG;
|
||||
g_writeln("We could not open the configuration file to read log parameters");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* we initialize the memory for the configuration and set all content
|
||||
to zero. */
|
||||
ret = internalInitAndAllocStruct();
|
||||
|
||||
if (ret != LOG_STARTUP_OK)
|
||||
{
|
||||
return ret;
|
||||
@ -292,10 +298,12 @@ internalReadConfiguration(const char* inFilename, const char* applicationName)
|
||||
/* read logging config */
|
||||
ret = internal_config_read_logging(fd, staticLogConfig, param_n,
|
||||
param_v, applicationName);
|
||||
|
||||
if (ret != LOG_STARTUP_OK)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
list_delete(sec);
|
||||
list_delete(param_v);
|
||||
@ -327,12 +335,15 @@ internal_config_read_logging(int file, struct log_config* lc,
|
||||
lc->syslog_level = LOG_LEVEL_DEBUG;
|
||||
|
||||
file_read_section(file, SESMAN_CFG_LOGGING, param_n, param_v);
|
||||
|
||||
for (i = 0; i < param_n->count; i++)
|
||||
{
|
||||
buf = (char *)list_get_item(param_n, i);
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_FILE))
|
||||
{
|
||||
lc->log_file = g_strdup((char *)list_get_item(param_v, i));
|
||||
|
||||
if (lc->log_file != NULL)
|
||||
{
|
||||
if (lc->log_file[0] != '/')
|
||||
@ -344,14 +355,17 @@ internal_config_read_logging(int file, struct log_config* lc,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_LEVEL))
|
||||
{
|
||||
lc->log_level = internal_log_text2level((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_ENABLE_SYSLOG))
|
||||
{
|
||||
lc->enable_syslog = text2bool((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_LOG_SYSLOG_LEVEL))
|
||||
{
|
||||
lc->syslog_level = internal_log_text2level((char *)list_get_item(param_v, i));
|
||||
@ -379,6 +393,7 @@ internalInitAndAllocStruct(void)
|
||||
{
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
staticLogConfig = g_malloc(sizeof(struct log_config), 1);
|
||||
|
||||
if (staticLogConfig != NULL)
|
||||
{
|
||||
staticLogConfig->fd = -1;
|
||||
@ -390,6 +405,7 @@ internalInitAndAllocStruct(void)
|
||||
g_writeln("could not allocate memory for log struct");
|
||||
ret = LOG_ERROR_MALLOC;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -414,6 +430,7 @@ text2bool(char* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -421,11 +438,13 @@ enum logReturns DEFAULT_CC
|
||||
log_start_from_param(const struct log_config *iniParams)
|
||||
{
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
|
||||
if (staticLogConfig != NULL)
|
||||
{
|
||||
log_message(LOG_LEVEL_ALWAYS, "Log already initialized");
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (iniParams == NULL)
|
||||
{
|
||||
g_writeln("inparam to log_start_from_param is NULL");
|
||||
@ -435,11 +454,13 @@ log_start_from_param(const struct log_config* iniParams)
|
||||
{
|
||||
/*Copy the struct information*/
|
||||
ret = internalInitAndAllocStruct();
|
||||
|
||||
if (ret != LOG_STARTUP_OK)
|
||||
{
|
||||
g_writeln("internalInitAndAllocStruct failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
staticLogConfig->enable_syslog = iniParams->enable_syslog;
|
||||
staticLogConfig->fd = iniParams->fd;
|
||||
staticLogConfig->log_file = g_strdup(iniParams->log_file);
|
||||
@ -449,9 +470,11 @@ log_start_from_param(const struct log_config* iniParams)
|
||||
staticLogConfig->program_name = g_strdup(iniParams->program_name);
|
||||
staticLogConfig->syslog_level = iniParams->syslog_level;
|
||||
ret = internal_log_start(staticLogConfig);
|
||||
|
||||
if (ret != LOG_STARTUP_OK)
|
||||
{
|
||||
g_writeln("Could not start log");
|
||||
|
||||
if (staticLogConfig != NULL)
|
||||
{
|
||||
g_free(staticLogConfig);
|
||||
@ -459,6 +482,7 @@ log_start_from_param(const struct log_config* iniParams)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -473,18 +497,23 @@ enum logReturns DEFAULT_CC
|
||||
log_start(const char *iniFile, const char *applicationName)
|
||||
{
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
|
||||
if (applicationName == NULL)
|
||||
{
|
||||
g_writeln("Programming error your application name cannot be null");
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = internalReadConfiguration(iniFile, applicationName);
|
||||
|
||||
if (ret == LOG_STARTUP_OK)
|
||||
{
|
||||
ret = internal_log_start(staticLogConfig);
|
||||
|
||||
if (ret != LOG_STARTUP_OK)
|
||||
{
|
||||
g_writeln("Could not start log");
|
||||
|
||||
if (staticLogConfig != NULL)
|
||||
{
|
||||
g_free(staticLogConfig);
|
||||
@ -497,6 +526,7 @@ log_start(const char* iniFile, const char* applicationName)
|
||||
g_writeln("Error reading configuration for log based on config: %s",
|
||||
iniFile);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -509,11 +539,13 @@ log_end(void)
|
||||
{
|
||||
enum logReturns ret = LOG_GENERAL_ERROR;
|
||||
ret = internal_log_end(staticLogConfig);
|
||||
|
||||
if (staticLogConfig != NULL)
|
||||
{
|
||||
g_free(staticLogConfig);
|
||||
staticLogConfig = NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -527,11 +559,13 @@ log_message(const enum logLevels lvl, const char* msg, ...)
|
||||
int writereply = 0;
|
||||
time_t now_t;
|
||||
struct tm *now;
|
||||
|
||||
if (staticLogConfig == NULL)
|
||||
{
|
||||
g_writeln("The log reference is NULL - log not initialized properly");
|
||||
return LOG_ERROR_NO_CFG;
|
||||
}
|
||||
|
||||
if (0 > staticLogConfig->fd && staticLogConfig->enable_syslog == 0)
|
||||
{
|
||||
return LOG_ERROR_FILE_NOT_OPEN;
|
||||
@ -588,18 +622,22 @@ log_message(const enum logLevels lvl, const char* msg, ...)
|
||||
#ifdef LOG_ENABLE_THREAD
|
||||
pthread_mutex_lock(&(staticLogConfig->log_lock));
|
||||
#endif
|
||||
|
||||
if (staticLogConfig->fd > 0)
|
||||
{
|
||||
writereply = g_file_write(staticLogConfig->fd, buff, g_strlen(buff));
|
||||
|
||||
if (writereply <= 0)
|
||||
{
|
||||
rv = LOG_ERROR_NULL_FILE;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef LOG_ENABLE_THREAD
|
||||
pthread_mutex_unlock(&(staticLogConfig->log_lock));
|
||||
#endif
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -625,5 +663,6 @@ getLogFile(char* replybuf, int bufsize)
|
||||
{
|
||||
g_snprintf(replybuf, bufsize, "The log is not properly started");
|
||||
}
|
||||
|
||||
return replybuf;
|
||||
}
|
||||
|
37
common/log.h
37
common/log.h
@ -1,24 +1,19 @@
|
||||
/*
|
||||
Copyright (c) 2005-2012 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef LOG_H
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,25 +1,21 @@
|
||||
/*
|
||||
Copyright (c) 2004-2012 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
generic operating system calls
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* generic operating system calls
|
||||
*/
|
||||
|
||||
#if !defined(OS_CALLS_H)
|
||||
|
@ -1,29 +1,25 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
Parsing structs and macros
|
||||
|
||||
based on parse.h from rdesktop
|
||||
this is a super fast stream method, you bet
|
||||
needed functions g_malloc, g_free, g_memset, g_memcpy
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Parsing structs and macros
|
||||
*
|
||||
* based on parse.h from rdesktop
|
||||
* this is a super fast stream method, you bet
|
||||
* needed functions g_malloc, g_free, g_memset, g_memcpy
|
||||
*/
|
||||
|
||||
#if !defined(PARSE_H)
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
ssl calls
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ssl calls
|
||||
*/
|
||||
|
||||
#include <stdlib.h> /* needed for openssl headers */
|
||||
@ -169,6 +167,7 @@ ssl_reverse_it(char* p, int len)
|
||||
|
||||
i = 0;
|
||||
j = len - 1;
|
||||
|
||||
while (i < j)
|
||||
{
|
||||
temp = p[i];
|
||||
@ -215,6 +214,7 @@ ssl_mod_exp(char* out, int out_len, char* in, int in_len,
|
||||
BN_bin2bn((tui8 *)l_in, in_len, &lin);
|
||||
BN_mod_exp(&lout, &lin, &lexp, &lmod, ctx);
|
||||
rv = BN_bn2bin(&lout, (tui8 *)l_out);
|
||||
|
||||
if (rv <= out_len)
|
||||
{
|
||||
ssl_reverse_it(l_out, rv);
|
||||
@ -224,6 +224,7 @@ ssl_mod_exp(char* out, int out_len, char* in, int in_len,
|
||||
{
|
||||
rv = 0;
|
||||
}
|
||||
|
||||
BN_free(&lin);
|
||||
BN_free(&lout);
|
||||
BN_free(&lexp);
|
||||
@ -257,6 +258,7 @@ ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
lmod = (char *)g_malloc(mod_len, 0);
|
||||
lpri = (char *)g_malloc(pri_len, 0);
|
||||
lexp = (tui8 *)exp;
|
||||
@ -268,31 +270,37 @@ ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
|
||||
srand(g_time1());
|
||||
my_key = RSA_generate_key(key_size_in_bits, my_e, 0, 0);
|
||||
error = my_key == 0;
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
len = BN_num_bytes(my_key->n);
|
||||
error = len != mod_len;
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
BN_bn2bin(my_key->n, (tui8 *)lmod);
|
||||
ssl_reverse_it(lmod, mod_len);
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
len = BN_num_bytes(my_key->d);
|
||||
error = len != pri_len;
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
BN_bn2bin(my_key->d, (tui8 *)lpri);
|
||||
ssl_reverse_it(lpri, pri_len);
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
g_memcpy(mod, lmod, mod_len);
|
||||
g_memcpy(pri, lpri, pri_len);
|
||||
}
|
||||
|
||||
RSA_free(my_key);
|
||||
g_free(lmod);
|
||||
g_free(lpri);
|
||||
@ -319,6 +327,7 @@ ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
lexp = (char *)g_malloc(exp_len, 0);
|
||||
lmod = (char *)g_malloc(mod_len, 0);
|
||||
lpri = (char *)g_malloc(pri_len, 0);
|
||||
@ -328,31 +337,37 @@ ssl_gen_key_xrdp1(int key_size_in_bits, char* exp, int exp_len,
|
||||
BN_bin2bn((tui8 *)lexp, exp_len, my_e);
|
||||
my_key = RSA_new();
|
||||
error = RSA_generate_key_ex(my_key, key_size_in_bits, my_e, 0) == 0;
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
len = BN_num_bytes(my_key->n);
|
||||
error = len != mod_len;
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
BN_bn2bin(my_key->n, (tui8 *)lmod);
|
||||
ssl_reverse_it(lmod, mod_len);
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
len = BN_num_bytes(my_key->d);
|
||||
error = len != pri_len;
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
BN_bn2bin(my_key->d, (tui8 *)lpri);
|
||||
ssl_reverse_it(lpri, pri_len);
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
g_memcpy(mod, lmod, mod_len);
|
||||
g_memcpy(pri, lpri, pri_len);
|
||||
}
|
||||
|
||||
BN_free(my_e);
|
||||
RSA_free(my_key);
|
||||
g_free(lexp);
|
||||
|
@ -1,21 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if !defined(SSL_CALLS_H)
|
||||
|
@ -1,26 +1,21 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
thread calls
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* thread calls
|
||||
*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -61,9 +56,12 @@ tc_thread_create(void* (* start_routine)(void *), void* arg)
|
||||
|
||||
/* pthread_create returns error */
|
||||
rv = pthread_create(&thread, 0, start_routine, arg);
|
||||
if (!rv) {
|
||||
|
||||
if (!rv)
|
||||
{
|
||||
rv = pthread_detach(thread);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
@ -142,9 +140,12 @@ tc_mutex_unlock(tbus mutex)
|
||||
#if defined(_WIN32)
|
||||
ReleaseMutex((HANDLE)mutex);
|
||||
#else
|
||||
if (mutex != 0) {
|
||||
|
||||
if (mutex != 0)
|
||||
{
|
||||
rv = pthread_mutex_unlock((pthread_mutex_t *)mutex);
|
||||
}
|
||||
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
@ -1,26 +1,21 @@
|
||||
/*
|
||||
Copyright (c) 2004-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
thread calls
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* thread calls
|
||||
*/
|
||||
|
||||
#if !defined(THREAD_CALLS_H)
|
||||
|
@ -1,26 +1,21 @@
|
||||
/*
|
||||
Copyright (c) 2008-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
generic transport
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* generic transport
|
||||
*/
|
||||
|
||||
#include "os_calls.h"
|
||||
@ -35,13 +30,16 @@ trans_create(int mode, int in_size, int out_size)
|
||||
struct trans *self = (struct trans *)NULL;
|
||||
|
||||
self = (struct trans *)g_malloc(sizeof(struct trans), 1);
|
||||
if (self != NULL) {
|
||||
|
||||
if (self != NULL)
|
||||
{
|
||||
make_stream(self->in_s);
|
||||
init_stream(self->in_s, in_size);
|
||||
make_stream(self->out_s);
|
||||
init_stream(self->out_s, out_size);
|
||||
self->mode = mode;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@ -53,17 +51,23 @@ trans_delete(struct trans* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
free_stream(self->in_s);
|
||||
free_stream(self->out_s);
|
||||
if (self->sck > 0) {
|
||||
|
||||
if (self->sck > 0)
|
||||
{
|
||||
g_tcp_close(self->sck);
|
||||
}
|
||||
|
||||
self->sck = 0;
|
||||
|
||||
if (self->listen_filename != 0)
|
||||
{
|
||||
g_file_delete(self->listen_filename);
|
||||
g_free(self->listen_filename);
|
||||
}
|
||||
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
@ -75,10 +79,12 @@ trans_get_wait_objs(struct trans* self, tbus* objs, int* count)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (self->status != TRANS_STATUS_UP)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
objs[*count] = self->sck;
|
||||
(*count)++;
|
||||
return 0;
|
||||
@ -99,16 +105,20 @@ trans_check_wait_objs(struct trans* self)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (self->status != TRANS_STATUS_UP)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
|
||||
if (self->type1 == TRANS_TYPE_LISTENER) /* listening */
|
||||
{
|
||||
if (g_tcp_can_recv(self->sck, 0))
|
||||
{
|
||||
in_sck = g_tcp_accept(self->sck);
|
||||
|
||||
if (in_sck == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@ -122,6 +132,7 @@ trans_check_wait_objs(struct trans* self)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (in_sck != -1)
|
||||
{
|
||||
if (self->trans_conn_in != 0) /* is function assigned */
|
||||
@ -131,6 +142,7 @@ trans_check_wait_objs(struct trans* self)
|
||||
in_trans->sck = in_sck;
|
||||
in_trans->type1 = TRANS_TYPE_SERVER;
|
||||
in_trans->status = TRANS_STATUS_UP;
|
||||
|
||||
if (self->trans_conn_in(self, in_trans) != 0)
|
||||
{
|
||||
trans_delete(in_trans);
|
||||
@ -149,9 +161,11 @@ trans_check_wait_objs(struct trans* self)
|
||||
{
|
||||
read_so_far = (int)(self->in_s->end - self->in_s->data);
|
||||
to_read = self->header_size - read_so_far;
|
||||
|
||||
if (to_read > 0)
|
||||
{
|
||||
read_bytes = g_tcp_recv(self->sck, self->in_s->end, to_read, 0);
|
||||
|
||||
if (read_bytes == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@ -176,7 +190,9 @@ trans_check_wait_objs(struct trans* self)
|
||||
self->in_s->end += read_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
read_so_far = (int)(self->in_s->end - self->in_s->data);
|
||||
|
||||
if (read_so_far == self->header_size)
|
||||
{
|
||||
if (self->trans_data_in != 0)
|
||||
@ -187,6 +203,7 @@ trans_check_wait_objs(struct trans* self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -200,9 +217,11 @@ trans_force_read_s(struct trans* self, struct stream* in_s, int size)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
rcvd = g_tcp_recv(self->sck, in_s->end, size, 0);
|
||||
|
||||
if (rcvd == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@ -231,6 +250,7 @@ trans_force_read_s(struct trans* self, struct stream* in_s, int size)
|
||||
size -= rcvd;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -253,11 +273,14 @@ trans_force_write_s(struct trans* self, struct stream* out_s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
size = (int)(out_s->end - out_s->data);
|
||||
total = 0;
|
||||
|
||||
while (total < size)
|
||||
{
|
||||
sent = g_tcp_send(self->sck, out_s->data + total, size - total, 0);
|
||||
|
||||
if (sent == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@ -285,6 +308,7 @@ trans_force_write_s(struct trans* self, struct stream* out_s)
|
||||
total = total + sent;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -306,6 +330,7 @@ trans_connect(struct trans* self, const char* server, const char* port,
|
||||
{
|
||||
g_tcp_close(self->sck);
|
||||
}
|
||||
|
||||
if (self->mode == TRANS_MODE_TCP) /* tcp */
|
||||
{
|
||||
self->sck = g_tcp_socket();
|
||||
@ -323,6 +348,7 @@ trans_connect(struct trans* self, const char* server, const char* port,
|
||||
self->status = TRANS_STATUS_DOWN;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (error == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@ -334,8 +360,10 @@ trans_connect(struct trans* self, const char* server, const char* port,
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
self->status = TRANS_STATUS_UP; /* ok */
|
||||
self->type1 = TRANS_TYPE_CLIENT; /* client */
|
||||
return 0;
|
||||
@ -349,10 +377,12 @@ trans_listen_address(struct trans* self, char* port, const char* address)
|
||||
{
|
||||
g_tcp_close(self->sck);
|
||||
}
|
||||
|
||||
if (self->mode == TRANS_MODE_TCP) /* tcp */
|
||||
{
|
||||
self->sck = g_tcp_socket();
|
||||
g_tcp_set_non_blocking(self->sck);
|
||||
|
||||
if (g_tcp_bind_address(self->sck, port, address) == 0)
|
||||
{
|
||||
if (g_tcp_listen(self->sck) == 0)
|
||||
@ -370,9 +400,11 @@ trans_listen_address(struct trans* self, char* port, const char* address)
|
||||
g_file_delete(port);
|
||||
self->sck = g_tcp_local_socket();
|
||||
g_tcp_set_non_blocking(self->sck);
|
||||
|
||||
if (g_tcp_local_bind(self->sck, port) == 0)
|
||||
{
|
||||
self->listen_filename = g_strdup(port);
|
||||
|
||||
if (g_tcp_listen(self->sck) == 0)
|
||||
{
|
||||
g_chmod_hex(port, 0xffff);
|
||||
@ -382,6 +414,7 @@ trans_listen_address(struct trans* self, char* port, const char* address)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -397,12 +430,16 @@ struct stream* APP_CC
|
||||
trans_get_in_s(struct trans *self)
|
||||
{
|
||||
struct stream *rv = (struct stream *)NULL;
|
||||
if (self == NULL) {
|
||||
|
||||
if (self == NULL)
|
||||
{
|
||||
rv = (struct stream *)NULL;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
rv = self->in_s;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -411,12 +448,16 @@ struct stream* APP_CC
|
||||
trans_get_out_s(struct trans *self, int size)
|
||||
{
|
||||
struct stream *rv = (struct stream *)NULL;
|
||||
if (self == NULL) {
|
||||
|
||||
if (self == NULL)
|
||||
{
|
||||
rv = (struct stream *)NULL;
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
init_stream(self->out_s, size);
|
||||
rv = self->out_s;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -1,26 +1,21 @@
|
||||
/*
|
||||
Copyright (c) 2008-2010 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
generic transport
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* generic transport
|
||||
*/
|
||||
|
||||
#if !defined(TRANS_H)
|
||||
|
@ -1,26 +1,21 @@
|
||||
/*
|
||||
Copyright (c) 2012 Jay Sorg
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
|
||||
xrdp / xserver info / caps
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* xrdp / xserver info / caps
|
||||
*/
|
||||
|
||||
#if !defined(XRDP_CLIENT_INFO_H)
|
||||
|
@ -1,3 +1,20 @@
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
@ -33,6 +50,7 @@ check_messages(void)
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -105,25 +123,30 @@ font_dump(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_running = 1;
|
||||
msg("starting");
|
||||
g_font_name[0] = 0;
|
||||
SendMessageA(g_font_list, WM_GETTEXT, 255, (LPARAM)g_font_name);
|
||||
|
||||
if (g_strlen(g_font_name) == 0)
|
||||
{
|
||||
msg("error font not set");
|
||||
g_running = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
dc = GetDC(g_wnd);
|
||||
height = -MulDiv(g_font_size, GetDeviceCaps(dc, LOGPIXELSY), 72);
|
||||
g_font = CreateFontA(height, 0, 0, 0, FW_DONTCARE, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, g_font_name);
|
||||
ReleaseDC(g_wnd, dc);
|
||||
|
||||
if (g_font == 0)
|
||||
{
|
||||
msg("error - Font creation failed");
|
||||
}
|
||||
|
||||
zero1 = 0;
|
||||
g_snprintf(filename, 255, "%s-%d.fv1", g_font_name, g_font_size);
|
||||
msg("creating file %s", filename);
|
||||
@ -133,48 +156,59 @@ font_dump(void)
|
||||
strlen1 = g_strlen(g_font_name);
|
||||
g_file_write(fd, g_font_name, strlen1);
|
||||
x1 = strlen1;
|
||||
|
||||
while (x1 < 32)
|
||||
{
|
||||
g_file_write(fd, &zero1, 1);
|
||||
x1++;
|
||||
}
|
||||
|
||||
x2 = g_font_size; /* font size */
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
x2 = 1; /* style */
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* pad */
|
||||
index1 = 0;
|
||||
|
||||
while (index1 < 8)
|
||||
{
|
||||
g_file_write(fd, &zero1, 1);
|
||||
index1++;
|
||||
}
|
||||
|
||||
for (x1 = 32; x1 < 0x4e00; x1++)
|
||||
{
|
||||
check_messages();
|
||||
dc = GetWindowDC(g_wnd);
|
||||
saved = SelectObject(dc, g_font);
|
||||
|
||||
if (!GetCharABCWidths(dc, x1, x1, &abc))
|
||||
{
|
||||
show_last_error();
|
||||
}
|
||||
|
||||
text[0] = (TCHAR)x1;
|
||||
text[1] = 0;
|
||||
|
||||
if (!GetTextExtentPoint32(dc, text, 1, &sz))
|
||||
{
|
||||
show_last_error();
|
||||
}
|
||||
|
||||
SelectObject(dc, saved);
|
||||
ReleaseDC(g_wnd, dc);
|
||||
|
||||
if ((sz.cx > 0) && (sz.cy > 0))
|
||||
{
|
||||
dc = GetWindowDC(g_wnd);
|
||||
saved = SelectObject(dc, g_font);
|
||||
SetBkColor(dc, RGB(255, 255, 255));
|
||||
|
||||
if (!ExtTextOut(dc, 50, 50, ETO_OPAQUE, 0, text, 1, 0))
|
||||
{
|
||||
show_last_error();
|
||||
}
|
||||
|
||||
SelectObject(dc, saved);
|
||||
ReleaseDC(g_wnd, dc);
|
||||
Sleep(10);
|
||||
@ -195,11 +229,13 @@ font_dump(void)
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* pad */
|
||||
index1 = 0;
|
||||
|
||||
while (index1 < 6)
|
||||
{
|
||||
g_file_write(fd, &zero1, 1);
|
||||
index1++;
|
||||
}
|
||||
|
||||
dc = GetWindowDC(g_wnd);
|
||||
rect.left = 50 + abc.abcA;
|
||||
rect.top = 50;
|
||||
@ -214,6 +250,7 @@ font_dump(void)
|
||||
bi.bmiHeader.biPlanes = 1;
|
||||
bi.bmiHeader.biBitCount = 32;
|
||||
bitmap = CreateDIBSection(dc, &bi, DIB_RGB_COLORS, (void *)&bits, 0, 0);
|
||||
|
||||
if (bitmap == 0)
|
||||
{
|
||||
msg("error - CreateDIBSection failed");
|
||||
@ -223,12 +260,15 @@ font_dump(void)
|
||||
memset(bits, 0, width * height * 4);
|
||||
dc1 = CreateCompatibleDC(dc);
|
||||
SelectObject(dc1, bitmap);
|
||||
|
||||
if (!BitBlt(dc1, 0, 0, width, height, dc, rect.left, rect.top, SRCCOPY))
|
||||
{
|
||||
show_last_error();
|
||||
}
|
||||
|
||||
bmtext = (char *)g_malloc(width * height + 16, 1);
|
||||
bmtextindex = 0;
|
||||
|
||||
for (index1 = (height - 1); index1 >= 0; index1--)
|
||||
{
|
||||
for (index2 = 0; index2 < width; index2++)
|
||||
@ -237,6 +277,7 @@ font_dump(void)
|
||||
red = (pixel >> 16) & 0xff;
|
||||
green = (pixel >> 8) & 0xff;
|
||||
blue = (pixel >> 0) & 0xff;
|
||||
|
||||
if (red == 0 && green == 0 && blue == 0)
|
||||
{
|
||||
bmtext[bmtextindex] = '1';
|
||||
@ -249,27 +290,47 @@ font_dump(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outlen = 0;
|
||||
b1 = 0;
|
||||
roller = 0;
|
||||
len = g_strlen(bmtext);
|
||||
|
||||
for (index2 = 0; index2 < len; index2++)
|
||||
{
|
||||
if (bmtext[index2] == '1')
|
||||
{
|
||||
switch (roller)
|
||||
{
|
||||
case 0: b1 = b1 | 0x80; break;
|
||||
case 1: b1 = b1 | 0x40; break;
|
||||
case 2: b1 = b1 | 0x20; break;
|
||||
case 3: b1 = b1 | 0x10; break;
|
||||
case 4: b1 = b1 | 0x08; break;
|
||||
case 5: b1 = b1 | 0x04; break;
|
||||
case 6: b1 = b1 | 0x02; break;
|
||||
case 7: b1 = b1 | 0x01; break;
|
||||
case 0:
|
||||
b1 = b1 | 0x80;
|
||||
break;
|
||||
case 1:
|
||||
b1 = b1 | 0x40;
|
||||
break;
|
||||
case 2:
|
||||
b1 = b1 | 0x20;
|
||||
break;
|
||||
case 3:
|
||||
b1 = b1 | 0x10;
|
||||
break;
|
||||
case 4:
|
||||
b1 = b1 | 0x08;
|
||||
break;
|
||||
case 5:
|
||||
b1 = b1 | 0x04;
|
||||
break;
|
||||
case 6:
|
||||
b1 = b1 | 0x02;
|
||||
break;
|
||||
case 7:
|
||||
b1 = b1 | 0x01;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
roller++;
|
||||
|
||||
if (roller == 8)
|
||||
{
|
||||
roller = 0;
|
||||
@ -278,19 +339,23 @@ font_dump(void)
|
||||
b1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
while ((outlen % 4) != 0)
|
||||
{
|
||||
g_file_write(fd, &zero1, 1);
|
||||
outlen++;
|
||||
}
|
||||
|
||||
free(bmtext);
|
||||
DeleteDC(dc1);
|
||||
DeleteObject(bitmap);
|
||||
}
|
||||
|
||||
if (sz.cx != (long)(abc.abcA + abc.abcB + abc.abcC))
|
||||
{
|
||||
msg("error - width not right 1");
|
||||
}
|
||||
|
||||
brush = CreateSolidBrush(RGB(255, 255, 255));
|
||||
FillRect(dc, &rect, brush);
|
||||
DeleteObject(brush);
|
||||
@ -316,13 +381,16 @@ font_dump(void)
|
||||
g_file_write(fd, (char *)&x2, 2);
|
||||
/* pad */
|
||||
index1 = 0;
|
||||
|
||||
while (index1 < 6)
|
||||
{
|
||||
g_file_write(fd, &zero1, 1);
|
||||
index1++;
|
||||
}
|
||||
|
||||
/* blank bitmap */
|
||||
index1 = 0;
|
||||
|
||||
while (index1 < 4)
|
||||
{
|
||||
g_file_write(fd, &zero1, 1);
|
||||
@ -330,6 +398,7 @@ font_dump(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g_file_close(fd);
|
||||
msg("done");
|
||||
g_running = 0;
|
||||
@ -366,6 +435,7 @@ wnd_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
font_dump();
|
||||
break;
|
||||
case WM_COMMAND:
|
||||
|
||||
if ((HWND)lParam == g_exit_button)
|
||||
{
|
||||
PostMessage(g_wnd, WM_CLOSE, 0, 0);
|
||||
@ -376,10 +446,13 @@ wnd_proc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
SendMessage(g_lb, LB_DELETESTRING, 0, 0);
|
||||
}
|
||||
|
||||
SetTimer(g_wnd, 1, 1000, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
@ -399,11 +472,13 @@ create_window(void)
|
||||
/* name of window class */
|
||||
wc.lpszClassName = _T("fontdump");
|
||||
wc.hCursor = LoadCursor(0, IDC_ARROW);
|
||||
|
||||
/* Register the window class. */
|
||||
if (!RegisterClass(&wc))
|
||||
{
|
||||
return 0; /* Failed to register window class */
|
||||
}
|
||||
|
||||
style = WS_OVERLAPPED | WS_CAPTION | WS_POPUP | WS_MINIMIZEBOX |
|
||||
WS_SYSMENU | WS_SIZEBOX | WS_MAXIMIZEBOX;
|
||||
left = GetSystemMetrics(SM_CXSCREEN) / 2 - 640 / 2;
|
||||
@ -444,6 +519,7 @@ main_loop(void)
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return (int)(msg.wParam);
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2010
|
||||
|
||||
freerdp wrapper
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* freerdp wrapper
|
||||
*/
|
||||
|
||||
#include "xrdp-freerdp.h"
|
||||
@ -41,6 +39,7 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
out = (char *)g_malloc(width * height, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -54,13 +53,16 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -74,13 +76,16 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -94,13 +99,16 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -113,13 +121,16 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -132,17 +143,21 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -155,13 +170,16 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -177,20 +195,25 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 24))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 32))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 15))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
g_writeln("convert_bitmap: error unknown conversion from %d to %d",
|
||||
in_bpp, out_bpp);
|
||||
return 0;
|
||||
@ -211,6 +234,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = in_color == 0 ? 0 : 0xffffff;
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 8))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@ -218,6 +242,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR8(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@ -225,6 +250,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR16(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@ -232,6 +258,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
pixel = in_color;
|
||||
@ -239,6 +266,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR16(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
@ -246,10 +274,12 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
@ -257,22 +287,27 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 24))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 32))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 15))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
g_writeln("convert_color: error unknown conversion from %d to %d",
|
||||
in_bpp, out_bpp);
|
||||
return 0;
|
||||
|
@ -1,21 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2010
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __XRDP_COLOR_H
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2010
|
||||
|
||||
freerdp wrapper
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* freerdp wrapper
|
||||
*/
|
||||
|
||||
#include "xrdp-freerdp.h"
|
||||
@ -56,6 +54,7 @@ lib_mod_start(struct mod* mod, int w, int h, int bpp)
|
||||
mod->width = w;
|
||||
mod->height = h;
|
||||
mod->bpp = bpp;
|
||||
|
||||
if (bpp == 24)
|
||||
{
|
||||
mod->settings->server_depth = 32;
|
||||
@ -64,6 +63,7 @@ lib_mod_start(struct mod* mod, int w, int h, int bpp)
|
||||
{
|
||||
mod->settings->server_depth = mod->bpp;
|
||||
}
|
||||
|
||||
mod->settings->width = mod->width;
|
||||
mod->settings->height = mod->height;
|
||||
LIB_DEBUG(mod, "out lib_mod_start");
|
||||
@ -152,6 +152,7 @@ lib_mod_event(struct mod* mod, int msg, long param1, long param2,
|
||||
case 110:
|
||||
break;
|
||||
}
|
||||
|
||||
LIB_DEBUG(mod, "out lib_mod_event");
|
||||
return 0;
|
||||
}
|
||||
@ -182,6 +183,7 @@ static int DEFAULT_CC
|
||||
lib_mod_set_param(struct mod *mod, char *name, char *value)
|
||||
{
|
||||
g_writeln("lib_mod_set_param: name [%s] value [%s]", name, value);
|
||||
|
||||
if (g_strcmp(name, "hostname") == 0)
|
||||
{
|
||||
g_strncpy(mod->settings->hostname, value, sizeof(mod->settings->hostname));
|
||||
@ -208,6 +210,7 @@ lib_mod_set_param(struct mod* mod, char* name, char* value)
|
||||
{
|
||||
g_writeln("lib_mod_set_param: unknown name [%s] value [%s]", name, value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -314,6 +317,7 @@ ui_create_bitmap(rdpInst* inst, int width, int height, uint8* data)
|
||||
bm->bpp = bpp;
|
||||
bmpdata = convert_bitmap(mod->settings->server_depth, bpp,
|
||||
data, width, height, mod->cmap);
|
||||
|
||||
if (bmpdata == (char *)data)
|
||||
{
|
||||
size = width * height * ((bpp + 7) / 8);
|
||||
@ -324,6 +328,7 @@ ui_create_bitmap(rdpInst* inst, int width, int height, uint8* data)
|
||||
{
|
||||
bm->data = bmpdata;
|
||||
}
|
||||
|
||||
return bm;
|
||||
}
|
||||
|
||||
@ -338,10 +343,12 @@ ui_paint_bitmap(rdpInst* inst, int x, int y, int cx, int cy, int width,
|
||||
mod = GET_MOD(inst);
|
||||
bmpdata = convert_bitmap(mod->settings->server_depth, mod->bpp,
|
||||
data, width, height, mod->cmap);
|
||||
|
||||
if (bmpdata != 0)
|
||||
{
|
||||
mod->server_paint_rect(mod, x, y, cx, cy, bmpdata, width, height, 0, 0);
|
||||
}
|
||||
|
||||
if (bmpdata != (char *)data)
|
||||
{
|
||||
g_free(bmpdata);
|
||||
@ -510,6 +517,7 @@ ui_patblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
bgcolor, mod->cmap);
|
||||
mod->server_set_bgcolor(mod, bgcolor);
|
||||
mod->server_set_mixmode(mod, 1);
|
||||
|
||||
if (brush->bd != 0)
|
||||
{
|
||||
if (brush->bd->color_code == 1) /* 8x8 1 bpp */
|
||||
@ -518,6 +526,7 @@ ui_patblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
{
|
||||
idata[index] = ~(brush->bd->data[index]);
|
||||
}
|
||||
|
||||
mod->server_set_brush(mod, brush->xorigin, brush->yorigin,
|
||||
brush->style, idata);
|
||||
}
|
||||
@ -532,9 +541,11 @@ ui_patblt(rdpInst* inst, uint8 opcode, int x, int y, int cx, int cy,
|
||||
{
|
||||
idata[index] = ~(brush->pattern[index]);
|
||||
}
|
||||
|
||||
mod->server_set_brush(mod, brush->xorigin, brush->yorigin,
|
||||
brush->style, idata);
|
||||
}
|
||||
|
||||
mod->server_fill_rect(mod, x, y, cx, cy);
|
||||
mod->server_set_opcode(mod, 0xcc);
|
||||
mod->server_set_mixmode(mod, 0);
|
||||
@ -638,6 +649,7 @@ ui_set_cursor(rdpInst* inst, RD_HCURSOR cursor)
|
||||
//g_writeln("ui_set_cursor:");
|
||||
mod = GET_MOD(inst);
|
||||
cur = (struct my_cursor *)cursor;
|
||||
|
||||
if (cur != 0)
|
||||
{
|
||||
mod->server_set_cursor(mod, cur->hotx, cur->hoty,
|
||||
@ -657,11 +669,13 @@ ui_destroy_cursor(rdpInst* inst, RD_HCURSOR cursor)
|
||||
|
||||
//g_writeln("ui_destroy_cursor:");
|
||||
cur = (struct my_cursor *)cursor;
|
||||
|
||||
if (cur != 0)
|
||||
{
|
||||
g_free(cur->andmask);
|
||||
g_free(cur->xormask);
|
||||
}
|
||||
|
||||
g_free(cur);
|
||||
}
|
||||
|
||||
@ -724,11 +738,16 @@ l_set_pixel(tui8* data, int x, int y, int width, int height,
|
||||
width = (width + 7) / 8;
|
||||
start = (y * width) + x / 8;
|
||||
shift = x % 8;
|
||||
|
||||
if (pixel)
|
||||
{
|
||||
data[start] = data[start] | (0x80 >> shift);
|
||||
}
|
||||
else
|
||||
{
|
||||
data[start] = data[start] & ~(0x80 >> shift);
|
||||
}
|
||||
}
|
||||
else if (bpp == 24)
|
||||
{
|
||||
dst8 = data + (y * width + x) * 3;
|
||||
@ -775,9 +794,11 @@ ui_create_cursor(rdpInst* inst, unsigned int x, unsigned int y,
|
||||
cur->hoty = y;
|
||||
cur->andmask = g_malloc(32 * 32 * 4, 1);
|
||||
cur->xormask = g_malloc(32 * 32 * 4, 1);
|
||||
|
||||
for (j = 0; j < height; j++)
|
||||
{
|
||||
jj = (bpp != 1) ? j : (height - 1) - j;
|
||||
|
||||
for (i = 0; i < width; i++)
|
||||
{
|
||||
apixel = l_get_pixel(andmask, i, jj, width, height, 1);
|
||||
@ -787,6 +808,7 @@ ui_create_cursor(rdpInst* inst, unsigned int x, unsigned int y,
|
||||
l_set_pixel(cur->xormask, i, j, width, height, 24, xpixel);
|
||||
}
|
||||
}
|
||||
|
||||
return (RD_HCURSOR)cur;
|
||||
}
|
||||
|
||||
@ -820,11 +842,14 @@ ui_create_palette(rdpInst* inst, RD_PALETTE* colors)
|
||||
mod = GET_MOD(inst);
|
||||
g_writeln("ui_create_palette:");
|
||||
count = 256;
|
||||
|
||||
if (count > colors->count)
|
||||
{
|
||||
count = colors->count;
|
||||
}
|
||||
|
||||
cmap = (int *)g_malloc(256 * 4, 1);
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
red = colors->entries[index].red;
|
||||
@ -833,6 +858,7 @@ ui_create_palette(rdpInst* inst, RD_PALETTE* colors)
|
||||
pixel = COLOR24RGB(red, green, blue);
|
||||
cmap[index] = pixel;
|
||||
}
|
||||
|
||||
return (RD_HPALETTE)cmap;
|
||||
}
|
||||
|
||||
@ -946,10 +972,12 @@ mod_init(void)
|
||||
mod->settings->text_flags = 1;
|
||||
|
||||
mod->inst = freerdp_new(mod->settings);
|
||||
|
||||
if (mod->inst == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SET_MOD(mod->inst, mod);
|
||||
mod->inst->ui_error = ui_error;
|
||||
mod->inst->ui_warning = ui_warning;
|
||||
@ -1012,6 +1040,7 @@ mod_exit(struct mod* mod)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
freerdp_free(mod->inst);
|
||||
g_free(mod->settings);
|
||||
g_free(mod);
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2010
|
||||
|
||||
freerdp wrapper
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* freerdp wrapper
|
||||
*/
|
||||
|
||||
/* include other h files */
|
||||
|
@ -38,6 +38,7 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
out = (char *)g_malloc(width * height, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -51,13 +52,16 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -71,13 +75,16 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -91,13 +98,16 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -110,13 +120,16 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -129,21 +142,26 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 15))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -156,13 +174,16 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -178,16 +199,20 @@ convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 24))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 32))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
g_writeln("convert_bitmap: error unknown conversion from %d to %d",
|
||||
in_bpp, out_bpp);
|
||||
return 0;
|
||||
@ -208,6 +233,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = in_color == 0 ? 0 : 0xffffff;
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 8))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@ -215,6 +241,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR8(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@ -222,6 +249,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR16(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@ -229,6 +257,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
pixel = in_color;
|
||||
@ -236,6 +265,7 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR16(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
@ -243,14 +273,17 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 15))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
@ -258,18 +291,22 @@ convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 24))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 32) && (out_bpp == 32))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
g_writeln("convert_color: error unknown conversion from %d to %d",
|
||||
in_bpp, out_bpp);
|
||||
return 0;
|
||||
|
@ -72,6 +72,7 @@ lxrdp_connect(struct mod* mod)
|
||||
{
|
||||
LLOGLN(0, ("Failure to connect"));
|
||||
#ifdef ERRORSTART
|
||||
|
||||
if (connectErrorCode != 0)
|
||||
{
|
||||
char buf[128];
|
||||
@ -126,11 +127,14 @@ lxrdp_connect(struct mod* mod)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
mod->server_msg(mod, buf, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -150,6 +154,7 @@ lxrdp_event(struct mod* mod, int msg, long param1, long param2,
|
||||
char *data;
|
||||
|
||||
LLOGLN(10, ("lxrdp_event: msg %d", msg));
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case 15: /* key down */
|
||||
@ -231,6 +236,7 @@ lxrdp_event(struct mod* mod, int msg, long param1, long param2,
|
||||
rectangle->top = param1 & 0xffff;
|
||||
rectangle->right = (((param2 >> 16) & 0xffff) + rectangle->left) - 1;
|
||||
rectangle->bottom = ((param2 & 0xffff) + rectangle->top) - 1;
|
||||
|
||||
if (mod->inst->settings->refresh_rect)
|
||||
{
|
||||
if (mod->inst->update != NULL)
|
||||
@ -262,6 +268,7 @@ lxrdp_event(struct mod* mod, int msg, long param1, long param2,
|
||||
{
|
||||
LLOGLN(0, ("Invalidate request - warning - update rectangle is disabled"));
|
||||
}
|
||||
|
||||
g_free(rectangle);
|
||||
break;
|
||||
case 0x5555:
|
||||
@ -271,12 +278,15 @@ lxrdp_event(struct mod* mod, int msg, long param1, long param2,
|
||||
data = (char *)param3;
|
||||
total_size = (int)param4;
|
||||
LLOGLN(10, ("lxrdp_event: client to server flags %d", flags));
|
||||
|
||||
if ((chanid < 0) || (chanid >= mod->inst->settings->num_channels))
|
||||
{
|
||||
LLOGLN(0, ("lxrdp_event: error chanid %d", chanid));
|
||||
break;
|
||||
}
|
||||
|
||||
lchid = mod->inst->settings->channels[chanid].channel_id;
|
||||
|
||||
switch (flags & 3)
|
||||
{
|
||||
case 3:
|
||||
@ -308,11 +318,13 @@ lxrdp_event(struct mod* mod, int msg, long param1, long param2,
|
||||
mod->chan_buf_valid += size;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
LLOGLN(0, ("Unhandled message type in eventhandler %d", msg));
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -340,6 +352,7 @@ lxrdp_end(struct mod* mod)
|
||||
g_free(mod->bitmap_cache[j][i].data);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
if (mod->brush_cache[i].data != mod->brush_cache[i].b8x8)
|
||||
@ -347,6 +360,7 @@ lxrdp_end(struct mod* mod)
|
||||
g_free(mod->brush_cache[i].data);
|
||||
}
|
||||
}
|
||||
|
||||
LLOGLN(10, ("lxrdp_end:"));
|
||||
return 0;
|
||||
}
|
||||
@ -426,11 +440,13 @@ lxrdp_get_wait_objs(struct mod* mod, tbus* read_objs, int* rcount,
|
||||
rfds = (void **)read_objs;
|
||||
wfds = (void **)write_objs;
|
||||
ok = freerdp_get_fds(mod->inst, rfds, rcount, wfds, wcount);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
LLOGLN(0, ("lxrdp_get_wait_objs: freerdp_get_fds failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -442,11 +458,13 @@ lxrdp_check_wait_objs(struct mod* mod)
|
||||
|
||||
LLOGLN(10, ("lxrdp_check_wait_objs:"));
|
||||
ok = freerdp_check_fds(mod->inst);
|
||||
|
||||
if (!ok)
|
||||
{
|
||||
LLOGLN(0, ("lxrdp_check_wait_objs: freerdp_check_fds failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -484,6 +502,7 @@ lfreerdp_set_bounds(rdpContext* context, rdpBounds* bounds)
|
||||
|
||||
LLOGLN(10, ("lfreerdp_set_bounds: %p", bounds));
|
||||
mod = ((struct mod_context *)context)->modi;
|
||||
|
||||
if (bounds != 0)
|
||||
{
|
||||
x = bounds->left;
|
||||
@ -531,15 +550,18 @@ lfreerdp_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap)
|
||||
cy = (bd->destBottom - bd->destTop) + 1;
|
||||
line_bytes = server_Bpp * bd->width;
|
||||
dst_data = (char *)g_malloc(bd->height * line_bytes + 16, 0);
|
||||
|
||||
if (bd->compressed)
|
||||
{
|
||||
bitmap_decompress(bd->bitmapDataStream, (tui8 *)dst_data, bd->width,
|
||||
bd->height, bd->bitmapLength, server_bpp, server_bpp);
|
||||
}
|
||||
else
|
||||
{ /* bitmap is upside down */
|
||||
{
|
||||
/* bitmap is upside down */
|
||||
src = (char *)(bd->bitmapDataStream);
|
||||
dst = dst_data + bd->height * line_bytes;
|
||||
|
||||
for (j = 0; j < bd->height; j++)
|
||||
{
|
||||
dst -= line_bytes;
|
||||
@ -547,14 +569,17 @@ lfreerdp_bitmap_update(rdpContext* context, BITMAP_UPDATE* bitmap)
|
||||
src += line_bytes;
|
||||
}
|
||||
}
|
||||
|
||||
dst_data1 = convert_bitmap(server_bpp, client_bpp, dst_data,
|
||||
bd->width, bd->height, mod->colormap);
|
||||
mod->server_paint_rect(mod, bd->destLeft, bd->destTop, cx, cy,
|
||||
dst_data1, bd->width, bd->height, 0, 0);
|
||||
|
||||
if (dst_data1 != dst_data)
|
||||
{
|
||||
g_free(dst_data1);
|
||||
}
|
||||
|
||||
g_free(dst_data);
|
||||
}
|
||||
}
|
||||
@ -605,11 +630,13 @@ lfreerdp_pat_blt(rdpContext* context, PATBLT_ORDER* patblt)
|
||||
if (patblt->brush.style & 0x80)
|
||||
{
|
||||
idx = patblt->brush.hatch;
|
||||
|
||||
if ((idx < 0) || (idx >= 64))
|
||||
{
|
||||
LLOGLN(0, ("lfreerdp_pat_blt: error"));
|
||||
return;
|
||||
}
|
||||
|
||||
bi = mod->brush_cache + idx;
|
||||
mod->server_set_brush(mod, patblt->brush.x, patblt->brush.y,
|
||||
3, bi->b8x8);
|
||||
@ -620,6 +647,7 @@ lfreerdp_pat_blt(rdpContext* context, PATBLT_ORDER* patblt)
|
||||
patblt->brush.style,
|
||||
(char *)(patblt->brush.p8x8));
|
||||
}
|
||||
|
||||
mod->server_fill_rect(mod, patblt->nLeftRect, patblt->nTopRect,
|
||||
patblt->nWidth, patblt->nHeight);
|
||||
mod->server_set_opcode(mod, 0xcc);
|
||||
@ -688,6 +716,7 @@ lfreerdp_mem_blt(rdpContext* context, MEMBLT_ORDER* memblt)
|
||||
LLOGLN(0, ("lfreerdp_mem_blt: bad id [%d]", id));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((idx < 0) || (idx >= 4096))
|
||||
{
|
||||
LLOGLN(0, ("lfreerdp_mem_blt: bad idx [%d]", idx));
|
||||
@ -784,9 +813,11 @@ lfreerdp_upsidedown(uint8* destination, CACHE_BITMAP_V2_ORDER* cache_bitmap_v2_o
|
||||
LLOGLN(0, ("lfreerdp_upsidedown: destination pointer is NULL !!!"));
|
||||
return;
|
||||
}
|
||||
|
||||
line_bytes = server_Bpp * cache_bitmap_v2_order->bitmapWidth;
|
||||
src = cache_bitmap_v2_order->bitmapDataStream;
|
||||
dst = destination + ((cache_bitmap_v2_order->bitmapHeight) * line_bytes);
|
||||
|
||||
for (j = 0; j < cache_bitmap_v2_order->bitmapHeight; j++)
|
||||
{
|
||||
dst -= line_bytes;
|
||||
@ -823,15 +854,18 @@ lfreerdp_cache_bitmapV2(rdpContext* context,
|
||||
id = cache_bitmap_v2_order->cacheId;
|
||||
idx = cache_bitmap_v2_order->cacheIndex;
|
||||
flags = cache_bitmap_v2_order->flags;
|
||||
|
||||
if (flags & 0x10) /* CBR2_DO_NOT_CACHE */
|
||||
{
|
||||
idx = 4096 - 1;
|
||||
}
|
||||
|
||||
if ((id < 0) || (id >= 4))
|
||||
{
|
||||
LLOGLN(0, ("lfreerdp_cache_bitmapV2: bad id [%d]", id));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((idx < 0) || (idx >= 4096))
|
||||
{
|
||||
LLOGLN(0, ("lfreerdp_cache_bitmapV2: bad idx [%d]", idx));
|
||||
@ -846,6 +880,7 @@ lfreerdp_cache_bitmapV2(rdpContext* context,
|
||||
height = cache_bitmap_v2_order->bitmapHeight;
|
||||
bytes = width * height * server_Bpp + 16;
|
||||
dst_data = (char *)g_malloc(bytes, 0);
|
||||
|
||||
if (cache_bitmap_v2_order->compressed)
|
||||
{
|
||||
bitmap_decompress(cache_bitmap_v2_order->bitmapDataStream,
|
||||
@ -859,12 +894,14 @@ lfreerdp_cache_bitmapV2(rdpContext* context,
|
||||
lfreerdp_upsidedown((tui8 *)dst_data, cache_bitmap_v2_order, server_Bpp);
|
||||
LLOGLN(10, ("lfreerdp_cache_bitmapV2: upside down progressed"));
|
||||
}
|
||||
|
||||
dst_data1 = convert_bitmap(server_bpp, client_bpp, dst_data,
|
||||
width, height, mod->colormap);
|
||||
g_free(mod->bitmap_cache[id][idx].data);
|
||||
mod->bitmap_cache[id][idx].width = width;
|
||||
mod->bitmap_cache[id][idx].height = height;
|
||||
mod->bitmap_cache[id][idx].data = dst_data1;
|
||||
|
||||
if (dst_data != dst_data1)
|
||||
{
|
||||
g_free(dst_data);
|
||||
@ -881,6 +918,7 @@ lfreerdp_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph_order)
|
||||
|
||||
mod = ((struct mod_context *)context)->modi;
|
||||
LLOGLN(10, ("lfreerdp_cache_glyph: %d", cache_glyph_order->cGlyphs));
|
||||
|
||||
for (index = 0; index < cache_glyph_order->cGlyphs; index++)
|
||||
{
|
||||
gd = cache_glyph_order->glyphData[index];
|
||||
@ -893,6 +931,7 @@ lfreerdp_cache_glyph(rdpContext* context, CACHE_GLYPH_ORDER* cache_glyph_order)
|
||||
xfree(gd);
|
||||
cache_glyph_order->glyphData[index] = 0;
|
||||
}
|
||||
|
||||
xfree(cache_glyph_order->unicodeCharacters);
|
||||
cache_glyph_order->unicodeCharacters = 0;
|
||||
}
|
||||
@ -916,26 +955,32 @@ lfreerdp_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush_order)
|
||||
bytes = cache_brush_order->length;
|
||||
LLOGLN(10, ("lfreerdp_cache_brush: bpp %d cx %d cy %d idx %d bytes %d",
|
||||
bpp, cx, cy, idx, bytes));
|
||||
|
||||
if ((idx < 0) || (idx >= 64))
|
||||
{
|
||||
LLOGLN(0, ("lfreerdp_cache_brush: error idx %d", idx));
|
||||
return;
|
||||
}
|
||||
|
||||
if ((bpp != 1) || (cx != 8) || (cy != 8))
|
||||
{
|
||||
LLOGLN(0, ("lfreerdp_cache_brush: error unsupported brush "
|
||||
"bpp %d cx %d cy %d", bpp, cx, cy));
|
||||
return;
|
||||
}
|
||||
|
||||
mod->brush_cache[idx].bpp = bpp;
|
||||
mod->brush_cache[idx].width = cx;
|
||||
mod->brush_cache[idx].height = cy;
|
||||
mod->brush_cache[idx].data = mod->brush_cache[idx].b8x8;
|
||||
|
||||
if (bytes > 8)
|
||||
{
|
||||
bytes = 8;
|
||||
}
|
||||
|
||||
g_memset(mod->brush_cache[idx].data, 0, 8);
|
||||
|
||||
if (bytes > 0)
|
||||
{
|
||||
if (bytes > 8)
|
||||
@ -943,8 +988,10 @@ lfreerdp_cache_brush(rdpContext* context, CACHE_BRUSH_ORDER* cache_brush_order)
|
||||
LLOGLN(0, ("lfreerdp_cache_brush: bytes to big %d", bytes));
|
||||
bytes = 8;
|
||||
}
|
||||
|
||||
g_memcpy(mod->brush_cache[idx].data, cache_brush_order->data, bytes);
|
||||
}
|
||||
|
||||
LLOGLN(10, ("lfreerdp_cache_brush: out bpp %d cx %d cy %d idx %d bytes %d",
|
||||
bpp, cx, cy, idx, bytes));
|
||||
|
||||
@ -999,6 +1046,7 @@ lfreerdp_get_pixel(void* bits, int width, int height, int bpp,
|
||||
{
|
||||
LLOGLN(0, ("lfreerdp_get_pixel: unknown bpp %d", bpp));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1016,6 +1064,7 @@ lfreerdp_set_pixel(int pixel, void* bits, int width, int height, int bpp,
|
||||
dst8 = (tui8 *)bits;
|
||||
start = (y * delta) + x / 8;
|
||||
shift = x % 8;
|
||||
|
||||
if (pixel)
|
||||
{
|
||||
dst8[start] = dst8[start] | (0x80 >> shift);
|
||||
@ -1037,6 +1086,7 @@ lfreerdp_set_pixel(int pixel, void* bits, int width, int height, int bpp,
|
||||
{
|
||||
LLOGLN(0, ("lfreerdp_set_pixel: unknown bpp %d", bpp));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1061,6 +1111,7 @@ lfreerdp_convert_color_image(void* dst, int dst_width, int dst_height,
|
||||
dst_delta, i, j);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1085,6 +1136,7 @@ lfreerdp_pointer_new(rdpContext* context,
|
||||
pointer_new->colorPtrAttr.lengthAndMask));
|
||||
|
||||
index = pointer_new->colorPtrAttr.cacheIndex;
|
||||
|
||||
if (pointer_new->xorBpp == 1 &&
|
||||
pointer_new->colorPtrAttr.width == 32 &&
|
||||
pointer_new->colorPtrAttr.height == 32 &&
|
||||
@ -1159,6 +1211,7 @@ lfreerdp_pre_connect(freerdp* instance)
|
||||
num_chans = 0;
|
||||
index = 0;
|
||||
error = mod->server_query_channel(mod, index, ch_name, &ch_flags);
|
||||
|
||||
while (error == 0)
|
||||
{
|
||||
num_chans++;
|
||||
@ -1171,6 +1224,7 @@ lfreerdp_pre_connect(freerdp* instance)
|
||||
index++;
|
||||
error = mod->server_query_channel(mod, index, ch_name, &ch_flags);
|
||||
}
|
||||
|
||||
instance->settings->num_channels = num_chans;
|
||||
|
||||
instance->settings->offscreen_bitmap_cache = false;
|
||||
@ -1276,11 +1330,13 @@ lrail_WindowCreate(rdpContext* context, WINDOW_ORDER_INFO* orderInfo,
|
||||
wso.style = window_state->style;
|
||||
wso.extended_style = window_state->extendedStyle;
|
||||
wso.show_state = window_state->showState;
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_TITLE)
|
||||
{
|
||||
wso.title_info = freerdp_uniconv_in(uniconv,
|
||||
window_state->titleInfo.string, window_state->titleInfo.length);
|
||||
}
|
||||
|
||||
LLOGLN(0, ("lrail_WindowCreate: %s", wso.title_info));
|
||||
wso.client_offset_x = window_state->clientOffsetX;
|
||||
wso.client_offset_y = window_state->clientOffsetY;
|
||||
@ -1295,10 +1351,12 @@ lrail_WindowCreate(rdpContext* context, WINDOW_ORDER_INFO* orderInfo,
|
||||
wso.window_width = window_state->windowWidth;
|
||||
wso.window_height = window_state->windowHeight;
|
||||
wso.num_window_rects = window_state->numWindowRects;
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_WND_RECTS)
|
||||
{
|
||||
wso.window_rects = (struct rail_window_rect *)
|
||||
g_malloc(sizeof(struct rail_window_rect) * wso.num_window_rects, 0);
|
||||
|
||||
for (index = 0; index < wso.num_window_rects; index++)
|
||||
{
|
||||
wso.window_rects[index].left = window_state->windowRects[index].left;
|
||||
@ -1307,13 +1365,16 @@ lrail_WindowCreate(rdpContext* context, WINDOW_ORDER_INFO* orderInfo,
|
||||
wso.window_rects[index].bottom = window_state->windowRects[index].bottom;
|
||||
}
|
||||
}
|
||||
|
||||
wso.visible_offset_x = window_state->visibleOffsetX;
|
||||
wso.visible_offset_y = window_state->visibleOffsetY;
|
||||
wso.num_visibility_rects = window_state->numVisibilityRects;
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
|
||||
{
|
||||
wso.visibility_rects = (struct rail_window_rect *)
|
||||
g_malloc(sizeof(struct rail_window_rect) * wso.num_visibility_rects, 0);
|
||||
|
||||
for (index = 0; index < wso.num_visibility_rects; index++)
|
||||
{
|
||||
wso.visibility_rects[index].left = window_state->visibilityRects[index].left;
|
||||
@ -1410,11 +1471,13 @@ lrail_NotifyIconCreate(rdpContext* context, WINDOW_ORDER_INFO* orderInfo,
|
||||
|
||||
memset(&rnso, 0, sizeof(rnso));
|
||||
rnso.version = notify_icon_state->version;
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_TIP)
|
||||
{
|
||||
rnso.tool_tip = freerdp_uniconv_in(uniconv,
|
||||
notify_icon_state->toolTip.string, notify_icon_state->toolTip.length);
|
||||
}
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP)
|
||||
{
|
||||
rnso.infotip.timeout = notify_icon_state->infoTip.timeout;
|
||||
@ -1426,6 +1489,7 @@ lrail_NotifyIconCreate(rdpContext* context, WINDOW_ORDER_INFO* orderInfo,
|
||||
notify_icon_state->infoTip.title.string,
|
||||
notify_icon_state->infoTip.title.length);
|
||||
}
|
||||
|
||||
rnso.state = notify_icon_state->state;
|
||||
rnso.icon_cache_entry = notify_icon_state->icon.cacheEntry;
|
||||
rnso.icon_cache_id = notify_icon_state->icon.cacheId;
|
||||
@ -1486,17 +1550,20 @@ lrail_MonitoredDesktop(rdpContext* context, WINDOW_ORDER_INFO* orderInfo,
|
||||
memset(&rmdo, 0, sizeof(rmdo));
|
||||
rmdo.active_window_id = monitored_desktop->activeWindowId;
|
||||
rmdo.num_window_ids = monitored_desktop->numWindowIds;
|
||||
|
||||
if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
|
||||
{
|
||||
if (rmdo.num_window_ids > 0)
|
||||
{
|
||||
rmdo.window_ids = (int *)g_malloc(sizeof(int) * rmdo.num_window_ids, 0);
|
||||
|
||||
for (index = 0; index < rmdo.num_window_ids; index++)
|
||||
{
|
||||
rmdo.window_ids[index] = monitored_desktop->windowIds[index];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod->server_monitored_desktop(mod, &rmdo, orderInfo->fieldFlags);
|
||||
g_free(rmdo.window_ids);
|
||||
}
|
||||
@ -1564,6 +1631,7 @@ lfreerdp_receive_channel_data(freerdp* instance, int channelId, uint8* data,
|
||||
|
||||
mod = ((struct mod_context *)(instance->context))->modi;
|
||||
lchid = -1;
|
||||
|
||||
for (index = 0; index < instance->settings->num_channels; index++)
|
||||
{
|
||||
if (instance->settings->channels[index].channel_id == channelId)
|
||||
@ -1572,11 +1640,13 @@ lfreerdp_receive_channel_data(freerdp* instance, int channelId, uint8* data,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lchid >= 0)
|
||||
{
|
||||
LLOGLN(10, ("lfreerdp_receive_channel_data: server to client"));
|
||||
error = mod->server_send_to_channel(mod, lchid, (char *)data, size,
|
||||
total_size, flags);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
LLOGLN(0, ("lfreerdp_receive_channel_data: error %d", error));
|
||||
@ -1586,6 +1656,7 @@ lfreerdp_receive_channel_data(freerdp* instance, int channelId, uint8* data,
|
||||
{
|
||||
LLOGLN(0, ("lfreerdp_receive_channel_data: bad lchid"));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1656,17 +1727,21 @@ int EXPORT_CC
|
||||
mod_exit(struct mod *mod)
|
||||
{
|
||||
LLOGLN(0, ("mod_exit:"));
|
||||
|
||||
if (mod == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (mod->inst == NULL)
|
||||
{
|
||||
LLOGLN(0, ("mod_exit - null pointer for inst:"));
|
||||
g_free(mod);
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
freerdp_disconnect(mod->inst);
|
||||
|
||||
if ((mod->vmaj == 1) && (mod->vmin == 0) && (mod->vrev == 1))
|
||||
{
|
||||
/* this version has a bug with double free in freerdp_free */
|
||||
@ -1675,6 +1750,7 @@ mod_exit(struct mod* mod)
|
||||
{
|
||||
freerdp_context_free(mod->inst);
|
||||
}
|
||||
|
||||
freerdp_free(mod->inst);
|
||||
g_free(mod);
|
||||
return 0;
|
||||
|
@ -60,37 +60,45 @@ int main(int argc, char **argv)
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
programname = argv[0];
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s out_filename\n", programname);
|
||||
fprintf(stderr, "Example: %s /etc/xrdp/km-0409.ini\n", programname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
outfname = argv[1];
|
||||
dpy = XOpenDisplay(displayname);
|
||||
|
||||
if (!dpy)
|
||||
{
|
||||
fprintf(stderr, "%s: unable to open display '%s'\n",
|
||||
programname, XDisplayName(displayname));
|
||||
return 1;
|
||||
}
|
||||
|
||||
outf = fopen(outfname, "w");
|
||||
|
||||
if (outf == NULL)
|
||||
{
|
||||
fprintf(stderr, "%s: unable to create file '%s'\n", programname, outfname);
|
||||
XCloseDisplay(dpy);
|
||||
return 1;
|
||||
}
|
||||
|
||||
memset(&e, 0, sizeof(e));
|
||||
e.type = KeyPress;
|
||||
e.serial = 16;
|
||||
e.send_event = True;
|
||||
e.display = dpy;
|
||||
e.same_screen = True;
|
||||
|
||||
for (idx = 0; idx < 5; idx++) /* Sections and states */
|
||||
{
|
||||
fprintf(outf, "[%s]\n", sections[idx]);
|
||||
e.state = states[idx];
|
||||
|
||||
for (i = 8; i <= 137; i++) /* Keycodes */
|
||||
{
|
||||
e.keycode = i;
|
||||
@ -98,17 +106,21 @@ int main(int argc, char **argv)
|
||||
text[nbytes] = 0;
|
||||
char_count = mbstowcs(wtext, text, 255);
|
||||
unicode = 0;
|
||||
|
||||
if (char_count == 1)
|
||||
{
|
||||
unicode = wtext[0];
|
||||
}
|
||||
|
||||
fprintf(outf, "Key%d=%d:%d\n", i, (int) ks, unicode);
|
||||
}
|
||||
|
||||
if (idx != 4)
|
||||
{
|
||||
fprintf(outf, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
XCloseDisplay(dpy);
|
||||
fclose(outf);
|
||||
return 0;
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2007-2010
|
||||
|
||||
rsa key generator for xrdp
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* rsa key generator for xrdp
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -137,6 +135,7 @@ sign_key(char* e_data, int e_len, char* n_data, int n_len,
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
key = (char *)g_malloc(176, 0);
|
||||
md5_final = (char *)g_malloc(64, 0);
|
||||
md5 = ssl_md5_info_create();
|
||||
@ -187,15 +186,18 @@ write_out_line(int fd, char* name, char* data, int len)
|
||||
g_strncpy(buf, name, max - 1);
|
||||
buf[buf_pos] = '=';
|
||||
buf_pos++;
|
||||
|
||||
for (index = 0; index < len; index++)
|
||||
{
|
||||
data_item = (tui8)(data[index]);
|
||||
g_snprintf(text, 255, "0x%2.2x", data_item);
|
||||
|
||||
if (index != 0)
|
||||
{
|
||||
buf[buf_pos] = ',';
|
||||
buf_pos++;
|
||||
}
|
||||
|
||||
buf[buf_pos] = text[0];
|
||||
buf_pos++;
|
||||
buf[buf_pos] = text[1];
|
||||
@ -205,6 +207,7 @@ write_out_line(int fd, char* name, char* data, int len)
|
||||
buf[buf_pos] = text[3];
|
||||
buf_pos++;
|
||||
}
|
||||
|
||||
buf[buf_pos] = '\n';
|
||||
buf_pos++;
|
||||
buf[buf_pos] = 0;
|
||||
@ -231,8 +234,10 @@ save_all(char* e_data, int e_len, char* n_data, int n_len,
|
||||
{
|
||||
g_strncpy(filename, path_and_file_name, 255);
|
||||
}
|
||||
|
||||
g_writeln("saving to %s", filename);
|
||||
g_writeln("");
|
||||
|
||||
if (g_file_exist(filename))
|
||||
{
|
||||
if (g_file_delete(filename) == 0)
|
||||
@ -241,7 +246,9 @@ save_all(char* e_data, int e_len, char* n_data, int n_len,
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
fd = g_file_open(filename);
|
||||
|
||||
if (fd > 0)
|
||||
{
|
||||
if (g_file_write(fd, "[keys]\n", 7) == -1)
|
||||
@ -249,6 +256,7 @@ save_all(char* e_data, int e_len, char* n_data, int n_len,
|
||||
g_writeln("problem writing to %s, maybe no rights", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
write_out_line(fd, "pub_exp", e_data, e_len);
|
||||
write_out_line(fd, "pub_mod", n_data, n_len);
|
||||
write_out_line(fd, "pub_sig", sign_data, sign_len);
|
||||
@ -259,6 +267,7 @@ save_all(char* e_data, int e_len, char* n_data, int n_len,
|
||||
g_writeln("problem opening %s, maybe no rights", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_file_close(fd);
|
||||
return 0;
|
||||
}
|
||||
@ -289,34 +298,41 @@ key_gen(const char* path_and_file_name)
|
||||
g_writeln("");
|
||||
g_writeln("Generating %d bit rsa key...", MY_KEY_SIZE);
|
||||
g_writeln("");
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
error = ssl_gen_key_xrdp1(MY_KEY_SIZE, e_data, e_len, n_data, n_len,
|
||||
d_data, d_len);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
g_writeln("error %d in key_gen, ssl_gen_key_xrdp1", error);
|
||||
}
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
g_writeln("ssl_gen_key_xrdp1 ok");
|
||||
g_writeln("");
|
||||
error = sign_key(e_data, e_len, n_data, n_len, sign_data, sign_len);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
g_writeln("error %d in key_gen, sign_key", error);
|
||||
}
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
error = save_all(e_data, e_len, n_data, n_len, d_data, d_len,
|
||||
sign_data, sign_len, path_and_file_name);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
g_writeln("error %d in key_gen, save_all", error);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(n_data);
|
||||
g_free(d_data);
|
||||
g_free(sign_data);
|
||||
@ -340,26 +356,32 @@ key_gen_run_it(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (g_file_get_size("/etc/xrdp/rsakeys.ini") < 10)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
fd = g_file_open("/etc/xrdp/rsakeys.ini");
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
names = list_create();
|
||||
names->auto_free = 1;
|
||||
values = list_create();
|
||||
values->auto_free = 1;
|
||||
|
||||
if (file_read_section(fd, "keys", names, values) == 0)
|
||||
{
|
||||
for (index = 0; index < names->count; index++)
|
||||
{
|
||||
name = (char *)list_get_item(names, index);
|
||||
value = (char *)list_get_item(values, index);
|
||||
|
||||
if (g_strcasecmp(name, "pub_sig") == 0)
|
||||
{
|
||||
if (g_strcasecmp(value, inst_pub_sig) == 0)
|
||||
@ -373,6 +395,7 @@ key_gen_run_it(void)
|
||||
{
|
||||
g_writeln("error reading keys section of rsakeys.ini");
|
||||
}
|
||||
|
||||
list_delete(names);
|
||||
list_delete(values);
|
||||
g_file_close(fd);
|
||||
@ -387,6 +410,7 @@ key_gen_auto(void)
|
||||
{
|
||||
return key_gen("/etc/xrdp/rsakeys.ini");
|
||||
}
|
||||
|
||||
g_writeln("xrdp-keygen does not need to run");
|
||||
return 0;
|
||||
}
|
||||
@ -451,6 +475,7 @@ main(int argc, char** argv)
|
||||
g_writeln("must run as root");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return key_gen_auto();
|
||||
}
|
||||
else
|
||||
@ -468,6 +493,7 @@ main(int argc, char** argv)
|
||||
return key_test();
|
||||
}
|
||||
}
|
||||
|
||||
out_params();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
this is the interface to libxrdp
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* this is the interface to libxrdp
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
@ -46,6 +44,7 @@ libxrdp_exit(struct xrdp_session* session)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
xrdp_orders_delete((struct xrdp_orders *)session->orders);
|
||||
xrdp_rdp_delete((struct xrdp_rdp *)session->rdp);
|
||||
free_stream(session->s);
|
||||
@ -81,6 +80,7 @@ libxrdp_process_data(struct xrdp_session* session)
|
||||
cont = 1;
|
||||
rv = 0;
|
||||
dead_lock_counter = 0;
|
||||
|
||||
while ((cont || !session->up_and_running) && !term)
|
||||
{
|
||||
if (session->is_term != 0)
|
||||
@ -90,14 +90,18 @@ libxrdp_process_data(struct xrdp_session* session)
|
||||
term = 1;
|
||||
}
|
||||
}
|
||||
|
||||
code = 0;
|
||||
|
||||
if (xrdp_rdp_recv((struct xrdp_rdp *)(session->rdp),
|
||||
session->s, &code) != 0)
|
||||
{
|
||||
rv = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG(("libxrdp_process_data code %d", code));
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case -1:
|
||||
@ -112,6 +116,7 @@ libxrdp_process_data(struct xrdp_session* session)
|
||||
session->s);
|
||||
break;
|
||||
case RDP_PDU_DATA: /* 7 */
|
||||
|
||||
if (xrdp_rdp_process_data((struct xrdp_rdp *)session->rdp,
|
||||
session->s) != 0)
|
||||
{
|
||||
@ -119,12 +124,14 @@ libxrdp_process_data(struct xrdp_session* session)
|
||||
cont = 0;
|
||||
term = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
g_writeln("unknown in libxrdp_process_data");
|
||||
dead_lock_counter++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (dead_lock_counter > 100000)
|
||||
{
|
||||
/*This situation can happen and this is a workaround*/
|
||||
@ -133,12 +140,14 @@ libxrdp_process_data(struct xrdp_session* session)
|
||||
g_writeln("remaining :%d", session->s->end - session->s->next_packet);
|
||||
session->s->next_packet = 0;
|
||||
}
|
||||
|
||||
if (cont)
|
||||
{
|
||||
cont = (session->s->next_packet != 0) &&
|
||||
(session->s->next_packet < session->s->end);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -154,6 +163,7 @@ libxrdp_send_palette(struct xrdp_session* session, int* palette)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEBUG(("libxrdp_send_palette sending palette"));
|
||||
/* clear orders */
|
||||
libxrdp_orders_force_send(session);
|
||||
@ -164,6 +174,7 @@ libxrdp_send_palette(struct xrdp_session* session, int* palette)
|
||||
out_uint16_le(s, 0);
|
||||
out_uint16_le(s, 256); /* # of colors */
|
||||
out_uint16_le(s, 0);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
color = palette[i];
|
||||
@ -171,6 +182,7 @@ libxrdp_send_palette(struct xrdp_session* session, int* palette)
|
||||
out_uint8(s, color >> 8);
|
||||
out_uint8(s, color);
|
||||
}
|
||||
|
||||
s_mark_end(s);
|
||||
xrdp_rdp_send_data((struct xrdp_rdp *)session->rdp, s, RDP_DATA_PDU_UPDATE);
|
||||
free_stream(s);
|
||||
@ -198,14 +210,17 @@ libxrdp_send_bell(struct xrdp_session* session)
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, 440); /* frequency */
|
||||
out_uint32_le(s, 100); /* duration (ms) */
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data((struct xrdp_rdp *)session->rdp, s, RDP_DATA_PDU_PLAY_SOUND) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -235,22 +250,27 @@ libxrdp_send_bitmap(struct xrdp_session* session, int width, int height,
|
||||
DEBUG(("libxrdp_send_bitmap sending bitmap"));
|
||||
Bpp = (bpp + 7) / 8;
|
||||
e = width % 4;
|
||||
|
||||
if (e != 0)
|
||||
{
|
||||
e = 4 - e;
|
||||
}
|
||||
|
||||
line_size = width * Bpp;
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (session->client_info->use_bitmap_comp)
|
||||
{
|
||||
make_stream(temp_s);
|
||||
init_stream(temp_s, 65536);
|
||||
i = 0;
|
||||
|
||||
if (cy <= height)
|
||||
{
|
||||
i = cy;
|
||||
}
|
||||
|
||||
while (i > 0)
|
||||
{
|
||||
total_bufsize = 0;
|
||||
@ -259,6 +279,7 @@ libxrdp_send_bitmap(struct xrdp_session* session, int width, int height,
|
||||
out_uint16_le(s, RDP_UPDATE_BITMAP);
|
||||
p_num_updates = s->p;
|
||||
out_uint8s(s, 2); /* num_updates set later */
|
||||
|
||||
do
|
||||
{
|
||||
if (session->client_info->op1)
|
||||
@ -269,15 +290,18 @@ libxrdp_send_bitmap(struct xrdp_session* session, int width, int height,
|
||||
{
|
||||
s_push_layer(s, channel_hdr, 26);
|
||||
}
|
||||
|
||||
p = s->p;
|
||||
lines_sending = xrdp_bitmap_compress(data, width, height,
|
||||
s, bpp,
|
||||
4096 - total_bufsize,
|
||||
i - 1, temp_s, e);
|
||||
|
||||
if (lines_sending == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
num_updates++;
|
||||
bufsize = s->p - p;
|
||||
total_bufsize += bufsize;
|
||||
@ -291,6 +315,7 @@ libxrdp_send_bitmap(struct xrdp_session* session, int width, int height,
|
||||
out_uint16_le(s, width + e); /* width */
|
||||
out_uint16_le(s, lines_sending); /* height */
|
||||
out_uint16_le(s, bpp); /* bpp */
|
||||
|
||||
if (session->client_info->op1)
|
||||
{
|
||||
out_uint16_le(s, 0x401); /* compress */
|
||||
@ -309,26 +334,33 @@ libxrdp_send_bitmap(struct xrdp_session* session, int width, int height,
|
||||
j = j * lines_sending;
|
||||
out_uint16_le(s, j); /* final size */
|
||||
}
|
||||
|
||||
if (j > 32768)
|
||||
{
|
||||
g_writeln("error, decompressed size too big, its %d", j);
|
||||
}
|
||||
|
||||
if (bufsize > 8192)
|
||||
{
|
||||
g_writeln("error, compressed size too big, its %d", bufsize);
|
||||
}
|
||||
|
||||
s->p = s->end;
|
||||
} while (total_bufsize < 4096 && i > 0);
|
||||
}
|
||||
while (total_bufsize < 4096 && i > 0);
|
||||
|
||||
p_num_updates[0] = num_updates;
|
||||
p_num_updates[1] = num_updates >> 8;
|
||||
xrdp_rdp_send_data((struct xrdp_rdp *)session->rdp, s,
|
||||
RDP_DATA_PDU_UPDATE);
|
||||
|
||||
if (total_bufsize > 8192)
|
||||
{
|
||||
g_writeln("error, total compressed size too big, its %d",
|
||||
total_bufsize);
|
||||
}
|
||||
}
|
||||
|
||||
free_stream(temp_s);
|
||||
}
|
||||
else
|
||||
@ -336,15 +368,18 @@ libxrdp_send_bitmap(struct xrdp_session* session, int width, int height,
|
||||
total_lines = height;
|
||||
i = 0;
|
||||
p = data;
|
||||
|
||||
if (line_size > 0 && total_lines > 0)
|
||||
{
|
||||
while (i < total_lines)
|
||||
{
|
||||
lines_sending = 4096 / (line_size + e * Bpp);
|
||||
|
||||
if (i + lines_sending > total_lines)
|
||||
{
|
||||
lines_sending = total_lines - i;
|
||||
}
|
||||
|
||||
p = p + line_size * lines_sending;
|
||||
xrdp_rdp_init_data((struct xrdp_rdp *)session->rdp, s);
|
||||
out_uint16_le(s, RDP_UPDATE_BITMAP);
|
||||
@ -359,12 +394,14 @@ libxrdp_send_bitmap(struct xrdp_session* session, int width, int height,
|
||||
out_uint16_le(s, 0); /* compress */
|
||||
out_uint16_le(s, (line_size + e * Bpp) * lines_sending); /* bufsize */
|
||||
q = p;
|
||||
|
||||
for (j = 0; j < lines_sending; j++)
|
||||
{
|
||||
q = q - line_size;
|
||||
out_uint8a(s, q, line_size); /* B_ENDIAN doesn't work here, todo */
|
||||
out_uint8s(s, e * Bpp);
|
||||
}
|
||||
|
||||
s_mark_end(s);
|
||||
xrdp_rdp_send_data((struct xrdp_rdp *)session->rdp, s,
|
||||
RDP_DATA_PDU_UPDATE);
|
||||
@ -372,6 +409,7 @@ libxrdp_send_bitmap(struct xrdp_session* session, int width, int height,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -400,6 +438,7 @@ libxrdp_send_pointer(struct xrdp_session* session, int cache_idx,
|
||||
out_uint16_le(s, 128);
|
||||
out_uint16_le(s, 3072);
|
||||
p = data;
|
||||
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
for (j = 0; j < 32; j++)
|
||||
@ -412,6 +451,7 @@ libxrdp_send_pointer(struct xrdp_session* session, int cache_idx,
|
||||
p++;
|
||||
}
|
||||
}
|
||||
|
||||
out_uint8a(s, mask, 128); /* mask */
|
||||
s_mark_end(s);
|
||||
xrdp_rdp_send_data((struct xrdp_rdp *)session->rdp, s, RDP_DATA_PDU_POINTER);
|
||||
@ -597,6 +637,7 @@ libxrdp_reset(struct xrdp_session* session,
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* if same, don't need to do anything */
|
||||
if (session->client_info->width == width &&
|
||||
session->client_info->height == height &&
|
||||
@ -604,6 +645,7 @@ libxrdp_reset(struct xrdp_session* session,
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
session->client_info->width = width;
|
||||
session->client_info->height = height;
|
||||
session->client_info->bpp = bpp;
|
||||
@ -612,27 +654,33 @@ libxrdp_reset(struct xrdp_session* session,
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* this will send any lingering orders */
|
||||
if (xrdp_orders_reset((struct xrdp_orders *)session->orders) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* shut down the rdp client */
|
||||
if (xrdp_rdp_send_deactive((struct xrdp_rdp *)session->rdp) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* this should do the resizing */
|
||||
if (xrdp_rdp_send_demand_active((struct xrdp_rdp *)session->rdp) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* process till up and running */
|
||||
session->up_and_running = 0;
|
||||
|
||||
if (libxrdp_process_data(session) != 0)
|
||||
{
|
||||
g_writeln("non handled error from libxrdp_process_data");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -685,32 +733,40 @@ libxrdp_query_channel(struct xrdp_session* session, int index,
|
||||
|
||||
rdp = (struct xrdp_rdp *)session->rdp;
|
||||
mcs = rdp->sec_layer->mcs_layer;
|
||||
|
||||
if (mcs->channel_list == NULL)
|
||||
{
|
||||
g_writeln("libxrdp_query_channel - No channel initialized");
|
||||
return 1 ;
|
||||
}
|
||||
|
||||
count = mcs->channel_list->count;
|
||||
|
||||
if (index < 0 || index >= count)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
channel_item = (struct mcs_channel_item *)
|
||||
list_get_item(mcs->channel_list, index);
|
||||
|
||||
if (channel_item == 0)
|
||||
{
|
||||
/* this should not happen */
|
||||
g_writeln("libxrdp_query_channel - channel item is 0");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (channel_name != 0)
|
||||
{
|
||||
g_strncpy(channel_name, channel_item->name, 8);
|
||||
}
|
||||
|
||||
if (channel_flags != 0)
|
||||
{
|
||||
*channel_flags = channel_item->flags;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -728,16 +784,20 @@ libxrdp_get_channel_id(struct xrdp_session* session, char* name)
|
||||
|
||||
rdp = (struct xrdp_rdp *)session->rdp;
|
||||
mcs = rdp->sec_layer->mcs_layer;
|
||||
|
||||
if (mcs->channel_list == NULL)
|
||||
{
|
||||
g_writeln("libxrdp_get_channel_id No channel initialized");
|
||||
return -1 ;
|
||||
}
|
||||
|
||||
count = mcs->channel_list->count;
|
||||
|
||||
for (index = 0; index < count; index++)
|
||||
{
|
||||
channel_item = (struct mcs_channel_item *)
|
||||
list_get_item(mcs->channel_list, index);
|
||||
|
||||
if (channel_item != 0)
|
||||
{
|
||||
if (g_strcasecmp(name, channel_item->name) == 0)
|
||||
@ -746,6 +806,7 @@ libxrdp_get_channel_id(struct xrdp_session* session, char* name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -765,20 +826,24 @@ libxrdp_send_to_channel(struct xrdp_session* session, int channel_id,
|
||||
chan = sec->chan_layer;
|
||||
make_stream(s);
|
||||
init_stream(s, data_len + 1024); /* this should be big enough */
|
||||
|
||||
if (xrdp_channel_init(chan, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* here we make a copy of the data */
|
||||
out_uint8a(s, data, data_len);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_channel_send(chan, s, channel_id, total_data_len, flags) != 0)
|
||||
{
|
||||
g_writeln("Debug - data NOT sent to channel");
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
libxrdp header
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2010
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* libxrdp header
|
||||
*/
|
||||
|
||||
#if !defined(LIBXRDP_H)
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
header file for use with libxrdp.so / xrdp.dll
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2010
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* header file for use with libxrdp.so / xrdp.dll
|
||||
*/
|
||||
|
||||
#ifndef LIBXRDPINC_H
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
bitmap compressor
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* bitmap compressor
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
@ -688,14 +686,17 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
fill_count = 0;
|
||||
mix_count = 0;
|
||||
fom_count = 0;
|
||||
|
||||
if (bpp == 8)
|
||||
{
|
||||
mix = 0xff;
|
||||
out_count = end;
|
||||
line = in_data + width * start_line;
|
||||
|
||||
while (start_line >= 0 && out_count < 32768)
|
||||
{
|
||||
i = (s->p - s->data) + count;
|
||||
|
||||
if (i - color_count >= byte_limit &&
|
||||
i - bicolor_count >= byte_limit &&
|
||||
i - fill_count >= byte_limit &&
|
||||
@ -704,12 +705,15 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
out_count += end;
|
||||
|
||||
for (i = 0; i < end; i++)
|
||||
{
|
||||
/* read next pixel */
|
||||
IN_PIXEL8(line, i, 0, width, last_pixel, pixel);
|
||||
IN_PIXEL8(last_line, i, 0, width, last_ypixel, ypixel);
|
||||
|
||||
if (!TEST_FILL)
|
||||
{
|
||||
if (fill_count > 3 &&
|
||||
@ -723,8 +727,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FILL_COUNT1(fill_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fill_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_MIX)
|
||||
{
|
||||
if (mix_count > 3 &&
|
||||
@ -738,8 +744,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_MIX_COUNT1(mix_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
mix_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_COLOR)
|
||||
{
|
||||
if (color_count > 3 &&
|
||||
@ -753,8 +761,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COLOR_COUNT1(color_count, s, last_pixel);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
color_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_BICOLOR)
|
||||
{
|
||||
if (bicolor_count > 3 &&
|
||||
@ -776,13 +786,16 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT1(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT1(bicolor_count, s, bicolor2, bicolor1);
|
||||
}
|
||||
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
bicolor_count = 0;
|
||||
bicolor1 = last_pixel;
|
||||
bicolor2 = pixel;
|
||||
bicolor_spin = 0;
|
||||
}
|
||||
|
||||
if (!TEST_FOM)
|
||||
{
|
||||
if (fom_count > 3 &&
|
||||
@ -796,26 +809,32 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FOM_COUNT1(fom_count, s, fom_mask, fom_mask_len);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fom_count = 0;
|
||||
fom_mask_len = 0;
|
||||
}
|
||||
|
||||
if (TEST_FILL)
|
||||
{
|
||||
fill_count++;
|
||||
}
|
||||
|
||||
if (TEST_MIX)
|
||||
{
|
||||
mix_count++;
|
||||
}
|
||||
|
||||
if (TEST_COLOR)
|
||||
{
|
||||
color_count++;
|
||||
}
|
||||
|
||||
if (TEST_BICOLOR)
|
||||
{
|
||||
bicolor_spin = !bicolor_spin;
|
||||
bicolor_count++;
|
||||
}
|
||||
|
||||
if (TEST_FOM)
|
||||
{
|
||||
if ((fom_count % 8) == 0)
|
||||
@ -823,17 +842,21 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
fom_mask[fom_mask_len] = 0;
|
||||
fom_mask_len++;
|
||||
}
|
||||
|
||||
if (pixel == (ypixel ^ mix))
|
||||
{
|
||||
fom_mask[fom_mask_len - 1] |= (1 << (fom_count % 8));
|
||||
}
|
||||
|
||||
fom_count++;
|
||||
}
|
||||
|
||||
out_uint8(temp_s, pixel);
|
||||
count++;
|
||||
last_pixel = pixel;
|
||||
last_ypixel = ypixel;
|
||||
}
|
||||
|
||||
/* can't take fix, mix, or fom past first line */
|
||||
if (last_line == 0)
|
||||
{
|
||||
@ -848,7 +871,9 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FILL_COUNT1(fill_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fill_count = 0;
|
||||
|
||||
if (mix_count > 3 &&
|
||||
mix_count >= fill_count &&
|
||||
mix_count >= bicolor_count &&
|
||||
@ -860,7 +885,9 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_MIX_COUNT1(mix_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
mix_count = 0;
|
||||
|
||||
if (fom_count > 3 &&
|
||||
fom_count >= fill_count &&
|
||||
fom_count >= color_count &&
|
||||
@ -872,14 +899,17 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FOM_COUNT1(fom_count, s, fom_mask, fom_mask_len);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fom_count = 0;
|
||||
fom_mask_len = 0;
|
||||
}
|
||||
|
||||
last_line = line;
|
||||
line = line - width;
|
||||
start_line--;
|
||||
lines_sent++;
|
||||
}
|
||||
|
||||
if (fill_count > 3 &&
|
||||
fill_count >= color_count &&
|
||||
fill_count >= bicolor_count &&
|
||||
@ -929,6 +959,7 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT1(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT1(bicolor_count, s, bicolor2, bicolor1);
|
||||
}
|
||||
|
||||
count -= bicolor_count;
|
||||
OUT_COPY_COUNT1(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT1(bicolor_count, s, bicolor1, bicolor2);
|
||||
@ -953,9 +984,11 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
mix = (bpp == 15) ? 0xba1f : 0xffff;
|
||||
out_count = end * 2;
|
||||
line = in_data + width * start_line * 2;
|
||||
|
||||
while (start_line >= 0 && out_count < 32768)
|
||||
{
|
||||
i = (s->p - s->data) + count * 2;
|
||||
|
||||
if (i - (color_count * 2) >= byte_limit &&
|
||||
i - (bicolor_count * 2) >= byte_limit &&
|
||||
i - (fill_count * 2) >= byte_limit &&
|
||||
@ -964,12 +997,15 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
out_count += end * 2;
|
||||
|
||||
for (i = 0; i < end; i++)
|
||||
{
|
||||
/* read next pixel */
|
||||
IN_PIXEL16(line, i, 0, width, last_pixel, pixel);
|
||||
IN_PIXEL16(last_line, i, 0, width, last_ypixel, ypixel);
|
||||
|
||||
if (!TEST_FILL)
|
||||
{
|
||||
if (fill_count > 3 &&
|
||||
@ -983,8 +1019,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FILL_COUNT2(fill_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fill_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_MIX)
|
||||
{
|
||||
if (mix_count > 3 &&
|
||||
@ -998,8 +1036,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_MIX_COUNT2(mix_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
mix_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_COLOR)
|
||||
{
|
||||
if (color_count > 3 &&
|
||||
@ -1013,8 +1053,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COLOR_COUNT2(color_count, s, last_pixel);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
color_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_BICOLOR)
|
||||
{
|
||||
if (bicolor_count > 3 &&
|
||||
@ -1036,13 +1078,16 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT2(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor2, bicolor1);
|
||||
}
|
||||
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
bicolor_count = 0;
|
||||
bicolor1 = last_pixel;
|
||||
bicolor2 = pixel;
|
||||
bicolor_spin = 0;
|
||||
}
|
||||
|
||||
if (!TEST_FOM)
|
||||
{
|
||||
if (fom_count > 3 &&
|
||||
@ -1056,26 +1101,32 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FOM_COUNT2(fom_count, s, fom_mask, fom_mask_len);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fom_count = 0;
|
||||
fom_mask_len = 0;
|
||||
}
|
||||
|
||||
if (TEST_FILL)
|
||||
{
|
||||
fill_count++;
|
||||
}
|
||||
|
||||
if (TEST_MIX)
|
||||
{
|
||||
mix_count++;
|
||||
}
|
||||
|
||||
if (TEST_COLOR)
|
||||
{
|
||||
color_count++;
|
||||
}
|
||||
|
||||
if (TEST_BICOLOR)
|
||||
{
|
||||
bicolor_spin = !bicolor_spin;
|
||||
bicolor_count++;
|
||||
}
|
||||
|
||||
if (TEST_FOM)
|
||||
{
|
||||
if ((fom_count % 8) == 0)
|
||||
@ -1083,17 +1134,21 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
fom_mask[fom_mask_len] = 0;
|
||||
fom_mask_len++;
|
||||
}
|
||||
|
||||
if (pixel == (ypixel ^ mix))
|
||||
{
|
||||
fom_mask[fom_mask_len - 1] |= (1 << (fom_count % 8));
|
||||
}
|
||||
|
||||
fom_count++;
|
||||
}
|
||||
|
||||
out_uint16_le(temp_s, pixel);
|
||||
count++;
|
||||
last_pixel = pixel;
|
||||
last_ypixel = ypixel;
|
||||
}
|
||||
|
||||
/* can't take fix, mix, or fom past first line */
|
||||
if (last_line == 0)
|
||||
{
|
||||
@ -1108,7 +1163,9 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FILL_COUNT2(fill_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fill_count = 0;
|
||||
|
||||
if (mix_count > 3 &&
|
||||
mix_count >= fill_count &&
|
||||
mix_count >= bicolor_count &&
|
||||
@ -1120,7 +1177,9 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_MIX_COUNT2(mix_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
mix_count = 0;
|
||||
|
||||
if (fom_count > 3 &&
|
||||
fom_count >= fill_count &&
|
||||
fom_count >= color_count &&
|
||||
@ -1132,14 +1191,17 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FOM_COUNT2(fom_count, s, fom_mask, fom_mask_len);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fom_count = 0;
|
||||
fom_mask_len = 0;
|
||||
}
|
||||
|
||||
last_line = line;
|
||||
line = line - width * 2;
|
||||
start_line--;
|
||||
lines_sent++;
|
||||
}
|
||||
|
||||
if (fill_count > 3 &&
|
||||
fill_count >= color_count &&
|
||||
fill_count >= bicolor_count &&
|
||||
@ -1189,6 +1251,7 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT2(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor2, bicolor1);
|
||||
}
|
||||
|
||||
count -= bicolor_count;
|
||||
OUT_COPY_COUNT2(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT2(bicolor_count, s, bicolor1, bicolor2);
|
||||
@ -1213,9 +1276,11 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
mix = 0xffffff;
|
||||
out_count = end * 3;
|
||||
line = in_data + width * start_line * 4;
|
||||
|
||||
while (start_line >= 0 && out_count < 32768)
|
||||
{
|
||||
i = (s->p - s->data) + count * 3;
|
||||
|
||||
if (i - (color_count * 3) >= byte_limit &&
|
||||
i - (bicolor_count * 3) >= byte_limit &&
|
||||
i - (fill_count * 3) >= byte_limit &&
|
||||
@ -1224,12 +1289,15 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
out_count += end * 3;
|
||||
|
||||
for (i = 0; i < end; i++)
|
||||
{
|
||||
/* read next pixel */
|
||||
IN_PIXEL32(line, i, 0, width, last_pixel, pixel);
|
||||
IN_PIXEL32(last_line, i, 0, width, last_ypixel, ypixel);
|
||||
|
||||
if (!TEST_FILL)
|
||||
{
|
||||
if (fill_count > 3 &&
|
||||
@ -1243,8 +1311,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FILL_COUNT3(fill_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fill_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_MIX)
|
||||
{
|
||||
if (mix_count > 3 &&
|
||||
@ -1258,8 +1328,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_MIX_COUNT3(mix_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
mix_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_COLOR)
|
||||
{
|
||||
if (color_count > 3 &&
|
||||
@ -1273,8 +1345,10 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COLOR_COUNT3(color_count, s, last_pixel);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
color_count = 0;
|
||||
}
|
||||
|
||||
if (!TEST_BICOLOR)
|
||||
{
|
||||
if (bicolor_count > 3 &&
|
||||
@ -1296,13 +1370,16 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT3(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT3(bicolor_count, s, bicolor2, bicolor1);
|
||||
}
|
||||
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
bicolor_count = 0;
|
||||
bicolor1 = last_pixel;
|
||||
bicolor2 = pixel;
|
||||
bicolor_spin = 0;
|
||||
}
|
||||
|
||||
if (!TEST_FOM)
|
||||
{
|
||||
if (fom_count > 3 &&
|
||||
@ -1316,26 +1393,32 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FOM_COUNT3(fom_count, s, fom_mask, fom_mask_len);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fom_count = 0;
|
||||
fom_mask_len = 0;
|
||||
}
|
||||
|
||||
if (TEST_FILL)
|
||||
{
|
||||
fill_count++;
|
||||
}
|
||||
|
||||
if (TEST_MIX)
|
||||
{
|
||||
mix_count++;
|
||||
}
|
||||
|
||||
if (TEST_COLOR)
|
||||
{
|
||||
color_count++;
|
||||
}
|
||||
|
||||
if (TEST_BICOLOR)
|
||||
{
|
||||
bicolor_spin = !bicolor_spin;
|
||||
bicolor_count++;
|
||||
}
|
||||
|
||||
if (TEST_FOM)
|
||||
{
|
||||
if ((fom_count % 8) == 0)
|
||||
@ -1343,12 +1426,15 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
fom_mask[fom_mask_len] = 0;
|
||||
fom_mask_len++;
|
||||
}
|
||||
|
||||
if (pixel == (ypixel ^ mix))
|
||||
{
|
||||
fom_mask[fom_mask_len - 1] |= (1 << (fom_count % 8));
|
||||
}
|
||||
|
||||
fom_count++;
|
||||
}
|
||||
|
||||
out_uint8(temp_s, pixel & 0xff);
|
||||
out_uint8(temp_s, (pixel >> 8) & 0xff);
|
||||
out_uint8(temp_s, (pixel >> 16) & 0xff);
|
||||
@ -1356,6 +1442,7 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
last_pixel = pixel;
|
||||
last_ypixel = ypixel;
|
||||
}
|
||||
|
||||
/* can't take fix, mix, or fom past first line */
|
||||
if (last_line == 0)
|
||||
{
|
||||
@ -1370,7 +1457,9 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FILL_COUNT3(fill_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fill_count = 0;
|
||||
|
||||
if (mix_count > 3 &&
|
||||
mix_count >= fill_count &&
|
||||
mix_count >= bicolor_count &&
|
||||
@ -1382,7 +1471,9 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_MIX_COUNT3(mix_count, s);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
mix_count = 0;
|
||||
|
||||
if (fom_count > 3 &&
|
||||
fom_count >= fill_count &&
|
||||
fom_count >= color_count &&
|
||||
@ -1394,14 +1485,17 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_FOM_COUNT3(fom_count, s, fom_mask, fom_mask_len);
|
||||
RESET_COUNTS;
|
||||
}
|
||||
|
||||
fom_count = 0;
|
||||
fom_mask_len = 0;
|
||||
}
|
||||
|
||||
last_line = line;
|
||||
line = line - width * 4;
|
||||
start_line--;
|
||||
lines_sent++;
|
||||
}
|
||||
|
||||
if (fill_count > 3 &&
|
||||
fill_count >= color_count &&
|
||||
fill_count >= bicolor_count &&
|
||||
@ -1451,6 +1545,7 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT3(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT3(bicolor_count, s, bicolor2, bicolor1);
|
||||
}
|
||||
|
||||
count -= bicolor_count;
|
||||
OUT_COPY_COUNT3(count, s, temp_s);
|
||||
OUT_BICOLOR_COUNT3(bicolor_count, s, bicolor1, bicolor2);
|
||||
@ -1470,5 +1565,6 @@ xrdp_bitmap_compress(char* in_data, int width, int height,
|
||||
OUT_COPY_COUNT3(count, s, temp_s);
|
||||
}
|
||||
}
|
||||
|
||||
return lines_sent;
|
||||
}
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2006-2010
|
||||
|
||||
channel layer
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2006-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* channel layer
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
@ -35,11 +33,13 @@ static struct mcs_channel_item* APP_CC
|
||||
xrdp_channel_get_item(struct xrdp_channel *self, int channel_id)
|
||||
{
|
||||
struct mcs_channel_item *channel;
|
||||
|
||||
if (self->mcs_layer->channel_list == NULL)
|
||||
{
|
||||
g_writeln("xrdp_channel_get_item - No channel initialized");
|
||||
return NULL ;
|
||||
}
|
||||
|
||||
channel = (struct mcs_channel_item *)
|
||||
list_get_item(self->mcs_layer->channel_list, channel_id);
|
||||
return channel;
|
||||
@ -66,6 +66,7 @@ xrdp_channel_delete(struct xrdp_channel* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_memset(self, 0, sizeof(struct xrdp_channel));
|
||||
g_free(self);
|
||||
}
|
||||
@ -79,6 +80,7 @@ xrdp_channel_init(struct xrdp_channel* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_push_layer(s, channel_hdr, 8);
|
||||
return 0;
|
||||
}
|
||||
@ -93,23 +95,29 @@ xrdp_channel_send(struct xrdp_channel* self, struct stream* s, int channel_id,
|
||||
struct mcs_channel_item *channel;
|
||||
|
||||
channel = xrdp_channel_get_item(self, channel_id);
|
||||
|
||||
if (channel == NULL)
|
||||
{
|
||||
g_writeln("xrdp_channel_send - no such channel");
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_pop_layer(s, channel_hdr);
|
||||
out_uint32_le(s, total_data_len);
|
||||
|
||||
if (channel->flags & XR_CHANNEL_OPTION_SHOW_PROTOCOL)
|
||||
{
|
||||
flags |= CHANNEL_FLAG_SHOW_PROTOCOL;
|
||||
}
|
||||
|
||||
out_uint32_le(s, flags);
|
||||
|
||||
if (xrdp_sec_send(self->sec_layer, s, channel->chanid) != 0)
|
||||
{
|
||||
g_writeln("xrdp_channel_send - failure sending data");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -128,6 +136,7 @@ xrdp_channel_call_callback(struct xrdp_channel* self, struct stream* s,
|
||||
|
||||
rv = 0;
|
||||
session = self->sec_layer->rdp_layer->session;
|
||||
|
||||
if (session != 0)
|
||||
{
|
||||
if (session->callback != 0)
|
||||
@ -147,6 +156,7 @@ xrdp_channel_call_callback(struct xrdp_channel* self, struct stream* s,
|
||||
{
|
||||
g_writeln("in xrdp_channel_call_callback, session is nil");
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -173,11 +183,13 @@ xrdp_channel_process(struct xrdp_channel* self, struct stream* s,
|
||||
one should be MCS_GLOBAL_CHANNEL + 2, and so on */
|
||||
channel_id = (chanid - MCS_GLOBAL_CHANNEL) - 1;
|
||||
channel = xrdp_channel_get_item(self, channel_id);
|
||||
|
||||
if (channel == NULL)
|
||||
{
|
||||
g_writeln("xrdp_channel_process, channel not found");
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
in_uint32_le(s, length);
|
||||
in_uint32_le(s, flags);
|
||||
|
@ -42,6 +42,7 @@ xrdp_fastpath_delete(struct xrdp_fastpath* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
free_stream(self->out_s);
|
||||
g_free(self);
|
||||
}
|
||||
@ -78,6 +79,7 @@ xrdp_fastpath_send_update_pdu(struct xrdp_fastpath* self, tui8 updateCode,
|
||||
s_send = self->out_s;
|
||||
maxLen = FASTPATH_MAX_PACKET_SIZE - 6; /* 6 bytes for header */
|
||||
payloadLeft = (s->end - s->data);
|
||||
|
||||
for (i = 0; payloadLeft > 0; i++)
|
||||
{
|
||||
if (payloadLeft > maxLen)
|
||||
@ -88,7 +90,9 @@ xrdp_fastpath_send_update_pdu(struct xrdp_fastpath* self, tui8 updateCode,
|
||||
{
|
||||
len = payloadLeft;
|
||||
}
|
||||
|
||||
payloadLeft -= len;
|
||||
|
||||
if (payloadLeft == 0)
|
||||
{
|
||||
fragment = i ? FASTPATH_FRAGMENT_LAST : FASTPATH_FRAGMENT_SINGLE;
|
||||
@ -97,6 +101,7 @@ xrdp_fastpath_send_update_pdu(struct xrdp_fastpath* self, tui8 updateCode,
|
||||
{
|
||||
fragment = i ? FASTPATH_FRAGMENT_NEXT : FASTPATH_FRAGMENT_FIRST;
|
||||
}
|
||||
|
||||
init_stream(s_send, 0);
|
||||
out_uint8(s_send, 0); /* fOutputHeader */
|
||||
i32 = ((len + 6) >> 8) | 0x80;
|
||||
@ -109,11 +114,13 @@ xrdp_fastpath_send_update_pdu(struct xrdp_fastpath* self, tui8 updateCode,
|
||||
out_uint16_le(s_send, len);
|
||||
s_copy(s_send, s, len);
|
||||
s_mark_end(s_send);
|
||||
|
||||
if (xrdp_tcp_send(self->tcp_layer, s_send) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -164,6 +171,7 @@ xrdp_fastpath_process_data(struct xrdp_fastpath* self, struct stream* s,
|
||||
numberEvents = (header & 0x3c) >> 2;
|
||||
xrdp_tcp_recv(self->tcp_layer, s, 1);
|
||||
in_uint8(s, length);
|
||||
|
||||
if (length & 0x80)
|
||||
{
|
||||
xrdp_tcp_recv(self->tcp_layer, s, 1);
|
||||
@ -174,16 +182,20 @@ xrdp_fastpath_process_data(struct xrdp_fastpath* self, struct stream* s,
|
||||
{
|
||||
length -= 2;
|
||||
}
|
||||
|
||||
xrdp_tcp_recv(self->tcp_layer, s, length);
|
||||
|
||||
if (encryptionFlags != 0)
|
||||
{
|
||||
/* TODO decryption ...*/
|
||||
}
|
||||
|
||||
/* parse updateHeader */
|
||||
in_uint8(s, updateHeader);
|
||||
updateCode = (updateHeader & 0x0f);
|
||||
updateFrag = (updateHeader & 0x30) >> 4;
|
||||
updateComp = (updateHeader & 0xc0) >> 6;
|
||||
|
||||
if (updateFrag && updateComp)
|
||||
{
|
||||
/* TODO */
|
||||
@ -191,6 +203,7 @@ xrdp_fastpath_process_data(struct xrdp_fastpath* self, struct stream* s,
|
||||
updateFrag, updateComp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint16_le(s, size);
|
||||
return xrdp_fastpath_process_update(self, updateCode, size, s);
|
||||
}
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
iso layer
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* iso layer
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
@ -44,6 +42,7 @@ xrdp_iso_delete(struct xrdp_iso* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
xrdp_tcp_delete(self->tcp_layer);
|
||||
g_free(self);
|
||||
}
|
||||
@ -57,23 +56,30 @@ xrdp_iso_recv_msg(struct xrdp_iso* self, struct stream* s, int* code)
|
||||
int len;
|
||||
|
||||
*code = 0;
|
||||
|
||||
if (xrdp_tcp_recv(self->tcp_layer, s, 4) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, ver);
|
||||
|
||||
if (ver != 3)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 1);
|
||||
in_uint16_be(s, len);
|
||||
|
||||
if (xrdp_tcp_recv(self->tcp_layer, s, len - 4) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 1);
|
||||
in_uint8(s, *code);
|
||||
|
||||
if (*code == ISO_PDU_DT)
|
||||
{
|
||||
in_uint8s(s, 1);
|
||||
@ -82,6 +88,7 @@ xrdp_iso_recv_msg(struct xrdp_iso* self, struct stream* s, int* code)
|
||||
{
|
||||
in_uint8s(s, 5);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -93,16 +100,19 @@ xrdp_iso_recv(struct xrdp_iso* self, struct stream* s)
|
||||
int code;
|
||||
|
||||
DEBUG((" in xrdp_iso_recv"));
|
||||
|
||||
if (xrdp_iso_recv_msg(self, s, &code) != 0)
|
||||
{
|
||||
DEBUG((" out xrdp_iso_recv xrdp_iso_recv_msg return non zero"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (code != ISO_PDU_DT)
|
||||
{
|
||||
DEBUG((" out xrdp_iso_recv code != ISO_PDU_DT"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_iso_recv"));
|
||||
return 0;
|
||||
}
|
||||
@ -115,6 +125,7 @@ xrdp_iso_send_msg(struct xrdp_iso* self, struct stream* s, int code)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, 3);
|
||||
out_uint8(s, 0);
|
||||
out_uint16_be(s, 11); /* length */
|
||||
@ -124,10 +135,12 @@ xrdp_iso_send_msg(struct xrdp_iso* self, struct stream* s, int code)
|
||||
out_uint16_le(s, 0);
|
||||
out_uint8(s, 0);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_tcp_send(self->tcp_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -142,21 +155,25 @@ xrdp_iso_incoming(struct xrdp_iso* self)
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
DEBUG((" in xrdp_iso_incoming"));
|
||||
|
||||
if (xrdp_iso_recv_msg(self, s, &code) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (code != ISO_PDU_CR)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_iso_send_msg(self, s, ISO_PDU_CC) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_iso_incoming"));
|
||||
free_stream(s);
|
||||
return 0;
|
||||
@ -188,10 +205,12 @@ xrdp_iso_send(struct xrdp_iso* self, struct stream* s)
|
||||
out_uint8(s, 2);
|
||||
out_uint8(s, ISO_PDU_DT);
|
||||
out_uint8(s, 0x80);
|
||||
|
||||
if (xrdp_tcp_send(self->tcp_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_iso_send"));
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2012
|
||||
|
||||
jpeg compressor
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* jpeg compressor
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
@ -117,6 +115,7 @@ jp_do_compress(char* data, int width, int height, int bpp, int quality,
|
||||
cinfo.dct_method = JDCT_FLOAT;
|
||||
jpeg_set_quality(&cinfo, quality, 1);
|
||||
jpeg_start_compress(&cinfo, 1);
|
||||
|
||||
while (cinfo.next_scanline + 3 < cinfo.image_height)
|
||||
{
|
||||
row_pointer[0] = data;
|
||||
@ -129,19 +128,23 @@ jp_do_compress(char* data, int width, int height, int bpp, int quality,
|
||||
data += width * Bpp;
|
||||
jpeg_write_scanlines(&cinfo, row_pointer, 4);
|
||||
}
|
||||
|
||||
while (cinfo.next_scanline < cinfo.image_height)
|
||||
{
|
||||
row_pointer[0] = data;
|
||||
data += width * Bpp;
|
||||
jpeg_write_scanlines(&cinfo, row_pointer, 1);
|
||||
}
|
||||
|
||||
jpeg_finish_compress(&cinfo);
|
||||
*comp_data_bytes = md.total_done;
|
||||
jpeg_destroy_compress(&cinfo);
|
||||
|
||||
if (md.overwrite)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -165,9 +168,11 @@ jpeg_compress(char* in_data, int width, int height,
|
||||
|
||||
data = temp_s->data;
|
||||
dst8 = data;
|
||||
|
||||
if (bpp == 24)
|
||||
{
|
||||
src32 = (tui32 *)in_data;
|
||||
|
||||
for (j = 0; j < height; j++)
|
||||
{
|
||||
for (i = 0; i < width; i++)
|
||||
@ -178,6 +183,7 @@ jpeg_compress(char* in_data, int width, int height,
|
||||
*(dst8++) = green;
|
||||
*(dst8++) = red;
|
||||
}
|
||||
|
||||
for (i = 0; i < e; i++)
|
||||
{
|
||||
*(dst8++) = blue;
|
||||
@ -190,6 +196,7 @@ jpeg_compress(char* in_data, int width, int height,
|
||||
{
|
||||
g_writeln("bpp wrong %d", bpp);
|
||||
}
|
||||
|
||||
cdata_bytes = byte_limit;
|
||||
jp_do_compress(data, width + e, height, 24, quality, s->p, &cdata_bytes);
|
||||
s->p += cdata_bytes;
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
mcs layer
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* mcs layer
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
@ -55,14 +53,17 @@ xrdp_mcs_delete(struct xrdp_mcs* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* here we have to free the channel items and anything in them */
|
||||
count = self->channel_list->count;
|
||||
|
||||
for (index = count - 1; index >= 0; index--)
|
||||
{
|
||||
channel_item = (struct mcs_channel_item *)
|
||||
list_get_item(self->channel_list, index);
|
||||
g_free(channel_item);
|
||||
}
|
||||
|
||||
list_delete(self->channel_list);
|
||||
xrdp_iso_delete(self->iso_layer);
|
||||
/* make sure we get null pointer exception if struct is used again. */
|
||||
@ -82,24 +83,28 @@ xrdp_mcs_send_cjcf(struct xrdp_mcs* self, int userid, int chanid)
|
||||
DEBUG((" in xrdp_mcs_send_cjcf"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_cjcf error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, (MCS_CJCF << 2) | 2);
|
||||
out_uint8(s, 0);
|
||||
out_uint16_be(s, userid);
|
||||
out_uint16_be(s, chanid); /* TODO Explain why we send this two times */
|
||||
out_uint16_be(s, chanid);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_cjcf error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_cjcf"));
|
||||
return 0;
|
||||
@ -117,6 +122,7 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
|
||||
int chanid;
|
||||
|
||||
DEBUG((" in xrdp_mcs_recv"));
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (xrdp_iso_recv(self->iso_layer, s) != 0)
|
||||
@ -124,14 +130,17 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
|
||||
DEBUG((" out xrdp_mcs_recv xrdp_iso_recv returned non zero"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
appid = opcode >> 2;
|
||||
|
||||
if (appid == MCS_DPUM) /* Disconnect Provider Ultimatum */
|
||||
{
|
||||
g_writeln("received Disconnect Provider Ultimatum");
|
||||
DEBUG((" out xrdp_mcs_recv appid != MCS_DPUM"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* this is channels getting added from the client */
|
||||
if (appid == MCS_CJRQ)
|
||||
{
|
||||
@ -139,12 +148,15 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
|
||||
in_uint16_be(s, userid);
|
||||
in_uint16_be(s, chanid);
|
||||
DEBUG(("xrdp_mcs_recv adding channel %4.4x", chanid));
|
||||
|
||||
if (xrdp_mcs_send_cjcf(self, userid, chanid) != 0)
|
||||
{
|
||||
g_writeln("Non handled error from xrdp_mcs_send_cjcf") ;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (appid == MCS_SDRQ || appid == MCS_SDIN)
|
||||
{
|
||||
break ;
|
||||
@ -153,21 +165,26 @@ xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
|
||||
{
|
||||
g_writeln("Recieved an unhandled appid:%d", appid);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (appid != MCS_SDRQ)
|
||||
{
|
||||
DEBUG((" out xrdp_mcs_recv err got 0x%x need MCS_SDRQ", appid));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 2);
|
||||
in_uint16_be(s, *chan);
|
||||
in_uint8s(s, 1);
|
||||
in_uint8(s, len);
|
||||
|
||||
if (len & 0x80)
|
||||
{
|
||||
in_uint8s(s, 1);
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_mcs_recv"));
|
||||
return 0;
|
||||
}
|
||||
@ -190,15 +207,19 @@ xrdp_mcs_ber_parse_header(struct xrdp_mcs* self, struct stream* s,
|
||||
{
|
||||
in_uint8(s, tag);
|
||||
}
|
||||
|
||||
if (tag != tag_val)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, l);
|
||||
|
||||
if (l & 0x80)
|
||||
{
|
||||
l = l & ~0x80;
|
||||
*len = 0;
|
||||
|
||||
while (l > 0)
|
||||
{
|
||||
in_uint8(s, i);
|
||||
@ -210,6 +231,7 @@ xrdp_mcs_ber_parse_header(struct xrdp_mcs* self, struct stream* s,
|
||||
{
|
||||
*len = l;
|
||||
}
|
||||
|
||||
if (s_check(s))
|
||||
{
|
||||
return 0;
|
||||
@ -231,7 +253,9 @@ xrdp_mcs_parse_domain_params(struct xrdp_mcs* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, len);
|
||||
|
||||
if (s_check(s))
|
||||
{
|
||||
return 0;
|
||||
@ -252,59 +276,73 @@ xrdp_mcs_recv_connect_initial(struct xrdp_mcs* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_ber_parse_header(self, s, MCS_CONNECT_INITIAL, &len) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_ber_parse_header(self, s, BER_TAG_OCTET_STRING, &len) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, len);
|
||||
|
||||
if (xrdp_mcs_ber_parse_header(self, s, BER_TAG_OCTET_STRING, &len) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, len);
|
||||
|
||||
if (xrdp_mcs_ber_parse_header(self, s, BER_TAG_BOOLEAN, &len) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, len);
|
||||
|
||||
if (xrdp_mcs_parse_domain_params(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_parse_domain_params(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_parse_domain_params(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_ber_parse_header(self, s, BER_TAG_OCTET_STRING, &len) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* make a copy of client mcs data */
|
||||
init_stream(self->client_mcs_data, len);
|
||||
out_uint8a(self->client_mcs_data, s->p, len);
|
||||
in_uint8s(s, len);
|
||||
s_mark_end(self->client_mcs_data);
|
||||
|
||||
if (s_check_end(s))
|
||||
{
|
||||
free_stream(s);
|
||||
@ -327,28 +365,35 @@ xrdp_mcs_recv_edrq(struct xrdp_mcs* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
|
||||
if ((opcode >> 2) != MCS_EDRQ)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 2);
|
||||
in_uint8s(s, 2);
|
||||
|
||||
if (opcode & 2)
|
||||
{
|
||||
in_uint16_be(s, self->userid);
|
||||
}
|
||||
|
||||
if (!(s_check_end(s)))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -363,26 +408,32 @@ xrdp_mcs_recv_aurq(struct xrdp_mcs* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
|
||||
if ((opcode >> 2) != MCS_AURQ)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (opcode & 2)
|
||||
{
|
||||
in_uint16_be(s, self->userid);
|
||||
}
|
||||
|
||||
if (!(s_check_end(s)))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -397,22 +448,26 @@ xrdp_mcs_send_aucf(struct xrdp_mcs* self)
|
||||
DEBUG((" in xrdp_mcs_send_aucf"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_aucf error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, ((MCS_AUCF << 2) | 2));
|
||||
out_uint8s(s, 1);
|
||||
out_uint16_be(s, self->userid);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_aucf error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_aucf"));
|
||||
return 0;
|
||||
@ -428,27 +483,34 @@ xrdp_mcs_recv_cjrq(struct xrdp_mcs* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
|
||||
if ((opcode >> 2) != MCS_CJRQ)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 4);
|
||||
|
||||
if (opcode & 2)
|
||||
{
|
||||
in_uint8s(s, 2);
|
||||
}
|
||||
|
||||
if (!(s_check_end(s)))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -467,6 +529,7 @@ xrdp_mcs_ber_out_header(struct xrdp_mcs* self, struct stream* s,
|
||||
{
|
||||
out_uint8(s, tag_val);
|
||||
}
|
||||
|
||||
if (len >= 0x80)
|
||||
{
|
||||
out_uint8(s, 0x82);
|
||||
@ -476,6 +539,7 @@ xrdp_mcs_ber_out_header(struct xrdp_mcs* self, struct stream* s,
|
||||
{
|
||||
out_uint8(s, len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -557,12 +621,14 @@ xrdp_mcs_send_connect_response(struct xrdp_mcs* self)
|
||||
/* mcs data */
|
||||
out_uint8a(s, self->server_mcs_data->data, data_len);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_connect_response error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_send_connect_response"));
|
||||
return 0;
|
||||
@ -574,57 +640,70 @@ int APP_CC
|
||||
xrdp_mcs_incoming(struct xrdp_mcs *self)
|
||||
{
|
||||
DEBUG((" in xrdp_mcs_incoming"));
|
||||
|
||||
if (xrdp_iso_incoming(self->iso_layer) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_recv_connect_initial(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* in xrdp_sec.c */
|
||||
if (xrdp_sec_process_mcs_data(self->sec_layer) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* in xrdp_sec.c */
|
||||
if (xrdp_sec_out_mcs_data(self->sec_layer) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_send_connect_response(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_recv_edrq(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_recv_aurq(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_send_aucf(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_recv_cjrq(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_send_cjcf(self, self->userid,
|
||||
self->userid + MCS_USERCHANNEL_BASE) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_recv_cjrq(self) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (xrdp_mcs_send_cjcf(self, self->userid, MCS_GLOBAL_CHANNEL) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_mcs_incoming"));
|
||||
return 0;
|
||||
}
|
||||
@ -652,6 +731,7 @@ xrdp_mcs_call_callback(struct xrdp_mcs* self)
|
||||
rv = 0;
|
||||
/* if there is a callback, call it here */
|
||||
session = self->sec_layer->rdp_layer->session;
|
||||
|
||||
if (session != 0)
|
||||
{
|
||||
if (session->callback != 0)
|
||||
@ -668,6 +748,7 @@ xrdp_mcs_call_callback(struct xrdp_mcs* self)
|
||||
{
|
||||
g_writeln("in xrdp_mcs_send, session is nil");
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -683,10 +764,12 @@ xrdp_mcs_send(struct xrdp_mcs* self, struct stream* s, int chan)
|
||||
DEBUG((" in xrdp_mcs_send"));
|
||||
s_pop_layer(s, mcs_hdr);
|
||||
len = (s->end - s->p) - 8;
|
||||
|
||||
if (len > 8192 * 2)
|
||||
{
|
||||
g_writeln("error in xrdp_mcs_send, size too bog, its %d", len);
|
||||
}
|
||||
|
||||
//if (len > max_len)
|
||||
//{
|
||||
// max_len = len;
|
||||
@ -698,6 +781,7 @@ xrdp_mcs_send(struct xrdp_mcs* self, struct stream* s, int chan)
|
||||
out_uint16_be(s, self->userid);
|
||||
out_uint16_be(s, chan);
|
||||
out_uint8(s, 0x70);
|
||||
|
||||
if (len >= 128)
|
||||
{
|
||||
len = len | 0x8000;
|
||||
@ -708,24 +792,29 @@ xrdp_mcs_send(struct xrdp_mcs* self, struct stream* s, int chan)
|
||||
out_uint8(s, len);
|
||||
/* move everything up one byte */
|
||||
lp = s->p;
|
||||
|
||||
while (lp < s->end)
|
||||
{
|
||||
lp[0] = lp[1];
|
||||
lp++;
|
||||
}
|
||||
|
||||
s->end--;
|
||||
}
|
||||
|
||||
if (xrdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
DEBUG((" out xrdp_mcs_send error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* todo, do we need to call this for every mcs packet,
|
||||
maybe every 5 or so */
|
||||
if (chan == MCS_GLOBAL_CHANNEL)
|
||||
{
|
||||
xrdp_mcs_call_callback(self);
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_mcs_send"));
|
||||
return 0;
|
||||
}
|
||||
@ -740,21 +829,25 @@ xrdp_mcs_disconnect(struct xrdp_mcs* self)
|
||||
DEBUG((" in xrdp_mcs_disconnect"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_disconnect error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, (MCS_DPUM << 2) | 1);
|
||||
out_uint8(s, 0x80);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_disconnect error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG((" out xrdp_mcs_disconnect"));
|
||||
return 0;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -94,6 +94,7 @@ xrdp_orders_send_ts_icon(struct stream* s, int cache_entry, int cache_id,
|
||||
int use_cmap;
|
||||
|
||||
use_cmap = 0;
|
||||
|
||||
if ((icon_info->bpp == 1) || (icon_info->bpp == 2) || (icon_info->bpp == 4))
|
||||
{
|
||||
use_cmap = 1;
|
||||
@ -105,17 +106,21 @@ xrdp_orders_send_ts_icon(struct stream* s, int cache_entry, int cache_id,
|
||||
out_uint8(s, icon_info->bpp);
|
||||
out_uint16_le(s, icon_info->width);
|
||||
out_uint16_le(s, icon_info->height);
|
||||
|
||||
if (use_cmap)
|
||||
{
|
||||
out_uint16_le(s, icon_info->cmap_bytes);
|
||||
}
|
||||
|
||||
out_uint16_le(s, icon_info->mask_bytes);
|
||||
out_uint16_le(s, icon_info->data_bytes);
|
||||
out_uint8p(s, icon_info->mask, icon_info->mask_bytes);
|
||||
|
||||
if (use_cmap)
|
||||
{
|
||||
out_uint8p(s, icon_info->cmap, icon_info->cmap_bytes);
|
||||
}
|
||||
|
||||
out_uint8p(s, icon_info->data, icon_info->data_bytes);
|
||||
return 0;
|
||||
}
|
||||
@ -137,15 +142,19 @@ xrdp_orders_send_window_icon(struct xrdp_orders* self,
|
||||
int use_cmap;
|
||||
|
||||
use_cmap = 0;
|
||||
|
||||
if ((icon_info->bpp == 1) || (icon_info->bpp == 2) || (icon_info->bpp == 4))
|
||||
{
|
||||
use_cmap = 1;
|
||||
}
|
||||
|
||||
order_size = 23 + icon_info->mask_bytes + icon_info->data_bytes;
|
||||
|
||||
if (use_cmap)
|
||||
{
|
||||
order_size += icon_info->cmap_bytes + 2;
|
||||
}
|
||||
|
||||
xrdp_orders_check(self, order_size);
|
||||
self->order_count++;
|
||||
order_flags = RDP_ORDER_SECONDARY;
|
||||
@ -176,10 +185,12 @@ xrdp_orders_send_as_unicode(struct stream* s, const char* text)
|
||||
twchar wdst[256];
|
||||
|
||||
str_chars = g_mbstowcs(wdst, text, 255);
|
||||
|
||||
if (str_chars > 0)
|
||||
{
|
||||
i32 = str_chars * 2;
|
||||
out_uint16_le(s, i32);
|
||||
|
||||
for (index = 0; index < str_chars; index++)
|
||||
{
|
||||
i32 = wdst[index];
|
||||
@ -190,6 +201,7 @@ xrdp_orders_send_as_unicode(struct stream* s, const char* text)
|
||||
{
|
||||
out_uint16_le(s, 0);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -210,11 +222,13 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
|
||||
order_size = 11;
|
||||
field_present_flags = flags | WINDOW_ORDER_TYPE_WINDOW;
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_OWNER)
|
||||
{
|
||||
/* ownerWindowId (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_STYLE)
|
||||
{
|
||||
/* style (4 bytes) */
|
||||
@ -222,17 +236,20 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* extendedStyle (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_SHOW)
|
||||
{
|
||||
/* showState (1 byte) */
|
||||
order_size += 1;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_TITLE)
|
||||
{
|
||||
/* titleInfo */
|
||||
num_chars = g_mbstowcs(0, window_state->title_info, 0);
|
||||
order_size += 2 * num_chars + 2;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
|
||||
{
|
||||
/* clientOffsetX (4 bytes) */
|
||||
@ -240,6 +257,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* clientOffsetY (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
|
||||
{
|
||||
/* clientAreaWidth (4 bytes) */
|
||||
@ -247,16 +265,19 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* clientAreaHeight (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_RP_CONTENT)
|
||||
{
|
||||
/* RPContent (1 byte) */
|
||||
order_size += 1;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_ROOT_PARENT)
|
||||
{
|
||||
/* rootParentHandle (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_OFFSET)
|
||||
{
|
||||
/* windowOffsetX (4 bytes) */
|
||||
@ -264,6 +285,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* windowOffsetY (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
|
||||
{
|
||||
/* windowClientDeltaX (4 bytes) */
|
||||
@ -271,6 +293,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* windowClientDeltaY (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_SIZE)
|
||||
{
|
||||
/* windowWidth (4 bytes) */
|
||||
@ -278,12 +301,14 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* windowHeight (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_RECTS)
|
||||
{
|
||||
/* numWindowRects (2 bytes) */
|
||||
order_size += 2;
|
||||
order_size += 8 * window_state->num_window_rects;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_VIS_OFFSET)
|
||||
{
|
||||
/* visibleOffsetX (4 bytes) */
|
||||
@ -291,6 +316,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* visibleOffsetY (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_VISIBILITY)
|
||||
{
|
||||
/* numVisibilityRects (2 bytes) */
|
||||
@ -315,6 +341,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* ownerWindowId (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->owner_window_id);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_STYLE)
|
||||
{
|
||||
/* style (4 bytes) */
|
||||
@ -322,16 +349,19 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* extendedStyle (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->extended_style);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_SHOW)
|
||||
{
|
||||
/* showState (1 byte) */
|
||||
out_uint8(self->out_s, window_state->show_state);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_TITLE)
|
||||
{
|
||||
/* titleInfo */
|
||||
xrdp_orders_send_as_unicode(self->out_s, window_state->title_info);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_CLIENT_AREA_OFFSET)
|
||||
{
|
||||
/* clientOffsetX (4 bytes) */
|
||||
@ -339,6 +369,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* clientOffsetY (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->client_offset_y);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_CLIENT_AREA_SIZE)
|
||||
{
|
||||
/* clientAreaWidth (4 bytes) */
|
||||
@ -346,16 +377,19 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* clientAreaHeight (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->client_area_height);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_RP_CONTENT)
|
||||
{
|
||||
/* RPContent (1 byte) */
|
||||
out_uint8(self->out_s, window_state->rp_content);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_ROOT_PARENT)
|
||||
{
|
||||
/* rootParentHandle (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->root_parent_handle);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_OFFSET)
|
||||
{
|
||||
/* windowOffsetX (4 bytes) */
|
||||
@ -363,6 +397,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* windowOffsetY (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->window_offset_y);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_CLIENT_DELTA)
|
||||
{
|
||||
/* windowClientDeltaX (4 bytes) */
|
||||
@ -370,6 +405,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* windowClientDeltaY (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->window_client_delta_y);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_SIZE)
|
||||
{
|
||||
/* windowWidth (4 bytes) */
|
||||
@ -377,10 +413,12 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* windowHeight (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->window_height);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_WND_RECTS)
|
||||
{
|
||||
/* numWindowRects (2 bytes) */
|
||||
out_uint16_le(self->out_s, window_state->num_window_rects);
|
||||
|
||||
for (index = 0; index < window_state->num_window_rects; index++)
|
||||
{
|
||||
out_uint16_le(self->out_s, window_state->window_rects[index].left);
|
||||
@ -389,6 +427,7 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
out_uint16_le(self->out_s, window_state->window_rects[index].bottom);
|
||||
}
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_VIS_OFFSET)
|
||||
{
|
||||
/* visibleOffsetX (4 bytes) */
|
||||
@ -396,10 +435,12 @@ xrdp_orders_send_window_new_update(struct xrdp_orders* self, int window_id,
|
||||
/* visibleOffsetY (4 bytes) */
|
||||
out_uint32_le(self->out_s, window_state->visible_offset_y);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_VISIBILITY)
|
||||
{
|
||||
/* numVisibilityRects (2 bytes) */
|
||||
out_uint16_le(self->out_s, window_state->num_visibility_rects);
|
||||
|
||||
for (index = 0; index < window_state->num_visibility_rects; index++)
|
||||
{
|
||||
out_uint16_le(self->out_s, window_state->visibility_rects[index].left);
|
||||
@ -459,17 +500,20 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
|
||||
|
||||
order_size = 15;
|
||||
field_present_flags = flags | WINDOW_ORDER_TYPE_NOTIFY;
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_VERSION)
|
||||
{
|
||||
/* Version (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_TIP)
|
||||
{
|
||||
/* ToolTip (variable) UNICODE_STRING */
|
||||
num_chars = g_mbstowcs(0, notify_state->tool_tip, 0);
|
||||
order_size += 2 * num_chars + 2;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP)
|
||||
{
|
||||
/* InfoTip (variable) TS_NOTIFY_ICON_INFOTIP */
|
||||
@ -483,27 +527,33 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
|
||||
/* InfoFlags (4 bytes) */
|
||||
order_size += 8;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_STATE)
|
||||
{
|
||||
/* State (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_ICON)
|
||||
{
|
||||
/* Icon (variable) */
|
||||
use_cmap = 0;
|
||||
|
||||
if ((notify_state->icon_info.bpp == 1) || (notify_state->icon_info.bpp == 2) ||
|
||||
(notify_state->icon_info.bpp == 4))
|
||||
{
|
||||
use_cmap = 1;
|
||||
}
|
||||
|
||||
order_size += 12 + notify_state->icon_info.mask_bytes +
|
||||
notify_state->icon_info.data_bytes;
|
||||
|
||||
if (use_cmap)
|
||||
{
|
||||
order_size += notify_state->icon_info.cmap_bytes + 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_CACHED_ICON)
|
||||
{
|
||||
/* CachedIcon (3 bytes) */
|
||||
@ -529,11 +579,13 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
|
||||
/* Version (4 bytes) */
|
||||
out_uint32_le(self->out_s, notify_state->version);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_TIP)
|
||||
{
|
||||
/* ToolTip (variable) UNICODE_STRING */
|
||||
xrdp_orders_send_as_unicode(self->out_s, notify_state->tool_tip);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_INFO_TIP)
|
||||
{
|
||||
/* InfoTip (variable) TS_NOTIFY_ICON_INFOTIP */
|
||||
@ -542,11 +594,13 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
|
||||
xrdp_orders_send_as_unicode(self->out_s, notify_state->infotip.text);
|
||||
xrdp_orders_send_as_unicode(self->out_s, notify_state->infotip.title);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_NOTIFY_STATE)
|
||||
{
|
||||
/* State (4 bytes) */
|
||||
out_uint32_le(self->out_s, notify_state->state);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_ICON)
|
||||
{
|
||||
/* Icon (variable) */
|
||||
@ -554,6 +608,7 @@ xrdp_orders_send_notify_new_update(struct xrdp_orders* self,
|
||||
notify_state->icon_cache_id,
|
||||
¬ify_state->icon_info);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_CACHED_ICON)
|
||||
{
|
||||
/* CacheEntry (2 bytes) */
|
||||
@ -587,6 +642,7 @@ xrdp_orders_send_monitored_desktop(struct xrdp_orders* self,
|
||||
/* ActiveWindowId (4 bytes) */
|
||||
order_size += 4;
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
|
||||
{
|
||||
/* NumWindowIds (1 byte) */
|
||||
@ -610,10 +666,12 @@ xrdp_orders_send_monitored_desktop(struct xrdp_orders* self,
|
||||
/* ActiveWindowId (4 bytes) */
|
||||
out_uint32_le(self->out_s, mdo->active_window_id);
|
||||
}
|
||||
|
||||
if (field_present_flags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
|
||||
{
|
||||
/* NumWindowIds (1 byte) */
|
||||
out_uint8(self->out_s, mdo->num_window_ids);
|
||||
|
||||
/* WindowIds (variable) */
|
||||
for (index = 0; index < mdo->num_window_ids; index++)
|
||||
{
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
rdp layer
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* rdp layer
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
@ -29,7 +27,8 @@
|
||||
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
static tui8 g_unknown1[172] =
|
||||
{ 0xff, 0x02, 0xb6, 0x00, 0x28, 0x00, 0x00, 0x00,
|
||||
{
|
||||
0xff, 0x02, 0xb6, 0x00, 0x28, 0x00, 0x00, 0x00,
|
||||
0x27, 0x00, 0x27, 0x00, 0x03, 0x00, 0x04, 0x00,
|
||||
0x00, 0x00, 0x26, 0x00, 0x01, 0x00, 0x1e, 0x00,
|
||||
0x02, 0x00, 0x1f, 0x00, 0x03, 0x00, 0x1d, 0x00,
|
||||
@ -50,7 +49,8 @@ static tui8 g_unknown1[172] =
|
||||
0x25, 0x00, 0x09, 0x00, 0x26, 0x00, 0x04, 0x00,
|
||||
0x27, 0x00, 0x03, 0x00, 0x28, 0x00, 0x02, 0x00,
|
||||
0x29, 0x00, 0x01, 0x00, 0x2a, 0x00, 0x05, 0x00,
|
||||
0x2b, 0x00, 0x2a, 0x00 };
|
||||
0x2b, 0x00, 0x2a, 0x00
|
||||
};
|
||||
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
/*
|
||||
@ -78,10 +78,12 @@ xrdp_rdp_read_config(struct xrdp_client_info* client_info)
|
||||
values->auto_free = 1;
|
||||
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
||||
file_by_name_read_section(cfg_file, "globals", items, values);
|
||||
|
||||
for (index = 0; index < items->count; index++)
|
||||
{
|
||||
item = (char *)list_get_item(items, index);
|
||||
value = (char *)list_get_item(values, index);
|
||||
|
||||
if (g_strcasecmp(item, "bitmap_cache") == 0)
|
||||
{
|
||||
if ((g_strcasecmp(value, "yes") == 0) ||
|
||||
@ -139,6 +141,7 @@ xrdp_rdp_read_config(struct xrdp_client_info* client_info)
|
||||
client_info->max_bpp = g_atoi(value);
|
||||
}
|
||||
}
|
||||
|
||||
list_delete(items);
|
||||
list_delete(values);
|
||||
return 0;
|
||||
@ -242,6 +245,7 @@ xrdp_rdp_delete(struct xrdp_rdp* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
xrdp_sec_delete(self->sec_layer);
|
||||
#if defined(XRDP_FREERDP1)
|
||||
mppc_enc_free((struct rdp_mppc_enc *)(self->mppc_enc));
|
||||
@ -258,6 +262,7 @@ xrdp_rdp_init(struct xrdp_rdp* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_push_layer(s, rdp_hdr, 6);
|
||||
return 0;
|
||||
}
|
||||
@ -270,6 +275,7 @@ xrdp_rdp_init_data(struct xrdp_rdp* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_push_layer(s, rdp_hdr, 18);
|
||||
return 0;
|
||||
}
|
||||
@ -285,10 +291,12 @@ xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
|
||||
int chan = 0;
|
||||
|
||||
DEBUG(("in xrdp_rdp_recv"));
|
||||
|
||||
if (s->next_packet == 0 || s->next_packet >= s->end)
|
||||
{
|
||||
chan = 0;
|
||||
error = xrdp_sec_recv(self->sec_layer, s, &chan);
|
||||
|
||||
if (error == -1) /* special code for send demand active */
|
||||
{
|
||||
s->next_packet = 0;
|
||||
@ -296,11 +304,13 @@ xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
|
||||
DEBUG(("out (1) xrdp_rdp_recv"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
DEBUG(("out xrdp_rdp_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if ((chan != MCS_GLOBAL_CHANNEL) && (chan > 0))
|
||||
{
|
||||
if (chan > MCS_GLOBAL_CHANNEL)
|
||||
@ -314,11 +324,13 @@ xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
|
||||
{
|
||||
g_writeln("Wrong channel Id to be handled by xrdp_channel_process %d", chan);
|
||||
}
|
||||
|
||||
s->next_packet = 0;
|
||||
*code = 0;
|
||||
DEBUG(("out (2) xrdp_rdp_recv"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
s->next_packet = s->p;
|
||||
}
|
||||
else
|
||||
@ -326,6 +338,7 @@ xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
|
||||
DEBUG(("xrdp_rdp_recv stream not touched"))
|
||||
s->p = s->next_packet;
|
||||
}
|
||||
|
||||
if (!s_check_rem(s, 6))
|
||||
{
|
||||
s->next_packet = 0;
|
||||
@ -360,11 +373,13 @@ xrdp_rdp_send(struct xrdp_rdp* self, struct stream* s, int pdu_type)
|
||||
out_uint16_le(s, len);
|
||||
out_uint16_le(s, 0x10 | pdu_type);
|
||||
out_uint16_le(s, self->mcs_channel);
|
||||
|
||||
if (xrdp_sec_send(self->sec_layer, s, MCS_GLOBAL_CHANNEL) != 0)
|
||||
{
|
||||
DEBUG(("out xrdp_rdp_send error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_rdp_send"));
|
||||
return 0;
|
||||
}
|
||||
@ -400,14 +415,17 @@ xrdp_rdp_send_data(struct xrdp_rdp* self, struct stream* s,
|
||||
clen = len;
|
||||
tocomplen = pdulen - 18;
|
||||
#if defined(XRDP_FREERDP1)
|
||||
|
||||
if (self->client_info.rdp_compression && self->session->up_and_running)
|
||||
{
|
||||
mppc_enc = (struct rdp_mppc_enc *)(self->mppc_enc);
|
||||
|
||||
if (compress_rdp(mppc_enc, (tui8 *)(s->p + 18), tocomplen))
|
||||
{
|
||||
DEBUG(("mppc_encode ok flags 0x%x bytes_in_opb %d historyOffset %d "
|
||||
"tocomplen %d", mppc_enc->flags, mppc_enc->bytes_in_opb,
|
||||
mppc_enc->historyOffset, tocomplen));
|
||||
|
||||
if (mppc_enc->flags & RDP_MPPC_COMPRESSED)
|
||||
{
|
||||
clen = mppc_enc->bytes_in_opb + 18;
|
||||
@ -437,6 +455,7 @@ xrdp_rdp_send_data(struct xrdp_rdp* self, struct stream* s,
|
||||
g_writeln("mppc_encode not ok");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
out_uint16_le(s, pdulen);
|
||||
out_uint16_le(s, pdutype);
|
||||
@ -454,6 +473,7 @@ xrdp_rdp_send_data(struct xrdp_rdp* self, struct stream* s,
|
||||
DEBUG(("out xrdp_rdp_send_data error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_rdp_send_data"));
|
||||
return 0;
|
||||
}
|
||||
@ -467,21 +487,25 @@ xrdp_rdp_send_data_update_sync(struct xrdp_rdp* self)
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
DEBUG(("in xrdp_rdp_send_data_update_sync"));
|
||||
|
||||
if (xrdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
DEBUG(("out xrdp_rdp_send_data_update_sync error"));
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, RDP_UPDATE_SYNCHRONIZE);
|
||||
out_uint8s(s, 2);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data(self, s, RDP_DATA_PDU_UPDATE) != 0)
|
||||
{
|
||||
DEBUG(("out xrdp_rdp_send_data_update_sync error"));
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_rdp_send_data_update_sync"));
|
||||
free_stream(s);
|
||||
return 0;
|
||||
@ -502,15 +526,18 @@ xrdp_rdp_parse_client_mcs_data(struct xrdp_rdp* self)
|
||||
in_uint8s(p, 120);
|
||||
self->client_info.bpp = 8;
|
||||
in_uint16_le(p, i);
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0xca01:
|
||||
in_uint8s(p, 6);
|
||||
in_uint8(p, i);
|
||||
|
||||
if (i > 8)
|
||||
{
|
||||
self->client_info.bpp = i;
|
||||
}
|
||||
|
||||
break;
|
||||
case 0xca02:
|
||||
self->client_info.bpp = 15;
|
||||
@ -522,6 +549,7 @@ xrdp_rdp_parse_client_mcs_data(struct xrdp_rdp* self)
|
||||
self->client_info.bpp = 24;
|
||||
break;
|
||||
}
|
||||
|
||||
if (self->client_info.max_bpp > 0)
|
||||
{
|
||||
if (self->client_info.bpp > self->client_info.max_bpp)
|
||||
@ -529,6 +557,7 @@ xrdp_rdp_parse_client_mcs_data(struct xrdp_rdp* self)
|
||||
self->client_info.bpp = self->client_info.max_bpp;
|
||||
}
|
||||
}
|
||||
|
||||
p->p = p->data;
|
||||
DEBUG(("client width %d, client height %d bpp %d",
|
||||
self->client_info.width, self->client_info.height,
|
||||
@ -541,10 +570,12 @@ int APP_CC
|
||||
xrdp_rdp_incoming(struct xrdp_rdp *self)
|
||||
{
|
||||
DEBUG(("in xrdp_rdp_incoming"));
|
||||
|
||||
if (xrdp_sec_incoming(self->sec_layer) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
self->mcs_channel = self->sec_layer->mcs_layer->userid +
|
||||
MCS_USERCHANNEL_BASE;
|
||||
xrdp_rdp_parse_client_mcs_data(self);
|
||||
@ -569,6 +600,7 @@ xrdp_rdp_send_demand_active(struct xrdp_rdp* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
@ -843,11 +875,13 @@ xrdp_process_capset_order(struct xrdp_rdp* self, struct stream* s,
|
||||
in_uint8s(s, 2); /* Text capability flags */
|
||||
/* read extended order support flags */
|
||||
in_uint16_le(s, ex_flags); /* Ex flags */
|
||||
|
||||
if (ex_flags & XR_ORDERFLAGS_EX_CACHE_BITMAP_REV3_SUPPORT)
|
||||
{
|
||||
g_writeln("xrdp_process_capset_order: bitmap cache v3 supported");
|
||||
self->client_info.bitmap_cache_version |= 4;
|
||||
}
|
||||
|
||||
in_uint8s(s, 4); /* Pad */
|
||||
|
||||
in_uint32_le(s, i); /* desktop cache size, usually 0x38400 */
|
||||
@ -971,6 +1005,7 @@ xrdp_process_offscreen_bmpcache(struct xrdp_rdp* self, struct stream* s,
|
||||
g_writeln("xrdp_process_offscreen_bmpcache: bad len");
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint32_le(s, i32);
|
||||
self->client_info.offscreen_support_level = i32;
|
||||
in_uint16_le(s, i32);
|
||||
@ -996,6 +1031,7 @@ xrdp_process_capset_rail(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
g_writeln("xrdp_process_capset_rail: bad len");
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint32_le(s, i32);
|
||||
self->client_info.rail_support_level = i32;
|
||||
g_writeln("xrdp_process_capset_rail: rail_support_level %d",
|
||||
@ -1014,6 +1050,7 @@ xrdp_process_capset_window(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
g_writeln("xrdp_process_capset_window: bad len");
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint32_le(s, i32);
|
||||
self->client_info.wnd_support_level = i32;
|
||||
in_uint8(s, i32);
|
||||
@ -1041,6 +1078,7 @@ xrdp_process_capset_codecs(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
char *next_guid;
|
||||
|
||||
in_uint8(s, codec_count);
|
||||
|
||||
for (index = 0; index < codec_count; index++)
|
||||
{
|
||||
codec_guid = s->p;
|
||||
@ -1048,6 +1086,7 @@ xrdp_process_capset_codecs(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
in_uint8(s, codec_id);
|
||||
in_uint16_le(s, codec_properties_length);
|
||||
next_guid = s->p + codec_properties_length;
|
||||
|
||||
if (g_memcmp(codec_guid, XR_CODEC_GUID_NSCODEC, 16) == 0)
|
||||
{
|
||||
g_writeln("xrdp_process_capset_codecs: nscodec codec id %d prop len %d",
|
||||
@ -1080,8 +1119,10 @@ xrdp_process_capset_codecs(struct xrdp_rdp* self, struct stream* s, int len)
|
||||
{
|
||||
g_writeln("xrdp_process_capset_codecs: unknown codec id %d", codec_id);
|
||||
}
|
||||
|
||||
s->p = next_guid;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1105,11 +1146,13 @@ xrdp_rdp_process_confirm_active(struct xrdp_rdp* self, struct stream* s)
|
||||
in_uint8s(s, source_len);
|
||||
in_uint16_le(s, num_caps);
|
||||
in_uint8s(s, 2); /* pad */
|
||||
|
||||
for (index = 0; index < num_caps; index++)
|
||||
{
|
||||
p = s->p;
|
||||
in_uint16_le(s, type);
|
||||
in_uint16_le(s, len);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case RDP_CAPSET_GENERAL: /* 1 */
|
||||
@ -1194,8 +1237,10 @@ xrdp_rdp_process_confirm_active(struct xrdp_rdp* self, struct stream* s)
|
||||
g_writeln("unknown in xrdp_rdp_process_confirm_active %d", type);
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = p + len;
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_rdp_process_confirm_active"));
|
||||
return 0;
|
||||
}
|
||||
@ -1223,6 +1268,7 @@ xrdp_rdp_process_data_input(struct xrdp_rdp* self, struct stream* s)
|
||||
in_uint16_le(s, num_events);
|
||||
in_uint8s(s, 2); /* pad */
|
||||
DEBUG(("in xrdp_rdp_process_data_input %d events", num_events));
|
||||
|
||||
for (index = 0; index < num_events; index++)
|
||||
{
|
||||
in_uint32_le(s, time);
|
||||
@ -1232,6 +1278,7 @@ xrdp_rdp_process_data_input(struct xrdp_rdp* self, struct stream* s)
|
||||
in_sint16_le(s, param2);
|
||||
DEBUG(("xrdp_rdp_process_data_input event %4.4x flags %4.4x param1 %d \
|
||||
param2 %d time %d", msg_type, device_flags, param1, param2, time));
|
||||
|
||||
if (self->session->callback != 0)
|
||||
{
|
||||
/* msg_type can be
|
||||
@ -1243,6 +1290,7 @@ param2 %d time %d", msg_type, device_flags, param1, param2, time));
|
||||
device_flags, time);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_rdp_process_data_input"));
|
||||
return 0;
|
||||
}
|
||||
@ -1255,19 +1303,23 @@ xrdp_rdp_send_synchronise(struct xrdp_rdp* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, 1);
|
||||
out_uint16_le(s, 1002);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data(self, s, RDP_DATA_PDU_SYNCHRONISE) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -1280,20 +1332,24 @@ xrdp_rdp_send_control(struct xrdp_rdp* self, int action)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, action);
|
||||
out_uint16_le(s, 0); /* userid */
|
||||
out_uint32_le(s, 1002); /* control id */
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data(self, s, RDP_DATA_PDU_CONTROL) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -1308,6 +1364,7 @@ xrdp_rdp_process_data_control(struct xrdp_rdp* self, struct stream* s)
|
||||
in_uint16_le(s, action);
|
||||
in_uint8s(s, 2); /* user id */
|
||||
in_uint8s(s, 4); /* control id */
|
||||
|
||||
if (action == RDP_CTL_REQUEST_CONTROL)
|
||||
{
|
||||
DEBUG(("xrdp_rdp_process_data_control got RDP_CTL_REQUEST_CONTROL"));
|
||||
@ -1322,6 +1379,7 @@ xrdp_rdp_process_data_control(struct xrdp_rdp* self, struct stream* s)
|
||||
{
|
||||
DEBUG(("xrdp_rdp_process_data_control unknown action"));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1352,10 +1410,12 @@ xrdp_rdp_process_screen_update(struct xrdp_rdp* self, struct stream* s)
|
||||
in_uint16_le(s, bottom);
|
||||
cx = (right - left) + 1;
|
||||
cy = (bottom - top) + 1;
|
||||
|
||||
if (self->session->callback != 0)
|
||||
{
|
||||
self->session->callback(self->session->id, 0x4444, left, top, cx, cy);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1367,18 +1427,22 @@ xrdp_rdp_send_unknown1(struct xrdp_rdp* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8a(s, g_unknown1, 172);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data(self, s, 0x28) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -1393,16 +1457,19 @@ xrdp_rdp_process_data_font(struct xrdp_rdp* self, struct stream* s)
|
||||
in_uint8s(s, 2); /* num of fonts */
|
||||
in_uint8s(s, 2); /* unknown */
|
||||
in_uint16_le(s, seq);
|
||||
|
||||
/* 419 client sends Seq 1, then 2 */
|
||||
/* 2600 clients sends only Seq 3 */
|
||||
if (seq == 2 || seq == 3) /* after second font message, we are up and */
|
||||
{ /* running */
|
||||
{
|
||||
/* running */
|
||||
DEBUG(("sending unknown1"));
|
||||
xrdp_rdp_send_unknown1(self);
|
||||
self->session->up_and_running = 1;
|
||||
DEBUG(("up_and_running set"));
|
||||
xrdp_rdp_send_data_update_sync(self);
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_rdp_process_data_font"));
|
||||
return 0;
|
||||
}
|
||||
@ -1416,17 +1483,21 @@ xrdp_rdp_send_disconnect_query_response(struct xrdp_rdp* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data(self, s, 37) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -1441,18 +1512,22 @@ xrdp_rdp_send_disconnect_reason(struct xrdp_rdp* self, int reason)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init_data(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, reason);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send_data(self, s, RDP_DATA_PDU_DISCONNECT) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -1474,6 +1549,7 @@ xrdp_rdp_process_data(struct xrdp_rdp* self, struct stream* s)
|
||||
in_uint8(s, ctype);
|
||||
in_uint16_le(s, clen);
|
||||
DEBUG(("xrdp_rdp_process_data code %d", data_type));
|
||||
|
||||
switch (data_type)
|
||||
{
|
||||
case RDP_DATA_PDU_POINTER: /* 27(0x1b) */
|
||||
@ -1510,6 +1586,7 @@ xrdp_rdp_process_data(struct xrdp_rdp* self, struct stream* s)
|
||||
g_writeln("unknown in xrdp_rdp_process_data %d", data_type);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1534,19 +1611,23 @@ xrdp_rdp_send_deactive(struct xrdp_rdp* self)
|
||||
DEBUG(("in xrdp_rdp_send_deactive"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_rdp_init(self, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG(("out xrdp_rdp_send_deactive error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_rdp_send(self, s, RDP_PDU_DEACTIVATE) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG(("out xrdp_rdp_send_deactive error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG(("out xrdp_rdp_send_deactive"));
|
||||
return 0;
|
||||
|
@ -1,42 +1,45 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
secure layer
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* secure layer
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
static tui8 g_pad_54[40] =
|
||||
{ 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
||||
{
|
||||
54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
||||
54, 54, 54, 54, 54, 54, 54, 54 };
|
||||
54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
||||
54, 54, 54, 54, 54, 54, 54, 54
|
||||
};
|
||||
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
static tui8 g_pad_92[48] =
|
||||
{ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
|
||||
{
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92 };
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92
|
||||
};
|
||||
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
static tui8 g_lic1[322] =
|
||||
{ 0x80, 0x00, 0x3e, 0x01, 0x01, 0x02, 0x3e, 0x01,
|
||||
{
|
||||
0x80, 0x00, 0x3e, 0x01, 0x01, 0x02, 0x3e, 0x01,
|
||||
0x7b, 0x3c, 0x31, 0xa6, 0xae, 0xe8, 0x74, 0xf6,
|
||||
0xb4, 0xa5, 0x03, 0x90, 0xe7, 0xc2, 0xc7, 0x39,
|
||||
0xba, 0x53, 0x1c, 0x30, 0x54, 0x6e, 0x90, 0x05,
|
||||
@ -76,20 +79,25 @@ static tui8 g_lic1[322] =
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x0e, 0x00, 0x0e, 0x00, 0x6d, 0x69, 0x63, 0x72,
|
||||
0x6f, 0x73, 0x6f, 0x66, 0x74, 0x2e, 0x63, 0x6f,
|
||||
0x6d, 0x00 };
|
||||
0x6d, 0x00
|
||||
};
|
||||
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
static tui8 g_lic2[20] =
|
||||
{ 0x80, 0x00, 0x10, 0x00, 0xff, 0x02, 0x10, 0x00,
|
||||
{
|
||||
0x80, 0x00, 0x10, 0x00, 0xff, 0x02, 0x10, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0x28, 0x14, 0x00, 0x00 };
|
||||
0x28, 0x14, 0x00, 0x00
|
||||
};
|
||||
|
||||
/* mce */
|
||||
/* some compilers need unsigned char to avoid warnings */
|
||||
static tui8 g_lic3[20] =
|
||||
{ 0x80, 0x02, 0x10, 0x00, 0xff, 0x03, 0x10, 0x00,
|
||||
{
|
||||
0x80, 0x02, 0x10, 0x00, 0xff, 0x03, 0x10, 0x00,
|
||||
0x07, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
|
||||
0xf3, 0x99, 0x00, 0x00 };
|
||||
0xf3, 0x99, 0x00, 0x00
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
static void APP_CC
|
||||
@ -104,6 +112,7 @@ hex_str_to_bin(char* in, char* out, int out_len)
|
||||
in_len = g_strlen(in);
|
||||
out_index = 0;
|
||||
in_index = 0;
|
||||
|
||||
while (in_index <= (in_len - 4))
|
||||
{
|
||||
if ((in[in_index] == '0') && (in[in_index + 1] == 'x'))
|
||||
@ -111,13 +120,16 @@ hex_str_to_bin(char* in, char* out, int out_len)
|
||||
hex[0] = in[in_index + 2];
|
||||
hex[1] = in[in_index + 3];
|
||||
hex[2] = 0;
|
||||
|
||||
if (out_index < out_len)
|
||||
{
|
||||
val = g_htoi(hex);
|
||||
out[out_index] = val;
|
||||
}
|
||||
|
||||
out_index++;
|
||||
}
|
||||
|
||||
in_index++;
|
||||
}
|
||||
}
|
||||
@ -134,6 +146,7 @@ xrdp_sec_create(struct xrdp_rdp* owner, struct trans* trans, int crypt_level,
|
||||
self->rdp_layer = owner;
|
||||
self->rc4_key_size = 1; /* 1 = 40 bit, 2 = 128 bit */
|
||||
self->crypt_level = 1; /* 1, 2, 3 = low, medium, high */
|
||||
|
||||
switch (crypt_level)
|
||||
{
|
||||
case 1:
|
||||
@ -152,16 +165,21 @@ xrdp_sec_create(struct xrdp_rdp* owner, struct trans* trans, int crypt_level,
|
||||
g_writeln("Fatal : Illegal crypt_level");
|
||||
break ;
|
||||
}
|
||||
|
||||
self->channel_code = channel_code;
|
||||
|
||||
if (self->decrypt_rc4_info != NULL)
|
||||
{
|
||||
g_writeln("xrdp_sec_create - decrypt_rc4_info already created !!!");
|
||||
}
|
||||
|
||||
self->decrypt_rc4_info = ssl_rc4_info_create();
|
||||
|
||||
if (self->encrypt_rc4_info != NULL)
|
||||
{
|
||||
g_writeln("xrdp_sec_create - encrypt_rc4_info already created !!!");
|
||||
}
|
||||
|
||||
self->encrypt_rc4_info = ssl_rc4_info_create();
|
||||
self->mcs_layer = xrdp_mcs_create(self, trans, &self->client_mcs_data,
|
||||
&self->server_mcs_data);
|
||||
@ -179,6 +197,7 @@ xrdp_sec_delete(struct xrdp_sec* self)
|
||||
g_writeln("xrdp_sec_delete: indata is null");
|
||||
return;
|
||||
}
|
||||
|
||||
xrdp_channel_delete(self->chan_layer);
|
||||
xrdp_mcs_delete(self->mcs_layer);
|
||||
ssl_rc4_info_delete(self->decrypt_rc4_info); /* TODO clear all data */
|
||||
@ -199,6 +218,7 @@ xrdp_sec_init(struct xrdp_sec* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (self->crypt_level > 1)
|
||||
{
|
||||
s_push_layer(s, sec_hdr, 4 + 8);
|
||||
@ -207,6 +227,7 @@ xrdp_sec_init(struct xrdp_sec* self, struct stream* s)
|
||||
{
|
||||
s_push_layer(s, sec_hdr, 4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -246,10 +267,12 @@ xrdp_sec_update(char* key, char* update_key, int key_len)
|
||||
ssl_md5_complete(md5_info, key);
|
||||
ssl_rc4_set_key(rc4_info, key, key_len);
|
||||
ssl_rc4_crypt(rc4_info, key, key_len);
|
||||
|
||||
if (key_len == 8)
|
||||
{
|
||||
xrdp_sec_make_40bit(key);
|
||||
}
|
||||
|
||||
ssl_sha1_info_delete(sha1_info);
|
||||
ssl_md5_info_delete(md5_info);
|
||||
ssl_rc4_info_delete(rc4_info);
|
||||
@ -268,6 +291,7 @@ xrdp_sec_decrypt(struct xrdp_sec* self, char* data, int len)
|
||||
self->rc4_key_len);
|
||||
self->decrypt_use_count = 0;
|
||||
}
|
||||
|
||||
ssl_rc4_crypt(self->decrypt_rc4_info, data, len);
|
||||
self->decrypt_use_count++;
|
||||
}
|
||||
@ -284,6 +308,7 @@ xrdp_sec_encrypt(struct xrdp_sec* self, char* data, int len)
|
||||
self->rc4_key_len);
|
||||
self->encrypt_use_count = 0;
|
||||
}
|
||||
|
||||
ssl_rc4_crypt(self->encrypt_rc4_info, data, len);
|
||||
self->encrypt_use_count++;
|
||||
}
|
||||
@ -297,17 +322,20 @@ unicode_in(struct stream* s, int uni_len, char* dst, int dst_len)
|
||||
|
||||
dst_index = 0;
|
||||
src_index = 0;
|
||||
|
||||
while (src_index < uni_len)
|
||||
{
|
||||
if (dst_index >= dst_len || src_index > 512)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
in_uint8(s, dst[dst_index]);
|
||||
in_uint8s(s, 1);
|
||||
dst_index++;
|
||||
src_index += 2;
|
||||
}
|
||||
|
||||
in_uint8s(s, 2);
|
||||
return 0;
|
||||
}
|
||||
@ -333,57 +361,79 @@ xrdp_sec_process_logon_info(struct xrdp_sec* self, struct stream* s)
|
||||
in_uint8s(s, 4);
|
||||
in_uint32_le(s, flags);
|
||||
DEBUG(("in xrdp_sec_process_logon_info flags $%x", flags));
|
||||
|
||||
/* this is the first test that the decrypt is working */
|
||||
if ((flags & RDP_LOGON_NORMAL) != RDP_LOGON_NORMAL) /* 0x33 */
|
||||
{ /* must be or error */
|
||||
{
|
||||
/* must be or error */
|
||||
DEBUG(("xrdp_sec_process_logon_info: flags wrong, major error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (flags & RDP_LOGON_LEAVE_AUDIO)
|
||||
{
|
||||
self->rdp_layer->client_info.sound_code = 1;
|
||||
DEBUG(("flag RDP_LOGON_LEAVE_AUDIO found"));
|
||||
}
|
||||
|
||||
if ((flags & RDP_LOGON_AUTO) && (!self->rdp_layer->client_info.is_mce))
|
||||
/* todo, for now not allowing autologon and mce both */
|
||||
{
|
||||
self->rdp_layer->client_info.rdp_autologin = 1;
|
||||
DEBUG(("flag RDP_LOGON_AUTO found"));
|
||||
}
|
||||
|
||||
if (flags & RDP_COMPRESSION)
|
||||
{
|
||||
self->rdp_layer->client_info.rdp_compression = 1;
|
||||
DEBUG(("flag RDP_COMPRESSION found"));
|
||||
}
|
||||
|
||||
in_uint16_le(s, len_domain);
|
||||
if (len_domain > 511) {
|
||||
|
||||
if (len_domain > 511)
|
||||
{
|
||||
DEBUG(("ERROR [xrdp_sec_process_logon_info()]: len_domain > 511"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint16_le(s, len_user);
|
||||
if (len_user > 511) {
|
||||
|
||||
if (len_user > 511)
|
||||
{
|
||||
DEBUG(("ERROR [xrdp_sec_process_logon_info()]: len_user > 511"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint16_le(s, len_password);
|
||||
if (len_password > 511) {
|
||||
|
||||
if (len_password > 511)
|
||||
{
|
||||
DEBUG(("ERROR [xrdp_sec_process_logon_info()]: len_password > 511"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint16_le(s, len_program);
|
||||
if (len_program > 511) {
|
||||
|
||||
if (len_program > 511)
|
||||
{
|
||||
DEBUG(("ERROR [xrdp_sec_process_logon_info()]: len_program > 511"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint16_le(s, len_directory);
|
||||
if (len_directory > 511) {
|
||||
|
||||
if (len_directory > 511)
|
||||
{
|
||||
DEBUG(("ERROR [xrdp_sec_process_logon_info()]: len_directory > 511"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
unicode_in(s, len_domain, self->rdp_layer->client_info.domain, 255);
|
||||
DEBUG(("domain %s", self->rdp_layer->client_info.domain));
|
||||
unicode_in(s, len_user, self->rdp_layer->client_info.username, 255);
|
||||
DEBUG(("username %s", self->rdp_layer->client_info.username));
|
||||
|
||||
if (flags & RDP_LOGON_AUTO)
|
||||
{
|
||||
unicode_in(s, len_password, self->rdp_layer->client_info.password, 255);
|
||||
@ -393,10 +443,12 @@ xrdp_sec_process_logon_info(struct xrdp_sec* self, struct stream* s)
|
||||
{
|
||||
in_uint8s(s, len_password + 2);
|
||||
}
|
||||
|
||||
unicode_in(s, len_program, self->rdp_layer->client_info.program, 255);
|
||||
DEBUG(("program %s", self->rdp_layer->client_info.program));
|
||||
unicode_in(s, len_directory, self->rdp_layer->client_info.directory, 255);
|
||||
DEBUG(("directory %s", self->rdp_layer->client_info.directory));
|
||||
|
||||
if (flags & RDP_LOGON_BLOB)
|
||||
{
|
||||
in_uint8s(s, 2); /* unknown */
|
||||
@ -411,6 +463,7 @@ xrdp_sec_process_logon_info(struct xrdp_sec* self, struct stream* s)
|
||||
in_uint8s(s, 26); /* skip stuff */
|
||||
in_uint32_le(s, self->rdp_layer->client_info.rdp5_performanceflags);
|
||||
}
|
||||
|
||||
DEBUG(("out xrdp_sec_process_logon_info"));
|
||||
return 0;
|
||||
}
|
||||
@ -424,18 +477,22 @@ xrdp_sec_send_lic_initial(struct xrdp_sec* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_mcs_init(self->mcs_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8a(s, g_lic1, 322);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_mcs_send(self->mcs_layer, s, MCS_GLOBAL_CHANNEL) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -449,18 +506,22 @@ xrdp_sec_send_lic_response(struct xrdp_sec* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_mcs_init(self->mcs_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8a(s, g_lic2, 20);
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_mcs_send(self->mcs_layer, s, MCS_GLOBAL_CHANNEL) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -474,18 +535,22 @@ xrdp_sec_send_media_lic_response(struct xrdp_sec* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (xrdp_mcs_init(self->mcs_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8a(s, g_lic3, sizeof(g_lic3));
|
||||
s_mark_end(s);
|
||||
|
||||
if (xrdp_mcs_send(self->mcs_layer, s, MCS_GLOBAL_CHANNEL) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -510,6 +575,7 @@ xrdp_sec_hash_48(char* out, char* in, char* salt1, char* salt2, int salt)
|
||||
|
||||
sha1_info = ssl_sha1_info_create();
|
||||
md5_info = ssl_md5_info_create();
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
g_memset(pad, salt + i, 4);
|
||||
@ -525,6 +591,7 @@ xrdp_sec_hash_48(char* out, char* in, char* salt1, char* salt2, int salt)
|
||||
ssl_md5_complete(md5_info, md5_sig);
|
||||
g_memcpy(out + i * 16, md5_sig, 16);
|
||||
}
|
||||
|
||||
ssl_sha1_info_delete(sha1_info);
|
||||
ssl_md5_info_delete(md5_info);
|
||||
}
|
||||
@ -563,6 +630,7 @@ xrdp_sec_establish_keys(struct xrdp_sec* self)
|
||||
self->server_random);
|
||||
xrdp_sec_hash_16(self->decrypt_key, session_key + 32, self->client_random,
|
||||
self->server_random);
|
||||
|
||||
if (self->rc4_key_size == 1)
|
||||
{
|
||||
xrdp_sec_make_40bit(self->sign_key);
|
||||
@ -574,6 +642,7 @@ xrdp_sec_establish_keys(struct xrdp_sec* self)
|
||||
{
|
||||
self->rc4_key_len = 16;
|
||||
}
|
||||
|
||||
g_memcpy(self->decrypt_update_key, self->decrypt_key, 16);
|
||||
g_memcpy(self->encrypt_update_key, self->encrypt_key, 16);
|
||||
ssl_rc4_set_key(self->decrypt_rc4_info, self->decrypt_key, self->rc4_key_len);
|
||||
@ -589,18 +658,22 @@ xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan)
|
||||
int len;
|
||||
|
||||
DEBUG((" in xrdp_sec_recv"));
|
||||
|
||||
if (xrdp_mcs_recv(self->mcs_layer, s, chan) != 0)
|
||||
{
|
||||
DEBUG((" out xrdp_sec_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint32_le(s, flags);
|
||||
DEBUG((" in xrdp_sec_recv flags $%x", flags));
|
||||
|
||||
if (flags & SEC_ENCRYPT) /* 0x08 */
|
||||
{
|
||||
in_uint8s(s, 8); /* signature */
|
||||
xrdp_sec_decrypt(self, s->p, (int)(s->end - s->p));
|
||||
}
|
||||
|
||||
if (flags & SEC_CLIENT_RANDOM) /* 0x01 */
|
||||
{
|
||||
in_uint32_le(s, len);
|
||||
@ -612,6 +685,7 @@ xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan)
|
||||
DEBUG((" out xrdp_sec_recv"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (flags & SEC_LOGON_INFO) /* 0x40 */
|
||||
{
|
||||
if (xrdp_sec_process_logon_info(self, s) != 0)
|
||||
@ -619,6 +693,7 @@ xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan)
|
||||
DEBUG((" out xrdp_sec_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (self->rdp_layer->client_info.is_mce)
|
||||
{
|
||||
if (xrdp_sec_send_media_lic_response(self) != 0)
|
||||
@ -626,18 +701,22 @@ xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan)
|
||||
DEBUG((" out xrdp_sec_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_sec_recv"));
|
||||
return -1; /* special error that means send demand active */
|
||||
}
|
||||
|
||||
if (xrdp_sec_send_lic_initial(self) != 0)
|
||||
{
|
||||
DEBUG((" out xrdp_sec_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
*chan = 1; /* just set a non existing channel and exit */
|
||||
DEBUG((" out xrdp_sec_recv"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (flags & SEC_LICENCE_NEG) /* 0x80 */
|
||||
{
|
||||
if (xrdp_sec_send_lic_response(self) != 0)
|
||||
@ -645,9 +724,11 @@ xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan)
|
||||
DEBUG((" out xrdp_sec_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_sec_recv"));
|
||||
return -1; /* special error that means send demand active */
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_sec_recv"));
|
||||
return 0;
|
||||
}
|
||||
@ -703,6 +784,7 @@ xrdp_sec_send(struct xrdp_sec* self, struct stream* s, int chan)
|
||||
|
||||
DEBUG((" in xrdp_sec_send"));
|
||||
s_pop_layer(s, sec_hdr);
|
||||
|
||||
if (self->crypt_level > 1)
|
||||
{
|
||||
out_uint32_le(s, SEC_ENCRYPT);
|
||||
@ -714,10 +796,12 @@ xrdp_sec_send(struct xrdp_sec* self, struct stream* s, int chan)
|
||||
{
|
||||
out_uint32_le(s, 0);
|
||||
}
|
||||
|
||||
if (xrdp_mcs_send(self->mcs_layer, s, chan) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_sec_send"));
|
||||
return 0;
|
||||
}
|
||||
@ -733,13 +817,16 @@ xrdp_sec_process_mcs_data_channels(struct xrdp_sec* self, struct stream* s)
|
||||
struct mcs_channel_item *channel_item;
|
||||
|
||||
DEBUG(("processing channels, channel_code is %d", self->channel_code));
|
||||
|
||||
/* this is an option set in xrdp.ini */
|
||||
if (self->channel_code != 1) /* are channels on? */
|
||||
{
|
||||
g_writeln("Processing channel data from client - The channel is off");
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint32_le(s, num_channels);
|
||||
|
||||
for (index = 0; index < num_channels; index++)
|
||||
{
|
||||
channel_item = (struct mcs_channel_item *)
|
||||
@ -751,6 +838,7 @@ xrdp_sec_process_mcs_data_channels(struct xrdp_sec* self, struct stream* s)
|
||||
DEBUG(("got channel flags %8.8x name %s", channel_item->flags,
|
||||
channel_item->name));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -770,17 +858,20 @@ xrdp_sec_process_mcs_data(struct xrdp_sec* self)
|
||||
s->p = s->data;
|
||||
/* skip header */
|
||||
in_uint8s(s, 23);
|
||||
|
||||
while (s_check_rem(s, 4))
|
||||
{
|
||||
hold_p = s->p;
|
||||
in_uint16_le(s, tag);
|
||||
in_uint16_le(s, size);
|
||||
|
||||
if (size < 4 || !s_check_rem(s, size - 4))
|
||||
{
|
||||
g_writeln("error in xrdp_sec_process_mcs_data tag %d size %d",
|
||||
tag, size);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case SEC_TAG_CLI_INFO:
|
||||
@ -797,8 +888,10 @@ xrdp_sec_process_mcs_data(struct xrdp_sec* self)
|
||||
tag, size);
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = hold_p + size;
|
||||
}
|
||||
|
||||
/* set p to beginning */
|
||||
s->p = s->data;
|
||||
return 0;
|
||||
@ -847,6 +940,7 @@ xrdp_sec_out_mcs_data(struct xrdp_sec* self)
|
||||
out_uint16_le(s, 8 + (num_channels_even * 2)); /* len */
|
||||
out_uint16_le(s, MCS_GLOBAL_CHANNEL); /* 1003, 0x03eb main channel */
|
||||
out_uint16_le(s, num_channels); /* number of other channels */
|
||||
|
||||
for (index = 0; index < num_channels_even; index++)
|
||||
{
|
||||
if (index < num_channels)
|
||||
@ -859,6 +953,7 @@ xrdp_sec_out_mcs_data(struct xrdp_sec* self)
|
||||
out_uint16_le(s, 0);
|
||||
}
|
||||
}
|
||||
|
||||
out_uint16_le(s, SEC_TAG_SRV_CRYPT);
|
||||
out_uint16_le(s, 0x00ec); /* len is 236 */
|
||||
out_uint32_le(s, self->rc4_key_size); /* key len 1 = 40 bit 2 = 128 bit */
|
||||
@ -909,6 +1004,7 @@ xrdp_sec_in_mcs_data(struct xrdp_sec* self)
|
||||
g_memset(client_info->hostname, 0, 32);
|
||||
c = 1;
|
||||
index = 0;
|
||||
|
||||
while (index < 16 && c != 0)
|
||||
{
|
||||
in_uint8(s, c);
|
||||
@ -916,6 +1012,7 @@ xrdp_sec_in_mcs_data(struct xrdp_sec* self)
|
||||
client_info->hostname[index] = c;
|
||||
index++;
|
||||
}
|
||||
|
||||
/* get build */
|
||||
s->p = s->data;
|
||||
in_uint8s(s, 43);
|
||||
@ -947,6 +1044,7 @@ xrdp_sec_incoming(struct xrdp_sec* self)
|
||||
values = list_create();
|
||||
values->auto_free = 1;
|
||||
g_snprintf(key_file, 255, "%s/rsakeys.ini", XRDP_CFG_PATH);
|
||||
|
||||
if (file_by_name_read_section(key_file, "keys", items, values) != 0)
|
||||
{
|
||||
/* this is a show stopper */
|
||||
@ -955,10 +1053,12 @@ xrdp_sec_incoming(struct xrdp_sec* self)
|
||||
list_delete(values);
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (index = 0; index < items->count; index++)
|
||||
{
|
||||
item = (char *)list_get_item(items, index);
|
||||
value = (char *)list_get_item(values, index);
|
||||
|
||||
if (g_strcasecmp(item, "pub_exp") == 0)
|
||||
{
|
||||
hex_str_to_bin(value, self->pub_exp, 4);
|
||||
@ -976,12 +1076,15 @@ xrdp_sec_incoming(struct xrdp_sec* self)
|
||||
hex_str_to_bin(value, self->pri_exp, 64);
|
||||
}
|
||||
}
|
||||
|
||||
list_delete(items);
|
||||
list_delete(values);
|
||||
|
||||
if (xrdp_mcs_incoming(self->mcs_layer) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef XRDP_DEBUG
|
||||
g_writeln("client mcs data received");
|
||||
g_hexdump(self->client_mcs_data.data,
|
||||
|
@ -45,6 +45,7 @@ xrdp_surface_delete(struct xrdp_surface* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
s = (STREAM *)(self->s);
|
||||
rfx_context = (RFX_CONTEXT *)(self->rfx_context);
|
||||
free_stream(self->out_s);
|
||||
@ -100,6 +101,7 @@ xrdp_surface_send_surface_bits(struct xrdp_surface* self,int bpp, char* data,
|
||||
|
||||
s = (STREAM *)(self->s);
|
||||
rfx_context = (RFX_CONTEXT *)(self->rfx_context);
|
||||
|
||||
if ((bpp == 24) || (bpp == 32))
|
||||
{
|
||||
}
|
||||
@ -108,6 +110,7 @@ xrdp_surface_send_surface_bits(struct xrdp_surface* self,int bpp, char* data,
|
||||
g_writeln("bpp = %d is not supported\n", bpp);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Bpp = 4;
|
||||
|
||||
rect.x = 0;
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2004-2010
|
||||
|
||||
tcp layer
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004 - 2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* tcp layer
|
||||
*/
|
||||
|
||||
#include "libxrdp.h"
|
||||
@ -60,11 +58,13 @@ xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
|
||||
{
|
||||
DEBUG((" in xrdp_tcp_recv, gota get %d bytes", len));
|
||||
init_stream(s, len);
|
||||
|
||||
if (trans_force_read_s(self->trans, s, len) != 0)
|
||||
{
|
||||
DEBUG((" error in trans_force_read_s"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_tcp_recv"));
|
||||
return 0;
|
||||
}
|
||||
@ -77,11 +77,13 @@ xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
|
||||
int len;
|
||||
len = s->end - s->data;
|
||||
DEBUG((" in xrdp_tcp_send, gota send %d bytes", len));
|
||||
|
||||
if (trans_force_write_s(self->trans, s) != 0)
|
||||
{
|
||||
DEBUG((" error in trans_force_write_s"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out xrdp_tcp_send, sent %d bytes ok", len));
|
||||
return 0;
|
||||
}
|
||||
|
39
mc/mc.c
39
mc/mc.c
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2007-2010
|
||||
|
||||
media center
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* media center
|
||||
*/
|
||||
|
||||
#include "mc.h"
|
||||
@ -109,6 +107,7 @@ mod_exit(struct mod* mod)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_free(mod);
|
||||
return 0;
|
||||
}
|
||||
|
38
mc/mc.h
38
mc/mc.h
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2007-2010
|
||||
|
||||
media center
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* media center
|
||||
*/
|
||||
|
||||
/* include other h files */
|
||||
|
59
rdp/rdp.c
59
rdp/rdp.c
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp main file
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* librdp main file
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
@ -49,6 +47,7 @@ lib_mod_connect(struct mod* mod)
|
||||
mod->server_set_fgcolor(mod, 0);
|
||||
mod->server_fill_rect(mod, 0, 0, mod->width, mod->height);
|
||||
mod->server_end_update(mod);
|
||||
|
||||
/* connect */
|
||||
if (rdp_rdp_connect(mod->rdp_layer, mod->ip, mod->port) == 0)
|
||||
{
|
||||
@ -59,6 +58,7 @@ lib_mod_connect(struct mod* mod)
|
||||
DEBUG(("out lib_mod_connect"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEBUG(("out lib_mod_connect error"));
|
||||
return 1;
|
||||
}
|
||||
@ -75,9 +75,11 @@ lib_mod_event(struct mod* mod, int msg, long param1, long param2,
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEBUG(("in lib_mod_event"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192 * 2);
|
||||
|
||||
switch (msg)
|
||||
{
|
||||
case 15:
|
||||
@ -147,6 +149,7 @@ lib_mod_event(struct mod* mod, int msg, long param1, long param2,
|
||||
(param2 >> 16) & 0xffff, param2 & 0xffff);
|
||||
break;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG(("out lib_mod_event"));
|
||||
return 0;
|
||||
@ -162,22 +165,28 @@ lib_mod_signal(struct mod* mod)
|
||||
struct stream *s;
|
||||
|
||||
DEBUG(("in lib_mod_signal"));
|
||||
|
||||
if (mod->in_s == 0)
|
||||
{
|
||||
make_stream(mod->in_s);
|
||||
}
|
||||
|
||||
s = mod->in_s;
|
||||
init_stream(s, 8192 * 2);
|
||||
cont = 1;
|
||||
|
||||
while (cont)
|
||||
{
|
||||
type = 0;
|
||||
|
||||
if (rdp_rdp_recv(mod->rdp_layer, s, &type) != 0)
|
||||
{
|
||||
DEBUG(("out lib_mod_signal error rdp_rdp_recv failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG(("lib_mod_signal type %d", type));
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case RDP_PDU_DATA:
|
||||
@ -197,8 +206,10 @@ lib_mod_signal(struct mod* mod)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
cont = s->next_packet < s->end;
|
||||
}
|
||||
|
||||
DEBUG(("out lib_mod_signal"));
|
||||
return 0;
|
||||
}
|
||||
@ -212,16 +223,19 @@ lib_mod_end(struct mod* mod)
|
||||
mod->rdp_layer = 0;
|
||||
free_stream(mod->in_s);
|
||||
mod->in_s = 0;
|
||||
|
||||
if (mod->sck_obj != 0)
|
||||
{
|
||||
g_delete_wait_obj_from_socket(mod->sck_obj);
|
||||
mod->sck_obj = 0;
|
||||
}
|
||||
|
||||
if (mod->sck != 0)
|
||||
{
|
||||
g_tcp_close(mod->sck);
|
||||
mod->sck = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -254,6 +268,7 @@ lib_mod_set_param(struct mod* mod, char* name, char* value)
|
||||
{
|
||||
mod->keylayout = g_atoi(value);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -266,6 +281,7 @@ lib_mod_get_wait_objs(struct mod* mod, tbus* read_objs, int* rcount,
|
||||
int i;
|
||||
|
||||
i = *rcount;
|
||||
|
||||
if (mod != 0)
|
||||
{
|
||||
if (mod->sck_obj != 0)
|
||||
@ -273,6 +289,7 @@ lib_mod_get_wait_objs(struct mod* mod, tbus* read_objs, int* rcount,
|
||||
read_objs[i++] = mod->sck_obj;
|
||||
}
|
||||
}
|
||||
|
||||
*rcount = i;
|
||||
return 0;
|
||||
}
|
||||
@ -285,6 +302,7 @@ lib_mod_check_wait_objs(struct mod* mod)
|
||||
int rv;
|
||||
|
||||
rv = 0;
|
||||
|
||||
if (mod != 0)
|
||||
{
|
||||
if (mod->sck_obj != 0)
|
||||
@ -295,6 +313,7 @@ lib_mod_check_wait_objs(struct mod* mod)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
38
rdp/rdp.h
38
rdp/rdp.h
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp main header file
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* librdp main header file
|
||||
*/
|
||||
|
||||
/* include other h files */
|
||||
|
111
rdp/rdp_bitmap.c
111
rdp/rdp_bitmap.c
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp bitmap routines
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* librdp bitmap routines
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
@ -98,6 +96,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
fom_mask = 0;
|
||||
code = CVAL(input);
|
||||
opcode = code >> 4;
|
||||
|
||||
/* Handle different opcode forms */
|
||||
switch (opcode)
|
||||
{
|
||||
@ -110,6 +109,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
break;
|
||||
case 0xf:
|
||||
opcode = code & 0xf;
|
||||
|
||||
if (opcode < 9)
|
||||
{
|
||||
count = CVAL(input);
|
||||
@ -119,6 +119,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
count = (opcode < 0xb) ? 8 : 1;
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
break;
|
||||
default:
|
||||
@ -127,10 +128,12 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
offset = 32;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Handle strange cases for counts */
|
||||
if (offset != 0)
|
||||
{
|
||||
isfillormix = ((opcode == 2) || (opcode == 7));
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
if (isfillormix)
|
||||
@ -147,14 +150,17 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
count <<= 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read preliminary data */
|
||||
switch (opcode)
|
||||
{
|
||||
case 0: /* Fill */
|
||||
|
||||
if ((lastopcode == opcode) && !((x == width) && (prevline == 0)))
|
||||
{
|
||||
insertmix = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
case 8: /* Bicolor */
|
||||
color1 = CVAL(input);
|
||||
@ -177,8 +183,10 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
fom_mask = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
lastopcode = opcode;
|
||||
mixmask = 0;
|
||||
|
||||
/* Output body */
|
||||
while (count > 0)
|
||||
{
|
||||
@ -188,14 +196,17 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
height--;
|
||||
prevline = line;
|
||||
line = output + height * width;
|
||||
}
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case 0: /* Fill */
|
||||
|
||||
if (insertmix)
|
||||
{
|
||||
if (prevline == 0)
|
||||
@ -206,10 +217,12 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
line[x] = prevline[x] ^ mix;
|
||||
}
|
||||
|
||||
insertmix = 0;
|
||||
count--;
|
||||
x++;
|
||||
}
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT(line[x] = 0)
|
||||
@ -218,8 +231,10 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
REPEAT(line[x] = prevline[x])
|
||||
}
|
||||
|
||||
break;
|
||||
case 1: /* Mix */
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT(line[x] = mix)
|
||||
@ -228,13 +243,16 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
REPEAT(line[x] = prevline[x] ^ mix)
|
||||
}
|
||||
|
||||
break;
|
||||
case 2: /* Fill or Mix */
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
(
|
||||
MASK_UPDATE;
|
||||
|
||||
if (mask & mixmask)
|
||||
{
|
||||
line[x] = mix;
|
||||
@ -250,6 +268,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
REPEAT
|
||||
(
|
||||
MASK_UPDATE;
|
||||
|
||||
if (mask & mixmask)
|
||||
{
|
||||
line[x] = prevline[x] ^ mix;
|
||||
@ -260,6 +279,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 3: /* Color */
|
||||
REPEAT(line[x] = color2)
|
||||
@ -270,6 +290,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
case 8: /* Bicolor */
|
||||
REPEAT
|
||||
(
|
||||
|
||||
if (bicolor)
|
||||
{
|
||||
line[x] = color2;
|
||||
@ -295,6 +316,7 @@ bitmap_decompress1(char* output, int width, int height, char* input, int size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -344,6 +366,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
fom_mask = 0;
|
||||
code = CVAL(input);
|
||||
opcode = code >> 4;
|
||||
|
||||
/* Handle different opcode forms */
|
||||
switch (opcode)
|
||||
{
|
||||
@ -356,6 +379,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
break;
|
||||
case 0xf:
|
||||
opcode = code & 0xf;
|
||||
|
||||
if (opcode < 9)
|
||||
{
|
||||
count = CVAL(input);
|
||||
@ -365,6 +389,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
count = (opcode < 0xb) ? 8 : 1;
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
break;
|
||||
default:
|
||||
@ -373,10 +398,12 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
offset = 32;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Handle strange cases for counts */
|
||||
if (offset != 0)
|
||||
{
|
||||
isfillormix = ((opcode == 2) || (opcode == 7));
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
if (isfillormix)
|
||||
@ -393,14 +420,17 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
count <<= 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read preliminary data */
|
||||
switch (opcode)
|
||||
{
|
||||
case 0: /* Fill */
|
||||
|
||||
if ((lastopcode == opcode) && !((x == width) && (prevline == 0)))
|
||||
{
|
||||
insertmix = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
case 8: /* Bicolor */
|
||||
color1[EIK0] = CVAL(input);
|
||||
@ -426,8 +456,10 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
fom_mask = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
lastopcode = opcode;
|
||||
mixmask = 0;
|
||||
|
||||
/* Output body */
|
||||
while (count > 0)
|
||||
{
|
||||
@ -437,14 +469,17 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
height--;
|
||||
prevline = line;
|
||||
line = output + height * (width * 2);
|
||||
}
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case 0: /* Fill */
|
||||
|
||||
if (insertmix)
|
||||
{
|
||||
if (prevline == 0)
|
||||
@ -457,10 +492,12 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
line[x * 2 + 0] = prevline[x * 2 + 0] ^ mix[0];
|
||||
line[x * 2 + 1] = prevline[x * 2 + 1] ^ mix[1];
|
||||
}
|
||||
|
||||
insertmix = 0;
|
||||
count--;
|
||||
x++;
|
||||
}
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
@ -477,8 +514,10 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
line[x * 2 + 1] = prevline[x * 2 + 1];
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 1: /* Mix */
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
@ -495,13 +534,16 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
line[x * 2 + 1] = prevline[x * 2 + 1] ^ mix[1];
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 2: /* Fill or Mix */
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
(
|
||||
MASK_UPDATE;
|
||||
|
||||
if (mask & mixmask)
|
||||
{
|
||||
line[x * 2 + 0] = mix[0];
|
||||
@ -519,6 +561,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
REPEAT
|
||||
(
|
||||
MASK_UPDATE;
|
||||
|
||||
if (mask & mixmask)
|
||||
{
|
||||
line[x * 2 + 0] = prevline[x * 2 + 0] ^ mix[0];
|
||||
@ -531,6 +574,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 3: /* Color */
|
||||
REPEAT
|
||||
@ -549,6 +593,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
case 8: /* Bicolor */
|
||||
REPEAT
|
||||
(
|
||||
|
||||
if (bicolor)
|
||||
{
|
||||
line[x * 2 + 0] = color2[0];
|
||||
@ -584,6 +629,7 @@ bitmap_decompress2(char* output, int width, int height, char* input, int size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -636,6 +682,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
fom_mask = 0;
|
||||
code = CVAL(input);
|
||||
opcode = code >> 4;
|
||||
|
||||
/* Handle different opcode forms */
|
||||
switch (opcode)
|
||||
{
|
||||
@ -648,6 +695,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
break;
|
||||
case 0xf:
|
||||
opcode = code & 0xf;
|
||||
|
||||
if (opcode < 9)
|
||||
{
|
||||
count = CVAL(input);
|
||||
@ -657,6 +705,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
count = (opcode < 0xb) ? 8 : 1;
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
break;
|
||||
default:
|
||||
@ -665,10 +714,12 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
offset = 32;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Handle strange cases for counts */
|
||||
if (offset != 0)
|
||||
{
|
||||
isfillormix = ((opcode == 2) || (opcode == 7));
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
if (isfillormix)
|
||||
@ -685,14 +736,17 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
count <<= 3;
|
||||
}
|
||||
}
|
||||
|
||||
/* Read preliminary data */
|
||||
switch (opcode)
|
||||
{
|
||||
case 0: /* Fill */
|
||||
|
||||
if ((lastopcode == opcode) && !((x == width) && (prevline == 0)))
|
||||
{
|
||||
insertmix = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
case 8: /* Bicolor */
|
||||
color1[0] = CVAL(input);
|
||||
@ -721,8 +775,10 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
fom_mask = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
lastopcode = opcode;
|
||||
mixmask = 0;
|
||||
|
||||
/* Output body */
|
||||
while (count > 0)
|
||||
{
|
||||
@ -732,14 +788,17 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
x = 0;
|
||||
height--;
|
||||
prevline = line;
|
||||
line = output + height * (width * 3);
|
||||
}
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
case 0: /* Fill */
|
||||
|
||||
if (insertmix)
|
||||
{
|
||||
if (prevline == 0)
|
||||
@ -754,10 +813,12 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
line[x * 3 + 1] = prevline[x * 3 + 1] ^ mix[1];
|
||||
line[x * 3 + 2] = prevline[x * 3 + 2] ^ mix[2];
|
||||
}
|
||||
|
||||
insertmix = 0;
|
||||
count--;
|
||||
x++;
|
||||
}
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
@ -776,8 +837,10 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
line[x * 3 + 2] = prevline[x * 3 + 2];
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 1: /* Mix */
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
@ -796,13 +859,16 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
line[x * 3 + 2] = prevline[x * 3 + 2] ^ mix[2];
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 2: /* Fill or Mix */
|
||||
|
||||
if (prevline == 0)
|
||||
{
|
||||
REPEAT
|
||||
(
|
||||
MASK_UPDATE;
|
||||
|
||||
if (mask & mixmask)
|
||||
{
|
||||
line[x * 3 + 0] = mix[0];
|
||||
@ -822,6 +888,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
REPEAT
|
||||
(
|
||||
MASK_UPDATE;
|
||||
|
||||
if (mask & mixmask)
|
||||
{
|
||||
line[x * 3 + 0] = prevline[x * 3 + 0] ^ mix[0];
|
||||
@ -836,6 +903,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
break;
|
||||
case 3: /* Color */
|
||||
REPEAT
|
||||
@ -856,6 +924,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
case 8: /* Bicolor */
|
||||
REPEAT
|
||||
(
|
||||
|
||||
if (bicolor)
|
||||
{
|
||||
line[x * 3 + 0] = color2[0];
|
||||
@ -895,6 +964,7 @@ bitmap_decompress3(char* output, int width, int height, char* input, int size)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -921,5 +991,6 @@ rdp_bitmap_decompress(char* output, int width, int height, char* input,
|
||||
rv = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp iso layer
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* librdp iso layer
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
@ -42,6 +40,7 @@ rdp_iso_delete(struct rdp_iso* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rdp_tcp_delete(self->tcp_layer);
|
||||
g_free(self);
|
||||
}
|
||||
@ -55,26 +54,33 @@ rdp_iso_recv_msg(struct rdp_iso* self, struct stream* s, int* code)
|
||||
int len;
|
||||
|
||||
*code = 0;
|
||||
|
||||
if (rdp_tcp_recv(self->tcp_layer, s, 4) != 0)
|
||||
{
|
||||
DEBUG((" out rdp_iso_recv_msg error rdp_tcp_recv 1 failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, ver);
|
||||
|
||||
if (ver != 3)
|
||||
{
|
||||
DEBUG((" out rdp_iso_recv_msg error ver != 3"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 1);
|
||||
in_uint16_be(s, len);
|
||||
|
||||
if (rdp_tcp_recv(self->tcp_layer, s, len - 4) != 0)
|
||||
{
|
||||
DEBUG((" out rdp_iso_recv_msg error rdp_tcp_recv 2 failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 1);
|
||||
in_uint8(s, *code);
|
||||
|
||||
if (*code == ISO_PDU_DT)
|
||||
{
|
||||
in_uint8s(s, 1);
|
||||
@ -83,6 +89,7 @@ rdp_iso_recv_msg(struct rdp_iso* self, struct stream* s, int* code)
|
||||
{
|
||||
in_uint8s(s, 5);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -94,6 +101,7 @@ rdp_iso_send_msg(struct rdp_iso* self, struct stream* s, int code)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, 3);
|
||||
out_uint8(s, 0);
|
||||
out_uint16_be(s, 11); /* length */
|
||||
@ -103,10 +111,12 @@ rdp_iso_send_msg(struct rdp_iso* self, struct stream* s, int code)
|
||||
out_uint16_le(s, 0);
|
||||
out_uint8(s, 0);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_tcp_send(self->tcp_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -121,10 +131,12 @@ rdp_iso_recv(struct rdp_iso* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (code != ISO_PDU_DT)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -153,10 +165,12 @@ rdp_iso_send(struct rdp_iso* self, struct stream* s)
|
||||
out_uint8(s, 2);
|
||||
out_uint8(s, ISO_PDU_DT);
|
||||
out_uint8(s, 0x80);
|
||||
|
||||
if (rdp_tcp_send(self->tcp_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -171,12 +185,14 @@ rdp_iso_connect(struct rdp_iso* self, char* ip, char* port)
|
||||
DEBUG((" in rdp_iso_connect"));
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_tcp_connect(self->tcp_layer, ip, port) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG((" out rdp_iso_connect error rdp_tcp_connect failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (rdp_iso_send_msg(self, s, ISO_PDU_CR) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
@ -184,7 +200,9 @@ rdp_iso_connect(struct rdp_iso* self, char* ip, char* port)
|
||||
DEBUG((" out rdp_iso_connect error rdp_iso_send_msg failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_recv_msg(self, s, &code) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
@ -192,6 +210,7 @@ rdp_iso_connect(struct rdp_iso* self, char* ip, char* port)
|
||||
DEBUG((" out rdp_iso_connect error rdp_iso_recv_msg failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (code != ISO_PDU_CC)
|
||||
{
|
||||
free_stream(s);
|
||||
@ -199,6 +218,7 @@ rdp_iso_connect(struct rdp_iso* self, char* ip, char* port)
|
||||
DEBUG((" out rdp_iso_connect error code != ISO_PDU_CC"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG((" out rdp_iso_connect"));
|
||||
return 0;
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
licence
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* licence
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
@ -41,6 +39,7 @@ rdp_lic_delete(struct rdp_lic* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
@ -176,6 +175,7 @@ rdp_lic_process_demand(struct rdp_lic* self, struct stream* s)
|
||||
g_memset(null_data, 0, sizeof(null_data));
|
||||
rdp_lic_generate_keys(self, null_data, server_random, null_data);
|
||||
licence_size = 0; /* todo load_licence(&licence_data); */
|
||||
|
||||
if (licence_size > 0)
|
||||
{
|
||||
/* Generate a signature for the HWID buffer */
|
||||
@ -192,6 +192,7 @@ rdp_lic_process_demand(struct rdp_lic* self, struct stream* s)
|
||||
g_free(licence_data);
|
||||
return;
|
||||
}
|
||||
|
||||
rdp_lic_send_request(self, null_data, null_data,
|
||||
self->sec_layer->rdp_layer->mod->username,
|
||||
self->sec_layer->rdp_layer->mod->hostname);
|
||||
@ -238,11 +239,13 @@ rdp_lic_parse_authreq(struct rdp_lic* self, struct stream* s,
|
||||
|
||||
in_uint8s(s, 6); /* unknown: f8 3d 15 00 04 f6 */
|
||||
in_uint16_le(s, tokenlen);
|
||||
|
||||
if (tokenlen != LICENCE_TOKEN_SIZE)
|
||||
{
|
||||
/* error("token len %d\n", tokenlen); */
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint8p(s, *token, tokenlen);
|
||||
in_uint8p(s, *signature, LICENCE_SIGNATURE_SIZE);
|
||||
return s_check_end(s);
|
||||
@ -299,32 +302,39 @@ rdp_lic_process_issue(struct rdp_lic* self, struct stream* s)
|
||||
|
||||
in_uint8s(s, 2); /* 3d 45 - unknown */
|
||||
in_uint16_le(s, length);
|
||||
|
||||
if (!s_check_rem(s, length))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
crypt_key = ssl_rc4_info_create();
|
||||
ssl_rc4_set_key(crypt_key, self->licence_key, 16);
|
||||
ssl_rc4_crypt(crypt_key, s->p, length);
|
||||
ssl_rc4_info_delete(crypt_key);
|
||||
in_uint16_le(s, check);
|
||||
|
||||
if (check != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self->licence_issued = 1;
|
||||
in_uint8s(s, 2); /* pad */
|
||||
/* advance to fourth string */
|
||||
length = 0;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
in_uint8s(s, length);
|
||||
in_uint32_le(s, length);
|
||||
|
||||
if (!s_check_rem(s, length))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* todo save_licence(s->p, length); */
|
||||
}
|
||||
|
||||
@ -337,6 +347,7 @@ rdp_lic_process(struct rdp_lic* self, struct stream* s)
|
||||
|
||||
in_uint8(s, tag);
|
||||
in_uint8s(s, 3); /* version, length */
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case LICENCE_TAG_DEMAND:
|
||||
|
106
rdp/rdp_mcs.c
106
rdp/rdp_mcs.c
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp mcs layer
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* librdp mcs layer
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
@ -47,6 +45,7 @@ rdp_mcs_delete(struct rdp_mcs* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rdp_iso_delete(self->iso_layer);
|
||||
g_free(self);
|
||||
}
|
||||
@ -61,25 +60,31 @@ rdp_mcs_recv(struct rdp_mcs* self, struct stream* s, int* chan)
|
||||
int len;
|
||||
|
||||
DEBUG((" in rdp_mcs_recv"));
|
||||
|
||||
if (rdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
appid = opcode >> 2;
|
||||
|
||||
if (appid != MCS_SDIN)
|
||||
{
|
||||
DEBUG((" out rdp_mcs_recv error"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 2);
|
||||
in_uint16_be(s, *chan);
|
||||
in_uint8s(s, 1);
|
||||
in_uint8(s, len);
|
||||
|
||||
if (len & 0x80)
|
||||
{
|
||||
in_uint8s(s, 1);
|
||||
}
|
||||
|
||||
DEBUG((" out rdp_mcs_recv"));
|
||||
return 0;
|
||||
}
|
||||
@ -98,6 +103,7 @@ rdp_mcs_ber_out_header(struct rdp_mcs* self, struct stream* s,
|
||||
{
|
||||
out_uint8(s, tag_val);
|
||||
}
|
||||
|
||||
if (len >= 0x80)
|
||||
{
|
||||
out_uint8(s, 0x82);
|
||||
@ -107,6 +113,7 @@ rdp_mcs_ber_out_header(struct rdp_mcs* self, struct stream* s,
|
||||
{
|
||||
out_uint8(s, len);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -180,11 +187,13 @@ rdp_mcs_send_connection_initial(struct rdp_mcs* self)
|
||||
init_stream(s, 8192);
|
||||
data_len = self->client_mcs_data->end - self->client_mcs_data->data;
|
||||
len = 7 + 3 * 34 + 4 + data_len;
|
||||
|
||||
if (rdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_ber_out_header(self, s, MCS_CONNECT_INITIAL, len);
|
||||
rdp_mcs_ber_out_header(self, s, BER_TAG_OCTET_STRING, 0); /* calling domain */
|
||||
rdp_mcs_ber_out_header(self, s, BER_TAG_OCTET_STRING, 0); /* called domain */
|
||||
@ -196,11 +205,13 @@ rdp_mcs_send_connection_initial(struct rdp_mcs* self)
|
||||
rdp_mcs_ber_out_header(self, s, BER_TAG_OCTET_STRING, data_len);
|
||||
out_uint8p(s, self->client_mcs_data->data, data_len);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -223,15 +234,19 @@ rdp_mcs_ber_parse_header(struct rdp_mcs* self, struct stream* s,
|
||||
{
|
||||
in_uint8(s, tag);
|
||||
}
|
||||
|
||||
if (tag != tag_val)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, l);
|
||||
|
||||
if (l & 0x80)
|
||||
{
|
||||
l = l & ~0x80;
|
||||
*len = 0;
|
||||
|
||||
while (l > 0)
|
||||
{
|
||||
in_uint8(s, i);
|
||||
@ -243,6 +258,7 @@ rdp_mcs_ber_parse_header(struct rdp_mcs* self, struct stream* s,
|
||||
{
|
||||
*len = l;
|
||||
}
|
||||
|
||||
if (s_check(s))
|
||||
{
|
||||
return 0;
|
||||
@ -264,7 +280,9 @@ rdp_mcs_parse_domain_params(struct rdp_mcs* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, len);
|
||||
|
||||
if (s_check(s))
|
||||
{
|
||||
return 0;
|
||||
@ -286,30 +304,37 @@ rdp_mcs_recv_connection_response(struct rdp_mcs* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_ber_parse_header(self, s, MCS_CONNECT_RESPONSE, &len);
|
||||
rdp_mcs_ber_parse_header(self, s, BER_TAG_RESULT, &len);
|
||||
in_uint8(s, res);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_ber_parse_header(self, s, BER_TAG_INTEGER, &len);
|
||||
in_uint8s(s, len); /* connect id */
|
||||
rdp_mcs_parse_domain_params(self, s);
|
||||
rdp_mcs_ber_parse_header(self, s, BER_TAG_OCTET_STRING, &len);
|
||||
|
||||
if (len > self->server_mcs_data->size)
|
||||
{
|
||||
len = self->server_mcs_data->size;
|
||||
}
|
||||
|
||||
in_uint8a(s, self->server_mcs_data->data, len);
|
||||
self->server_mcs_data->p = self->server_mcs_data->data;
|
||||
self->server_mcs_data->end = self->server_mcs_data->data + len;
|
||||
|
||||
if (s_check_end(s))
|
||||
{
|
||||
free_stream(s);
|
||||
@ -331,20 +356,24 @@ rdp_mcs_send_edrq(struct rdp_mcs* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, (MCS_EDRQ << 2));
|
||||
out_uint16_be(s, 0x100); /* height */
|
||||
out_uint16_be(s, 0x100); /* interval */
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -358,18 +387,22 @@ rdp_mcs_send_aurq(struct rdp_mcs* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, (MCS_AURQ << 2));
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -385,32 +418,40 @@ rdp_mcs_recv_aucf(struct rdp_mcs* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
|
||||
if ((opcode >> 2) != MCS_AUCF)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, res);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (opcode & 2)
|
||||
{
|
||||
in_uint16_be(s, self->userid);
|
||||
}
|
||||
|
||||
if (!(s_check_end(s)))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -424,20 +465,24 @@ rdp_mcs_send_cjrq(struct rdp_mcs* self, int chanid)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_init(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint8(s, (MCS_CJRQ << 2));
|
||||
out_uint16_be(s, self->userid);
|
||||
out_uint16_be(s, chanid);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -453,33 +498,42 @@ rdp_mcs_recv_cjcf(struct rdp_mcs* self)
|
||||
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
|
||||
if (rdp_iso_recv(self->iso_layer, s) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, opcode);
|
||||
|
||||
if ((opcode >> 2) != MCS_CJCF)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8(s, res);
|
||||
|
||||
if (res != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 4); /* mcs_userid, req_chanid */
|
||||
|
||||
if (opcode & 2)
|
||||
{
|
||||
in_uint8s(s, 2); /* join_chanid */
|
||||
}
|
||||
|
||||
if (!(s_check_end(s)))
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -490,12 +544,15 @@ int APP_CC
|
||||
rdp_mcs_connect(struct rdp_mcs *self, char *ip, char *port)
|
||||
{
|
||||
DEBUG((" in rdp_mcs_connect"));
|
||||
|
||||
if (rdp_iso_connect(self->iso_layer, ip, port) != 0)
|
||||
{
|
||||
DEBUG((" out rdp_mcs_connect error rdp_iso_connect failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_send_connection_initial(self);
|
||||
|
||||
if (rdp_mcs_recv_connection_response(self) != 0)
|
||||
{
|
||||
rdp_iso_disconnect(self->iso_layer);
|
||||
@ -503,28 +560,35 @@ rdp_mcs_connect(struct rdp_mcs* self, char* ip, char* port)
|
||||
failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_send_edrq(self);
|
||||
rdp_mcs_send_aurq(self);
|
||||
|
||||
if (rdp_mcs_recv_aucf(self) != 0)
|
||||
{
|
||||
rdp_iso_disconnect(self->iso_layer);
|
||||
DEBUG((" out rdp_mcs_connect error rdp_mcs_recv_aucf failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_send_cjrq(self, self->userid + 1001);
|
||||
|
||||
if (rdp_mcs_recv_cjcf(self) != 0)
|
||||
{
|
||||
rdp_iso_disconnect(self->iso_layer);
|
||||
DEBUG((" out rdp_mcs_connect error rdp_mcs_recv_cjcf 1 failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_mcs_send_cjrq(self, MCS_GLOBAL_CHANNEL);
|
||||
|
||||
if (rdp_mcs_recv_cjcf(self) != 0)
|
||||
{
|
||||
rdp_iso_disconnect(self->iso_layer);
|
||||
DEBUG((" out rdp_mcs_connect error rdp_mcs_recv_cjcf 2 failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out rdp_mcs_connect"));
|
||||
return 0;
|
||||
}
|
||||
@ -554,9 +618,11 @@ rdp_mcs_send(struct rdp_mcs* self, struct stream* s)
|
||||
out_uint16_be(s, MCS_GLOBAL_CHANNEL);
|
||||
out_uint8(s, 0x70);
|
||||
out_uint16_be(s, len);
|
||||
|
||||
if (rdp_iso_send(self->iso_layer, s) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
200
rdp/rdp_orders.c
200
rdp/rdp_orders.c
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp orders
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* ibrdp orders
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
@ -48,11 +46,13 @@ rdp_orders_delete(struct rdp_orders* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* free the colormap cache */
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
g_free(self->cache_colormap[i]);
|
||||
}
|
||||
|
||||
/* free the bitmap cache */
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
@ -62,9 +62,11 @@ rdp_orders_delete(struct rdp_orders* self)
|
||||
{
|
||||
g_free(self->cache_bitmap[i][j]->data);
|
||||
}
|
||||
|
||||
g_free(self->cache_bitmap[i][j]);
|
||||
}
|
||||
}
|
||||
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
@ -88,6 +90,7 @@ rdp_orders_in_present(struct stream* s, int* present,
|
||||
{
|
||||
size--;
|
||||
}
|
||||
|
||||
if (flags & RDP_ORDER_TINY)
|
||||
{
|
||||
if (size < 2)
|
||||
@ -99,7 +102,9 @@ rdp_orders_in_present(struct stream* s, int* present,
|
||||
size -= 2;
|
||||
}
|
||||
}
|
||||
|
||||
*present = 0;
|
||||
|
||||
for (i = 0; i < size; i++)
|
||||
{
|
||||
in_uint8(s, bits);
|
||||
@ -133,6 +138,7 @@ rdp_orders_parse_bounds(struct rdp_orders* self, struct stream* s)
|
||||
int present = 0;
|
||||
|
||||
in_uint8(s, present);
|
||||
|
||||
if (present & 1)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.clip_left, 0);
|
||||
@ -141,6 +147,7 @@ rdp_orders_parse_bounds(struct rdp_orders* self, struct stream* s)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.clip_left, 1);
|
||||
}
|
||||
|
||||
if (present & 2)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.clip_top, 0);
|
||||
@ -149,6 +156,7 @@ rdp_orders_parse_bounds(struct rdp_orders* self, struct stream* s)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.clip_top, 1);
|
||||
}
|
||||
|
||||
if (present & 4)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.clip_right, 0);
|
||||
@ -157,6 +165,7 @@ rdp_orders_parse_bounds(struct rdp_orders* self, struct stream* s)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.clip_right, 1);
|
||||
}
|
||||
|
||||
if (present & 8)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.clip_bottom, 0);
|
||||
@ -181,12 +190,15 @@ rdp_orders_process_colcache(struct rdp_orders* self, struct stream* s,
|
||||
colormap = (struct rdp_colormap *)g_malloc(sizeof(struct rdp_colormap), 1);
|
||||
in_uint8(s, cache_id);
|
||||
in_uint16_le(s, colormap->ncolors);
|
||||
|
||||
for (i = 0; i < colormap->ncolors; i++)
|
||||
{
|
||||
in_uint32_le(s, colormap->colors[i]);
|
||||
}
|
||||
|
||||
g_free(self->cache_colormap[cache_id]);
|
||||
self->cache_colormap[cache_id] = colormap;
|
||||
|
||||
if (self->rdp_layer->rec_mode)
|
||||
{
|
||||
rdp_rec_check_file(self->rdp_layer);
|
||||
@ -195,10 +207,12 @@ rdp_orders_process_colcache(struct rdp_orders* self, struct stream* s,
|
||||
s_push_layer(rec_s, iso_hdr, 4);
|
||||
out_uint8(rec_s, 10);
|
||||
out_uint8(rec_s, cache_id);
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
out_uint32_le(rec_s, colormap->colors[i]);
|
||||
}
|
||||
|
||||
rdp_rec_write_item(self->rdp_layer, rec_s);
|
||||
free_stream(rec_s);
|
||||
}
|
||||
@ -233,9 +247,11 @@ rdp_orders_process_raw_bmpcache(struct rdp_orders* self, struct stream* s,
|
||||
in_uint16_le(s, bufsize);
|
||||
in_uint16_le(s, cache_idx);
|
||||
inverted = (char *)g_malloc(width * height * Bpp, 0);
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
dst = inverted + (((height - y) - 1) * (width * Bpp));
|
||||
|
||||
if (Bpp == 1)
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
@ -260,17 +276,21 @@ rdp_orders_process_raw_bmpcache(struct rdp_orders* self, struct stream* s,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bitmap = (struct rdp_bitmap *)g_malloc(sizeof(struct rdp_bitmap), 0);
|
||||
bitmap->width = width;
|
||||
bitmap->height = height;
|
||||
bitmap->bpp = bpp;
|
||||
bitmap->data = inverted;
|
||||
|
||||
if (self->cache_bitmap[cache_id][cache_idx] != 0)
|
||||
{
|
||||
g_free(self->cache_bitmap[cache_id][cache_idx]->data);
|
||||
}
|
||||
|
||||
g_free(self->cache_bitmap[cache_id][cache_idx]);
|
||||
self->cache_bitmap[cache_id][cache_idx] = bitmap;
|
||||
|
||||
if (self->rdp_layer->rec_mode)
|
||||
{
|
||||
y = width * height * Bpp;
|
||||
@ -321,6 +341,7 @@ rdp_orders_process_bmpcache(struct rdp_orders* self, struct stream* s,
|
||||
Bpp = (bpp + 7) / 8;
|
||||
in_uint16_le(s, bufsize);
|
||||
in_uint16_le(s, cache_idx);
|
||||
|
||||
if (flags & 1024)
|
||||
{
|
||||
size = bufsize;
|
||||
@ -332,8 +353,10 @@ rdp_orders_process_bmpcache(struct rdp_orders* self, struct stream* s,
|
||||
in_uint16_le(s, row_size);
|
||||
in_uint16_le(s, final_size);
|
||||
}
|
||||
|
||||
in_uint8p(s, data, size);
|
||||
bmpdata = (char *)g_malloc(width * height * Bpp, 0);
|
||||
|
||||
if (rdp_bitmap_decompress(bmpdata, width, height, data, size, Bpp))
|
||||
{
|
||||
}
|
||||
@ -341,17 +364,21 @@ rdp_orders_process_bmpcache(struct rdp_orders* self, struct stream* s,
|
||||
{
|
||||
/* error */
|
||||
}
|
||||
|
||||
bitmap = (struct rdp_bitmap *)g_malloc(sizeof(struct rdp_bitmap), 0);
|
||||
bitmap->width = width;
|
||||
bitmap->height = height;
|
||||
bitmap->bpp = bpp;
|
||||
bitmap->data = bmpdata;
|
||||
|
||||
if (self->cache_bitmap[cache_id][cache_idx] != 0)
|
||||
{
|
||||
g_free(self->cache_bitmap[cache_id][cache_idx]->data);
|
||||
}
|
||||
|
||||
g_free(self->cache_bitmap[cache_id][cache_idx]);
|
||||
self->cache_bitmap[cache_id][cache_idx] = bitmap;
|
||||
|
||||
if (self->rdp_layer->rec_mode)
|
||||
{
|
||||
size = width * height * Bpp;
|
||||
@ -391,6 +418,7 @@ rdp_orders_process_fontcache(struct rdp_orders* self, struct stream* s,
|
||||
|
||||
in_uint8(s, font);
|
||||
in_uint8(s, nglyphs);
|
||||
|
||||
for (i = 0; i < nglyphs; i++)
|
||||
{
|
||||
in_uint16_le(s, character);
|
||||
@ -403,6 +431,7 @@ rdp_orders_process_fontcache(struct rdp_orders* self, struct stream* s,
|
||||
self->rdp_layer->mod->server_add_char(self->rdp_layer->mod, font,
|
||||
character, offset, baseline,
|
||||
width, height, data);
|
||||
|
||||
if (self->rdp_layer->rec_mode)
|
||||
{
|
||||
rdp_rec_check_file(self->rdp_layer);
|
||||
@ -438,6 +467,7 @@ rdp_orders_process_secondary_order(struct rdp_orders* self, struct stream* s)
|
||||
in_uint16_le(s, flags);
|
||||
in_uint8(s, type);
|
||||
next_order = s->p + length + 7;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case RDP_ORDER_COLCACHE:
|
||||
@ -456,6 +486,7 @@ rdp_orders_process_secondary_order(struct rdp_orders* self, struct stream* s)
|
||||
/* error, unknown order */
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = next_order;
|
||||
return 0;
|
||||
}
|
||||
@ -484,18 +515,22 @@ rdp_orders_parse_brush(struct stream* s, struct rdp_brush* brush, int present)
|
||||
{
|
||||
in_uint8(s, brush->xorigin);
|
||||
}
|
||||
|
||||
if (present & 2)
|
||||
{
|
||||
in_uint8(s, brush->yorigin);
|
||||
}
|
||||
|
||||
if (present & 4)
|
||||
{
|
||||
in_uint8(s, brush->style);
|
||||
}
|
||||
|
||||
if (present & 8)
|
||||
{
|
||||
in_uint8(s, brush->pattern[0]);
|
||||
}
|
||||
|
||||
if (present & 16)
|
||||
{
|
||||
in_uint8a(s, brush->pattern + 1, 7);
|
||||
@ -511,10 +546,12 @@ rdp_orders_parse_pen(struct stream* s, struct rdp_pen* pen, int present)
|
||||
{
|
||||
in_uint8(s, pen->style);
|
||||
}
|
||||
|
||||
if (present & 2)
|
||||
{
|
||||
in_uint8(s, pen->width);
|
||||
}
|
||||
|
||||
if (present & 4)
|
||||
{
|
||||
rdp_orders_in_color(s, &pen->color);
|
||||
@ -535,72 +572,90 @@ rdp_orders_process_text2(struct rdp_orders* self, struct stream* s,
|
||||
{
|
||||
in_uint8(s, self->state.text_font);
|
||||
}
|
||||
|
||||
if (present & 0x000002)
|
||||
{
|
||||
in_uint8(s, self->state.text_flags);
|
||||
}
|
||||
|
||||
if (present & 0x000004)
|
||||
{
|
||||
in_uint8(s, self->state.text_opcode);
|
||||
}
|
||||
|
||||
if (present & 0x000008)
|
||||
{
|
||||
in_uint8(s, self->state.text_mixmode);
|
||||
}
|
||||
|
||||
if (present & 0x000010)
|
||||
{
|
||||
rdp_orders_in_color(s, &self->state.text_fgcolor);
|
||||
}
|
||||
|
||||
if (present & 0x000020)
|
||||
{
|
||||
rdp_orders_in_color(s, &self->state.text_bgcolor);
|
||||
}
|
||||
|
||||
if (present & 0x000040)
|
||||
{
|
||||
in_sint16_le(s, self->state.text_clipleft);
|
||||
}
|
||||
|
||||
if (present & 0x000080)
|
||||
{
|
||||
in_sint16_le(s, self->state.text_cliptop);
|
||||
}
|
||||
|
||||
if (present & 0x000100)
|
||||
{
|
||||
in_sint16_le(s, self->state.text_clipright);
|
||||
}
|
||||
|
||||
if (present & 0x000200)
|
||||
{
|
||||
in_sint16_le(s, self->state.text_clipbottom);
|
||||
}
|
||||
|
||||
if (present & 0x000400)
|
||||
{
|
||||
in_sint16_le(s, self->state.text_boxleft);
|
||||
}
|
||||
|
||||
if (present & 0x000800)
|
||||
{
|
||||
in_sint16_le(s, self->state.text_boxtop);
|
||||
}
|
||||
|
||||
if (present & 0x001000)
|
||||
{
|
||||
in_sint16_le(s, self->state.text_boxright);
|
||||
}
|
||||
|
||||
if (present & 0x002000)
|
||||
{
|
||||
in_sint16_le(s, self->state.text_boxbottom);
|
||||
}
|
||||
|
||||
rdp_orders_parse_brush(s, &self->state.text_brush, present >> 14);
|
||||
|
||||
if (present & 0x080000)
|
||||
{
|
||||
in_sint16_le(s, self->state.text_x);
|
||||
}
|
||||
|
||||
if (present & 0x100000)
|
||||
{
|
||||
in_sint16_le(s, self->state.text_y);
|
||||
}
|
||||
|
||||
if (present & 0x200000)
|
||||
{
|
||||
in_uint8(s, self->state.text_length);
|
||||
in_uint8a(s, self->state.text_text, self->state.text_length);
|
||||
}
|
||||
|
||||
self->rdp_layer->mod->server_set_opcode(self->rdp_layer->mod,
|
||||
self->state.text_opcode);
|
||||
fgcolor = rdp_orders_convert_color(self->rdp_layer->mod->rdp_bpp,
|
||||
@ -630,6 +685,7 @@ rdp_orders_process_text2(struct rdp_orders* self, struct stream* s,
|
||||
self->state.text_text,
|
||||
self->state.text_length);
|
||||
self->rdp_layer->mod->server_set_opcode(self->rdp_layer->mod, 0xcc);
|
||||
|
||||
if (self->rdp_layer->rec_mode)
|
||||
{
|
||||
rdp_rec_check_file(self->rdp_layer);
|
||||
@ -672,22 +728,27 @@ rdp_orders_process_destblt(struct rdp_orders* self, struct stream* s,
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.dest_x, delta);
|
||||
}
|
||||
|
||||
if (present & 0x02)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.dest_y, delta);
|
||||
}
|
||||
|
||||
if (present & 0x04)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.dest_cx, delta);
|
||||
}
|
||||
|
||||
if (present & 0x08)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.dest_cy, delta);
|
||||
}
|
||||
|
||||
if (present & 0x10)
|
||||
{
|
||||
in_uint8(s, self->state.dest_opcode);
|
||||
}
|
||||
|
||||
self->rdp_layer->mod->server_set_opcode(self->rdp_layer->mod,
|
||||
self->state.dest_opcode);
|
||||
self->rdp_layer->mod->server_fill_rect(self->rdp_layer->mod,
|
||||
@ -696,6 +757,7 @@ rdp_orders_process_destblt(struct rdp_orders* self, struct stream* s,
|
||||
self->state.dest_cx,
|
||||
self->state.dest_cy);
|
||||
self->rdp_layer->mod->server_set_opcode(self->rdp_layer->mod, 0xcc);
|
||||
|
||||
if (self->rdp_layer->rec_mode)
|
||||
{
|
||||
rdp_rec_check_file(self->rdp_layer);
|
||||
@ -727,30 +789,37 @@ rdp_orders_process_patblt(struct rdp_orders* self, struct stream* s,
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.pat_x, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0002)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.pat_y, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0004)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.pat_cx, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0008)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.pat_cy, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0010)
|
||||
{
|
||||
in_uint8(s, self->state.pat_opcode);
|
||||
}
|
||||
|
||||
if (present & 0x0020)
|
||||
{
|
||||
rdp_orders_in_color(s, &self->state.pat_bgcolor);
|
||||
}
|
||||
|
||||
if (present & 0x0040)
|
||||
{
|
||||
rdp_orders_in_color(s, &self->state.pat_fgcolor);
|
||||
}
|
||||
|
||||
rdp_orders_parse_brush(s, &self->state.pat_brush, present >> 7);
|
||||
self->rdp_layer->mod->server_set_opcode(self->rdp_layer->mod,
|
||||
self->state.pat_opcode);
|
||||
@ -777,6 +846,7 @@ rdp_orders_process_patblt(struct rdp_orders* self, struct stream* s,
|
||||
self->state.pat_cy);
|
||||
self->rdp_layer->mod->server_set_opcode(self->rdp_layer->mod, 0xcc);
|
||||
self->rdp_layer->mod->server_set_mixmode(self->rdp_layer->mod, 0);
|
||||
|
||||
if (self->rdp_layer->rec_mode)
|
||||
{
|
||||
rdp_rec_check_file(self->rdp_layer);
|
||||
@ -812,30 +882,37 @@ rdp_orders_process_screenblt(struct rdp_orders* self, struct stream* s,
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.screenblt_x, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0002)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.screenblt_y, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0004)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.screenblt_cx, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0008)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.screenblt_cy, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0010)
|
||||
{
|
||||
in_uint8(s, self->state.screenblt_opcode);
|
||||
}
|
||||
|
||||
if (present & 0x0020)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.screenblt_srcx, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0040)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.screenblt_srcy, delta);
|
||||
}
|
||||
|
||||
self->rdp_layer->mod->server_set_opcode(self->rdp_layer->mod,
|
||||
self->state.screenblt_opcode);
|
||||
self->rdp_layer->mod->server_screen_blt(self->rdp_layer->mod,
|
||||
@ -846,6 +923,7 @@ rdp_orders_process_screenblt(struct rdp_orders* self, struct stream* s,
|
||||
self->state.screenblt_srcx,
|
||||
self->state.screenblt_srcy);
|
||||
self->rdp_layer->mod->server_set_opcode(self->rdp_layer->mod, 0xcc);
|
||||
|
||||
if (self->rdp_layer->rec_mode)
|
||||
{
|
||||
rdp_rec_check_file(self->rdp_layer);
|
||||
@ -879,30 +957,37 @@ rdp_orders_process_line(struct rdp_orders* self, struct stream* s,
|
||||
{
|
||||
in_uint16_le(s, self->state.line_mixmode);
|
||||
}
|
||||
|
||||
if (present & 0x0002)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.line_startx, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0004)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.line_starty, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0008)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.line_endx, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0010)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.line_endy, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0020)
|
||||
{
|
||||
rdp_orders_in_color(s, &self->state.line_bgcolor);
|
||||
}
|
||||
|
||||
if (present & 0x0040)
|
||||
{
|
||||
in_uint8(s, self->state.line_opcode);
|
||||
}
|
||||
|
||||
rdp_orders_parse_pen(s, &self->state.line_pen, present >> 7);
|
||||
self->rdp_layer->mod->server_set_opcode(self->rdp_layer->mod,
|
||||
self->state.line_opcode);
|
||||
@ -925,6 +1010,7 @@ rdp_orders_process_line(struct rdp_orders* self, struct stream* s,
|
||||
self->state.line_endx,
|
||||
self->state.line_endy);
|
||||
self->rdp_layer->mod->server_set_opcode(self->rdp_layer->mod, 0xcc);
|
||||
|
||||
if (self->rdp_layer->rec_mode)
|
||||
{
|
||||
rdp_rec_check_file(self->rdp_layer);
|
||||
@ -961,33 +1047,40 @@ rdp_orders_process_rect(struct rdp_orders* self, struct stream* s,
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.rect_x, delta);
|
||||
}
|
||||
|
||||
if (present & 0x02)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.rect_y, delta);
|
||||
}
|
||||
|
||||
if (present & 0x04)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.rect_cx, delta);
|
||||
}
|
||||
|
||||
if (present & 0x08)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.rect_cy, delta);
|
||||
}
|
||||
|
||||
if (present & 0x10)
|
||||
{
|
||||
in_uint8(s, i);
|
||||
self->state.rect_color = (self->state.rect_color & 0xffffff00) | i;
|
||||
}
|
||||
|
||||
if (present & 0x20)
|
||||
{
|
||||
in_uint8(s, i);
|
||||
self->state.rect_color = (self->state.rect_color & 0xffff00ff) | (i << 8);
|
||||
}
|
||||
|
||||
if (present & 0x40)
|
||||
{
|
||||
in_uint8(s, i);
|
||||
self->state.rect_color = (self->state.rect_color & 0xff00ffff) | (i << 16);
|
||||
}
|
||||
|
||||
fgcolor = rdp_orders_convert_color(self->rdp_layer->mod->rdp_bpp,
|
||||
self->rdp_layer->mod->xrdp_bpp,
|
||||
self->state.rect_color,
|
||||
@ -998,6 +1091,7 @@ rdp_orders_process_rect(struct rdp_orders* self, struct stream* s,
|
||||
self->state.rect_y,
|
||||
self->state.rect_cx,
|
||||
self->state.rect_cy);
|
||||
|
||||
if (self->rdp_layer->rec_mode)
|
||||
{
|
||||
rdp_rec_check_file(self->rdp_layer);
|
||||
@ -1028,26 +1122,32 @@ rdp_orders_process_desksave(struct rdp_orders* self, struct stream* s,
|
||||
{
|
||||
in_uint32_le(s, self->state.desksave_offset);
|
||||
}
|
||||
|
||||
if (present & 0x02)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.desksave_left, delta);
|
||||
}
|
||||
|
||||
if (present & 0x04)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.desksave_top, delta);
|
||||
}
|
||||
|
||||
if (present & 0x08)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.desksave_right, delta);
|
||||
}
|
||||
|
||||
if (present & 0x10)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.desksave_bottom, delta);
|
||||
}
|
||||
|
||||
if (present & 0x20)
|
||||
{
|
||||
in_uint8(s, self->state.desksave_action);
|
||||
}
|
||||
|
||||
// width = (self->state.desksave_right - self->state.desksave_left) + 1;
|
||||
// height = (self->state.desksave_bottom - self->state.desksave_top) + 1;
|
||||
if (self->state.desksave_action == 0)
|
||||
@ -1075,40 +1175,50 @@ rdp_orders_process_memblt(struct rdp_orders* self, struct stream* s,
|
||||
in_uint8(s, self->state.memblt_cache_id);
|
||||
in_uint8(s, self->state.memblt_color_table);
|
||||
}
|
||||
|
||||
if (present & 0x0002)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.memblt_x, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0004)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.memblt_y, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0008)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.memblt_cx, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0010)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.memblt_cy, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0020)
|
||||
{
|
||||
in_uint8(s, self->state.memblt_opcode);
|
||||
}
|
||||
|
||||
if (present & 0x0040)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.memblt_srcx, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0080)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.memblt_srcy, delta);
|
||||
}
|
||||
|
||||
if (present & 0x0100)
|
||||
{
|
||||
in_uint16_le(s, self->state.memblt_cache_idx);
|
||||
}
|
||||
|
||||
bitmap = self->cache_bitmap[self->state.memblt_cache_id]
|
||||
[self->state.memblt_cache_idx];
|
||||
|
||||
if (bitmap != 0)
|
||||
{
|
||||
self->rdp_layer->mod->server_set_opcode(self->rdp_layer->mod,
|
||||
@ -1130,6 +1240,7 @@ rdp_orders_process_memblt(struct rdp_orders* self, struct stream* s,
|
||||
self->state.memblt_srcx,
|
||||
self->state.memblt_srcy);
|
||||
self->rdp_layer->mod->server_set_opcode(self->rdp_layer->mod, 0xcc);
|
||||
|
||||
if (self->rdp_layer->rec_mode)
|
||||
{
|
||||
rdp_rec_check_file(self->rdp_layer);
|
||||
@ -1149,6 +1260,7 @@ rdp_orders_process_memblt(struct rdp_orders* self, struct stream* s,
|
||||
rdp_rec_write_item(self->rdp_layer, rec_s);
|
||||
free_stream(rec_s);
|
||||
}
|
||||
|
||||
if (bmpdata != bitmap->data)
|
||||
{
|
||||
g_free(bmpdata);
|
||||
@ -1175,27 +1287,33 @@ rdp_orders_process_polyline(struct rdp_orders* self, struct stream* s,
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.polyline_x, delta);
|
||||
}
|
||||
|
||||
if (present & 0x02)
|
||||
{
|
||||
rdp_orders_in_coord(s, &self->state.polyline_y, delta);
|
||||
}
|
||||
|
||||
if (present & 0x04)
|
||||
{
|
||||
in_uint8(s, self->state.polyline_opcode);
|
||||
}
|
||||
|
||||
if (present & 0x10)
|
||||
{
|
||||
rdp_orders_in_color(s, &self->state.polyline_fgcolor);
|
||||
}
|
||||
|
||||
if (present & 0x20)
|
||||
{
|
||||
in_uint8(s, self->state.polyline_lines);
|
||||
}
|
||||
|
||||
if (present & 0x40)
|
||||
{
|
||||
in_uint8(s, self->state.polyline_datasize);
|
||||
in_uint8a(s, self->state.polyline_data, self->state.polyline_datasize);
|
||||
}
|
||||
|
||||
/* todo */
|
||||
}
|
||||
|
||||
@ -1211,14 +1329,17 @@ rdp_orders_process_orders(struct rdp_orders* self, struct stream* s,
|
||||
int delta = 0;
|
||||
|
||||
processed = 0;
|
||||
|
||||
while (processed < num_orders)
|
||||
{
|
||||
in_uint8(s, order_flags);
|
||||
|
||||
if (!(order_flags & RDP_ORDER_STANDARD))
|
||||
{
|
||||
/* error, this should always be set */
|
||||
break;
|
||||
}
|
||||
|
||||
if (order_flags & RDP_ORDER_SECONDARY)
|
||||
{
|
||||
rdp_orders_process_secondary_order(self, s);
|
||||
@ -1229,6 +1350,7 @@ rdp_orders_process_orders(struct rdp_orders* self, struct stream* s,
|
||||
{
|
||||
in_uint8(s, self->state.order_type);
|
||||
}
|
||||
|
||||
switch (self->state.order_type)
|
||||
{
|
||||
case RDP_ORDER_TRIBLT:
|
||||
@ -1244,20 +1366,25 @@ rdp_orders_process_orders(struct rdp_orders* self, struct stream* s,
|
||||
size = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
rdp_orders_in_present(s, &present, order_flags, size);
|
||||
|
||||
if (order_flags & RDP_ORDER_BOUNDS)
|
||||
{
|
||||
if (!(order_flags & RDP_ORDER_LASTBOUNDS))
|
||||
{
|
||||
rdp_orders_parse_bounds(self, s);
|
||||
}
|
||||
|
||||
self->rdp_layer->mod->server_set_clip(self->rdp_layer->mod,
|
||||
self->state.clip_left,
|
||||
self->state.clip_top,
|
||||
(self->state.clip_right - self->state.clip_left) + 1,
|
||||
(self->state.clip_bottom - self->state.clip_top) + 1);
|
||||
}
|
||||
|
||||
delta = order_flags & RDP_ORDER_DELTA;
|
||||
|
||||
switch (self->state.order_type)
|
||||
{
|
||||
case RDP_ORDER_TEXT2:
|
||||
@ -1294,13 +1421,16 @@ rdp_orders_process_orders(struct rdp_orders* self, struct stream* s,
|
||||
/* error unknown order */
|
||||
break;
|
||||
}
|
||||
|
||||
if (order_flags & RDP_ORDER_BOUNDS)
|
||||
{
|
||||
self->rdp_layer->mod->server_reset_clip(self->rdp_layer->mod);
|
||||
}
|
||||
}
|
||||
|
||||
processed++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1327,6 +1457,7 @@ rdp_orders_convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
out = (char *)g_malloc(width * height, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -1340,13 +1471,16 @@ rdp_orders_convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst++;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -1360,13 +1494,16 @@ rdp_orders_convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -1380,13 +1517,16 @@ rdp_orders_convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 2, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -1399,13 +1539,16 @@ rdp_orders_convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -1418,17 +1561,21 @@ rdp_orders_convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return bmpdata;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -1441,13 +1588,16 @@ rdp_orders_convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
out = (char *)g_malloc(width * height * 4, 0);
|
||||
src = bmpdata;
|
||||
dst = out;
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
for (j = 0; j < width; j++)
|
||||
@ -1463,8 +1613,10 @@ rdp_orders_convert_bitmap(int in_bpp, int out_bpp, char* bmpdata,
|
||||
dst += 4;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1485,6 +1637,7 @@ rdp_orders_convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR8(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 16))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@ -1492,6 +1645,7 @@ rdp_orders_convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR16(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 8) && (out_bpp == 24))
|
||||
{
|
||||
pixel = palette[in_color];
|
||||
@ -1499,6 +1653,7 @@ rdp_orders_convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 16))
|
||||
{
|
||||
pixel = in_color;
|
||||
@ -1506,6 +1661,7 @@ rdp_orders_convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR16(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 15) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
@ -1513,10 +1669,12 @@ rdp_orders_convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 16))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
if ((in_bpp == 16) && (out_bpp == 24))
|
||||
{
|
||||
pixel = in_color;
|
||||
@ -1524,9 +1682,11 @@ rdp_orders_convert_color(int in_bpp, int out_bpp, int in_color, int* palette)
|
||||
pixel = COLOR24BGR(red, green, blue);
|
||||
return pixel;
|
||||
}
|
||||
|
||||
if ((in_bpp == 24) && (out_bpp == 24))
|
||||
{
|
||||
return in_color;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
122
rdp/rdp_rdp.c
122
rdp/rdp_rdp.c
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp rdp layer
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* librdp rdp layer
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
@ -51,13 +49,16 @@ rdp_rdp_delete(struct rdp_rdp* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rdp_orders_delete(self->orders);
|
||||
rdp_sec_delete(self->sec_layer);
|
||||
|
||||
if (self->rec_fd != 0)
|
||||
{
|
||||
g_file_close(self->rec_fd);
|
||||
self->rec_fd = 0;
|
||||
}
|
||||
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
@ -70,6 +71,7 @@ rdp_rdp_init(struct rdp_rdp* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_push_layer(s, rdp_hdr, 6);
|
||||
return 0;
|
||||
}
|
||||
@ -88,10 +90,12 @@ rdp_rdp_send(struct rdp_rdp* self, struct stream* s, int pdu_type)
|
||||
out_uint16_le(s, pdu_type | 0x10);
|
||||
out_uint16_le(s, self->sec_layer->mcs_layer->userid);
|
||||
sec_flags = SEC_ENCRYPT;
|
||||
|
||||
if (rdp_sec_send(self->sec_layer, s, sec_flags) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -104,6 +108,7 @@ rdp_rdp_init_data(struct rdp_rdp* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s_push_layer(s, rdp_hdr, 18);
|
||||
return 0;
|
||||
}
|
||||
@ -129,10 +134,12 @@ rdp_rdp_send_data(struct rdp_rdp* self, struct stream* s, int pdu_data_type)
|
||||
out_uint8(s, 0); /* compress type */
|
||||
out_uint16_le(s, 0); /* compress len */
|
||||
sec_flags = SEC_ENCRYPT;
|
||||
|
||||
if (rdp_sec_send(self->sec_layer, s, sec_flags) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -305,7 +312,8 @@ rdp_rdp_out_colcache_caps(struct rdp_rdp* self, struct stream* s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char caps_0x0d[] = {
|
||||
static char caps_0x0d[] =
|
||||
{
|
||||
0x01, 0x00, 0x00, 0x00, 0x09, 0x04, 0x00, 0x00,
|
||||
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
@ -323,7 +331,8 @@ static char caps_0x0c[] = { 0x01, 0x00, 0x00, 0x00 };
|
||||
|
||||
static char caps_0x0e[] = { 0x01, 0x00, 0x00, 0x00 };
|
||||
|
||||
static char caps_0x10[] = {
|
||||
static char caps_0x10[] =
|
||||
{
|
||||
0xFE, 0x00, 0x04, 0x00, 0xFE, 0x00, 0x04, 0x00,
|
||||
0xFE, 0x00, 0x08, 0x00, 0xFE, 0x00, 0x08, 0x00,
|
||||
0xFE, 0x00, 0x10, 0x00, 0xFE, 0x00, 0x20, 0x00,
|
||||
@ -362,10 +371,12 @@ rdp_rdp_send_confirm_active(struct rdp_rdp* self, struct stream* s)
|
||||
RDP_CAPLEN_POINTER_MONO + RDP_CAPLEN_SHARE +
|
||||
0x58 + 0x08 + 0x08 + 0x34 /* unknown caps */ +
|
||||
4 /* w2k fix, why? */ ;
|
||||
|
||||
if (rdp_sec_init(self->sec_layer, s, sec_flags) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, 2 + 14 + caplen + sizeof(RDP_SOURCE));
|
||||
out_uint16_le(s, (RDP_PDU_CONFIRM_ACTIVE | 0x10)); /* Version 1 */
|
||||
out_uint16_le(s, (self->sec_layer->mcs_layer->userid + 1001));
|
||||
@ -390,10 +401,12 @@ rdp_rdp_send_confirm_active(struct rdp_rdp* self, struct stream* s)
|
||||
rdp_rdp_out_unknown_caps(self, s, 0x0e, 0x08, caps_0x0e);
|
||||
rdp_rdp_out_unknown_caps(self, s, 0x10, 0x34, caps_0x10); /* glyph cache? */
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_sec_send(self->sec_layer, s, sec_flags) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -408,10 +421,12 @@ rdp_rdp_process_color_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
struct rdp_cursor *cursor;
|
||||
|
||||
in_uint16_le(s, cache_idx);
|
||||
|
||||
if (cache_idx >= sizeof(self->cursors) / sizeof(cursor))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
cursor = self->cursors + cache_idx;
|
||||
in_uint16_le(s, cursor->x);
|
||||
in_uint16_le(s, cursor->y);
|
||||
@ -419,10 +434,12 @@ rdp_rdp_process_color_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
in_uint16_le(s, cursor->height);
|
||||
in_uint16_le(s, mlen); /* mask length */
|
||||
in_uint16_le(s, dlen); /* data length */
|
||||
|
||||
if ((mlen > sizeof(cursor->mask)) || (dlen > sizeof(cursor->data)))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8a(s, cursor->data, dlen);
|
||||
in_uint8a(s, cursor->mask, mlen);
|
||||
self->mod->server_set_cursor(self->mod, cursor->x, cursor->y,
|
||||
@ -439,10 +456,12 @@ rdp_rdp_process_cached_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
struct rdp_cursor *cursor;
|
||||
|
||||
in_uint16_le(s, cache_idx);
|
||||
|
||||
if (cache_idx >= sizeof(self->cursors) / sizeof(cursor))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
cursor = self->cursors + cache_idx;
|
||||
self->mod->server_set_cursor(self->mod, cursor->x, cursor->y,
|
||||
cursor->data, cursor->mask);
|
||||
@ -458,6 +477,7 @@ rdp_rdp_process_system_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
struct rdp_cursor *cursor;
|
||||
|
||||
in_uint16_le(s, system_pointer_type);
|
||||
|
||||
switch (system_pointer_type)
|
||||
{
|
||||
case RDP_NULL_POINTER:
|
||||
@ -470,6 +490,7 @@ rdp_rdp_process_system_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -486,6 +507,7 @@ rdp_rdp_process_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
rv = 0;
|
||||
in_uint16_le(s, message_type);
|
||||
in_uint8s(s, 2); /* pad */
|
||||
|
||||
switch (message_type)
|
||||
{
|
||||
case RDP_POINTER_MOVE:
|
||||
@ -504,6 +526,7 @@ rdp_rdp_process_pointer_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -534,6 +557,7 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
char *bmpdata1 = NULL;
|
||||
|
||||
in_uint16_le(s, num_updates);
|
||||
|
||||
for (i = 0; i < num_updates; i++)
|
||||
{
|
||||
in_uint16_le(s, left);
|
||||
@ -549,6 +573,7 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
cx = (right - left) + 1;
|
||||
cy = (bottom - top) + 1;
|
||||
bmpdata0 = (char *)g_malloc(width * height * Bpp, 0);
|
||||
|
||||
if (compress)
|
||||
{
|
||||
if (compress & 0x400)
|
||||
@ -561,6 +586,7 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
in_uint16_le(s, size);
|
||||
in_uint8s(s, 4); /* line_size, final_size */
|
||||
}
|
||||
|
||||
in_uint8p(s, data, size);
|
||||
rdp_bitmap_decompress(bmpdata0, width, height, data, size, Bpp);
|
||||
bmpdata1 = rdp_orders_convert_bitmap(bpp, self->mod->xrdp_bpp,
|
||||
@ -574,6 +600,7 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
data = bmpdata0 + ((height - y) - 1) * (width * Bpp);
|
||||
|
||||
if (Bpp == 1)
|
||||
{
|
||||
for (x = 0; x < width; x++)
|
||||
@ -598,16 +625,19 @@ rdp_rdp_process_bitmap_updates(struct rdp_rdp* self, struct stream* s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bmpdata1 = rdp_orders_convert_bitmap(bpp, self->mod->xrdp_bpp,
|
||||
bmpdata0, width, height,
|
||||
self->colormap.colors);
|
||||
self->mod->server_paint_rect(self->mod, left, top, cx, cy, bmpdata1,
|
||||
width, height, 0, 0);
|
||||
}
|
||||
|
||||
if (bmpdata0 != bmpdata1)
|
||||
{
|
||||
g_free(bmpdata1);
|
||||
}
|
||||
|
||||
g_free(bmpdata0);
|
||||
}
|
||||
}
|
||||
@ -625,6 +655,7 @@ rdp_rdp_process_palette(struct rdp_rdp* self, struct stream* s)
|
||||
in_uint8s(s, 2); /* pad */
|
||||
in_uint16_le(s, self->colormap.ncolors);
|
||||
in_uint8s(s, 2); /* pad */
|
||||
|
||||
for (i = 0; i < self->colormap.ncolors; i++)
|
||||
{
|
||||
in_uint8(s, r);
|
||||
@ -632,6 +663,7 @@ rdp_rdp_process_palette(struct rdp_rdp* self, struct stream* s)
|
||||
in_uint8(s, b);
|
||||
self->colormap.colors[i] = (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
//ui_set_colormap(hmap);
|
||||
}
|
||||
|
||||
@ -645,6 +677,7 @@ rdp_rdp_process_update_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
|
||||
in_uint16_le(s, update_type);
|
||||
self->mod->server_begin_update(self->mod);
|
||||
|
||||
switch (update_type)
|
||||
{
|
||||
case RDP_UPDATE_ORDERS:
|
||||
@ -664,6 +697,7 @@ rdp_rdp_process_update_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
self->mod->server_end_update(self->mod);
|
||||
return 0;
|
||||
}
|
||||
@ -676,12 +710,14 @@ rdp_rdp_out_unistr(struct stream* s, char* text)
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
|
||||
while (text[i] != 0)
|
||||
{
|
||||
out_uint8(s, text[i]);
|
||||
out_uint8(s, 0);
|
||||
i++;
|
||||
}
|
||||
|
||||
out_uint8(s, 0);
|
||||
out_uint8(s, 0);
|
||||
}
|
||||
@ -707,12 +743,14 @@ rdp_rdp_send_login_info(struct rdp_rdp* self, int flags)
|
||||
len_program = 2 * g_strlen(self->mod->program);
|
||||
len_directory = 2 * g_strlen(self->mod->directory);
|
||||
sec_flags = SEC_LOGON_INFO | SEC_ENCRYPT;
|
||||
|
||||
if (rdp_sec_init(self->sec_layer, s, sec_flags) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG(("out rdp_rdp_send_login_info error 1"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, 0);
|
||||
out_uint32_le(s, flags);
|
||||
out_uint16_le(s, len_domain);
|
||||
@ -726,12 +764,14 @@ rdp_rdp_send_login_info(struct rdp_rdp* self, int flags)
|
||||
rdp_rdp_out_unistr(s, self->mod->program);
|
||||
rdp_rdp_out_unistr(s, self->mod->directory);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_sec_send(self->sec_layer, s, sec_flags) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
DEBUG(("out rdp_rdp_send_login_info error 2"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
DEBUG(("out rdp_rdp_send_login_info"));
|
||||
return 0;
|
||||
@ -745,20 +785,24 @@ rdp_rdp_connect(struct rdp_rdp* self, char* ip, char* port)
|
||||
|
||||
DEBUG(("in rdp_rdp_connect"));
|
||||
flags = RDP_LOGON_NORMAL;
|
||||
|
||||
if (g_strlen(self->mod->password) > 0)
|
||||
{
|
||||
flags |= RDP_LOGON_AUTO;
|
||||
}
|
||||
|
||||
if (rdp_sec_connect(self->sec_layer, ip, port) != 0)
|
||||
{
|
||||
DEBUG(("out rdp_rdp_connect error rdp_sec_connect failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (rdp_rdp_send_login_info(self, flags) != 0)
|
||||
{
|
||||
DEBUG(("out rdp_rdp_connect error rdp_rdp_send_login_info failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG(("out rdp_rdp_connect"));
|
||||
return 0;
|
||||
}
|
||||
@ -773,6 +817,7 @@ rdp_rdp_send_input(struct rdp_rdp* self, struct stream* s,
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, 1); /* number of events */
|
||||
out_uint16_le(s, 0);
|
||||
out_uint32_le(s, time);
|
||||
@ -781,10 +826,12 @@ rdp_rdp_send_input(struct rdp_rdp* self, struct stream* s,
|
||||
out_uint16_le(s, param1);
|
||||
out_uint16_le(s, param2);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_rdp_send_data(self, s, RDP_DATA_PDU_INPUT) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -797,16 +844,19 @@ rdp_rdp_send_invalidate(struct rdp_rdp* self, struct stream* s,
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, 1);
|
||||
out_uint16_le(s, left);
|
||||
out_uint16_le(s, top);
|
||||
out_uint16_le(s, (left + width) - 1);
|
||||
out_uint16_le(s, (top + height) - 1);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_rdp_send_data(self, s, 33) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -820,6 +870,7 @@ rdp_rdp_recv(struct rdp_rdp* self, struct stream* s, int* type)
|
||||
|
||||
chan = 0;
|
||||
DEBUG(("in rdp_rdp_recv"));
|
||||
|
||||
if (s->next_packet >= s->end || s->next_packet == 0)
|
||||
{
|
||||
if (rdp_sec_recv(self->sec_layer, s, &chan) != 0)
|
||||
@ -827,6 +878,7 @@ rdp_rdp_recv(struct rdp_rdp* self, struct stream* s, int* type)
|
||||
DEBUG(("error in rdp_rdp_recv, rdp_sec_recv failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
s->next_packet = s->p;
|
||||
}
|
||||
else
|
||||
@ -834,16 +886,19 @@ rdp_rdp_recv(struct rdp_rdp* self, struct stream* s, int* type)
|
||||
chan = MCS_GLOBAL_CHANNEL;
|
||||
s->p = s->next_packet;
|
||||
}
|
||||
|
||||
if (chan == MCS_GLOBAL_CHANNEL)
|
||||
{
|
||||
in_uint16_le(s, len);
|
||||
DEBUG(("rdp_rdp_recv got %d len", len));
|
||||
|
||||
if (len == 0x8000)
|
||||
{
|
||||
s->next_packet += 8;
|
||||
DEBUG(("out rdp_rdp_recv"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint16_le(s, pdu_type);
|
||||
in_uint8s(s, 2);
|
||||
*type = pdu_type & 0xf;
|
||||
@ -855,6 +910,7 @@ rdp_rdp_recv(struct rdp_rdp* self, struct stream* s, int* type)
|
||||
DEBUG(("got channel data channel %d", chan));
|
||||
s->next_packet = s->end;
|
||||
}
|
||||
|
||||
DEBUG(("out rdp_rdp_recv"));
|
||||
return 0;
|
||||
}
|
||||
@ -882,6 +938,7 @@ rdp_rdp_process_data_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
in_uint8(s, data_pdu_type);
|
||||
in_uint8(s, ctype);
|
||||
in_uint8s(s, 2); /* clen */
|
||||
|
||||
switch (data_pdu_type)
|
||||
{
|
||||
case RDP_DATA_PDU_UPDATE:
|
||||
@ -904,6 +961,7 @@ rdp_rdp_process_data_pdu(struct rdp_rdp* self, struct stream* s)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -947,15 +1005,18 @@ rdp_rdp_process_server_caps(struct rdp_rdp* self, struct stream* s, int len)
|
||||
start = s->p;
|
||||
in_uint16_le(s, ncapsets);
|
||||
in_uint8s(s, 2); /* pad */
|
||||
|
||||
for (n = 0; n < ncapsets; n++)
|
||||
{
|
||||
if (s->p > start + len)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint16_le(s, capset_type);
|
||||
in_uint16_le(s, capset_length);
|
||||
next = (s->p + capset_length) - 4;
|
||||
|
||||
switch (capset_type)
|
||||
{
|
||||
case RDP_CAPSET_GENERAL:
|
||||
@ -967,8 +1028,10 @@ rdp_rdp_process_server_caps(struct rdp_rdp* self, struct stream* s, int len)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = next;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -982,14 +1045,17 @@ rdp_rdp_send_control(struct rdp_rdp* self, struct stream* s, int action)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, action);
|
||||
out_uint16_le(s, 0); /* userid */
|
||||
out_uint32_le(s, 0); /* control id */
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_rdp_send_data(self, s, RDP_DATA_PDU_CONTROL) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1003,13 +1069,16 @@ rdp_rdp_send_synchronise(struct rdp_rdp* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, 1); /* type */
|
||||
out_uint16_le(s, 1002);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_rdp_send_data(self, s, RDP_DATA_PDU_SYNCHRONISE) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1022,15 +1091,18 @@ rdp_rdp_send_fonts(struct rdp_rdp* self, struct stream* s, int seq)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint16_le(s, 0); /* number of fonts */
|
||||
out_uint16_le(s, 0); /* pad? */
|
||||
out_uint16_le(s, seq); /* unknown */
|
||||
out_uint16_le(s, 0x32); /* entry size */
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_rdp_send_data(self, s, RDP_DATA_PDU_FONT2) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1078,15 +1150,19 @@ rdp_rec_check_file(struct rdp_rdp* self)
|
||||
{
|
||||
index = 1;
|
||||
g_sprintf(file_name, "rec%8.8d.rec", index);
|
||||
|
||||
while (g_file_exist(file_name))
|
||||
{
|
||||
index++;
|
||||
|
||||
if (index >= 9999)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_sprintf(file_name, "rec%8.8d.rec", index);
|
||||
}
|
||||
|
||||
self->rec_fd = g_file_open(file_name);
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
@ -1097,6 +1173,7 @@ rdp_rec_check_file(struct rdp_rdp* self)
|
||||
g_file_write(self->rec_fd, s->data, len);
|
||||
free_stream(s);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1111,6 +1188,7 @@ rdp_rec_write_item(struct rdp_rdp* self, struct stream* s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
time = g_time1();
|
||||
out_uint32_le(s, time);
|
||||
s_mark_end(s);
|
||||
|
106
rdp/rdp_sec.c
106
rdp/rdp_sec.c
@ -1,36 +1,38 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp secure layer
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* librdp secure layer
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
|
||||
static char g_pad_54[40] =
|
||||
{ 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
||||
{
|
||||
54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
||||
54, 54, 54, 54, 54, 54, 54, 54 };
|
||||
54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
|
||||
54, 54, 54, 54, 54, 54, 54, 54
|
||||
};
|
||||
|
||||
static char g_pad_92[48] =
|
||||
{ 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
|
||||
{
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92 };
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92,
|
||||
92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, 92
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
struct rdp_sec *APP_CC
|
||||
@ -46,15 +48,19 @@ rdp_sec_create(struct rdp_rdp* owner)
|
||||
init_stream(self->server_mcs_data, 8192);
|
||||
self->mcs_layer = rdp_mcs_create(self, self->client_mcs_data,
|
||||
self->server_mcs_data);
|
||||
|
||||
if (self->decrypt_rc4_info != NULL)
|
||||
{
|
||||
g_writeln("rdp_sec_create - decrypt_rc4_info already created !!!");
|
||||
}
|
||||
|
||||
self->decrypt_rc4_info = ssl_rc4_info_create();
|
||||
|
||||
if (self->encrypt_rc4_info != NULL)
|
||||
{
|
||||
g_writeln("rdp_sec_create - encrypt_rc4_info already created !!!");
|
||||
}
|
||||
|
||||
self->encrypt_rc4_info = ssl_rc4_info_create();
|
||||
self->lic_layer = rdp_lic_create(self);
|
||||
return self;
|
||||
@ -68,6 +74,7 @@ rdp_sec_delete(struct rdp_sec* self)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rdp_lic_delete(self->lic_layer);
|
||||
rdp_mcs_delete(self->mcs_layer);
|
||||
free_stream(self->client_mcs_data);
|
||||
@ -113,10 +120,12 @@ rdp_sec_update(char* key, char* update_key, int key_len)
|
||||
ssl_md5_complete(md5_info, key);
|
||||
ssl_rc4_set_key(rc4_info, key, key_len);
|
||||
ssl_rc4_crypt(rc4_info, key, key_len);
|
||||
|
||||
if (key_len == 8)
|
||||
{
|
||||
rdp_sec_make_40bit(key);
|
||||
}
|
||||
|
||||
ssl_sha1_info_delete(sha1_info);
|
||||
ssl_md5_info_delete(md5_info);
|
||||
ssl_rc4_info_delete(rc4_info);
|
||||
@ -135,6 +144,7 @@ rdp_sec_decrypt(struct rdp_sec* self, char* data, int len)
|
||||
self->rc4_key_len);
|
||||
self->decrypt_use_count = 0;
|
||||
}
|
||||
|
||||
ssl_rc4_crypt(self->decrypt_rc4_info, data, len);
|
||||
self->decrypt_use_count++;
|
||||
}
|
||||
@ -147,24 +157,29 @@ rdp_sec_recv(struct rdp_sec* self, struct stream* s, int* chan)
|
||||
int flags;
|
||||
|
||||
DEBUG((" in rdp_sec_recv"));
|
||||
|
||||
if (rdp_mcs_recv(self->mcs_layer, s, chan) != 0)
|
||||
{
|
||||
DEBUG((" error in rdp_sec_recv, rdp_mcs_recv failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint32_le(s, flags);
|
||||
DEBUG((" rdp_sec_recv flags %8.8x", flags));
|
||||
|
||||
if (flags & SEC_ENCRYPT) /* 0x08 */
|
||||
{
|
||||
in_uint8s(s, 8); /* signature */
|
||||
rdp_sec_decrypt(self, s->p, s->end - s->p);
|
||||
}
|
||||
|
||||
if (flags & SEC_LICENCE_NEG) /* 0x80 */
|
||||
{
|
||||
DEBUG((" in rdp_sec_recv, got SEC_LICENCE_NEG"));
|
||||
rdp_lic_process(self->lic_layer, s);
|
||||
*chan = 0;
|
||||
}
|
||||
|
||||
DEBUG((" out rdp_sec_recv"));
|
||||
return 0;
|
||||
}
|
||||
@ -246,15 +261,19 @@ rdp_sec_parse_public_key(struct rdp_sec* self, struct stream* s,
|
||||
int modulus_len;
|
||||
|
||||
in_uint32_le(s, magic);
|
||||
|
||||
if (magic != SEC_RSA_MAGIC)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint32_le(s, modulus_len);
|
||||
|
||||
if (modulus_len != SEC_MODULUS_SIZE + SEC_PADDING_SIZE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint8s(s, 8);
|
||||
in_uint8a(s, exponent, SEC_EXPONENT_SIZE);
|
||||
in_uint8a(s, modulus, SEC_MODULUS_SIZE);
|
||||
@ -279,46 +298,58 @@ rdp_sec_parse_crypt_info(struct rdp_sec* self, struct stream* s,
|
||||
|
||||
in_uint32_le(s, self->rc4_key_size); /* 1 = 40-bit, 2 = 128-bit */
|
||||
in_uint32_le(s, self->crypt_level); /* 1 = low, 2 = medium, 3 = high */
|
||||
|
||||
if (self->crypt_level == 0) /* no encryption */
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint32_le(s, random_len);
|
||||
in_uint32_le(s, rsa_info_len);
|
||||
|
||||
if (random_len != SEC_RANDOM_SIZE)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint8a(s, self->server_random, random_len);
|
||||
/* RSA info */
|
||||
end = s->p + rsa_info_len;
|
||||
|
||||
if (end > s->end)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
in_uint32_le(s, flags); /* 1 = RDP4-style, 0x80000002 = X.509 */
|
||||
|
||||
if (flags & 1)
|
||||
{
|
||||
in_uint8s(s, 8); /* unknown */
|
||||
|
||||
while (s->p < end)
|
||||
{
|
||||
in_uint16_le(s, tag);
|
||||
in_uint16_le(s, length);
|
||||
next_tag = s->p + length;
|
||||
DEBUG((" rdp_sec_parse_crypt_info tag %d length %d", tag, length));
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case SEC_TAG_PUBKEY:
|
||||
|
||||
if (!rdp_sec_parse_public_key(self, s, modulus, exponent))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
break;
|
||||
case SEC_TAG_KEYSIG:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = next_tag;
|
||||
}
|
||||
}
|
||||
@ -327,6 +358,7 @@ rdp_sec_parse_crypt_info(struct rdp_sec* self, struct stream* s,
|
||||
/* todo */
|
||||
return 0;
|
||||
}
|
||||
|
||||
return s_check_end(s);
|
||||
}
|
||||
|
||||
@ -353,6 +385,7 @@ rdp_sec_hash_48(char* out, char* in, char* salt1, char* salt2, int salt)
|
||||
|
||||
sha1_info = ssl_sha1_info_create();
|
||||
md5_info = ssl_md5_info_create();
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
g_memset(pad, salt + i, 4);
|
||||
@ -368,6 +401,7 @@ rdp_sec_hash_48(char* out, char* in, char* salt1, char* salt2, int salt)
|
||||
ssl_md5_complete(md5_info, md5_sig);
|
||||
g_memcpy(out + i * 16, md5_sig, 16);
|
||||
}
|
||||
|
||||
ssl_sha1_info_delete(sha1_info);
|
||||
ssl_md5_info_delete(md5_info);
|
||||
}
|
||||
@ -408,6 +442,7 @@ rdp_sec_generate_keys(struct rdp_sec* self)
|
||||
self->server_random);
|
||||
DEBUG((" rdp_sec_generate_keys, rc4_key_size is %d", self->rc4_key_size));
|
||||
DEBUG((" rdp_sec_generate_keys, crypt_level is %d", self->crypt_level));
|
||||
|
||||
if (self->rc4_key_size == 1)
|
||||
{
|
||||
rdp_sec_make_40bit(self->sign_key);
|
||||
@ -419,6 +454,7 @@ rdp_sec_generate_keys(struct rdp_sec* self)
|
||||
{
|
||||
self->rc4_key_len = 16;
|
||||
}
|
||||
|
||||
g_memcpy(self->decrypt_update_key, self->decrypt_key, 16);
|
||||
g_memcpy(self->encrypt_update_key, self->encrypt_key, 16);
|
||||
ssl_rc4_set_key(self->decrypt_rc4_info, self->decrypt_key, self->rc4_key_len);
|
||||
@ -436,11 +472,13 @@ rdp_sec_process_crypt_info(struct rdp_sec* self, struct stream* s)
|
||||
|
||||
g_memset(modulus, 0, sizeof(modulus));
|
||||
g_memset(exponent, 0, sizeof(exponent));
|
||||
|
||||
if (!rdp_sec_parse_crypt_info(self, s, modulus, exponent))
|
||||
{
|
||||
DEBUG((" error in rdp_sec_process_crypt_info"));
|
||||
return;
|
||||
}
|
||||
|
||||
/* Generate a client random, and determine encryption keys */
|
||||
g_random(self->client_random, 32);
|
||||
rdp_sec_rsa_op(self->client_crypt_random, self->client_random,
|
||||
@ -463,20 +501,25 @@ rdp_sec_process_mcs_data(struct rdp_sec* self)
|
||||
s->p = s->data;
|
||||
in_uint8s(s, 21); /* header (T.124 ConferenceCreateResponse) */
|
||||
in_uint8(s, len);
|
||||
|
||||
if (len & 0x80)
|
||||
{
|
||||
in_uint8(s, len);
|
||||
}
|
||||
|
||||
while (s->p < s->end)
|
||||
{
|
||||
in_uint16_le(s, tag);
|
||||
in_uint16_le(s, length);
|
||||
DEBUG((" rdp_sec_process_mcs_data tag %d length %d", tag, length));
|
||||
|
||||
if (length <= 4)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
next_tag = (s->p + length) - 4;
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
case SEC_TAG_SRV_INFO:
|
||||
@ -490,6 +533,7 @@ rdp_sec_process_mcs_data(struct rdp_sec* self)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = next_tag;
|
||||
}
|
||||
}
|
||||
@ -509,20 +553,24 @@ rdp_sec_establish_key(struct rdp_sec* self)
|
||||
init_stream(s, 8192);
|
||||
length = SEC_MODULUS_SIZE + SEC_PADDING_SIZE;
|
||||
flags = SEC_CLIENT_RANDOM;
|
||||
|
||||
if (rdp_sec_init(self, s, flags) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, length);
|
||||
out_uint8p(s, self->client_crypt_random, SEC_MODULUS_SIZE);
|
||||
out_uint8s(s, SEC_PADDING_SIZE);
|
||||
s_mark_end(s);
|
||||
|
||||
if (rdp_sec_send(self, s, flags) != 0)
|
||||
{
|
||||
free_stream(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
return 0;
|
||||
}
|
||||
@ -534,17 +582,21 @@ rdp_sec_connect(struct rdp_sec* self, char* ip, char* port)
|
||||
{
|
||||
DEBUG((" in rdp_sec_connect"));
|
||||
rdp_sec_out_mcs_data(self);
|
||||
|
||||
if (rdp_mcs_connect(self->mcs_layer, ip, port) != 0)
|
||||
{
|
||||
DEBUG((" out rdp_sec_connect error rdp_mcs_connect failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
rdp_sec_process_mcs_data(self);
|
||||
|
||||
if (rdp_sec_establish_key(self) != 0)
|
||||
{
|
||||
DEBUG((" out rdp_sec_connect error rdp_sec_establish_key failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out rdp_sec_connect"));
|
||||
return 0;
|
||||
}
|
||||
@ -558,6 +610,7 @@ rdp_sec_init(struct rdp_sec* self, struct stream* s, int flags)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (flags & SEC_ENCRYPT)
|
||||
{
|
||||
s_push_layer(s, sec_hdr, 12);
|
||||
@ -566,6 +619,7 @@ rdp_sec_init(struct rdp_sec* self, struct stream* s, int flags)
|
||||
{
|
||||
s_push_layer(s, sec_hdr, 4);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -624,6 +678,7 @@ rdp_sec_encrypt(struct rdp_sec* self, char* data, int length)
|
||||
self->rc4_key_len);
|
||||
self->encrypt_use_count = 0;
|
||||
}
|
||||
|
||||
ssl_rc4_crypt(self->encrypt_rc4_info, data, length);
|
||||
self->encrypt_use_count++;
|
||||
}
|
||||
@ -638,6 +693,7 @@ rdp_sec_send(struct rdp_sec* self, struct stream* s, int flags)
|
||||
DEBUG((" in rdp_sec_send flags %8.8x", flags));
|
||||
s_pop_layer(s, sec_hdr);
|
||||
out_uint32_le(s, flags);
|
||||
|
||||
if (flags & SEC_ENCRYPT)
|
||||
{
|
||||
datalen = (s->end - s->p) - 8;
|
||||
@ -645,11 +701,13 @@ rdp_sec_send(struct rdp_sec* self, struct stream* s, int flags)
|
||||
datalen);
|
||||
rdp_sec_encrypt(self, s->p + 8, datalen);
|
||||
}
|
||||
|
||||
if (rdp_mcs_send(self->mcs_layer, s) != 0)
|
||||
{
|
||||
DEBUG((" out rdp_sec_send, rdp_mcs_send failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out rdp_sec_send"));
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,23 +1,21 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
librdp tcp layer
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* librdp tcp layer
|
||||
*/
|
||||
|
||||
#include "rdp.h"
|
||||
@ -59,15 +57,19 @@ rdp_tcp_recv(struct rdp_tcp* self, struct stream* s, int len)
|
||||
|
||||
DEBUG((" in rdp_tcp_recv gota get %d bytes on sck %d",
|
||||
len, self->sck));
|
||||
|
||||
if (self->sck_closed)
|
||||
{
|
||||
DEBUG((" out rdp_tcp_recv error sck closed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
init_stream(s, len);
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
rcvd = g_tcp_recv(self->sck, s->end, len, 0);
|
||||
|
||||
if (rcvd == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@ -93,6 +95,7 @@ rdp_tcp_recv(struct rdp_tcp* self, struct stream* s, int len)
|
||||
len -= rcvd;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -110,13 +113,16 @@ rdp_tcp_send(struct rdp_tcp* self, struct stream* s)
|
||||
DEBUG((" out rdp_tcp_send error sck closed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
len = s->end - s->data;
|
||||
DEBUG((" in rdp_tcp_send gota send %d bytes on sck %d", len,
|
||||
self->sck));
|
||||
total = 0;
|
||||
|
||||
while (total < len)
|
||||
{
|
||||
sent = g_tcp_send(self->sck, s->data + total, len - total, 0);
|
||||
|
||||
if (sent == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(self->sck))
|
||||
@ -141,6 +147,7 @@ rdp_tcp_send(struct rdp_tcp* self, struct stream* s)
|
||||
total = total + sent;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -151,6 +158,7 @@ rdp_tcp_connect(struct rdp_tcp* self, char* ip, char* port)
|
||||
{
|
||||
DEBUG((" in rdp_tcp_connect ip %s port %s", ip, port));
|
||||
self->sck = g_tcp_socket();
|
||||
|
||||
if (g_tcp_connect(self->sck, ip, port) == 0)
|
||||
{
|
||||
g_tcp_set_non_blocking(self->sck);
|
||||
@ -160,6 +168,7 @@ rdp_tcp_connect(struct rdp_tcp* self, char* ip, char* port)
|
||||
DEBUG((" out rdp_tcp_connect error g_tcp_connect failed"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
DEBUG((" out rdp_tcp_connect"));
|
||||
return 0;
|
||||
}
|
||||
@ -173,6 +182,7 @@ rdp_tcp_disconnect(struct rdp_tcp* self)
|
||||
{
|
||||
g_tcp_close(self->sck);
|
||||
}
|
||||
|
||||
self->sck = 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -35,4 +35,4 @@ make install
|
||||
|
||||
see file-loc.txt to see what files are installed where
|
||||
|
||||
Jay
|
||||
Jay Sorg
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -83,6 +83,7 @@ add_data_to_chan_item(struct chan_item* chan_item, char* data, int size)
|
||||
s->end = s->data + size;
|
||||
cod = (struct chan_out_data *)g_malloc(sizeof(struct chan_out_data), 1);
|
||||
cod->s = s;
|
||||
|
||||
if (chan_item->tail == 0)
|
||||
{
|
||||
chan_item->tail = cod;
|
||||
@ -93,6 +94,7 @@ add_data_to_chan_item(struct chan_item* chan_item, char* data, int size)
|
||||
chan_item->tail->next = cod;
|
||||
chan_item->tail = cod;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -112,18 +114,22 @@ send_data_from_chan_item(struct chan_item* chan_item)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
cod = chan_item->head;
|
||||
bytes_left = (int)(cod->s->end - cod->s->p);
|
||||
size = MIN(1600, bytes_left);
|
||||
chan_flags = 0;
|
||||
|
||||
if (cod->s->p == cod->s->data)
|
||||
{
|
||||
chan_flags |= 1; /* first */
|
||||
}
|
||||
|
||||
if (cod->s->p + size >= cod->s->end)
|
||||
{
|
||||
chan_flags |= 2; /* last */
|
||||
}
|
||||
|
||||
s = trans_get_out_s(g_con_trans, 8192);
|
||||
out_uint32_le(s, 0); /* version */
|
||||
out_uint32_le(s, 8 + 8 + 2 + 2 + 2 + 4 + size); /* size */
|
||||
@ -138,21 +144,27 @@ send_data_from_chan_item(struct chan_item* chan_item)
|
||||
LOGM((LOG_LEVEL_DEBUG, "chansrv::send_channel_data: -- "
|
||||
"size %d chan_flags 0x%8.8x", size, chan_flags));
|
||||
error = trans_force_write(g_con_trans);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
cod->s->p += size;
|
||||
|
||||
if (cod->s->p >= cod->s->end)
|
||||
{
|
||||
free_stream(cod->s);
|
||||
chan_item->head = chan_item->head->next;
|
||||
|
||||
if (chan_item->head == 0)
|
||||
{
|
||||
chan_item->tail = 0;
|
||||
}
|
||||
|
||||
g_free(cod);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -170,6 +182,7 @@ check_chan_items(void)
|
||||
send_data_from_chan_item(g_chan_items + index);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -181,10 +194,12 @@ send_channel_data(int chan_id, char* data, int size)
|
||||
int index;
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "chansrv::send_channel_data: size %d", size));
|
||||
|
||||
if (chan_id == -1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (index = 0; index < g_num_chan_items; index++)
|
||||
{
|
||||
if (g_chan_items[index].id == chan_id)
|
||||
@ -194,6 +209,7 @@ send_channel_data(int chan_id, char* data, int size)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -206,10 +222,12 @@ send_init_response_message(void)
|
||||
|
||||
LOGM((LOG_LEVEL_INFO, "send_init_response_message:"));
|
||||
s = trans_get_out_s(g_con_trans, 8192);
|
||||
|
||||
if (s == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, 0); /* version */
|
||||
out_uint32_le(s, 8 + 8); /* size */
|
||||
out_uint32_le(s, 2); /* msg id */
|
||||
@ -227,10 +245,12 @@ send_channel_setup_response_message(void)
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "send_channel_setup_response_message:"));
|
||||
s = trans_get_out_s(g_con_trans, 8192);
|
||||
|
||||
if (s == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, 0); /* version */
|
||||
out_uint32_le(s, 8 + 8); /* size */
|
||||
out_uint32_le(s, 4); /* msg id */
|
||||
@ -248,10 +268,12 @@ send_channel_data_response_message(void)
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "send_channel_data_response_message:"));
|
||||
s = trans_get_out_s(g_con_trans, 8192);
|
||||
|
||||
if (s == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
out_uint32_le(s, 0); /* version */
|
||||
out_uint32_le(s, 8 + 8); /* size */
|
||||
out_uint32_le(s, 6); /* msg id */
|
||||
@ -292,6 +314,7 @@ process_message_channel_setup(struct stream* s)
|
||||
in_uint16_le(s, num_chans);
|
||||
LOGM((LOG_LEVEL_DEBUG, "process_message_channel_setup: num_chans %d",
|
||||
num_chans));
|
||||
|
||||
for (index = 0; index < num_chans; index++)
|
||||
{
|
||||
ci = &(g_chan_items[g_num_chan_items]);
|
||||
@ -301,6 +324,7 @@ process_message_channel_setup(struct stream* s)
|
||||
in_uint16_le(s, ci->flags);
|
||||
LOGM((LOG_LEVEL_DEBUG, "process_message_channel_setup: chan name '%s' "
|
||||
"id %d flags %8.8x", ci->name, ci->id, ci->flags));
|
||||
|
||||
if (g_strcasecmp(ci->name, "cliprdr") == 0)
|
||||
{
|
||||
g_cliprdr_index = g_num_chan_items;
|
||||
@ -325,25 +349,32 @@ process_message_channel_setup(struct stream* s)
|
||||
{
|
||||
LOG(10, ("other %s", ci->name));
|
||||
}
|
||||
|
||||
g_num_chan_items++;
|
||||
}
|
||||
|
||||
rv = send_channel_setup_response_message();
|
||||
|
||||
if (g_cliprdr_index >= 0)
|
||||
{
|
||||
clipboard_init();
|
||||
}
|
||||
|
||||
if (g_rdpsnd_index >= 0)
|
||||
{
|
||||
sound_init();
|
||||
}
|
||||
|
||||
if (g_rdpdr_index >= 0)
|
||||
{
|
||||
dev_redir_init();
|
||||
}
|
||||
|
||||
if (g_rail_index >= 0)
|
||||
{
|
||||
rail_init();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -367,6 +398,7 @@ process_message_channel_data(struct stream* s)
|
||||
"chan_flags %d", chan_id, chan_flags));
|
||||
LOG(10, ("process_message_channel_data"));
|
||||
rv = send_channel_data_response_message();
|
||||
|
||||
if (rv == 0)
|
||||
{
|
||||
if (chan_id == g_cliprdr_chan_id)
|
||||
@ -391,11 +423,14 @@ process_message_channel_data(struct stream* s)
|
||||
LOG(10, ("process_message_channel_data length %d total_length %d "
|
||||
"chan_flags 0x%8.8x", length, total_length, chan_flags));
|
||||
ls = g_api_con_trans->out_s;
|
||||
|
||||
if (chan_flags & 1) /* first */
|
||||
{
|
||||
init_stream(ls, total_length);
|
||||
}
|
||||
|
||||
out_uint8a(ls, s->p, length);
|
||||
|
||||
if (chan_flags & 2) /* last */
|
||||
{
|
||||
s_mark_end(ls);
|
||||
@ -403,6 +438,7 @@ process_message_channel_data(struct stream* s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -431,18 +467,23 @@ process_message(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s = trans_get_in_s(g_con_trans);
|
||||
|
||||
if (s == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = 0;
|
||||
|
||||
while (s_check_rem(s, 8))
|
||||
{
|
||||
next_msg = s->p;
|
||||
in_uint32_le(s, id);
|
||||
in_uint32_le(s, size);
|
||||
next_msg += size;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case 1: /* init */
|
||||
@ -462,12 +503,15 @@ process_message(void)
|
||||
"unknown msg %d", id));
|
||||
break;
|
||||
}
|
||||
|
||||
if (rv != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
s->p = next_msg;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -485,20 +529,24 @@ my_trans_data_in(struct trans* trans)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (trans != g_con_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "my_trans_data_in:"));
|
||||
s = trans_get_in_s(trans);
|
||||
in_uint32_le(s, id);
|
||||
in_uint32_le(s, size);
|
||||
error = trans_force_read(trans, size - 8);
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
/* here, the entire message block is read in, process it */
|
||||
error = process_message();
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -512,21 +560,26 @@ my_api_trans_data_in(struct trans* trans)
|
||||
struct xrdp_api_data *ad;
|
||||
|
||||
LOG(10, ("my_api_trans_data_in:"));
|
||||
|
||||
if (trans == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (trans != g_api_con_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "my_api_trans_data_in:"));
|
||||
s = trans_get_in_s(trans);
|
||||
error = g_tcp_recv(trans->sck, s->data, 8192, 0);
|
||||
|
||||
if (error > 0)
|
||||
{
|
||||
LOG(10, ("my_api_trans_data_in: got data %d", error));
|
||||
ad = (struct xrdp_api_data *)(trans->callback_data);
|
||||
|
||||
if (send_channel_data(ad->chan_id, s->data, error) != 0)
|
||||
{
|
||||
LOG(0, ("my_api_trans_data_in: send_channel_data failed"));
|
||||
@ -537,6 +590,7 @@ my_api_trans_data_in(struct trans* trans)
|
||||
LOG(10, ("my_api_trans_data_in: g_tcp_recv failed, or disconnected"));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -548,18 +602,22 @@ my_trans_conn_in(struct trans* trans, struct trans* new_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (trans != g_lis_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (g_con_trans != 0) /* if already set, error */
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (new_trans == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "my_trans_conn_in:"));
|
||||
g_con_trans = new_trans;
|
||||
g_con_trans->trans_data_in = my_trans_data_in;
|
||||
@ -584,14 +642,17 @@ my_api_trans_conn_in(struct trans* trans, struct trans* new_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (trans != g_api_lis_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (new_trans == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "my_api_trans_conn_in:"));
|
||||
|
||||
LOG(10, ("my_api_trans_conn_in: got incoming"));
|
||||
@ -599,11 +660,13 @@ my_api_trans_conn_in(struct trans* trans, struct trans* new_trans)
|
||||
s = trans_get_in_s(new_trans);
|
||||
s->end = s->data;
|
||||
error = trans_force_read(new_trans, 64);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
LOG(0, ("my_api_trans_conn_in: trans_force_read failed"));
|
||||
trans_delete(new_trans);
|
||||
}
|
||||
|
||||
s->end = s->data;
|
||||
|
||||
ad = (struct xrdp_api_data *)g_malloc(sizeof(struct xrdp_api_data), 1);
|
||||
@ -613,6 +676,7 @@ my_api_trans_conn_in(struct trans* trans, struct trans* new_trans)
|
||||
ad->flags = GGET_UINT32(ad->header, 16);
|
||||
|
||||
found = 0;
|
||||
|
||||
if (ad->flags | 1) /* WTS_CHANNEL_OPTION_DYNAMIC */
|
||||
{
|
||||
/* TODO */
|
||||
@ -623,6 +687,7 @@ my_api_trans_conn_in(struct trans* trans, struct trans* new_trans)
|
||||
for (index = 0; index < g_num_chan_items; index++)
|
||||
{
|
||||
LOG(10, (" %s %s", ad->header, g_chan_items[index].name));
|
||||
|
||||
if (g_strcasecmp(ad->header, g_chan_items[index].name) == 0)
|
||||
{
|
||||
LOG(10, ("my_api_trans_conn_in: found it at %d", index));
|
||||
@ -632,7 +697,9 @@ my_api_trans_conn_in(struct trans* trans, struct trans* new_trans)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG(10, ("my_api_trans_conn_in: found %d", found));
|
||||
|
||||
if (!found)
|
||||
{
|
||||
ad->chan_id = -1;
|
||||
@ -659,6 +726,7 @@ setup_listen(void)
|
||||
{
|
||||
trans_delete(g_lis_trans);
|
||||
}
|
||||
|
||||
if (g_use_unix_socket)
|
||||
{
|
||||
g_lis_trans = trans_create(2, 8192, 8192);
|
||||
@ -670,14 +738,17 @@ setup_listen(void)
|
||||
g_lis_trans = trans_create(1, 8192, 8192);
|
||||
g_snprintf(port, 255, "%d", 7200 + g_display_num);
|
||||
}
|
||||
|
||||
g_lis_trans->trans_conn_in = my_trans_conn_in;
|
||||
error = trans_listen(g_lis_trans, port);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "setup_listen: trans_listen failed for port %s",
|
||||
port));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -692,12 +763,14 @@ setup_api_listen(void)
|
||||
g_snprintf(port, 255, "/tmp/.xrdp/xrdpapi_%d", g_display_num);
|
||||
g_api_lis_trans->trans_conn_in = my_api_trans_conn_in;
|
||||
error = trans_listen(g_api_lis_trans, port);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "setup_api_listen: trans_listen failed for port %s",
|
||||
port));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -715,6 +788,7 @@ channel_thread_loop(void* in_val)
|
||||
rv = 0;
|
||||
setup_api_listen();
|
||||
error = setup_listen();
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
timeout = -1;
|
||||
@ -723,6 +797,7 @@ channel_thread_loop(void* in_val)
|
||||
num_objs++;
|
||||
trans_get_wait_objs(g_lis_trans, objs, &num_objs);
|
||||
trans_get_wait_objs(g_api_lis_trans, objs, &num_objs);
|
||||
|
||||
while (g_obj_wait(objs, num_objs, 0, 0, timeout) == 0)
|
||||
{
|
||||
if (g_is_wait_obj_set(g_term_event))
|
||||
@ -734,6 +809,7 @@ channel_thread_loop(void* in_val)
|
||||
rail_deinit();
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_lis_trans != 0)
|
||||
{
|
||||
if (trans_check_wait_objs(g_lis_trans) != 0)
|
||||
@ -742,6 +818,7 @@ channel_thread_loop(void* in_val)
|
||||
"trans_check_wait_objs error"));
|
||||
}
|
||||
}
|
||||
|
||||
if (g_con_trans != 0)
|
||||
{
|
||||
if (trans_check_wait_objs(g_con_trans) != 0)
|
||||
@ -757,12 +834,14 @@ channel_thread_loop(void* in_val)
|
||||
g_con_trans = 0;
|
||||
/* create new listener */
|
||||
error = setup_listen();
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (g_api_lis_trans != 0)
|
||||
{
|
||||
if (trans_check_wait_objs(g_api_lis_trans) != 0)
|
||||
@ -772,9 +851,11 @@ channel_thread_loop(void* in_val)
|
||||
}
|
||||
|
||||
LOG(10, ("0 %p", g_api_con_trans));
|
||||
|
||||
if (g_api_con_trans != 0)
|
||||
{
|
||||
LOG(10, ("1 %p %d", g_api_con_trans, g_tcp_can_recv(g_api_con_trans->sck, 0)));
|
||||
|
||||
if (trans_check_wait_objs(g_api_con_trans) != 0)
|
||||
{
|
||||
LOG(10, ("channel_thread_loop: trans_check_wait_objs failed, "
|
||||
@ -801,6 +882,7 @@ channel_thread_loop(void* in_val)
|
||||
dev_redir_get_wait_objs(objs, &num_objs, &timeout);
|
||||
}
|
||||
}
|
||||
|
||||
trans_delete(g_lis_trans);
|
||||
g_lis_trans = 0;
|
||||
trans_delete(g_con_trans);
|
||||
@ -836,16 +918,20 @@ child_signal_handler(int sig)
|
||||
int i1;
|
||||
|
||||
LOG(10, ("child_signal_handler:"));
|
||||
|
||||
do
|
||||
{
|
||||
i1 = g_waitchild();
|
||||
|
||||
if (i1 == g_exec_pid)
|
||||
{
|
||||
LOG(0, ("child_signal_handler: found pid %d", i1));
|
||||
//shutdownx();
|
||||
}
|
||||
|
||||
LOG(10, (" %d", i1));
|
||||
} while (i1 >= 0);
|
||||
}
|
||||
while (i1 >= 0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -870,6 +956,7 @@ get_display_num_from_display(char* display_text)
|
||||
disp_index = 0;
|
||||
scre_index = 0;
|
||||
mode = 0;
|
||||
|
||||
while (display_text[index] != 0)
|
||||
{
|
||||
if (display_text[index] == ':')
|
||||
@ -895,8 +982,10 @@ get_display_num_from_display(char* display_text)
|
||||
scre[scre_index] = display_text[index];
|
||||
scre_index++;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
host[host_index] = 0;
|
||||
disp[disp_index] = 0;
|
||||
scre[scre_index] = 0;
|
||||
@ -934,12 +1023,14 @@ read_ini(void)
|
||||
values->auto_free = 1;
|
||||
g_use_unix_socket = 0;
|
||||
g_snprintf(filename, 255, "%s/sesman.ini", XRDP_CFG_PATH);
|
||||
|
||||
if (file_by_name_read_section(filename, "Globals", names, values) == 0)
|
||||
{
|
||||
for (index = 0; index < names->count; index++)
|
||||
{
|
||||
name = (char *)list_get_item(names, index);
|
||||
value = (char *)list_get_item(values, index);
|
||||
|
||||
if (g_strcasecmp(name, "ListenAddress") == 0)
|
||||
{
|
||||
if (g_strcasecmp(value, "127.0.0.1") == 0)
|
||||
@ -949,6 +1040,7 @@ read_ini(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list_delete(names);
|
||||
list_delete(values);
|
||||
return 0;
|
||||
@ -962,6 +1054,7 @@ run_exec(void)
|
||||
|
||||
LOG(10, ("run_exec:"));
|
||||
pid = g_fork();
|
||||
|
||||
if (pid == 0)
|
||||
{
|
||||
trans_delete(g_con_trans);
|
||||
@ -973,6 +1066,7 @@ run_exec(void)
|
||||
g_execlp3(g_exec_name, g_exec_name, 0);
|
||||
g_exit(0);
|
||||
}
|
||||
|
||||
g_exec_pid = pid;
|
||||
tc_sem_inc(g_exec_sem);
|
||||
|
||||
@ -995,6 +1089,7 @@ main(int argc, char** argv)
|
||||
g_init("xrdp-chansrv"); /* os_calls */
|
||||
|
||||
home_text = g_getenv("HOME");
|
||||
|
||||
if (home_text == 0)
|
||||
{
|
||||
g_writeln("error reading HOME environment variable");
|
||||
@ -1010,16 +1105,19 @@ main(int argc, char** argv)
|
||||
logconfig.program_name = "XRDP-Chansrv";
|
||||
g_snprintf(log_file, 255, "%s/xrdp-chansrv.log", home_text);
|
||||
g_writeln("chansrv::main: using log file [%s]", log_file);
|
||||
|
||||
if (g_file_exist(log_file))
|
||||
{
|
||||
g_file_delete(log_file);
|
||||
}
|
||||
|
||||
logconfig.log_file = log_file;
|
||||
logconfig.fd = -1;
|
||||
logconfig.log_level = LOG_LEVEL_ERROR;
|
||||
logconfig.enable_syslog = 0;
|
||||
logconfig.syslog_level = 0;
|
||||
error = log_start_from_param(&logconfig);
|
||||
|
||||
if (error != LOG_STARTUP_OK)
|
||||
{
|
||||
switch (error)
|
||||
@ -1035,9 +1133,11 @@ main(int argc, char** argv)
|
||||
g_writeln("log_start error");
|
||||
break;
|
||||
}
|
||||
|
||||
g_deinit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_ALWAYS, "main: app started pid %d(0x%8.8x)", pid, pid));
|
||||
/* set up signal handler */
|
||||
g_signal_kill(term_signal_handler); /* SIGKILL */
|
||||
@ -1048,12 +1148,14 @@ main(int argc, char** argv)
|
||||
display_text = g_getenv("DISPLAY");
|
||||
LOGM((LOG_LEVEL_INFO, "main: DISPLAY env var set to %s", display_text));
|
||||
get_display_num_from_display(display_text);
|
||||
|
||||
if (g_display_num == 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "main: error, display is zero"));
|
||||
g_deinit();
|
||||
return 1;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_INFO, "main: using DISPLAY %d", g_display_num));
|
||||
g_snprintf(text, 255, "xrdp_chansrv_%8.8x_main_term", pid);
|
||||
g_term_event = g_create_wait_obj(text);
|
||||
@ -1064,25 +1166,30 @@ main(int argc, char** argv)
|
||||
g_exec_mutex = tc_mutex_create();
|
||||
g_exec_sem = tc_sem_create(0);
|
||||
tc_thread_create(channel_thread_loop, 0);
|
||||
|
||||
while (g_term_event > 0 && !g_is_wait_obj_set(g_term_event))
|
||||
{
|
||||
waiters[0] = g_term_event;
|
||||
waiters[1] = g_exec_event;
|
||||
|
||||
if (g_obj_wait(waiters, 2, 0, 0, 0) != 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "main: error, g_obj_wait failed"));
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_is_wait_obj_set(g_term_event))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_is_wait_obj_set(g_exec_event))
|
||||
{
|
||||
g_reset_wait_obj(g_exec_event);
|
||||
run_exec();
|
||||
}
|
||||
}
|
||||
|
||||
while (g_thread_done_event > 0 && !g_is_wait_obj_set(g_thread_done_event))
|
||||
{
|
||||
/* wait for thread to exit */
|
||||
@ -1092,6 +1199,7 @@ main(int argc, char** argv)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
main_cleanup();
|
||||
LOGM((LOG_LEVEL_INFO, "main: app exiting pid %d(0x%8.8x)", pid, pid));
|
||||
|
@ -116,11 +116,14 @@ clipboard_get_server_time(void)
|
||||
no_text[0] = 0;
|
||||
XChangeProperty(g_display, g_wnd, g_get_time_atom, XA_STRING, 8,
|
||||
PropModeAppend, no_text, 0);
|
||||
|
||||
/* wait for PropertyNotify */
|
||||
do
|
||||
{
|
||||
XMaskEvent(g_display, PropertyChangeMask, &xevent);
|
||||
} while (xevent.type != PropertyNotify);
|
||||
}
|
||||
while (xevent.type != PropertyNotify);
|
||||
|
||||
return xevent.xproperty.time;
|
||||
}
|
||||
|
||||
@ -150,22 +153,27 @@ clipboard_init(void)
|
||||
Status st;
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "xrdp-chansrv: in clipboard_init"));
|
||||
|
||||
if (g_clip_up)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
xcommon_init();
|
||||
clipboard_deinit();
|
||||
rv = 0;
|
||||
|
||||
if (rv == 0)
|
||||
{
|
||||
g_clipboard_atom = XInternAtom(g_display, "CLIPBOARD", False);
|
||||
|
||||
if (g_clipboard_atom == None)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "clipboard_init: XInternAtom failed"));
|
||||
rv = 3;
|
||||
}
|
||||
}
|
||||
|
||||
if (rv == 0)
|
||||
{
|
||||
if (!XFixesQueryExtension(g_display, &g_xfixes_event_base, &dummy))
|
||||
@ -174,6 +182,7 @@ clipboard_init(void)
|
||||
rv = 5;
|
||||
}
|
||||
}
|
||||
|
||||
if (rv == 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_DEBUG, "clipboard_init: g_xfixes_event_base %d",
|
||||
@ -194,6 +203,7 @@ clipboard_init(void)
|
||||
|
||||
g_image_bmp_atom = XInternAtom(g_display, "image/bmp", False);
|
||||
g_incr_atom = XInternAtom(g_display, "INCR", False);
|
||||
|
||||
if (g_image_bmp_atom == None)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "clipboard_init: g_image_bmp_atom was "
|
||||
@ -211,6 +221,7 @@ clipboard_init(void)
|
||||
XFixesSelectionWindowDestroyNotifyMask |
|
||||
XFixesSelectionClientCloseNotifyMask);
|
||||
}
|
||||
|
||||
if (rv == 0)
|
||||
{
|
||||
make_stream(s);
|
||||
@ -224,14 +235,17 @@ clipboard_init(void)
|
||||
LOGM((LOG_LEVEL_DEBUG, "clipboard_init: data out, sending "
|
||||
"CLIPRDR_CONNECT (clip_msg_id = 1)"));
|
||||
rv = send_channel_data(g_cliprdr_chan_id, s->data, size);
|
||||
|
||||
if (rv != 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "clipboard_init: send_channel_data failed "
|
||||
"rv = %d", rv));
|
||||
rv = 4;
|
||||
}
|
||||
|
||||
free_stream(s);
|
||||
}
|
||||
|
||||
if (rv == 0)
|
||||
{
|
||||
g_clip_up = 1;
|
||||
@ -242,6 +256,7 @@ clipboard_init(void)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "xrdp-chansrv: clipboard_init: error on exit"));
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -254,6 +269,7 @@ clipboard_deinit(void)
|
||||
XDestroyWindow(g_display, g_wnd);
|
||||
g_wnd = 0;
|
||||
}
|
||||
|
||||
g_free(g_last_clip_data);
|
||||
g_last_clip_data = 0;
|
||||
g_last_clip_size = 0;
|
||||
@ -272,12 +288,14 @@ clipboard_send_data_request(void)
|
||||
int rv;
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "clipboard_send_data_request:"));
|
||||
|
||||
if (!g_got_format_announce)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "clipboard_send_data_request: error, "
|
||||
"no format announce"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_got_format_announce = 0;
|
||||
make_stream(s);
|
||||
init_stream(s, 8192);
|
||||
@ -362,19 +380,24 @@ clipboard_out_unicode(struct stream* s, char* text, int num_chars)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
lnum_chars = g_mbstowcs(0, text, num_chars);
|
||||
|
||||
if (lnum_chars < 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ltext = g_malloc((num_chars + 1) * sizeof(twchar), 1);
|
||||
g_mbstowcs(ltext, text, num_chars);
|
||||
index = 0;
|
||||
|
||||
while (index < num_chars)
|
||||
{
|
||||
out_uint16_le(s, ltext[index]);
|
||||
index++;
|
||||
}
|
||||
|
||||
g_free(ltext);
|
||||
return index * 2;
|
||||
}
|
||||
@ -394,12 +417,14 @@ clipboard_send_data_response_for_image(void)
|
||||
out_uint16_le(s, 5); /* CLIPRDR_DATA_RESPONSE */
|
||||
out_uint16_le(s, 1); /* status */
|
||||
out_uint32_le(s, g_last_clip_size); /* length */
|
||||
|
||||
/* insert image data */
|
||||
if (g_last_clip_type == g_image_bmp_atom)
|
||||
{
|
||||
/* do not insert first header */
|
||||
out_uint8p(s, g_last_clip_data + 14, g_last_clip_size - 14);
|
||||
}
|
||||
|
||||
out_uint16_le(s, 0); /* nil for string */
|
||||
out_uint32_le(s, 0);
|
||||
out_uint32_le(s, 0);
|
||||
@ -423,15 +448,18 @@ clipboard_send_data_response(void)
|
||||
|
||||
LOG(10, ("clipboard_send_data_response:"));
|
||||
num_chars = 0;
|
||||
|
||||
if (g_last_clip_data != 0)
|
||||
{
|
||||
if (g_last_clip_type == g_image_bmp_atom)
|
||||
{
|
||||
return clipboard_send_data_response_for_image();
|
||||
}
|
||||
|
||||
if ((g_last_clip_type == XA_STRING) || (g_last_clip_type == g_utf8_atom))
|
||||
{
|
||||
num_chars = g_mbstowcs(0, g_last_clip_data, 0);
|
||||
|
||||
if (num_chars < 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "clipboard_send_data_response: bad string"));
|
||||
@ -439,6 +467,7 @@ clipboard_send_data_response(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LOG(10, ("clipboard_send_data_response: g_last_clip_size %d "
|
||||
"num_chars %d", g_last_clip_size, num_chars));
|
||||
make_stream(s);
|
||||
@ -446,11 +475,13 @@ clipboard_send_data_response(void)
|
||||
out_uint16_le(s, 5); /* CLIPRDR_DATA_RESPONSE */
|
||||
out_uint16_le(s, 1); /* status */
|
||||
out_uint32_le(s, num_chars * 2 + 2); /* length */
|
||||
|
||||
if (clipboard_out_unicode(s, g_last_clip_data, num_chars) != num_chars * 2)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "clipboard_send_data_response: error "
|
||||
"clipboard_out_unicode didn't write right number of bytes"));
|
||||
}
|
||||
|
||||
out_uint16_le(s, 0); /* nil for string */
|
||||
out_uint32_le(s, 0);
|
||||
s_mark_end(s);
|
||||
@ -472,11 +503,13 @@ clipboard_set_selection_owner(void)
|
||||
g_selection_time = clipboard_get_server_time();
|
||||
XSetSelectionOwner(g_display, g_clipboard_atom, g_wnd, g_selection_time);
|
||||
owner = XGetSelectionOwner(g_display, g_clipboard_atom);
|
||||
|
||||
if (owner != g_wnd)
|
||||
{
|
||||
g_got_selection = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_got_selection = 1;
|
||||
return 0;
|
||||
}
|
||||
@ -536,11 +569,13 @@ clipboard_process_format_announce(struct stream* s, int clip_msg_status,
|
||||
clipboard_send_format_ack();
|
||||
g_got_format_announce = 1;
|
||||
g_data_in_up_to_date = 0;
|
||||
|
||||
if (clipboard_set_selection_owner() != 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "clipboard_process_format_announce: "
|
||||
"XSetSelectionOwner failed"));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -590,19 +625,23 @@ clipboard_process_data_response_for_image(struct stream * s,
|
||||
"CLIPRDR_DATA_RESPONSE_FOR_IMAGE"));
|
||||
g_waiting_for_data_response = 0;
|
||||
len = (int)(s->end - s->p);
|
||||
|
||||
if (len < 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_last_clip_type == g_image_bmp_atom)
|
||||
{
|
||||
/* space for inserting bmp image header */
|
||||
len += 14;
|
||||
cptr = (char *)g_malloc(len, 0);
|
||||
|
||||
if (cptr == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_memcpy(cptr, g_bmp_image_header, 14);
|
||||
index = 14;
|
||||
}
|
||||
@ -610,11 +649,13 @@ clipboard_process_data_response_for_image(struct stream * s,
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (s_check(s))
|
||||
{
|
||||
in_uint8(s, cdata);
|
||||
cptr[index++] = cdata;
|
||||
}
|
||||
|
||||
if (len >= 0)
|
||||
{
|
||||
g_data_in = cptr;
|
||||
@ -622,6 +663,7 @@ clipboard_process_data_response_for_image(struct stream * s,
|
||||
g_data_in_time = clipboard_get_local_time();
|
||||
g_data_in_up_to_date = 1;
|
||||
}
|
||||
|
||||
clipboard_provide_selection(lxev, lxev->target, 8, cptr, len);
|
||||
return 0;
|
||||
}
|
||||
@ -649,53 +691,67 @@ clipboard_process_data_response(struct stream* s, int clip_msg_status,
|
||||
clipboard_process_data_response_for_image(s, clip_msg_status, clip_msg_len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
LOGM((LOG_LEVEL_DEBUG, "clipboard_process_data_response: "
|
||||
"CLIPRDR_DATA_RESPONSE"));
|
||||
g_waiting_for_data_response = 0;
|
||||
len = (int)(s->end - s->p);
|
||||
|
||||
if (len < 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
//g_hexdump(s->p, len);
|
||||
wtext = (twchar *)g_malloc(((len / 2) + 1) * sizeof(twchar), 0);
|
||||
|
||||
if (wtext == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
index = 0;
|
||||
|
||||
while (s_check(s))
|
||||
{
|
||||
in_uint16_le(s, wchr);
|
||||
wtext[index] = wchr;
|
||||
|
||||
if (wchr == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
index++;
|
||||
}
|
||||
|
||||
wtext[index] = 0;
|
||||
g_free(g_data_in);
|
||||
g_data_in = 0;
|
||||
g_data_in_size = 0;
|
||||
g_data_in_time = 0;
|
||||
len = g_wcstombs(0, wtext, 0);
|
||||
|
||||
if (len >= 0)
|
||||
{
|
||||
g_data_in = (char *)g_malloc(len + 16, 0);
|
||||
|
||||
if (g_data_in == 0)
|
||||
{
|
||||
g_free(wtext);
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_data_in_size = len;
|
||||
g_wcstombs(g_data_in, wtext, len + 1);
|
||||
g_data_in_time = xcommon_get_local_time();
|
||||
g_data_in_up_to_date = 1;
|
||||
}
|
||||
|
||||
if (g_data_in != 0)
|
||||
{
|
||||
data_in_len = g_strlen(g_data_in);
|
||||
|
||||
for (index = 0; index < g_selection_request_event_count; index++)
|
||||
{
|
||||
lxev = &(g_selection_request_event[index]);
|
||||
@ -705,6 +761,7 @@ clipboard_process_data_response(struct stream* s, int clip_msg_status,
|
||||
"data_in_len %d", lxev->requestor, data_in_len));
|
||||
}
|
||||
}
|
||||
|
||||
g_selection_request_event_count = 0;
|
||||
g_free(wtext);
|
||||
return 0;
|
||||
@ -724,6 +781,7 @@ clipboard_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
LOG(10, ("clipboard_data_in: chan_is %d "
|
||||
"chan_flags %d length %d total_length %d",
|
||||
chan_id, chan_flags, length, total_length));
|
||||
|
||||
if ((chan_flags & 3) == 3)
|
||||
{
|
||||
ls = s;
|
||||
@ -734,14 +792,18 @@ clipboard_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
{
|
||||
init_stream(g_ins, total_length);
|
||||
}
|
||||
|
||||
in_uint8a(s, g_ins->end, length);
|
||||
g_ins->end += length;
|
||||
|
||||
if ((chan_flags & 2) == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
ls = g_ins;
|
||||
}
|
||||
|
||||
in_uint16_le(ls, clip_msg_id);
|
||||
in_uint16_le(ls, clip_msg_status);
|
||||
in_uint32_le(ls, clip_msg_len);
|
||||
@ -749,6 +811,7 @@ clipboard_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
"clip_msg_status %d clip_msg_len %d",
|
||||
clip_msg_id, clip_msg_status, clip_msg_len));
|
||||
rv = 0;
|
||||
|
||||
switch (clip_msg_id)
|
||||
{
|
||||
/* sent by client or server when its local system clipboard is */
|
||||
@ -784,6 +847,7 @@ clipboard_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
clip_msg_id));
|
||||
break;
|
||||
}
|
||||
|
||||
XFlush(g_display);
|
||||
return rv;
|
||||
}
|
||||
@ -813,6 +877,7 @@ clipboard_event_selection_owner_notify(XEvent* xevent)
|
||||
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_owner_notify: "
|
||||
"window %d subtype %d owner %d g_wnd %d",
|
||||
lxevent->window, lxevent->subtype, lxevent->owner, g_wnd));
|
||||
|
||||
if (lxevent->owner == g_wnd)
|
||||
{
|
||||
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_owner_notify: skipping, "
|
||||
@ -820,6 +885,7 @@ clipboard_event_selection_owner_notify(XEvent* xevent)
|
||||
g_got_selection = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_got_selection = 0;
|
||||
XConvertSelection(g_display, g_clipboard_atom, g_targets_atom,
|
||||
g_clip_property_atom, g_wnd, lxevent->timestamp);
|
||||
@ -845,10 +911,12 @@ clipboard_get_window_property(Window wnd, Atom prop, Atom* type, int* fmt,
|
||||
XGetWindowProperty(g_display, g_wnd, prop, 0, 0, 0,
|
||||
AnyPropertyType, <ype, &lfmt, &ln_items,
|
||||
&llen_after, &lxdata);
|
||||
|
||||
if (lxdata != 0)
|
||||
{
|
||||
XFree(lxdata);
|
||||
}
|
||||
|
||||
if (ltype == 0)
|
||||
{
|
||||
/* XGetWindowProperty failed */
|
||||
@ -872,11 +940,13 @@ clipboard_get_window_property(Window wnd, Atom prop, Atom* type, int* fmt,
|
||||
/* no data, ok */
|
||||
return 0;
|
||||
}
|
||||
|
||||
lxdata = 0;
|
||||
ltype = 0;
|
||||
XGetWindowProperty(g_display, g_wnd, prop, 0, (llen_after + 3) / 4, 0,
|
||||
AnyPropertyType, <ype, &lfmt, &ln_items,
|
||||
&llen_after, &lxdata);
|
||||
|
||||
if (ltype == 0)
|
||||
{
|
||||
/* XGetWindowProperty failed */
|
||||
@ -884,9 +954,12 @@ clipboard_get_window_property(Window wnd, Atom prop, Atom* type, int* fmt,
|
||||
{
|
||||
XFree(lxdata);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
lxdata_size = (lfmt / 8) * ln_items;
|
||||
|
||||
if (lxdata_size < 1)
|
||||
{
|
||||
/* should not happen */
|
||||
@ -894,8 +967,10 @@ clipboard_get_window_property(Window wnd, Atom prop, Atom* type, int* fmt,
|
||||
{
|
||||
XFree(lxdata);
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (llen_after > 0)
|
||||
{
|
||||
/* should not happen */
|
||||
@ -903,33 +978,41 @@ clipboard_get_window_property(Window wnd, Atom prop, Atom* type, int* fmt,
|
||||
{
|
||||
XFree(lxdata);
|
||||
}
|
||||
|
||||
return 3;
|
||||
}
|
||||
|
||||
if (xdata != 0)
|
||||
{
|
||||
*xdata = (char *)g_malloc(lxdata_size, 0);
|
||||
g_memcpy(*xdata, lxdata, lxdata_size);
|
||||
}
|
||||
|
||||
if (lxdata != 0)
|
||||
{
|
||||
XFree(lxdata);
|
||||
}
|
||||
|
||||
if (xdata_size != 0)
|
||||
{
|
||||
*xdata_size = lxdata_size;
|
||||
}
|
||||
|
||||
if (fmt != 0)
|
||||
{
|
||||
*fmt = (int)lfmt;
|
||||
}
|
||||
|
||||
if (n_items != 0)
|
||||
{
|
||||
*n_items = (int)ln_items;
|
||||
}
|
||||
|
||||
if (type != 0)
|
||||
{
|
||||
*type = ltype;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -981,12 +1064,14 @@ clipboard_event_selection_notify(XEvent* xevent)
|
||||
type = 0;
|
||||
lxevent = (XSelectionEvent *)xevent;
|
||||
g_memset(format_name, 0, 32);
|
||||
|
||||
if (lxevent->property == None)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_notify: clip could "
|
||||
"not be converted"));
|
||||
rv = 1;
|
||||
}
|
||||
|
||||
if (rv == 0)
|
||||
{
|
||||
/* we need this if the call below turns out to be a
|
||||
@ -999,13 +1084,16 @@ clipboard_event_selection_notify(XEvent* xevent)
|
||||
rv = clipboard_get_window_property(lxevent->requestor, lxevent->property,
|
||||
&type, &fmt,
|
||||
&n_items, &data, &data_size);
|
||||
|
||||
if (rv != 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_notify: "
|
||||
"clipboard_get_window_property failed error %d", rv));
|
||||
}
|
||||
|
||||
XDeleteProperty(g_display, lxevent->requestor, lxevent->property);
|
||||
}
|
||||
|
||||
if (rv == 0)
|
||||
{
|
||||
if (lxevent->selection == g_clipboard_atom)
|
||||
@ -1016,11 +1104,13 @@ clipboard_event_selection_notify(XEvent* xevent)
|
||||
if ((type == XA_ATOM) && (fmt == 32))
|
||||
{
|
||||
atoms = (Atom *)data;
|
||||
|
||||
for (index = 0; index < n_items; index++)
|
||||
{
|
||||
atom = atoms[index];
|
||||
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_notify: %d %s %d",
|
||||
atom, XGetAtomName(g_display, atom), XA_STRING));
|
||||
|
||||
if (atom == g_utf8_atom)
|
||||
{
|
||||
convert_to_utf8 = 1;
|
||||
@ -1096,6 +1186,7 @@ clipboard_event_selection_notify(XEvent* xevent)
|
||||
"unknown selection"));
|
||||
}
|
||||
}
|
||||
|
||||
if (convert_to_utf8)
|
||||
{
|
||||
XConvertSelection(g_display, g_clipboard_atom, g_utf8_atom,
|
||||
@ -1111,6 +1202,7 @@ clipboard_event_selection_notify(XEvent* xevent)
|
||||
XConvertSelection(g_display, g_clipboard_atom, g_image_bmp_atom,
|
||||
g_clip_property_atom, g_wnd, lxevent->time);
|
||||
}
|
||||
|
||||
if (send_format_announce)
|
||||
{
|
||||
if (clipboard_send_format_announce(format_id, format_name) != 0)
|
||||
@ -1118,6 +1210,7 @@ clipboard_event_selection_notify(XEvent* xevent)
|
||||
rv = 4;
|
||||
}
|
||||
}
|
||||
|
||||
g_free(data);
|
||||
return rv;
|
||||
}
|
||||
@ -1160,6 +1253,7 @@ clipboard_event_selection_request(XEvent* xevent)
|
||||
g_wnd, lxev->requestor, lxev->owner, lxev->selection,
|
||||
XGetAtomName(g_display, lxev->selection),
|
||||
lxev->target, lxev->property));
|
||||
|
||||
if (lxev->property == None)
|
||||
{
|
||||
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
|
||||
@ -1191,6 +1285,7 @@ clipboard_event_selection_request(XEvent* xevent)
|
||||
/* target, property pairs */
|
||||
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: "
|
||||
"g_multiple_atom"));
|
||||
|
||||
if (clipboard_get_window_property(xev.xselection.requestor,
|
||||
xev.xselection.property,
|
||||
&type, &fmt, &n_items, &xdata,
|
||||
@ -1207,11 +1302,13 @@ clipboard_event_selection_request(XEvent* xevent)
|
||||
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_selection_request: %s",
|
||||
XGetAtomName(g_display, lxev->target)));
|
||||
clipboard_format_id = CB_FORMAT_UNICODETEXT;
|
||||
|
||||
if (g_data_in_up_to_date)
|
||||
{
|
||||
return clipboard_provide_selection(lxev, lxev->target, 8,
|
||||
g_data_in, g_strlen(g_data_in));
|
||||
}
|
||||
|
||||
if (g_selection_request_event_count > 10)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_request: error, "
|
||||
@ -1221,12 +1318,14 @@ clipboard_event_selection_request(XEvent* xevent)
|
||||
{
|
||||
g_memcpy(&(g_selection_request_event[g_selection_request_event_count]),
|
||||
lxev, sizeof(g_selection_request_event[0]));
|
||||
|
||||
if (g_selection_request_event_count == 0)
|
||||
{
|
||||
clipboard_send_data_request();
|
||||
g_waiting_for_data_response = 1;
|
||||
g_waiting_for_data_response_time = xcommon_get_local_time();
|
||||
}
|
||||
|
||||
g_selection_request_event_count++;
|
||||
return 0;
|
||||
}
|
||||
@ -1248,6 +1347,7 @@ clipboard_event_selection_request(XEvent* xevent)
|
||||
LOGM((LOG_LEVEL_ERROR, "clipboard_event_selection_request: unknown "
|
||||
"target %s", XGetAtomName(g_display, lxev->target)));
|
||||
}
|
||||
|
||||
clipboard_refuse_selection(lxev);
|
||||
return 0;
|
||||
}
|
||||
@ -1300,6 +1400,7 @@ clipboard_event_property_notify(XEvent* xevent)
|
||||
LOG(10, ("clipboard_check_wait_objs: PropertyNotify .window %d "
|
||||
".state %d .atom %d", xevent->xproperty.window,
|
||||
xevent->xproperty.state, xevent->xproperty.atom));
|
||||
|
||||
if (g_incr_in_progress &&
|
||||
(xevent->xproperty.atom == g_incr_atom_type) &&
|
||||
(xevent->xproperty.state == PropertyNewValue))
|
||||
@ -1307,11 +1408,13 @@ clipboard_event_property_notify(XEvent* xevent)
|
||||
rv = XGetWindowProperty(g_display, g_wnd, g_incr_atom_type, 0, 0, 0,
|
||||
AnyPropertyType, &actual_type_return, &actual_format_return,
|
||||
&nitems_returned, &bytes_left, (unsigned char **) &data);
|
||||
|
||||
if (data != 0)
|
||||
{
|
||||
XFree(data);
|
||||
data = 0;
|
||||
}
|
||||
|
||||
if (bytes_left <= 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_DEBUG, "clipboard_event_property_notify: INCR done"));
|
||||
@ -1322,11 +1425,13 @@ clipboard_event_property_notify(XEvent* xevent)
|
||||
g_last_clip_data = g_incr_data;
|
||||
g_incr_data = 0;
|
||||
g_last_clip_type = g_incr_atom_target;
|
||||
|
||||
if (g_incr_atom_target == g_image_bmp_atom)
|
||||
{
|
||||
g_snprintf(format_name, 31, "image/bmp");
|
||||
clipboard_send_format_announce(CB_FORMAT_DIB, format_name);
|
||||
}
|
||||
|
||||
XDeleteProperty(g_display, g_wnd, g_incr_atom_type);
|
||||
}
|
||||
else
|
||||
@ -1336,36 +1441,45 @@ clipboard_event_property_notify(XEvent* xevent)
|
||||
&nitems_returned, &bytes_left, (unsigned char **) &data);
|
||||
|
||||
format_in_bytes = actual_format_return / 8;
|
||||
|
||||
if ((actual_format_return == 32) && (sizeof(long) == 8))
|
||||
{
|
||||
/* on a 64 bit machine, actual_format_return of 32 implies long */
|
||||
format_in_bytes = 8;
|
||||
}
|
||||
|
||||
new_data_len = nitems_returned * format_in_bytes;
|
||||
cptr = (char *)g_malloc(g_incr_data_size + new_data_len, 0);
|
||||
g_memcpy(cptr, g_incr_data, g_incr_data_size);
|
||||
g_free(g_incr_data);
|
||||
|
||||
if (cptr == NULL)
|
||||
{
|
||||
g_incr_data = 0;
|
||||
|
||||
/* cannot add any more data */
|
||||
if (data != 0)
|
||||
{
|
||||
XFree(data);
|
||||
}
|
||||
|
||||
XDeleteProperty(g_display, g_wnd, g_incr_atom_type);
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_incr_data = cptr;
|
||||
g_memcpy(g_incr_data + g_incr_data_size, data, new_data_len);
|
||||
g_incr_data_size += new_data_len;
|
||||
|
||||
if (data)
|
||||
{
|
||||
XFree(data);
|
||||
}
|
||||
|
||||
XDeleteProperty(g_display, g_wnd, g_incr_atom_type);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1380,7 +1494,9 @@ clipboard_xevent(void* xevent)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
lxevent = (XEvent *)xevent;
|
||||
|
||||
switch (lxevent->type)
|
||||
{
|
||||
case SelectionNotify:
|
||||
@ -1404,14 +1520,17 @@ clipboard_xevent(void* xevent)
|
||||
LOG(0, ("chansrv::clipboard_xevent: got ClientMessage"));
|
||||
break;
|
||||
default:
|
||||
|
||||
if (lxevent->type == g_xfixes_event_base +
|
||||
XFixesSetSelectionOwnerNotify)
|
||||
{
|
||||
clipboard_event_selection_owner_notify(lxevent);
|
||||
break;
|
||||
}
|
||||
|
||||
/* we didn't handle this message */
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -114,6 +114,7 @@ is_window_valid_child_of_root(unsigned int window_id)
|
||||
|
||||
found = 0;
|
||||
XQueryTree(g_display, g_root_window, &r, &p, &children, &nchild);
|
||||
|
||||
for (i = 0; i < nchild; i++)
|
||||
{
|
||||
if (window_id == children[i])
|
||||
@ -122,6 +123,7 @@ is_window_valid_child_of_root(unsigned int window_id)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XFree(children);
|
||||
return found;
|
||||
}
|
||||
@ -175,10 +177,12 @@ rail_is_another_wm_running(void)
|
||||
XSync(g_display, 0);
|
||||
XSetErrorHandler((XErrorHandler)old);
|
||||
g_rail_up = g_rail_running;
|
||||
|
||||
if (!g_rail_up)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -188,11 +192,13 @@ rail_init(void)
|
||||
{
|
||||
LOG(10, ("chansrv::rail_init:"));
|
||||
xcommon_init();
|
||||
|
||||
if (rail_is_another_wm_running())
|
||||
{
|
||||
log_message(LOG_LEVEL_ERROR, "rail_init: another window manager "
|
||||
"is running");
|
||||
}
|
||||
|
||||
rail_send_init();
|
||||
g_rail_up = 1;
|
||||
return 0;
|
||||
@ -208,6 +214,7 @@ rail_deinit(void)
|
||||
XSelectInput(g_display, g_root_window, 0);
|
||||
g_rail_up = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -222,15 +229,19 @@ read_uni(struct stream* s, int num_chars)
|
||||
|
||||
rchrs = 0;
|
||||
rv = 0;
|
||||
|
||||
if (num_chars > 0)
|
||||
{
|
||||
rchrs = (twchar *)g_malloc((num_chars + 1) * sizeof(twchar), 0);
|
||||
|
||||
for (index = 0; index < num_chars; index++)
|
||||
{
|
||||
in_uint16_le(s, rchrs[index]);
|
||||
}
|
||||
|
||||
rchrs[num_chars] = 0;
|
||||
lchars = g_wcstombs(0, rchrs, 0);
|
||||
|
||||
if (lchars > 0)
|
||||
{
|
||||
rv = (char *)g_malloc((lchars + 1) * 4, 0);
|
||||
@ -238,6 +249,7 @@ read_uni(struct stream* s, int num_chars)
|
||||
rv[lchars] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
g_free(rchrs);
|
||||
return rv;
|
||||
}
|
||||
@ -267,6 +279,7 @@ rail_process_exec(struct stream* s, int size)
|
||||
"ArgumentsLen %d ExeOrFile [%s] WorkingDir [%s] "
|
||||
"Arguments [%s]", flags, ExeOrFileLength, WorkingDirLength,
|
||||
ArgumentsLen, ExeOrFile, WorkingDir, Arguments));
|
||||
|
||||
if (g_strlen(ExeOrFile) > 0)
|
||||
{
|
||||
LOG(10, ("rail_process_exec: pre"));
|
||||
@ -278,6 +291,7 @@ rail_process_exec(struct stream* s, int size)
|
||||
tc_mutex_unlock(g_exec_mutex);
|
||||
LOG(10, ("rail_process_exec: post"));
|
||||
}
|
||||
|
||||
g_free(ExeOrFile);
|
||||
g_free(WorkingDir);
|
||||
g_free(Arguments);
|
||||
@ -295,6 +309,7 @@ rail_process_activate(struct stream* s, int size)
|
||||
in_uint32_le(s, window_id);
|
||||
in_uint8(s, enabled);
|
||||
LOG(10, (" window_id 0x%8.8x enabled %d", window_id, enabled));
|
||||
|
||||
if (enabled)
|
||||
{
|
||||
LOG(10, ("chansrv::rail_process_activate: calling XRaiseWindow 0x%8.8x", window_id));
|
||||
@ -302,6 +317,7 @@ rail_process_activate(struct stream* s, int size)
|
||||
LOG(10, ("chansrv::rail_process_activate: calling XSetInputFocus 0x%8.8x", window_id));
|
||||
XSetInputFocus(g_display, window_id, RevertToParent, CurrentTime);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -346,6 +362,7 @@ rail_process_system_command(struct stream* s, int size)
|
||||
LOG(10, ("chansrv::rail_process_system_command:"));
|
||||
in_uint32_le(s, window_id);
|
||||
in_uint16_le(s, command);
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case SC_SIZE:
|
||||
@ -378,6 +395,7 @@ rail_process_system_command(struct stream* s, int size)
|
||||
window_id, command));
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -541,6 +559,7 @@ rail_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
in_uint8(s, code);
|
||||
in_uint8s(s, 1);
|
||||
in_uint16_le(s, size);
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case TS_RAIL_ORDER_EXEC: /* 1 */
|
||||
@ -592,6 +611,7 @@ rail_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
LOG(10, ("rail_data_in: unknown code %d size %d", code, size));
|
||||
break;
|
||||
}
|
||||
|
||||
XFlush(g_display);
|
||||
return 0;
|
||||
}
|
||||
@ -613,12 +633,15 @@ rail_xevent(void* xevent)
|
||||
XWindowAttributes wnd_attributes;
|
||||
|
||||
LOG(10, ("chansrv::rail_xevent:"));
|
||||
|
||||
if (!g_rail_up)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
rv = 1;
|
||||
lxevent = (XEvent *)xevent;
|
||||
|
||||
switch (lxevent->type)
|
||||
{
|
||||
case ConfigureRequest:
|
||||
@ -673,5 +696,6 @@ rail_xevent(void* xevent)
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -139,16 +139,20 @@ sound_process_formats(struct stream* s, int size)
|
||||
print_got_here();
|
||||
|
||||
LOG(0, ("sound_process_formats:"));
|
||||
|
||||
if (size < 16)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
in_uint8s(s, 14);
|
||||
in_uint16_le(s, num_formats);
|
||||
|
||||
if (num_formats > 0)
|
||||
{
|
||||
sound_send_training();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -263,24 +267,30 @@ sound_trans_audio_data_in(struct trans* trans)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (trans != g_audio_c_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
s = trans_get_in_s(trans);
|
||||
in_uint32_le(s, id);
|
||||
in_uint32_le(s, size);
|
||||
|
||||
if ((id != 0) || (size > 32 * 1024 + 8) || (size < 1))
|
||||
{
|
||||
LOG(0, ("sound_trans_audio_data_in: bad message id %d size %d", id, size));
|
||||
return 1;
|
||||
}
|
||||
|
||||
error = trans_force_read(trans, size - 8);
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
/* here, the entire message block is read in, process it */
|
||||
error = process_pcm_message(id, size - 8, s);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@ -294,18 +304,22 @@ sound_trans_audio_conn_in(struct trans *trans, struct trans *new_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (trans != g_audio_l_trans)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (g_audio_c_trans != 0) /* if already set, error */
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (new_trans == 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_audio_c_trans = new_trans;
|
||||
g_audio_c_trans->trans_data_in = sound_trans_audio_data_in;
|
||||
g_audio_c_trans->header_size = 8;
|
||||
@ -329,6 +343,7 @@ sound_init(void)
|
||||
g_snprintf(port, 255, "/tmp/xrdp_chansrv_audio_socket_%d", g_display_num);
|
||||
g_audio_l_trans->trans_conn_in = sound_trans_audio_conn_in;
|
||||
error = trans_listen(g_audio_l_trans, port);
|
||||
|
||||
if (error != 0)
|
||||
{
|
||||
LOG(0, ("sound_init: trans_listen failed"));
|
||||
@ -355,6 +370,7 @@ sound_deinit(void)
|
||||
trans_delete(g_audio_l_trans);
|
||||
g_audio_l_trans = 0;
|
||||
}
|
||||
|
||||
if (g_audio_c_trans != 0)
|
||||
{
|
||||
trans_delete(g_audio_c_trans);
|
||||
@ -378,6 +394,7 @@ sound_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
in_uint8(s, code);
|
||||
in_uint8s(s, 1);
|
||||
in_uint16_le(s, size);
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case SNDC_WAVECONFIRM:
|
||||
@ -396,6 +413,7 @@ sound_data_in(struct stream* s, int chan_id, int chan_flags, int length,
|
||||
LOG(0, ("sound_data_in: unknown code %d size %d", code, size));
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -406,16 +424,19 @@ sound_get_wait_objs(tbus* objs, int* count, int* timeout)
|
||||
int lcount;
|
||||
|
||||
lcount = *count;
|
||||
|
||||
if (g_audio_l_trans != 0)
|
||||
{
|
||||
objs[lcount] = g_audio_l_trans->sck;
|
||||
lcount++;
|
||||
}
|
||||
|
||||
if (g_audio_c_trans != 0)
|
||||
{
|
||||
objs[lcount] = g_audio_c_trans->sck;
|
||||
lcount++;
|
||||
}
|
||||
|
||||
*count = lcount;
|
||||
return 0;
|
||||
}
|
||||
@ -465,13 +486,16 @@ read_raw_audio_data(void* arg)
|
||||
struct stream *outs;
|
||||
|
||||
strans = trans_create(TRANS_MODE_UNIX, 8192, 8192);
|
||||
|
||||
if (strans == 0)
|
||||
{
|
||||
LOG(0, ("read_raw_audio_data: trans_create failed\n"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
strans->trans_data_in = sttrans_data_in;
|
||||
g_snprintf(path, 255, "/tmp/xrdp_chansrv_audio_socket_%d", g_display_num);
|
||||
|
||||
if (trans_connect(strans, "", path, 100) != 0)
|
||||
{
|
||||
LOG(0, ("read_raw_audio_data: trans_connect failed\n"));
|
||||
@ -493,12 +517,14 @@ read_raw_audio_data(void* arg)
|
||||
{
|
||||
simple = pa_simple_new(NULL, "xrdp", PA_STREAM_RECORD, NULL,
|
||||
"record", &samp_spec, NULL, NULL, &error);
|
||||
|
||||
if (simple)
|
||||
{
|
||||
/* connected to pulseaudio server */
|
||||
LOG(0, ("read_raw_audio_data: connected to pulseaudio server\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
LOG(0, ("read_raw_audio_data: ERROR creating PulseAudio async interface\n"));
|
||||
LOG(0, ("read_raw_audio_data: %s\n", pa_strerror(error)));
|
||||
g_sleep(1000);
|
||||
@ -524,12 +550,14 @@ read_raw_audio_data(void* arg)
|
||||
/* read a block of raw audio data... */
|
||||
g_memset(cptr, 0, 4);
|
||||
bytes_read = pa_simple_read(simple, cptr, AUDIO_BUF_SIZE, &error);
|
||||
|
||||
if (bytes_read < 0)
|
||||
{
|
||||
LOG(0, ("read_raw_audio_data: ERROR reading from pulseaudio stream\n"));
|
||||
LOG(0, ("read_raw_audio_data: %s\n", pa_strerror(error)));
|
||||
break;
|
||||
}
|
||||
|
||||
/* bug workaround:
|
||||
even when there is no audio data, pulseaudio is returning without
|
||||
errors but the data itself is zero; we use this zero data to
|
||||
@ -539,12 +567,14 @@ read_raw_audio_data(void* arg)
|
||||
g_sleep(10);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (trans_force_write_s(strans, outs) != 0)
|
||||
{
|
||||
LOG(0, ("read_raw_audio_data: ERROR writing audio data to server\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
pa_simple_free(simple);
|
||||
trans_delete(strans);
|
||||
return NULL;
|
||||
|
@ -84,7 +84,9 @@ xcommon_init(void)
|
||||
LOG(10, ("xcommon_init: xcommon_init already called"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
g_display = XOpenDisplay(0);
|
||||
|
||||
if (g_display == 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "xcommon_init: error, XOpenDisplay failed"));
|
||||
@ -99,6 +101,7 @@ xcommon_init(void)
|
||||
//XSetIOErrorHandler(xcommon_fatal_handler);
|
||||
|
||||
g_x_socket = XConnectionNumber(g_display);
|
||||
|
||||
if (g_x_socket == 0)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "xcommon_init: XConnectionNumber failed"));
|
||||
@ -131,6 +134,7 @@ xcommon_get_wait_objs(tbus* objs, int* count, int* timeout)
|
||||
LOG(10, ("xcommon_get_wait_objs: nothing to do"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
lcount = *count;
|
||||
objs[lcount] = g_x_wait_obj;
|
||||
lcount++;
|
||||
@ -152,6 +156,7 @@ xcommon_check_wait_objs(void)
|
||||
LOG(10, ("xcommon_check_wait_objs: nothing to do"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_is_wait_obj_set(g_x_wait_obj))
|
||||
{
|
||||
if (XPending(g_display) < 1)
|
||||
@ -160,16 +165,19 @@ xcommon_check_wait_objs(void)
|
||||
LOGM((LOG_LEVEL_ERROR, "xcommon_check_wait_objs: sck closed"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (g_waiting_for_data_response)
|
||||
{
|
||||
time_diff = xcommon_get_local_time() -
|
||||
g_waiting_for_data_response_time;
|
||||
|
||||
if (time_diff > 10000)
|
||||
{
|
||||
LOGM((LOG_LEVEL_ERROR, "xcommon_check_wait_objs: warning, "
|
||||
"waiting for data response too long"));
|
||||
}
|
||||
}
|
||||
|
||||
while (XPending(g_display) > 0)
|
||||
{
|
||||
g_memset(&xevent, 0, sizeof(xevent));
|
||||
@ -177,11 +185,13 @@ xcommon_check_wait_objs(void)
|
||||
|
||||
clip_rv = clipboard_xevent(&xevent);
|
||||
rail_rv = rail_xevent(&xevent);
|
||||
|
||||
if ((clip_rv == 1) && (rail_rv == 1))
|
||||
{
|
||||
LOG(10, ("xcommon_check_wait_objs unknown xevent type %d", xevent.type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -47,6 +46,7 @@ config_read(struct config_sesman* cfg)
|
||||
|
||||
g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH);
|
||||
fd = g_file_open(cfg_file);
|
||||
|
||||
if (-1 == fd)
|
||||
{
|
||||
//if (g_cfg->log.fd >= 0)
|
||||
@ -61,6 +61,7 @@ config_read(struct config_sesman* cfg)
|
||||
//}
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_memset(cfg, 0, sizeof(struct config_sesman));
|
||||
sec = list_create();
|
||||
sec->auto_free = 1;
|
||||
@ -114,9 +115,11 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n,
|
||||
cf->auth_file_path = 0;
|
||||
|
||||
file_read_section(file, SESMAN_CFG_GLOBALS, param_n, param_v);
|
||||
|
||||
for (i = 0; i < param_n->count; i++)
|
||||
{
|
||||
buf = (char *)list_get_item(param_n, i);
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_DEFWM))
|
||||
{
|
||||
g_strncpy(cf->default_wm, (char *)list_get_item(param_v, i), 31);
|
||||
@ -148,14 +151,17 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n,
|
||||
{
|
||||
g_strncpy(cf->listen_address, "0.0.0.0", 8);
|
||||
}
|
||||
|
||||
if ('\0' == cf->listen_port[0])
|
||||
{
|
||||
g_strncpy(cf->listen_port, "3350", 5);
|
||||
}
|
||||
|
||||
if ('\0' == cf->user_wm[0])
|
||||
{
|
||||
cf->enable_user_wm = 0;
|
||||
}
|
||||
|
||||
if ('\0' == cf->default_wm[0])
|
||||
{
|
||||
g_strncpy(cf->default_wm, "startwm.sh", 11);
|
||||
@ -248,17 +254,21 @@ config_read_security(int file, struct config_security* sc,
|
||||
sc->ts_admins_enable = 0;
|
||||
|
||||
file_read_section(file, SESMAN_CFG_SECURITY, param_n, param_v);
|
||||
|
||||
for (i = 0; i < param_n->count; i++)
|
||||
{
|
||||
buf = (char *)list_get_item(param_n, i);
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_ALLOW_ROOT))
|
||||
{
|
||||
sc->allow_root = text2bool((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_LOGIN_RETRY))
|
||||
{
|
||||
sc->login_retry = g_atoi((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_USR_GROUP))
|
||||
{
|
||||
if (g_getgroup_info((char *)list_get_item(param_v, i), &gid) == 0)
|
||||
@ -267,6 +277,7 @@ config_read_security(int file, struct config_security* sc,
|
||||
sc->ts_users = gid;
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_ADM_GROUP))
|
||||
{
|
||||
if (g_getgroup_info((char *)list_get_item(param_v, i), &gid) == 0)
|
||||
@ -281,6 +292,7 @@ config_read_security(int file, struct config_security* sc,
|
||||
g_printf("security configuration:\r\n");
|
||||
g_printf("\tAllowRootLogin: %i\r\n", sc->allow_root);
|
||||
g_printf("\tMaxLoginRetry: %i\r\n", sc->login_retry);
|
||||
|
||||
if (sc->ts_users_enable)
|
||||
{
|
||||
g_printf("\tTSUsersGroup: %i\r\n", sc->ts_users);
|
||||
@ -289,6 +301,7 @@ config_read_security(int file, struct config_security* sc,
|
||||
{
|
||||
g_printf("\tNo TSUsersGroup defined\r\n");
|
||||
}
|
||||
|
||||
if (sc->ts_admins_enable)
|
||||
{
|
||||
g_printf("\tTSAdminsGroup: %i\r\n", sc->ts_admins);
|
||||
@ -320,25 +333,31 @@ config_read_sessions(int file, struct config_sessions* se, struct list* param_n,
|
||||
se->kill_disconnected = 0;
|
||||
|
||||
file_read_section(file, SESMAN_CFG_SESSIONS, param_n, param_v);
|
||||
|
||||
for (i = 0; i < param_n->count; i++)
|
||||
{
|
||||
buf = (char *)list_get_item(param_n, i);
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_X11DISPLAYOFFSET))
|
||||
{
|
||||
se->x11_display_offset = g_atoi((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_MAX))
|
||||
{
|
||||
se->max_sessions = g_atoi((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_KILL_DISC))
|
||||
{
|
||||
se->kill_disconnected = text2bool((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_IDLE_LIMIT))
|
||||
{
|
||||
se->max_idle_time = g_atoi((char *)list_get_item(param_v, i));
|
||||
}
|
||||
|
||||
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_DISC_LIMIT))
|
||||
{
|
||||
se->max_disc_time = g_atoi((char *)list_get_item(param_v, i));
|
||||
@ -369,6 +388,7 @@ config_read_rdp_params(int file, struct config_sesman* cs, struct list* param_n,
|
||||
cs->rdp_params = list_create();
|
||||
|
||||
file_read_section(file, SESMAN_CFG_RDP_PARAMS, param_n, param_v);
|
||||
|
||||
for (i = 0; i < param_n->count; i++)
|
||||
{
|
||||
list_add_item(cs->rdp_params, (long)g_strdup((char *)list_get_item(param_v, i)));
|
||||
@ -376,6 +396,7 @@ config_read_rdp_params(int file, struct config_sesman* cs, struct list* param_n,
|
||||
|
||||
/* printing security config */
|
||||
g_printf("X11rdp parameters:\r\n");
|
||||
|
||||
for (i = 0; i < cs->rdp_params->count; i++)
|
||||
{
|
||||
g_printf("\tParameter %02d %s\r\n", i, (char *)list_get_item(cs->rdp_params, i));
|
||||
@ -397,6 +418,7 @@ config_read_vnc_params(int file, struct config_sesman* cs, struct list* param_n,
|
||||
cs->vnc_params = list_create();
|
||||
|
||||
file_read_section(file, SESMAN_CFG_VNC_PARAMS, param_n, param_v);
|
||||
|
||||
for (i = 0; i < param_n->count; i++)
|
||||
{
|
||||
list_add_item(cs->vnc_params, (long)g_strdup((char *)list_get_item(param_v, i)));
|
||||
@ -404,6 +426,7 @@ config_read_vnc_params(int file, struct config_sesman* cs, struct list* param_n,
|
||||
|
||||
/* printing security config */
|
||||
g_printf("Xvnc parameters:\r\n");
|
||||
|
||||
for (i = 0; i < cs->vnc_params->count; i++)
|
||||
{
|
||||
g_printf("\tParameter %02d %s\r\n", i, (char *)list_get_item(cs->vnc_params, i));
|
||||
@ -411,4 +434,3 @@ config_read_vnc_params(int file, struct config_sesman* cs, struct list* param_n,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -296,4 +295,3 @@ config_read_vnc_params(int file, struct config_sesman* cs, struct list* param_n,
|
||||
struct list* param_v);
|
||||
|
||||
#endif
|
||||
|
||||
|
43
sesman/env.c
43
sesman/env.c
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -45,6 +44,7 @@ env_check_password_file(char* filename, char* password)
|
||||
rfbDesKey(g_fixedkey, 0);
|
||||
rfbDes((unsigned char *)encryptedPasswd, (unsigned char *)encryptedPasswd);
|
||||
fd = g_file_open(filename);
|
||||
|
||||
if (fd == -1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING,
|
||||
@ -52,6 +52,7 @@ env_check_password_file(char* filename, char* password)
|
||||
filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_file_write(fd, encryptedPasswd, 8);
|
||||
g_file_close(fd);
|
||||
return 0;
|
||||
@ -72,20 +73,25 @@ env_set_user(char* username, char* passwd_file, int display)
|
||||
|
||||
error = g_getuser_info(username, &pw_gid, &pw_uid, pw_shell, pw_dir,
|
||||
pw_gecos);
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
g_rm_temp_dir();
|
||||
error = g_setgid(pw_gid);
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
error = g_initgroups(username, pw_gid);
|
||||
}
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
uid = pw_uid;
|
||||
error = g_setuid(uid);
|
||||
}
|
||||
|
||||
g_mk_temp_dir(0);
|
||||
|
||||
if (error == 0)
|
||||
{
|
||||
g_clearenv();
|
||||
@ -98,6 +104,7 @@ env_set_user(char* username, char* passwd_file, int display)
|
||||
g_set_current_dir(pw_dir);
|
||||
g_sprintf(text, ":%d.0", display);
|
||||
g_setenv("DISPLAY", text, 1);
|
||||
|
||||
if (passwd_file != 0)
|
||||
{
|
||||
if (0 == g_cfg->auth_file_path)
|
||||
@ -112,6 +119,7 @@ env_set_user(char* username, char* passwd_file, int display)
|
||||
/* we use auth_file_path as requested */
|
||||
g_sprintf(passwd_file, g_cfg->auth_file_path, username);
|
||||
}
|
||||
|
||||
LOG_DBG("pass file: %s", passwd_file);
|
||||
}
|
||||
}
|
||||
@ -121,5 +129,6 @@ env_set_user(char* username, char* passwd_file, int display)
|
||||
log_message(LOG_LEVEL_ERROR,
|
||||
"error getting user info for user %s", username);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
34
sesman/env.h
34
sesman/env.h
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -52,4 +51,3 @@ int DEFAULT_CC
|
||||
env_set_user(char* username, char* passwd_file, int display);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -51,4 +50,3 @@ void
|
||||
scp_connection_destroy(struct SCP_CONNECTION* c);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -48,4 +47,3 @@ scp_init()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -45,4 +44,3 @@ int DEFAULT_CC
|
||||
scp_init();
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
session manager
|
||||
linux only
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* session manager
|
||||
* linux only
|
||||
*/
|
||||
|
||||
#include "libscp_lock.h"
|
||||
@ -56,11 +54,13 @@ scp_lock_fork_request(void)
|
||||
{
|
||||
/* lock mutex */
|
||||
pthread_mutex_lock(&lock_fork);
|
||||
|
||||
if (lock_fork_blockers_count == 0)
|
||||
{
|
||||
/* if noone is blocking fork(), then we're allowed to fork */
|
||||
sem_post(&lock_fork_req);
|
||||
}
|
||||
|
||||
lock_fork_forkers_count++;
|
||||
pthread_mutex_unlock(&lock_fork);
|
||||
|
||||
@ -86,6 +86,7 @@ scp_lock_fork_release(void)
|
||||
/* waking up the other processes */
|
||||
sem_post(&lock_fork_wait);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&lock_fork);
|
||||
}
|
||||
|
||||
@ -108,6 +109,7 @@ scp_lock_fork_critical_section_end(int blocking)
|
||||
{
|
||||
sem_post(&lock_fork_req);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&lock_fork);
|
||||
}
|
||||
|
||||
@ -138,9 +140,9 @@ scp_lock_fork_critical_section_start(void)
|
||||
|
||||
return LIBSCP_LOCK_FORK_BLOCKER;
|
||||
}
|
||||
} while (1);
|
||||
}
|
||||
while (1);
|
||||
|
||||
/* we'll never get here */
|
||||
return LIBSCP_LOCK_FORK_WAITING;
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef LIBSCP_LOCK_H
|
||||
@ -72,4 +71,3 @@ void DEFAULT_CC
|
||||
scp_lock_fork_critical_section_end(int blocking);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -40,11 +39,13 @@ scp_session_create()
|
||||
struct SCP_SESSION *s;
|
||||
|
||||
s = (struct SCP_SESSION *)g_malloc(sizeof(struct SCP_SESSION), 1);
|
||||
|
||||
if (0 == s)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] session create: malloc error", __LINE__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@ -66,16 +67,19 @@ scp_session_set_type(struct SCP_SESSION* s, tui8 type)
|
||||
case SCP_SESSION_TYPE_MANAGE:
|
||||
s->type = SCP_SESSION_TYPE_MANAGE;
|
||||
s->mng = (struct SCP_MNG_DATA *)g_malloc(sizeof(struct SCP_MNG_DATA), 1);
|
||||
|
||||
if (NULL == s->mng)
|
||||
{
|
||||
log_message(LOG_LEVEL_ERROR, "[session:%d] set_type: internal error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_type: unknown type", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -95,6 +99,7 @@ scp_session_set_version(struct SCP_SESSION* s, tui32 version)
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_version: unknown version", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -128,6 +133,7 @@ scp_session_set_bpp(struct SCP_SESSION* s, tui8 bpp)
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -143,6 +149,7 @@ scp_session_set_rsr(struct SCP_SESSION* s, tui8 rsr)
|
||||
{
|
||||
s->rsr = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -156,6 +163,7 @@ scp_session_set_locale(struct SCP_SESSION* s, char* str)
|
||||
s->locale[0] = '\0';
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_strncpy(s->locale, str, 17);
|
||||
s->locale[17] = '\0';
|
||||
return 0;
|
||||
@ -170,16 +178,20 @@ scp_session_set_username(struct SCP_SESSION* s, char* str)
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_username: null username", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->username)
|
||||
{
|
||||
g_free(s->username);
|
||||
}
|
||||
|
||||
s->username = g_strdup(str);
|
||||
|
||||
if (0 == s->username)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_username: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -192,16 +204,20 @@ scp_session_set_password(struct SCP_SESSION* s, char* str)
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_password: null password", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->password)
|
||||
{
|
||||
g_free(s->password);
|
||||
}
|
||||
|
||||
s->password = g_strdup(str);
|
||||
|
||||
if (0 == s->password)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_password: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -214,16 +230,20 @@ scp_session_set_domain(struct SCP_SESSION* s, char* str)
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_domain: null domain", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->domain)
|
||||
{
|
||||
g_free(s->domain);
|
||||
}
|
||||
|
||||
s->domain = g_strdup(str);
|
||||
|
||||
if (0 == s->domain)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_domain: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -236,16 +256,20 @@ scp_session_set_program(struct SCP_SESSION* s, char* str)
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_program: null program", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->program)
|
||||
{
|
||||
g_free(s->program);
|
||||
}
|
||||
|
||||
s->program = g_strdup(str);
|
||||
|
||||
if (0 == s->program)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_program: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -258,16 +282,20 @@ scp_session_set_directory(struct SCP_SESSION* s, char* str)
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_directory: null directory", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->directory)
|
||||
{
|
||||
g_free(s->directory);
|
||||
}
|
||||
|
||||
s->directory = g_strdup(str);
|
||||
|
||||
if (0 == s->directory)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_directory: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -280,16 +308,20 @@ scp_session_set_client_ip(struct SCP_SESSION* s, char* str)
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_client_ip: null ip", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->client_ip)
|
||||
{
|
||||
g_free(s->client_ip);
|
||||
}
|
||||
|
||||
s->client_ip = g_strdup(str);
|
||||
|
||||
if (0 == s->client_ip)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_client_ip: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -302,16 +334,20 @@ scp_session_set_hostname(struct SCP_SESSION* s, char* str)
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_hostname: null hostname", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->hostname)
|
||||
{
|
||||
g_free(s->hostname);
|
||||
}
|
||||
|
||||
s->hostname = g_strdup(str);
|
||||
|
||||
if (0 == s->hostname)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_hostname: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -324,16 +360,20 @@ scp_session_set_errstr(struct SCP_SESSION* s, char* str)
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_errstr: null string", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (0 != s->errstr)
|
||||
{
|
||||
g_free(s->errstr);
|
||||
}
|
||||
|
||||
s->errstr = g_strdup(str);
|
||||
|
||||
if (0 == s->errstr)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_errstr: strdup error", __LINE__);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -360,6 +400,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
|
||||
case SCP_ADDRESS_TYPE_IPV4:
|
||||
/* convert from char to 32bit*/
|
||||
ret = inet_pton(AF_INET, addr, &ip4);
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__);
|
||||
@ -367,6 +408,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
|
||||
g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4);
|
||||
break;
|
||||
case SCP_ADDRESS_TYPE_IPV4_BIN:
|
||||
@ -376,6 +418,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
|
||||
case SCP_ADDRESS_TYPE_IPV6:
|
||||
/* convert from char to 128bit*/
|
||||
ret = inet_pton(AF_INET6, addr, &ip6);
|
||||
|
||||
if (ret == 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__);
|
||||
@ -383,6 +426,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
|
||||
g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16);
|
||||
break;
|
||||
case SCP_ADDRESS_TYPE_IPV6_BIN:
|
||||
@ -392,6 +436,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr)
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -48,6 +47,7 @@ scp_tcp_force_recv(int sck, char* data, int len)
|
||||
while (len > 0)
|
||||
{
|
||||
rcvd = g_tcp_recv(sck, data, len, 0);
|
||||
|
||||
if (rcvd == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(sck))
|
||||
@ -90,6 +90,7 @@ scp_tcp_force_send(int sck, char* data, int len)
|
||||
while (len > 0)
|
||||
{
|
||||
sent = g_tcp_send(sck, data, len, 0);
|
||||
|
||||
if (sent == -1)
|
||||
{
|
||||
if (g_tcp_last_error_would_block(sck))
|
||||
@ -131,4 +132,3 @@ scp_tcp_bind(int sck, char* addr, char* port)
|
||||
s.sin_addr.s_addr = inet_addr(addr);
|
||||
return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_in));
|
||||
}
|
||||
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -62,6 +61,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_CLIENT_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
sz = g_strlen(s->username);
|
||||
out_uint16_be(c->out_s, sz);
|
||||
out_uint8a(c->out_s, s->username, sz);
|
||||
@ -94,6 +94,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (0 != version)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__);
|
||||
@ -101,6 +102,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 14)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: packet size error", __LINE__);
|
||||
@ -109,6 +111,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
/* getting payload */
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
||||
@ -117,6 +120,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
/* check code */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
|
||||
if (3 != sz)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: sequence error", __LINE__);
|
||||
@ -125,6 +129,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
/* message payload */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
|
||||
if (1 != sz)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: connection denied", __LINE__);
|
||||
@ -153,10 +158,12 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
if (!skipVchk)
|
||||
{
|
||||
LOG_DBG("[v0:%d] starting connection", __LINE__);
|
||||
|
||||
if (0 == scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
c->in_s->end = c->in_s->data + 8;
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__);
|
||||
@ -173,11 +180,13 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
init_stream(c->in_s, 8196);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
||||
return SCP_SERVER_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
c->in_s->end = c->in_s->data + (size - 8);
|
||||
|
||||
in_uint16_be(c->in_s, code);
|
||||
@ -185,6 +194,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
if (code == 0 || code == 10)
|
||||
{
|
||||
session = scp_session_create();
|
||||
|
||||
if (0 == session)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
|
||||
@ -192,6 +202,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
}
|
||||
|
||||
scp_session_set_version(session, version);
|
||||
|
||||
if (code == 0)
|
||||
{
|
||||
scp_session_set_type(session, SCP_SESSION_TYPE_XVNC);
|
||||
@ -205,6 +216,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
in_uint16_be(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_username(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@ -216,6 +228,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
in_uint16_be(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_password(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@ -232,10 +245,12 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
/* bpp */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
scp_session_set_bpp(session, (tui8)sz);
|
||||
|
||||
if (s_check_rem(c->in_s, 2))
|
||||
{
|
||||
/* reading domain */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
|
||||
if (sz > 0)
|
||||
{
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
@ -243,10 +258,12 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
scp_session_set_domain(session, buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (s_check_rem(c->in_s, 2))
|
||||
{
|
||||
/* reading program */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
|
||||
if (sz > 0)
|
||||
{
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
@ -254,10 +271,12 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
scp_session_set_program(session, buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (s_check_rem(c->in_s, 2))
|
||||
{
|
||||
/* reading directory */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
|
||||
if (sz > 0)
|
||||
{
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
@ -265,10 +284,12 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
scp_session_set_directory(session, buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (s_check_rem(c->in_s, 2))
|
||||
{
|
||||
/* reading client IP address */
|
||||
in_uint16_be(c->in_s, sz);
|
||||
|
||||
if (sz > 0)
|
||||
{
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
@ -281,6 +302,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
{
|
||||
/* g_writeln("Command is SCP_GW_AUTHENTICATION"); */
|
||||
session = scp_session_create();
|
||||
|
||||
if (0 == session)
|
||||
{
|
||||
/* until syslog merge log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);*/
|
||||
@ -293,6 +315,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
in_uint16_be(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
/* g_writeln("Received user name: %s",buf); */
|
||||
if (0 != scp_session_set_username(session, buf))
|
||||
{
|
||||
@ -305,6 +328,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk)
|
||||
in_uint16_be(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
/* g_writeln("Received password: %s",buf); */
|
||||
if (0 != scp_session_set_password(session, buf))
|
||||
{
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -83,4 +82,3 @@ enum SCP_SERVER_STATES_E
|
||||
scp_v0s_replyauthentication(struct SCP_CONNECTION* c, unsigned short int value);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -46,6 +45,7 @@ scp_v1c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
size = 19 + 17 + 4 + g_strlen(s->hostname) + g_strlen(s->username) +
|
||||
g_strlen(s->password);
|
||||
|
||||
if (s->addr_type == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
size = size + 4;
|
||||
@ -177,36 +177,42 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
{
|
||||
/* then we wait for server response */
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
return SCP_CLIENT_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
return SCP_CLIENT_STATE_VERSION_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SIZE_ERR;
|
||||
}
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
return SCP_CLIENT_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_DEFAULT)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != 42)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
||||
@ -219,6 +225,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
sestmp = sescnt;
|
||||
|
||||
ds = g_malloc(sizeof(struct SCP_DISCONNECTED_SESSION) * sescnt, 0);
|
||||
|
||||
if (ds == 0)
|
||||
{
|
||||
return SCP_CLIENT_STATE_INTERNAL_ERR;
|
||||
@ -228,6 +235,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
{
|
||||
in_uint32_be(c->in_s, sestmp);
|
||||
}
|
||||
|
||||
in_uint8(c->in_s, continued);
|
||||
in_uint8(c->in_s, pktcnt);
|
||||
|
||||
@ -248,6 +256,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
in_uint8(c->in_s, (ds[totalcnt]).conn_hour);
|
||||
in_uint8(c->in_s, (ds[totalcnt]).conn_minute);
|
||||
in_uint8(c->in_s, (ds[totalcnt]).addr_type);
|
||||
|
||||
if ((ds[totalcnt]).addr_type == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
in_uint32_be(c->in_s, (ds[totalcnt]).ipv4addr);
|
||||
@ -256,6 +265,7 @@ scp_v1c_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
{
|
||||
in_uint8a(c->in_s, (ds[totalcnt]).ipv6addr, 16);
|
||||
}
|
||||
|
||||
totalcnt++;
|
||||
}
|
||||
}
|
||||
@ -295,24 +305,28 @@ scp_v1c_select_session(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
|
||||
|
||||
/* waiting for response.... */
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
return SCP_CLIENT_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
return SCP_CLIENT_STATE_VERSION_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SIZE_ERR;
|
||||
}
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
/* read the rest of the packet */
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
@ -320,12 +334,14 @@ scp_v1c_select_session(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_DEFAULT)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != 46)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
||||
@ -372,12 +388,14 @@ _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
tui16 dim;
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
return SCP_CLIENT_STATE_NETWORK_ERR;
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
return SCP_CLIENT_STATE_VERSION_ERR;
|
||||
@ -386,6 +404,7 @@ _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
/* read the rest of the packet */
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
@ -393,24 +412,30 @@ _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_DEFAULT)
|
||||
{
|
||||
return SCP_CLIENT_STATE_SEQUENCE_ERR;
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd == 2) /* connection denied */
|
||||
{
|
||||
in_uint16_be(c->in_s, dim);
|
||||
|
||||
if (s->errstr != 0)
|
||||
{
|
||||
g_free(s->errstr);
|
||||
}
|
||||
|
||||
s->errstr = g_malloc(dim + 1, 0);
|
||||
|
||||
if (s->errstr == 0)
|
||||
{
|
||||
return SCP_CLIENT_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
in_uint8a(c->in_s, s->errstr, dim);
|
||||
(s->errstr)[dim] = '\0';
|
||||
|
||||
@ -419,15 +444,19 @@ _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
else if (cmd == 3) /* resend usr/pwd */
|
||||
{
|
||||
in_uint16_be(c->in_s, dim);
|
||||
|
||||
if (s->errstr != 0)
|
||||
{
|
||||
g_free(s->errstr);
|
||||
}
|
||||
|
||||
s->errstr = g_malloc(dim + 1, 0);
|
||||
|
||||
if (s->errstr == 0)
|
||||
{
|
||||
return SCP_CLIENT_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
in_uint8a(c->in_s, s->errstr, dim);
|
||||
(s->errstr)[dim] = '\0';
|
||||
|
||||
@ -436,15 +465,19 @@ _scp_v1c_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
else if (cmd == 20) /* password change */
|
||||
{
|
||||
in_uint16_be(c->in_s, dim);
|
||||
|
||||
if (s->errstr != 0)
|
||||
{
|
||||
g_free(s->errstr);
|
||||
}
|
||||
|
||||
s->errstr = g_malloc(dim + 1, 0);
|
||||
|
||||
if (s->errstr == 0)
|
||||
{
|
||||
return SCP_CLIENT_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
in_uint8a(c->in_s, s->errstr, dim);
|
||||
(s->errstr)[dim] = '\0';
|
||||
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -48,6 +47,7 @@ scp_v1c_mng_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
size = 12 + 4 + g_strlen(s->hostname) + g_strlen(s->username) +
|
||||
g_strlen(s->password);
|
||||
|
||||
if (s->addr_type == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
size = size + 4;
|
||||
@ -75,6 +75,7 @@ scp_v1c_mng_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
|
||||
/* address */
|
||||
out_uint8(c->out_s, s->addr_type);
|
||||
|
||||
if (s->addr_type == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
out_uint32_be(c->out_s, s->ipv4addr);
|
||||
@ -135,6 +136,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
{
|
||||
/* then we wait for server response */
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
|
||||
@ -142,6 +144,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: version error", __LINE__);
|
||||
@ -149,6 +152,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: size error", __LINE__);
|
||||
@ -156,6 +160,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
}
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
|
||||
@ -163,6 +168,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_MANAGE)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
|
||||
@ -170,6 +176,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_CMD_MNG_LIST) /* session list */
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
|
||||
@ -193,6 +200,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
}
|
||||
|
||||
ds = g_malloc(sizeof(struct SCP_DISCONNECTED_SESSION) * sescnt, 0);
|
||||
|
||||
if (ds == 0)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: internal error", __LINE__);
|
||||
@ -203,6 +211,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
{
|
||||
in_uint32_be(c->in_s, sestmp);
|
||||
}
|
||||
|
||||
in_uint8(c->in_s, continued);
|
||||
in_uint8(c->in_s, pktcnt);
|
||||
|
||||
@ -223,14 +232,17 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount,
|
||||
in_uint8(c->in_s, (ds[totalcnt]).conn_hour);
|
||||
in_uint8(c->in_s, (ds[totalcnt]).conn_minute);
|
||||
in_uint8(c->in_s, (ds[totalcnt]).addr_type);
|
||||
|
||||
if ((ds[totalcnt]).addr_type == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
in_uint32_be(c->in_s, (ds[totalcnt]).ipv4addr);
|
||||
}
|
||||
|
||||
if ((ds[totalcnt]).addr_type == SCP_ADDRESS_TYPE_IPV6)
|
||||
{
|
||||
in_uint8a(c->in_s, (ds[totalcnt]).ipv6addr, 16);
|
||||
}
|
||||
|
||||
totalcnt++;
|
||||
}
|
||||
}
|
||||
@ -348,6 +360,7 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
char buf[257];
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__);
|
||||
@ -355,6 +368,7 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: version error", __LINE__);
|
||||
@ -364,6 +378,7 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
/* read the rest of the packet */
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
@ -372,6 +387,7 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_MANAGE)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__);
|
||||
@ -379,6 +395,7 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd == SCP_CMD_MNG_LOGIN_ALLOW) /* connection ok */
|
||||
{
|
||||
log_message(LOG_LEVEL_INFO, "[v1c_mng:%d] connection ok", __LINE__);
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -49,6 +48,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
if (0 == scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
|
||||
@ -63,6 +63,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
|
||||
@ -70,6 +71,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
}
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (size - 8)))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
@ -96,6 +98,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
|
||||
/* reading command */
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
|
||||
@ -103,20 +106,24 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
}
|
||||
|
||||
session = scp_session_create();
|
||||
|
||||
if (0 == session)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error (malloc returned NULL)", __LINE__);
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
scp_session_set_version(session, 1);
|
||||
|
||||
in_uint8(c->in_s, sz);
|
||||
|
||||
if ((sz != SCP_SESSION_TYPE_XVNC) && (sz != SCP_SESSION_TYPE_XRDP))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: unknown session type", __LINE__);
|
||||
return SCP_SERVER_STATE_SESSION_TYPE_ERR;
|
||||
}
|
||||
|
||||
scp_session_set_type(session, sz);
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
@ -132,6 +139,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
scp_session_set_locale(session, buf);
|
||||
|
||||
in_uint8(c->in_s, sz);
|
||||
|
||||
if (sz == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
in_uint32_be(c->in_s, size);
|
||||
@ -148,6 +156,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_hostname(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@ -159,6 +168,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_username(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@ -170,6 +180,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_password(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@ -192,6 +203,7 @@ scp_v1s_deny_connection(struct SCP_CONNECTION* c, char* reason)
|
||||
|
||||
/* forcing message not to exceed 64k */
|
||||
rlen = g_strlen(reason);
|
||||
|
||||
if (rlen > 65535)
|
||||
{
|
||||
rlen = 65535;
|
||||
@ -231,6 +243,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
|
||||
/* forcing message not to exceed 64k */
|
||||
rlen = g_strlen(reason);
|
||||
|
||||
if (rlen > 65535)
|
||||
{
|
||||
rlen = 65535;
|
||||
@ -262,6 +275,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
|
||||
@ -269,6 +283,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
|
||||
@ -276,6 +291,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
}
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (size - 8)))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
@ -283,6 +299,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmdset);
|
||||
|
||||
if (cmdset != SCP_COMMAND_SET_DEFAULT)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
|
||||
@ -290,6 +307,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != 4)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
|
||||
@ -301,6 +319,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_username(s, buf))
|
||||
{
|
||||
scp_session_destroy(s);
|
||||
@ -312,6 +331,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char*
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_password(s, buf))
|
||||
{
|
||||
scp_session_destroy(s);
|
||||
@ -418,6 +438,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
#warning maybe this message could say if the session should be resized on
|
||||
#warning server side or client side
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
@ -425,6 +446,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
|
||||
@ -432,6 +454,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
|
||||
@ -439,6 +462,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (size - 8)))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
@ -446,6 +470,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_DEFAULT)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
|
||||
@ -453,6 +478,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != 41)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
|
||||
@ -461,6 +487,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
|
||||
/* calculating the number of packets to send */
|
||||
pktcnt = sescnt / SCP_SERVER_MAX_LIST_SIZE;
|
||||
|
||||
if ((sescnt % SCP_SERVER_MAX_LIST_SIZE) != 0)
|
||||
{
|
||||
pktcnt++;
|
||||
@ -549,6 +576,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
|
||||
/* we get the response */
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (8)))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
@ -556,6 +584,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__);
|
||||
@ -563,6 +592,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
if (size < 12)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__);
|
||||
@ -571,6 +601,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
|
||||
/* rest of the packet */
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (size - 8)))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__);
|
||||
@ -578,6 +609,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_DEFAULT)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__);
|
||||
@ -585,6 +617,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd == 43)
|
||||
{
|
||||
/* select session */
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -47,12 +46,14 @@ scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
|
||||
/* reading command */
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != 1) /* manager login */
|
||||
{
|
||||
return SCP_SERVER_STATE_SEQUENCE_ERR;
|
||||
}
|
||||
|
||||
session = scp_session_create();
|
||||
|
||||
if (0 == session)
|
||||
{
|
||||
return SCP_SERVER_STATE_INTERNAL_ERR;
|
||||
@ -65,6 +66,7 @@ scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_username(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@ -75,6 +77,7 @@ scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_password(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@ -83,6 +86,7 @@ scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
|
||||
/* reading remote address */
|
||||
in_uint8(c->in_s, sz);
|
||||
|
||||
if (sz == SCP_ADDRESS_TYPE_IPV4)
|
||||
{
|
||||
in_uint32_be(c->in_s, ipaddr);
|
||||
@ -98,6 +102,7 @@ scp_v1s_mng_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s)
|
||||
in_uint8(c->in_s, sz);
|
||||
buf[sz] = '\0';
|
||||
in_uint8a(c->in_s, buf, sz);
|
||||
|
||||
if (0 != scp_session_set_hostname(session, buf))
|
||||
{
|
||||
scp_session_destroy(session);
|
||||
@ -141,6 +146,7 @@ scp_v1s_mng_deny_connection(struct SCP_CONNECTION* c, char* reason)
|
||||
|
||||
/* forcing message not to exceed 64k */
|
||||
rlen = g_strlen(reason);
|
||||
|
||||
if (rlen > 65535)
|
||||
{
|
||||
rlen = 65535;
|
||||
@ -179,6 +185,7 @@ scp_v1s_mng_list_sessions(struct SCP_CONNECTION* c, struct SCP_SESSION* s,
|
||||
|
||||
/* calculating the number of packets to send */
|
||||
pktcnt = sescnt / SCP_SERVER_MAX_LIST_SIZE;
|
||||
|
||||
if ((sescnt % SCP_SERVER_MAX_LIST_SIZE) != 0)
|
||||
{
|
||||
pktcnt++;
|
||||
@ -277,6 +284,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
// char buf[257];
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8))
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__);
|
||||
@ -284,6 +292,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint32_be(c->in_s, version);
|
||||
|
||||
if (version != 1)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: version error", __LINE__);
|
||||
@ -293,6 +302,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
in_uint32_be(c->in_s, size);
|
||||
|
||||
init_stream(c->in_s, c->in_s->size);
|
||||
|
||||
/* read the rest of the packet */
|
||||
if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8))
|
||||
{
|
||||
@ -301,6 +311,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd != SCP_COMMAND_SET_MANAGE)
|
||||
{
|
||||
log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: sequence error", __LINE__);
|
||||
@ -308,6 +319,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
}
|
||||
|
||||
in_uint16_be(c->in_s, cmd);
|
||||
|
||||
if (cmd == SCP_CMD_MNG_LIST_REQ) /* request session list */
|
||||
{
|
||||
log_message(LOG_LEVEL_INFO, "[v1s_mng:%d] request session list", __LINE__);
|
||||
@ -323,6 +335,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s)
|
||||
log_message(LOG_LEVEL_INFO, "[v1s_mng:%d] action request", __LINE__);
|
||||
return SCP_SERVER_STATE_MNG_ACTION;
|
||||
}
|
||||
|
||||
/* else if (cmd == 20) / * password change * /
|
||||
{
|
||||
in_uint16_be(c->in_s, s->display);
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,20 +1,19 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -1,24 +1,22 @@
|
||||
/*
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
xrdp: A Remote Desktop Protocol server.
|
||||
Copyright (C) Jay Sorg 2005-2010
|
||||
|
||||
session manager
|
||||
linux only
|
||||
|
||||
/**
|
||||
* xrdp: A Remote Desktop Protocol server.
|
||||
*
|
||||
* Copyright (C) Jay Sorg 2004-2012
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* session manager
|
||||
* linux only
|
||||
*/
|
||||
|
||||
#include "sesman.h"
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user