chiark / gitweb /
In access_quirk, filter by defined at the end. (nfc)
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 3c311400afeaec6ef64dccc64cbc5a4129e59c66..57159b70fd62cdba67c3568736bdd594ccd6221f 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -601,9 +601,8 @@ sub access_distros () {
     my @l = access_basedistro();
 
     my (undef,$quirkdistro) = access_quirk();
-    unshift @l, $quirkdistro if defined $quirkdistro;
-
-    return @l;
+    unshift @l, $quirkdistro;
+    return grep { defined } @l;
 }
 
 sub access_cfg (@) {
@@ -655,6 +654,11 @@ sub access_cfg_ssh () {
     }
 }
 
+sub access_runeinfo ($) {
+    my ($info) = @_;
+    return ": dgit ".access_basedistro()." $info ;";
+}
+
 sub access_someuserhost ($) {
     my ($some) = @_;
     my $user = access_cfg("$some-user",'username');
@@ -819,8 +823,8 @@ sub canonicalise_suite_madison {
     return $r[0][2];
 }
 
-sub sshpsql ($$) {
-    my ($data,$sql) = @_;
+sub sshpsql ($$$) {
+    my ($data,$runeinfo,$sql) = @_;
     if (!length $data) {
        $data= access_someuserhost('sshpsql').':'.
            access_cfg('sshpsql-dbname');
@@ -829,7 +833,9 @@ sub sshpsql ($$) {
     my ($userhost,$dbname) = ($`,$'); #';
     my @rows;
     my @cmd = (access_cfg_ssh, $userhost,
-              "export LANG=C; ".shellquote qw(psql -A), $dbname, qw(-c), $sql);
+              access_runeinfo("ssh-psql $runeinfo").
+              " export LANG=C;".
+              " ".shellquote qw(psql -A), $dbname, qw(-c), $sql);
     printcmd(\*DEBUG,$debugprefix."|",@cmd) if $debug>0;
     open P, "-|", @cmd or die $!;
     while (<P>) {
@@ -849,13 +855,13 @@ sub sshpsql ($$) {
 }
 
 sub sql_injection_check {
-    foreach (@_) { die "$_ $& ?" if m/[']/; }
+    foreach (@_) { die "$_ $& ?" if m{[^-+=:_.,/0-9a-zA-Z]}; }
 }
 
 sub archive_query_sshpsql ($$) {
     my ($proto,$data) = @_;
     sql_injection_check $isuite, $package;
-    my @rows = sshpsql($data, <<END);
+    my @rows = sshpsql($data, "archive-query $isuite $package", <<END);
         SELECT source.version, component.name, files.filename, files.sha256sum
           FROM source
           JOIN src_associations ON source.id = src_associations.source
@@ -880,7 +886,7 @@ END
 sub canonicalise_suite_sshpsql ($$) {
     my ($proto,$data) = @_;
     sql_injection_check $isuite;
-    my @rows = sshpsql($data, <<END);
+    my @rows = sshpsql($data, "canonicalise-suite $isuite", <<END);
         SELECT suite.codename
           FROM suite where suite_name='$isuite' or codename='$isuite';
 END
@@ -975,6 +981,7 @@ sub check_for_git () {
     if ($how eq 'ssh-cmd') {
        my @cmd =
            (access_cfg_ssh, access_gituserhost(),
+            access_runeinfo("git-check $package").
             " set -e; cd ".access_cfg('git-path').";".
             " if test -d $package.git; then echo 1; else echo 0; fi");
        my $r= cmdoutput @cmd;
@@ -994,6 +1001,7 @@ sub create_remote_git_repo () {
     if ($how eq 'ssh-cmd') {
        runcmd_ordryrun
            (access_cfg_ssh, access_gituserhost(),
+            access_runeinfo("git-create $package").
             "set -e; cd ".access_cfg('git-path').";".
             " cp -a _template $package.git");
     } elsif ($how eq 'true') {