Hi,
I wanted to test PostgreSQL under Wine compiled with
Fedora 18's MingW cross-compiler:
$ wine --version
wine-1.5.20
$ mingw64-configure
$ mingw64-make
$ sudo mingw64-make install
The source compiled nicely but running "wine initdb.exe" fails
because Wine reports my user as an administrator and
PostgreSQL intentionally asks for a non-admin user to run under:
[zozo@localhost ~]$ wine /usr/x86_64-w64-mingw32/sys-root/mingw/bin/initdb.exe -D
Z:/home/zozo/pgd93win
fixme:advapi:CreateRestrictedToken (0x30, 0x1, 2, 0x32f710, 0, (nil), 0, (nil), 0x32f6e8):
stub
initdb: could not create restricted token: error code 120
The files belonging to this database system will be owned by user "zozo".
This user must also own the server process.
The database cluster will be initialized with locale "Hungarian_Hungary.1250".
The default database encoding has accordingly been set to "WIN1250".
The default text search configuration will be set to "hungarian".
creating directory Z:/home/zozo/pgd93win ... ok
creating subdirectories ... ok
selecting default max_connections ... 10
selecting default shared_buffers ... 400kB
creating configuration files ... ok
creating template1 database in Z:/home/zozo/pgd93win/base/1 ... initdb: could not
re-execute with restricted token: error code 120
Execution of PostgreSQL by a user with administrative permissions is not permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromises. See the documentation for
more information on how to properly start the server.
pclose failed: No space left on device
initdb: removing data directory "Z:/home/zozo/pgd93win"
If I set
$ export PG_RESTRICT_EXEC=1
then error is
[zozo@localhost ~]$ wine /usr/x86_64-w64-mingw32/sys-root/mingw/bin/initdb.exe -D
Z:/home/zozo/pgd93win
The files belonging to this database system will be owned by user "zozo".
This user must also own the server process.
The database cluster will be initialized with locale "Hungarian_Hungary.1250".
The default database encoding has accordingly been set to "WIN1250".
The default text search configuration will be set to "hungarian".
creating directory Z:/home/zozo/pgd93win ... ok
creating subdirectories ... ok
selecting default max_connections ... 10
selecting default shared_buffers ... 400kB
creating configuration files ... ok
creating template1 database in Z:/home/zozo/pgd93win/base/1 ... Execution of PostgreSQL by
a user with administrative permissions is not
permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromises. See the documentation for
more information on how to properly start the server.
pclose failed: No space left on device
initdb: removing data directory "Z:/home/zozo/pgd93win"
OK, so Wine report an admin user. In the PostgreSQL backend code
it can be worked around to "return 0" early in pgwin32_is_admin()
in src/backend/port/win32/security.c. But then:
[zozo@localhost ~]$ wine /usr/x86_64-w64-mingw32/sys-root/mingw/bin/initdb.exe -D
Z:/home/zozo/pgd93win
The files belonging to this database system will be owned by user "zozo".
This user must also own the server process.
The database cluster will be initialized with locale "Hungarian_Hungary.1250".
The default database encoding has accordingly been set to "WIN1250".
The default text search configuration will be set to "hungarian".
creating directory Z:/home/zozo/pgd93win ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
creating configuration files ... ok
"reating template1 database in Z:/home/zozo/pgd93win/base/1 ... FATAL: syntax error at
line 2: unexpected character "
pclose failed: No space left on device
initdb: removing data directory "Z:/home/zozo/pgd93win"
So, the PostgreSQL database directory cannot be initialized under Wine,
it's needed to start the database server. Also, Wine needs a restricted
user mode before the server permits to be started up.
Best regards,
Zoltán Böszörményi