fde308
From 21437d973ef7389533b3cf67183aca73b3dad3ad Mon Sep 17 00:00:00 2001
fde308
From: Cathy Avery <cavery@redhat.com>
fde308
Date: Fri, 27 Mar 2020 13:33:32 +0100
fde308
Subject: add appinfo plugin
fde308
fde308
Message-id: <20200327133332.7366-1-cavery@redhat.com>
fde308
Patchwork-id: 94454
fde308
O-Subject: [RHEL7.9 open-vm-tools PATCH] add appinfo plugin
fde308
Bugzilla: 1809753
fde308
RH-Acked-by: Eduardo Otubo <otubo@redhat.com>
fde308
RH-Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
fde308
fde308
commit f1f0b812e7fb9ccf405fcfd48ddb4d65e8532eef
fde308
Author: Oliver Kurth <okurth@vmware.com>
fde308
Date:   Wed Feb 5 17:21:52 2020 -0800
fde308
fde308
    add appinfo plugin
fde308
fde308
Signed-off-by: Cathy Avery <cavery@redhat.com>
fde308
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
fde308
---
fde308
 open-vm-tools/configure.ac                         |   3 +-
fde308
 open-vm-tools/lib/include/appInfo.h                |  41 ++
fde308
 open-vm-tools/services/plugins/Makefile.am         |   5 +-
fde308
 open-vm-tools/services/plugins/appInfo/COPYING     | 502 ++++++++++++++++++
fde308
 open-vm-tools/services/plugins/appInfo/Makefile.am |  37 ++
fde308
 open-vm-tools/services/plugins/appInfo/appInfo.c   | 572 +++++++++++++++++++++
fde308
 .../services/plugins/appInfo/appInfoInt.h          |  64 +++
fde308
 .../services/plugins/appInfo/appInfoPosix.c        | 124 +++++
fde308
 .../services/plugins/appInfo/appInfoUtil.c         | 143 ++++++
fde308
 9 files changed, 1489 insertions(+), 2 deletions(-)
fde308
 create mode 100644 open-vm-tools/lib/include/appInfo.h
fde308
 create mode 100644 open-vm-tools/services/plugins/appInfo/COPYING
fde308
 create mode 100644 open-vm-tools/services/plugins/appInfo/Makefile.am
fde308
 create mode 100644 open-vm-tools/services/plugins/appInfo/appInfo.c
fde308
 create mode 100644 open-vm-tools/services/plugins/appInfo/appInfoInt.h
fde308
 create mode 100644 open-vm-tools/services/plugins/appInfo/appInfoPosix.c
fde308
 create mode 100644 open-vm-tools/services/plugins/appInfo/appInfoUtil.c
fde308
fde308
diff --git a/open-vm-tools/configure.ac b/open-vm-tools/configure.ac
fde308
index f1cc721..009fe87 100644
fde308
--- a/open-vm-tools/configure.ac
fde308
+++ b/open-vm-tools/configure.ac
fde308
@@ -1,5 +1,5 @@
fde308
 ################################################################################
fde308
-### Copyright (C) 2007-2019 VMware, Inc.  All rights reserved.
fde308
+### Copyright (C) 2007-2020 VMware, Inc.  All rights reserved.
fde308
 ###
fde308
 ### Configure script for building the VMware OSS Tools.
fde308
 ###
