diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2013-01-27 16:34:57 +0000 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2013-01-27 16:34:57 +0000 |
commit | 5e5500edfef302605aea6cdbf4fd6060e80d1248 (patch) | |
tree | a8392cdd2cdb0fdbea9a368d949833ebfe2b9cb1 /misc | |
parent | 5f477c55c7500f6e4d748e4ddcd3ba90dc1bac79 (diff) | |
download | userv-utils-5e5500edfef302605aea6cdbf4fd6060e80d1248.tar.gz |
checkpass: installation arrangements
Diffstat (limited to 'misc')
-rw-r--r-- | misc/Makefile | 5 | ||||
-rw-r--r-- | misc/checkpasswd-other | 2 | ||||
-rw-r--r-- | misc/checkpasswd-self | 6 | ||||
-rwxr-xr-x | misc/checkpasswd-service | 52 |
4 files changed, 58 insertions, 7 deletions
diff --git a/misc/Makefile b/misc/Makefile index 0bfa61d..bdec315 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -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: diff --git a/misc/checkpasswd-other b/misc/checkpasswd-other index c9a9b59..bb52b9b 100644 --- a/misc/checkpasswd-other +++ b/misc/checkpasswd-other @@ -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 diff --git a/misc/checkpasswd-self b/misc/checkpasswd-self index 5e3a5a5..a0daf6b 100644 --- a/misc/checkpasswd-self +++ b/misc/checkpasswd-self @@ -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 diff --git a/misc/checkpasswd-service b/misc/checkpasswd-service index 5418a7c..af72772 100755 --- a/misc/checkpasswd-service +++ b/misc/checkpasswd-service @@ -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); |