diff options
author | ramon <ramongomez@us.es> | 2018-01-22 11:20:51 +0000 |
---|---|---|
committer | ramon <ramongomez@us.es> | 2018-01-22 11:20:51 +0000 |
commit | 58718f504ebf4c288fc1f8e505bf6e6c883db885 (patch) | |
tree | cc9d787c44fd0d2ef04bc93e3d4a7e4636d49bbf /client | |
parent | f7f7a213caaec5ae4b20b3c036a01a6397bda1bf (diff) |
Cerrar #823: Métodos más rápido para localizar ficheros y para obtener versión en Windows; cambiar {{{Mac OS...}}} por {{{macOS...}}} en función {{{ogGetOsVersion}}}.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@5576 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'client')
-rwxr-xr-x | client/engine/File.lib | 29 | ||||
-rwxr-xr-x | client/engine/Inventory.lib | 25 | ||||
-rwxr-xr-x | client/engine/Registry.lib | 15 |
3 files changed, 39 insertions, 30 deletions
diff --git a/client/engine/File.lib b/client/engine/File.lib index 88e0af7e..bbe79ec5 100755 --- a/client/engine/File.lib +++ b/client/engine/File.lib @@ -265,25 +265,24 @@ case $# in return $? ;; esac -# Volver a directorio inicial en caso de error. -CURRENTDIR="$PWD" -trap "cd $CURRENTDIR" RETURN - # Eliminar caracteres \c / iniciales, finales y duplicados. # /* (comentario Doxygen) FILE="$(echo $FILE|sed -e 's/\(\/\)*\1/\//g' -e 's/^\///' -e 's/\/$//')" -PREVFILE="" -FILEPATH="/" -while [ "$FILE" != "$PREVFILE" ]; do - # Busca el nombre correcto en el directorio actual. - cd "$FILEPATH" 2>/dev/null || FILE="" - FILEPATH="${FILEPATH}/$(ls -A 2>/dev/null | grep -i -m1 "^${FILE%%/*}$")" || return $? - PREVFILE="$FILE" - FILE="${FILE#*/}" -done +# Comprobar si existe el fichero para reducir tiempos. +if [ -e "$FILE" ]; then + FILEPATH="$FILE" +else + # Buscar el nombre correcto en cada subdirectorio del camino. + FILEPATH="/" + while [ "$FILE" != "$PREVFILE" ]; do + FILEPATH="$(ls -d "${FILEPATH%/}/${FILE%%/*}" 2>/dev/null || find "$FILEPATH" -maxdepth 1 -iname "${FILE%%/*}" -print 2>/dev/null)" + PREVFILE="$FILE" + FILE="${FILE#*/}" + done +fi # (comentario Doxygen) */ -# Muestra el camino Linux, quitando el / inicial duplicado. -[ "$FILEPATH" != "/" ] && echo ${FILEPATH#/} +[ -n "$FILEPATH" ] && echo "$FILEPATH" +return 0 } diff --git a/client/engine/Inventory.lib b/client/engine/Inventory.lib index 5ad4649b..3450b3e5 100755 --- a/client/engine/Inventory.lib +++ b/client/engine/Inventory.lib @@ -168,8 +168,23 @@ fi # Para Windows: leer la version del registro. if [ -z "$VERSION" ]; then TYPE="Windows" - VERSION=$(ogGetRegistryValue $MNTDIR software '\Microsoft\Windows NT\CurrentVersion\ProductName' 2>/dev/null) - [ -n "$(ogGetRegistryValue $MNTDIR software '\Microsoft\Windows\CurrentVersion\ProgramW6432Dir' 2>/dev/null)" ] && IS64BIT="$MSG_64BIT" + FILE="$(ogGetHivePath $MNTDIR SOFTWARE)" + if [ -n "$FILE" ]; then + # Nuevo método más rápido para acceder al registro de Windows.. + VERSION=$(echo $(hivexsh << EOT 2>/dev/null +load $FILE +cd \Microsoft\Windows NT\CurrentVersion +lsval ProductName +lsval ReleaseId +EOT + )) + [ -n "$(reglookup -H -p "Microsoft/Windows/CurrentVersion/ProgramW6432Dir" "$FILE" 2>/dev/null)" ] && IS64BIT="$MSG_64BIT" + if [ -z "$VERSION" ]; then + # Compatibilidad con métrodo antiguo y más lento de acceder al registro. + VERSION=$(ogGetRegistryValue $MNTDIR software '\Microsoft\Windows NT\CurrentVersion\ProductName' 2>/dev/null) + [ -n "$(ogGetRegistryValue $MNTDIR software '\Microsoft\Windows\CurrentVersion\ProgramW6432Dir' 2>/dev/null)" ] && IS64BIT="$MSG_64BIT" + fi + fi fi # Para cargador Windows: buscar versión en fichero BCD (basado en os-prober). if [ -z "$VERSION" ]; then @@ -184,14 +199,14 @@ if [ -z "$VERSION" ]; then done fi fi -# Para MacOS: detectar kernel y completar con fichero plist de información del sistema. +# Para macOS: detectar kernel y completar con fichero plist de información del sistema. if [ -z "$VERSION" ]; then TYPE="MacOS" # Kernel de Mac OS (no debe ser fichero de texto). FILE="$MNTDIR/mach_kernel" if [ -z "$(file -b $FILE | grep 'text')" ]; then # Obtener tipo de kernel. - [ -n "$(file -b $FILE | grep 'Mach-O')" ] && VERSION="Mac OS" + [ -n "$(file -b $FILE | grep 'Mach-O')" ] && VERSION="macOS" [ -n "$(file -b $FILE | grep 'Mach-O 64-bit')" ] && IS64BIT="$MSG_64BIT" # Datos de configuración de versión de Mac OS. FILE="$MNTDIR/System/Library/CoreServices/SystemVersion.plist" @@ -199,7 +214,7 @@ if [ -z "$VERSION" ]; then /ProductName/ {getline;s=$3} /ProductVersion/ {getline;v=$3} END {print s,v}' $FILE) - # Datos de recuperación de Mac OS. + # Datos de recuperación de macOS. FILE="$MNTDIR/com.apple.recovery.boot" [ -r $FILE -a -n "$VERSION" ] && VERSION="$VERSION recovery" fi diff --git a/client/engine/Registry.lib b/client/engine/Registry.lib index 78a725de..dbe69aee 100755 --- a/client/engine/Registry.lib +++ b/client/engine/Registry.lib @@ -234,16 +234,11 @@ fi [ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $? # Camino del fichero de registro de usuario o de sistema (de menor a mayor prioridad). -for FILE in $(ogGetPath "/$1/Documents and Settings/$2/NTUSER.DAT") \ - $(ogGetPath "/$1/Users/$2/NTUSER.DAT") \ - $(ogGetPath "/$1/winnt/system32/config/$2") \ - $(ogGetPath "/$1/windows/system32/config/$2"); do - [ -f "$FILE" ] && HIVE="$FILE" -done -# Error si no se encuentra el fichero de registro. -[ -f "$HIVE" ] || ogRaiseError $OG_ERR_NOTFOUND "$1 $2" || return $? - -echo "$HIVE" +FILE="$(ogGetPath "/$1/Windows/System32/config/$2")" +[ -z "$FILE" ] && FILE="$(ogGetPath "/$1/Users/$2/NTUSER.DAT")" +[ -z "$FILE" ] && FILE="$(ogGetPath "/$1/winnt/system32/config/$2")" +[ -z "$FILE" ] && FILE="$(ogGetPath "/$1/Documents and Settings/$2/NTUSER.DAT")" +[ -f "$FILE" ] && echo "$FILE" || ogRaiseError $OG_ERR_NOTFOUND "$1 $2" || return $? } |