Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit84a059a

Browse files
committed
Don't crash initdb when we fail to get the current username.
Give an error message and exit instead, like we do elsewhere...Per report from Wez Furlong and Robert Treat.
1 parentdf13324 commit84a059a

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

‎src/bin/initdb/initdb.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
* Portions taken from FreeBSD.
4444
*
45-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.168 2009/02/25 13:03:06 petere Exp $
45+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.169 2009/03/31 18:58:16 mha Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -670,6 +670,13 @@ get_id(void)
670670
progname);
671671
exit(1);
672672
}
673+
if (!pw)
674+
{
675+
fprintf(stderr,
676+
_("%s: could not obtain information about current user: %s\n"),
677+
progname,strerror(errno));
678+
exit(1);
679+
}
673680
#else/* the windows code */
674681

675682
structpasswd_win32
@@ -681,7 +688,12 @@ get_id(void)
681688
DWORDpwname_size=sizeof(pass_win32.pw_name)-1;
682689

683690
pw->pw_uid=1;
684-
GetUserName(pw->pw_name,&pwname_size);
691+
if (!GetUserName(pw->pw_name,&pwname_size))
692+
{
693+
fprintf(stderr,_("%s: could not get current user name: %s\n"),
694+
progname,strerror(errno));
695+
exit(1);
696+
}
685697
#endif
686698

687699
returnxstrdup(pw->pw_name);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp