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: cd0c687ec00e4bbade36961ede


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone: cd0c687ec00e4bbade36961ede4cc3f9bf1ec294
Date: Tue, 18 Jan 2011 15:25:29 GMT

revision:            cd0c687ec00e4bbade36961ede4cc3f9bf1ec294
date:                2011-01-18T15:25:06
author:              Richard Levitte <address@hidden>
branch:              net.venge.monotone
changelog:
Following the example from get_netsync_(read|write)_permitted, have
get_remote_automate_permitted process both the file remote-automate-permissions
and the files in the subdirectory remote-automate-permissions.d/

manifest:
format_version "1"

new_manifest [6b50df20d199e1a427df1b376250972361181b11]

old_revision [38d30a2c8d2e6193a637a3397d198656dd2b09be]

patch "contrib/authorize_remote_automate.lua"
 from [9d6f81a90c85dcb1a566755ce5a04d5ba2c23d2a]
   to [a6b785023719249109eac24a91a64d93f3674f94]
============================================================
--- contrib/authorize_remote_automate.lua	9d6f81a90c85dcb1a566755ce5a04d5ba2c23d2a
+++ contrib/authorize_remote_automate.lua	a6b785023719249109eac24a91a64d93f3674f94
@@ -30,16 +30,12 @@ do
       _safe_commands = ARA_safe_commands
    end
 
-   local _save_get_remote_automate_permitted = get_remote_automate_permitted
-   function get_remote_automate_permitted(key_identity, command, options)
-      local permfile =
-	 io.open(get_confdir() .. "/remote-automate-permissions", "r")
+   function _get_remote_automate_permitted(key_identity, 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
-
-      -- See if the incoming key matches any of the key identities or
-      -- patterns found in the permissions file.
       local matches = false
       local line = permfile:read()
       while (not matches and line ~= nil) do
@@ -52,8 +48,28 @@ do
 	 end
       end
       io.close(permfile)
-      if matches then return true end
+      return matches
+   end
 
+   local _save_get_remote_automate_permitted = get_remote_automate_permitted
+   function get_remote_automate_permitted(key_identity, command, options)
+      local permfilename = get_confdir() .. "/remote-automate-permissions"
+      local permdirname = permfilename .. ".d"
+
+      -- See if the incoming key matches any of the key identities or
+      -- patterns found in the permissions file.
+      if _get_remote_automate_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_remote_automate_permitted(ident, pf) then return true end
+	 end
+      end
+
       -- No matching key found, let's see if the command matches one the
       -- admin allowed to be performed anonymously
       for _,v in ipairs(_safe_commands) do

reply via email to

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