patches/system-tools-backends-05-services.diff
author padraigo
Thu, 16 Mar 2006 09:25:39 +0000
changeset 6955 fef846f62545
child 7085 677b18c80bd7
permissions -rw-r--r--
2006-03-16 Padraig O'Briain <[email protected]> * patches/gnome-system-tools-01-config.diff * patches/gnome-system-tools-02-forkpty.diff * patches/gnome-system-tools-03-emptyconstruct.diff * patches/gnome-system-tools-04-tz.diff * patches/gnome-system-tools-05-shares.diff * patches/system-tools-backends-01-boot.diff * patches/system-tools-backends-02-common.diff * patches/system-tools-backends-03-disks.diff * patches/system-tools-backends-04-network.diff * patches/system-tools-backends-05-services.diff * patches/system-tools-backends-06-shares.diff * patches/system-tools-backends-07-time.diff * patches/system-tools-backends-08-users.diff: Patches moved from Solaris directory * gnome-system-tools.spec: * system-tools-backends.spec: Update to apply patches.

diff -ru /var/tmp/clean/system-tools-backends-1.4.2/services-conf.in system-tools-backends-1.4.2/services-conf.in
--- /var/tmp/clean/system-tools-backends-1.4.2/services-conf.in	2006-01-02 15:32:34.000000000 +0000
+++ system-tools-backends-1.4.2/services-conf.in	2006-03-13 10:14:56.155294000 +0000
@@ -51,6 +51,7 @@
               
               "debian-2.2", "debian-3.0", "debian-sarge",
 
+	          "nexenta-1.0", "solaris-2.11",
               "suse-7.0", "turbolinux-7.0", "fedora-1", "fedora-2", "fedora-3", "rpath",
               "pld-1.0", "pld-1.1", "pld-1.99",
               "slackware-9.1.0", "slackware-10.0.0", "slackware-10.1.0", "slackware-10.2.0",
@@ -260,6 +261,7 @@
 sub xml_print_runlevels
 {
   my ($h, $default) = @_;
+  &gst_xml_print_pcdata ("longname", $i);
   &gst_xml_print_line ("<runlevels>");
   &gst_xml_enter ();
 
diff -ru /var/tmp/clean/system-tools-backends-1.4.2/share.pl.in system-tools-backends-1.4.2/share.pl.in
--- /var/tmp/clean/system-tools-backends-1.4.2/share.pl.in	2005-02-25 14:15:34.000000000 +0000
+++ system-tools-backends-1.4.2/share.pl.in	2006-03-13 10:14:56.155671000 +0000
@@ -202,6 +202,16 @@
   }
 }
 
+sub gst_share_nfs_info_get_name
+{
+  return $_[0]->{'name'};
+}
+
+sub gst_share_nfs_info_set_name
+{
+  &gst_share_nfs_info_set ($_[0], 'name', $_[1]);
+}
+
 sub gst_share_nfs_info_get_point
 {
   return $_[0]->{'point'};
@@ -397,6 +407,52 @@
   return $table;
 }
 
