This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: ssh-host-config script sends /etc/passwd thru awk
- From: Achim Gratz <Stromeko at nexgo dot de>
- To: cygwin at cygwin dot com
- Date: Wed, 18 Feb 2015 13:00:23 +0100
- Subject: Re: ssh-host-config script sends /etc/passwd thru awk
- Authentication-results: sourceware.org; auth=none
- References: <4C148215-468D-469D-8060-B2010DF5E9A9 at etr-usa dot com> <20150217230230 dot GH8493 at calimero dot vinschen dot de> <62DA4A6B-8BA1-4676-B88F-42F6A3707AAD at etr-usa dot com> <20150218100809 dot GK8493 at calimero dot vinschen dot de>
Corinna Vinschen writes:
> It's a bit confusing to talk about the Cygwin version when this is
> only about openssh and the csih package. I'm really busy with other
> stuff right now. I quickly scanned the ssh-*-config scripts again
> and they never write a passwd entry so, if anything, it's a problem
> in the csih helper script. Does anybody want to inspect
> /usr/share/csih/cygwin-service-installation-helper.sh for this?
How about this (untested)?
--8<---------------cut here---------------start------------->8---
--- /usr/share/csih/cygwin-service-installation-helper.sh.orig 2015-01-08 16:30:30.000000000 +0100
+++ /usr/share/csih/cygwin-service-installation-helper.sh 2015-02-18 12:47:18.487096800 +0100
@@ -88,6 +88,7 @@
# csih_make_dir
# csih_get_system_and_admins_ids
# csih_check_passwd_and_group
+# csih_old_cygwin
# csih_use_file_etc
# csih_check_user
# csih_check_dir_perms
@@ -2017,7 +2018,7 @@
if [ -z "$csih_ADMINSUID" -o -z "$csih_SYSTEMUID" ]
then
csih_warning "It appears that you do not have an entry for the local"
- csih_warning "ADMINISTRATORS (group) and/or SYSTEM sids in /etc/passwd."
+ csih_warning "ADMINISTRATORS (group) and/or SYSTEM sids."
csih_warning ""
csih_warning "Use the 'mkpasswd' utility to generate it or allow \"db\""
csih_warning "search of passwd accounts in /etc/nsswitch.conf"
@@ -2042,37 +2043,54 @@
csih_stacktrace "${@}"
$_csih_trace
local ret=0
- # Check for mkpasswd only valid up to Cygwin 1.7.32 */
- if [ "$(/usr/bin/id -gn)" = "mkpasswd" ]
- then
- csih_warning "It appears that you do not have an entry for your user ID"
- csih_warning "in /etc/passwd."
- csih_warning ""
- csih_warning "If so, use the 'mkpasswd' utility to generate an"
- csih_warning "entry for your User ID in the password file:"
- csih_warning " mkpasswd -l -u User_ID >> /etc/passwd"
- csih_warning "or"
- csih_warning " mkpasswd -d -u User_ID >> /etc/passwd."
- csih_warning ""
- _csih_warning_for_etc_file passwd
- ret=1
- fi
-
- # Check for mkgroup only valid up to Cygwin 1.7.32 */
- if [ "$(/usr/bin/id -gn)" = mkgroup ]
- then
- csih_warning "It appears that you do not have an entry for your group ID"
- csih_warning "in /etc/group. If this check is incorrect, then re-run"
- csih_warning "this script with the '-f' command-line option."
- csih_warning ""
- csih_warning "Otherwise, use the 'mkgroup' utility to generate an"
- csih_warning "entry for your group ID in the password file:"
- csih_warning " mkgroup -l -g Group_id >> /etc/group"
- csih_warning "or"
- csih_warning " mkgroup -d -g Group_id >> /etc/group."
- csih_warning ""
- _csih_warning_for_etc_file group
- ret=1
+ # Check for mkpasswd/mkgroup only valid up to Cygwin 1.7.33
+ if csih_old_cygwin
+ if [ "$(/usr/bin/id -un)" = "mkpasswd" ]
+ then
+ csih_warning "It appears that you do not have an entry for your user ID"
+ csih_warning "in /etc/passwd."
+ csih_warning ""
+ csih_warning "If so, use the 'mkpasswd' utility to generate an"
+ csih_warning "entry for your User ID in the password file:"
+ csih_warning " mkpasswd -l -u User_ID >> /etc/passwd"
+ csih_warning "or"
+ csih_warning " mkpasswd -d -u User_ID >> /etc/passwd."
+ csih_warning ""
+ _csih_warning_for_etc_file passwd
+ ret=1
+ fi
+ if [ "$(/usr/bin/id -gn)" = mkgroup ]
+ then
+ csih_warning "It appears that you do not have an entry for your group ID"
+ csih_warning "in /etc/group. If this check is incorrect, then re-run"
+ csih_warning "this script with the '-f' command-line option."
+ csih_warning ""
+ csih_warning "Otherwise, use the 'mkgroup' utility to generate an"
+ csih_warning "entry for your group ID in the password file:"
+ csih_warning " mkgroup -l -g Group_id >> /etc/group"
+ csih_warning "or"
+ csih_warning " mkgroup -d -g Group_id >> /etc/group."
+ csih_warning ""
+ _csih_warning_for_etc_file group
+ ret=1
+ fi
+ else
+ if ! getent passwd $(/usr/bin/id -un) >/dev/null 2>&1
+ then
+ csih_warning "It appears that you do not have an entry for your user ID"
+ csih_warning "in the user account database."
+ csih_warning ""
+ csih_warning "Please check the settings in /etc/nsswitch.conf."
+ ret=1
+ fi
+ if ! getent group $(/usr/bin/id -gn) >/dev/null 2>&1
+ then
+ csih_warning "It appears that you do not have an entry for your user ID"
+ csih_warning "in the group account database."
+ csih_warning ""
+ csih_warning "Please check the settings in /etc/nsswitch.conf."
+ ret=1
+ fi
fi
return "${ret}"
} # === End of csih_check_passwd_and_group() === #
@@ -2493,6 +2511,29 @@
readonly -f _csih_setup
# ======================================================================
+# Routine: csih_old_cygwin
+# Check Cygwin version, account databases are avaiable since 1.7.34
+# On Cygwin versions <= 1.7.33 return 0
+# On Cygwin versions > 1.7.33 return 1
+# ======================================================================
+csih_old_cygwin()
+{
+ local old_cygwin
+
+ /usr/bin/uname -r |
+ /usr/bin/awk -F. '{
+ if ( $1 < 1 || \
+ ($1 == 1 && $2 < 7) || \
+ ($1 == 1 && $2 == 7 && strtonum($3) <= 33))
+ exit 0;
+ exit 1;
+ }'
+ old_cygwin=$?
+ return ${old_cygwin}
+} # === End of csih_old_cygwin() === #
+readonly -f csih_old_cygwin
+
+# ======================================================================
# Routine: csih_use_file_etc passwd|group
# Check if /etc/passwd or /etc/group file is in use.
# On Cygwin versions < 1.7.33, files are always used.
@@ -2517,18 +2558,12 @@
then
csih_error 'Script error: csih_use_file_etc requires argument "passwd" or "group".'
fi
- /usr/bin/uname -r |
- /usr/bin/awk -F. '{
- if ($1 < 1 || \
- ($1 == 1 && $2 < 7) || \
- ($1 == 1 && $2 == 7 && strtonum($3) <= 33))
- exit 0;
- exit 1;
- }'
- use_file=$?
+ csih_old_cygwin ; use_file=$?
if [ ${use_file} -ne 0 -a -f /etc/nsswitch.conf ]
then
- grep -Eq "^${file}:[^#]*\<db\>" /etc/nsswitch.conf || use_file=0
+ grep -Eq "^${file}:" /etc/nsswitch.conf &&
+ grep -Eq "^${file}:[^#]*\<db\>" /etc/nsswitch.conf ||
+ use_file=0
fi
return ${use_file}
} # === End of csih_use_file_etc() === #
--8<---------------cut here---------------end--------------->8---
Regards,
Achim.
--
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+
Wavetables for the Terratec KOMPLEXER:
http://Synth.Stromeko.net/Downloads.html#KomplexerWaves
--
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