mirror of
https://github.com/postgres/postgres.git
synced 2025-11-01 21:31:19 +03:00
Pre-beta mechanical code beautification.
Run pgindent, pgperltidy, and reformat-dat-files. This set of diffs is a bit larger than typical. We've updated to pg_bsd_indent 2.1.2, which properly indents variable declarations that have multi-line initialization expressions (the continuation lines are now indented one tab stop). We've also updated to perltidy version 20230309 and changed some of its settings, which reduces its desire to add whitespace to lines to make assignments etc. line up. Going forward, that should make for fewer random-seeming changes to existing code. Discussion: https://postgr.es/m/20230428092545.qfb3y5wcu4cm75ur@alvherre.pgsql
This commit is contained in:
@@ -66,36 +66,36 @@ INIT
|
||||
if ($^O eq 'darwin' && -d '/opt/homebrew/opt/openldap')
|
||||
{
|
||||
# typical paths for Homebrew on ARM
|
||||
$slapd = '/opt/homebrew/opt/openldap/libexec/slapd';
|
||||
$slapd = '/opt/homebrew/opt/openldap/libexec/slapd';
|
||||
$ldap_schema_dir = '/opt/homebrew/etc/openldap/schema';
|
||||
}
|
||||
elsif ($^O eq 'darwin' && -d '/usr/local/opt/openldap')
|
||||
{
|
||||
# typical paths for Homebrew on Intel
|
||||
$slapd = '/usr/local/opt/openldap/libexec/slapd';
|
||||
$slapd = '/usr/local/opt/openldap/libexec/slapd';
|
||||
$ldap_schema_dir = '/usr/local/etc/openldap/schema';
|
||||
}
|
||||
elsif ($^O eq 'darwin' && -d '/opt/local/etc/openldap')
|
||||
{
|
||||
# typical paths for MacPorts
|
||||
$slapd = '/opt/local/libexec/slapd';
|
||||
$slapd = '/opt/local/libexec/slapd';
|
||||
$ldap_schema_dir = '/opt/local/etc/openldap/schema';
|
||||
}
|
||||
elsif ($^O eq 'linux')
|
||||
{
|
||||
$slapd = '/usr/sbin/slapd';
|
||||
$slapd = '/usr/sbin/slapd';
|
||||
$ldap_schema_dir = '/etc/ldap/schema' if -d '/etc/ldap/schema';
|
||||
$ldap_schema_dir = '/etc/openldap/schema'
|
||||
if -d '/etc/openldap/schema';
|
||||
}
|
||||
elsif ($^O eq 'freebsd')
|
||||
{
|
||||
$slapd = '/usr/local/libexec/slapd';
|
||||
$slapd = '/usr/local/libexec/slapd';
|
||||
$ldap_schema_dir = '/usr/local/etc/openldap/schema';
|
||||
}
|
||||
elsif ($^O eq 'openbsd')
|
||||
{
|
||||
$slapd = '/usr/local/libexec/slapd';
|
||||
$slapd = '/usr/local/libexec/slapd';
|
||||
$ldap_schema_dir = '/usr/local/share/examples/openldap/schema';
|
||||
}
|
||||
else
|
||||
@@ -137,25 +137,25 @@ sub new
|
||||
{
|
||||
die "no suitable binaries found" unless $setup;
|
||||
|
||||
my $class = shift;
|
||||
my $rootpw = shift;
|
||||
my $authtype = shift; # 'users' or 'anonymous'
|
||||
my $class = shift;
|
||||
my $rootpw = shift;
|
||||
my $authtype = shift; # 'users' or 'anonymous'
|
||||
my $testname = basename((caller)[1], '.pl');
|
||||
my $self = {};
|
||||
my $self = {};
|
||||
|
||||
my $test_temp = PostgreSQL::Test::Utils::tempdir("ldap-$testname");
|
||||
|
||||
my $ldap_datadir = "$test_temp/openldap-data";
|
||||
my $slapd_certs = "$test_temp/slapd-certs";
|
||||
my $ldap_datadir = "$test_temp/openldap-data";
|
||||
my $slapd_certs = "$test_temp/slapd-certs";
|
||||
my $slapd_pidfile = "$test_temp/slapd.pid";
|
||||
my $slapd_conf = "$test_temp/slapd.conf";
|
||||
my $slapd_conf = "$test_temp/slapd.conf";
|
||||
my $slapd_logfile =
|
||||
"${PostgreSQL::Test::Utils::log_path}/slapd-$testname.log";
|
||||
my $ldap_server = 'localhost';
|
||||
my $ldap_port = PostgreSQL::Test::Cluster::get_free_port();
|
||||
my $ldaps_port = PostgreSQL::Test::Cluster::get_free_port();
|
||||
my $ldap_url = "ldap://$ldap_server:$ldap_port";
|
||||
my $ldaps_url = "ldaps://$ldap_server:$ldaps_port";
|
||||
my $ldap_port = PostgreSQL::Test::Cluster::get_free_port();
|
||||
my $ldaps_port = PostgreSQL::Test::Cluster::get_free_port();
|
||||
my $ldap_url = "ldap://$ldap_server:$ldap_port";
|
||||
my $ldaps_url = "ldaps://$ldap_server:$ldaps_port";
|
||||
my $ldap_basedn = 'dc=example,dc=net';
|
||||
my $ldap_rootdn = 'cn=Manager,dc=example,dc=net';
|
||||
my $ldap_rootpw = $rootpw;
|
||||
@@ -188,7 +188,7 @@ EOC
|
||||
append_to_file($slapd_conf, $conf);
|
||||
|
||||
mkdir $ldap_datadir or die "making $ldap_datadir: $!";
|
||||
mkdir $slapd_certs or die "making $slapd_certs: $!";
|
||||
mkdir $slapd_certs or die "making $slapd_certs: $!";
|
||||
|
||||
my $certdir = dirname(__FILE__) . "/../ssl/ssl";
|
||||
|
||||
@@ -205,7 +205,8 @@ EOC
|
||||
chmod 0600, $ldap_pwfile or die "chmod on $ldap_pwfile";
|
||||
|
||||
# -s0 prevents log messages ending up in syslog
|
||||
system_or_bail $slapd, '-f', $slapd_conf, '-s0', '-h', "$ldap_url $ldaps_url";
|
||||
system_or_bail $slapd, '-f', $slapd_conf, '-s0', '-h',
|
||||
"$ldap_url $ldaps_url";
|
||||
|
||||
# wait until slapd accepts requests
|
||||
my $retries = 0;
|
||||
@@ -215,25 +216,25 @@ EOC
|
||||
if (
|
||||
system_log(
|
||||
"ldapsearch", "-sbase",
|
||||
"-H", $ldap_url,
|
||||
"-b", $ldap_basedn,
|
||||
"-D", $ldap_rootdn,
|
||||
"-y", $ldap_pwfile,
|
||||
"-n", "'objectclass=*'") == 0);
|
||||
"-H", $ldap_url,
|
||||
"-b", $ldap_basedn,
|
||||
"-D", $ldap_rootdn,
|
||||
"-y", $ldap_pwfile,
|
||||
"-n", "'objectclass=*'") == 0);
|
||||
die "cannot connect to slapd" if ++$retries >= 300;
|
||||
note "waiting for slapd to accept requests...";
|
||||
Time::HiRes::usleep(1000000);
|
||||
}
|
||||
|
||||
$self->{pidfile} = $slapd_pidfile;
|
||||
$self->{pwfile} = $ldap_pwfile;
|
||||
$self->{url} = $ldap_url;
|
||||
$self->{s_url} = $ldaps_url;
|
||||
$self->{server} = $ldap_server;
|
||||
$self->{port} = $ldap_port;
|
||||
$self->{s_port} = $ldaps_port;
|
||||
$self->{basedn} = $ldap_basedn;
|
||||
$self->{rootdn} = $ldap_rootdn;
|
||||
$self->{pwfile} = $ldap_pwfile;
|
||||
$self->{url} = $ldap_url;
|
||||
$self->{s_url} = $ldaps_url;
|
||||
$self->{server} = $ldap_server;
|
||||
$self->{port} = $ldap_port;
|
||||
$self->{s_port} = $ldaps_port;
|
||||
$self->{basedn} = $ldap_basedn;
|
||||
$self->{rootdn} = $ldap_rootdn;
|
||||
|
||||
bless $self, $class;
|
||||
push @servers, $self;
|
||||
@@ -244,8 +245,8 @@ EOC
|
||||
sub _ldapenv
|
||||
{
|
||||
my $self = shift;
|
||||
my %env = %ENV;
|
||||
$env{'LDAPURI'} = $self->{url};
|
||||
my %env = %ENV;
|
||||
$env{'LDAPURI'} = $self->{url};
|
||||
$env{'LDAPBINDDN'} = $self->{rootdn};
|
||||
return %env;
|
||||
}
|
||||
@@ -287,8 +288,8 @@ Set the user's password in the LDAP server
|
||||
|
||||
sub ldapsetpw
|
||||
{
|
||||
my $self = shift;
|
||||
my $user = shift;
|
||||
my $self = shift;
|
||||
my $user = shift;
|
||||
my $password = shift;
|
||||
|
||||
local %ENV = $self->_ldapenv;
|
||||
|
||||
@@ -37,8 +37,8 @@ $ldap->ldapadd_file('authdata.ldif');
|
||||
$ldap->ldapsetpw('uid=test1,dc=example,dc=net', 'secret1');
|
||||
$ldap->ldapsetpw('uid=test2,dc=example,dc=net', 'secret2');
|
||||
|
||||
my ($ldap_server, $ldap_port, $ldaps_port, $ldap_url,
|
||||
$ldaps_url, $ldap_basedn, $ldap_rootdn
|
||||
my ($ldap_server, $ldap_port, $ldaps_port, $ldap_url,
|
||||
$ldaps_url, $ldap_basedn, $ldap_rootdn
|
||||
) = $ldap->prop(qw(server port s_port url s_url basedn rootdn));
|
||||
|
||||
# don't bother to check the server's cert (though perhaps we should)
|
||||
|
||||
Reference in New Issue
Block a user