aboutsummaryrefslogtreecommitdiff
path: root/rex
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-02-18 13:15:55 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2013-02-18 13:15:55 +0200
commit936bab2bed33ab383636b252857eb61245208446 (patch)
tree720ec9c0ad4ad546075e143e6448c759c37520c9 /rex
parent7c1d8f6ca246cf4a2ab1a4625d5cce659cce87ea (diff)
downloadrex-936bab2bed33ab383636b252857eb61245208446.tar.gz
rex-936bab2bed33ab383636b252857eb61245208446.tar.bz2
Bugfixes.
* rex: Change libpath (writedb): Use maketempfile to create a temporary file. (mkdbview,svdbview): Fix conditionals. (editdb): Add a global decl for env. * vpnc.exp (startvpnc): Set default value for pidfile.
Diffstat (limited to 'rex')
-rwxr-xr-xrex19
1 files changed, 13 insertions, 6 deletions
diff --git a/rex b/rex
index 5cc5937..549d2a8 100755
--- a/rex
+++ b/rex
@@ -21,7 +21,7 @@ set version "2.0"
set sysconfdir "/etc/rex"
set usrconfdir "$env(HOME)/.rex"
set confpath [list $usrconfdir $sysconfdir]
-set libpath [list $usrconfdir $sysconfdir "$sysconfdir/script"]
+set libpath [list $usrconfdir/script $sysconfdir/script]
array set config {
prompt "(%|#|\\$) $"
@@ -286,12 +286,13 @@ proc writedb {file var} {
upvar $var x
debug 2 writing database file $file
- set fd [open ${file}.tmp "w"]
+ set temp [maketempfile]
+ set fd [open $temp "w"]
foreach key [lsort -command keycmp [array names x]] {
puts $fd "$key $x($key)"
}
close $fd
- file rename -force ${file}.tmp $file
+ file rename -force $temp $file
}
# Update rexdb if it has been modified.
@@ -316,7 +317,8 @@ proc mkdbview {dbname tempfile dbvar} {
puts $fd [format "# %-30.30s\t%s" "Key" "Value"]
foreach key [lsort -command keycmp [array names db]] {
if {$key == "pass" ||
- [string last ":pass" $key] == [expr [string length $key] - 5]} {
+ ([string last ":pass" $key] > 0 &&
+ [string last ":pass" $key] == [expr [string length $key] - 5])} {
puts $fd [format "%-32.32s\t%s" $key [passdec $db($key)]]
} else {
puts $fd [format "%-32.32s\t%s" $key $db($key)]
@@ -330,8 +332,9 @@ proc svdbview {tempfile outfile} {
array set x {}
readdb $tempfile x
foreach key [array names x] {
- if {$key == "pass" ||
- [string last ":pass" $key] == [expr [string length $key] - 5]} {
+ if {$key == "pass" ||
+ ([string last ":pass" $key] > 0 &&
+ [string last ":pass" $key] == [expr [string length $key] - 5])} {
set x($key) [passenc $x($key)]
}
}
@@ -363,6 +366,8 @@ proc whatnow {} {
# human-readable way, stored in a temporary file and an editor is started
# on that file.
proc editdb {dbname} {
+ global env
+
array set rexdb {}
readdb $dbname rexdb
@@ -774,6 +779,8 @@ if [info exists config(option,hostgroup)] {
set libpath [linsert libpath 0 "$config(home)/script"]
debug 1 "group home is $config(home)"
}
+} else {
+ set config(home) $usrconfdir
}
if [info exists config(option,encrypt)] {

Return to:

Send suggestions and report system problems to the System administrator.