#!/usr/bin/perl # # Squid NCSA password manager - ncsa-passwd.pl # # ncsa-passwd.pl # # This program 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. # # # Copyright (c) 1999,2000 Alexandre Dulaunoy # # I have just made this little perl script for interfacing with cgi, # a list of user with their NCSA equivalent password for authentification # with SQUID proxy-cache. (cf http://www.squid-cache.org/) # # version 0.1 - 14-04-2000 - Alexandre Dulaunoy adulau@metatix.com ### Def $PasswdFile = "/usr/etc/passwd"; $PasswdFileTmp = "/tmp/passwd-ncsa.tmp"; ### my @param = split(/\s+/,shift); #print $param[0]; $salt = substr(time(), -2); $CryptVar = crypt($param[1],$salt); $LineEntry = $param[0].":".$CryptVar."\n"; open (FILEBROL ,"<$PasswdFile"); open (FILETMP, ">$PasswdFileTmp"); while () { @ValuePasswd = split (":"); if ($ValuePasswd[0] eq $param[0]) { print FILETMP $LineEntry; $FlagExist = 1; } else { print FILETMP $_; } } if ($FlagExist == 0) {print FILETMP $LineEntry;} print FILEBROL $LineEntry; close (FILEBROL); close (FILETMP); rename ($PasswdFile, "$PasswdFile.orig"); rename ($PasswdFileTmp, $PasswdFile);