Re: initdb failure with PostgreSQL 7.3.2 / Cygwin 1.3.22-1 / - Mailing list pgsql-cygwin

From Frank Seesink
Subject Re: initdb failure with PostgreSQL 7.3.2 / Cygwin 1.3.22-1 /
Date
Msg-id b8seg0$bra$1@main.gmane.org
Whole thread Raw
In response to Re: initdb failure with PostgreSQL 7.3.2 / Cygwin 1.3.22-1 /  (Frank Seesink <frank@mail.wvnet.edu>)
List pgsql-cygwin
More interesting news:  After looking over the various posts, and going
with my gut, I decided to do an identical install on a test box I
luckily have handy.

    Basically, the EXACT same configuration...same rev of
setup.exe/cygwin/cygipc/etc., same install steps, etc....but this time
the box was a Windows 2000 SP3 box with all updates thru today, as
opposed to Windows XP Pro.  That was the only real difference.  And it
WORKS!

    * ipc-daemon installs and runs fine (just like before)
    * but now, user 'postgres' CAN create the tables with the
      'initdb -D ...' command, and tests of 'ipctest s' are
      susccessful.

HOWEVER, and this is KEY, the FILE PERMISSIONS OF THIS INSTALL ARE
TOTALLY DIFFERENT FROM WINDOWS XP!!!

    In short, the Windows 2000 install looks like it totally ignores the
file permissions.  EVERYTHING is tagged as chmod 777, from the root on
down.  And that got me thinking.

    So I started comparing.  What struck me is that--for lack of a nicer
