Re: Fix for ssh-user-config /etc/passwd parsing

2015-01-08 Thread Corinna Vinschen
On Jan  5 09:12, Andrey Repin wrote:
> Greetings, All!
> 
> Replace line 79 with
> 
>   pwdhome=$(getent passwd ${uid} | cut -sd : -f 6 )
> 
> The error messages in the next few lines should probably be updated as well.
> Something along the lines of
> 
> 83:  "Unable to determine user's home directory from system settings." \
> 
> 90:  "${pwdhome} is found to be set as your home directory" \
> 
> 99:csih_warning "Your home directory is found to be set to root (/). This 
> is not recommended!"

Just as I outlined in my other mail a few minutes ago, ssh-user-config
in the OpenSSH release package is not the latest upstream version.  If
you want to test the latest ssh-user-config script with 1.7.34-awareness,
see the attached.


Thanks,
Corinna

-- 
Corinna Vinschen  Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
#!/bin/bash
#
# ssh-user-config, Copyright 2000-2014 Red Hat Inc.
#
# This file is part of the Cygwin port of OpenSSH.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF   
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   
# IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
# THE USE OR OTHER DEALINGS IN THE SOFTWARE.   

# ==
# Initialization
# ==
PROGNAME=$(basename -- $0)
_tdir=$(dirname -- $0)
PROGDIR=$(cd $_tdir && pwd)

CSIH_SCRIPT=/usr/share/csih/cygwin-service-installation-helper.sh

# Subdirectory where the new package is being installed
PREFIX=/usr

# Directory where the config files are stored
SYSCONFDIR=/etc

source ${CSIH_SCRIPT}

auto_passphrase="no"
passphrase=""
pwdhome=
with_passphrase=

# ==
# Routine: create_identity
#   optionally create identity of type argument in ~/.ssh
#   optionally add result to ~/.ssh/authorized_keys
# ==
create_identity() {
  local file="$1"
  local type="$2"
  local name="$3"
  if [ ! -f "${pwdhome}/.ssh/${file}" ]
  then
if csih_request "Shall I create a ${name} identity file for you?"
then
  csih_inform "Generating ${pwdhome}/.ssh/${file}"
  if [ "${with_passphrase}" = "yes" ]
  then
ssh-keygen -t "${type}" -N "${passphrase}" -f "${pwdhome}/.ssh/${file}" 
> /dev/null
  else
ssh-keygen -t "${type}" -f "${pwdhome}/.ssh/${file}" > /dev/null
  fi
  if csih_request "Do you want to use this identity to login to this 
machine?"
  then
csih_inform "Adding to ${pwdhome}/.ssh/authorized_keys"
cat "${pwdhome}/.ssh/${file}.pub" >> "${pwdhome}/.ssh/authorized_keys"
  fi
fi
  fi
} # === End of create_ssh1_identity() === #
readonly -f create_identity

# ==
# Routine: check_user_homedir
#   Perform various checks on the user's home directory
# SETS GLOBAL VARIABLE:
#   pwdhome
# ==
check_user_homedir() {
  pwdhome=$(getent passwd $UID | awk -F: '{ print $6; }')
  if [ "X${pwdhome}" = "X" ]
  then
csih_error_multi \
  "There is no home directory set for you in the account database." \
  'Setting $HOME is not sufficient!'
  fi
  
  if [ ! -d "${pwdhome}" ]
  then
csih_error_multi \
  "${pwdhome} is set in the account database as your home directory" \
  'but it is not a valid directory. Cannot create user identity files.'
  fi
  
  # If home is the root dir, set home to empty string to avoid error messages
  # in subsequent parts of that script.
  if [ "X${pwdhome}" = "X/" ]
  then
# But first raise a warning!
csih_warning "Your home directory in the account database is set to root 
(/). This is not recommended!"
if csih_request "Would you like to proceed anyway?"
then
  pwdhome=''
else
  csih_warning "Exiting. Configuration is not complete"
  exit 1
fi
  fi
  
  if [ -d "${pwdhome}" -a -n "`chmod -c g-w,o-w "${pwdhome}"`" ]
  then
echo
csih_warning 'group and other have been revoked write permission to your 
home'
csih_warning "directory ${pwdhome}."
csih_warning 'This is required by OpenSSH to allow public key 
authentication using'
csih_warning 'the key files stored in your .ssh subdirectory.'
 

Fix for ssh-user-config /etc/passwd parsing

2015-01-04 Thread Andrey Repin
Greetings, All!

Replace line 79 with

  pwdhome=$(getent passwd ${uid} | cut -sd : -f 6 )

The error messages in the next few lines should probably be updated as well.
Something along the lines of

83:  "Unable to determine user's home directory from system settings." \

90:  "${pwdhome} is found to be set as your home directory" \

99:csih_warning "Your home directory is found to be set to root (/). This 
is not recommended!"


-- 
WBR,
Andrey Repin (anrdae...@yandex.ru) 05.01.2015, <09:04>

Sorry for my terrible english...


--
Problem reports:   http://cygwin.com/problems.html
FAQ:   http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info:  http://cygwin.com/ml/#unsubscribe-simple