diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/gnome-ssh-askpass2.c | 99 | ||||
-rw-r--r-- | contrib/redhat/openssh.spec | 7 | ||||
-rw-r--r-- | contrib/ssh-copy-id | 158 | ||||
-rw-r--r-- | contrib/ssh-copy-id.1 | 2 | ||||
-rw-r--r-- | contrib/suse/openssh.spec | 6 |
5 files changed, 186 insertions, 86 deletions
diff --git a/contrib/gnome-ssh-askpass2.c b/contrib/gnome-ssh-askpass2.c index bc83a2d670f4..f7912727c3b3 100644 --- a/contrib/gnome-ssh-askpass2.c +++ b/contrib/gnome-ssh-askpass2.c @@ -56,9 +56,11 @@ #include <stdio.h> #include <string.h> #include <unistd.h> + #include <X11/Xlib.h> #include <gtk/gtk.h> #include <gdk/gdkx.h> +#include <gdk/gdkkeysyms.h> static void report_failed_grab (GtkWidget *parent_window, const char *what) @@ -85,6 +87,67 @@ ok_dialog(GtkWidget *entry, gpointer dialog) gtk_dialog_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); } +static gboolean +check_none(GtkWidget *widget, GdkEventKey *event, gpointer dialog) +{ + switch (event->keyval) { + case GDK_KEY_Escape: + /* esc -> close dialog */ + gtk_dialog_response(GTK_DIALOG(dialog), GTK_RESPONSE_CLOSE); + return TRUE; + case GDK_KEY_Tab: + /* tab -> focus close button */ + gtk_widget_grab_focus(gtk_dialog_get_widget_for_response( + dialog, GTK_RESPONSE_CLOSE)); + return TRUE; + default: + /* eat all other key events */ + return TRUE; + } +} + +static int +parse_env_hex_color(const char *env, GdkColor *c) +{ + const char *s; + unsigned long ul; + char *ep; + size_t n; + + if ((s = getenv(env)) == NULL) + return 0; + + memset(c, 0, sizeof(*c)); + + /* Permit hex rgb or rrggbb optionally prefixed by '#' or '0x' */ + if (*s == '#') + s++; + else if (strncmp(s, "0x", 2) == 0) + s += 2; + n = strlen(s); + if (n != 3 && n != 6) + goto bad; + ul = strtoul(s, &ep, 16); + if (*ep != '\0' || ul > 0xffffff) { + bad: + fprintf(stderr, "Invalid $%s - invalid hex color code\n", env); + return 0; + } + /* Valid hex sequence; expand into a GdkColor */ + if (n == 3) { + /* 4-bit RGB */ + c->red = ((ul >> 8) & 0xf) << 12; + c->green = ((ul >> 4) & 0xf) << 12; + c->blue = (ul & 0xf) << 12; + } else { + /* 8-bit RGB */ + c->red = ((ul >> 16) & 0xff) << 8; + c->green = ((ul >> 8) & 0xff) << 8; + c->blue = (ul & 0xff) << 8; + } + return 1; +} + static int passphrase_dialog(char *message, int prompt_type) { @@ -94,11 +157,16 @@ passphrase_dialog(char *message, int prompt_type) int buttons, default_response; GtkWidget *parent_window, *dialog, *entry; GdkGrabStatus status; + GdkColor fg, bg; + int fg_set = 0, bg_set = 0; grab_server = (getenv("GNOME_SSH_ASKPASS_GRAB_SERVER") != NULL); grab_pointer = (getenv("GNOME_SSH_ASKPASS_GRAB_POINTER") != NULL); grab_tries = 0; + fg_set = parse_env_hex_color("GNOME_SSH_ASKPASS_FG_COLOR", &fg); + bg_set = parse_env_hex_color("GNOME_SSH_ASKPASS_BG_COLOR", &bg); + /* Create an invisible parent window so that GtkDialog doesn't * complain. */ parent_window = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -127,17 +195,38 @@ passphrase_dialog(char *message, int prompt_type) gtk_dialog_set_default_response(GTK_DIALOG(dialog), default_response); gtk_window_set_keep_above(GTK_WINDOW(dialog), TRUE); - if (prompt_type == PROMPT_ENTRY) { + if (fg_set) + gtk_widget_modify_fg(dialog, GTK_STATE_NORMAL, &fg); + if (bg_set) + gtk_widget_modify_bg(dialog, GTK_STATE_NORMAL, &bg); + + if (prompt_type == PROMPT_ENTRY || prompt_type == PROMPT_NONE) { entry = gtk_entry_new(); + if (fg_set) + gtk_widget_modify_fg(entry, GTK_STATE_NORMAL, &fg); + if (bg_set) + gtk_widget_modify_bg(entry, GTK_STATE_NORMAL, &bg); gtk_box_pack_start( GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), entry, FALSE, FALSE, 0); gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE); gtk_widget_grab_focus(entry); - gtk_widget_show(entry); - /* Make <enter> close dialog */ - g_signal_connect(G_OBJECT(entry), "activate", - G_CALLBACK(ok_dialog), dialog); + if (prompt_type == PROMPT_ENTRY) { + gtk_widget_show(entry); + /* Make <enter> close dialog */ + g_signal_connect(G_OBJECT(entry), "activate", + G_CALLBACK(ok_dialog), dialog); + } else { + /* + * Ensure the 'close' button is not focused by default + * but is still reachable via tab. This is a bit of a + * hack - it uses a hidden entry that responds to a + * couple of keypress events (escape and tab only). + */ + gtk_widget_realize(entry); + g_signal_connect(G_OBJECT(entry), "key_press_event", + G_CALLBACK(check_none), dialog); + } } /* Grab focus */ diff --git a/contrib/redhat/openssh.spec b/contrib/redhat/openssh.spec index dcd57aa1966a..df99f7d73e05 100644 --- a/contrib/redhat/openssh.spec +++ b/contrib/redhat/openssh.spec @@ -1,4 +1,4 @@ -%global ver 8.3p1 +%global ver 8.4p1 %global rel 1%{?dist} # OpenSSH privilege separation requires a user & group ID @@ -363,8 +363,10 @@ fi %attr(0755,root,root) %dir %{_libexecdir}/openssh %attr(4711,root,root) %{_libexecdir}/openssh/ssh-keysign %attr(0755,root,root) %{_libexecdir}/openssh/ssh-pkcs11-helper +%attr(0755,root,root) %{_libexecdir}/openssh/ssh-sk-helper %attr(0644,root,root) %{_mandir}/man8/ssh-keysign.8* %attr(0644,root,root) %{_mandir}/man8/ssh-pkcs11-helper.8* +%attr(0644,root,root) %{_mandir}/man8/ssh-sk-helper.8* %endif %if %{scard} %attr(0755,root,root) %dir %{_datadir}/openssh @@ -422,6 +424,9 @@ fi %endif %changelog +* Mon Jul 20 2020 Damien Miller <djm@mindrto.org> +- Add ssh-sk-helper and corresponding manual page. + * Sat Feb 10 2018 Darren Tucker <dtucker@dtucker.net> - Update openssl-devel dependency to match current requirements. - Handle Fedora >=6 openssl 1.0 compat libs. diff --git a/contrib/ssh-copy-id b/contrib/ssh-copy-id index b83b83619896..392f64f9425f 100644 --- a/contrib/ssh-copy-id +++ b/contrib/ssh-copy-id @@ -1,6 +1,7 @@ #!/bin/sh -# Copyright (c) 1999-2016 Philip Hands <phil@hands.com> +# Copyright (c) 1999-2020 Philip Hands <phil@hands.com> +# 2017 Sebastien Boyron <seb@boyron.eu> # 2013 Martin Kletzander <mkletzan@redhat.com> # 2010 Adeodato =?iso-8859-1?Q?Sim=F3?= <asp16@alu.ua.es> # 2010 Eric Moret <eric.moret@gmail.com> @@ -33,13 +34,15 @@ # Shell script to install your public key(s) on a remote machine # See the ssh-copy-id(1) man page for details +# shellcheck shell=dash + # check that we have something mildly sane as our shell, or try to find something better if false ^ printf "%s: WARNING: ancient shell, hunting for a more modern one... " "$0" then SANE_SH=${SANE_SH:-/usr/bin/ksh} if printf 'true ^ false\n' | "$SANE_SH" then - printf "'%s' seems viable.\n" "$SANE_SH" + printf "'%s' seems viable.\\n" "$SANE_SH" exec "$SANE_SH" "$0" "$@" else cat <<-EOF @@ -51,16 +54,16 @@ then a bug describing your setup, and the shell you used to make it work. EOF - printf "%s: ERROR: Less dimwitted shell required.\n" "$0" + printf '%s: ERROR: Less dimwitted shell required.\n' "$0" exit 1 fi fi -most_recent_id="$(cd "$HOME" ; ls -t .ssh/id*.pub 2>/dev/null | grep -v -- '-cert.pub$' | head -n 1)" -DEFAULT_PUB_ID_FILE="${most_recent_id:+$HOME/}$most_recent_id" +# shellcheck disable=SC2010 +DEFAULT_PUB_ID_FILE=$(ls -t "${HOME}"/.ssh/id*.pub 2>/dev/null | grep -v -- '-cert.pub$' | head -n 1) usage () { - printf 'Usage: %s [-h|-?|-f|-n] [-i [identity_file]] [-p port] [[-o <ssh -o options>] ...] [user@]hostname\n' "$0" >&2 + printf 'Usage: %s [-h|-?|-f|-n] [-i [identity_file]] [-p port] [-F alternative ssh_config file] [[-o <ssh -o options>] ...] [user@]hostname\n' "$0" >&2 printf '\t-f: force mode -- copy keys without trying to check if they are already installed\n' >&2 printf '\t-n: dry run -- no keys are actually copied\n' >&2 printf '\t-h|-?: print this help\n' >&2 @@ -69,18 +72,18 @@ usage () { # escape any single quotes in an argument quote() { - printf "%s\n" "$1" | sed -e "s/'/'\\\\''/g" + printf '%s\n' "$1" | sed -e "s/'/'\\\\''/g" } use_id_file() { local L_ID_FILE="$1" if [ -z "$L_ID_FILE" ] ; then - printf "%s: ERROR: no ID file found\n" "$0" + printf '%s: ERROR: no ID file found\n' "$0" exit 1 fi - if expr "$L_ID_FILE" : ".*\.pub$" >/dev/null ; then + if expr "$L_ID_FILE" : '.*\.pub$' >/dev/null ; then PUB_ID_FILE="$L_ID_FILE" else PUB_ID_FILE="$L_ID_FILE.pub" @@ -93,7 +96,7 @@ use_id_file() { ErrMSG=$( { : < "$f" ; } 2>&1 ) || { local L_PRIVMSG="" [ "$f" = "$PRIV_ID_FILE" ] && L_PRIVMSG=" (to install the contents of '$PUB_ID_FILE' anyway, look at the -f option)" - printf "\n%s: ERROR: failed to open ID file '%s': %s\n" "$0" "$f" "$(printf "%s\n%s\n" "$ErrMSG" "$L_PRIVMSG" | sed -e 's/.*: *//')" + printf "\\n%s: ERROR: failed to open ID file '%s': %s\\n" "$0" "$f" "$(printf '%s\n%s\n' "$ErrMSG" "$L_PRIVMSG" | sed -e 's/.*: *//')" exit 1 } done @@ -105,80 +108,37 @@ if [ -n "$SSH_AUTH_SOCK" ] && ssh-add -L >/dev/null 2>&1 ; then GET_ID="ssh-add -L" fi -while test "$#" -gt 0 +while getopts "i:o:p:F:fnh?" OPT do - [ "${SEEN_OPT_I}" ] && expr "$1" : "[-]i" >/dev/null && { - printf "\n%s: ERROR: -i option must not be specified more than once\n\n" "$0" - usage - } - - OPT= OPTARG= - # implement something like getopt to avoid Solaris pain - case "$1" in - -i?*|-o?*|-p?*) - OPT="$(printf -- "$1"|cut -c1-2)" - OPTARG="$(printf -- "$1"|cut -c3-)" - shift - ;; - -o|-p) - OPT="$1" - OPTARG="$2" - shift 2 - ;; - -i) - OPT="$1" - test "$#" -le 2 || expr "$2" : "[-]" >/dev/null || { - OPTARG="$2" - shift - } - shift - ;; - -f|-n|-h|-\?) - OPT="$1" - OPTARG= - shift - ;; - --) - shift - while test "$#" -gt 0 - do - SAVEARGS="${SAVEARGS:+$SAVEARGS }'$(quote "$1")'" - shift - done - break - ;; - -*) - printf "\n%s: ERROR: invalid option (%s)\n\n" "$0" "$1" - usage - ;; - *) - SAVEARGS="${SAVEARGS:+$SAVEARGS }'$(quote "$1")'" - shift - continue - ;; - esac case "$OPT" in - -i) + i) + [ "${SEEN_OPT_I}" ] && { + printf '\n%s: ERROR: -i option must not be specified more than once\n\n' "$0" + usage + } SEEN_OPT_I="yes" use_id_file "${OPTARG:-$DEFAULT_PUB_ID_FILE}" ;; - -o|-p) - SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }$OPT '$(quote "$OPTARG")'" + o|p|F) + SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }-$OPT '$(quote "${OPTARG}")'" ;; - -f) + f) FORCED=1 ;; - -n) + n) DRY_RUN=1 ;; - -h|-\?) + h|\?) usage ;; esac done +#shift all args to keep only USER_HOST +shift $((OPTIND-1)) + + -eval set -- "$SAVEARGS" if [ $# = 0 ] ; then usage @@ -189,16 +149,18 @@ if [ $# != 1 ] ; then fi # drop trailing colon -USER_HOST=$(printf "%s\n" "$1" | sed 's/:$//') +USER_HOST="$*" # tack the hostname onto SSH_OPTS SSH_OPTS="${SSH_OPTS:+$SSH_OPTS }'$(quote "$USER_HOST")'" # and populate "$@" for later use (only way to get proper quoting of options) eval set -- "$SSH_OPTS" +# shellcheck disable=SC2086 if [ -z "$(eval $GET_ID)" ] && [ -r "${PUB_ID_FILE:=$DEFAULT_PUB_ID_FILE}" ] ; then use_id_file "$PUB_ID_FILE" fi +# shellcheck disable=SC2086 if [ -z "$(eval $GET_ID)" ] ; then printf '%s: ERROR: No identities found\n' "$0" >&2 exit 1 @@ -209,6 +171,7 @@ fi populate_new_ids() { local L_SUCCESS="$1" + # shellcheck disable=SC2086 if [ "$FORCED" ] ; then NEW_IDS=$(eval $GET_ID) return @@ -218,17 +181,20 @@ populate_new_ids() { eval set -- "$SSH_OPTS" umask 0177 - local L_TMP_ID_FILE=$(mktemp ~/.ssh/ssh-copy-id_id.XXXXXXXXXX) + local L_TMP_ID_FILE + L_TMP_ID_FILE=$(mktemp ~/.ssh/ssh-copy-id_id.XXXXXXXXXX) if test $? -ne 0 || test "x$L_TMP_ID_FILE" = "x" ; then printf '%s: ERROR: mktemp failed\n' "$0" >&2 exit 1 fi local L_CLEANUP="rm -f \"$L_TMP_ID_FILE\" \"${L_TMP_ID_FILE}.stderr\"" + # shellcheck disable=SC2064 trap "$L_CLEANUP" EXIT TERM INT QUIT printf '%s: INFO: attempting to log in with the new key(s), to filter out any that are already installed\n' "$0" >&2 + # shellcheck disable=SC2086 NEW_IDS=$( eval $GET_ID | { - while read ID || [ "$ID" ] ; do + while read -r ID || [ "$ID" ] ; do printf '%s\n' "$ID" > "$L_TMP_ID_FILE" # the next line assumes $PRIV_ID_FILE only set if using a single id file - this @@ -261,21 +227,52 @@ populate_new_ids() { fi if [ -z "$NEW_IDS" ] ; then printf '\n%s: WARNING: All keys were skipped because they already exist on the remote system.\n' "$0" >&2 - printf '\t\t(if you think this is a mistake, you may want to use -f option)\n\n' "$0" >&2 + printf '\t\t(if you think this is a mistake, you may want to use -f option)\n\n' >&2 exit 0 fi printf '%s: INFO: %d key(s) remain to be installed -- if you are prompted now it is to install the new keys\n' "$0" "$(printf '%s\n' "$NEW_IDS" | wc -l)" >&2 } +# installkey_sh [target_path] +# produce a one-liner to add the keys to remote authorized_keys file +# optionally takes an alternative path for authorized_keys +installkeys_sh() { + local AUTH_KEY_FILE=${1:-.ssh/authorized_keys} + + # In setting INSTALLKEYS_SH: + # the tr puts it all on one line (to placate tcsh) + # (hence the excessive use of semi-colons (;) ) + # then in the command: + # cd to be at $HOME, just in case; + # the -z `tail ...` checks for a trailing newline. The echo adds one if was missing + # the cat adds the keys we're getting via STDIN + # and if available restorecon is used to restore the SELinux context + INSTALLKEYS_SH=$(tr '\t\n' ' ' <<-EOF) + cd; + umask 077; + mkdir -p $(dirname "${AUTH_KEY_FILE}") && + { [ -z \`tail -1c ${AUTH_KEY_FILE} 2>/dev/null\` ] || echo >> ${AUTH_KEY_FILE}; } && + cat >> ${AUTH_KEY_FILE} || + exit 1; + if type restorecon >/dev/null 2>&1; then + restorecon -F .ssh ${AUTH_KEY_FILE}; + fi +EOF + + # to defend against quirky remote shells: use 'exec sh -c' to get POSIX; + printf "exec sh -c '%s'" "${INSTALLKEYS_SH}" +} + REMOTE_VERSION=$(ssh -v -o PreferredAuthentications=',' -o ControlPath=none "$@" 2>&1 | sed -ne 's/.*remote software version //p') +# shellcheck disable=SC2029 case "$REMOTE_VERSION" in NetScreen*) populate_new_ids 1 for KEY in $(printf "%s" "$NEW_IDS" | cut -d' ' -f2) ; do - KEY_NO=$(($KEY_NO + 1)) - printf "%s\n" "$KEY" | grep ssh-dss >/dev/null || { + KEY_NO=$((KEY_NO + 1)) + printf '%s\n' "$KEY" | grep ssh-dss >/dev/null || { printf '%s: WARNING: Non-dsa key (#%d) skipped (NetScreen only supports DSA keys)\n' "$0" "$KEY_NO" >&2 continue } @@ -283,20 +280,25 @@ case "$REMOTE_VERSION" in if [ $? = 255 ] ; then printf '%s: ERROR: installation of key #%d failed (please report a bug describing what caused this, so that we can make this message useful)\n' "$0" "$KEY_NO" >&2 else - ADDED=$(($ADDED + 1)) + ADDED=$((ADDED + 1)) fi done if [ -z "$ADDED" ] ; then exit 1 fi ;; + dropbear*) + populate_new_ids 0 + [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | \ + ssh "$@" "$(installkeys_sh /etc/dropbear/authorized_keys)" \ + || exit 1 + ADDED=$(printf '%s\n' "$NEW_IDS" | wc -l) + ;; *) # Assuming that the remote host treats ~/.ssh/authorized_keys as one might expect populate_new_ids 0 - # in ssh below - to defend against quirky remote shells: use 'exec sh -c' to get POSIX; - # 'cd' to be at $HOME; add a newline if it's missing; and all on one line, because tcsh. [ "$DRY_RUN" ] || printf '%s\n' "$NEW_IDS" | \ - ssh "$@" "exec sh -c 'cd ; umask 077 ; mkdir -p .ssh && { [ -z "'`tail -1c .ssh/authorized_keys 2>/dev/null`'" ] || echo >> .ssh/authorized_keys ; } && cat >> .ssh/authorized_keys || exit 1 ; if type restorecon >/dev/null 2>&1 ; then restorecon -F .ssh .ssh/authorized_keys ; fi'" \ + ssh "$@" "$(installkeys_sh)" \ || exit 1 ADDED=$(printf '%s\n' "$NEW_IDS" | wc -l) ;; diff --git a/contrib/ssh-copy-id.1 b/contrib/ssh-copy-id.1 index ae75c79a5793..b75a88365396 100644 --- a/contrib/ssh-copy-id.1 +++ b/contrib/ssh-copy-id.1 @@ -1,5 +1,5 @@ .ig \" -*- nroff -*- -Copyright (c) 1999-2013 hands.com Ltd. <http://hands.com/> +Copyright (c) 1999-2016 hands.com Ltd. <http://hands.com/> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions diff --git a/contrib/suse/openssh.spec b/contrib/suse/openssh.spec index a2789052d535..e6459e82d69a 100644 --- a/contrib/suse/openssh.spec +++ b/contrib/suse/openssh.spec @@ -13,7 +13,7 @@ Summary: OpenSSH, a free Secure Shell (SSH) protocol implementation Name: openssh -Version: 8.3p1 +Version: 8.4p1 URL: https://www.openssh.com/ Release: 1 Source0: openssh-%{version}.tar.gz @@ -75,6 +75,8 @@ patented algorithms to separate libraries (OpenSSL). This package contains an X Window System passphrase dialog for OpenSSH. %changelog +* Mon Jul 20 2020 Damien Miller <djm@mindrto.org> +- Add ssh-sk-helper and corresponding manual page. * Wed Oct 26 2005 Iain Morgan <imorgan@nas.nasa.gov> - Removed accidental inclusion of --without-zlib-version-check * Tue Oct 25 2005 Iain Morgan <imorgan@nas.nasa.gov> @@ -211,6 +213,7 @@ rm -rf $RPM_BUILD_ROOT %attr(0755,root,root) %{_libdir}/ssh/sftp-server %attr(4711,root,root) %{_libdir}/ssh/ssh-keysign %attr(0755,root,root) %{_libdir}/ssh/ssh-pkcs11-helper +%attr(0755,root,root) %{_libdir}/ssh/ssh-sk-helper %attr(0644,root,root) %doc %{_mandir}/man1/scp.1* %attr(0644,root,root) %doc %{_mandir}/man1/sftp.1* %attr(0644,root,root) %doc %{_mandir}/man1/ssh.1* @@ -224,6 +227,7 @@ rm -rf $RPM_BUILD_ROOT %attr(0644,root,root) %doc %{_mandir}/man8/sftp-server.8* %attr(0644,root,root) %doc %{_mandir}/man8/ssh-keysign.8* %attr(0644,root,root) %doc %{_mandir}/man8/ssh-pkcs11-helper.8* +%attr(0644,root,root) %doc %{_mandir}/man8/ssh-sk-helper.8* %attr(0644,root,root) %doc %{_mandir}/man8/sshd.8* %attr(0644,root,root) /var/adm/fillup-templates/sysconfig.ssh |