]>
Commit | Line | Data |
---|---|---|
4aa5c0b3 JB |
1 | --- postgresql-8.3.0/src/bin/pg_ctl/pg_ctl.c.orig 2008-01-01 20:45:55.000000000 +0100 |
2 | +++ postgresql-8.3.0/src/bin/pg_ctl/pg_ctl.c 2008-02-19 21:30:21.369174813 +0100 | |
3 | @@ -414,11 +414,11 @@ | |
4 | PGconn *conn; | |
0796510c | 5 | bool success = false; |
6 | int i; | |
4aa5c0b3 JB |
7 | - char portstr[32]; |
8 | + char portstr[32], sockstr[MAXPGPATH]; | |
0796510c | 9 | char *p; |
4aa5c0b3 JB |
10 | - char connstr[128]; /* Should be way more than enough! */ |
11 | + char connstr[128+MAXPGPATH]; /* Should be way more than enough! */ | |
0796510c | 12 | |
4aa5c0b3 JB |
13 | - *portstr = '\0'; |
14 | + *portstr = *sockstr = '\0'; | |
0796510c | 15 | |
16 | /* post_opts */ | |
17 | for (p = post_opts; *p;) | |
4aa5c0b3 JB |
18 | @@ -436,6 +436,15 @@ |
19 | strlcpy(portstr, p, Min(strcspn(p, "\"'" WHITESPACE) + 1, | |
20 | sizeof(portstr))); | |
21 | /* keep looking, maybe there is another -p */ | |
22 | + } else if (strncmp(p, "-k", strlen("-k")) == 0) | |
23 | + { | |
24 | + p += strlen("-k"); | |
25 | + /* advance past whitespace/quoting */ | |
26 | + while (isspace((unsigned char) *p) || *p == '\'' || *p == '"') | |
27 | + p++; | |
28 | + strlcpy(sockstr, p, Min(strcspn(p, "\"'" WHITESPACE) + 1, | |
29 | + sizeof(sockstr))); | |
30 | + /* keep looking, maybe there is another -k */ | |
31 | } | |
32 | /* Advance to next whitespace */ | |
33 | while (*p && !isspace((unsigned char) *p)) | |
34 | @@ -443,7 +452,7 @@ | |
0796510c | 35 | } |
36 | ||
37 | /* config file */ | |
38 | - if (!*portstr) | |
39 | + if (!*portstr || !*sockstr) | |
40 | { | |
41 | char **optlines; | |
42 | ||
4aa5c0b3 | 43 | @@ -456,19 +465,30 @@ |
0796510c | 44 | |
45 | while (isspace((unsigned char) *p)) | |
46 | p++; | |
47 | - if (strncmp(p, "port", strlen("port")) != 0) | |
48 | - continue; | |
49 | - p += strlen("port"); | |
50 | - while (isspace((unsigned char) *p)) | |
4aa5c0b3 | 51 | + if (!strncmp(p, "port", strlen("port"))) { |
0796510c | 52 | + p += strlen("port"); |
53 | + while (isspace((unsigned char) *p)) | |
54 | + p++; | |
55 | + if (*p != '=') | |
56 | + continue; | |
57 | p++; | |
4aa5c0b3 JB |
58 | - if (*p != '=') |
59 | - continue; | |
60 | - p++; | |
61 | - while (isspace((unsigned char) *p)) | |
0796510c | 62 | + while (isspace((unsigned char) *p)) |
63 | + p++; | |
4aa5c0b3 JB |
64 | + strlcpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1, |
65 | + sizeof(portstr))); | |
66 | + /* keep looking, maybe there is another */ | |
67 | + } else if(!strncmp(p, "unix_socket_directory", strlen("unix_socket_directory"))) { | |
0796510c | 68 | + p += strlen("unix_socket_directory"); |
69 | + while (isspace((unsigned char) *p)) | |
70 | + p++; | |
71 | + if (*p != '=') | |
72 | + continue; | |
4aa5c0b3 JB |
73 | p++; |
74 | - strlcpy(portstr, p, Min(strcspn(p, "#" WHITESPACE) + 1, | |
75 | - sizeof(portstr))); | |
76 | - /* keep looking, maybe there is another */ | |
0796510c | 77 | + while (isspace((unsigned char) *p) || *p == '\'' || *p == '"') |
78 | + p++; | |
4aa5c0b3 JB |
79 | + strlcpy(sockstr, p, Min(strcspn(p, "\"'#" WHITESPACE) + 1, |
80 | + sizeof(sockstr))); | |
0796510c | 81 | + } |
0796510c | 82 | } |
83 | } | |
4aa5c0b3 JB |
84 | } |
85 | @@ -486,7 +506,8 @@ | |
86 | * probably timeout first | |
87 | */ | |
88 | snprintf(connstr, sizeof(connstr), | |
89 | - "dbname=postgres port=%s connect_timeout=5", portstr); | |
90 | + "dbname=postgres port=%s connect_timeout=5%s%s", portstr, | |
91 | + (*sockstr ? " host=" : ""), sockstr); | |
0796510c | 92 | |
93 | for (i = 0; i < wait_seconds; i++) | |
94 | { |