Lines 65-73
Link Here
|
65 |
$quietopt || echo "$*" >&2 |
65 |
$quietopt || echo "$*" >&2 |
66 |
} |
66 |
} |
67 |
|
67 |
|
68 |
# synopsis: mesg "message" |
68 |
# synopsis: message "message" |
69 |
# Prettily print something to stderr, honors quietopt |
69 |
# Prettily print something to stderr, honors quietopt |
70 |
mesg() { |
70 |
message() { |
71 |
qprint " ${GREEN}*${OFF} $*" |
71 |
qprint " ${GREEN}*${OFF} $*" |
72 |
} |
72 |
} |
73 |
|
73 |
|
Lines 431-442
Link Here
|
431 |
if [ $tl_current -eq $tl_nextmesg ]; then |
431 |
if [ $tl_current -eq $tl_nextmesg ]; then |
432 |
tl_timeleft=`expr $tl_end - $tl_current` |
432 |
tl_timeleft=`expr $tl_end - $tl_current` |
433 |
if [ $tl_timeleft -gt 0 ]; then |
433 |
if [ $tl_timeleft -gt 0 ]; then |
434 |
mesg "Waiting $tl_timeleft seconds for lock, held by pid $tl_pid" |
434 |
message "Waiting $tl_timeleft seconds for lock, held by pid $tl_pid" |
435 |
fi |
435 |
fi |
436 |
tl_nextmesg=`expr $tl_current + 1` |
436 |
tl_nextmesg=`expr $tl_current + 1` |
437 |
fi |
437 |
fi |
438 |
else |
438 |
else |
439 |
$tl_announced || mesg "Waiting for lock, held by pid $tl_pid" |
439 |
$tl_announced || message "Waiting for lock, held by pid $tl_pid" |
440 |
tl_announced=true |
440 |
tl_announced=true |
441 |
fi |
441 |
fi |
442 |
|
442 |
|
Lines 539-552
Link Here
|
539 |
[ $? = 0 ] || die |
539 |
[ $? = 0 ] || die |
540 |
|
540 |
|
541 |
if [ -z "$stop_mypids" ]; then |
541 |
if [ -z "$stop_mypids" ]; then |
542 |
mesg "No $stop_prog-agent(s) found running" |
542 |
message "No $stop_prog-agent(s) found running" |
543 |
return 0 |
543 |
return 0 |
544 |
fi |
544 |
fi |
545 |
|
545 |
|
546 |
case "$stopwhich" in |
546 |
case "$stopwhich" in |
547 |
all) |
547 |
all) |
548 |
kill $stop_mypids >/dev/null 2>&1 |
548 |
kill $stop_mypids >/dev/null 2>&1 |
549 |
mesg "All $me's $stop_prog-agent(s) ($stop_mypids) are now stopped" |
549 |
message "All $me's $stop_prog-agent(s) ($stop_mypids) are now stopped" |
550 |
;; |
550 |
;; |
551 |
|
551 |
|
552 |
others) |
552 |
others) |
Lines 573-590
Link Here
|
573 |
|
573 |
|
574 |
if [ -n "$stop_mynewpids" ]; then |
574 |
if [ -n "$stop_mynewpids" ]; then |
575 |
kill $stop_mynewpids >/dev/null 2>&1 |
575 |
kill $stop_mynewpids >/dev/null 2>&1 |
576 |
mesg "Other $me's $stop_prog-agent(s) ($stop_mynewpids) are now stopped" |
576 |
message "Other $me's $stop_prog-agent(s) ($stop_mynewpids) are now stopped" |
577 |
else |
577 |
else |
578 |
mesg "No other $stop_prog-agent(s) than keychain's $stop_except found running" |
578 |
message "No other $stop_prog-agent(s) than keychain's $stop_except found running" |
579 |
fi |
579 |
fi |
580 |
;; |
580 |
;; |
581 |
|
581 |
|
582 |
mine) |
582 |
mine) |
583 |
if [ $stop_except -gt 0 ] 2>/dev/null; then |
583 |
if [ $stop_except -gt 0 ] 2>/dev/null; then |
584 |
kill $stop_except >/dev/null 2>&1 |
584 |
kill $stop_except >/dev/null 2>&1 |
585 |
mesg "Keychain $stop_prog-agent $stop_except is now stopped" |
585 |
message "Keychain $stop_prog-agent $stop_except is now stopped" |
586 |
else |
586 |
else |
587 |
mesg "No keychain $stop_prog-agent found running" |
587 |
message "No keychain $stop_prog-agent found running" |
588 |
fi |
588 |
fi |
589 |
;; |
589 |
;; |
590 |
esac |
590 |
esac |
Lines 794-800
Link Here
|
794 |
start_tester="$inheritwhich: $start_mypids $start_fwdflg " |
794 |
start_tester="$inheritwhich: $start_mypids $start_fwdflg " |
795 |
case "$start_tester" in |
795 |
case "$start_tester" in |
796 |
none:*" $start_pid "*|*-once:*" $start_pid "*) |
796 |
none:*" $start_pid "*|*-once:*" $start_pid "*) |
797 |
mesg "Found existing ${start_prog}-agent ($start_pid)" |
797 |
message "Found existing ${start_prog}-agent ($start_pid)" |
798 |
return 0 |
798 |
return 0 |
799 |
;; |
799 |
;; |
800 |
|
800 |
|
Lines 807-813
Link Here
|
807 |
startagent "$start_prog" |
807 |
startagent "$start_prog" |
808 |
return $? |
808 |
return $? |
809 |
fi |
809 |
fi |
810 |
mesg "Inheriting ${start_prog}-agent ($start_inherit_pid)" |
810 |
message "Inheriting ${start_prog}-agent ($start_inherit_pid)" |
811 |
;; |
811 |
;; |
812 |
|
812 |
|
813 |
*) |
813 |
*) |
Lines 818-824
Link Here
|
818 |
esac |
818 |
esac |
819 |
|
819 |
|
820 |
# Init the bourne-formatted pidfile |
820 |
# Init the bourne-formatted pidfile |
821 |
mesg "Initializing $start_pidf file..." |
821 |
message "Initializing $start_pidf file..." |
822 |
( umask 0177 && :> "$start_pidf"; ) |
822 |
( umask 0177 && :> "$start_pidf"; ) |
823 |
if [ $? != 0 ]; then |
823 |
if [ $? != 0 ]; then |
824 |
rm -f "$start_pidf" "$start_cshpidf" "$start_fishpidf" 2>/dev/null |
824 |
rm -f "$start_pidf" "$start_cshpidf" "$start_fishpidf" 2>/dev/null |
Lines 827-833
Link Here
|
827 |
fi |
827 |
fi |
828 |
|
828 |
|
829 |
# Init the csh-formatted pidfile |
829 |
# Init the csh-formatted pidfile |
830 |
mesg "Initializing $start_cshpidf file..." |
830 |
message "Initializing $start_cshpidf file..." |
831 |
( umask 0177 && :> "$start_cshpidf"; ) |
831 |
( umask 0177 && :> "$start_cshpidf"; ) |
832 |
if [ $? != 0 ]; then |
832 |
if [ $? != 0 ]; then |
833 |
rm -f "$start_pidf" "$start_cshpidf" "$start_fishpidf" 2>/dev/null |
833 |
rm -f "$start_pidf" "$start_cshpidf" "$start_fishpidf" 2>/dev/null |
Lines 836-842
Link Here
|
836 |
fi |
836 |
fi |
837 |
|
837 |
|
838 |
# Init the fish-formatted pidfile |
838 |
# Init the fish-formatted pidfile |
839 |
mesg "Initializing $start_fishpidf file..." |
839 |
message "Initializing $start_fishpidf file..." |
840 |
( umask 0177 && :> "$start_fishpidf"; ) |
840 |
( umask 0177 && :> "$start_fishpidf"; ) |
841 |
if [ $? != 0 ]; then |
841 |
if [ $? != 0 ]; then |
842 |
rm -f "$start_pidf" "$start_cshpidf" "$start_fishpidf" 2>/dev/null |
842 |
rm -f "$start_pidf" "$start_cshpidf" "$start_fishpidf" 2>/dev/null |
Lines 850-856
Link Here
|
850 |
|
850 |
|
851 |
# Start the agent. |
851 |
# Start the agent. |
852 |
# Branch again since the agents start differently |
852 |
# Branch again since the agents start differently |
853 |
mesg "Starting ${start_prog}-agent" |
853 |
message "Starting ${start_prog}-agent" |
854 |
if [ "$start_prog" = ssh ]; then |
854 |
if [ "$start_prog" = ssh ]; then |
855 |
start_out=`ssh-agent` |
855 |
start_out=`ssh-agent` |
856 |
elif [ "$start_prog" = gpg ]; then |
856 |
elif [ "$start_prog" = gpg ]; then |
Lines 937-943
Link Here
|
937 |
# explicitly in ssh_l and ssh_f, so hopefully this rule will |
937 |
# explicitly in ssh_l and ssh_f, so hopefully this rule will |
938 |
# never fire. |
938 |
# never fire. |
939 |
warn "Can't determine fingerprint from the following line, falling back to filename" |
939 |
warn "Can't determine fingerprint from the following line, falling back to filename" |
940 |
mesg "$ef_line" |
940 |
message "$ef_line" |
941 |
basename "$ef_line" | sed 's/[ (].*//' |
941 |
basename "$ef_line" | sed 's/[ (].*//' |
942 |
;; |
942 |
;; |
943 |
esac |
943 |
esac |
Lines 1042-1048
Link Here
|
1042 |
if echo | env -i PATH="$PATH" GPG_AGENT_INFO="$GPG_AGENT_INFO" \ |
1042 |
if echo | env -i PATH="$PATH" GPG_AGENT_INFO="$GPG_AGENT_INFO" \ |
1043 |
gpg --no-options --use-agent --no-tty --sign --local-user "$glm_k" -o- >/dev/null 2>&1; then |
1043 |
gpg --no-options --use-agent --no-tty --sign --local-user "$glm_k" -o- >/dev/null 2>&1; then |
1044 |
# already know about this key |
1044 |
# already know about this key |
1045 |
mesg "Known gpg key: ${BLUE}${glm_k}${OFF}" |
1045 |
message "Known gpg key: ${BLUE}${glm_k}${OFF}" |
1046 |
continue |
1046 |
continue |
1047 |
else |
1047 |
else |
1048 |
# need to add this key |
1048 |
# need to add this key |
Lines 1081-1087
Link Here
|
1081 |
case " $sshavail " in |
1081 |
case " $sshavail " in |
1082 |
*" $slm_finger "*) |
1082 |
*" $slm_finger "*) |
1083 |
# already know about this key |
1083 |
# already know about this key |
1084 |
mesg "Known ssh key: ${BLUE}${slm_k}${OFF}" |
1084 |
message "Known ssh key: ${BLUE}${slm_k}${OFF}" |
1085 |
;; |
1085 |
;; |
1086 |
*) |
1086 |
*) |
1087 |
# need to add this key |
1087 |
# need to add this key |
Lines 1458-1464
Link Here
|
1458 |
sshavail=`ssh_l` # try to use existing agent |
1458 |
sshavail=`ssh_l` # try to use existing agent |
1459 |
# 0 = found keys, 1 = no keys, 2 = no agent |
1459 |
# 0 = found keys, 1 = no keys, 2 = no agent |
1460 |
if [ $? = 0 -o \( $? = 1 -a -z "$mykeys" \) ]; then |
1460 |
if [ $? = 0 -o \( $? = 1 -a -z "$mykeys" \) ]; then |
1461 |
mesg "Found existing ssh-agent ($ssh_agent_pid)" |
1461 |
message "Found existing ssh-agent ($ssh_agent_pid)" |
1462 |
needstart=false |
1462 |
needstart=false |
1463 |
fi |
1463 |
fi |
1464 |
elif [ $a = gpg ]; then |
1464 |
elif [ $a = gpg ]; then |
Lines 1466-1472
Link Here
|
1466 |
if [ -n "$gpg_agent_pid" ]; then |
1466 |
if [ -n "$gpg_agent_pid" ]; then |
1467 |
case " `findpids gpg` " in |
1467 |
case " `findpids gpg` " in |
1468 |
*" $gpg_agent_pid "*) |
1468 |
*" $gpg_agent_pid "*) |
1469 |
mesg "Found existing gpg-agent ($gpg_agent_pid)" |
1469 |
message "Found existing gpg-agent ($gpg_agent_pid)" |
1470 |
needstart=false ;; |
1470 |
needstart=false ;; |
1471 |
esac |
1471 |
esac |
1472 |
fi |
1472 |
fi |
Lines 1525-1537
Link Here
|
1525 |
if [ $a = ssh ]; then |
1525 |
if [ $a = ssh ]; then |
1526 |
sshout=`ssh-add -D 2>&1` |
1526 |
sshout=`ssh-add -D 2>&1` |
1527 |
if [ $? = 0 ]; then |
1527 |
if [ $? = 0 ]; then |
1528 |
mesg "ssh-agent: $sshout" |
1528 |
message "ssh-agent: $sshout" |
1529 |
else |
1529 |
else |
1530 |
warn "ssh-agent: $sshout" |
1530 |
warn "ssh-agent: $sshout" |
1531 |
fi |
1531 |
fi |
1532 |
elif [ $a = gpg ]; then |
1532 |
elif [ $a = gpg ]; then |
1533 |
kill -1 $gpg_agent_pid 2>/dev/null |
1533 |
kill -1 $gpg_agent_pid 2>/dev/null |
1534 |
mesg "gpg-agent: All identities removed." |
1534 |
message "gpg-agent: All identities removed." |
1535 |
else |
1535 |
else |
1536 |
warn "--clear not supported for ${a}-agent" |
1536 |
warn "--clear not supported for ${a}-agent" |
1537 |
fi |
1537 |
fi |
Lines 1556-1562
Link Here
|
1556 |
# Attempt to add the keys |
1556 |
# Attempt to add the keys |
1557 |
while [ -n "$sshkeys" ]; do |
1557 |
while [ -n "$sshkeys" ]; do |
1558 |
|
1558 |
|
1559 |
mesg "Adding ${BLUE}"`echo "$sshkeys" | wc -l`"${OFF} ssh key(s)..." |
1559 |
message "Adding ${BLUE}"`echo "$sshkeys" | wc -l`"${OFF} ssh key(s)..." |
1560 |
|
1560 |
|
1561 |
# Parse $sshkeys into positional params to preserve spaces in filenames. |
1561 |
# Parse $sshkeys into positional params to preserve spaces in filenames. |
1562 |
# This *must* happen after any calls to subroutines because pure Bourne |
1562 |
# This *must* happen after any calls to subroutines because pure Bourne |
Lines 1609-1615
Link Here
|
1609 |
while [ -n "$gpgkeys" ]; do |
1609 |
while [ -n "$gpgkeys" ]; do |
1610 |
tryagain=false |
1610 |
tryagain=false |
1611 |
|
1611 |
|
1612 |
mesg "Adding ${BLUE}"`echo "$gpgkeys" | wc -l`"${OFF} gpg key(s)..." |
1612 |
message "Adding ${BLUE}"`echo "$gpgkeys" | wc -l`"${OFF} gpg key(s)..." |
1613 |
|
1613 |
|
1614 |
# Parse $gpgkeys into positional params to preserve spaces in filenames. |
1614 |
# Parse $gpgkeys into positional params to preserve spaces in filenames. |
1615 |
# This *must* happen after any calls to subroutines because pure Bourne |
1615 |
# This *must* happen after any calls to subroutines because pure Bourne |