git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: df13324)
Don't crash initdb when we fail to get the current username.
2009年3月31日 18:58:16 +0000 (18:58 +0000)
2009年3月31日 18:58:16 +0000 (18:58 +0000)
Give an error message and exit instead, like we do elsewhere...

Per report from Wez Furlong and Robert Treat.


diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 4885b21e69a73ac92433c5b7aaf94cb651ae57b0..546460c38ae767d8cf3c8c18a63870aa7be1a957 100644 (file)
--- 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.168 2009年02月25日 13:03:06 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.169 2009年03月31日 18:58:16 mha Exp $
*
*-------------------------------------------------------------------------
*/
@@ -670,6 +670,13 @@ get_id(void)
progname);
exit(1);
}
+ if (!pw)
+ {
+ fprintf(stderr,
+ _("%s: could not obtain information about current user: %s\n"),
+ progname, strerror(errno));
+ exit(1);
+ }
#else /* the windows code */
struct passwd_win32
@@ -681,7 +688,12 @@ get_id(void)
DWORD pwname_size = sizeof(pass_win32.pw_name) - 1;
pw->pw_uid = 1;
- GetUserName(pw->pw_name, &pwname_size);
+ if (!GetUserName(pw->pw_name, &pwname_size))
+ {
+ fprintf(stderr, _("%s: could not get current user name: %s\n"),
+ progname, strerror(errno));
+ exit(1);
+ }
#endif
return xstrdup(pw->pw_name);
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /