refs #1166 add ogSetWindowsName()
parent
9a78f9f2c7
commit
39ad37e324
|
@ -0,0 +1,548 @@
|
||||||
|
#/**
|
||||||
|
#@file BootLib.py
|
||||||
|
#@brief Librería o clase Boot
|
||||||
|
#@class Boot
|
||||||
|
#@brief Funciones para arranque y post-configuración de sistemas de archivos.
|
||||||
|
#@warning License: GNU GPLv3+
|
||||||
|
#*/
|
||||||
|
|
||||||
|
import ogGlobals
|
||||||
|
import SystemLib
|
||||||
|
import FileSystemLib
|
||||||
|
import RegistryLib
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBoot int_ndisk int_nfilesys [ NVRAMPERM ] [str_kernel str_initrd str_krnlparams]
|
||||||
|
#@brief Inicia el proceso de arranque de un sistema de archivos.
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@param int_nfilesys nº de orden del sistema de archivos
|
||||||
|
#@param str_nvramperm UEFI: La entrada en la NVRAM se incluye en el orden de arranque (opcional)
|
||||||
|
#@param str_krnlparams parámetros de arranque del kernel (opcional)
|
||||||
|
#@return (activar el sistema de archivos).
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||||
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||||
|
#@exception OG_ERR_NOTOS La partición no tiene instalado un sistema operativo.
|
||||||
|
#@note En Linux, si no se indican los parámetros de arranque se detectan de la opción por defecto del cargador GRUB.
|
||||||
|
#@note En Linux, debe arrancarse la partición del directorio \c /boot
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGetWindowsName int_ndisk int_nfilesys
|
||||||
|
#@brief Muestra el nombre del equipo en el registro de Windows.
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@param int_nfilesys nº de orden del sistema de archivos
|
||||||
|
#@return str_name - nombre del equipo
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||||
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogLinuxBootParameters int_ndisk int_nfilesys
|
||||||
|
#@brief Muestra los parámetros de arranque de un sistema de archivos Linux.
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@param int_nfilesys nº de orden del sistema de archivos
|
||||||
|
#@return str_kernel str_initrd str_parameters ...
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||||
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||||
|
#@warning Función básica usada por \c ogBoot
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogSetWindowsName int_ndisk int_nfilesys str_name
|
||||||
|
#@brief Establece el nombre del equipo en el registro de Windows.
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@param int_nfilesys nº de orden del sistema de archivos
|
||||||
|
#@param str_name nombre asignado
|
||||||
|
#@return (nada)
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||||
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||||
|
#@exception OG_ERR_OUTOFLIMIT Nombre Netbios con más de 15 caracteres.
|
||||||
|
#*/ ##
|
||||||
|
def ogSetWindowsName (disk, par, name):
|
||||||
|
if len (name) > 15:
|
||||||
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_OUTOFLIMIT, f'"{name[0:15]}..."')
|
||||||
|
return
|
||||||
|
|
||||||
|
mntdir = FileSystemLib.ogMount (disk, par)
|
||||||
|
if not mntdir: return None
|
||||||
|
|
||||||
|
RegistryLib.ogSetRegistryValue (mntdir, 'system', r'\ControlSet001\Control\ComputerName\ComputerName\ComputerName', name)
|
||||||
|
RegistryLib.ogSetRegistryValue (mntdir, 'system', r'\ControlSet001\Services\Tcpip\Parameters\Hostname', name)
|
||||||
|
RegistryLib.ogSetRegistryValue (mntdir, 'system', r'\ControlSet001\Services\Tcpip\Parameters\HostName', name)
|
||||||
|
RegistryLib.ogSetRegistryValue (mntdir, 'system', r'\ControlSet001\services\Tcpip\Parameters\Hostname', name)
|
||||||
|
RegistryLib.ogSetRegistryValue (mntdir, 'system', r'\ControlSet001\Services\Tcpip\Parameters\NV Hostname', name)
|
||||||
|
RegistryLib.ogSetRegistryValue (mntdir, 'system', r'\ControlSet001\Services\Tcpip\Parameters\NV HostName', name)
|
||||||
|
RegistryLib.ogSetRegistryValue (mntdir, 'system', r'\ControlSet001\services\Tcpip\Parameters\NV Hostname', name)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogSetWinlogonUser int_ndisk int_npartition str_username
|
||||||
|
#@brief Establece el nombre de usuario por defecto en la entrada de Windows.
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@param int_npartition nº de orden de la partición
|
||||||
|
#@param str_username nombre de usuario por defecto
|
||||||
|
#@return (nada)
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||||
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBootMbrXP int_ndisk
|
||||||
|
#@brief Genera un nuevo Master Boot Record en el disco duro indicado, compatible con los SO tipo Windows
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@return salida del programa my-sys
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBootMbrGeneric int_ndisk
|
||||||
|
#@brief Genera un nuevo Codigo de arranque en el MBR del disco indicado, compatible con los SO tipo Windows, Linux.
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@return salida del programa my-sys
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND Tipo de partición desconocido o no se puede montar.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogFixBootSector int_ndisk int_parition
|
||||||
|
#@brief Corrige el boot sector de una particion activa para MS windows/dos -fat-ntfs
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@param int_partition nº de particion
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGetBootMbr int_ndisk
|
||||||
|
#@brief Obtiene el contenido del sector de arranque de un disco.
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@return str_MBR Descripción del contenido del MBR.
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND Dispositivo de disco no encontrado.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogWindowsBootParameters int_ndisk int_parition
|
||||||
|
#@brief Configura el gestor de arranque de windows 7 / vista / XP / 2000
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@param int_partition nº de particion
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogWindowsRegisterPartition int_ndisk int_partiton str_volume int_disk int_partition
|
||||||
|
#@brief Registra una partición en windows con un determinado volumen.
|
||||||
|
#@param int_ndisk nº de orden del disco a registrar
|
||||||
|
#@param int_partition nº de particion a registrar
|
||||||
|
#@param str_volumen volumen a resgistar
|
||||||
|
#@param int_ndisk_windows nº de orden del disco donde esta windows
|
||||||
|
#@param int_partition_windows nº de particion donde esta windows
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrubInstallMbr int_disk_GRUBCFG int_partition_GRUBCFG
|
||||||
|
#@brief Instala el grub el el MBR del primer disco duro (FIRSTSTAGE). El fichero de configuración grub.cfg ubicado según parametros disk y part(SECONDSTAGE). Admite sistemas Windows.
|
||||||
|
#@param int_disk_SecondStage
|
||||||
|
#@param int_part_SecondStage
|
||||||
|
#@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default]
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrubInstallPartition int_disk_SECONDSTAGE int_partition_SECONDSTAGE bolean_Check_Os_installed_and_Configure_2ndStage
|
||||||
|
#@brief Instala y actualiza el gestor grub en el bootsector de la particion indicada
|
||||||
|
#@param int_disk_SecondStage
|
||||||
|
#@param int_part_SecondStage
|
||||||
|
#@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default]
|
||||||
|
#@param str "kernel param "
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogConfigureFstab int_ndisk int_nfilesys
|
||||||
|
#@brief Configura el fstab según particiones existentes
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@param int_nfilesys nº de orden del sistema de archivos
|
||||||
|
#@return (nada)
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND No se encuentra el fichero fstab a procesar.
|
||||||
|
#@warning Puede haber un error si hay más de 1 partición swap.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogSetLinuxName int_ndisk int_nfilesys [str_name]
|
||||||
|
#@brief Establece el nombre del equipo en los ficheros hostname y hosts.
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@param int_nfilesys nº de orden del sistema de archivos
|
||||||
|
#@param str_name nombre asignado (opcional)
|
||||||
|
#@return (nada)
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||||
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||||
|
#@note Si no se indica nombre, se asigna un valor por defecto.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogCleanLinuxDevices int_ndisk int_nfilesys
|
||||||
|
#@brief Limpia los dispositivos del equipo de referencia. Interfaz de red ...
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@param int_nfilesys nº de orden del sistema de archivos
|
||||||
|
#@return (nada)
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND Disco o particion no corresponden con un dispositivo.
|
||||||
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrubAddOgLive num_disk num_part [ timeout ] [ offline ]
|
||||||
|
#@brief Crea entrada de menu grub para ogclient, tomando como paramentros del kernel los actuales del cliente.
|
||||||
|
#@param 1 Numero de disco
|
||||||
|
#@param 2 Numero de particion
|
||||||
|
#@param 3 timeout Segundos de espera para iniciar el sistema operativo por defecto (opcional)
|
||||||
|
#@param 4 offline configura el modo offline [offline|online] (opcional)
|
||||||
|
#@return (nada)
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND No existe kernel o initrd en cache.
|
||||||
|
#@exception OG_ERR_NOTFOUND No existe archivo de configuracion del grub.
|
||||||
|
# /// FIXME: Solo para el grub instalado en MBR por Opengnsys, ampliar para más casos.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrubHidePartitions num_disk num_part
|
||||||
|
#@brief ver ogBootLoaderHidePartitions
|
||||||
|
#@see ogBootLoaderHidePartitions
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBurgHidePartitions num_disk num_part
|
||||||
|
#@brief ver ogBootLoaderHidePartitions
|
||||||
|
#@see ogBootLoaderHidePartitions
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBootLoaderHidePartitions num_disk num_part
|
||||||
|
#@brief Configura el grub/burg para que oculte las particiones de windows que no se esten iniciando.
|
||||||
|
#@param 1 Numero de disco
|
||||||
|
#@param 2 Numero de particion
|
||||||
|
#@param 3 Numero de disco de la partición de datos (no ocultar)
|
||||||
|
#@param 4 Numero de particion de datos (no ocultar)
|
||||||
|
#@return (nada)
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception No existe archivo de configuracion del grub/burg.
|
||||||
|
#*/
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrubDeleteEntry num_disk num_part num_disk_delete num_part_delete
|
||||||
|
#@brief ver ogBootLoaderDeleteEntry
|
||||||
|
#@see ogBootLoaderDeleteEntry
|
||||||
|
#*/
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBurgDeleteEntry num_disk num_part num_disk_delete num_part_delete
|
||||||
|
#@brief ver ogBootLoaderDeleteEntry
|
||||||
|
#@see ogBootLoaderDeleteEntry
|
||||||
|
#*/
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogRefindDeleteEntry num_disk_delete num_part_delete
|
||||||
|
#@brief ver ogBootLoaderDeleteEntry
|
||||||
|
#@see ogBootLoaderDeleteEntry
|
||||||
|
#*/
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBootLoaderDeleteEntry num_disk num_part num_part_delete
|
||||||
|
#@brief Borra en el grub las entradas para el inicio en una particion.
|
||||||
|
#@param 1 Numero de disco donde esta el grub
|
||||||
|
#@param 2 Numero de particion donde esta el grub
|
||||||
|
#@param 3 Numero del disco del que borramos las entradas
|
||||||
|
#@param 4 Numero de la particion de la que borramos las entradas
|
||||||
|
#@note Tiene que ser llamada desde ogGrubDeleteEntry, ogBurgDeleteEntry o ogRefindDeleteEntry
|
||||||
|
#@return (nada)
|
||||||
|
#@exception OG_ERR_FORMAT Use ogGrubDeleteEntry or ogBurgDeleteEntry.
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND No existe archivo de configuracion del grub.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBurgInstallMbr int_disk_GRUBCFG int_partition_GRUBCFG
|
||||||
|
#@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default]
|
||||||
|
#@brief Instala y actualiza el gestor grub en el MBR del disco duro donde se encuentra el fichero grub.cfg. Admite sistemas Windows.
|
||||||
|
#@param int_disk_SecondStage
|
||||||
|
#@param int_part_SecondStage
|
||||||
|
#@param bolean_Check_Os_installed_and_Configure_2ndStage true | false[default]
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Partición no soportada
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrubDefaultEntry int_disk_GRUGCFG int_partition_GRUBCFG int_disk_default_entry int_npartition_default_entry
|
||||||
|
#@brief ver ogBootLoaderDefaultEntry
|
||||||
|
#@see ogBootLoaderDefaultEntry
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBurgDefaultEntry int_disk_BURGCFG int_partition_BURGCFG int_disk_default_entry int_npartition_default_entry
|
||||||
|
#@brief ver ogBootLoaderDefaultEntry
|
||||||
|
#@see ogBootLoaderDefaultEntry
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogRefindDefaultEntry int_disk_default_entry int_npartition_default_entry
|
||||||
|
#@brief ver ogBootLoaderDefaultEntry
|
||||||
|
#@see ogBootLoaderDefaultEntry
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBootLoaderDefaultEntry int_disk_CFG int_partition_CFG int_disk_default_entry int_npartition_default_entry
|
||||||
|
#@brief Configura la entrada por defecto de Burg
|
||||||
|
#@param int_disk_SecondStage
|
||||||
|
#@param int_part_SecondStage
|
||||||
|
#@param int_disk_default_entry
|
||||||
|
#@param int_part_default_entry
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||||
|
#@exception OG_ERR_OUTOFLIMIT Param $3 no es entero.
|
||||||
|
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: burg.cfg.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrubOgliveDefaultEntry num_disk num_part
|
||||||
|
#@brief ver ogBootLoaderOgliveDefaultEntry
|
||||||
|
#@see ogBootLoaderOgliveDefaultEntry
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBurgOgliveDefaultEntry num_disk num_part
|
||||||
|
#@brief ver ogBootLoaderOgliveDefaultEntry
|
||||||
|
#@see ogBootLoaderOgliveDefaultEntry
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogRefindOgliveDefaultEntry
|
||||||
|
#@brief ver ogBootLoaderOgliveDefaultEntry
|
||||||
|
#@see ogBootLoaderOgliveDefaultEntry
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBootLoaderOgliveDefaultEntry
|
||||||
|
#@brief Configura la entrada de ogLive como la entrada por defecto de Burg.
|
||||||
|
#@param int_disk_SecondStage
|
||||||
|
#@param int_part_SecondStage
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||||
|
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: burg.cfg.
|
||||||
|
#@exception OG_ERR_NOTFOUND Entrada de OgLive no encontrada en burg.cfg.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrubSecurity int_disk_GRUBCFG int_partition_GRUBCFG [user] [password]
|
||||||
|
#@brief Configura grub.cfg para que sólo permita editar entrada o acceder a línea de comandos al usuario especificado
|
||||||
|
#@param int_disk_SecondStage
|
||||||
|
#@param int_part_SecondStage
|
||||||
|
#@param user (default root)
|
||||||
|
#@param password (default "", no puede entrar)
|
||||||
|
#@return (nada)
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Tipo de partición desconocido o no se puede montar (ogMount).
|
||||||
|
#@exception OG_ERR_NOTFOUND No encuentra archivo de configuración del grub.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrubSetTheme num_disk num_part str_theme
|
||||||
|
#@brief ver ogBootLoaderSetTheme
|
||||||
|
#@see ogBootLoaderSetTheme
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBurgSetTheme num_disk num_part str_theme
|
||||||
|
#@brief ver ogBootLoaderSetTheme
|
||||||
|
#@see ogBootLoaderSetTheme
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogRefindSetTheme str_theme
|
||||||
|
#@brief ver ogBootLoaderSetTheme
|
||||||
|
#@see ogBootLoaderSetTheme
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBootLoaderSetTheme
|
||||||
|
#@brief asigna un tema al BURG
|
||||||
|
#@param int_disk_SecondStage
|
||||||
|
#@param int_part_SecondStage
|
||||||
|
#@param str_theme_name
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||||
|
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg refind.conf.
|
||||||
|
#@exception OG_ERR_NOTFOUND Entrada deltema no encontrada en burg.cfg.
|
||||||
|
#@exception OG_ERR_NOTFOUND Fichero de configuración del tema no encontrado: theme.conf (sólo refind).
|
||||||
|
#@note El tema debe situarse en OGLIB/BOOTLOADER/themes
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrubSetAdminKeys num_disk num_part str_theme
|
||||||
|
#@brief ver ogBootLoaderSetTheme
|
||||||
|
#@see ogBootLoaderSetTheme
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBurgSetAdminKeys num_disk num_part str_bolean
|
||||||
|
#@brief ver ogBootLoaderSetAdminKeys
|
||||||
|
#@see ogBootLoaderSetAdminKeys
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBootLoaderSetAdminKeys
|
||||||
|
#@brief Activa/Desactica las teclas de administracion
|
||||||
|
#@param int_disk_SecondStage
|
||||||
|
#@param int_part_SecondStage
|
||||||
|
#@param Boolean TRUE/FALSE
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||||
|
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg.
|
||||||
|
#@exception OG_ERR_NOTFOUND Entrada deltema no encontrada en burg.cfg.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrubSetTimeOut num_disk num_part int_timeout_seconds
|
||||||
|
#@brief ver ogBootLoaderSetTimeOut
|
||||||
|
#@see ogBootLoaderSetTimeOut
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBurgSetTimeOut num_disk num_part str_bolean
|
||||||
|
#@brief ver ogBootLoaderSetTimeOut
|
||||||
|
#@see ogBootLoaderSetTimeOut
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogRefindSetTimeOut int_timeout_second
|
||||||
|
#@brief ver ogBootLoaderSetTimeOut
|
||||||
|
#@see ogBootLoaderSetTimeOut
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBootLoaderSetTimeOut
|
||||||
|
#@brief Define el tiempo (segundos) que se muestran las opciones de inicio
|
||||||
|
#@param int_disk_SecondStage
|
||||||
|
#@param int_part_SecondStage
|
||||||
|
#@param int_timeout_seconds
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||||
|
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg.
|
||||||
|
#@exception OG_ERR_NOTFOUND Entrada deltema no encontrada en burg.cfg.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrubSetResolution num_disk num_part int_resolution
|
||||||
|
#@brief ver ogBootLoaderSetResolution
|
||||||
|
#@see ogBootLoaderSetResolution
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBurgSetResolution num_disk num_part str_bolean
|
||||||
|
#@brief ver ogBootLoaderSetResolution
|
||||||
|
#@see ogBootLoaderSetResolution
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBootLoaderSetResolution
|
||||||
|
#@brief Define la resolucion que usuara el thema del gestor de arranque
|
||||||
|
#@param int_disk_SecondStage
|
||||||
|
#@param int_part_SecondStage
|
||||||
|
#@param str_resolution (Opcional)
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||||
|
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogBootLoaderSetResolution
|
||||||
|
#@brief Define la resolucion que usuara el thema del gestor de arranque
|
||||||
|
#@param int_resolution1
|
||||||
|
#@param int_resolution2 (Opcional)
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_PARTITION Partición errónea o desconocida (ogMount).
|
||||||
|
#@exception OG_ERR_NOTFOUND Fichero de configuración no encontrado: grub.cfg burg.cfg.
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
# ogRefindInstall bool_autoconfig
|
||||||
|
#@brief Instala y actualiza el gestor rEFInd en la particion EFI
|
||||||
|
#@param bolean_Check__auto_config true | false[default]
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND No se encuentra la partición ESP.
|
||||||
|
#@exception OG_ERR_NOTFOUND No se encuentra shimx64.efi.signed.
|
||||||
|
#@exception OG_ERR_NOTFOUND No se encuentra refind-install o refind en OGLIB
|
||||||
|
#@exception OG_ERR_PARTITION No se puede montar la partición ESP.
|
||||||
|
#@note Refind debe estar instalado en el ogLive o compartido en OGLIB
|
||||||
|
#*/ ##
|
||||||
|
|
||||||
|
#/**
|
||||||
|
# ogGrub4dosInstallMbr int_ndisk
|
||||||
|
#@brief Genera un nuevo Codigo de arranque en el MBR del disco indicado, compatible con los SO tipo Windows, Linux.
|
||||||
|
#@param int_ndisk nº de orden del disco
|
||||||
|
#@param int_ndisk nº de orden del particion
|
||||||
|
#@return
|
||||||
|
#@exception OG_ERR_FORMAT Formato incorrecto.
|
||||||
|
#@exception OG_ERR_NOTFOUND Tipo de partición desconocido o no se puede montar.
|
||||||
|
#@exception OG_ERR_NOTBIOS Equipo no firmware BIOS legacy
|
||||||
|
#@exception OG_ERR_NOMSDOS Disco duro no particioniado en modo msdos
|
||||||
|
#@exception OG_ERR_NOTWRITE Particion no modificable.
|
||||||
|
#*/ ##
|
|
@ -1,9 +1,8 @@
|
||||||
#/**
|
#/**
|
||||||
#@file Disk.lib
|
#@file DiskLib.py
|
||||||
#@brief Librería o clase Disk
|
#@brief Librería o clase Disk
|
||||||
#@class Disk
|
#@class Disk
|
||||||
#@brief Funciones para gestión de discos y particiones.
|
#@brief Funciones para gestión de discos y particiones.
|
||||||
#@version 1.1.1
|
|
||||||
#@warning License: GNU GPLv3+
|
#@warning License: GNU GPLv3+
|
||||||
#*/
|
#*/
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#/**
|
#/**
|
||||||
#@file FileSystem.lib
|
#@file FileSystemLib.py
|
||||||
#@brief Librería o clase FileSystem
|
#@brief Librería o clase FileSystem
|
||||||
#@class FileSystem
|
#@class FileSystem
|
||||||
#@brief Funciones para gestión de sistemas de archivos.
|
#@brief Funciones para gestión de sistemas de archivos.
|
||||||
#@version 1.1.0
|
|
||||||
#@warning License: GNU GPLv3+
|
#@warning License: GNU GPLv3+
|
||||||
#*/
|
#*/
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#/**
|
#/**
|
||||||
#@file Inventory.lib
|
#@file InventoryLib.py
|
||||||
#@brief Librería o clase Inventory
|
#@brief Librería o clase Inventory
|
||||||
#@class Inventory
|
#@class Inventory
|
||||||
#@brief Funciones para recogida de datos de inventario de hardware y software de los clientes.
|
#@brief Funciones para recogida de datos de inventario de hardware y software de los clientes.
|
||||||
#@version 1.1.0
|
|
||||||
#@warning License: GNU GPLv3+
|
#@warning License: GNU GPLv3+
|
||||||
#*/
|
#*/
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#/**
|
#/**
|
||||||
#@file Net.lib
|
#@file NetLib.py
|
||||||
#@brief Librería o clase Net
|
#@brief Librería o clase Net
|
||||||
#@class Net
|
#@class Net
|
||||||
#@brief Funciones básicas de red.
|
#@brief Funciones básicas de red.
|
||||||
#@version 1.0.6
|
|
||||||
#@warning License: GNU GPLv3+
|
#@warning License: GNU GPLv3+
|
||||||
#*/
|
#*/
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#/**
|
#/**
|
||||||
#@file Registry.lib
|
#@file RegistryLib.py
|
||||||
#@brief Librería o clase Registry
|
#@brief Librería o clase Registry
|
||||||
#@class Boot
|
#@class Boot
|
||||||
#@brief Funciones para gestión del registro de Windows.
|
#@brief Funciones para gestión del registro de Windows.
|
||||||
#@version 1.1.0
|
|
||||||
#@warning License: GNU GPLv3+
|
#@warning License: GNU GPLv3+
|
||||||
#*/
|
#*/
|
||||||
|
|
||||||
|
@ -11,6 +10,7 @@ import subprocess
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
|
||||||
import ogGlobals
|
import ogGlobals
|
||||||
import SystemLib
|
import SystemLib
|
||||||
|
@ -185,17 +185,17 @@ def ogGetHivePath(path_mountpoint, str_hive):
|
||||||
#@warning Requisitos: chntpw, awk
|
#@warning Requisitos: chntpw, awk
|
||||||
#@warning El sistema de archivos de Windows debe estar montado previamente.
|
#@warning El sistema de archivos de Windows debe estar montado previamente.
|
||||||
#*/ ##
|
#*/ ##
|
||||||
def ogGetRegistryValue(path_mountpoint, str_hive, str_valuename):
|
def ogGetRegistryValue(path_mountpoint, hive, k):
|
||||||
FILE = ogGetHivePath(path_mountpoint, str_hive)
|
FILE = ogGetHivePath(path_mountpoint, hive)
|
||||||
if not FILE: return
|
if not FILE: return
|
||||||
|
|
||||||
elems = str_valuename.split ('\\')
|
k_elems = k.split ('\\')
|
||||||
dirname = '\\'.join (elems[0:-1])
|
k_dirname = '\\'.join (k_elems[0:-1])
|
||||||
basename = elems[-1]
|
k_basename = k_elems[-1]
|
||||||
|
|
||||||
input = '\n'.join ([
|
input = '\n'.join ([
|
||||||
f'cd {dirname}',
|
f'cd {k_dirname}',
|
||||||
f'cat {basename}',
|
f'cat {k_basename}',
|
||||||
'q',
|
'q',
|
||||||
])
|
])
|
||||||
chntpw_out = chntpw (file, input)
|
chntpw_out = chntpw (file, input)
|
||||||
|
@ -264,6 +264,24 @@ def ogListRegistryValues(path_mountpoint, str_hive, str_key):
|
||||||
'''
|
'''
|
||||||
subprocess.run(chntpw_cmd, shell=True, timeout=5)
|
subprocess.run(chntpw_cmd, shell=True, timeout=5)
|
||||||
|
|
||||||
|
def _format_hex (hex_string):
|
||||||
|
result = []
|
||||||
|
offset = 0
|
||||||
|
|
||||||
|
hex_values = hex_string.strip().split()
|
||||||
|
result.append (str (len (hex_values)))
|
||||||
|
|
||||||
|
while hex_values:
|
||||||
|
chunk = hex_values[:16]
|
||||||
|
hex_values = hex_values[16:]
|
||||||
|
|
||||||
|
offset_str = f':{offset:05x} '
|
||||||
|
hex_line = ' '.join (chunk)
|
||||||
|
result.append (offset_str + hex_line)
|
||||||
|
|
||||||
|
offset += 16
|
||||||
|
|
||||||
|
return '\n'.join (result)
|
||||||
|
|
||||||
#/**
|
#/**
|
||||||
# ogSetRegistryValue path_mountpoint str_hive str_valuename str_valuedata
|
# ogSetRegistryValue path_mountpoint str_hive str_valuename str_valuedata
|
||||||
|
@ -279,40 +297,46 @@ def ogListRegistryValues(path_mountpoint, str_hive, str_key):
|
||||||
#@warning Requisitos: chntpw
|
#@warning Requisitos: chntpw
|
||||||
#@warning El sistema de archivos de Windows debe estar montado previamente.
|
#@warning El sistema de archivos de Windows debe estar montado previamente.
|
||||||
#*/ ##
|
#*/ ##
|
||||||
def ogSetRegistryValue(path_mountpoint, str_hive, str_valuename, str_data):
|
#ogSetRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Key\SubKey\StringValue', 'Abcde Fghij')
|
||||||
# Variables locales.
|
#ogSetRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Key\SubKey\DwordValue', 1)
|
||||||
FILE = ogGetHivePath(path_mountpoint, str_hive)
|
#ogSetRegistryValue ('/mnt/sda1', 'SOFTWARE', '\Key\SubKey\BinaryValue', '04 08 0C 10')
|
||||||
if not FILE:
|
def ogSetRegistryValue (mntpt, hive, k, v):
|
||||||
return
|
hivefile = ogGetHivePath (mntpt, hive)
|
||||||
|
if not hivefile: return
|
||||||
|
|
||||||
# Fichero temporal para componer la entrada al comando "chntpw".
|
# ${3%\\*} es dirname
|
||||||
tmpfile = "/tmp/chntpw$$"
|
# ${3##*\\} es basename
|
||||||
|
k_elems = k.split ('\\')
|
||||||
|
k_dirname = '\\'.join (k_elems[0:-1])
|
||||||
|
k_basename = k_elems[-1]
|
||||||
|
|
||||||
|
tmpfile = tempfile.TemporaryFile (prefix='chntpw-', mode='w')
|
||||||
try:
|
try:
|
||||||
# Comprobar tipo de datos del valor del registro.
|
|
||||||
with open(tmpfile, 'w') as f:
|
with open(tmpfile, 'w') as f:
|
||||||
f.write(f"ls {str_valuename.rsplit('\\', 1)[0]}\nq\n")
|
f.write (f"ls {k_dirname}\n")
|
||||||
output = subprocess.check_output(['chntpw', FILE], input=open(tmpfile, 'rb'), stderr=subprocess.DEVNULL).decode()
|
f.write ('q\n')
|
||||||
if f"BINARY.*<{str_valuename.rsplit('\\', 1)[-1]}>" in output:
|
|
||||||
# Procesar tipo binario (incluir nº de bytes y líneas de 16 parejas hexadecimales).
|
output = subprocess.run (['chntpw', hivefile], input=open(tmpfile, 'r'), capture_output=True, text=True).stdout
|
||||||
if not re.match(r'^([0-9A-F]{2} )*$', str_data):
|
if re.search (f"BINARY.*<{k_basename}>", output):
|
||||||
SystemLib.ogRaiseError(
|
## the entry in the registry is binary. Our input should be a sequence of bytes
|
||||||
"session",
|
|
||||||
ogGlobals.OG_ERR_FORMAT,
|
if ' ' != v[-1]: v += ' ' ## the regex below requires a trailing space
|
||||||
f'"{str_data}"'
|
if not re.match (r'^([0-9A-F]{2} )*$', v.upper()):
|
||||||
)
|
SystemLib.ogRaiseError ([], ogGlobals.OG_ERR_FORMAT, f'"{v}"')
|
||||||
return
|
return
|
||||||
n = len(str_data) + 1
|
|
||||||
with open(tmpfile, 'w') as f:
|
formatted = _format_hex (v.upper())
|
||||||
f.write(f"cd {str_valuename.rsplit('\\', 1)[0]}\ned {str_valuename.rsplit('\\', 1)[-1]}\n{int(n/3)}\n")
|
formatted += '\ns'
|
||||||
for i in range(0, n, 48):
|
|
||||||
f.write(f":{i//3:05x} {str_data[i:i+48]}\n")
|
|
||||||
f.write("s\nq\ny\n")
|
|
||||||
else:
|
else:
|
||||||
# Cambiar el dato del valor de registro para cadenas y bytes.
|
formatted = v
|
||||||
with open(tmpfile, 'w') as f:
|
|
||||||
f.write(f"cd {str_valuename.rsplit('\\', 1)[0]}\ned {str_valuename.rsplit('\\', 1)[-1]}\n{str_data}\nq\ny\n")
|
with open(tmpfile, 'w') as f:
|
||||||
|
f.write (f'cd {k_dirname}\n')
|
||||||
|
f.write (f'ed {k_basename}\n')
|
||||||
|
f.write (f'{formatted}\n')
|
||||||
|
f.write ('q\ny\n')
|
||||||
|
|
||||||
# Aplicar cambios.
|
# Aplicar cambios.
|
||||||
subprocess.run(['chntpw', FILE], input=open(tmpfile, 'rb'), stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
subprocess.run (['chntpw', hivefile], input=open(tmpfile, 'r'))
|
||||||
finally:
|
finally:
|
||||||
os.remove(tmpfile)
|
os.remove(tmpfile)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
#/**
|
#/**
|
||||||
#@file restoreImage
|
#@file restoreImage.py
|
||||||
#@brief Script de ejemplo para restaurar una imagen.
|
#@brief Script de ejemplo para restaurar una imagen.
|
||||||
#@param $1 Repositorio (CACHE, REPO o dirección IP)
|
#@param $1 Repositorio (CACHE, REPO o dirección IP)
|
||||||
#@param $2 Nombre canónico de la imagen (sin extensión)
|
#@param $2 Nombre canónico de la imagen (sin extensión)
|
||||||
|
|
Loading…
Reference in New Issue