@@ -268,23 +268,17 @@ } } } proc _saveDB {dbCmd fileName} { - set tmpFileName "${fileName}.[expr rand()]" - - file delete -force -- $tmpFileName - - set fd [open $tmpFileName w] - if {[info exists ::globalHeader($dbCmd)]} { - puts $fd $::globalHeader($dbCmd) + lappend output $::globalHeader($dbCmd) unset ::globalHeader($dbCmd) } - puts $fd "# oh, ok." + lappend output "# oh, ok." foreach table [list users passwords] { unset -nocomplain row $dbCmd eval "SELECT * FROM $table ORDER BY name;" row { set outputLine [list $table] @@ -298,21 +292,17 @@ } lappend outputLine $key $value } - puts $fd $outputLine + lappend output $outputLine } } + set fd [open $fileName w 0600] + puts $fd [join $output "\n"] close $fd - - catch { - file attributes $tmpFileName {*}[file attributes $fileName] - } - - file rename -force -- $tmpFileName $fileName } proc _listCertificates {} { if {![info exists ::env(PKCS11MODULE)]} { return [list]