chiark / gitweb /
Merge branch 'master' into newacpi
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 3 Jun 2012 14:20:29 +0000 (15:20 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 3 Jun 2012 14:20:29 +0000 (15:20 +0100)
Conflicts:
.gitignore
cprogs/.gitignore
debian/.gitignore
debian/changelog

.gitignore
cprogs/.gitignore [deleted file]
debian/.gitignore [deleted file]
debian/changelog
debian/compat [new file with mode: 0644]
debian/control
scripts/ChiarkNNTP.pm [new file with mode: 0644]
scripts/nntpid [new file with mode: 0755]

index 7353e7e145139bbcfb99384df098facea1844fb9..fa3ec36a2a7c2441feda6856b29a030e0a63d8f6 100644 (file)
@@ -1,2 +1,20 @@
-build
+*~
 *.o
+
+build
+
+cprogs/readbuffer
+cprogs/writebuffer
+cprogs/trivsoundd
+cprogs/really
+cprogs/with-lock-ex
+cprogs/xacpi-simple
+cprogs/mcastsoundd
+cprogs/summer
+cprogs/watershed
+cprogs/rcopy-repeatedly
+
+debian/tmp
+debian/sv-*
+debian/files
+debian/*.debhelper.log
diff --git a/cprogs/.gitignore b/cprogs/.gitignore
deleted file mode 100644 (file)
index ca39263..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-readbuffer
-writebuffer
-trivsoundd
-really
-with-lock-ex
-xacpi-simple
-mcastsoundd
-summer
-watershed
-rcopy-repeatedly
diff --git a/debian/.gitignore b/debian/.gitignore
deleted file mode 100644 (file)
index c777f76..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-tmp
-sv-*
-files
index 68085018fc5178fedf5aba6692d310a3ccf919db..4ed6596d88cbf682a253c65fcab00a5524ebf129 100644 (file)
@@ -1,8 +1,13 @@
-chiark-utils (4.1.31) unstable; urgency=low
+chiark-utils (4.1.31~~iwj) unstable; urgency=low
 
+  * chiark-backup Suggests chiark-utils-bin, not the nonexistent
+    chiark-cprogs (for `summer').
+  * Fix the build-depends to refer to nettle-dev not libnettle-dev.
+  * Add ${misc:Depends} to Depends: lines.  Causes no change to the .debs.
   * Switch to git.  Move .cvsignores to .gitignore, etc.
+  * Update my email address.
 
- --
+ -- Ian Jackson <ijackson@chiark.greenend.org.uk>  Sun, 03 Jun 2012 14:56:36 +0100
 
 chiark-utils (4.1.30) unstable; urgency=low
 
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
index 38e47efbfdfecabfdc180dfadf534df3f461bc78..1d51ce9911bb4f963551e94d700b63efcb8f0225 100644 (file)
@@ -1,16 +1,16 @@
 Source: chiark-utils
 Section: admin
 Priority: extra
-Maintainer: Ian Jackson <ian@davenant.greenend.org.uk>
-Build-Depends: libx11-dev, libnettle-dev, debhelper
+Maintainer: Ian Jackson <ijackson@chiark.greenend.org.uk>
+Build-Depends: libx11-dev, nettle-dev, debhelper (>= 5)
 Standards-Version: 3.2.1.0
 
 Package: chiark-backup
 Section: utils
 Priority: extra
 Architecture: all
-Depends: chiark-rwbuffer, chiark-utils-bin
-Suggests: chiark-cprogs (>= 4.1.14)
+Depends: chiark-rwbuffer, chiark-utils-bin, ${misc:Depends}
+Suggests: chiark-utils-bin (>= 4.1.14)
 Description: backup system for small systems and networks
  These are the backup scripts used by chiark.greenend.org.uk and other
  systems belonging to the Sinister Greenend Organisation.  Features:
@@ -68,7 +68,7 @@ Package: chiark-rwbuffer
 Section: utils
 Priority: extra
 Architecture: any
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: readbuffer/writebuffer: prevents tape drive seesawing, etc.
  readbuffer and writebuffer: programs for reading input from devices,
  and writing output to, which don't like constant stopping and
@@ -76,7 +76,7 @@ Description: readbuffer/writebuffer: prevents tape drive seesawing, etc.
 
 Package: chiark-utils-bin
 Architecture: any
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}
 Recommends: ${shlibs:Recommends}
 Suggests: ${shlibs:Suggests}
 Section: utils
@@ -107,7 +107,7 @@ Package: chiark-really
 Section: admin
 Priority: extra
 Architecture: any
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends}, ${misc:Depends}
 Description: really - a tool for gaining privilege (simple, realistic sudo)
  really is a program that allows certain users to become whatever user
  they like on request.  It is a bit like sudo in that respect.
diff --git a/scripts/ChiarkNNTP.pm b/scripts/ChiarkNNTP.pm
new file mode 100644 (file)
index 0000000..5b69e28
--- /dev/null
@@ -0,0 +1,137 @@
+#!/usr/bin/perl
+
+use strict qw(subs);
+use warnings;
+
+require 5.002;
+use Socket;
+use FileHandle;
+
+
+BEGIN {
+    use Exporter   ();
+    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
+
+    # set the version for version checking
+    $VERSION     = 1.00;
+
+    @ISA         = qw(Exporter);
+    @EXPORT      = qw(cnntp_connect);
+    %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
+    
+    @EXPORT_OK   = qw();
+}
+our @EXPORT_OK;
+
+sub cnntp_connect ($) {
+    my ($verbose) = @_;
+
+    my $ns=$ENV{'NNTPSERVER'};
+    if (!defined $ns or !length $ns) {
+       $ns = `cat /etc/nntpserver`;
+       chomp($ns);
+    }
+    my $port = (getservbyname("nntp", "tcp"))[2];
+    $ns = inet_aton($ns);
+    my $proto = getprotobyname("tcp");
+    my $paddr = sockaddr_in($port, $ns);
+
+    my $sock = new IO::Handle;
+    socket($sock,PF_INET,SOCK_STREAM,$proto) or die "socket: $!";
+    connect($sock,$paddr) or die "connect: $!";
+
+    $sock->autoflush(1);
+
+    return bless { S => $sock, V => $verbose };
+}
+
+sub banner_reader ($) {
+    my ($c) = @_;
+    my ($code,$l) = $c->getline();
+    $code =~ /^2\d\d/ or die "no initial greeting from server\n";
+    $c->docmd("MODE READER");
+}
+
+sub disconnect ($) {
+    my ($c) = @_;
+    close $c->{S};
+}
+
+sub putline ($$) {
+    my ($c, $line) = @_;
+    my $s = $c->{S};
+    my $v = $c->{V};
+    print $v ">>> $line\n" if $v;
+    print $s "$line\r\n";
+}
+
+sub getline_raw ($) {
+    my ($c) = @_;
+    my $s = $c->{S};
+    my $l = <$s>;
+    return $l;
+}
+
+sub getline ($) {
+    my ($c) = @_;
+    my $v = $c->{V};
+    my $l = $c->getline_raw();
+    $l =~ s/[\r\n]*$//s;
+    my $code = substr($l,0,3);
+    print $v "<<< $l\n" if $v;
+    return ($code,$l);
+}
+
+sub docmd ($$;$) {
+    my ($c,$cmd,$nocheck) = @_;
+    my ($code,$l);
+    for my $n (0,1) {
+       $c->putline($cmd);
+       ($code,$l) = $c->getline();
+       if ($code eq "480") { $c->auth(); } else { last; }
+    }
+    if (!$nocheck) {
+       $code =~ /^2\d\d/ or die "failed on `$cmd':\n$l\n";
+    }
+    return ($code,$l);
+}
+
+sub auth ($) {
+    my ($c) = @_;
+    # Authentication.
+    return if $c->{Authed}++;
+    my $auth = $ENV{"NNTPAUTH"};
+    if (defined $auth) {
+       $c->putline("AUTHINFO GENERIC $auth");
+       pipe AUTHSTDIN, TOAUTH or die "unable to create pipes";
+       pipe FROMAUTH, AUTHSTDOUT or die "unable to create pipes";
+       flush STDOUT;
+       my $pid = fork;
+       if (!defined $pid) {
+           die "unable to fork for authentication helper";
+       } elsif ($pid == 0) {
+           # we are child
+           $c->{V} = undef if $c->{V} eq 'STDOUT';
+           $ENV{"NNTP_AUTH_FDS"} = "0.1";
+           open STDIN, "<&AUTHSTDIN";
+           open STDOUT, ">&AUTHSTDOUT";
+           close $c->{S};
+           exec $auth;
+           die $!;
+       }
+       # we are parent
+       close AUTHSTDIN;
+       close AUTHSTDOUT;
+       autoflush TOAUTH 1;
+       my ($code,$l) = $c->getline(); print TOAUTH "$l\n";
+       while (<FROMAUTH>) {
+           s/[\r\n]*$//s;
+           $c->putline($_);
+           ($code,$l) = $c->getline();
+           print TOAUTH "$l\n";
+       }
+       die "failed authentication\n" unless $? == 0;
+    }
+}
+
+1;
diff --git a/scripts/nntpid b/scripts/nntpid
new file mode 100755 (executable)
index 0000000..e0e286a
--- /dev/null
@@ -0,0 +1,72 @@
+#!/usr/bin/perl
+
+# Originally by Simon Tatham
+# Modified by Richard Kettlewell, Colin Watson, Ian Jackson
+
+use ChiarkNNTP;
+
+our $verbose;
+($verbose='STDERR', shift @ARGV) if $ARGV[0] eq "-v";
+
+my $c = cnntp_connect($verbose);
+$c->banner_reader();
+
+our $code;
+
+# some servers require a GROUP before an ARTICLE command
+$c->docmd("GROUP misc.misc");
+
+if(@ARGV == 0) {
+  while(<>) {
+    s/(^\s+|\s+$)//gs;
+    lookup($_);
+  }
+} else {
+  while (@ARGV) {
+    my $item = shift @ARGV;
+    if($item !~ /[\@:]/ and not defined $group) {
+      # maybe a bare group followed by an article number
+      die unless @ARGV;
+      my $number = shift @ARGV;
+      $item = "$item $number";
+    }
+    lookup($item);
+  }
+}
+
+$c->docmd("QUIT");
+close S;
+
+sub lookup {
+  my $mid = shift;
+
+  if($mid !~ /\@/ and $mid =~ /^(.*)[: ](\d+)$/) {
+      my ($g, $n) = ($1, $2);
+      $c->docmd("GROUP $g");
+      $c->docmd("ARTICLE $n");
+  } else {
+      $mid =~ s/.*\<//;
+      $mid =~ s/\>.*//;
+      $c->docmd("ARTICLE <$mid>");
+  }
+
+  my $fh= 'STDOUT';
+  if (-t $fh) {
+    my $lesscmd= $ENV{'NNTPID_PAGER'};
+    $lesscmd= 'less' unless defined $lesscmd;
+    open LESS, "|-", 'sh','-c',$lesscmd or die $!;
+    $fh= 'LESS';
+  }
+  
+  while (1) {
+    ($code,$_) = $c->getline();
+    s/[\r\n]//g;
+    last if /^\.$/;
+    s/^\.//;
+    print $fh "$_\n";
+  }
+
+  if ($fh ne 'STDOUT') {
+    close $fh or die "$? $!";
+  }
+}