source: client/engine/Registry.lib.testing @ db8fdd2

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since db8fdd2 was 9f577259, checked in by ramon <ramongomez@…>, 14 years ago

Versión 1.0.2: separar funciones de registro de Windows en librería Registry.lib (modificar #401).

git-svn-id: https://opengnsys.es/svn/branches/version1.0@1979 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 6.4 KB
Line 
1#!/bin/bash
2#/**
3#@file    Registry.lib
4#@brief   Librería o clase Registry
5#@class   Boot
6#@brief   Funciones para gestión del registro de Windows.
7#@version 1.0.1
8#@warning License: GNU GPLv3+
9#*/
10
11
12#/**
13#         ogAddRegistryKey path_mountpoint str_hive str_keyname
14#@brief   Añade una nueva clave al registro de Windows.
15#@version 1.0.1 - Nueva función
16#@author  Ramon Gomez, ETSII Universidad de Sevilla
17#@date    2011-05-18
18#*/ ##
19function ogAddRegistryValue ()
20{
21}
22
23#/**
24#         ogAddRegistryValue path_mountpoint str_hive str_valuename str_valuedata
25#@brief   Añade un nuevo valor (dupla nombre/valor) al registro de Windows.
26#@version 1.0.1 - Nueva función
27#@author  Ramon Gomez, ETSII Universidad de Sevilla
28#@date    2011-05-18
29#*/ ##
30function ogAddRegistryValue ()
31{
32}
33
34
35#/**
36#         ogGetRegistryPath path_mountpoint str_hive
37#@brief   Función básica que devuelve el camino del fichero con una sección del registro.
38#@param   path_mountpoint  directorio donde está montado el sistema Windows
39#@param   str_hive         sección del registro
40#@return  str_path - camino del fichero de registro
41#@exception OG_ERR_FORMAT    Formato incorrecto.
42#@exception OG_ERR_NOTFOUND  Disco o partición no corresponden con un dispositivo.
43#@note    hive = { default, sam, security, software, system, components }
44#@warning El sistema de archivos de Windows debe estar montada previamente.
45#@version 1.0.1 - Nueva función
46#@author  Ramon Gomez, ETSII Universidad de Sevilla
47#@date    2011-05-18
48#*/ ##
49function ogGetRegistryPath ()
50{
51# Variables locales.
52local FILE FILENT FILEXP
53
54# Si se solicita, mostrar ayuda.
55if [ "$*" == "help" ]; then
56    ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive"
57    return
58fi
59# Error si no se reciben 2 parámetros.
60[ $# == 2 ] || ogRaiseError $OG_ERR_FORMAT || return $?
61
62# Camino del fichero de registro en NT/2000 o XP/Vista/7.
63FILENT=$(ogGetPath "/$1/winnt/system32/config/$2")
64[ -f $FILENT ] && FILE="$FILENT"
65FILEXP=$(ogGetPath "/$1/windows/system32/config/$2")
66[ -f $FLEHXP ] && FILE="$FILEXP"
67[ ! -f $FILE ] && ogRaiseError OG_ERR_NOTFOUND "$1,$2" && return $?
68
69echo "$FILE"
70}
71
72
73#/**
74#         ogGetRegistryValue path_mountpoint str_hive str_valuename
75#@brief   Devuelve el dato de un valor del registro de Windows.
76#@param   path_mountpoint  directorio donde está montado el sistema Windows
77#@param   str_hive         sección del registro
78#@param   str_valuename    nombre del valor
79#@return  str_valuedata - datos del valor.
80#@exception OG_ERR_FORMAT    Formato incorrecto.
81#@exception OG_ERR_NOTFOUND  Disco o partición no corresponden con un dispositivo.
82#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
83#@note    hive = { default, sam, security, software, system, components }
84#@warning Requisitos: chntpw, awk
85#@warning La partición de Windows debe estar montada previamente.
86#@version 0.9 - Adaptación para OpenGNSys.
87#@author  Ramon Gomez, ETSII Universidad de Sevilla
88#@date    2009-09-11
89#*/ ##
90function ogGetRegistryValue ()
91{
92# Variables locales.
93local FILE
94
95# Si se solicita, mostrar ayuda.
96if [ "$*" == "help" ]; then
97    ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename"
98    return
99fi
100# Error si no se reciben 3 parámetros.
101[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
102
103# Camino del fichero de registro.
104FILE=$(ogGetRegistryPath "$1" "$2") || return $?
105
106# Devolver el dato del valor de registro.
107# /* (comentario Doxygen)
108chntpw $FILE << FIN 2>/dev/null | awk '/> Value/ {getline;print $0;}'
109cd ${3%\\*}
110cat ${3##*\\}
111q
112FIN
113# (comentario Doxygen) */
114}
115
116
117#/**
118#         ogListRegistryKey path_mountpoint str_hive str_key
119#@brief   Lista los nombres de claves de una determinada clave del registro de Windows.
120#@param   path_mountpoint  directorio donde está montado el sistema Windows
121#@param   str_hive         sección del registro
122#@param   str_key          clave de registro
123#@return  str_subkey ... - lista de subclaves
124#@exception OG_ERR_FORMAT    Formato incorrecto.
125#@exception OG_ERR_NOTFOUND  Disco o particion no corresponden con un dispositivo.
126#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
127#@note    hive = { default, sam, security, software, system, components }
128#@warning Requisitos: chntpw, awk
129#@warning La partición de Windows debe estar montada previamente.
130#@version 0.9 - Adaptación para OpenGNSys.
131#@author  Ramon Gomez, ETSII Universidad de Sevilla
132#@date    2009-09-23
133#@version 1.0.1 - Renombrada de ogListRegistryKeys
134#@author  Ramon Gomez, ETSII Universidad de Sevilla
135#@date    2011-05-18
136#*/ ##
137function ogListRegistryKey ()
138{
139# Variables locales.
140local FILE
141
142# Si se solicita, mostrar ayuda.
143if [ "$*" == "help" ]; then
144    ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_key"
145    return
146fi
147# Error si no se reciben 3 parámetros.
148[ $# == 3 ] || ogRaiseError $OG_ERR_FORMAT || return $?
149
150# Camino del fichero de registro.
151FILE=$(ogGetRegistryPath "$1" "$2") || return $?
152
153# Devolver la lista de claves de registro.
154chntpw $FILE << FIN 2>/dev/null | awk 'BEGIN {FS="[<>]"} $1~/^  $/ {print $2}'
155ls $3
156q
157FIN
158}
159
160
161#/**
162#         ogSetRegistryValue path_mountpoint str_hive str_valuename str_valuedata
163#@brief   Establece el dato asociado a un valor del registro de Windows.
164#@param   path_mountpoint  directorio donde está montado el sistema Windows
165#@param   str_hive         tipo de registro
166#@param   str_valuename    nombre del valor de registro
167#@param   str_valuedata    dato del valor de registro
168#@return  (nada)
169#@exception OG_ERR_FORMAT    Formato incorrecto.
170#@exception OG_ERR_NOTFOUND  Disco o partición no corresponden con un dispositivo.
171#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
172#@note    hive = { default, sam, security, software, system, components }
173#@warning Requisitos: chntpw, awk
174#@warning La partición de Windows debe estar montada previamente.
175#@version 0.9 - Adaptación para OpenGNSys.
176#@author  Ramon Gomez, ETSII Universidad de Sevilla
177#@date    2009-09-24
178#*/ ##
179function ogSetRegistryValue ()
180{
181# Variables locales.
182local FILE
183
184# Si se solicita, mostrar ayuda.
185if [ "$*" == "help" ]; then
186    ogHelp "$FUNCNAME" "$FUNCNAME path_mountpoint str_hive str_valuename str_data"
187    return
188fi
189# Error si no se reciben 4 parámetros.
190[ $# == 4 ] || ogRaiseError $OG_ERR_FORMAT || return $?
191
192# Camino del fichero de registro.
193FILE=$(ogGetRegistryPath "$1" "$2") || return $?
194
195# Cambiar el dato del valor de registro.
196chntpw $FILE << FIN &>/dev/null
197ed $3
198$4
199q
200y
201FIN
202}
203
Note: See TracBrowser for help on using the repository browser.