fde308
@@ -1579,6 +1579,7 @@ AC_CONFIG_FILES([                      \
fde308
    services/Makefile                   \
fde308
    services/vmtoolsd/Makefile          \
fde308
    services/plugins/Makefile           \
fde308
+   services/plugins/appInfo/Makefile   \
fde308
    services/plugins/desktopEvents/Makefile \
fde308
    services/plugins/dndcp/Makefile     \
fde308
    services/plugins/guestInfo/Makefile \
fde308
diff --git a/open-vm-tools/lib/include/appInfo.h b/open-vm-tools/lib/include/appInfo.h
fde308
new file mode 100644
fde308
index 0000000..122d08e
fde308
--- /dev/null
fde308
+++ b/open-vm-tools/lib/include/appInfo.h
fde308
@@ -0,0 +1,41 @@
fde308
+/*********************************************************
fde308
+ * Copyright (C) 2020 VMware, Inc. All rights reserved.
fde308
+ *
fde308
+ * This program is free software; you can redistribute it and/or modify it
fde308
+ * under the terms of the GNU Lesser General Public License as published
fde308
+ * by the Free Software Foundation version 2.1 and no later version.
fde308
+ *
fde308
+ * This program is distributed in the hope that it will be useful, but
fde308
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
fde308
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
fde308
+ * License for more details.
fde308
+ *
fde308
+ * You should have received a copy of the GNU Lesser General Public License
fde308
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
fde308
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
fde308
+ *
fde308
+ *********************************************************/
fde308
+
fde308
+#ifndef _APPINFO_H_
fde308
+#define _APPINFO_H_
fde308
+
fde308
+/**
fde308
+ * @file appInfo.h
fde308
+ *
fde308
+ * Declares few constants for the appInfo plugin.
fde308
+ */
fde308
+
fde308
+/**
fde308
+ * The guest Variable name for the application information.
fde308
+ */
fde308
+#define APP_INFO_GUESTVAR_KEY         "appInfo"
fde308
+
fde308
+#define APP_INFO_VERSION_1            1
fde308
+#define APP_INFO_KEY_VERSION          "version"
fde308
+#define APP_INFO_KEY_UPDATE_COUNTER   "updateCounter"
fde308
+#define APP_INFO_KEY_PUBLISHTIME      "publishTime"
fde308
+#define APP_INFO_KEY_APPS             "applications"
fde308
+#define APP_INFO_KEY_APP_NAME         "a"
fde308
+#define APP_INFO_KEY_APP_VERSION      "v"
fde308
+
fde308
+#endif /* _APPINFO_H_ */
fde308
diff --git a/open-vm-tools/services/plugins/Makefile.am b/open-vm-tools/services/plugins/Makefile.am
fde308
index 7ab22ee..e010ab1 100644
fde308
--- a/open-vm-tools/services/plugins/Makefile.am
fde308
+++ b/open-vm-tools/services/plugins/Makefile.am
fde308
@@ -1,5 +1,5 @@
fde308
 ################################################################################
fde308
-### Copyright (C) 2009-2019 VMware, Inc.  All rights reserved.
fde308
+### Copyright (C) 2009-2020 VMware, Inc.  All rights reserved.
fde308
 ###
fde308
 ### This program is free software; you can redistribute it and/or modify
fde308
 ### it under the terms of version 2 of the GNU General Public License as
fde308
@@ -16,6 +16,9 @@
fde308
 ################################################################################
fde308
 
fde308
 SUBDIRS =
fde308
+if LINUX
fde308
+SUBDIRS += appInfo
fde308
+endif
fde308
 if HAVE_X11
fde308
    SUBDIRS += desktopEvents
fde308
 endif
fde308
diff --git a/open-vm-tools/services/plugins/appInfo/COPYING b/open-vm-tools/services/plugins/appInfo/COPYING
fde308
new file mode 100644
fde308
index 0000000..9c6a6cc
fde308
--- /dev/null
fde308
+++ b/open-vm-tools/services/plugins/appInfo/COPYING
fde308
@@ -0,0 +1,502 @@
fde308
+		  GNU LESSER GENERAL PUBLIC LICENSE
fde308
+		       Version 2.1, February 1999
fde308
+
fde308
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
fde308
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
fde308
+ Everyone is permitted to copy and distribute verbatim copies
fde308
+ of this license document, but changing it is not allowed.
fde308
+
fde308
+[This is the first released version of the Lesser GPL.  It also counts
fde308
+ as the successor of the GNU Library Public License, version 2, hence
fde308
+ the version number 2.1.]
fde308
+
fde308
+			    Preamble
fde308
+
fde308
+  The licenses for most software are designed to take away your
fde308
+freedom to share and change it.  By contrast, the GNU General Public
fde308
+Licenses are intended to guarantee your freedom to share and change
fde308
+free software--to make sure the software is free for all its users.
fde308
+
fde308
+  This license, the Lesser General Public License, applies to some
fde308
+specially designated software packages--typically libraries--of the
fde308
+Free Software Foundation and other authors who decide to use it.  You
fde308
+can use it too, but we suggest you first think carefully about whether
fde308
+this license or the ordinary General Public License is the better
fde308
+strategy to use in any particular case, based on the explanations below.
fde308
+
fde308
+  When we speak of free software, we are referring to freedom of use,
fde308
+not price.  Our General Public Licenses are designed to make sure that
fde308
+you have the freedom to distribute copies of free software (and charge
fde308
+for this service if you wish); that you receive source code or can get
fde308
+it if you want it; that you can change the software and use pieces of
fde308
+it in new free programs; and that you are informed that you can do
fde308
+these things.
fde308
+
fde308
+  To protect your rights, we need to make restrictions that forbid
fde308
+distributors to deny you these rights or to ask you to surrender these
fde308
+rights.  These restrictions translate to certain responsibilities for
fde308
+you if you distribute copies of the library or if you modify it.
fde308
+
fde308
+  For example, if you distribute copies of the library, whether gratis
fde308
+or for a fee, you must give the recipients all the rights that we gave
fde308
+you.  You must make sure that they, too, receive or can get the source
fde308
+code.  If you link other code with the library, you must provide
fde308
+complete object files to the recipients, so that they can relink them
fde308
+with the library after making changes to the library and recompiling
fde308
+it.  And you must show them these terms so they know their rights.
fde308
+
fde308
+  We protect your rights with a two-step method: (1) we copyright the
fde308
+library, and (2) we offer you this license, which gives you legal
fde308
+permission to copy, distribute and/or modify the library.
fde308
+
fde308
+  To protect each distributor, we want to make it very clear that
fde308
+there is no warranty for the free library.  Also, if the library is
fde308
+modified by someone else and passed on, the recipients should know
fde308
+that what they have is not the original version, so that the original
fde308
+author's reputation will not be affected by problems that might be
fde308
+introduced by others.
fde308
+
fde308
+  Finally, software patents pose a constant threat to the existence of
fde308
+any free program.  We wish to make sure that a company cannot
fde308
+effectively restrict the users of a free program by obtaining a
fde308
+restrictive license from a patent holder.  Therefore, we insist that
fde308
+any patent license obtained for a version of the library must be
fde308
+consistent with the full freedom of use specified in this license.
fde308
+
fde308
+  Most GNU software, including some libraries, is covered by the
fde308
+ordinary GNU General Public License.  This license, the GNU Lesser
fde308
+General Public License, applies to certain designated libraries, and
fde308
+is quite different from the ordinary General Public License.  We use
fde308
+this license for certain libraries in order to permit linking those
fde308
+libraries into non-free programs.
fde308
+
fde308
+  When a program is linked with a library, whether statically or using
fde308
+a shared library, the combination of the two is legally speaking a
fde308
+combined work, a derivative of the original library.  The ordinary
fde308
+General Public License therefore permits such linking only if the
fde308
+entire combination fits its criteria of freedom.  The Lesser General
fde308
+Public License permits more lax criteria for linking other code with
fde308
+the library.
fde308
+
fde308
+  We call this license the "Lesser" General Public License because it
fde308
+does Less to protect the user's freedom than the ordinary General
fde308
+Public License.  It also provides other free software developers Less
fde308
+of an advantage over competing non-free programs.  These disadvantages
fde308
+are the reason we use the ordinary General Public License for many
fde308
+libraries.  However, the Lesser license provides advantages in certain
fde308
+special circumstances.
fde308
+
fde308
+  For example, on rare occasions, there may be a special need to
fde308
+encourage the widest possible use of a certain library, so that it becomes
fde308
+a de-facto standard.  To achieve this, non-free programs must be
fde308
+allowed to use the library.  A more frequent case is that a free
fde308
+library does the same job as widely used non-free libraries.  In this
fde308
+case, there is little to gain by limiting the free library to free
fde308
+software only, so we use the Lesser General Public License.
fde308
+
fde308
+  In other cases, permission to use a particular library in non-free
fde308
+programs enables a greater number of people to use a large body of
fde308
+free software.  For example, permission to use the GNU C Library in
fde308
+non-free programs enables many more people to use the whole GNU
fde308
+operating system, as well as its variant, the GNU/Linux operating
fde308
+system.
fde308
+
fde308
+  Although the Lesser General Public License is Less protective of the
fde308
+users' freedom, it does ensure that the user of a program that is
fde308
+linked with the Library has the freedom and the wherewithal to run
fde308
+that program using a modified version of the Library.
fde308
+
fde308
+  The precise terms and conditions for copying, distribution and
fde308
+modification follow.  Pay close attention to the difference between a
fde308
+"work based on the library" and a "work that uses the library".  The
fde308
+former contains code derived from the library, whereas the latter must
fde308
+be combined with the library in order to run.
fde308
+
fde308
+		  GNU LESSER GENERAL PUBLIC LICENSE
fde308
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
fde308
+
fde308
+  0. This License Agreement applies to any software library or other
fde308
+program which contains a notice placed by the copyright holder or
fde308
+other authorized party saying it may be distributed under the terms of
fde308
+this Lesser General Public License (also called "this License").
fde308
+Each licensee is addressed as "you".
fde308
+
fde308
+  A "library" means a collection of software functions and/or data
fde308
+prepared so as to be conveniently linked with application programs
fde308
+(which use some of those functions and data) to form executables.
fde308
+
fde308
+  The "Library", below, refers to any such software library or work
fde308
+which has been distributed under these terms.  A "work based on the
fde308
+Library" means either the Library or any derivative work under
fde308
+copyright law: that is to say, a work containing the Library or a
fde308
+portion of it, either verbatim or with modifications and/or translated
fde308
+straightforwardly into another language.  (Hereinafter, translation is
fde308
+included without limitation in the term "modification".)
fde308
+
fde308
+  "Source code" for a work means the preferred form of the work for
fde308
+making modifications to it.  For a library, complete source code means
fde308
+all the source code for all modules it contains, plus any associated
fde308
+interface definition files, plus the scripts used to control compilation
fde308
+and installation of the library.
fde308
+
fde308
+  Activities other than copying, distribution and modification are not
fde308
+covered by this License; they are outside its scope.  The act of
fde308
+running a program using the Library is not restricted, and output from
fde308
+such a program is covered only if its contents constitute a work based
fde308
+on the Library (independent of the use of the Library in a tool for
fde308
+writing it).  Whether that is true depends on what the Library does
fde308
+and what the program that uses the Library does.
fde308
+
fde308
+  1. You may copy and distribute verbatim copies of the Library's
fde308
+complete source code as you receive it, in any medium, provided that
fde308
+you conspicuously and appropriately publish on each copy an
fde308
+appropriate copyright notice and disclaimer of warranty; keep intact
fde308
+all the notices that refer to this License and to the absence of any
fde308
+warranty; and distribute a copy of this License along with the
fde308
+Library.
fde308
+
fde308
+  You may charge a fee for the physical act of transferring a copy,
fde308
+and you may at your option offer warranty protection in exchange for a
fde308
+fee.
fde308
+
fde308
+  2. You may modify your copy or copies of the Library or any portion
fde308
+of it, thus forming a work based on the Library, and copy and
fde308
+distribute such modifications or work under the terms of Section 1
fde308
+above, provided that you also meet all of these conditions:
fde308
+
fde308
+    a) The modified work must itself be a software library.
fde308
+
fde308
+    b) You must cause the files modified to carry prominent notices
fde308
+    stating that you changed the files and the date of any change.
fde308
+
fde308
+    c) You must cause the whole of the work to be licensed at no
fde308
+    charge to all third parties under the terms of this License.
fde308
+
fde308
+    d) If a facility in the modified Library refers to a function or a
fde308
+    table of data to be supplied by an application program that uses
fde308
+    the facility, other than as an argument passed when the facility
fde308
+    is invoked, then you must make a good faith effort to ensure that,
fde308
+    in the event an application does not supply such function or
fde308
+    table, the facility still operates, and performs whatever part of
fde308
+    its purpose remains meaningful.
fde308
+
fde308
+    (For example, a function in a library to compute square roots has
fde308
+    a purpose that is entirely well-defined independent of the
fde308
+    application.  Therefore, Subsection 2d requires that any
fde308
+    application-supplied function or table used by this function must
fde308
+    be optional: if the application does not supply it, the square
fde308
+    root function must still compute square roots.)
fde308
+
fde308
+These requirements apply to the modified work as a whole.  If
fde308
+identifiable sections of that work are not derived from the Library,
fde308
+and can be reasonably considered independent and separate works in
fde308
+themselves, then this License, and its terms, do not apply to those
fde308
+sections when you distribute them as separate works.  But when you
fde308
+distribute the same sections as part of a whole which is a work based
fde308
+on the Library, the distribution of the whole must be on the terms of
fde308
+this License, whose permissions for other licensees extend to the
fde308
+entire whole, and thus to each and every part regardless of who wrote
fde308
+it.
fde308
+
fde308
+Thus, it is not the intent of this section to claim rights or contest
fde308
+your rights to work written entirely by you; rather, the intent is to
fde308
+exercise the right to control the distribution of derivative or
fde308
+collective works based on the Library.
fde308
+
fde308
+In addition, mere aggregation of another work not based on the Library
fde308
+with the Library (or with a work based on the Library) on a volume of
fde308
+a storage or distribution medium does not bring the other work under
fde308
+the scope of this License.
fde308
+
fde308
+  3. You may opt to apply the terms of the ordinary GNU General Public
fde308
+License instead of this License to a given copy of the Library.  To do
fde308
+this, you must alter all the notices that refer to this License, so
fde308
+that they refer to the ordinary GNU General Public License, version 2,
fde308
+instead of to this License.  (If a newer version than version 2 of the
fde308
+ordinary GNU General Public License has appeared, then you can specify
fde308
+that version instead if you wish.)  Do not make any other change in
fde308
+these notices.
fde308
+
fde308
+  Once this change is made in a given copy, it is irreversible for
fde308
+that copy, so the ordinary GNU General Public License applies to all
fde308
+subsequent copies and derivative works made from that copy.
fde308
+
fde308
+  This option is useful when you wish to copy part of the code of
fde308
+the Library into a program that is not a library.
fde308
+
fde308
+  4. You may copy and distribute the Library (or a portion or
fde308
+derivative of it, under Section 2) in object code or executable form
fde308
+under the terms of Sections 1 and 2 above provided that you accompany
fde308
+it with the complete corresponding machine-readable source code, which
fde308
+must be distributed under the terms of Sections 1 and 2 above on a
fde308
+medium customarily used for software interchange.
fde308
+
fde308
+  If distribution of object code is made by offering access to copy
fde308
+from a designated place, then offering equivalent access to copy the
fde308
+source code from the same place satisfies the requirement to
fde308
+distribute the source code, even though third parties are not
fde308
+compelled to copy the source along with the object code.
fde308
+
fde308
+  5. A program that contains no derivative of any portion of the
fde308
+Library, but is designed to work with the Library by being compiled or
fde308
+linked with it, is called a "work that uses the Library".  Such a
fde308
+work, in isolation, is not a derivative work of the Library, and
fde308
+therefore falls outside the scope of this License.
fde308
+
fde308
+  However, linking a "work that uses the Library" with the Library
fde308
+creates an executable that is a derivative of the Library (because it
fde308
+contains portions of the Library), rather than a "work that uses the
fde308
+library".  The executable is therefore covered by this License.
fde308
+Section 6 states terms for distribution of such executables.
fde308
+
fde308
+  When a "work that uses the Library" uses material from a header file
fde308
+that is part of the Library, the object code for the work may be a
fde308
+derivative work of the Library even though the source code is not.
fde308
+Whether this is true is especially significant if the work can be
fde308
+linked without the Library, or if the work is itself a library.  The
fde308
+threshold for this to be true is not precisely defined by law.
fde308
+
fde308
+  If such an object file uses only numerical parameters, data
fde308
+structure layouts and accessors, and small macros and small inline
fde308
+functions (ten lines or less in length), then the use of the object
fde308
+file is unrestricted, regardless of whether it is legally a derivative
fde308
+work.  (Executables containing this object code plus portions of the
fde308
+Library will still fall under Section 6.)
fde308
+
fde308
+  Otherwise, if the work is a derivative of the Library, you may
fde308
+distribute the object code for the work under the terms of Section 6.
fde308
+Any executables containing that work also fall under Section 6,
fde308
+whether or not they are linked directly with the Library itself.
fde308
+
fde308
+  6. As an exception to the Sections above, you may also combine or
fde308
+link a "work that uses the Library" with the Library to produce a
fde308
+work containing portions of the Library, and distribute that work
fde308
+under terms of your choice, provided that the terms permit
fde308
+modification of the work for the customer's own use and reverse
fde308
+engineering for debugging such modifications.
fde308
+
fde308
+  You must give prominent notice with each copy of the work that the
fde308
+Library is used in it and that the Library and its use are covered by
fde308
+this License.  You must supply a copy of this License.  If the work
fde308
+during execution displays copyright notices, you must include the
fde308
+copyright notice for the Library among them, as well as a reference
fde308
+directing the user to the copy of this License.  Also, you must do one
fde308
+of these things:
fde308
+
fde308
+    a) Accompany the work with the complete corresponding
fde308
+    machine-readable source code for the Library including whatever
fde308
+    changes were used in the work (which must be distributed under
fde308
+    Sections 1 and 2 above); and, if the work is an executable linked
fde308
+    with the Library, with the complete machine-readable "work that
fde308
+    uses the Library", as object code and/or source code, so that the
fde308
+    user can modify the Library and then relink to produce a modified
fde308
+    executable containing the modified Library.  (It is understood
fde308
+    that the user who changes the contents of definitions files in the
fde308
+    Library will not necessarily be able to recompile the application
fde308
+    to use the modified definitions.)
fde308
+
fde308
+    b) Use a suitable shared library mechanism for linking with the
fde308
+    Library.  A suitable mechanism is one that (1) uses at run time a
fde308
+    copy of the library already present on the user's computer system,
fde308
+    rather than copying library functions into the executable, and (2)
fde308
+    will operate properly with a modified version of the library, if
fde308
+    the user installs one, as long as the modified version is
fde308
+    interface-compatible with the version that the work was made with.
fde308
+
fde308
+    c) Accompany the work with a written offer, valid for at
fde308
+    least three years, to give the same user the materials
fde308
+    specified in Subsection 6a, above, for a charge no more
fde308
+    than the cost of performing this distribution.
fde308
+
fde308
+    d) If distribution of the work is made by offering access to copy
fde308
+    from a designated place, offer equivalent access to copy the above
fde308
+    specified materials from the same place.
fde308
+
fde308
+    e) Verify that the user has already received a copy of these
fde308
+    materials or that you have already sent this user a copy.
fde308
+
fde308
+  For an executable, the required form of the "work that uses the
fde308
+Library" must include any data and utility programs needed for
fde308
+reproducing the executable from it.  However, as a special exception,
fde308
+the materials to be distributed need not include anything that is
fde308
+normally distributed (in either source or binary form) with the major
fde308
+components (compiler, kernel, and so on) of the operating system on
fde308
+which the executable runs, unless that component itself accompanies
fde308
+the executable.
fde308
+
fde308
+  It may happen that this requirement contradicts the license
fde308
+restrictions of other proprietary libraries that do not normally
fde308
+accompany the operating system.  Such a contradiction means you cannot
fde308
+use both them and the Library together in an executable that you
fde308
+distribute.
fde308
+
fde308
+  7. You may place library facilities that are a work based on the
fde308
+Library side-by-side in a single library together with other library
fde308
+facilities not covered by this License, and distribute such a combined
fde308
+library, provided that the separate distribution of the work based on
fde308
+the Library and of the other library facilities is otherwise
fde308
+permitted, and provided that you do these two things:
fde308
+
fde308
+    a) Accompany the combined library with a copy of the same work
fde308
+    based on the Library, uncombined with any other library
fde308
+    facilities.  This must be distributed under the terms of the
fde308
+    Sections above.
fde308
+
fde308
+    b) Give prominent notice with the combined library of the fact
fde308
+    that part of it is a work based on the Library, and explaining
fde308
+    where to find the accompanying uncombined form of the same work.
fde308
+
fde308
+  8. You may not copy, modify, sublicense, link with, or distribute
fde308
+the Library except as expressly provided under this License.  Any
fde308
+attempt otherwise to copy, modify, sublicense, link with, or
fde308
+distribute the Library is void, and will automatically terminate your
fde308
+rights under this License.  However, parties who have received copies,
fde308
+or rights, from you under this License will not have their licenses
fde308
+terminated so long as such parties remain in full compliance.
fde308
+
fde308
+  9. You are not required to accept this License, since you have not
fde308
+signed it.  However, nothing else grants you permission to modify or
fde308
+distribute the Library or its derivative works.  These actions are
fde308
+prohibited by law if you do not accept this License.  Therefore, by
fde308
+modifying or distributing the Library (or any work based on the
fde308
+Library), you indicate your acceptance of this License to do so, and
fde308
+all its terms and conditions for copying, distributing or modifying
fde308
+the Library or works based on it.
fde308
+
fde308
+  10. Each time you redistribute the Library (or any work based on the
fde308
+Library), the recipient automatically receives a license from the
fde308
+original licensor to copy, distribute, link with or modify the Library
fde308
+subject to these terms and conditions.  You may not impose any further
fde308
+restrictions on the recipients' exercise of the rights granted herein.
fde308
+You are not responsible for enforcing compliance by third parties with
fde308
+this License.
fde308
+
fde308
+  11. If, as a consequence of a court judgment or allegation of patent
fde308
+infringement or for any other reason (not limited to patent issues),
fde308
+conditions are imposed on you (whether by court order, agreement or
fde308
+otherwise) that contradict the conditions of this License, they do not
fde308
+excuse you from the conditions of this License.  If you cannot
fde308
+distribute so as to satisfy simultaneously your obligations under this
fde308
+License and any other pertinent obligations, then as a consequence you
fde308
+may not distribute the Library at all.  For example, if a patent
fde308
+license would not permit royalty-free redistribution of the Library by
fde308
+all those who receive copies directly or indirectly through you, then
fde308
+the only way you could satisfy both it and this License would be to
fde308
+refrain entirely from distribution of the Library.
fde308
+
fde308
+If any portion of this section is held invalid or unenforceable under any
fde308
+particular circumstance, the balance of the section is intended to apply,
fde308
+and the section as a whole is intended to apply in other circumstances.
fde308
+
fde308
+It is not the purpose of this section to induce you to infringe any
fde308
+patents or other property right claims or to contest validity of any
fde308
+such claims; this section has the sole purpose of protecting the
fde308
+integrity of the free software distribution system which is
fde308
+implemented by public license practices.  Many people have made
fde308
+generous contributions to the wide range of software distributed
fde308
+through that system in reliance on consistent application of that
fde308
+system; it is up to the author/donor to decide if he or she is willing
fde308
+to distribute software through any other system and a licensee cannot
fde308
+impose that choice.
fde308
+
fde308
+This section is intended to make thoroughly clear what is believed to
fde308
+be a consequence of the rest of this License.
fde308
+
fde308
+  12. If the distribution and/or use of the Library is restricted in
fde308
+certain countries either by patents or by copyrighted interfaces, the
fde308
+original copyright holder who places the Library under this License may add
fde308
+an explicit geographical distribution limitation excluding those countries,
fde308
+so that distribution is permitted only in or among countries not thus
fde308
+excluded.  In such case, this License incorporates the limitation as if
fde308
+written in the body of this License.
fde308
+
fde308
+  13. The Free Software Foundation may publish revised and/or new
fde308
+versions of the Lesser General Public License from time to time.
fde308
+Such new versions will be similar in spirit to the present version,
fde308
+but may differ in detail to address new problems or concerns.
fde308
+
fde308
+Each version is given a distinguishing version number.  If the Library
fde308
+specifies a version number of this License which applies to it and
fde308
+"any later version", you have the option of following the terms and
fde308
+conditions either of that version or of any later version published by
fde308
+the Free Software Foundation.  If the Library does not specify a
fde308
+license version number, you may choose any version ever published by
fde308
+the Free Software Foundation.
fde308
+
fde308
+  14. If you wish to incorporate parts of the Library into other free
fde308
+programs whose distribution conditions are incompatible with these,
fde308
+write to the author to ask for permission.  For software which is
fde308
+copyrighted by the Free Software Foundation, write to the Free
fde308
+Software Foundation; we sometimes make exceptions for this.  Our
fde308
+decision will be guided by the two goals of preserving the free status
fde308
+of all derivatives of our free software and of promoting the sharing
fde308
+and reuse of software generally.
fde308
+
fde308
+			    NO WARRANTY
fde308
+
fde308
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
fde308
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
fde308
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
fde308
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
fde308
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
fde308
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
fde308
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
fde308
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
fde308
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
fde308
+
fde308
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
fde308
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
fde308
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
fde308
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
fde308
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
fde308
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
fde308
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
fde308
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
fde308
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
fde308
+DAMAGES.
fde308
+
fde308
+		     END OF TERMS AND CONDITIONS
fde308
+
fde308
+           How to Apply These Terms to Your New Libraries
fde308
+
fde308
+  If you develop a new library, and you want it to be of the greatest
fde308
+possible use to the public, we recommend making it free software that
fde308
+everyone can redistribute and change.  You can do so by permitting
fde308
+redistribution under these terms (or, alternatively, under the terms of the
fde308
+ordinary General Public License).
fde308
+
fde308
+  To apply these terms, attach the following notices to the library.  It is
fde308
+safest to attach them to the start of each source file to most effectively
fde308
+convey the exclusion of warranty; and each file should have at least the
fde308
+"copyright" line and a pointer to where the full notice is found.
fde308
+
fde308
+    <one line to give the library's name and a brief idea of what it does.>
fde308
+    Copyright (C) <year>  <name of author>
fde308
+
fde308
+    This library is free software; you can redistribute it and/or
fde308
+    modify it under the terms of the GNU Lesser General Public
fde308
+    License as published by the Free Software Foundation; either
fde308
+    version 2.1 of the License, or (at your option) any later version.
fde308
+
fde308
+    This library is distributed in the hope that it will be useful,
fde308
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
fde308
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
fde308
+    Lesser General Public License for more details.
fde308
+
fde308
+    You should have received a copy of the GNU Lesser General Public
fde308
+    License along with this library; if not, write to the Free Software
fde308
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
fde308
+
fde308
+Also add information on how to contact you by electronic and paper mail.
fde308
+
fde308
+You should also get your employer (if you work as a programmer) or your
fde308
+school, if any, to sign a "copyright disclaimer" for the library, if
fde308
+necessary.  Here is a sample; alter the names:
fde308
+
fde308
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
fde308
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
fde308
+
fde308
+  <signature of Ty Coon>, 1 April 1990
fde308
+  Ty Coon, President of Vice
fde308
+
fde308
+That's all there is to it!
fde308
diff --git a/open-vm-tools/services/plugins/appInfo/Makefile.am b/open-vm-tools/services/plugins/appInfo/Makefile.am
fde308
new file mode 100644
fde308
index 0000000..fd1e466
fde308
--- /dev/null
fde308
+++ b/open-vm-tools/services/plugins/appInfo/Makefile.am
fde308
@@ -0,0 +1,37 @@
fde308
+################################################################################
fde308
+### Copyright (C) 2020 VMware, Inc.  All rights reserved.
fde308
+###
fde308
+### This program is free software; you can redistribute it and/or modify
fde308
+### it under the terms of version 2 of the GNU General Public License as
fde308
+### published by the Free Software Foundation.
fde308
+###
fde308
+### This program is distributed in the hope that it will be useful,
fde308
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
fde308
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fde308
+### GNU General Public License for more details.
fde308
+###
fde308
+### You should have received a copy of the GNU General Public License
fde308
+### along with this program; if not, write to the Free Software
fde308
+### Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
fde308
+################################################################################
fde308
+
fde308
+SUBDIRS =
fde308
+
fde308
+plugindir = @VMSVC_PLUGIN_INSTALLDIR@
fde308
+plugin_LTLIBRARIES = libappInfo.la
fde308
+
fde308
+libappInfo_la_CPPFLAGS =
fde308
+libappInfo_la_CPPFLAGS += @PLUGIN_CPPFLAGS@
fde308
+
fde308
+libappInfo_la_LDFLAGS =
fde308
+libappInfo_la_LDFLAGS += @PLUGIN_LDFLAGS@
fde308
+
fde308
+libappInfo_la_LIBADD =
fde308
+libappInfo_la_LIBADD += @VMTOOLS_LIBS@
fde308
+libappInfo_la_LIBADD += @GOBJECT_LIBS@
fde308
+
fde308
+libappInfo_la_SOURCES =
fde308
+libappInfo_la_SOURCES += appInfo.c
fde308
+libappInfo_la_SOURCES += appInfoInt.h
fde308
+libappInfo_la_SOURCES += appInfoUtil.c
fde308
+libappInfo_la_SOURCES += appInfoPosix.c
fde308
diff --git a/open-vm-tools/services/plugins/appInfo/appInfo.c b/open-vm-tools/services/plugins/appInfo/appInfo.c
fde308
new file mode 100644
fde308
index 0000000..b0db092
fde308
--- /dev/null
fde308
+++ b/open-vm-tools/services/plugins/appInfo/appInfo.c
fde308
@@ -0,0 +1,572 @@
fde308
+/*********************************************************
fde308
+ * Copyright (C) 2020 VMware, Inc. All rights reserved.
fde308
+ *
fde308
+ * This program is free software; you can redistribute it and/or modify it
fde308
+ * under the terms of the GNU Lesser General Public License as published
fde308
+ * by the Free Software Foundation version 2.1 and no later version.
fde308
+ *
fde308
+ * This program is distributed in the hope that it will be useful, but
fde308
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
fde308
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
fde308
+ * License for more details.
fde308
+ *
fde308
+ * You should have received a copy of the GNU Lesser General Public License
fde308
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
fde308
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
fde308
+ *
fde308
+ *********************************************************/
fde308
+
fde308
+/*
fde308
+ * appInfo.c --
fde308
+ *
fde308
+ *      Captures the information about running applications inside the guest
fde308
+ *      and publishes it to a guest variable.
fde308
+ */
fde308
+
fde308
+
fde308
+#include <stdio.h>
fde308
+#include <stdlib.h>
fde308
+#include <string.h>
fde308
+
fde308
+#include "appInfo.h"
fde308
+#include "appInfoInt.h"
fde308
+#include "vmware.h"
fde308
+#include "conf.h"
fde308
+#include "dynbuf.h"
fde308
+#include "escape.h"
fde308
+#include "str.h"
fde308
+#include "util.h"
fde308
+#include "vm_atomic.h"
fde308
+#include "vmcheck.h"
fde308
+#include "vmware/tools/log.h"
fde308
+#include "vmware/tools/threadPool.h"
fde308
+#include "vmware/tools/utils.h"
fde308
+
fde308
+#if !defined(__APPLE__)
fde308
+#include "vm_version.h"
fde308
+#include "embed_version.h"
fde308
+#include "vmtoolsd_version.h"
fde308
+VM_EMBED_VERSION(VMTOOLSD_VERSION_STRING);
fde308
+#endif
fde308
+
fde308
+#if defined(_WIN32)
fde308
+#include "codeset.h"
fde308
+#endif
fde308
+
fde308
+/**
fde308
+ * Maximum size of the packet size that appInfo plugin should send
fde308
+ * to the VMX. Currently, this is set to 62 KB.
fde308
+ */
fde308
+#define MAX_APP_INFO_SIZE (62 * 1024)
fde308
+
fde308
+/**
fde308
+ * Default poll interval for appInfo is 30m
fde308
+ */
fde308
+#define APP_INFO_POLL_INTERVAL (30 * 60)
fde308
+
fde308
+/**
fde308
+ * Default value for CONFNAME_APPINFO_DISABLED setting in
fde308
+ * tools configuration file.
fde308
+ *
fde308
+ * FALSE will enable the plugin. TRUE will disable the plugin.
fde308
+ */
fde308
+#define APP_INFO_CONF_DEFAULT_DISABLED_VALUE FALSE
fde308
+
fde308
+/**
fde308
+ * Defines the current poll interval (in seconds).
fde308
+ *
fde308
+ * This value is controlled by the appinfo.poll-interval config file option.
fde308
+ */
fde308
+int appInfoPollInterval = 0;
fde308
+
fde308
+/**
fde308
+ * AppInfo gather loop timeout source.
fde308
+ */
fde308
+static GSource *appInfoTimeoutSource = NULL;
fde308
+
fde308
+
fde308
+/*
fde308
+ *****************************************************************************
fde308
+ * EscapeJSONString --
fde308
+ *
fde308
+ * Escapes a string to be included in JSON content.
fde308
+ *
fde308
+ * @param[in] str The string to be escaped.
fde308
+ *
fde308
+ * @retval Pointer to a heap-allocated memory. This holds the escaped content
fde308
+ *         of the string passed by the caller.
fde308
+ *
fde308
+ *****************************************************************************
fde308
+ */
fde308
+
fde308
+static char *
fde308
+EscapeJSONString(const char *str)    // IN
fde308
+{
fde308
+   /*
fde308
+    * Escape '"' and '\' characters in the JSON string.
fde308
+    */
fde308
+
fde308
+   static const int bytesToEscape[] = {
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,   // "
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,   // '\'
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+      0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
fde308
+   };
fde308
+
fde308
+   return Escape_DoString("\\u00", bytesToEscape, str, strlen(str),
fde308
+                          NULL);
fde308
+}
fde308
+
fde308
+
fde308
+/*
fde308
+ *****************************************************************************
fde308
+ * SetGuestInfo --
fde308
+ *
fde308
+ * Sends a simple key-value update request to the VMX.
fde308
+ *
fde308
+ * @param[in] ctx       Application context.
fde308
+ * @param[in] key       Key sent to the VMX
fde308
+ * @param[in] value     GuestInfo data sent to the VMX
fde308
+ *
fde308
+ * @retval TRUE  RPCI succeeded.
fde308
+ * @retval FALSE RPCI failed.
fde308
+ *
fde308
+ *****************************************************************************
fde308
+ */
fde308
+
fde308
+static Bool
fde308
+SetGuestInfo(ToolsAppCtx *ctx,              // IN:
fde308
+             const char *guestVariableName, // IN:
fde308
+             const char *value)             // IN:
fde308
+{
fde308
+   Bool status;
fde308
+   char *reply = NULL;
fde308
+   gchar *msg;
fde308
+   size_t replyLen;
fde308
+
fde308
+   ASSERT(guestVariableName);
fde308
+   ASSERT(value);
fde308
+
fde308
+   msg = g_strdup_printf("info-set guestinfo.%s %s",
fde308
+                         guestVariableName,
fde308
+                         value);
fde308
+
fde308
+   status = RpcChannel_Send(ctx->rpc,
fde308
+                            msg,
fde308
+                            strlen(msg) + 1,
fde308
+                            &reply,
fde308
+                            &replyLen);
fde308
+   g_free(msg);
fde308
+
fde308
+   if (!status) {
fde308
+      g_warning("Error sending RPC message: %s\n", reply ? reply : "NULL");
fde308
+      vm_free(reply);
fde308
+      return FALSE;
fde308
+   } else {
fde308
+      g_info("Successfully sent the app information.\n");
fde308
+   }
fde308
+
fde308
+   status = (*reply == '\0');
fde308
+   vm_free(reply);
fde308
+   return status;
fde308
+}
fde308
+
fde308
+
fde308
+/*
fde308
+ *****************************************************************************
fde308
+ * AppInfoGatherTask --
fde308
+ *
fde308
+ * Collects all the desired application related information and updates VMX.
fde308
+ *
fde308
+ * @param[in]  data     The application context.
fde308
+ *
fde308
+ *****************************************************************************
fde308
+ */
fde308
+
fde308
+static void
fde308
+AppInfoGatherTask(ToolsAppCtx *ctx,
fde308
+                  void *data)
fde308
+{
fde308
+   DynBuf dynBuffer;
fde308
+   char tmpBuf[1024];
fde308
+   int len;
fde308
+   gchar *tstamp = NULL;
fde308
+   char *escapedCmd = NULL;
fde308
+   char *escapedVersion = NULL;
fde308
+   GSList *appList = NULL;
fde308
+   GSList *appNode;
fde308
+   static Atomic_uint64 updateCounter = {0};
fde308
+   uint64 counter = (uint64) Atomic_ReadInc64(&updateCounter) + 1;
fde308
+
fde308
+   static char headerFmt[] = "{\n"
fde308
+                     "\"" APP_INFO_KEY_VERSION        "\":\"%d\", \n"
fde308
+                     "\"" APP_INFO_KEY_UPDATE_COUNTER "\":\"%"FMT64"d\", \n"
fde308
+                     "\"" APP_INFO_KEY_PUBLISHTIME    "\":\"%s\", \n"
fde308
+                     "\"" APP_INFO_KEY_APPS           "\":[";
fde308
+   static char jsonPerAppFmt[] =
fde308
+                           "%s\n" // , for all the elements after the first one
fde308
+                           "{"
fde308
+                           "\"" APP_INFO_KEY_APP_NAME    "\":\"%s\""
fde308
+                           ","
fde308
+                           "\"" APP_INFO_KEY_APP_VERSION "\":\"%s\""
fde308
+                           "}";
fde308
+   static char jsonSuffix[] = "]}";
fde308
+
fde308
+   DynBuf_Init(&dynBuffer);
fde308
+
fde308
+   tstamp = VMTools_GetTimeAsString();
fde308
+
fde308
+   len = Str_Snprintf(tmpBuf, sizeof tmpBuf, headerFmt,
fde308
+                      APP_INFO_VERSION_1,
fde308
+                      counter,
fde308
+                      tstamp != NULL ? tstamp : "");
fde308
+
fde308
+   if (len < 0) {
fde308
+      g_warning("Insufficient space for the header.\n");
fde308
+      goto abort;
fde308
+   }
fde308
+
fde308
+   DynBuf_Append(&dynBuffer, tmpBuf, len);
fde308
+
fde308
+   appList = AppInfo_SortAppList(AppInfo_GetAppList());
fde308
+
fde308
+   for (appNode = appList; appNode != NULL; appNode = appNode->next) {
fde308
+      size_t currentBufferSize = DynBuf_GetSize(&dynBuffer);
fde308
+      AppInfo *appInfo = (AppInfo *) appNode->data;
fde308
+
fde308
+      if (appInfo->appName == NULL ||
fde308
+          appInfo->version == NULL) {
fde308
+         goto next_entry;
fde308
+      }
fde308
+
fde308
+      escapedCmd = EscapeJSONString(appInfo->appName);
fde308
+
fde308
+      if (NULL == escapedCmd) {
fde308
+         g_warning("Failed to escape the content of cmdName\n");
fde308
+         goto abort;
fde308
+      }
fde308
+
fde308
+      escapedVersion = EscapeJSONString(appInfo->version);
fde308
+      if (NULL == escapedVersion) {
fde308
+         g_warning("Failed to escape the content of version information.\n");
fde308
+         goto abort;
fde308
+      }
fde308
+
fde308
+      if (appNode == appList) {
fde308
+         len = Str_Snprintf(tmpBuf, sizeof tmpBuf, jsonPerAppFmt,
fde308
+                            "", escapedCmd, escapedVersion);
fde308
+      } else {
fde308
+         /*
fde308
+          * If this is not the first element, then add ',' at the beginning.
fde308
+          */
fde308
+         len = Str_Snprintf(tmpBuf, sizeof tmpBuf, jsonPerAppFmt,
fde308
+                            ",", escapedCmd, escapedVersion);
fde308
+      }
fde308
+
fde308
+      if (len < 0) {
fde308
+         g_warning("Insufficient space for the application information.\n");
fde308
+         goto next_entry;
fde308
+      }
fde308
+
fde308
+      if (currentBufferSize + len + sizeof jsonSuffix > MAX_APP_INFO_SIZE) {
fde308
+         g_warning("Exceeded the max info packet size."
fde308
+                   " Truncating the rest of the applications.\n");
fde308
+         break;
fde308
+      }
fde308
+
fde308
+      DynBuf_Append(&dynBuffer, tmpBuf, len);
fde308
+
fde308
+next_entry:
fde308
+      free(escapedCmd);
fde308
+      escapedCmd = NULL;
fde308
+      free(escapedVersion);
fde308
+      escapedVersion = NULL;
fde308
+   }
fde308
+
fde308
+   DynBuf_Append(&dynBuffer, jsonSuffix, sizeof jsonSuffix - 1);
fde308
+   SetGuestInfo(ctx, APP_INFO_GUESTVAR_KEY, DynBuf_GetString(&dynBuffer));
fde308
+
fde308
+abort:
fde308
+   free(escapedCmd);
fde308
+   free(escapedVersion);
fde308
+   AppInfo_DestroyAppList(appList);
fde308
+   g_free(tstamp);
fde308
+   DynBuf_Destroy(&dynBuffer);
fde308
+}
fde308
+
fde308
+
fde308
+/*
fde308
+ *****************************************************************************
fde308
+ * AppInfoGather --
fde308
+ *
fde308
+ * Creates a new thread that collects all the desired application related
fde308
+ * information and udates the VMX.
fde308
+ *
fde308
+ * @param[in]  data     The application context.
fde308
+ *
fde308
+ * @return TRUE to indicate that the timer should be rescheduled.
fde308
+ *
fde308
+ *****************************************************************************
fde308
+ */
fde308
+
fde308
+static gboolean
fde308
+AppInfoGather(gpointer data)
fde308
+{
fde308
+   ToolsAppCtx *ctx = data;
fde308
+   if (!ToolsCorePool_SubmitTask(ctx, AppInfoGatherTask, NULL, NULL)) {
fde308
+      g_warning("%s: failed to start information gather thread\n",
fde308
+                __FUNCTION__);
fde308
+   }
fde308
+
fde308
+   return TRUE;
fde308
+}
fde308
+
fde308
+
fde308
+/*
fde308
+ *****************************************************************************
fde308
+ * TweakGatherLoop --
fde308
+ *
fde308
+ * @brief Start, stop, reconfigure a GuestInfoGather poll loop.
fde308
+ *
fde308
+ * This function is responsible for creating, manipulating, and resetting a
fde308
+ * AppDiscoveryGather loop timeout source.
fde308
+ *
fde308
+ * @param[in]     ctx           The app context.
fde308
+ * @param[in]     enable        Whether to enable the gather loop.
fde308
+ *
fde308
+ *****************************************************************************
fde308
+ */
fde308
+
fde308
+static void
fde308
+TweakGatherLoop(ToolsAppCtx *ctx,
fde308
+                gboolean enable)
fde308
+{
fde308
+   gint pollInterval = 0;
fde308
+
fde308
+   if (enable) {
fde308
+      pollInterval = APP_INFO_POLL_INTERVAL * 1000;
fde308
+
fde308
+      /*
fde308
+      * Check the config registry for custom poll interval,
fde308
+      * converting from seconds to milliseconds.
fde308
+      */
fde308
+      if (g_key_file_has_key(ctx->config, CONFGROUPNAME_APPINFO,
fde308
+                             CONFNAME_APPINFO_POLLINTERVAL, NULL)) {
fde308
+         GError *gError = NULL;
fde308
+
fde308
+         pollInterval = g_key_file_get_integer(ctx->config,
fde308
+                                               CONFGROUPNAME_APPINFO,
fde308
+                                               CONFNAME_APPINFO_POLLINTERVAL,
fde308
+                                               &gError);
fde308
+         pollInterval *= 1000;
fde308
+
fde308
+         if (pollInterval < 0 || gError) {
fde308
+            g_warning("Invalid %s.%s value. Using default %us.\n",
fde308
+                      CONFGROUPNAME_APPINFO,
fde308
+                      CONFNAME_APPINFO_POLLINTERVAL,
fde308
+                      APP_INFO_POLL_INTERVAL);
fde308
+            pollInterval = APP_INFO_POLL_INTERVAL * 1000;
fde308
+         }
fde308
+
fde308
+         g_clear_error(&gError);
fde308
+      }
fde308
+   }
fde308
+
fde308
+   if (appInfoTimeoutSource != NULL) {
fde308
+      /*
fde308
+       * If the interval hasn't changed, let's not interfere with the existing
fde308
+       * timeout source.
fde308
+       */
fde308
+      if (pollInterval == appInfoPollInterval) {
fde308
+         ASSERT(pollInterval);
fde308
+         return;
fde308
+      }
fde308
+
fde308
+      /*
fde308
+       * Destroy the existing timeout source since the interval has changed.
fde308
+       */
fde308
+
fde308
+      g_source_destroy(appInfoTimeoutSource);
fde308
+      appInfoTimeoutSource = NULL;
fde308
+   }
fde308
+
fde308
+   /*
fde308
+    * All checks have passed.  Create a new timeout source and attach it.
fde308
+    */
fde308
+   appInfoPollInterval = pollInterval;
fde308
+
fde308
+   if (appInfoPollInterval) {
fde308
+      g_info("New value for %s is %us.\n",
fde308
+             CONFNAME_APPINFO_POLLINTERVAL,
fde308
+             appInfoPollInterval / 1000);
fde308
+
fde308
+      appInfoTimeoutSource = g_timeout_source_new(appInfoPollInterval);
fde308
+      VMTOOLSAPP_ATTACH_SOURCE(ctx, appInfoTimeoutSource,
fde308
+                               AppInfoGather, ctx, NULL);
fde308
+      g_source_unref(appInfoTimeoutSource);
fde308
+   } else {
fde308
+      g_info("Poll loop for %s disabled.\n", CONFNAME_APPINFO_POLLINTERVAL);
fde308
+      SetGuestInfo(ctx, APP_INFO_GUESTVAR_KEY, "");
fde308
+   }
fde308
+}
fde308
+
fde308
+
fde308
+/*
fde308
+ *****************************************************************************
fde308
+ * AppInfoServerConfReload --
fde308
+ *
fde308
+ * @brief Reconfigures the poll loop interval upon config file reload.
fde308
+ *
fde308
+ * @param[in]  src     The source object.
fde308
+ * @param[in]  ctx     The application context.
fde308
+ * @param[in]  data    Unused.
fde308
+ *
fde308
+ *****************************************************************************
fde308
+ */
fde308
+
fde308
+static void
fde308
+AppInfoServerConfReload(gpointer src,
fde308
+                        ToolsAppCtx *ctx,
fde308
+                        gpointer data)
fde308
+{
fde308
+   gboolean disabled =
fde308
+      VMTools_ConfigGetBoolean(ctx->config,
fde308
+                               CONFGROUPNAME_APPINFO,
fde308
+                               CONFNAME_APPINFO_DISABLED,
fde308
+                               APP_INFO_CONF_DEFAULT_DISABLED_VALUE);
fde308
+   TweakGatherLoop(ctx, !disabled);
fde308
+}
fde308
+
fde308
+
fde308
+/*
fde308
+ *****************************************************************************
fde308
+ * AppInfoServerShutdown --
fde308
+ *
fde308
+ * Cleanup internal data on shutdown.
fde308
+ *
fde308
+ * @param[in]  src     The source object.
fde308
+ * @param[in]  ctx     Unused.
fde308
+ * @param[in]  data    Unused.
fde308
+ *
fde308
+ *****************************************************************************
fde308
+ */
fde308
+
fde308
+static void
fde308
+AppInfoServerShutdown(gpointer src,
fde308
+                      ToolsAppCtx *ctx,
fde308
+                      gpointer data)
fde308
+{
fde308
+   if (appInfoTimeoutSource != NULL) {
fde308
+      g_source_destroy(appInfoTimeoutSource);
fde308
+      appInfoTimeoutSource = NULL;
fde308
+   }
fde308
+
fde308
+   SetGuestInfo(ctx, APP_INFO_GUESTVAR_KEY, "");
fde308
+}
fde308
+
fde308
+
fde308
+/*
fde308
+ *****************************************************************************
fde308
+ * ToolsOnLoad --
fde308
+ *
fde308
+ * Plugin entry point. Initializes internal plugin state.
fde308
+ *
fde308
+ * @param[in]  ctx   The app context.
fde308
+ *
fde308
+ * @return The registration data.
fde308
+ *
fde308
+ *****************************************************************************
fde308
+ */
fde308
+
fde308
+TOOLS_MODULE_EXPORT ToolsPluginData *
fde308
+ToolsOnLoad(ToolsAppCtx *ctx)
fde308
+{
fde308
+   static ToolsPluginData regData = {
fde308
+      "appInfo",
fde308
+      NULL,
fde308
+      NULL
fde308
+   };
fde308
+
fde308
+   uint32 vmxVersion = 0;
fde308
+   uint32 vmxType = VMX_TYPE_UNSET;
fde308
+
fde308
+   /*
fde308
+    * Return NULL to disable the plugin if not running in a VMware VM.
fde308
+    */
fde308
+   if (!ctx->isVMware) {
fde308
+      g_info("Not running in a VMware VM.\n");
fde308
+      return NULL;
fde308
+   }
fde308
+
fde308
+   /*
fde308
+    * Return NULL to disable the plugin if VM is not running on ESX host.
fde308
+    */
fde308
+   if (!VmCheck_GetVersion(&vmxVersion, &vmxType) ||
fde308
+       vmxType != VMX_TYPE_SCALABLE_SERVER) {
fde308
+      g_info("VM is not running on ESX host.\n");
fde308
+      return NULL;
fde308
+   }
fde308
+
fde308
+   /*
fde308
+    * Return NULL to disable the plugin if not running in vmsvc daemon.
fde308
+    */
fde308
+   if (!TOOLS_IS_MAIN_SERVICE(ctx)) {
fde308
+      g_info("Not running in vmsvc daemon: container name='%s'.\n",
fde308
+             ctx->name);
fde308
+      return NULL;
fde308
+   }
fde308
+
fde308
+   /*
fde308
+    * This plugin is useless without an RpcChannel.  If we don't have one,
fde308
+    * just bail.
fde308
+    */
fde308
+   if (ctx->rpc != NULL) {
fde308
+      ToolsPluginSignalCb sigs[] = {
fde308
+         { TOOLS_CORE_SIG_CONF_RELOAD, AppInfoServerConfReload, NULL },
fde308
+         { TOOLS_CORE_SIG_SHUTDOWN, AppInfoServerShutdown, NULL }
fde308
+      };
fde308
+      ToolsAppReg regs[] = {
fde308
+         { TOOLS_APP_SIGNALS,
fde308
+           VMTools_WrapArray(sigs, sizeof *sigs, ARRAYSIZE(sigs))
fde308
+         }
fde308
+      };
fde308
+
fde308
+      gboolean disabled = FALSE;
fde308
+
fde308
+      regData.regs = VMTools_WrapArray(regs,
fde308
+                                       sizeof *regs,
fde308
+                                       ARRAYSIZE(regs));
fde308
+
fde308
+      /*
fde308
+       * Set up the AppInfo gather loop.
fde308
+       */
fde308
+      disabled =
fde308
+         VMTools_ConfigGetBoolean(ctx->config,
fde308
+                                  CONFGROUPNAME_APPINFO,
fde308
+                                  CONFNAME_APPINFO_DISABLED,
fde308
+                                  APP_INFO_CONF_DEFAULT_DISABLED_VALUE);
fde308
+      TweakGatherLoop(ctx, !disabled);
fde308
+
fde308
+      return &regData;
fde308
+   }
fde308
+
fde308
+   return NULL;
fde308
+}
fde308
+
fde308
+
fde308
+/*
fde308
+ * END Tools Core Services goodies.
fde308
+ *****************************************************************************
fde308
+ */
fde308
diff --git a/open-vm-tools/services/plugins/appInfo/appInfoInt.h b/open-vm-tools/services/plugins/appInfo/appInfoInt.h
fde308
new file mode 100644
fde308
index 0000000..1897926
fde308
--- /dev/null
fde308
+++ b/open-vm-tools/services/plugins/appInfo/appInfoInt.h
fde308
@@ -0,0 +1,64 @@
fde308
+/*********************************************************
fde308
+ * Copyright (C) 2020 VMware, Inc. All rights reserved.
fde308
+ *
fde308
+ * This program is free software; you can redistribute it and/or modify it
fde308
+ * under the terms of the GNU Lesser General Public License as published
fde308
+ * by the Free Software Foundation version 2.1 and no later version.
fde308
+ *
fde308
+ * This program is distributed in the hope that it will be useful, but
fde308
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
fde308
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
fde308
+ * License for more details.
fde308
+ *
fde308
+ * You should have received a copy of the GNU Lesser General Public License
fde308
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
fde308
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
fde308
+ *
fde308
+ *********************************************************/
fde308
+
fde308
+#ifndef _APPINFOINT_H_
fde308
+#define _APPINFOINT_H_
fde308
+
fde308
+/**
fde308
+ * @file appInfoInt.h
fde308
+ *
fde308
+ * Header file with few functions that are internal to appInfo plugin.
fde308
+ */
fde308
+
fde308
+#define G_LOG_DOMAIN "appInfo"
fde308
+#include "vm_basic_types.h"
fde308
+#include <glib.h>
fde308
+#include "vmware/tools/plugin.h"
fde308
+
fde308
+#if defined(_WIN32)
fde308
+
fde308
+#include <windows.h>
fde308
+typedef DWORD AppInfo_Pid;
fde308
+
fde308
+#else /* POSIX */
fde308
+
fde308
+#include <sys/types.h>
fde308
+typedef pid_t AppInfo_Pid;
fde308
+
fde308
+#endif
fde308
+
fde308
+/*
fde308
+ * Application information structure.
fde308
+ * This holds basic information we return per process
fde308
+ * when listing process information inside the guest.
fde308
+ */
fde308
+
fde308
+typedef struct AppInfo {
fde308
+   AppInfo_Pid procId;
fde308
+   char *appName;             // UTF-8
fde308
+   char *version;
fde308
+#if defined(_WIN32)
fde308
+   size_t memoryUsed;
fde308
+#endif
fde308
+} AppInfo;
fde308
+
fde308
+GSList *AppInfo_GetAppList(void);
fde308
+GSList *AppInfo_SortAppList(GSList *appList);
fde308
+
fde308
+void AppInfo_DestroyAppList(GSList *appList);
fde308
+#endif /* _APPINFOINT_H_ */
fde308
diff --git a/open-vm-tools/services/plugins/appInfo/appInfoPosix.c b/open-vm-tools/services/plugins/appInfo/appInfoPosix.c
fde308
new file mode 100644
fde308
index 0000000..d7b05be
fde308
--- /dev/null
fde308
+++ b/open-vm-tools/services/plugins/appInfo/appInfoPosix.c
fde308
@@ -0,0 +1,124 @@
fde308
+/*********************************************************
fde308
+ * Copyright (C) 2020 VMware, Inc. All rights reserved.
fde308
+ *
fde308
+ * This program is free software; you can redistribute it and/or modify it
fde308
+ * under the terms of the GNU Lesser General Public License as published
fde308
+ * by the Free Software Foundation version 2.1 and no later version.
fde308
+ *
fde308
+ * This program is distributed in the hope that it will be useful, but
fde308
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
fde308
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
fde308
+ * License for more details.
fde308
+ *
fde308
+ * You should have received a copy of the GNU Lesser General Public License
fde308
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
fde308
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
fde308
+ *
fde308
+ *********************************************************/
fde308
+
fde308
+/*
fde308
+ * appInfoPosix.c --
fde308
+ *
fde308
+ *      Functions to capture the information about running applications inside
fde308
+ *      a Linux guest.
fde308
+ *
fde308
+ */
fde308
+
fde308
+#ifndef __linux__
fde308
+#   error This file should not be compiled.
fde308
+#endif
fde308
+
fde308
+
fde308
+#include <stdio.h>
fde308
+#include <stdlib.h>
fde308
+#include <string.h>
fde308
+
fde308
+#include "appInfoInt.h"
fde308
+#include "procMgr.h"
fde308
+#include "vmware.h"
fde308
+#include "str.h"
fde308
+#include "util.h"
fde308
+
fde308
+
fde308
+/*
fde308
+ *----------------------------------------------------------------------
fde308
+ * AppInfoGetAppInfo --
fde308
+ *
fde308
+ * Retrieves the application information for a specified process.
fde308
+ *
fde308
+ * @param[in] procInfo   Information about a process.
fde308
+ *
fde308
+ * @retval The application information. The caller must free the memory
fde308
+ *         allocated for the application information.
fde308
+ *         NULL if any error happens.
fde308
+ *
fde308
+ *----------------------------------------------------------------------
fde308
+ */
fde308
+
fde308
+AppInfo *
fde308
+AppInfoGetAppInfo(ProcMgrProcInfo *procInfo)   // IN
fde308
+{
fde308
+   AppInfo *appInfo = NULL;
fde308
+
fde308
+   if (procInfo == NULL) {
fde308
+      return appInfo;
fde308
+   }
fde308
+
fde308
+   if (procInfo->procCmdName == NULL) {
fde308
+      return appInfo;
fde308
+   }
fde308
+
fde308
+   appInfo = Util_SafeMalloc(sizeof (*appInfo) * 1);
fde308
+   appInfo->procId = procInfo->procId;
fde308
+   appInfo->appName = Util_SafeStrdup(procInfo->procCmdName);
fde308
+   appInfo->version = Util_SafeStrdup("");
fde308
+
fde308
+   return appInfo;
fde308
+}
fde308
+
fde308
+
fde308
+/*
fde308
+ *----------------------------------------------------------------------
fde308
+ * AppInfo_GetAppList --
fde308
+ *
fde308
+ * Generates the application information list.
fde308
+ *
fde308
+ * @retval Pointer to the newly allocated application list. The caller must
fde308
+ *         free the memory using AppInfoDestroyAppList function.
fde308
+ *         NULL if any error occurs.
fde308
+ *
fde308
+ *----------------------------------------------------------------------
fde308
+ */
fde308
+
fde308
+GSList *
fde308
+AppInfo_GetAppList(void) {
fde308
+   GSList *appList = NULL;
fde308
+   int i;
fde308
+   ProcMgrProcInfoArray *procList = NULL;
fde308
+   size_t procCount;
fde308
+
fde308
+#if defined(_WIN32)
fde308
+   procList = ProcMgr_ListProcessesEx();
fde308
+#else
fde308
+   procList = ProcMgr_ListProcesses();
fde308
+#endif
fde308
+
fde308
+   if (procList == NULL) {
fde308
+      g_warning("Failed to get the list of processes.\n");
fde308
+      return appList;
fde308
+   }
fde308
+
fde308
+   procCount = ProcMgrProcInfoArray_Count(procList);
fde308
+   for (i = 0; i < procCount; i++) {
fde308
+      AppInfo *appInfo;
fde308
+      ProcMgrProcInfo *procInfo = ProcMgrProcInfoArray_AddressOf(procList, i);
fde308
+      appInfo = AppInfoGetAppInfo(procInfo);
fde308
+      if (NULL != appInfo) {
fde308
+         appList = g_slist_prepend(appList, appInfo);
fde308
+      }
fde308
+   }
fde308
+
fde308
+   ProcMgr_FreeProcList(procList);
fde308
+
fde308
+   return appList;
fde308
+}
fde308
diff --git a/open-vm-tools/services/plugins/appInfo/appInfoUtil.c b/open-vm-tools/services/plugins/appInfo/appInfoUtil.c
fde308
new file mode 100644
fde308
index 0000000..f0327ec
fde308
--- /dev/null
fde308
+++ b/open-vm-tools/services/plugins/appInfo/appInfoUtil.c
fde308
@@ -0,0 +1,143 @@
fde308
+/*********************************************************
fde308
+ * Copyright (C) 2020 VMware, Inc. All rights reserved.
fde308
+ *
fde308
+ * This program is free software; you can redistribute it and/or modify it
fde308
+ * under the terms of the GNU Lesser General Public License as published
fde308
+ * by the Free Software Foundation version 2.1 and no later version.
fde308
+ *
fde308
+ * This program is distributed in the hope that it will be useful, but
fde308
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
fde308
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
fde308
+ * License for more details.
fde308
+ *
fde308
+ * You should have received a copy of the GNU Lesser General Public License
fde308
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
fde308
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
fde308
+ *
fde308
+ *********************************************************/
fde308
+
fde308
+/*
fde308
+ * appInfoUtil.c --
fde308
+ *
fde308
+ *      Utility functions for the application list information.
fde308
+ */
fde308
+
fde308
+
fde308
+#include <stdio.h>
fde308
+#include <stdlib.h>
fde308
+#include "appInfoInt.h"
fde308
+
fde308
+
fde308
+/*
fde308
+ ******************************************************************************
fde308
+ * AppInfoDestroyAppData --
fde308
+ *
fde308
+ * Free function for application data. This function is called by the glib
fde308
+ * for each element in the application list while freeing.
fde308
+ *
fde308
+ * @param[in] data      Pointer to the application data.
fde308
+ *
fde308
+ * @retval NONE
fde308
+ *
fde308
+ ******************************************************************************
fde308
+ */
fde308
+
fde308
+void
fde308
+AppInfoDestroyAppData(gpointer data) {
fde308
+   AppInfo *appInfo = (AppInfo *) data;
fde308
+
fde308
+   if (appInfo == NULL) {
fde308
+      return;
fde308
+   }
fde308
+
fde308
+   free(appInfo->appName);
fde308
+   free(appInfo->version);
fde308
+   free(appInfo);
fde308
+}
fde308
+
fde308
+
fde308
+/*
fde308
+ ******************************************************************************
fde308
+ * AppInfoDestroyAppList --
fde308
+ *
fde308
+ * Frees the entire memory allocated for the application list.
fde308
+ *
fde308
+ * @param[in] appList      Pointer to the application list.
fde308
+ *
fde308
+ * @retval NONE
fde308
+ *
fde308
+ ******************************************************************************
fde308
+ */
fde308
+
fde308
+void
fde308
+AppInfo_DestroyAppList(GSList *appList) {
fde308
+   if (appList == NULL) {
fde308
+      return;
fde308
+   }
fde308
+
fde308
+   g_slist_free_full(appList, AppInfoDestroyAppData);
fde308
+}
fde308
+
fde308
+
fde308
+/*
fde308
+ ******************************************************************************
fde308
+ * AppInfoCompareApps --
fde308
+ *
fde308
+ * Compare function used by glib while sorting the application list.
fde308
+ * For windows guests, the memory used by the application is used for comparing.
fde308
+ * For linux guests, no comparison is done and hence 0 is returned.
fde308
+ *
fde308
+ * @param[in] a      Pointer to the first application that should be compared.
fde308
+ * @param[in] b      Pointer to the second application that should be compared.
fde308
+ *
fde308
+ * @retval -1 if a should be kept before b in the sorted list.
fde308
+ *          0 if both the elements are same.
fde308
+ *          1 if b should be kept before a in the sorted list.
fde308
+ *
fde308
+ ******************************************************************************
fde308
+ */
fde308
+
fde308
+static gint
fde308
+AppInfoCompareApps(gconstpointer a,
fde308
+                   gconstpointer b) {
fde308
+#if defined(_WIN32)
fde308
+   if (a != NULL && b != NULL) {
fde308
+      size_t aMemory = ((AppInfo *) a)->memoryUsed;
fde308
+      size_t bMemory = ((AppInfo *) b)->memoryUsed;
fde308
+      if (aMemory < bMemory) {
fde308
+         return 1;
fde308
+      } else if (aMemory == bMemory) {
fde308
+         return 0;
fde308
+      } else {
fde308
+         return -1;
fde308
+      }
fde308
+   }
fde308
+   return 0;
fde308
+#else
fde308
+   return 0;
fde308
+#endif
fde308
+}
fde308
+
fde308
+
fde308
+/*
fde308
+ ******************************************************************************
fde308
+ * AppInfo_SortAppList --
fde308
+ *
fde308
+ * Sorts the provided list of applications.
fde308
+ *
fde308
+ * @param[in] appList List of applications that need to be sorted.
fde308
+ *
fde308
+ * @retval The sorted list of applications.
fde308
+ *
fde308
+ ******************************************************************************
fde308
+ */
fde308
+
fde308
+GSList *
fde308
+AppInfo_SortAppList(GSList *appList) // IN/OUT
fde308
+{
fde308
+   if (appList == NULL) {
fde308
+      return appList;
fde308
+   }
fde308
+
fde308
+   return g_slist_sort(appList, AppInfoCompareApps);
fde308
+}
fde308
-- 
fde308
1.8.3.1
fde308