X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=bin%2Fwanna-build;h=070009fecb760a32822f775de4c1b34d76be5b5a;hb=eb1c0170236ade56c2779b406bafe756f05f09a2;hp=5b6fd6784b3ed1a748b5f189dad5a8eebe918a3e;hpb=7b763e902e29b81ecf3ed75560ec428f8814325b;p=wannabuild.git 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 {