#!/bin/tclsh source once.tcl sourceOnce common.tcl sourceOnce session.tcl sourceOnce file_io.tcl load tclrpc.so load tclrega.so set PFMD_URL "bin://127.0.0.1:2002" set portnumber 2001 catch { source "/etc/eq3services.ports.tcl" } if { [info exists EQ3_SERVICE_RFD_PORT] } { set portnumber $EQ3_SERVICE_RFD_PORT } set RFD_URL "bin://127.0.0.1:$portnumber" proc array_getValue { pArray name } { upvar $pArray arr set value {} catch { set value $arr($name) } return $value } proc get_current_key_index {} { set KEY_FILE "/etc/config/keys" set CURRENT_INDEX "Current user key" set PREVIOUS_INDEX "Previous user key" # Schl�ssel-Index ermitteln set fd [open "|crypttool -g" r] set content [read $fd] close $fd array set keys {} foreach line [split $content "\n"] { if { [regexp {([^=]*)=(.*)} $line dummy key value] } then { set key [string trim $key] set value [string trim $value] set keys($key) $value } } set currentIndex 0 if { [info exists keys($CURRENT_INDEX)] } then { set currentIndex $keys($CURRENT_INDEX) } return $currentIndex } proc set_key { key } { global RFD_URL xmlrpc $RFD_URL changeKey $key # set always new key with crypttool set index [get_current_key_index] incr index 1 set fd [open "|crypttool -S -k $key -i $index" r] close $fd } proc getSGTIN_CCU {} { set fp [open "/var/hmip_board_sgtin" r] set file_data [read $fp] close $fp set sgtinCCU [lindex [split $file_data "\n"] 0] return $sgtinCCU } proc getSGTIN_Backup {migrationMode} { switch $migrationMode { "CCU2_CCU2" {set path_crRFD "/tmp/backup/usr/local/etc/config/crRFD/data"} "CCU2_CCU3" {set path_crRFD "/tmp/backup/usr/local/etc/config/crRFD/data"} "CCU3_CCU3" {set path_crRFD "/usr/local/eQ-3-Backup/restore/etc/config/crRFD/data"} } cd $path_crRFD set sgtinBackup [lindex [split [glob *.apkx] "."] 0] return "$sgtinBackup" } proc getBackupErrorMessage {errorCode migration_mode} { set errorCode [expr $errorCode * 1] # ERROR CODES: # 9 = Check the script /bin/checkUsrBackup.sh - the java call is wrong # 10 = OK # 11 = Backup fehlerhaft / unvollst�ndig (z.B. *.apkx Datei fehlt) # 12 = Internet fehlt / KeyServer Timeout # 13 = KeyServer NAK (eine oder beide sind nicht im KeyServer) # 14 = Fehler bei Ger�tepersistenz (einlesen fehlgeschlagen oder Versionen / Typen nicht kompatibel) # 15 = Migration Fehlgeschlagen (nicht f�r die Backup Validierungs Main) # 16 = Adapter (Coprozessor) nicht verf�gbar (basierend auf den Konfigurationen aus dem Backup + Default aus /etc) # 17 = Adapter konnte nicht initialisiert werden (besch�digte Application / Fehlerr�ckmeldungen) # 18 = Adapter Version nicht unterst�tzt # 99 = Unknown error if {$errorCode == 13} { # TODO This is currently deactivated because we cannot determine for sure if a SGTIN belongs to a CCU or to a DRAP (see TWIST-1928) # set sgtinCCU [getSGTIN_CCU] # set sgtinBackup [getSGTIN_Backup $migration_mode] } set code(9) "
\$\{backupWrongJavaCall\}" set code(10) "
\$\{backupOK\}" set code(11) "
\$\{backupBackupImperfectMissingFile\}" set code(12) "
\$\{backupNoInternet_KeyserverTimeout\}" # TODO Activate the next line and delete the line after that when we can extract the SGTIN (see TWIST-1928) # set code(13) "
\$\{backupKeyServer_NAK\}

SGTIN CCU: $sgtinCCU
SGTIN Backup: $sgtinBackup
 " set code(13) "
