This is the mail archive of the
cygwin-developers
mailing list for the Cygwin project.
Re: setup/mkpasswd and HOMEDRIVE/HOMEPATH
On May 7 00:44, Larry Hall (Cygwin Developers) wrote:
> Dave Korn wrote:
>> Larry Hall (Cygwin Developers) wrote:
>>> I was basically thinking of the pathelogical case where the user
>>> doesn't have permissions to create or access the home directory
>>> due to some strange phenomena (somebody messed up permissions,
>>> '/home/<user>' points to a shared drive that's inaccessible, etc.).
>>
>> I was thinking of that too, but I'd hardly call it 'pathological'. It's
>> standard practice on Linux for /home to be owned by root and only have r-x
>> perms for everyone else, as root is the only one who should be adding new
>> users and hence the only person who should be creating dirs in /home.
>>
>> In cygwin we're effectively letting non-admin users control most of the
>> 'adduser' behaviour themselves. Someone might easily think that chmod'ing
>> /home 755 was a good idea.
>
> Right.
>
> And as to the terminology, let's call them "corner cases" instead so no one
> gets hung up on semantics. :-)
But how's that supposed to work? Right now (and also in the former
code) Cygwin doesn't (and didn't) check for any directory permissions.
Evaluating the home directory is just a question of where to get the
information from
$HOME
/etc/passwd
($HOMEDIRVE/$HOMEPATH)
default /home/$USER or /.
As for /home permissions, the old setup together with the old Cygwin
(<= 1.7.0-46) created /home with 777 permissions. Actually setup didn't
create /home at all, /etc/profile did, and umask was set to 0000 in Cygwin
by default. And /etc/profile creates /home before setting umask. So
777 was the typical outcome so far, unfortunately not only for /home,
but also for the /home/$USER.
The new combination of setup-1.7 and Cygwin 1.7.0-47 will do it
different. Setup now actually creates /home right at the start with
1777 permissions. And Cygwin has a default umask of 022. So the
user's home dir will be created with 755 permissions which is a much
more sane default than before.
Back to the / fallback.
Right now, what happens is this:
If /home/$USER exists, but cd to it fails due to missing permissions,
the shell will end up in the former current directory. This is typically
/bin or /usr/bin.
If /home/$USER does not exist, the /etc/profile mechanism kicks in.
If /home does not have sufficient permissions for the user to create
his/her own home dir, something like this will happen:
mkdir: cannot create directory `/home/corinna': Permission denied
/home/corinna could not be created.
Setting HOME to /cygdrive/c/Users/corinna/AppData/Local/Temp.
When not using bash, but tcsh, the following happens:
mkdir: cannot create directory `/home/corinna': Permission denied
cd: Can't change to home directory.
[/usr/bin]$
I don't see anything wrong with this behaviour. Maybe /etc/profile
should choose / rather than $TEMP as fallback HOME dir? And maybe tcsh
should align its behaviour and set HOME to / as well if mkdir fails to
work?
What other pathological case am I missing?
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Project Co-Leader cygwin AT cygwin DOT com
Red Hat