⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 changepass.pl

📁 Unix下基于Web的管理工具
💻 PL
字号:
#!/usr/local/bin/perl# changepass.pl# Script for the user to change their webmin password# Check command line argumentsusage() if (@ARGV != 3);($config, $user, $pass) = @ARGV;if (!-d $config) {	print STDERR "The config directory $config does not exist\n";	exit 2;	}if (!open(CONF, "$config/miniserv.conf")) {	print STDERR "Failed to open $config/miniserv.conf : $!\n";	print STDERR "Maybe $config is not the Webmin config directory.\n";	exit 3;	}while(<CONF>) {	if (/^([^=]+)=(\S+)/) { $config{$1} = $2; }	}close(CONF);# Update the users fileif (!open(USERS, $config{'userfile'})) {	print STDERR "Failed to open Webmin users file $config{'userfile'} : $!\n";	exit 4;	}while(<USERS>) {	if (/^([^:]+):(\S+)/) { $users{$1} = $2; }	}close(USERS);if (!defined($users{$user})) {	print STDERR "The Webmin user $user does not exist\n";	exit 5;	}$salt = substr(time(), 0, 2);$users{$user} = crypt($pass, $salt);if (!open(USERS, "> $config{'userfile'}")) {	print STDERR "Failed to open Webmin users file $config{'userfile'} : $!\n";	exit 6;	}foreach $k (keys %users) { print USERS "$k:$users{$k}\n"; }close(USERS);print "Updated password of Webmin user $user\n";# Send a signal to restart miniserv, if runningif (open(PID, $config{'pidfile'})) {	<PID> =~ /(\d+)/; $pid = $1;	close(PID);	kill('HUP', $pid);	}sub usage{print STDERR <<EOF;usage: changepass.pl <config-dir> <login> <password>This program allows you to change the password of a user in the Webminpassword file. For example, to change the password of the admin userto foo, you would run:	changepass.pl /etc/webmin admin fooThis assumes that /etc/webmin is the Webmin configuration directory.EOFexit 1;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -