monotone-commits-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-commits-diffs] net.venge.monotone: dd63dfe52e8c18fe1f0a48cf5d


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone: dd63dfe52e8c18fe1f0a48cf5d9f82ec712dbe70
Date: Sat, 1 Jan 2011 19:32:35 GMT

revision:            dd63dfe52e8c18fe1f0a48cf5d9f82ec712dbe70
date:                2011-01-01T19:31:53
author:              Richard Levitte <address@hidden>
branch:              net.venge.monotone
changelog:
propagate from branch 'net.venge.monotone.levitte.permissions-directories' 
(head 9696ace0310a6be09f779637f6388c8ca49ea1c0)
            to branch 'net.venge.monotone' (head 
e362bb1d496c9528de713bbf42b2d9755fff4671)

manifest:
format_version "1"

new_manifest [2d0622873d69ef2512ea02a46681b2a3fa6dd04f]

old_revision [9696ace0310a6be09f779637f6388c8ca49ea1c0]

patch "INSTALL"
 from [b617e97515ceb80b13f01c5e2f00ccc6fb11aec9]
   to [f273e5a0e29dbebf4d5ff71909d61b4dd616dd7a]

patch "monotone.texi"
 from [ba72de0b6fa7910773f053127a6b9c631fc64e68]
   to [e9588fb6725cf73f9e894164f1b3573dc5f1430d]

patch "po/sv.po"
 from [60090cb2c4d91b782a50e3b83c78ff8f31a578ee]
   to [bb39ba476f5d0e053d07773116b7869ed3841ea2]

old_revision [e362bb1d496c9528de713bbf42b2d9755fff4671]

rename "tests/netsync_permissions/closed/write-permissions"
    to "tests/netsync_permissions/closed/write-permissions.d/tester"

add_dir "tests/netsync_permissions/closed/read-permissions.d"

add_dir "tests/netsync_permissions/closed/write-permissions.d"

add_file "tests/netsync_permissions/closed/read-permissions.d/tester"
 content [b9bae8e35f085049ddfa0cfe92308a79998ad6d0]

patch "NEWS"
 from [7216d7870a01f5caaa0f309482d269d9345f3c38]
   to [1e1359c5cd7ef37431ad77f27d952639754d2b8c]

patch "luaext_platform.cc"
 from [b22b5f7fa127055e909280379694c1635f4923ff]
   to [288a571d7c91fbb4abffb66611b52aac74889aa2]

patch "monotone.texi"
 from [ab28c929743895e228543d6b1ddbc1be5115f9e6]
   to [e9588fb6725cf73f9e894164f1b3573dc5f1430d]

patch "std_hooks.lua"
 from [c97901eafc09c1ae80f7f33425761c1ea06a6929]
   to [b1a61ba83a6e8c0c9d72393aaf0e86089b75464d]

patch "tester.cc"
 from [adb12440ea0b944027ea7f8eb35e06acbce2bcce]
   to [969901c130b3d7701a780802dbc73061bafbe57d]

patch "tests/netsync_permissions/__driver__.lua"
 from [a0632f717c1fff69661ccc56516bcae93e3b3de8]
   to [8a675ebd2b67064a295f5143b2159580d1028ac9]

patch "tests/netsync_permissions/closed/read-permissions"
 from [2164855b160ba5bfa19257d29dc4e820becc5459]
   to [eff21031c117b085855d3a6220dfb95f3e000efa]
============================================================
--- monotone.texi	ba72de0b6fa7910773f053127a6b9c631fc64e68
+++ monotone.texi	e9588fb6725cf73f9e894164f1b3573dc5f1430d
@@ -6859,51 +6859,9 @@ @section Automation
 also give useful chatter on @code{stderr}, including warnings and error
 messages.
 
address@hidden @code{basic_io} Format
+Many commands produce output in a format called basic_io, for more
+information, @pxref{Formats}.
 
