Package: postgresql-common
Version: 59
Severity: minor
Tags: patch

Hi,

I made the following improvements to some of the pg_* scripts:

- pg_createcluster creates and sets permissions on a non-standard socketdir
- pg_createcluster(8) manpage now has consistent long-option syntax
- pg_dropcluster removes a non-standard socketdir

The patches are attached and tested on my box.

Regards,
  Bastian

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.17-treasure8
Locale: [EMAIL PROTECTED], [EMAIL PROTECTED] (charmap=ISO-8859-15)

Versions of packages postgresql-common depends on:
ii  adduser                       3.97       Add and remove users and groups
ii  debconf [debconf-2.0]         1.5.3      Debian configuration management sy
ii  lsb-base                      3.1-15     Linux Standard Base 3.1 init scrip
ii  postgresql-client-common      59         manager for multiple PostgreSQL cl
ii  procps                        1:3.2.7-2  /proc file system utilities
ii  ssl-cert                      1.0.13     Simple debconf wrapper for openssl

postgresql-common recommends no packages.

-- debconf information:
  postgresql-common/obsolete-major:
  postgresql-common/untransitioned:
--- /usr/bin/pg_createcluster.orig      2006-09-05 12:14:16.000000000 +0200
+++ /usr/bin/pg_createcluster   2006-09-05 16:31:47.000000000 +0200
@@ -304,6 +304,15 @@
 setup_pg_hba if $newcluster;
 
 # configure socket directory
+if ($socketdir) {
+    if (-e $socketdir) {
+        chmod 0750, $socketdir;
+        chown $owneruid, $ownergid, $socketdir;
+    }
+    elsif (system 'install', '-d', '-m', '0750', '-o', $owneruid, '-g', 
$ownergid, $socketdir) {
+        error 'could not create socket directory';
+    }
+}
 $orig_euid = $>;
 $> = $owneruid;
 unless ($socketdir) {
@@ -453,8 +462,12 @@
 it is integrated into the B<postgresql-common> structure by moving the
 configuration file and creating the C<pgdata> link.
 
+If a custom socket directory is given and it does not exist, it is created.
+The permissions are adjusted to allow write access to the cluster owner and
+group.
+
 If the log file does not exist, it is created. In any case the permissions are
-adjusted to allow write access to the cluster owner. Please note that
+adjusted to allow write access to the cluster owner and group. Please note that
 C<postgresql.conf> can be customized to specify C<log_directory> and/or
 C<log_filename>; if at least one of these options is present, then the symbolic
 link C<log> in the cluster configuration directory is ignored.
@@ -502,7 +515,7 @@
 Explicitly set the path for the L<postmaster(1)> server log file. Defaults to
 C</var/log/postgresql/postgresql->I<version>C<->I<cluster>C<.log>.
 
-=item B<-e> I<encoding>, B<--encoding> I<encoding>
+=item B<-e> I<encoding>, B<--encoding=>I<encoding>
 
 Select the encoding of the template database. This will also be the default
 encoding of any database you create later, unless you override it there. The
@@ -510,7 +523,7 @@
 character sets supported by the PostgreSQL server are described in the
 documentation.
 
-=item B<-p> I<port>, B<--port> I<port>
+=item B<-p> I<port>, B<--port=>I<port>
 
 Select the port the new cluster listens on (for the Unix socket and the TCP
 port); this must be a number between 1024 and 65535, since PostgreSQL does not
@@ -523,7 +536,7 @@
 C<pg_ctlcluster> I<version cluster> C<start> on it). By default, the cluster is
 not started.
 
-=item B<--start-conf>  B<auto>|B<manual>|B<disabled>
+=item B<--start-conf=>B<auto>|B<manual>|B<disabled>
 
 Set the initial value in the C<start.conf> configuration file. See B<STARTUP
 CONTROL> below. By default, B<auto> is used, which means that the cluster is
--- /usr/bin/pg_dropcluster.orig        2006-09-05 12:29:12.000000000 +0200
+++ /usr/bin/pg_dropcluster     2006-09-05 16:31:47.000000000 +0200
@@ -66,6 +66,9 @@
     $c.'/environment';
 unlink $info{'logfile'} if defined ($info{'logfile'});
 unlink $info{'avac_logfile'} if defined ($info{'avac_logfile'});
+if ($info{'socketdir'} !~ /^(\/tmp|\/var\/run\/postgresql)\/?$/) {
+    rmdir $info{'socketdir'};
+}
 rmdir $c;
 rmdir "/etc/postgresql/$version";
 rmdir "/var/lib/postgresql/$version/$cluster";
@@ -90,6 +93,8 @@
 were created by L<pg_createcluster(1)>. If the configuration directory
 (C</etc/postgresql/>I<version>C</>I<cluster>) is empty after this, it is
 removed as well.
+An empty socket directory other than B</var/run/postgresql> or B</tmp> is
+also removed.
 
 Usually a cluster which still has a running server attached will not be
 deleted. To override this, the B<--stop> option forces a server shutdown

Reply via email to