Skip to content

Commit

Permalink
Fixed permissions issues with new head and tail files.
Browse files Browse the repository at this point in the history
  • Loading branch information
mesaprotector committed Dec 16, 2024
1 parent bd5da0f commit 8248b00
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions addcomment
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,39 @@ else
echo "OK" > "$tmpdir"/"$tty"
echo "Comment added"
fi
#!/bin/bash
if [ "`ps ax | awk '$5 ~ /\/bin\/bash/' | awk '$6 ~ \
/\/lib\/waitcomment.sh/' | wc -l`" = "0" ]; then
echo "No waitcomment process"
exit
fi
. /etc/sudo-comment.conf
tty="`tty | cut -d '/' -f 3-`"
mytmpdir="`cat "$tmpdir/$tty"`"
echo "Comment on an edit? [y/yp/N] "
read -r comment
if [ "$comment" = "N" ]; then
echo "N/A" > "$tmpdir"/"$tty"
echo "No comment added"
elif [ "$comment" = "yp" ]; then
echo -e "=POSTDATED=" >> "$mytmpdir"/comment.tmp
lines="`cat "$mytmpdir"/comment.tmp | wc -l`"
sed '1s/^/@@ /' "$mytmpdir"/comment.tmp > "$mytmpdir"/head.tmp
eval "$editor" "$mytmpdir"/comment.tmp
tail -n +$((lines+1)) "$mytmpdir"/comment.tmp \
| fold -s | sed 's/^/# /' > "$mytmpdir"/tail.tmp
cat "$mytmpdir"/head.tmp "$mytmpdir"/tail.tmp > "$mytmpdir"/comment.tmp
rm "$mytmpdir"/head.tmp "$mytmpdir"/tail.tmp
echo "OK" > "$tmpdir"/"$tty"
echo "Comment added"
else
lines="`cat "$mytmpdir"/comment.tmp | wc -l`"
sed '1s/^/@@ /' "$mytmpdir"/comment.tmp > "$mytmpdir"/head.tmp
eval "$editor" "$mytmpdir"/comment.tmp
tail -n +$((lines+1)) "$mytmpdir"/comment.tmp \
| fold -s | sed 's/^/# /' > "$mytmpdir"/tail.tmp
cat "$mytmpdir"/head.tmp "$mytmpdir"/tail.tmp > "$mytmpdir"/comment.tmp
rm "$mytmpdir"/head.tmp "$mytmpdir"/tail.tmp
echo "OK" > "$tmpdir"/"$tty"
echo "Comment added"
fi
1 change: 1 addition & 0 deletions waitcomment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ if grep -qE "$p_track|>" <<< "$curr_command"; then

# addcomment normally runs unprivileged so these files need to be
# world-writable.
chmod 777 "$mytmpdir"
chmod 666 "$mytmpdir"/comment.tmp
chmod 666 "$tmpdir/$curr_shell"

Expand Down

0 comments on commit 8248b00

Please sign in to comment.