-Many commands produce output in a format called basic_io. At the most basic
-level this is a stream of three token types, separated by whitespace; a
address@hidden matches @code{/[a-z_]+/} (a word consisting of lowercase letters
-and underscores), a @code{string} matches @code{/"([^\\]|\\\\|\\")*"/} (a pair
-of double-quotes containing arbitrary characters, with only backslash and
-double-quote escaped with a backslash), and a @code{hex} matches
address@hidden/address@hidden@}\]/} (40 lowercase hex digits enclosed by square
-brackets; this will necessarily change in some manner when we eventually move
-to a stronger hash than sha1). Each @code{symbol} is followed by zero or more
address@hidden and/or @code{hex}es.
-
-While the above is all that is strictly necessary to parse basic_io, there is
-some formatting of the stream which may be helpful when parsing and is required
-(but not always verified) when producing basic_io for consumption by monotone:
address@hidden
address@hidden
-Each @code{symbol} begins a new line.
address@hidden
-Tokens on the same line are separated by a single space.
address@hidden
-Lines are grouped into logical @code{stanza}s, separated by a single empty line.
-Each stanza then describes a particular item, with the different lines
-(@code{symbol}s followed by @code{string} and @code{hex} values) describing
-different aspects of that item.
address@hidden
address@hidden in a stanza are right-aligned with each other; each @code{symbol}
-other than the longest is preceeded by spaces. The longest @code{symbol} in a
-stanza is not preceeded by spaces, even if there are longer @code{symbol}s in
-other stanzas.
address@hidden
-Lines within stanzas have a consistent order, although some may be
-optional in some commands.
address@hidden
-Stanzas typically have no defined order, although some commands define
-a partial order to aid in parsing.
-
-For example, revisions have associated data; the structure is header
-stanzas followed by a list of changes vs. each parent revision, with
-each change represented by a separate stanza; reordering the stanzas
-could cause a particular change to be interpreted against the wrong
-parent.
address@hidden itemize
-
 @subsection Automation Commands
 
 @ftable @command
@@ -8223,7 +8181,7 @@ @subsection Automation Commands
 
 @end table
 
address@hidden mtn automate stdio
address@hidden@item mtn automate stdio
 
 @table @strong
 @item Arguments:
@@ -11090,7 +11048,88 @@ @section GIT
 @end ftable
 
 
