Opened 3 years ago

Closed 2 years ago

#63407 closed defect (fixed)

ssh-copy-id @8.4p1_0: installkeys_sh() is broken (badly placed ')' of '$(..)'). Simple fix + openssh source reference included.

Reported by: balanco Owned by: l2dy (Zero King)
Priority: Normal Milestone:
Component: ports Version: 2.7.1
Keywords: Cc:
Port: ssh-copy-id

Description

Description:

in version @8.4p1_0 of ssh-copy-id,
line 250 of function installkeys_sh() reads:

INSTALLKEYS_SH=$(tr '\t\n' ' ' <<-EOF)

The final closing ')' on this line is misplaced, it should be moved to after the EOF ending the here code on the following lines; i.e.:

  • the closing parenthesis ')' should be removed from line 250
  • a new line consisting of just a closing parenthesis ')' should be added as line 261 (= immediately after the EOF closing the here code)

The corrected code fragment (lines 250-261 of ssh-copy-id) should read (changes at the end of the first and the added last line):

   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
  )

For validation:
At the time of writing (2021-08-26T16:41CEST), this can be verified against the authoritative openssh source code at https://github.com/openssh/openssh-portable/blob/master/contrib/ssh-copy-id; here is a direct permalink to the start of the code block in question (lines 251..262):
https://github.com/openssh/openssh-portable/blob/95401eea8503943449f712e5f3de52fc0bc612c5/contrib/ssh-copy-id#L251.

Change History (1)

comment:1 Changed 2 years ago by l2dy (Zero King)

Port: @8.4p1_0 removed
Resolution: fixed
Status: assignedclosed

Fixed in ssh-copy-id @8.8p1.

Note: See TracTickets for help on using tickets.