Improve error trapping
This commit is contained in:
parent
13c4173ca1
commit
39ab2d4505
|
@ -845,42 +845,47 @@ ts method getkey {mode} {
|
|||
|
||||
set rfile [file rootname $file]
|
||||
|
||||
# the active key
|
||||
set keys {}
|
||||
# the active key
|
||||
set key [string range [system nugget cryptokey -key] 0 31]
|
||||
if {$key ne ""} {
|
||||
lappend keys $key
|
||||
}
|
||||
if { $mode ne "dlna" } {
|
||||
# also try other keys, such as the native key
|
||||
if {![catch {set fd [open "/mod/boot/cryptokey"]}]} {
|
||||
# also try other keys, such as this - same as active?
|
||||
try {
|
||||
set fd [open "/mod/boot/cryptokey"]
|
||||
set bytes [$fd read 16]
|
||||
$fd close
|
||||
binary scan $bytes H* key
|
||||
if {[string length $key] == 32} {
|
||||
if {$key ni $keys} {
|
||||
lappend keys $key
|
||||
}
|
||||
}
|
||||
}
|
||||
set key [system encryptionkey]
|
||||
if {$key ni $keys} {
|
||||
lappend keys $key
|
||||
}
|
||||
try {
|
||||
set fd [open "/mod/etc/keys" r]
|
||||
set xkeys [split [$fd read -nonewline] "\n"]
|
||||
$fd close
|
||||
} on error {} {
|
||||
set xkeys {}
|
||||
} finally {
|
||||
foreach key $xkeys {
|
||||
binary scan $bytes H* key
|
||||
if {[string length $key] == 32} {
|
||||
if {$key ni $keys} {
|
||||
lappend keys $key
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
catch {$fd close}
|
||||
}
|
||||
|
||||
# the native key
|
||||
if {![catch {set key [system encryptionkey]}]} {
|
||||
if {$key ni $keys} {
|
||||
lappend keys $key
|
||||
}
|
||||
|
||||
# support a file listing other keys in hex, one-per-line
|
||||
# eg, for recordings imported from a broken box
|
||||
try {
|
||||
set fd [open "/mod/etc/keys" r]
|
||||
foreach key [split [$fd read -nonewline] "\n"] {
|
||||
if {$key ni $keys} {
|
||||
lappend keys $key
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
catch {$fd close}
|
||||
}
|
||||
}
|
||||
|
||||
foreach key $keys {
|
||||
if {[catch {
|
||||
set ret [exec /mod/bin/stripts -q/ $key $rfile]
|
||||
|
|
Loading…
Reference in New Issue