address@hidden    Lua Reference, Special Topics, Command Reference, Top
address@hidden    Formats, Lua Reference, Command Reference, Top
address@hidden Formats
+
+Monotone uses two well defined formats to output or to accept input of
+data (mostly structured), @code{basic_io} and @code{stdio}.
address@hidden is often used to represent data or for configuration,
+while @code{stdio} is used for communication with @code{automate stdio}.
+
+The @code{stdio} format is not described here.  For information on it,
+please @pxref{mtn-au-stdio,,@code{mtn automate stdio}}.
+
address@hidden @code{basic_io} Format
+
address@hidden is a very simple format, yet expressive, and can be
+described with the following ABNF (see RFC 2234) specification:
+
address@hidden
address@hidden
+basic_io = *( item )
+
+    item = *sp symbol *sp *( string / hexid ) *sp
+           ; a symbol followed by zero or more strings and/or hexes.
+
+  symbol = 1*( lcalpha / "_" )
+           ; One or more letters or underscores.
+  string = DQUOTE *( charnqnb / "\" "\" / "\" DQUOTE ) DQUOTE
+           ; A series of any character, enclosed with double quotes
+           ; To include a double quote or a backslash in the string,
+           ; escape it with a backslash.
+   hexid = "[" 40HEXDIG "]"
+           ; 40 hexadecimal characters enclosed in brackets.
+           ; Note: the amount might change as we move away from sha1.
+
+      sp = ( WSP CR LF )
+charnqnb = %x01-21 / %x23-5B / %x5D-FF
+           ; All characters except NUL (%x00) , " (%x22) and \ (%x5C).
+ lcalpha = %x61-7A
+           ; Lower case a-z.
address@hidden verbatim
address@hidden display
+
+In essence, it's a stream of items, where each item is a @code{symbol}
+followed by zero or more @code{string}s and @code{hex}es.
+
+There is an idea of stanzas, which is a group of items that logically
+belongs together.  However, stanzas aren't defined in the
address@hidden syntax, and are instead defined in terms of order and
+sequence for what symbols may be part of the stream, how they may
+appear, and how many and what arguments should follow them.  This is
+defined by each command or program using this format.
+
+For example, revisions have associated data; the structure is header
+stanzas followed by a list of changes vs. each parent revision, with
+each change represented by a separate stanza; reordering the stanzas
+could cause a particular change to be interpreted against the wrong
+parent.
+
+Another example is the @file{read-permissions} file that's read by the
+default definition of the @code{get_netsync_read_permitted} lua hook.
+
+Monotone will format its output in @code{basic_io} as follows:
address@hidden
address@hidden
+Each @code{symbol} begins a new line.
address@hidden
+Tokens on the same line are separated by a single space.
address@hidden
+Lines are grouped into logical @code{stanza}s, separated by a single empty line.
+Each stanza then describes a particular item, with the different lines
+(@code{symbol}s followed by @code{string} and @code{hex} values) describing
+different aspects of that item.
address@hidden
address@hidden in a stanza are right-aligned with each other; each @code{symbol}
+other than the longest is preceeded by spaces. The longest @code{symbol} in a
+stanza is not preceeded by spaces, even if there are longer @code{symbol}s in
+other stanzas.
address@hidden
+Lines within stanzas have a consistent order, although some may be
+optional in some commands.
address@hidden itemize
+
address@hidden    Lua Reference, Special Topics, Formats, Top
 @chapter Lua Reference
 
 Monotone makes use of the @uref{http://www.lua.org, Lua} programming
============================================================
--- INSTALL	b617e97515ceb80b13f01c5e2f00ccc6fb11aec9
+++ INSTALL	f273e5a0e29dbebf4d5ff71909d61b4dd616dd7a
@@ -56,7 +56,14 @@ 1. prerequisites:
              autoconf automake gettext boost boost-devel zlib zlib-devel
              lua lua-devel pcre pcre-devel sqlite sqlite-devel libidn
              libidn-devel gcc-c++ texinfo texinfo-tex botan botan-devel
+ 
+        on openSUSE:
 
+            install the following extra packages with YaST or zypper:
+              autoconf automake gettext-tools gcc-g++ boost-devel zlib-devel
+              libbotan-devel sqlite3-dev pcre-devel lua-devel libidn-devel
+              libbz2-devel texinfo make
+
         on Mac OS X:
 
            use MacPorts (http://www.macports.org) to install the following
============================================================
--- po/sv.po	60090cb2c4d91b782a50e3b83c78ff8f31a578ee
+++ po/sv.po	bb39ba476f5d0e053d07773116b7869ed3841ea2
@@ -155,7 +155,7 @@ msgstr ""
 "Project-Id-Version: monotone 0.26pre1\n"
 "Report-Msgid-Bugs-To: address@hidden"
 "POT-Creation-Date: 2010-11-27 16:55+0100\n"
-"PO-Revision-Date: 2010-11-28 06:39+0100\n"
+"PO-Revision-Date: 2010-12-03 09:16+0100\n"
 "Last-Translator: Joel Rosdahl <address@hidden>\n"
 "Language-Team: Richard Levitte <address@hidden>\n"
 "Language: \n"
@@ -1461,9 +1461,7 @@ msgid "public or private key '%s' does n
 #: cmd_key_cert.cc:160
 #, c-format
 msgid "public or private key '%s' does not exist in keystore or database"
-msgstr ""
-"den publika eller privata nyckeln '%s' finns inte i nyckellager eller\n"
-"databas"
+msgstr "den publika eller privata nyckeln '%s' finns inte i nyckellager eller databas"
 
 #: cmd_key_cert.cc:163
 #, c-format
@@ -1515,9 +1513,7 @@ msgid ""
 msgid ""
 "Creates a certificate with the given name and value on each revision that "
 "matches the given selector"
-msgstr ""
-"Skapar ett certifikat med givna namn och värde för verja revision som\n"
-"motsvarar den givna väljaren"
+msgstr "Skapar ett certifikat med givna namn och värde för verja revision som motsvarar den givna väljaren"
 
 #: cmd_key_cert.cc:300
 msgid "REVISION NAME VALUE SIGNER1 [SIGNER2 [...]]"
@@ -2253,9 +2249,7 @@ msgid ""
 msgid ""
 "Deletes all certs which are on the given revision(s) and have the given name "
 "and if a value is specified then also the given value."
-msgstr ""
-"Tar bort alla certifikat med givet namn och eventuellt givet värde\n"
-"från givna revisioner."
+msgstr "Tar bort alla certifikat med givet namn och eventuellt givet värde från givna revisioner."
 
 #: cmd_db.cc:319
 msgid "Does some sanity checks on the database"
============================================================
--- NEWS	7216d7870a01f5caaa0f309482d269d9345f3c38
+++ NEWS	1e1359c5cd7ef37431ad77f27d952639754d2b8c
@@ -16,6 +16,11 @@ XXX XXX XX XX:XX:XX UTC 2010
           Steve Petruzzello <address@hidden> for the outstanding
           work!
 
+        - get_netsync_(read|write)_permitted have been extended to not
+          only read the files read-permissions and write-permissions,
+          but also the files in the subdirectories read-permissions.d
+          and write-permissions.d.
+
         New Features
 
         - 'mtn conflicts store' now outputs a count of the conflicts,
============================================================
--- monotone.texi	ab28c929743895e228543d6b1ddbc1be5115f9e6
+++ monotone.texi	e9588fb6725cf73f9e894164f1b3573dc5f1430d
@@ -11664,8 +11664,11 @@ @subsection Netsync Permission Hooks
 Returns @code{true} if a peer authenticated as key @var{key_identity}
 should be allowed to read from your database certs, revisions,
 manifests, and files associated with @var{branch}; otherwise @code{false}.
-The default definition of this hook reads a file @file{read-permissions} in
-the configuration directory. This file looks like
+The default definition of this hook reads a file @file{read-permissions}
+and all files in the subdirectory @file{read-permissions.d} in the
+configuration directory. All the files are treated as if they were one
+file, with @file{read-permissions} first followed by the files in
address@hidden in alphanumerical order. The files look like
 @smallexample
 @group
 pattern "address@hidden,address@hidden"
@@ -11702,11 +11705,13 @@ @subsection Netsync Permission Hooks
 
 @item get_netsync_write_permitted (@var{key_identity})
 
-Returns @code{true} if a peer authenticated as key @var{key_identity} should
-be allowed to write into your database certs, revisions, manifests, and
-files; otherwise @code{false}. The default definition of this hook reads a file
address@hidden in the configuration directory which contains a list
-of key hashes or local key names, one per line, which are allowed write access.
+Returns @code{true} if a peer authenticated as key @var{key_identity}
+should be allowed to write into your database certs, revisions,
+manifests, and files; otherwise @code{false}. The default definition of
+this hook reads a file @file{write-permissions} and all files in the
+subdirectory @file{write-permissions.d} in the configuration directory
+which contains a list of key hashes or local key names, one per line,
+which are allowed write access.
 The special value
 @code{*} means to allow access to anyone whose public key we already have.
 
============================================================
--- std_hooks.lua	c97901eafc09c1ae80f7f33425761c1ea06a6929
+++ std_hooks.lua	b1a61ba83a6e8c0c9d72393aaf0e86089b75464d
@@ -1078,46 +1078,51 @@ end
       end
 end
 
-function get_netsync_read_permitted(branch, ident)
-   local permfile = io.open(get_confdir() .. "/read-permissions", "r")
+function _get_netsync_read_permitted(branch, ident, permfilename, state)
+   if not exists(permfilename) or isdir(permfilename) then
+      return false
+   end
+   local permfile = io.open(permfilename, "r")
    if (permfile == nil) then return false end
    local dat = permfile:read("*a")
    io.close(permfile)
    local res = parse_basic_io(dat)
    if res == nil then
-      io.stderr:write("file read-permissions cannot be parsed\n")
-      return false
+      io.stderr:write("file "..permfilename.." cannot be parsed\n")
+      return false,"continue"
    end
-   local matches = false
-   local cont = false
+   state["matches"] = state["matches"] or false
+   state["cont"] = state["cont"] or false
    for i, item in pairs(res)
    do
       -- legal names: pattern, allow, deny, continue
       if item.name == "pattern" then
-         if matches and not cont then return false end
-         matches = false
-         cont = false
+         if state["matches"] and not state["cont"] then return false end
+         state["matches"] = false
+         state["cont"] = false
          for j, val in pairs(item.values) do
-            if globish_match(val, branch) then matches = true end
+            if globish_match(val, branch) then state["matches"] = true end
          end
-      elseif item.name == "allow" then if matches then
+      elseif item.name == "allow" then if state["matches"] then
          for j, val in pairs(item.values) do
             if val == "*" then return true end
             if val == "" and ident == nil then return true end
             if ident ~= nil and val == ident.id then return true end
             if ident ~= nil and globish_match(val, ident.name) then return true end
          end
-      end elseif item.name == "deny" then if matches then
+      end elseif item.name == "deny" then if state["matches"] then
          for j, val in pairs(item.values) do
             if val == "*" then return false end
             if val == "" and ident == nil then return false end
             if ident ~= nil and val == ident.id then return false end
             if ident ~= nil and globish_match(val, ident.name) then return false end
          end
-      end elseif item.name == "continue" then if matches then
-         cont = true
+      end elseif item.name == "continue" then if state["matches"] then
+         state["cont"] = true
          for j, val in pairs(item.values) do
-            if val == "false" or val == "no" then cont = false end
+            if val == "false" or val == "no" then 
+	       state["cont"] = false
+	    end
          end
       end elseif item.name ~= "comment" then
          io.stderr:write("unknown symbol in read-permissions: " .. item.name .. "\n")
@@ -1127,8 +1132,29 @@ end
    return false
 end
 
-function get_netsync_write_permitted(ident)
-   local permfile = io.open(get_confdir() .. "/write-permissions", "r")
+function get_netsync_read_permitted(branch, ident)
+   local permfilename = get_confdir() .. "/read-permissions"
+   local permdirname = permfilename .. ".d"
+   local state = {}
+   if _get_netsync_read_permitted(branch, ident, permfilename, state) then
+      return true
+   end
+   if isdir(permdirname) then
+      local files = read_directory(permdirname)
+      table.sort(files)
+      for _,f in ipairs(files) do
+	 pf = permdirname.."/"..f
+	 if _get_netsync_read_permitted(branch, ident, pf, state) then
+	    return true
+	 end
+      end
+   end
+   return false
+end
+
+function _get_netsync_write_permitted(ident, permfilename)
+   if not exists(permfilename) or isdir(permfilename) then return false end
+   local permfile = io.open(permfilename, "r")
    if (permfile == nil) then
       return false
    end
@@ -1145,6 +1171,21 @@ end
    return matches
 end
 
+function get_netsync_write_permitted(ident)
+   local permfilename = get_confdir() .. "/write-permissions"
+   local permdirname = permfilename .. ".d"
+   if _get_netsync_write_permitted(ident, permfilename) then return true end
+   if isdir(permdirname) then
+      local files = read_directory(permdirname)
+      table.sort(files)
+      for _,f in ipairs(files) do
+	 pf = permdirname.."/"..f
+	 if _get_netsync_write_permitted(ident, pf) then return true end
+      end
+   end
+   return false
+end
+
 -- This is a simple function which assumes you're going to be spawning
 -- a copy of mtn, so reuses a common bit at the end for converting
 -- local args into remote args. You might need to massage the logic a
============================================================
--- tester.cc	adb12440ea0b944027ea7f8eb35e06acbce2bcce
+++ tester.cc	969901c130b3d7701a780802dbc73061bafbe57d
@@ -313,22 +313,6 @@ LUAEXT(copy_recursive, )
     }
 }
 
-LUAEXT(mkdir, )
-{
-  try
-    {
-      char const * dirname = luaL_checkstring(LS, -1);
-      do_mkdir(dirname);
-      lua_pushboolean(LS, true);
-      return 1;
-    }
-  catch(recoverable_failure & e)
-    {
-      lua_pushnil(LS);
-      return 1;
-    }
-}
-
 LUAEXT(make_temp_dir, )
 {
   try
@@ -367,88 +351,6 @@ LUAEXT(mtime, )
     }
 }
 
