This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: New passwd/group handling in Cygwin - test results and observations


On Feb 14 02:11, Andrey Repin wrote:
> Greetings, Corinna Vinschen!
> 
> > This week I applied the first incarnation of the new passwd/group
> > handling code to the Cygwin repository and after fixing a crash which
> > manifested in Denis Excoffier's network, I think we're at a point
> > which allows to push this forward.
> 
> Oookaaaay... What to say about it?...
> First impression is "oh my god, did I bought a new rig?"
> 
> $ uname -a
> CYGWIN_NT-5.1 daemon2 1.7.29s(0.271/5/3) 20140213 14:06:26 i686 Cygwin
> 
> mintty startup is almost instant. Same with diff in native console.
> I have no idea, what you did, I don't even have a good explanation of why it
> happened. My /etc/passwd is about 1.5kb, half that - /etc/group.
> 
> I only dumped new cygwin1.dll into place and not changed anything else.
> I'm going to run unattended tests just to prove I'm not dreaming.
> 
> HOWEVER, here's a first bug. Actually, it was a long standing issue, that
> I've been discarding as nonessential, but since you are here already, can we
> have a bit of attention?
> 
> The issue can be observed when you have a user or group name containing
> characters outside basic ASCII character set. Even western diacritics will
> suffice.
> 
> Add somewhere in your startup files an equivalent of the following block:
> (I have it in private .profile)
> 
> ---->8-------->8-------->8-------->8-------->8-------->8-------->8----
> case "$TERM" in
>   xterm*)
>     LANG=ru_RU.UTF-8
>     ;;
>   *)
>     LANG=ru_RU.CP866
>     ;;
> esac
> 
> export PATH HISTCONTROL LANG
> ----8<--------8<--------8<--------8<--------8<--------8<--------8<----
> 
> restart your shell, and try to ls -l a directory, where you have files owned
> by abovementioned user/group.
> 
> Try it in mintty(the encoding will be UTF-8 and names will show up readable)
> and in native console (with appropriate single-byte encoding, the names will
> still be printed in unicode, means, raw byte sequences will be dumped to
> terminal).
> I though it could be affected by the fact I'm changing LANG on the fly, but
> starting bash in a console that initially have correct LANG= variable doesn't
> change observed results.

Yes, this is a problem, and I'm not sure how to fix it, if at all.

The problem is hopefully obvious.  We have to initialize things in some
order.  For instance, to read /etc/fstab.d/$USER, we need the username.
And since the Cygwin username can be different from the Windows username
(I guess I should have never added this functionality in the first
place), we have to read the user's passwd before we read the fstabs.

Same for the initialization of $LANG and friends.  That occurs pretty
late in the process initialization.  You know that Windows uses UTF-16
under the hood, so a lot of stuff gets read and converted to UTF-8
before we even care for the environment.  And if you set the codeset in
the application only, all the relevant information has already been read
long ago, of course.

But this is a problem not different from Linux.  If you have a username
with non-ASCII chars, it will use *some* encoding in the passwd DB,
usually UTF-8 these days.  If you then change the codeset in your
application, you will still get your username in UTF-8.  It won't be
changed on the fly, just because your application calls setlocale.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: pgp3I86Sh8aEC.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]