diff options
author | Magnus Hagander <magnus@hagander.net> | 2008-02-29 15:31:33 +0000 |
---|---|---|
committer | Magnus Hagander <magnus@hagander.net> | 2008-02-29 15:31:33 +0000 |
commit | 2d2b0222677fb00b09ee724127a6643c3d451af3 (patch) | |
tree | 1d55bd122768bbea3b31136d173ff53f8b6f0da6 /src/bin/initdb/initdb.c | |
parent | 4db0d87c9d6c819346f1e4012a44437bf9191a29 (diff) | |
download | postgresql-2d2b0222677fb00b09ee724127a6643c3d451af3.tar.gz postgresql-2d2b0222677fb00b09ee724127a6643c3d451af3.zip |
Fix handling of restricted processes for Windows Vista (mainly),
by explicitly adding back the user to the DACL of the new process.
This fixes the failure case when executing as the Administrator
user, which had no permissions left at all after we dropped the
Administrators group.
Dave Page with some modifications from me
Diffstat (limited to 'src/bin/initdb/initdb.c')
-rw-r--r-- | src/bin/initdb/initdb.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index f3eb38b2dc4..41db8a8b029 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -42,7 +42,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * Portions taken from FreeBSD. * - * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.153 2008/02/20 22:46:24 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.154 2008/02/29 15:31:33 mha Exp $ * *------------------------------------------------------------------------- */ @@ -2329,7 +2329,26 @@ CreateRestrictedProcess(char *cmd, PROCESS_INFORMATION * processInfo) return 0; } - return CreateProcessAsUser(restrictedToken, NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &si, processInfo); + if (!CreateProcessAsUser(restrictedToken, + NULL, + cmd, + NULL, + NULL, + TRUE, + CREATE_SUSPENDED, + NULL, + NULL, + &si, + processInfo)) + + { + fprintf(stderr, "CreateProcessAsUser failed: %lu\n", GetLastError()); + return 0; + } + + AddUserToDacl(processInfo->hProcess); + + return ResumeThread(processInfo->hThread); } #endif |