|
37 | 37 | * |
38 | 38 | * |
39 | 39 | * IDENTIFICATION |
40 | | - * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.284 2002/08/17 15:12:06 momjian Exp $ |
| 40 | + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.285 2002/08/18 03:03:25 momjian Exp $ |
41 | 41 | * |
42 | 42 | * NOTES |
43 | 43 | * |
|
116 | 116 | sigset_tUnBlockSig, |
117 | 117 | BlockSig, |
118 | 118 | AuthBlockSig; |
119 | | - |
120 | 119 | #else |
121 | 120 | intUnBlockSig, |
122 | 121 | BlockSig, |
@@ -191,6 +190,8 @@ intCheckPointTimeout = 300; |
191 | 190 | boolHostnameLookup;/* for ps display */ |
192 | 191 | boolShowPortNumber; |
193 | 192 | boolLog_connections= false; |
| 193 | +boolDb_user_namespace= false; |
| 194 | + |
194 | 195 |
|
195 | 196 | /* Startup/shutdown state */ |
196 | 197 | staticpid_tStartupPID=0, |
@@ -1155,6 +1156,26 @@ ProcessStartupPacket(Port *port, bool SSLdone) |
1155 | 1156 | if (port->user[0]=='\0') |
1156 | 1157 | elog(FATAL,"no PostgreSQL user name specified in startup packet"); |
1157 | 1158 |
|
| 1159 | +if (Db_user_namespace) |
| 1160 | + { |
| 1161 | +/* |
| 1162 | + *If user@, it is a global user, remove '@'. |
| 1163 | + *We only want to do this if there is an '@' at the end and no |
| 1164 | + *earlier in the user string or they may fake as a local user |
| 1165 | + *of another database attaching to this database. |
| 1166 | + */ |
| 1167 | +if (strchr(port->user,'@')==port->user+strlen(port->user)-1) |
| 1168 | +*strchr(port->user,'@')='\0'; |
| 1169 | +else |
| 1170 | +{ |
| 1171 | +/* Append '@' and dbname */ |
| 1172 | +charhold_user[SM_DATABASE_USER+1]; |
| 1173 | +snprintf(hold_user,SM_DATABASE_USER+1,"%s@%s",port->user, |
| 1174 | +port->database); |
| 1175 | +strcpy(port->user,hold_user); |
| 1176 | +} |
| 1177 | +} |
| 1178 | + |
1158 | 1179 | /* |
1159 | 1180 | * If we're going to reject the connection due to database state, say |
1160 | 1181 | * so now instead of wasting cycles on an authentication exchange. |
@@ -2581,11 +2602,10 @@ CreateOptsFile(int argc, char *argv[]) |
2581 | 2602 | if (FindExec(fullprogname,argv[0],"postmaster")<0) |
2582 | 2603 | return false; |
2583 | 2604 |
|
2584 | | -filename=palloc(strlen(DataDir)+20); |
| 2605 | +filename=palloc(strlen(DataDir)+17); |
2585 | 2606 | sprintf(filename,"%s/postmaster.opts",DataDir); |
2586 | 2607 |
|
2587 | | -fp=fopen(filename,"w"); |
2588 | | -if (fp==NULL) |
| 2608 | +if ((fp=fopen(filename,"w"))==NULL) |
2589 | 2609 | { |
2590 | 2610 | postmaster_error("cannot create file %s: %s", |
2591 | 2611 | filename,strerror(errno)); |
|