[LON-CAPA-cvs] cvs: loncom / pwchange
raeburn
raeburn@source.lon-capa.org
Fri, 17 Jul 2009 02:20:59 -0000
raeburn Fri Jul 17 02:20:59 2009 EDT
Modified files:
/loncom pwchange
Log:
--stdin option not available with system passwd command in debian/ubuntu
- use system call to usermod instead.
Index: loncom/pwchange
diff -u loncom/pwchange:1.9 loncom/pwchange:1.10
--- loncom/pwchange:1.9 Mon Feb 3 18:03:52 2003
+++ loncom/pwchange Fri Jul 17 02:20:59 2009
@@ -9,7 +9,7 @@
# YEAR=2002
# 02/19 Matthew Hall
#
-# $Id: pwchange,v 1.9 2003/02/03 18:03:52 harris41 Exp $
+# $Id: pwchange,v 1.10 2009/07/17 02:20:59 raeburn Exp $
###
use strict;
@@ -52,10 +52,20 @@
exit 3 if $pbad;
# --------------------------------------------------------- Call system command
-open OUT,"|passwd --stdin $safe >/dev/null";
-print OUT $pword;
-print OUT "\n";
-close OUT;
+my $distro;
+if (open(PIPE,"perl distprobe|")) {
+ $distro = <PIPE>;
+ close(PIPE);
+}
+if ($distro =~ /^ubuntu|debian/) {
+ open(OUT,"|/usr/sbin/usermod -p `mkpasswd $pword` $safe");
+ close(OUT);
+} else {
+ open(OUT,"|passwd --stdin $safe >/dev/null");
+ print OUT $pword;
+ print OUT "\n";
+ close(OUT);
+}
# --------------------------------------- exit with status of command execution
exit $?/256;