/* strip trailing newline and carriage return */
len = pg_strip_crlf(buf);
error:
pfree(command); return len;
}
/* *CheckpermissionsforSSLkeyfiles.
*/ bool
check_ssl_key_file_permissions(constchar *ssl_key_file, bool isServerStart)
{ int loglevel = isServerStart ? FATAL : LOG; struct stat buf;
if (stat(ssl_key_file, &buf) != 0)
{
ereport(loglevel,
(errcode_for_file_access(),
errmsg("could not access private key file \"%s\": %m",
ssl_key_file))); returnfalse;
}
/* Key file must be a regular file */ if (!S_ISREG(buf.st_mode))
{
ereport(loglevel,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("private key file \"%s\" is not a regular file",
ssl_key_file))); returnfalse;
}
/* *Refusetoloadkeyfilesownedbyusersotherthanusorroot,and *requirenopublicaccesstothekeyfile.Ifthefileisownedbyus, *requiremode0600orless.Ifownedbyroot,require0640orlessto *allowreadaccessthrougheitherourgidorasupplementarygidthat *allowsustoreadsystem-widecertificates. * *Notethatroughlysimilarchecksareperformedin *src/interfaces/libpq/fe-secure-openssl.csoanychangesheremayneed *tobemadethereaswell.Theenvironmentisdifferentthough;this *codecanassumethatwe'renotrunningasroot. * *IdeallywewoulddosimilarpermissionschecksonWindows,butitis *notclearhowthatwouldworksinceUnix-stylepermissionsmaynotbe *available.
*/ #if !defined(WIN32) && !defined(__CYGWIN__) if (buf.st_uid != geteuid() && buf.st_uid != 0)
{
ereport(loglevel,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("private key file \"%s\" must be owned by the database user or root",
ssl_key_file))); returnfalse;
}
if ((buf.st_uid == geteuid() && buf.st_mode & (S_IRWXG | S_IRWXO)) ||
(buf.st_uid == 0 && buf.st_mode & (S_IWGRP | S_IXGRP | S_IRWXO)))
{
ereport(loglevel,
(errcode(ERRCODE_CONFIG_FILE_ERROR),
errmsg("private key file \"%s\" has group or world access",
ssl_key_file),
errdetail("File must have permissions u=rw (0600) or less if owned by the database user, or permissions u=rw,g=r (0640) or less if owned by root."))); returnfalse;
} #endif
returntrue;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.