diff options
author | ramon <ramongomez@us.es> | 2018-01-15 12:16:18 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2018-01-15 12:16:18 +0000 |
commit | 2f3d0532faa68eed97c28a1120b0b134b6859198 (patch) | |
tree | acfd6711139bb5d822cc4bbc5ee5c5bdc292a9d9 /client/engine/Inventory.lib | |
parent | f2e6a2ee2b4363cd22d90d6bff362c0d89c142da (diff) |
#823: Función {{{ogListSoftware}}} accede al registro de Windows con {{{hivexregedit}}}.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5555 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'client/engine/Inventory.lib')
-rwxr-xr-x | client/engine/Inventory.lib | 58 |
1 files changed, 40 insertions, 18 deletions
diff --git a/client/engine/Inventory.lib b/client/engine/Inventory.lib index ce8cba68..5ad4649b 100755 --- a/client/engine/Inventory.lib +++ b/client/engine/Inventory.lib @@ -354,7 +354,7 @@ lshw | awk 'BEGIN {type="mod";} function ogListSoftware () { # Variables locales. -local MNTDIR TYPE DPKGDIR RPMDIR PACMANDIR KEYS KEYS32 k PROG VERS +local MNTDIR TYPE DPKGDIR RPMDIR PACMANDIR k # Si se solicita, mostrar ayuda. if [ "$*" == "help" ]; then @@ -412,24 +412,46 @@ for k in db.keys(): fi ;; Windows) # Software de Windows. - # Claves de registro para programas instalados: formato "{clave}". - KEYS=$(ogListRegistryKeys $MNTDIR software '\Microsoft\Windows\CurrentVersion\Uninstall') - KEYS32=$(ogListRegistryKeys $MNTDIR software '\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall') - # Mostrar los valores "DisplayName" y "DisplayVersion" para cada clave. - (for k in $KEYS; do - PROG=$(ogGetRegistryValue $MNTDIR software "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayName") - if [ -n "$PROG" ]; then - VERS=$(ogGetRegistryValue $MNTDIR software "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayVersion") - echo "$PROG $VERS" + # Comprobar tipo de proceso del registro de Windows. + if which hivexregedit &>/dev/null; then + # Nuevo proceso más rápido basado en "hivexregedit". + local HIVE TMPFILE + HIVE=$(ogGetHivePath $MNTDIR software 2>/dev/null) + if [ -n "$HIVE" ]; then + # Claves de registro para programas instalados. + TMPFILE=/tmp/tmp$$ + trap "rm -f $TMPFILE" 1 2 3 9 15 + hivexregedit --unsafe-printable-strings --export "$HIVE" '\Microsoft\Windows\CurrentVersion\Uninstall' > $TMPFILE 2>/dev/null + hivexregedit --unsafe-printable-strings --export "$HIVE" '\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall' >> $TMPFILE 2>/dev/null + # Mostrar los valores "DisplayName" y "DisplayVersion" para cada clave. + awk -F\" '$1~/^\[/ {n=""} + $2~/DisplayName/ {n=$4} + $2~/DisplayVersion/ {print n,$4} + ' $TMPFILE | sort | uniq + rm -f $TMPFILE fi - done - for k in $KEYS32; do - PROG=$(ogGetRegistryValue $MNTDIR software "\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayName") - if [ -n "$PROG" ]; then - VERS=$(ogGetRegistryValue $MNTDIR software "\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayVersion") - echo "$PROG $VERS" - fi - done) | sort | uniq + else + # Compatibilidad con clientes ogLive antiguos. + local KEYS KEYS32 PROG VERS + # Claves de registro para programas instalados: formato "{clave}". + KEYS=$(ogListRegistryKeys $MNTDIR software '\Microsoft\Windows\CurrentVersion\Uninstall') + KEYS32=$(ogListRegistryKeys $MNTDIR software '\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall') + # Mostrar los valores "DisplayName" y "DisplayVersion" para cada clave. + (for k in $KEYS; do + PROG=$(ogGetRegistryValue $MNTDIR software "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayName") + if [ -n "$PROG" ]; then + VERS=$(ogGetRegistryValue $MNTDIR software "\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayVersion") + echo "$PROG $VERS" + fi + done + for k in $KEYS32; do + PROG=$(ogGetRegistryValue $MNTDIR software "\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayName") + if [ -n "$PROG" ]; then + VERS=$(ogGetRegistryValue $MNTDIR software "\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\$k\\DisplayVersion") + echo "$PROG $VERS" + fi + done) | sort | uniq + fi ;; MacOS) # Software de Mac OS. # Listar directorios de aplicaciones e intentar obtener la versión del fichero .plist (tanto original como descomprimido). |