@@ -185,6 +185,7 @@ static const char *default_timezone = NULL;
185
185
"# allows any local user to connect as any PostgreSQL user, including\n" \
186
186
"# the database superuser. If you do not trust all your local users,\n" \
187
187
"# use another authentication method.\n"
188
+ static bool authwarning = false;
188
189
189
190
/*
190
191
* Centralized knowledge of switches to pass to backend
@@ -2390,6 +2391,16 @@ usage(const char *progname)
2390
2391
printf (
_ (
"\nReport bugs to <[email protected] >.\n" ));
2391
2392
}
2392
2393
2394
+ static void
2395
+ check_authmethod_unspecified (const char * * authmethod )
2396
+ {
2397
+ if (* authmethod == NULL )
2398
+ {
2399
+ authwarning = true;
2400
+ * authmethod = "trust" ;
2401
+ }
2402
+ }
2403
+
2393
2404
static void
2394
2405
check_authmethod_valid (const char * authmethod , const char * const * valid_methods , const char * conntype )
2395
2406
{
@@ -3237,16 +3248,8 @@ main(int argc, char *argv[])
3237
3248
exit (1 );
3238
3249
}
3239
3250
3240
- if (authmethodlocal == NULL )
3241
- {
3242
- #ifdef HAVE_AUTH_PEER
3243
- authmethodlocal = "peer" ;
3244
- #else
3245
- authmethodlocal = "md5" ;
3246
- #endif
3247
- }
3248
- if (authmethodhost == NULL )
3249
- authmethodhost = "md5" ;
3251
+ check_authmethod_unspecified (& authmethodlocal );
3252
+ check_authmethod_unspecified (& authmethodhost );
3250
3253
3251
3254
check_authmethod_valid (authmethodlocal , auth_methods_local , "local" );
3252
3255
check_authmethod_valid (authmethodhost , auth_methods_host , "host" );
@@ -3329,6 +3332,14 @@ main(int argc, char *argv[])
3329
3332
else
3330
3333
printf (_ ("\nSync to disk skipped.\nThe data directory might become corrupt if the operating system crashes.\n" ));
3331
3334
3335
+ if (authwarning )
3336
+ {
3337
+ printf ("\n" );
3338
+ pg_log_warning ("enabling \"trust\" authentication for local connections" );
3339
+ fprintf (stderr , _ ("You can change this by editing pg_hba.conf or using the option -A, or\n"
3340
+ "--auth-local and --auth-host, the next time you run initdb.\n" ));
3341
+ }
3342
+
3332
3343
/*
3333
3344
* Build up a shell command to tell the user how to start the server
3334
3345
*/
0 commit comments