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

📄 inetd-lib.pl

📁 Unix下基于Web的管理工具
💻 PL
字号:
# inetd-lib.pl# Common functions for managing inetd.conf and services filesdo '../web-lib.pl';&init_config();# list_services()# Returns a list of services from the services file, each being an array of#  line name port protocol aliasessub list_services{local(@rv, $l);$l = 0;system("$config{'get_services_command'}") if ($config{'get_services_command'});open(SERVICES, $config{services_file});while(<SERVICES>) {	chop; s/#.*$//g;	if (/^(\S+)\s+([0-9]+)\/(\S+)\s*(.*)$/) {		push(@rv, [ $l, $1, $2, $3, $4 ]);		}	$l++;	}close(SERVICES);return @rv;}# create_service(name, port, proto, aliases)# Add a new service to the listsub create_service{open(SERVICES, ">> $config{services_file}");print SERVICES "$_[0]\t$_[1]/$_[2]",$_[3] ? "\t$_[3]\n" : "\n";close(SERVICES);system("$config{'put_services_command'}") if ($config{'put_services_command'});}# modify_service(line, name, port, proto, aliases)# Change an existing servicesub modify_service{local(@serv);open(SERVICES, $config{services_file});@serv = <SERVICES>;close(SERVICES);$serv[$_[0]] = "$_[1]\t$_[2]/$_[3]".($_[4] ? "\t$_[4]\n" : "\n");open(SERVICES, "> $config{services_file}");print SERVICES @serv;close(SERVICES);system("$config{'put_services_command'}") if ($config{'put_services_command'});}# delete_service(line)sub delete_service{local(@serv);open(SERVICES, $config{services_file});@serv = <SERVICES>;close(SERVICES);splice(@serv, $_[0], 1);open(SERVICES, "> $config{services_file}");print SERVICES @serv;close(SERVICES);system("$config{'put_services_command'}") if ($config{'put_services_command'});}# list_inets()# Returns a list of service details handled by inetd. RPC services# will have a name like foo/1 or bar/1-3, where the thing after the / is# the version or versions supported. For each service, the list contains#  line active? rpc? name type protocol wait user path|internal [args]sub list_inets{local(@rv, $l);$l = 0;open(INET, $config{'inetd_conf_file'});while(<INET>) {	chop;	if (/^(#+|#<off>#)?\s*(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\/\S+|internal)\s*(.*)$/) { push(@rv, [ $l, !$1, 0, $2, $3, $4, $5, $6, $7, $8 ]); $rv[$#rv]->[2] = ($2 =~ /\//); }	$l++;	}close(INET);return @rv;}# create_inet(enabled, name, type, protocol, wait, user, program, args)# Add a new service to the inetd config filesub create_inet{open(INET, ">> $config{inetd_conf_file}");print INET ($_[0] ? "" : "#")."$_[1]\t$_[2]\t$_[3]\t$_[4]\t$_[5]\t$_[6]".	   ($_[7] ? "\t$_[7]\n" : "\n");close(INET);}# modify_inet(line, enabled, name, type, protocol, wait, user, program, args)# Modify an existing inetd servicesub modify_inet{local(@inet);open(INET, $config{inetd_conf_file});@inet = <INET>;close(INET);$inet[$_[0]] = ($_[1] ? "" : "#")."$_[2]\t$_[3]\t$_[4]\t$_[5]\t$_[6]\t$_[7]".	       ($_[8] ? "\t$_[8]\n" : "\n");open(INET, "> $config{inetd_conf_file}");print INET @inet;close(INET);}# delete_inet(line)# Delete an internet service at some linesub delete_inet{local(@inet);open(INET, $config{inetd_conf_file});@inet = <INET>;close(INET);splice(@inet, $_[0], 1);open(INET, "> $config{inetd_conf_file}");print INET @inet;close(INET);}# list_rpcs()# Returns a list of rpc services, in the format#  line name number aliasessub list_rpcs{local(@rv, $l);$l = 0;open(RPC, $config{rpc_file});while(<RPC>) {	chop; s/#.*$//g;	if (/^(\S+)\s+(\d+)\s*(.*)$/) {		push(@rv, [ $l, $1, $2, $3, $4 ]);		}	$l++;	}close(RPC);return @rv;}	# create_rpc(name, number, aliases)# Create a new rpc file entrysub create_rpc{open(RPC, ">> $config{rpc_file}");print RPC "$_[0]\t$_[1]",($_[2] ? "\t$_[2]\n" : "\n");close(RPC);}# modify_rpc(line, name, number, aliases)# Change an existing rpc programsub modify_rpc{local(@rpcs);open(RPC, $config{rpc_file});@rpcs = <RPC>;close(RPC);$rpcs[$_[0]] = "$_[1]\t$_[2]".($_[3] ? "\t$_[3]\n" : "\n");open(RPC, "> $config{rpc_file}");print RPC @rpcs;close(RPC);}# delete_rpc(line)# Delete an entry from the rpc filesub delete_rpc{local(@rpcs);open(RPC, $config{rpc_file});@rpcs = <RPC>;close(RPC);splice(@rpcs, $_[0], 1);open(RPC, "> $config{rpc_file}");print RPC @rpcs;close(RPC);}# list_protocols()# Returns a list of supported protocols on this systemsub list_protocols{local(@rv);open(PROT, $config{protocols_file});while(<PROT>) {	chop; s/#.*$//g;	if (!/\S/) { next; }	/^(\S+)\s+/;	push(@rv, $1);	}close(PROT);return @rv;}%prot_name = ("ip", "Internet Protocol",	      "tcp", "Transmission Control Protocol",	      "udp", "User Datagram Protocol");1;

⌨️ 快捷键说明

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