Browse Source

Initial version: parse the output of NLIST /T /C as a hierarchical hash

Frederic G. Marand 17 years ago
commit
73768d0316
1 changed files with 117 additions and 0 deletions
  1. 117 0
      lib/main.rb

+ 117 - 0
lib/main.rb

@@ -0,0 +1,117 @@
+# The source format is the one returned by the <code>RIGHTS <dir> /T /C</code>
+# command on a directory existing on a network drive accessible using a NetWare
+# client.
+#
+# This format should be available from NetWare 4.x to 6.5 at least. This script
+# has been created for NetWare 6.5 with the latest Win32 client as of 2009-07-01.
+# 
+
+# Load rights information from the text file generated by redirecting stdout
+# on the RIGHTS /T command
+class Loader
+
+  # The file from which to load
+  PATH = 'droits_h.txt'
+
+  attr_accessor :items
+
+  # Actually load the data. The format is a repeated pattern:
+  # - path line: volume:path
+  # - user|group|other (x) trustees
+  #   - "no (x) trustees have been assigned", or
+  #   - "(x) trustees:", then
+  #   - trustee lines: (trustee) (spaces) '[' (rights_vector) ']'
+  # - '----------'
+  # - the other (x) group(s) of trustees (group|user)
+  # - "\n"
+  def load_item_data
+    line_types = {
+      'path'         => { 'default' => 'trustee_head'},
+      'trustee_head' => { 'default' => 'trustee_row'},
+      'trustee_row'  => { 'default' => 'trustee_row', 'head' => 'trustee_head', 'path' => 'path'},
+      'separator'    => { 'default' => 'trustee_head'},
+      'empty'        => { 'default' => 'path'}
+    }
+
+    line_type = 'path'
+    @items = {}
+    path  = ''
+    trustee_type = 'invalid'
+    File.open(PATH) do |data_file|
+      data_file.readlines.each do |line|
+        line.chomp!
+        # puts "Line type: #{line_type}, value: (#{line})\n"
+        new_line_key = 'default'
+        case line_type
+          when 'path' then
+            path = line
+            items[path] = { 'user' => [], 'group' => [], 'other' => []}
+          #   puts "  New path: #{path}\n"
+          when 'trustee_head'
+          #   printf "    Checking trustee head (#{line}):"
+            case line
+              when /[uU]ser/ then
+                trustee_type = 'user'
+              when /[gG]roup/ then
+                trustee_type = 'group'
+              when /Other/ then
+                trustee_type = 'other'
+              else
+                trustee_type = 'invalid'
+            end # case line
+         #    puts "      Found type #{trustee_type}\n"
+          when 'trustee_row'
+            case line
+              when /----/ then
+                new_line_key = 'head'
+            when '' then
+                new_line_key = 'path'
+            else
+              # puts "    Adding #{trustee_type} trustee line to #{path}: #{line}\n"
+              pattern = / *(.*?) *\[(.*)\]/
+              matches = line.match pattern
+              #    p line if matches == nil
+              @items[path][trustee_type] << [ matches[1], matches[2] ]
+            end
+          when 'separator'
+            trustee_type = 'invalid'
+          when 'empty'
+            trustee_type = 'invalid'
+            path         = ''
+          else
+            raise "Invalid line type '#{line}'\n"
+        end
+        line_type = line_types[line_type][new_line_key]
+      end
+    end
+  end
+
+  def dump
+    @items.keys.sort.each do |path|
+      puts path
+      @items[path].keys.sort.each do |kind|
+        @items[path][kind].sort.each do |assignment|
+          printf("  %-6s|%8s|%s\n", kind, assignment[1], assignment[0])
+        end
+      end
+    end
+  end
+
+  # Loader "constructor"
+  def initialize
+    self.load_item_data
+  end
+
+end
+
+# Main class for the TBackup utility
+class Main
+
+  # Main "constructor"
+  def initialize
+    loader = Loader.new
+    loader.dump
+  end
+end
+
+Main.new

PANIC: session(release): write data/sessions/7/c/7c572236582de5c4: no space left on device

PANIC

session(release): write data/sessions/7/c/7c572236582de5c4: no space left on device
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/session@v1.0.3/session.go:204 (0xb13e07)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:80 (0x967b75)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:157 (0x9512ee)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:135 (0x951205)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:124 (0x967cc4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:114 (0x967bf6)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/recovery.go:161 (0x15baec4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/logger.go:40 (0x96b257)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:157 (0x9512ee)
/my/cache/.heroku/go/go-path/pkg/mod/github.com/go-macaron/inject@v0.0.0-20200308113650-138e5925c53b/inject.go:135 (0x951205)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/context.go:124 (0x967cc4)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/router.go:187 (0x972959)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/router.go:304 (0x973a01)
/my/cache/.heroku/go/go-path/pkg/mod/gopkg.in/macaron.v1@v1.5.1/macaron.go:218 (0x96c572)
/my/cache/.heroku/go/go1.26.3/go/src/net/http/server.go:3311 (0x85a5cd)
/my/cache/.heroku/go/go1.26.3/go/src/net/http/server.go:2073 (0x837f6f)
/my/cache/.heroku/go/go1.26.3/go/src/runtime/asm_amd64.s:1771 (0x493380)