way of saying it--in Windows XP, chmod appears to actually have an
effect, whereas in Windows 2000 it does not.  Everything in Windows 2000
was tagged for the world to do whatever it wanted with the files.  In
Windows XP, only /home was set that way during install.  And I had to
modify /tmp (chmod 777) and /bin--a.k.a. /usr/bin-- and /usr/bin/*
(chmod a+rx) so that everyone could execute what was in those directories.

    However, looking further, what I see now is that almost everything else
under Windows XP (what I have not touched) is defaulted to chmod
770...including /var and almost everything in it!!! (except /var/cron).
  Also /usr/var, and...well, basically, most of the files.
______________________________________________________________________
$ cd /var
$ ls -al
total 0
drwxrwx---+   9 Frank    Users           0 Apr 29 11:03 .
drwxrwx---+  10 Frank    Users           0 Apr 29 17:37 ..
drwxrwx---+   4 Frank    Users           0 Apr 29 10:48 cache
drwxrwxrwt+   3 Frank    Users           0 Apr 29 11:03 cron
drwxrwx---+   4 Frank    Users           0 Apr 29 11:06 log
drwxrwx---+   2 Frank    Users           0 Apr 29 10:39 run
drwxrwx---+   5 Frank    Users           0 Apr 29 11:03 spool
drwxrwx---+   2 Frank    Users           0 Apr 29 10:39 tmp
drwxrwx---+   5 Frank    Users           0 Apr 29 10:40 www
______________________________________________________________________

Files in /etc have various permissions.  Some allow read/write by the
world, others only read, others read/execute, and some neither.

Files in /lib have permissions set as -rwxr-x---+ , whereas directories
also have group write capability.

Mind you, this is the EXACT SAME INSTALL I did on the Windows 2000 SP3
box...same version of EVERYTHING.
______________________________________________________________________
    To try to determine whether some file permission was biting me, I
started systematically 'opening' the file permissions on my WinXP Cygwin
install.  First I did the following:

    $ chmod 777 /usr/tmp /usr/var
    $ chmod 777 /var /var/*
    $ chmod -R 777 /var/cache/*
    $ chmod 777 /var/log/apache

And retried 'initdb -D' under 'postgres'.  No good.  Exact same error
(same semget numbers EXACTLY...EVERY time).
______________________________________________________________________
Next I tried opening up access to the PostgreSQL data directories:

    $ mkdir /usr/share/postgresql/data
    $ chown postgres:Users /usr/share/postgresql/data
    $ cd /usr/share/postgresql
    $ chmod 777 data
    $ chmod -R a+rx contrib
    $ chmod a+rx conversion_create.sql
    $ chmod -R a+rx java
    $ chmod a+rx *

Nope.  Still same error.  Problem appears definitely with CygIPC.  I
just can't seem to create a semaphore under 'postgres', but it's ok
under an Administrator account.
______________________________________________________________________
Next I started digging into the Cygwin docs, eventually reading and
re-reading the following:

    http://cygwin.com/cygwin-ug-net/ntsec.html#NTSEC-FILES

I did find out why the heck 'postgres' was listing with a 'None' group
setting, vs. my administrator account showing with a 'Users' setting.
So that I fixed by modifying the /etc/passwd file.  But that had no
bearing on anything in the end. *sigh*

It definitely seems that with Cygwin 1.3.20, things started changing
file permissions-wise.  I suspect this is when 'ntsec' became a default
setting (something that should have been accompanied with a BIG WARNING
to users in my book, but whatever).  But I have tried (several days ago)
to disable all this by setting

    CYGWIN=nontsec

but to no avail.  Haven't tried it here today or yesterday, but see no
reason why it would magically make a difference now.  I'll try that
tomorrow if I can.  But I expect nothing.
______________________________________________________________________
Anyway, the probably clearly IS that I am unable to create semaphores
(using things like 'ipctest s') running as 'postgres', but I can't for
the life of me figure out why.  What makes the EXACT same version of
Cygwin/CygIPC/PostgreSQL WORK under Windows 2000 but NOT under Windows
XP???  I don't recall any major changes between the OS versions that
would impact things here...except possibly the change in the NTFS file
format (again, file permissions-related).

CygIPC simply creates semaphores and stores them in the files in /tmp,
and I have that folder and those files set WIDE open.  (I even tested
doing an 'echo HAHA >> /tmp/MultiShm' and it worked from 'postgres', so
I know directly writing into the file is not a problem.)

So why can't I create a 'semaphor'?  I even tried running CygIPC under
the context of user 'postgres', thereby eliminating any potential weird
Win2K/WinXP 'features' that might have crept in.  If CygIPC runs as
'postgres', it makes no difference.  Still no go.

But if I am running as the user with Administrative rights that I
installed Cygwin and CygIPC with, it's fine.  And it's not like it has
some requirement that I am THE Administrator (i.e., RID 500 in the NT
world), as I am using a regular account (RID above 1000) that happens to
be a member of the Administrators group, and that works.

But I just can't figure out what is different.  I have even tried adding
user 'postgres' to the Administrators group and THEN tried creating a
semaphore, but still no go.

Running as 'postgres' as a member of the Administrators group, I then did

$ net stop ipc-daemon
$ ipc-daemon --remove-as-service
$ rm /tmp/Multi*
$ ipc-daemon --install-as-service
$ net start ipc-daemon
$ ipctest s

and it STILL fails!!  But as the admin user, I CAN create semaphores!!!
  GAAAH!

    I'm quickly running out of ideas.  This is a level of frustration I
have NEVER felt when dealing with PostgreSQL under Cygwin.  My earlier
failures (more than a year ago) could easily be attributed to
inexperience.  But I have done this literally dozens of times now, and I
know most of the minefields.  Only now am I experiencing this hell.

    My gut still tells me it's some kind of permissions issue, but who
knows.  Maybe CygIPC is hooking into some feature of the Windows API
that is somehow just...so...slightly...different in XP.  Beats me.  I
just find it interesting and a bit unnerving when I read things like

http://cygwin.com/ml/cygwin-announce/2003-03/msg00025.html

where Christopher Faylor of Red Hat, Inc. writes

...
Changes since 1.3.21-1 (worst cygwin release ever):
...                     ^^^^^^^^^^^^^^^^^^^^^^^^^

Ouch.
Uh oh.

Here's to hoping for a solid, native port of PostgreSQL to Windows, or
else a cleanup of whatever is ailing Cygwin/CygIPC.  Ideally, if it's
true the developer of CygIPC has gone AWOL, here's to hoping someone
gets that replacement Cygwin IPC daemon done sometime REAL soon.

If anyone has any other suggestions, please throw 'm at me.


pgsql-cygwin by date:

Previous
From: Frank Seesink
Date:
Subject: Re: initdb failure with PostgreSQL 7.3.2 / Cygwin 1.3.22-1 /
Next
From: Jason Tishler
Date:
Subject: Re: initdb failure with PostgreSQL 7.3.2 / Cygwin 1.3.22-1 /