Commit ef3424c7 authored by Martin Pitt's avatar Martin Pitt

* pg_ctlcluster: Remove --setuid option, it does not make too much sense

  after all and only confuses users. Closes: #343063
* Remove pg_ctlcluster's -s option from all scripts.
parent 0e640e52
postgresql-common (38) unstable; urgency=low
*
* pg_ctlcluster: Remove --setuid option, it does not make too much sense
after all and only confuses users. Closes: #343063
* Remove pg_ctlcluster's -s option from all scripts.
-- Martin Pitt <mpitt@debian.org> Sun, 11 Dec 2005 11:40:03 +0100
-- Martin Pitt <mpitt@debian.org> Tue, 13 Dec 2005 21:34:03 +0100
postgresql-common (37) unstable; urgency=low
......
......@@ -26,7 +26,7 @@ do_ctl_all() {
[ "$start" = "auto" ] || continue
log_begin_msg "$3 $name"
pg_ctlcluster -s "$2" "$name" $1
pg_ctlcluster "$2" "$name" $1
log_end_msg $?
done
if [ "$fail" ]; then
......
......@@ -343,7 +343,7 @@ if ($newcluster && -e '/etc/postgresql-common/root.crt') {
# start it if requested
if ($start) {
system '/usr/bin/pg_ctlcluster', '-s', $version, $cluster, 'start';
system '/usr/bin/pg_ctlcluster', $version, $cluster, 'start';
}
__END__
......
......@@ -12,12 +12,8 @@ use POSIX qw/setsid setlocale LC_ALL :sys_wait_h/;
use PgCommon;
use Fcntl 'SEEK_SET';
# command line options
$setuid = 0;
exit 1 unless GetOptions ("setuid|s" => \$setuid);
if ($#ARGV != 2) {
print "Usage: $0 [-s] <version> <cluster> <action>\n";
print "Usage: $0 <version> <cluster> <action>\n";
exit 1;
}
......@@ -354,7 +350,7 @@ unless (getgrgid $info{'ownergid'}) {
error 'The cluster is owned by group id '.$info{'ownergid'}.' which does not exist any more'
}
if ($setuid) {
if ($> == 0) {
chdir ('/var/lib/postgresql');
change_ugid $info{'owneruid'}, $info{'ownergid'};
}
......@@ -388,7 +384,7 @@ pg_ctlcluster - start/stop/restart/reload a PostgreSQL cluster
=head1 SYNOPSIS
B<pg_ctlcluster> [B<--setuid>|B<-s>] I<cluster-version> I<cluster-name> I<action>
B<pg_ctlcluster> I<cluster-version> I<cluster-name> I<action>
where I<action> = B<start>|B<stop>|B<restart>|B<reload>|B<autovac-start>|B<autovac-stop>|B<autovac-restart>
......@@ -399,10 +395,8 @@ essentially wraps the L<pg_ctl(1)> command. It determines the cluster version
and data path and calls the right version of B<pg_ctl> with appropriate
configuration parameters and paths.
You have to start this program as the user who owns the database cluster. If
you start B<pg_ctlcluster> as root, you can also use the option
B<--setuid>/B<-s> to automatically set the user and group id to the cluster
owner.
You have to start this program as the user who owns the database cluster or as
root.
=head1 ACTIONS
......
......@@ -27,7 +27,7 @@ error 'This command needs to be executed as root' if $> != 0;
if ($info{'running'}) {
if ($stopserver) {
if ($info{'pgdata'} && -d $info{'pgdata'}) {
if (system ('pg_ctlcluster', '-s', $version, $cluster, 'stop')) {
if (system ('pg_ctlcluster', $version, $cluster, 'stop')) {
error 'could not stop server, aborting';
}
} else {
......
......@@ -159,7 +159,7 @@ sub disable_connections {
print F "local all $_[2] ident sameuser";
close F;
if (system 'pg_ctlcluster', '-s', $_[0], $_[1], 'reload') {
if (system 'pg_ctlcluster', $_[0], $_[1], 'reload') {
rename "$hba.orig", $hba;
error "could not reload cluster $_[0]/$_[1]";
}
......@@ -218,7 +218,7 @@ $ENV{'LC_CTYPE'} = $lc_ctype;
$ENV{'LC_COLLATE'} = $lc_collate;
error "Could not create target cluster" if system @argv;
@argv = ('pg_ctlcluster', '-s', $newversion, $cluster, 'start');
@argv = ('pg_ctlcluster', $newversion, $cluster, 'start');
error "Could not start target cluster" if system @argv;
sleep(4);
......@@ -339,7 +339,7 @@ if ($?) {
system 'pg_dropcluster', '--stop-server', $newversion, $cluster;
# Reload old cluster to allow connections again
if (system 'pg_ctlcluster', '-s', $version, $cluster, 'reload') {
if (system 'pg_ctlcluster', $version, $cluster, 'reload') {
error 'could not reload old cluster, please do that manually';
}
exit 1;
......@@ -362,11 +362,11 @@ if ( -e $info{'configdir'}.'/start.conf') {
adapt_conffiles;
print "Stopping target cluster...\n";
@argv = ('pg_ctlcluster', '-s', $newversion, $cluster, 'stop');
@argv = ('pg_ctlcluster', $newversion, $cluster, 'stop');
error "Could not stop target cluster" if system @argv;
print "Stopping old cluster...\n";
@argv = ('pg_ctlcluster', '-s', $version, $cluster, 'stop');
@argv = ('pg_ctlcluster', $version, $cluster, 'stop');
error "Could not stop old cluster" if system @argv;
print "Disabling automatic startup of old cluster...\n";
......@@ -387,7 +387,7 @@ print "Configuring old cluster to use a different port ($oldport)...\n";
set_cluster_port $version, $cluster, $oldport;
print "Starting target cluster on the original port...\n";
@argv = ('pg_ctlcluster', '-s', $newversion, $cluster, 'start');
@argv = ('pg_ctlcluster', $newversion, $cluster, 'start');
error "Could not start target cluster; please check configuration and log files" if system @argv;
print "Success. Please check that the upgraded cluster works. If it does,
......
......@@ -31,15 +31,15 @@ ok ((system "pg_createcluster --socketdir '$socketdir' $version main >/dev/null"
# chown cluster to an invalid user to test error
(system "chown -R 99 /var/lib/postgresql/$version/main") == 0 or die "chown failed: $!";
is ((system "pg_ctlcluster -s $version main start 2>/dev/null"), 256,
is ((system "pg_ctlcluster $version main start 2>/dev/null"), 256,
'pg_ctlcluster fails on invalid cluster owner uid');
(system "chown -R postgres:99 /var/lib/postgresql/$version/main") == 0 or die "chown failed: $!";
is ((system "pg_ctlcluster -s $version main start 2>/dev/null"), 256,
is ((system "pg_ctlcluster $version main start 2>/dev/null"), 256,
'pg_ctlcluster as root fails on invalid cluster owner gid');
is ((exec_as 'postgres', "pg_ctlcluster $version main start"), 1,
'pg_ctlcluster as postgres fails on invalid cluster owner gid');
(system "chown -R postgres:postgres /var/lib/postgresql/$version/main") == 0 or die "chown failed: $!";
is ((system "pg_ctlcluster -s $version main start"), 0,
is ((system "pg_ctlcluster $version main start"), 0,
'pg_ctlcluster succeeds on valid cluster owner uid/gid');
# check socket
......@@ -47,7 +47,7 @@ ok_dir '/var/run/postgresql', [], 'No sockets in /var/run/postgresql';
ok_dir $socketdir, ['.s.PGSQL.5432', '.s.PGSQL.5432.lock'], "Socket is in $socketdir";
# stop cluster, check sockets
ok ((system "pg_ctlcluster -s $version main stop") == 0,
ok ((system "pg_ctlcluster $version main stop") == 0,
'cluster stops after removing unix_socket_dir');
ok_dir $socketdir, [], "No sockets in $socketdir after stopping cluster";
......@@ -62,7 +62,7 @@ truncate F, 0;
print F @lines;
close F;
ok ((system "pg_ctlcluster -s $version main start") == 0,
ok ((system "pg_ctlcluster $version main start") == 0,
'cluster starts after removing unix_socket_dir');
ok_dir '/var/run/postgresql', ['.s.PGSQL.5432', '.s.PGSQL.5432.lock'],
'Socket is in default dir /var/run/postgresql';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment