Mail Archives: cygwin/2003/04/05/12:49:23
Alan,
The one problem I see immediately with *any* automated solution of this
sort is that you can actually *have* two users, e.g., "Alan Miles" and
"Alan_Miles", in some situations (in large domains, for example).
Neither extra options to /bin/mkpasswd nor scripting will help here --
both will do the wrong thing. The only correct solution is fixing the
scripts with broken quoting.
I think your solution is fine as a temporary band-aid, but this should be
done a) manually, and b) once by everyone who has the problem. I don't
think it merits automated scripting. The more bug reports we have, the
higher the pressure on package maintainers to fix broken scripts.
In fact, now that I think of it, a very useful service to the community
would be to maintain a list of scripts with broken quoting (and,
optionally, a list of patches to those scripts) [and no, I'm not
volunteering, as I'm not affected by this problem at all]. I'd be willing
to help out with the patches, though.
Igor
On Sat, 5 Apr 2003, Alan Miles wrote:
> Igor,
>
> Granted - There are "issues" with the solution - that is why I said
> "partial" solution ( I need to resolve ALL issues)
>
> The challenge really has to do with /usr/bin/mkpasswd (which gets called by
> /etc/postinstall/passwd-grp.sh during the install process)
>
> From what I can tell, it is the item that generates the password file, which
> affects HOME and the home directory setup.
>
> Often, users don't have access to change their id's, so there Windows logon
> name may have spaces in them. We cannot chnage that.
>
> Maybe I wasn't too clear in my thoughts - until I have a scripted solution
> (the code fragment I presented), I manually "fix" the problem by:
>
> 1/ Install CYGWIN (say to c:\cygwin) - I install the icon to my desktop and
> start menu
> 2/ Using Windows Wordpad, open the /etc/passwd file (e.g.,
> c:\cygwin\etc\passwd)
> 3/ Change field 1 (the user name) - change any spaces to _ characters (i.e.,
> change "Alan Miles" to "Alan_Miles")
> 4/ Change field 6 (the home directory setting) - change any spaces to _
> characters (i.e., change "/home/Alan Miles" to "/home/Alan_Miles")
> 5/ Save /etc/passwd file (e.g., c:\cygwin\etc\passwd)
> 6/ Click on the cygwin desktop icon to "logon" to cygwin for the first time.
> /etc/profile creates the home directory the first time:
>
> (fragment from /etc/profile:
> # If the home directory doesn't exist, create it.
> if [ ! -d "$HOME" ]; then
> mkdir -p "$HOME"
> # copy skeleton files
> cp -a /etc/skel/. $HOME
> fi
> )
>
> Now the cygwin creates the home directory properly (i.e.,
> "/home/Alan_Miles"), HOME is set to "/home/Alan_Miles", and USER is set to
> "Alan_Miles"
>
> I have not had any trouble with this "manual" setup.
>
> This is the item I would like to either fix by scripting, e.g., the partial
> code fragment already presented, or better still patch /usr/bin/mkpasswd to
> convert any names it sees with spaces in them to _ characters. Then problem
> "completely" solved.
>
> I appreciate your input.
>
> BTW, Igor got your other message regarding Perl - you said:
>
> >> This wasn't meant to chide you;
>
> You weren't chiding me - my first message I thought went to Gerrit only and
> should have gone to the list (which is why I then resent it). All you did
> was point out that I inadvertently duplicated messages - no problem.
>
> Alan
> -----Original Message-----
> From: Igor Pechtchanski [mailto:pechtcha AT cs DOT nyu DOT edu]
> Sent: April 5, 2003 10:53
> To: alan DOT miles AT ieee DOT org
> Cc: kaio; cygwin AT cygwin DOT com
> Subject: RE: WinXP username with spaces --> wmaker ko
>
> Alan,
>
> The "fix" below has a few problems (one of which is unconditionally
> removing /etc/passwd). IMO, it's better to fix the scripts that have
> improper quoting, or, barring that, unset HOME in your Windows environment
> (or modify /etc/profile) and make sure your username doesn't contain a
> space. Going out of your way to accomodate scripts without proper quoting
> will only lead to the proliferation of such scripts.
> Igor
>
> On Sat, 5 Apr 2003, Alan Miles wrote:
>
> > All,
> >
> > I have the same problem (on my machine at home) - However I do have a
> > (partial) solution (I am still working on the final solution):
> >
> > This has to be done after CYGWIN installation, but BEFORE and user logon.
> > Edit the /etc/passwd file and replace the space in the first field, and edit
> > the field /home/<something with space> to /home/<something_with_out_space>
> > and save.
> >
> > I am working on a scripting solution to install as part of my installation -
> > maybe this could be incorporated as part of the "main" CYGWIN release.
> >
> > Below is a script fragment on how I am proposing to "automate" this fix.
> >
> > ThePasswordFile="/etc/passwd"
> > ModUserName="$(/usr/bin/echo "${USER}" | /usr/bin/sed -e 's/ /_/g')"
> >
> > ...
> >
> > ModHomeUserName="$(/usr/bin/basename "${HOME}" | /usr/bin/sed -e 's/
> /_/g')"
> > ModHomeUserDirName="$(/usr/bin/dirname "${HOME}")/"
> > ModHome="${ModHomeUserDirName}${ModHomeUserName}"
> >
> > /usr/bin/rm -f "${ThePasswordFile}"
> >
> > if [ ! -e "${ThePasswordFile}" -a ! -L "${ThePasswordFile}" ]
> > then
> > /usr/bin/mkpasswd -l -c | /usr/bin/gawk -F':' -v oldUser="${USER}" -v newUser="${ModUserName}" -v newUserHomeDir="${ModHome}" ' BEGIN {OFS=":" ; } $1 ~ oldUser {$1=newUser ; $6=newUserHomeDir; } {print $0 ; } ' > "${ThePasswordFile}"
> > fi
> >
> > Hope this helps.
> >
> > Alan
> > -----Original Message-----
> > From: kaio [mailto:electabuzz AT katamail DOT com]
> > Sent: April 4, 2003 10:48
> > To: cygwin AT cygwin DOT com
> > Subject: WinXP username with spaces --> wmaker ko
> >
> >
> > i have my administrator user named with a space on WInXP.
> > cygwin installation is ok, but windowmaker don't install: seems that the
> > space generates a new parameter in installation commands!
> > in fact, wmaker installation creates a new dir in /home/ with the
> > first half of username!
--
http://cs.nyu.edu/~pechtcha/
|\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com
|,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski
'---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow!
Knowledge is an unending adventure at the edge of uncertainty.
-- Leto II
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -