Index: initdb.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/initdb/initdb.c,v
retrieving revision 1.41
diff -u -r1.41 initdb.c
--- initdb.c	1 Jul 2004 00:51:36 -0000	1.41
+++ initdb.c	8 Jul 2004 13:13:06 -0000
@@ -1137,7 +1137,7 @@
 	PG_CMD_OPEN;
 
 	if (fprintf(pg,
-		  "ALTER USER \"%s\" WITH PASSWORD '%s';\n", username, pwd1) < 0)
+		  "ALTER USER \"%s\" WITH PASSWORD '%s';\n", effective_user, pwd1) < 0)
 	{
 		/* write failure */
 		exit_nicely();
@@ -1433,7 +1433,7 @@
 	PG_CMD_OPEN;
 
 	priv_lines = replace_token(privileges_setup,
-							   "$POSTGRES_SUPERUSERNAME", username);
+							   "$POSTGRES_SUPERUSERNAME", effective_user);
 	for (line = priv_lines; *line != NULL; line++)
 		PG_CMD_PUTLINE;
 
@@ -2003,8 +2003,8 @@
 	}
 
 	effective_user = get_id();
-	if (!strlen(username))
-		username = effective_user;
+	if (strlen(username))
+		effective_user = username;
 
 	if (strlen(encoding))
 		encodingid = get_encoding_id(encoding);
@@ -2033,7 +2033,7 @@
 				PG_VERSION,
 				pg_data, share_path, bin_path,
 				encoding, encodingid,
-				username, bki_file,
+				effective_user, bki_file,
 				desc_file, conf_file,
 				hba_file, ident_file);
 		if (show_setting)