diff options
author | Eugeni Dodonov <eugeni@mandriva.org> | 2009-03-17 16:49:19 +0000 |
---|---|---|
committer | Eugeni Dodonov <eugeni@mandriva.org> | 2009-03-17 16:49:19 +0000 |
commit | b3f2bfa14a5fd48ad1e1feffd82cc8203d54f055 (patch) | |
tree | 7d36b02313e6f6ddd74656f91ec8bca9a65a41b5 /lib/network/nfs.pm | |
parent | ee0aaf75dd71df0113417670d25640d85dc79d86 (diff) | |
download | drakx-net-b3f2bfa14a5fd48ad1e1feffd82cc8203d54f055.tar drakx-net-b3f2bfa14a5fd48ad1e1feffd82cc8203d54f055.tar.gz drakx-net-b3f2bfa14a5fd48ad1e1feffd82cc8203d54f055.tar.bz2 drakx-net-b3f2bfa14a5fd48ad1e1feffd82cc8203d54f055.tar.xz drakx-net-b3f2bfa14a5fd48ad1e1feffd82cc8203d54f055.zip |
Supporting custom user-defined NFS ports.
Diffstat (limited to 'lib/network/nfs.pm')
-rw-r--r-- | lib/network/nfs.pm | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/lib/network/nfs.pm b/lib/network/nfs.pm index e3dca58..34ea52e 100644 --- a/lib/network/nfs.pm +++ b/lib/network/nfs.pm @@ -3,9 +3,9 @@ package network::nfs; use strict; use common; -sub read_nfs_port_settings { +sub read_nfs_ports { my $statd_port = 4001; - my $statd_outgoing_port = 4001; + my $statd_outgoing_port = undef; my $lockd_tcp_port = 4002; my $lockd_udp_port = 4002; my $rpc_mountd_port = 4003; @@ -25,13 +25,68 @@ sub read_nfs_port_settings { } } - { statd_port => $statd_port, - statd_outgoing_port => $statd_outgoing_port, + my $ports = { statd_port => $statd_port, lockd_tcp_port => $lockd_tcp_port, lockd_udp_port => $lockd_udp_port, rpc_mountd_port => $rpc_mountd_port, rpc_rquotad_port => $rpc_rquotad_port, + }; + if (defined $statd_outgoing_port) { + $ports->{statd_outgoing_port} => $statd_outgoing_port, } + $ports; +} + +sub list_nfs_ports { + my $ports = read_nfs_ports(); + + my $portlist = $ports->{lockd_tcp_port}. "/tcp " . $ports->{lockd_udp_port} . "/udp"; + if (defined $ports->{statd_outgoing_port} and $ports->{statd_outgoing_port} ne $ports->{statd_port}) { + $portlist .= " " . $ports->{statd_outgoing_port} . "/tcp " . $ports->{statd_outgoing_port} . "/udp"; + } + foreach (qw(statd_port rpc_mountd_port rpc_rquotad_port)) { + my $port = $ports->{$_}; + $portlist .= " $port/tcp $port/udp"; + } + # list of ports in shorewall format + $portlist; +} + +sub write_nfs_ports { + my ($ports) = @_; + # enabling fixed ports for NFS services + # nfs-common + substInFile { + if ($ports->{statd_port}) { + my $port = $ports->{statd_port}; + s/^(STATD_OPTIONS)=$/$1="--port $port"/; + s/^(STATD_OPTIONS)="(.*)(--port \d+)(.*)"$/$1="$2--port $port$4"/; + s/^(STATD_OPTIONS)="(.*)(-p \d+)(.*)"$/$1="$2--port $port$4"/; + } + if ($ports->{lockd_tcp_port}) { + my $port = $ports->{lockd_tcp_port}; + s/^LOCKD_TCPPORT=.*/LOCKD_TCPPORT=$port/; + } + if ($ports->{lockd_udp_port}) { + my $port = $ports->{lockd_udp_port}; + s/^LOCKD_UDPPORT=.*/LOCKD_UDPPORT=$port/; + } + } "/etc/sysconfig/nfs-common"; + # nfs-server + substInFile { + if ($ports->{rpc_mountd_port}) { + my $port = $ports->{rpc_mountd_port}; + s/^(RPCMOUNTD_OPTIONS)=$/$1="--port $port"/; + s/^(RPCMOUNTD_OPTIONS)="(.*)(--port \d+)(.*)"$/$1="$2--port $port$4"/; + s/^(RPCMOUNTD_OPTIONS)="(.*)(-p \d+)(.*)"$/$1="$2--port $port$4"/; + } + if ($ports->{rpc_rquotad_port}) { + my $port = $ports->{rpc_rquotad_port}; + s/^(RPCRQUOTAD_OPTIONS)=$/$1="--port $port"/; + s/^(RPCRQUOTAD_OPTIONS)="(.*)(--port \d+)(.*)"$/$1="$2--port $port$4"/; + s/^(RPCRQUOTAD_OPTIONS)="(.*)(-p \d+)(.*)"$/$1="$2--port $port$4"/; + } + } "/etc/sysconfig/nfs-server"; } 1; |