3 # Update, create or delete an NFS export
5 require './file-lib.pl';
6 $disallowed_buttons{'sharing'} && &error($text{'ebutton'});
8 print "Content-type: text/plain\n\n";
9 if ($access{'ro'} || $access{'uid'}) {
10 # User has no access to NFS
15 &read_acl(\%acl, undef);
16 %einfo = &get_module_info("exports");
17 %dinfo = &get_module_info("dfsadmin");
18 %binfo = &get_module_info("bsdexports");
20 if (%einfo && &check_os_support(\%einfo)) {
22 &module_check("exports");
23 &foreign_require("exports", "exports-lib.pl");
24 %econfig = &foreign_config("exports");
25 &lock_file($econfig{'exports_file'});
26 foreach $e (&foreign_call("exports", "list_exports")) {
27 push(@{$exp{$e->{'dir'}}}, $e);
30 # Delete all exports for some dir
31 foreach $e (reverse(@{$exp{$in{'path'}}})) {
32 &foreign_call("exports", "delete_export", $e);
36 # Adding or updating an export
38 # Updating, so delete old exports first
39 foreach $e (reverse(@{$exp{$in{'path'}}})) {
40 $host{$e->{'host'}} = $e;
41 &foreign_call("exports", "delete_export", $e);
44 for($i=0; $in{"host$i"}; $i++) {
45 $h = $in{"host$i"} eq '*' ? '' : $in{"host$i"};
49 'dir' => $in{'path'} } if (!$e);
50 delete($e->{'options'}->{'ro'});
52 $e->{'options'}->{'ro'} = '';
54 delete($e->{'options'}->{'all_squash'});
55 delete($e->{'options'}->{'no_root_squash'});
56 if ($in{"squash$i"} == 0) {
57 $e->{'options'}->{'all_squash'} = '';
59 elsif ($in{"squash$i"} == 2) {
60 $e->{'options'}->{'no_root_squash'} = '';
62 &foreign_call("exports", "create_export", $e);
65 &unlock_file($econfig{'exports_file'});
68 &exports::restart_mountd();
70 &webmin_log($in{'delete'} ? 'delete' : $in{'new'} ? 'create' : 'modify',
71 'export', $in{'path'});
74 elsif (%dinfo && &check_os_support(\%dinfo)) {
76 &module_check("dfsadmin");
77 &foreign_require("dfsadmin", "dfs-lib.pl");
78 %iconfig = &foreign_config("dfsadmin");
79 &lock_file($iconfig{'dfstab_file'});
80 @shlist = &foreign_call("dfsadmin", "list_shares");
81 foreach $s (@shlist) {
82 $share = $s if ($s->{'dir'} eq $in{'path'});
85 # Delete existing share
86 &foreign_call("dfsadmin", "delete_share", $share);
90 foreach $r ('ro', 'rw', 'root') {
93 $opts->{$r} = $in{$r};
96 $share->{'dir'} = $in{'path'};
97 $share->{'desc'} = $in{'desc'};
99 &foreign_call("dfsadmin", "join_options", $opts);
100 &foreign_call("dfsadmin", "create_share", $share);
103 # Update existing share
104 $opts = &foreign_call("dfsadmin", "parse_options",
106 foreach $r ('ro', 'rw', 'root') {
107 if ($in{$r} eq '-') { delete($opts->{$r}); }
109 $in{$r} =~ s/\s+/:/g;
110 $opts->{$r} = $in{$r};
113 $share->{'dir'} = $in{'path'};
114 $share->{'desc'} = $in{'desc'};
116 &foreign_call("dfsadmin", "join_options", $opts);
117 &foreign_call("dfsadmin", "modify_share", $share);
119 &unlock_file($iconfig{'dfstab_file'});
121 # Apply changes to NFS daemon
122 &dfsadmin::apply_configuration();
124 &webmin_log($in{'delete'} ? 'delete' : $in{'new'} ? 'create' : 'modify',
125 'export', $in{'path'});
128 elsif (%binfo && &check_os_support(\%binfo)) {
130 &module_check("bsdexports");
133 # No NFS modules installed or supported
139 if (!$acl{$base_remote_user,$_[0]}) {