chiark / gitweb /
checkpass: installation arrangements
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Jan 2013 16:34:57 +0000 (16:34 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 27 Jan 2013 16:34:57 +0000 (16:34 +0000)
README
debian/changelog
debian/control
misc/Makefile
misc/checkpasswd-other
misc/checkpasswd-self
misc/checkpasswd-service
settings.make

diff --git a/README b/README
index a968a8ee92560a59c997c931cbfa5814275a0ae4..38e1b4605686ac08e072eb8c3bb56093595d9176 100644 (file)
--- a/README
+++ b/README
@@ -25,6 +25,7 @@ ipif          Y Y A   UC create IP interfaces/VPNs (Linux-specific)
 www-cgi                Y B A   UC provide CGIs which run as themselves
 misc/mailq     Y S S   UC list mail queue even if sendmail forbids
 misc/ndc-reload        Y S S   UC reload named after editing own zone files
+misc/checkpass* Y Y S   UC check own password; some can check any passwd
 git-daemon     Y Y Y   UC safely publish git repositories on port 9418
 newsrc-lg      X B X   Acquire list of subscribed groups from .newsrcs
 
@@ -48,7 +49,7 @@ Key to the Status:
    S   Too small to need any significant documentation.
 
 userv-utils are
-Copyright (C)1996-2010 Ian Jackson <ian@davenant.greenend.org.uk>.
+Copyright (C)1996-2013 Ian Jackson <ian@davenant.greenend.org.uk>.
 Copyright (C)1998 David Damerell <damerell@chiark.greenend.org.uk>
 Copyright (C)1999,2003
    Chancellor Masters and Scholars of the University of Cambridge
index 11faf52bccf0a4328b5d08458a40c0d2047fbd4b..49dc8f9916002b529852b6d8fd746bbfdc36027c 100644 (file)
@@ -1,5 +1,6 @@
-userv-utils (0.5.0) unstable; urgency=low
+userv-utils (0.5.0~~iwj) unstable; urgency=low
 
+  * checkpasswd-*: new service
   * www-cgi: whitelist some more HTTP headers.
   * ipif: Improve documentation comment.
   * ipif: Some portability improvements.
@@ -7,7 +8,7 @@ userv-utils (0.5.0) unstable; urgency=low
   * Pass -g to linker, by default.
   * www-cgi: clean target removes *.o.
 
- --
+ -- Ian Jackson <ian@liberator.relativity.greenend.org.uk>  Sun, 27 Jan 2013 16:34:29 +0000
 
 userv-utils (0.4.2) unstable; urgency=low
 
index 48852b41a6e8a5f00becf647d4fa7081d1e3deeb..8b6e3e54696b62723c849f86d6c39010d6fb905a 100644 (file)
@@ -89,3 +89,4 @@ Description: miscellaneous small userv scripts
  .
  mailq - allow users to view the mail queue
  ndc-reload  - allow certain users to reload the nameserver
+ checkpasswd-* - allow users to run a UNIX password check
index 0bfa61d555c40eafe1420f5ed6537fbd0e3e2afa..bdec31557092eb0baea80ed080f569636f16e972 100644 (file)
@@ -24,9 +24,12 @@ include ../settings.make
 install:
                mkdir -p $(bindir)
                cp mailq-wrapper $(bindir)/mailq
+               mkdir -p $(sbindir)
+               cp checkpasswd-service $(sbindir)/checkpasswd-service
 
 install-examples:
                mkdir -p $(services)
-               cp mailq ndc-reload $(services)/.
+               cp mailq ndc-reload checkpasswd-self checkpasswd-other \
+                       $(services)/.
 
 install-docs:
index c9a9b595f864eef35b0ab64a57ae073fd1f28f30..bb52b9bc567248cfab3d08e7c7dd461e0f7bb687 100644 (file)
@@ -5,5 +5,5 @@ if ( grep calling-user /etc/userv/checkpasswd-service-users
        reset
        no-set-environment
        disconnect-hup
-       execute checkpasswd-service
+       execute checkpasswd-service /var/run/checkpasswd.synch 0.5 --
 fi
index 5e3a5a535d577889129e47b1c7b7050972cd05b0..a0daf6b9ee6b93248bb73454b10d6336ac529983 100644 (file)
@@ -1,8 +1,10 @@
 #
-if glob service-user root
+if ( grep service /etc/userv/default-services-enabled
+   & glob service-user root
+   )
        reset
        no-set-environment
        disconnect-hup
        suppress-args
-       execute checkpasswd-service SELF
+       execute checkpasswd-service /var/run/checkpasswd.synch 0.5 -- SELF
 fi
index 5418a7c54e23c9937e7608e72f6535b7797a8f8e..af72772f5a07e97cdaea739142e64eef41a07e56 100755 (executable)
@@ -1,10 +1,57 @@
 #!/usr/bin/perl -w
+# checkpasswd-service
+# part of userv-utils
+#
+#
+# protocols:
+#
+#   userv root checkpasswd-self <<'END'
+# < PASSWORD
+# < ^D
+# > STATUS MESSAGE...
+#
+#   userv root checkpasswd-other USERNAME <<'END'
+# < PASSWORD
+# < ^D
+# > STATUS MESSAGE...
+#
+# STATUS MESSAGE may be
+#   0 ok
+#   2 incorrect password
+#   4 no such user
+#   5 password disabled
+#
+#
+# Copyright (C) 2013 Ian Jackson
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with userv-utils; if not, write to the Free Software
+# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
 use strict;
 use IO::File;
 use Fcntl qw(:flock);
 
-die "$0: bad usage\n" unless @ARGV==1 && $ARGV[0] !~ m/^-/;
-my $username = shift @ARGV;
+my ($lockpath, $delay, $separator, $username) = @ARGV;
+
+die "$0: bad usage\n" unless
+    @ARGV == 4 ||
+    $lockpath =~ m#^/# ||
+    $delay =~ m/^[0-9.]+$/ ||
+    $separator eq '--' ||
+    $username =~ m/^\w/;
+
 $username = $ENV{'USERV_USER'} if $username eq 'SELF';
 
 sub result {
@@ -21,7 +68,6 @@ result 5, "password disabled" unless length $encrpw >= 13;
 $!=0; my $pw = <STDIN>;
 chomp $pw or die "reading password: $!\n";
 
-my $lockpath = "/var/run/checkpasswd.synch";
 my $lockf = new IO::File $lockpath, "w+" or die "open $lockpath: $!\n";
 flock($lockf, LOCK_EX) or die "lock $lockpath: $!\n";
 select(undef,undef,undef,0.5);
index 0c4de29eea65d740e842f9a72b8178518ddc486b..22c0073c6fd3a32052a69b47f75ee795c606e559 100644 (file)
@@ -21,6 +21,7 @@
 etcdir=                /etc
 prefix=                /usr/local
 bindir=                $(prefix)/bin
+sbindir=       $(prefix)/sbin
 vardir=                /var
 
 libdir=                $(prefix)/lib