summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Kahn Gillmor <dkg@fifthhorseman.net>2008-09-04 20:28:55 -0400
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>2008-09-04 20:28:55 -0400
commitb66fd50fb2a2611ca4ba58003535748f453369d8 (patch)
tree619d9af34f6ea475686fbb777f5948cf02498ffb
parent990c334442c6c8cb5a7a6c0b4d11c0a8d3adac6d (diff)
removed use of sponge, got rid of dependency on moreutils.
-rw-r--r--debian/control2
-rw-r--r--src/common16
2 files changed, 15 insertions, 3 deletions
diff --git a/debian/control b/debian/control
index 348a394..a909c5d 100644
--- a/debian/control
+++ b/debian/control
@@ -11,7 +11,7 @@ Dm-Upload-Allowed: yes
Package: monkeysphere
Architecture: any
-Depends: openssh-client, gnupg | gnupg2, coreutils (>= 6), moreutils, lockfile-progs, adduser, ${shlibs:Depends}
+Depends: openssh-client, gnupg | gnupg2, coreutils (>= 6), lockfile-progs, adduser, ${shlibs:Depends}
Recommends: netcat | socat, ssh-askpass
Enhances: openssh-client, openssh-server
Description: use the OpenPGP web of trust to verify ssh connections
diff --git a/src/common b/src/common
index 7768335..2b05c3c 100644
--- a/src/common
+++ b/src/common
@@ -222,6 +222,7 @@ vnQCFl3+QFSe4zinqykHnLwGPMXv428d/ZjkIc2ju8dRsn4=
remove_line() {
local file
local string
+ local tempfile
file="$1"
string="$2"
@@ -236,8 +237,13 @@ remove_line() {
# if the string is in the file...
if grep -q -F "$string" "$file" 2> /dev/null ; then
+ tempfile=$(mktemp "${file}.XXXXXXX") || \
+ failure "Unable to make temp file '${file}.XXXXXXX'"
+
# remove the line with the string, and return 0
- grep -v -F "$string" "$file" | sponge "$file"
+ grep -v -F "$string" "$file" >"$tempfile"
+ cat "$tempfile" > "$file"
+ rm "$tempfile"
return 0
# otherwise return 1
else
@@ -248,6 +254,7 @@ remove_line() {
# remove all lines with MonkeySphere strings in file
remove_monkeysphere_lines() {
local file
+ local tempfile
file="$1"
@@ -259,8 +266,13 @@ remove_monkeysphere_lines() {
return 1
fi
+ tempfile=$(mktemp "${file}.XXXXXXX") || \
+ failure "Could not make temporary file '${file}.XXXXXXX'."
+
egrep -v '^MonkeySphere[[:digit:]]{4}(-[[:digit:]]{2}){2}T[[:digit:]]{2}(:[[:digit:]]{2}){2}$' \
- "$file" | sponge "$file"
+ "$file" >"$tempfile"
+ cat "$tempfile" > "$file"
+ rm "$tempfile"
}
# translate ssh-style path variables %h and %u