-LUAEXT(exists, )
-{
-  try
-    {
-      char const * name = luaL_checkstring(LS, -1);
-      switch (get_path_status(name))
-        {
-        case path::nonexistent:  lua_pushboolean(LS, false); break;
-        case path::file:
-        case path::directory:    lua_pushboolean(LS, true); break;
-        }
-    }
-  catch(recoverable_failure & e)
-    {
-      lua_pushnil(LS);
-    }
-  return 1;
-}
-
-LUAEXT(isdir, )
-{
-  try
-    {
-      char const * name = luaL_checkstring(LS, -1);
-      switch (get_path_status(name))
-        {
-        case path::nonexistent:
-        case path::file:         lua_pushboolean(LS, false); break;
-        case path::directory:    lua_pushboolean(LS, true); break;
-        }
-    }
-  catch(recoverable_failure & e)
-    {
-      lua_pushnil(LS);
-    }
-  return 1;
-}
-
-namespace
-{
-  struct build_table : public dirent_consumer
-  {
-    build_table(lua_State * st) : st(st), n(1)
-    {
-      lua_newtable(st);
-    }
-    virtual void consume(const char *s)
-    {
-      lua_pushstring(st, s);
-      lua_rawseti(st, -2, n);
-      n++;
-    }
-  private:
-    lua_State * st;
-    unsigned int n;
-  };
-}
-
-LUAEXT(read_directory, )
-{
-  int top = lua_gettop(LS);
-  try
-    {
-      string path(luaL_checkstring(LS, -1));
-      build_table tbl(LS);
-
-      read_directory(path, tbl, tbl, tbl);
-    }
-  catch(recoverable_failure &)
-    {
-      // discard the table and any pending path element
-      lua_settop(LS, top);
-      lua_pushnil(LS);
-    }
-  catch (...)
-    {
-      lua_settop(LS, top);
-      throw;
-    }
-  return 1;
-}
-
 LUAEXT(get_source_dir, )
 {
   lua_pushstring(LS, source_dir.c_str());
============================================================
--- tests/netsync_permissions/__driver__.lua	a0632f717c1fff69661ccc56516bcae93e3b3de8
+++ tests/netsync_permissions/__driver__.lua	8a675ebd2b67064a295f5143b2159580d1028ac9
@@ -116,13 +116,13 @@ check(get("closed"))
 check(get("closed"))
 
 -- setup by-hash line in permissions files
-writeperm = readfile("closed/write-permissions")
-writeperm = writeperm .. byhash_hash .. "\n"
-writefile("closed/write-permissions", writeperm)
+writefile("closed/write-permissions.d/tester-by-hash", byhash_hash.."\n")
 
-readperm = readfile("closed/read-permissions")
-readperm = readperm .. 'allow "' .. byhash_hash .. '"\n'
-writefile("closed/read-permissions", readperm)
+readperm = readfile("closed/read-permissions.d/tester")
+readperm = readperm .. 'continue "yes"\n'
+writefile("closed/read-permissions.d/tester", readperm)
+writefile("closed/read-permissions.d/tester-by-hash",
+       'pattern "*"\nallow "' .. byhash_hash .. '"\n')
 
 -- general setup
 clean()
============================================================
--- tests/netsync_permissions/closed/read-permissions	2164855b160ba5bfa19257d29dc4e820becc5459
+++ tests/netsync_permissions/closed/read-permissions	eff21031c117b085855d3a6220dfb95f3e000efa
@@ -1,5 +1,2 @@ deny "*"
 pattern "badbranch"
 deny "*"
-
-pattern "*"
-allow "address@hidden"
============================================================
--- luaext_platform.cc	b22b5f7fa127055e909280379694c1635f4923ff
+++ luaext_platform.cc	288a571d7c91fbb4abffb66611b52aac74889aa2
@@ -14,7 +14,9 @@
 #include <cstdlib>
 
 #include "platform.hh"
+#include "sanity.hh"
 
+using std::string;
 using std::malloc;
 using std::free;
 
@@ -185,6 +187,106 @@ LUAEXT(get_pid, )
   return 1;
 }
 
