From eb1c0170236ade56c2779b406bafe756f05f09a2 Mon Sep 17 00:00:00 2001 From: Kurt Roeckx Date: Fri, 4 Sep 2009 18:56:12 +0000 Subject: [PATCH] Add support for the public view of the data. Currently does this for user nobody, to be able to use from the website. We probably want to make this decission some other way. --- bin/wanna-build | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/bin/wanna-build b/bin/wanna-build index 5b6fd67..070009f 100755 --- a/bin/wanna-build +++ b/bin/wanna-build @@ -301,8 +301,18 @@ END { } } -$dbh = DBI->connect("DBI:Pg:database=wanna-build") || - die "FATAL: Cannot open database: $DBI::errstr\n"; +my $schema_suffix = ''; +# TODO: Base this on something else, like an option that is passed. +if ($real_user eq 'nobody') { + $dbh = DBI->connect("DBI:Pg:service=wanna-build") || + die "FATAL: Cannot open database: $DBI::errstr\n"; + $schema_suffix = '_public'; +} +else +{ + $dbh = DBI->connect("DBI:Pg:service=wanna-build-privileged") || + die "FATAL: Cannot open database: $DBI::errstr\n"; +} # TODO: This shouldn't be needed, file a bug. $dbh->{pg_server_prepare} = 0; @@ -2374,11 +2384,11 @@ sub pkg_version_eq { } sub table_name { - return '"' . $arch . '".packages'; + return '"' . $arch . $schema_suffix . '".packages'; } sub user_table_name { - return '"' . $arch . '".users'; + return '"' . $arch . $schema_suffix . '".users'; } sub get_source_info { -- 2.39.2