Files
mrbs-equbao-2026/crypt_passwd.pl
T
人事系统开发 48092cab42
Docker image / push (push) Canceled after 0s
MRBS 1.12.2 等保2.0二级整改完整提交
包含:登录失败锁定、90天密码有效期、30分钟会话超时、
强制改密、登录审计日志、屏幕水印、企业背景图、
备案信息固定底部、favicon、登录页JS修复等全部改动
2026-09-08 21:19:47 +08:00

64 lines
1.4 KiB
Perl
Executable File

#!/usr/bin/perl
# Authentication script to use with MRBS's "ext" authentication
# scheme. config.inc.php should include something like:
#
# $auth["realm"] = "MRBS";
# $auth["type"] = "ext";
# $auth["prog"] = "../crypt_passwd.pl";
# $auth["params"] = "/etc/httpd/mrbs_passwd #USERNAME# #PASSWORD#";
#
# The script takes 3 pararameters:
#
# PASSWDFILE USERNAME PASSWORD
#
# Where:
#
# PASSWDFILE - Filename of password file, which is the form
# <username>:<crypted password>
# [See crypt_passwd.example for an example]
# You should make sure this is readable by the
# user that PHP (most likely the web server)
# runs as.
# USERNAME - Username to check
# PASSWORD - Password to check against crypted password in
# password file
#
# Returns 0 on success, 1 on failure
use strict;
use warnings;
my $passwd_filename = shift || die "No passwd filename supplied\n";
my $username = shift || die "No username supplied\n";
my $password = shift || die "No password supplied\n";
my $retcode = 1;
open PASSWD,'<',$passwd_filename;
while (<PASSWD>)
{
if (m/^([^:]+):(.*)$/)
{
my $user = $1;
my $crypt = $2;
if ($user eq $username)
{
if (crypt($password, $crypt) eq $crypt)
{
$retcode = 0;
last;
}
else
{
last;
}
}
}
}
close PASSWD;
exit $retcode;