+// fs extensions
+
+LUAEXT(mkdir, )
+{
+  try
+    {
+      char const * dirname = luaL_checkstring(LS, -1);
+      do_mkdir(dirname);
+      lua_pushboolean(LS, true);
+      return 1;
+    }
+  catch(recoverable_failure & e)
+    {
+      lua_pushnil(LS);
+      return 1;
+    }
+}
+
+LUAEXT(exists, )
+{
+  try
+    {
+      char const * name = luaL_checkstring(LS, -1);
+      switch (get_path_status(name))
+        {
+        case path::nonexistent:  lua_pushboolean(LS, false); break;
+        case path::file:
+        case path::directory:    lua_pushboolean(LS, true); break;
+        }
+    }
+  catch(recoverable_failure & e)
+    {
+      lua_pushnil(LS);
+    }
+  return 1;
+}
+
+LUAEXT(isdir, )
+{
+  try
+    {
+      char const * name = luaL_checkstring(LS, -1);
+      switch (get_path_status(name))
+        {
+        case path::nonexistent:
+        case path::file:         lua_pushboolean(LS, false); break;
+        case path::directory:    lua_pushboolean(LS, true); break;
+        }
+    }
+  catch(recoverable_failure & e)
+    {
+      lua_pushnil(LS);
+    }
+  return 1;
+}
+
+namespace
+{
+  struct build_table : public dirent_consumer
+  {
+    build_table(lua_State * st) : st(st), n(1)
+    {
+      lua_newtable(st);
+    }
+    virtual void consume(const char *s)
+    {
+      lua_pushstring(st, s);
+      lua_rawseti(st, -2, n);
+      n++;
+    }
+  private:
+    lua_State * st;
+    unsigned int n;
+  };
+}
+
+LUAEXT(read_directory, )
+{
+  int top = lua_gettop(LS);
+  try
+    {
+      string path(luaL_checkstring(LS, -1));
+      build_table tbl(LS);
+
+      read_directory(path, tbl, tbl, tbl);
+    }
+  catch(recoverable_failure &)
+    {
+      // discard the table and any pending path element
+      lua_settop(LS, top);
+      lua_pushnil(LS);
+    }
+  catch (...)
+    {
+      lua_settop(LS, top);
+      throw;
+    }
+  return 1;
+}
+
 // Local Variables:
 // mode: C++
 // fill-column: 76
============================================================
--- /dev/null	
+++ tests/netsync_permissions/closed/read-permissions.d/tester	b9bae8e35f085049ddfa0cfe92308a79998ad6d0
@@ -0,0 +1,2 @@
+pattern "*"
+allow "address@hidden"

reply via email to

[Prev in Thread] Current Thread [Next in Thread]