\$\{backupKeyServer_NAK\}" set code(14) "
\$\{backupErrorDevicePersistence_TypesNotCompatibel\}" set code(15) "
\$\{backupMigrationFailed\}" set code(16) "
\$\{backupCoProcessor_not_availabel\}" set code(17) "
\$\{backupCoProcessor_NotInitialized\}" set code(18) "
\$\{backupCoProcessor_VersionNotSupported\}" set code(99) "
\$\{backupUnknownError\}" return $code($errorCode) } proc readBackupStatus {} { set fp [open "/tmp/backupStatus.log" r] set data [read $fp] close $fp return $data } proc checkUserBackupValidility {migrationMode} { switch $migrationMode { "CCU2_CCU2" {set pathBackup "/tmp/backup/usr/local/"} "CCU2_CCU3" {set pathBackup "/tmp/backup/usr/local/"} "CCU3_CCU3" {set pathBackup "/usr/local/eQ-3-Backup/restore/"} } catch {exec killall java} set tmp [catch {exec checkUsrBackup.sh $pathBackup}] return [readBackupStatus] } proc action_change_key {} { global env RFD_URL http_head import key1 import key2 if { "$key1" != "$key2" } { #put_message "\${dialogSettingsSecurityMessageErrorSecKeyTitle}" "Die beiden eingegebenen Schlüssel stimmen nicht überein." {\${dialogBack} "showSecurityCP();"} put_message "\${dialogSettingsSecurityMessageErrorSecKeyTitle}" "\${dialogSettingsSecurityMessageErrorSecKeyContentKeysNotIdentical}" {\${dialogBack} "showSecurityCP();"} return } if { [string length "$key1"] < 5 } { #put_message "Sicherheitsschlüssel setzen - Fehler" "Der eingegebene Schlüssel ist zu kurz. Geben Sie einen Schlüssel ein, der mindestens 5 Zeichen lang ist." {"Zurück" "showSecurityCP();"} put_message "\${dialogSettingsSecurityMessageErrorSecKeyTitle}" \${dialogSettingsSecurityMessageErrorSecKeyContentKeyShort} {\${dialogBack} "showSecurityCP();"} return } if { 0 == [regexp {^[0-9a-zA-Z_]+$} $key1 dummy] } { #put_message "Sicherheitsschlüssel setzen - Fehler" "Der eingegebene Schlüssel darf keine Sonderzeichen enthalten. Erlaubt sind lediglich die Buchstaben A bis Z, die Ziffern 0 bis 9 sowie der Unterstrich." {"Zurück" "showSecurityCP();"} put_message "\${dialogSettingsSecurityMessageErrorSecKeyTitle}" \${dialogSettingsSecurityMessageErrorSecKeyContentIllegalChar} {\${dialogBack} "showSecurityCP();"} return } # check the entered key against our current system key if { ![catch {exec crypttool -v -t 3 -k "$key1"}]} { # "Der eingegebene Schl�ssel entspricht dem aktuellen Schl�ssel der Zentrale. " # "Der Schl�ssel wird nicht ge�ndert." put_message "\${dialogSettingsSecurityMessageHintSecKeyTitle}" \${dialogSettingsSecurityMessageErrorSecKeyContentKeysIsIdentical} {\${dialogBack} "showSecurityCP();"} return } if { [catch {set_key $key1}] } { # "Der Schl�ssel konnte nicht gesetzt werden. Das liegt vermutlich daran, da� " # "der aktuelle Schl�;ssel noch nicht an alle Komponenten �bertragen wurde. " # "Hinweise darauf finden Sie in den Servicemeldungen." put_message "\${dialogSettingsSecurityMessageErrorSecKeyTitle}" \${dialogSettingsSecurityMessageErrorSecKeyContentKeyNotAllDevices} {\${dialogBack} "showSecurityCP();"} return } put_message "\${dialogSettingsSecurityMessageOKSecKeyTitle}" \${dialogSettingsSecurityMessageErrorSecKeyContentSetKeySucceed} {\${dialogBack} "showSecurityCP();"} } proc action_factory_reset_check {} { global env http_head division {class="popupTitle"} { puts "\${dialogSettingsSecurityMessagePerformSystemResetTitle}" } division {class="CLASS20800"} { table {class="popupTable"} {border="1"} { table_row { table_data { table {class="CLASS20810"} {width="100%"} { set system_has_user_key [catch {exec crypttool -v -t 0}] if { $system_has_user_key } { table_row { table_data {colspan="3"} {align="left"} { puts "\${dialogSetSecKeyRebootHead}" } } table_row { td {width="20"} {} table_data {align="left"} { puts "\${dialogSetSecKeyRebootLbl}" } table_data {align="right"} { cgi_text key= {size="16"} {id="text_key"} {type="password"} } } } else { table_row { table_data {colspan="3"} { puts "\${dialogSettingsSecurityMessagePerformSystemResetContent}" cgi_put "" } } } table_row { table_data {align="right"} {class="CLASS20812"} {colspan="3"} { division {class="popupControls CLASS20811"} { division {class="CLASS20813"} {onClick="OnNextStep()"} { puts "\${dialogSettingsSecurityMessagePerformBtnSystemReset}" } } } } } } } } } division {class="popupControls"} { table { table_row { table_data {class="CLASS20803"} { division {class="CLASS20804"} {onClick="showSecurityCP();"} { puts "\${btnCancel}" } } } } } puts "" cgi_javascript { puts "var url = \"$env(SCRIPT_NAME)?sid=\" + SessionId;" puts { OnNextStep = function() { dlgPopup.hide(); dlgPopup.setWidth(400); dlgPopup.LoadFromFile(url, "action=factory_reset_go&key="+document.getElementById("text_key").value); } } puts "translatePage('#messagebox');" } } proc action_factory_reset_go {} { global env http_head set system_has_user_key [catch {exec crypttool -v -t 0}] if { $system_has_user_key } { import key # check the entered key against our current system key if { [catch {exec crypttool -v -t 3 -k "$key"}]} { put_message "\${dialogSetSecKeyRebootFalseTitle}" { ${dialogSetSecKeyRebootFalseContent} } {"\${dialogBack}" "showSecurityCP();"} return } } catch { exec run-parts -a stop /etc/config/rc.d } if { [catch { exec crypttool -r # exec umount /usr/local # exec /usr/sbin/ubidetach -p /dev/mtd6 # exec /usr/sbin/ubiformat /dev/mtd6 -y # exec /usr/sbin/ubiattach -p /dev/mtd6 # exec /usr/sbin/ubimkvol /dev/ubi1 -N user -m # exec mount /usr/local if {[getProduct] < 3 } { # CCU2 exec touch /var/doFactoryReset } else { exec touch /usr/local/.doFactoryReset } exec kill -SIGQUIT 1 }]} { # TWIST-22 set comment { division {class="popupTitle"} { puts "Systemreset: Fehler" } division {class="CLASS20800"} { table {class="popupTable CLASS20801"} {border="1"} { table_row {class="CLASS20802"} { table_data { puts { Das System konnte nicht auf Werkseinstellungen zurückgesetzt werden. Die Zentrale wird jetzt neu gestartet. Versuchen Sie es danach bitte erneut.
Falls diese Meldung danach wieder erscheint, deinstallieren Sie bitte jegliche Zusatzsoftware, starten die Zentrale neu und versuchen es nocheinmal. } } } } } } } put_message "\${dialogPerformRebootTitle}" { ${dialogPerformRebootContent} } {"\${btnNewLogin}" "window.location.href='/';"} # Nicht mehr n�tig, siehe TWIST-22 set comment { else { division {class="popupTitle"} { puts "Systemreset: Neustart des Systems" } division {class="CLASS20800"} { table {class="popupTable CLASS20801"} {border="1"} { table_row {class="CLASS20802"} { table_data { puts { Das System wurde auf Werkseinstellungen zurückgesetzt. Die Zentrale wird jetzt neu gestartet. Bitte melden Sie sich nach dem Starten der Zentrale neu an. } } } } } } division {class="popupControls"} { table { table_row { table_data {class="CLASS20803" align="center"} { division {class="CLASS20804"} {onClick="window.location.href='/';"} { puts "Neu anmelden" } } } } } } puts "" cgi_javascript { puts "var url = \"$env(SCRIPT_NAME)?sid=\" + SessionId;" puts { var pb = "action=reboot"; var opts = { postBody: pb, sendXML: false }; new Ajax.Request(url, opts); } } } proc action_backup_restore_check {} { global env cd /tmp/ http_head set i 0 if { [catch { exec tar xf new_config.tar file delete -force /tmp/new_config.tar set config_version [read_version "firmware_version"] set ccu1_backup false if { [version_compare $config_version 2.0.0] < 0 } { set ccu1_backup true } set system_has_user_key [catch {exec crypttool -v -t 0}] set stored_signature [exec cat signature] set calculated_signature [exec crypttool -s -t 0