+sub gst_share_dfstab_list
+{
+  my ($file) = @_;
+  my $lnum = 0;
+  my @rv;
+
+  # dfstab example:
+  #
+  #       share [-F fstype] [-o fs_options ] [-d description] [pathname [resourcename]]
+  #       .e.g,
+  #       share  -F nfs  -o rw=engineering  -d "home dirs"  /export/home2
+  my $fd = &gst_file_open_read_from_names ($file);
+  return @rv if !$fd;
+
+  while (<$fd>) {
+    s/\r|\n//g; s/#.*$//;
+    if (/^\s*\S*share\s+(.*)/) {
+      # Found a share line
+      my $share = { 'line' => $lnum,
+                    'index' => scalar(@rv) };
+      my $line = $1;
+      while($line =~ /\\$/) {
+        $_ = <$fd>;
+        s/\r|\n//g; s/#.*$//;
+        $line =~ s/\\$//;
+        $line .= $_;
+        $lnum++;
+      }
+      $share->{'eline'} = $lnum;
+      if ($line =~ /\s+(\/\S+)/ || $line =~ /\s+(\/)/ || $line eq "/") { $share->{'dir'} = $1; }
+      if ($line =~ /-d\s+"([^"]+)"/) { $share->{'desc'} = $1; }
+      elsif ($line =~ /-d\s+(\S+)/) { $share->{'desc'} = $1; }
+      if ($line =~ /-o\s+"([^"]+)"/) { $share->{'opts'} = $1; }
+      elsif ($line =~ /-o\s+(\S+)/) { $share->{'opts'} = $1; }
+      if ($line =~ /\s-F\s+(\S+)/) { $share->{'type'} = $1; }
+      else { $share->{'type'} = "nfs"; }
+      $share->{'desc'} =~ s/"//g; $share->{'desc'} =~ s/'//g;
+      push(@rv, $share);
+    }
+    $lnum++;
+  }
+  &gst_file_close ($fd);
+
+  return @rv;
+}
+
 sub gst_share_parse_nfs_exports
 {
   my ($nfs_exports_name) = @_;
@@ -405,43 +461,82 @@
 
   $table = &gst_share_nfs_table_new ();
 
-  $entries = &gst_parse_split_hash_with_continuation ($nfs_exports_name, "[ \t]+", "[ \t]+");
+  if ($$tool{"system"} eq "SunOS") {
+    foreach $share (&gst_share_dfstab_list($file)) {
+      if ($share->{'type'} eq "nfs") {
+        my $info = &gst_share_nfs_info_new ();
+        my $client_table = &gst_share_nfs_client_table_new ();
+
+        &gst_share_nfs_info_set_point ($info, $share->{'dir'});
+        &gst_share_nfs_info_set_name ($info, $share->{'desc'});
+
+        # Parse a mount options string like rw=foo,nosuid,...
+        # Parts with no value are given an empty string as the value
+        foreach my $opt (split(/,/, $share->{'opts'})) {
+          if ($opt =~ /^([^=]+)=(.*)$/) {
+            my $cinfo = &gst_share_nfs_client_info_new ();
+            my $pattern;
+            my $access = $1;
+            my $client = $2;
+
+            $client =~ /^([a-zA-Z0-9.-_*?@\/]+)/;
+            $pattern = $1;
+            $pattern = "0.0.0.0/0" if $pattern eq "";
+            &gst_share_nfs_client_info_set_pattern ($cinfo, $pattern);
+
+            if ($access eq "rw" || $access eq "root") {
+              &gst_share_nfs_client_info_set_write ($cinfo, 1);
+            }
+
+            &gst_share_nfs_client_table_add ($client_table, $cinfo);
+          } else {
+            $clients{$opt} = "";
+          }
+        }
 
-  foreach $point (keys %$entries)
-  {
-    my $clients = $$entries{$point};
-    my $info = &gst_share_nfs_info_new ();
-    my $client_table = &gst_share_nfs_client_table_new ();
-
-    &gst_share_nfs_info_set_point ($info, $point);
-
-    foreach $client (@$clients)
+        &gst_share_nfs_info_set_client_table ($info, $client_table);
+        &gst_share_nfs_table_add ($table, $info);
+      }
+    }
+  } else {
+    $entries = &gst_parse_split_hash_with_continuation ($nfs_exports_name, "[ \t]+", "[ \t]+");
+  
+    foreach $point (keys %$entries)
     {
-      my $cinfo = &gst_share_nfs_client_info_new ();
-      my $pattern;
-
-      $client =~ /^([a-zA-Z0-9.-_*?@\/]+)/;
-      $pattern = $1;
-      $pattern = "0.0.0.0/0" if $pattern eq "";
-      &gst_share_nfs_client_info_set_pattern ($cinfo, $pattern);
-
-      my $option_str = "";
-      my @options;
-
-      if ($client =~ /\((.+)\)/) { $option_str = $1; }
-      @options = ($option_str =~ /([a-zA-Z0-9_=-]+),?/mg);
-
-      for $option (@options)
+      my $clients = $$entries{$point};
+      my $info = &gst_share_nfs_info_new ();
+      my $client_table = &gst_share_nfs_client_table_new ();
+  
+      &gst_share_nfs_info_set_point ($info, $point);
+  
+      foreach $client (@$clients)
       {
-        if ($option eq "rw") { &gst_share_nfs_client_info_set_write ($cinfo, 1); }
-        # Add supported NFS export options here. Some might have to be split on '='.
+        my $cinfo = &gst_share_nfs_client_info_new ();
+        my $pattern;
+  
+        $client =~ /^([a-zA-Z0-9.-_*?@\/]+)/;
+        $pattern = $1;
+        $pattern = "0.0.0.0/0" if $pattern eq "";
+        &gst_share_nfs_client_info_set_pattern ($cinfo, $pattern);
+  
+        my $option_str = "";
+        my @options;
+  
+        if ($client =~ /\((.+)\)/) { $option_str = $1; }
+        @options = ($option_str =~ /([a-zA-Z0-9_=-]+),?/mg);
+  
+        for $option (@options)
+        {
+          if ($option eq "rw") { &gst_share_nfs_client_info_set_write ($cinfo, 1); }
+          # Add supported NFS export options here. Some might have to be split on '='.
+        }
+  
+        &gst_share_nfs_client_table_add ($client_table, $cinfo);
       }
-
-      &gst_share_nfs_client_table_add ($client_table, $cinfo);
+  
+      &gst_share_nfs_info_set_client_table ($info, $client_table);
+      &gst_share_nfs_table_add ($table, $info);
     }
-
-    &gst_share_nfs_info_set_client_table ($info, $client_table);
-    &gst_share_nfs_table_add ($table, $info);
   }
 
   return $table;
@@ -495,11 +590,27 @@
   {
     # Each line is in the following format:
     # <point> <clients>
-    my @line = split /[ \t]+/, $_;
-    if ($line[0] eq "") { shift @line; }
-    if (@line < 1 || &gst_ignore_line (@line)) { print $outfd $_; next; }
-
-    return $_;
+    if ($$tool{"system"} eq "SunOS") {
+      if (&gst_ignore_line($_)) { print $outfd $_; next; }
+      if (/^\s*\S*share\s+(.*)/) {
+	my $point, $type;
+        my $line = $1;
+        while($line =~ /\\$/) {
+          $_ = <$infd>;
+          s/\r|\n//g; s/#.*$//;
+          $line =~ s/\\$//;
+          $line .= $_;
+        }
+        if ($line =~ /\s-F\s+(\S+)/) { $type = $1; }
+        else { $type = "nfs"; }
+	return "share $line\n" if ($type eq "nfs");
+      }
+    } else {
+      my @line = split /[ \t]+/, $_;
+      if ($line[0] eq "") { shift @line; }
+      if (@line < 1 || &gst_ignore_line (@line)) { print $outfd $_; next; }
+      return $_;
+    }
   }
 
   return undef;
@@ -528,9 +639,20 @@
 
   for $client (@$clients)
   {
-    $line .= &gst_share_nfs_client_info_get_pattern ($client);
-    $line .= "(rw)" if (&gst_share_nfs_client_info_get_write ($client));
-    $line .= " ";
+    if ($$tool{"system"} eq "SunOS") {
+      if (&gst_share_nfs_client_info_get_pattern ($client) ne "") {
+        $line .= "," if (!$first);
+        if (&gst_share_nfs_client_info_get_write ($client)) { $line .= "rw="; 
+      }
+      else { $line .= "ro="; }
+        $line .= &gst_share_nfs_client_info_get_pattern ($client);
+      }
+      $first = 0;
+    } else {
+      $line .= &gst_share_nfs_client_info_get_pattern ($client);
+      $line .= "(rw)" if (&gst_share_nfs_client_info_get_write ($client));
+      $line .= " ";
+    }
   }
 
   return $line;
@@ -541,13 +663,19 @@
   my ($info) = @_;
   my $line;
 
-  # <point>
-
-  $line = sprintf ("%-15s ", &gst_share_nfs_info_get_point ($info));
-
-  # <clients>
-
-  $line .= &gst_share_nfs_info_print_clients ($info);
+  if ($$tool{"system"} eq "SunOS") {
+    $line = "share -F nfs ";
+    $line .= sprintf ("-o %s ", &gst_share_nfs_info_print_clients ($info))
+            if (&gst_share_nfs_info_print_clients ($info));
+    $line .= sprintf ("-d %s ", &gst_share_nfs_info_get_name ($info))
+	    if (&gst_share_nfs_info_get_name ($info));
+    $line .= sprintf ("%-15s ", &gst_share_nfs_info_get_point ($info));
+  } else {
+    # <point>
+    $line = sprintf ("%-15s ", &gst_share_nfs_info_get_point ($info));
+    # <clients>
+    $line .= &gst_share_nfs_info_print_clients ($info);
+  }
 
   return $line;
 }
@@ -583,66 +711,75 @@
   my $outline;
   my $ctable = &gst_share_nfs_info_get_client_table ($info);
 
-  # <point>
-
-  $outline = sprintf ("%-15s", &gst_share_nfs_info_get_point ($info));
-
-  # <clients>
-
-  chomp $line;
-  my @clients = split /[ \t]+/, $line;
-  shift @clients;
-
-  # Make client hash based on line.
-
-  my $chash = { };
-
-  for $client (@clients)
-  {
-    my $opthash = { };
-
-    $client =~ /^([a-zA-Z0-9.-_*?@\/]+)/;
-    my $pattern = $1;
-    $$chash{$pattern} = $opthash;
-
-    my $option_str = "";
-    if ($client =~ /\((.+)\)/) { $option_str = $1; }
-    @options = ($option_str =~ /([a-zA-Z0-9_=-]+),?/mg);
-
-    for $option (@options)
-    {
-      my ($key, $value) = split /[=]/, $option;
-      next if ($key eq "");
-
-      if ($value eq "" && $option =~ /=/) { $value = " "; }
-      $$opthash{$key} = $value;
-    }
-  }
-
-  # @clients contains client(options) entries.
-
-  for $cinfo (@$ctable)
-  {
-    my $pattern = &gst_share_nfs_client_info_get_pattern ($cinfo);
-    my $opthash = $$chash{$pattern};
-
-    if (&gst_share_nfs_client_info_get_write ($cinfo))
-    {
-      $$opthash{'rw'} = "";
-    }
-    else
+  if ($$tool{"system"} eq "SunOS") {
+    my $desc = "unknown";
+    if ($line =~ /-d\s+"([^"]+)"/) { $desc = $1; }
+    elsif ($line =~ /-d\s+(\S+)/) { $desc = $1; }
+    $desc =~ s/"//g; $desc =~ s/'//g;
+    &gst_share_nfs_info_set_name ($info, $desc);
+    $outline = &gst_share_nfs_info_print_entry ($info);
+  } else {
+    # <point>
+  
+    $outline = sprintf ("%-15s", &gst_share_nfs_info_get_point ($info));
+  
+    # <clients>
+  
+    chomp $line;
+    my @clients = split /[ \t]+/, $line;
+    shift @clients;
+  
+    # Make client hash based on line.
+  
+    my $chash = { };
+  
+    for $client (@clients)
     {
-      delete $$opthash{'rw'};
+      my $opthash = { };
+  
+      $client =~ /^([a-zA-Z0-9.-_*?@\/]+)/;
+      my $pattern = $1;
+      $$chash{$pattern} = $opthash;
+  
+      my $option_str = "";
+      if ($client =~ /\((.+)\)/) { $option_str = $1; }
+      @options = ($option_str =~ /([a-zA-Z0-9_=-]+),?/mg);
+  
+      for $option (@options)
+      {
+        my ($key, $value) = split /[=]/, $option;
+        next if ($key eq "");
+  
+        if ($value eq "" && $option =~ /=/) { $value = " "; }
+        $$opthash{$key} = $value;
+      }
     }
-
-    $outline .= " " . &gst_share_nfs_client_info_get_pattern ($cinfo);
-    my $client_string = &gst_share_nfs_client_print_option_hash ($opthash);
-    if ($client_string ne "")
+  
+    # @clients contains client(options) entries.
+  
+    for $cinfo (@$ctable)
     {
-      $outline .= "(" . $client_string . ")";
+      my $pattern = &gst_share_nfs_client_info_get_pattern ($cinfo);
+      my $opthash = $$chash{$pattern};
+  
+      if (&gst_share_nfs_client_info_get_write ($cinfo))
+      {
+        $$opthash{'rw'} = "";
+      }
+      else
+      {
+        delete $$opthash{'rw'};
+      }
+  
+      $outline .= " " . &gst_share_nfs_client_info_get_pattern ($cinfo);
+      my $client_string = &gst_share_nfs_client_print_option_hash ($opthash);
+      if ($client_string ne "")
+      {
+        $outline .= "(" . $client_string . ")";
+      }
     }
   }
-
+  
   return $outline;
 }
 
@@ -719,7 +856,11 @@
   my ($line) = @_;
   my $point;
 
-  ($point) = split /[ \t]+/, $line;
+  if ($$tool{"system"} eq "SunOS") {
+    if ($line =~ /\s+(\/\S+)/ || $line =~ /\s+(\/)/ || $line eq "/") { $point = $1; }
+  } else {
+    ($point) = split /[ \t]+/, $line;
+  }
   return $point;
 }
 
@@ -752,6 +893,11 @@
       &gst_share_nfs_exports_remove_entry ($file, $old_info);
     }
   } 
+
+  if ($$tool{"system"} eq "SunOS") {
+    &gst_file_run ("unshareall");
+    &gst_file_run ("/bin/sh $file");
+  }
 }