--------------------------------
% cat .users
# This file needs to be gpg signed by a key whose fingerprint
-# is listed in ~/.pws-trusted-users
+# is listed in ~/.pws.yaml
formorer = 6E3966C1E1D15DB973D05B491E45F8CA9DE23B16
weasel = 25FC1614B8F87B52FF2F99B962AF4031C82E0039
re-encrypt data to the wrong key - the .users file needs to be
PGP-clearsigned with a key from a whitelist.
-This whitelist lives in ~/.pws-trusted-users, and simply takes one
-key fingerprint per line:
+This whitelist lives in ~/.pws.yaml under the trusted_users key and
+then under the directory name. A sample file looks like:
---------------------------------
-% cat ~/.pws-trusted-users
-#formorer
-6E3966C1E1D15DB973D05B491E45F8CA9DE23B16
+aliases:
+ debian:
+ - &tfheen A28411A596193171331802C0B65A4871CA19D717
+ - &weasel 25FC1614B8F87B52FF2F99B962AF4031C82E0039
+
+trusted_users:
+ "~/.pws":
+ - *tfheen
+ "~/debian/dsa-passwords":
+ - *tfheen
+ - *weasel
---------------------------------
-Currently this whitelist is the same for any pws repositories a user
-might have. A patch to remove this limitation would be nice.
-
-
adding a new file
-----------------
GROUP_PATTERN = "@[a-zA-Z0-9-]+"
USER_PATTERN = "[a-zA-Z0-9:-]+"
$program_name = File.basename($0, '.*')
+CONFIG_FILE = ENV['HOME']+ "/.pws.yaml"
$editor = ENV['EDITOR']
if $editor == nil
def initialize(dirname=".", trusted_users=nil)
@dirname = dirname
if trusted_users
- @trusted_users = trusted_users
+ @trusted_users = load_trusted_users(trusted_users)
+ elsif FileTest.exists?(CONFIG_FILE)
+ t = {}
+ begin
+ yaml = YAML::load_file(CONFIG_FILE)
+ yaml["trusted_users"].each do |k,v|
+ t[File.expand_path(k)] = v
+ end
+ @trusted_users = t[File.expand_path(dirname)]
+ if @trusted_users.nil?
+ raise ("Could not find #{File.expand_path(dirname)} in configuration file #{CONFIG_FILE}")
+ end
+ rescue Psych::SyntaxError, ArgumentError => e
+ raise("Could not parse YAML: #{e.message}")
+ end
else
- @trusted_users = ENV['HOME']+'/.pws-trusted-users'
+ @trusted_users = load_trusted_users(ENV['HOME']+'/.pws-trusted-users')
end
parse_file
expand_groups
end
- def verify(content)
+ def load_trusted_users(trusted_users_file)
begin
- f = File.open(@trusted_users)
+ f = File.open(trusted_users_file)
rescue Exception => e
raise e
end
trusted.push line
end
+ trusted
+ end
+
+ def verify(content)
args = []
args.push "--keyring=./.keyring" if FileTest.exists?(".keyring")
raise "Not goodsig"
end
- if not trusted.include?(validsig)
+ if not @trusted_users.include?(validsig)
raise ".users file is signed by #{validsig} which is not in #{@trusted_users}"
end