summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/meta-check41
-rwxr-xr-xbin/meta-normalize-stdio171
-rwxr-xr-xbin/pgp-get-keyid-by-uid5
-rwxr-xr-xbin/pgp-list-keyids28
-rwxr-xr-xbin/postfix-generate-virtual-map21
-rwxr-xr-xbin/ssh-list-authorized-keys30
-rwxr-xr-xbin/uid-map10
7 files changed, 0 insertions, 306 deletions
diff --git a/bin/meta-check b/bin/meta-check
deleted file mode 100755
index 16994ce..0000000
--- a/bin/meta-check
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/bash
-
-. libremessages
-
-PATH="$(dirname "$0"):$PATH"
-
-check-yaml() {
- file=$1
- msg 'Inspecting %q' "$file"
- norm=$(mktemp --tmpdir)
- trap "rm -f -- $(printf '%q' "$norm")" RETURN
- meta-normalize-stdio < "$file" > "$norm" || return $?
- colordiff -u "$file" "$norm" || return $?
-}
-
-main() {
- declare -i ret=0
-
- # Check the user YAML files
- for file in users/*.yml; do
- check-yaml "$file" || ret=$?
- done
-
- msg 'Checking for duplicate usernames'
- dups=($(sed -n 's/^username: //p' -- users/*.yml| sort | uniq -d))
- if (( ${#dups[@]} )); then
- error 'Duplicate usernames:'
- plain '%s' "${dups[@]}"
- ret=1
- fi
-
- msg 'Checking PGP keys'
- if pgp-list-keyids | grep -Ev '^(trusted|secondary|revoked)/[a-z][a-z0-9-]* [0-9A-F]{40}$'; then
- error 'Bad pgp keys ^^^'
- ret=1
- fi
-
- return $ret
-}
-
-main "$@"
diff --git a/bin/meta-normalize-stdio b/bin/meta-normalize-stdio
deleted file mode 100755
index 5611ae6..0000000
--- a/bin/meta-normalize-stdio
+++ /dev/null
@@ -1,171 +0,0 @@
-#!/usr/bin/env ruby
-
-# First we define a bunch of code-generators, then at the end is a
-# very neat and readable definition of the format of the YAML files.
-
-require 'yaml'
-
-def error(msg)
- $stderr.puts "ERROR: #{msg}"
- @err = 1
-end
-
-def warning(msg)
- $stderr.puts "WARNING: #{msg}"
-end
-
-
-# Generic validators/formatters
-
-def semiordered_list(cnt, validator)
- lambda {|name,ary|
- if ary.class != Array
- error "`#{name}' must be a list"
- else
- ary.each_index{|i| ary[i] = validator.call("#{name}[#{i}]", ary[i])}
- ary = ary.first(cnt).concat(ary.last(ary.count-cnt).sort)
- end
- ary
- }
-end
-
-def unordered_list(validator)
- semiordered_list(0, validator)
-end
-
-def _unknown(map_name, key)
- error "Unknown item: #{map_name}[#{key.inspect}]"
- 0
-end
-def unordered_map1(validator)
- lambda {|name,hash|
- if hash.class != Hash
- error "`#{name}' must be a map"
- else
- order = Hash[[*validator.keys.map.with_index]]
- hash = Hash[hash.sort_by{|k,v| order[k] || _unknown(name,k) }]
- hash.keys.each{|k|
- if validator[k]
- hash[k] = validator[k].call("#{name}[#{k.inspect}]", hash[k])
- end
- }
- end
- hash
- }
-end
-
-def unordered_map2(key_validator, val_validator)
- lambda {|name,hash|
- if hash.class != Hash
- error "`#{name}' must be a map"
- else
- hash = Hash[hash.sort_by{|k,v| k}]
- hash.keys.each{|k|
- key_validator.call("#{name} key #{k.inspect}", k)
- hash[k] = val_validator.call("#{name}[#{k.inspect}]", hash[k])
- }
- end
- hash
- }
-end
-
-string = lambda {|name,str|
- if str.class != String
- error "`#{name}' must be a string"
- else
- str
- end
-}
-
-# Regular Expression String
-def restring(re)
- lambda {|name,str|
- if str.class != String
- error "`#{name}' must be a string"
- else
- unless re =~ str
- error "`#{name}' does not match #{re.inspect}: #{str}"
- end
- str
- end
- }
-end
-
-
-# Specific validators/formatters
-
-year = lambda {|name, num|
- if num.class != Fixnum
- error "`#{name}' must be a year"
- else
- if (num < 1900 || num > 3000)
- error "`#{name}' is a number, but doesn't look like a year"
- end
- num
- end
-}
-
-# This regex is taken from http://www.w3.org/TR/html5/forms.html#valid-e-mail-address
-_email_regex = /^[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/
-email_list = lambda {|name, ary|
- if ary.class != Array
- error "`#{name}' must be a list"
- elsif not ary.empty?
- preserve = 1
- if ary.first.end_with?("@parabola.nu") and ary.count >= 2
- preserve = 2
- end
- ary = semiordered_list(preserve, restring(_email_regex)).call(name, ary)
- end
- ary
-}
-
-shell = lambda {|name, sh|
- if sh.class != String
- error "`#{name}' must be a string"
- else
- @valid_shells ||= open("/etc/shells").read.split("\n")
- .find_all{|line| /^[^\#]/ =~ line}
- unless @valid_shells.include?(sh)
- warning "shell not listed in /etc/shells: #{sh}"
- end
- end
- sh
-}
-
-
-# The format of the YAML files
-
-format = unordered_map1(
- {
- "username" => restring(/^[a-z][a-z0-9-]*$/),
- "fullname" => string,
- "email" => email_list,
- "groups" => semiordered_list(1, string),
- "pgp_keyid" => restring(/^[0-9A-F]{40}$/),
- "pgp_revoked_keyids" => unordered_list(restring(/^[0-9A-F]{40}$/)),
- "ssh_keys" => unordered_map2(string, string),
- "shell" => shell,
- "extra" => unordered_map1(
- {
- "alias" => string,
- "other_contact" => string,
- "roles" => string,
- "website" => string,
- "occupation" => string,
- "yob" => year,
- "location" => string,
- "languages" => string,
- "interests" => string,
- "favorite_distros" => string,
- })
- })
-
-
-
-@err = 0
-user = format.call("user", YAML::load(STDIN))
-if @err != 0
- exit @err
-end
-print user.to_yaml
diff --git a/bin/pgp-get-keyid-by-uid b/bin/pgp-get-keyid-by-uid
deleted file mode 100755
index 1dea99f..0000000
--- a/bin/pgp-get-keyid-by-uid
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env ruby
-# Usage: pgp-get-keyid-by-uid {uid}
-
-require 'yaml'
-puts YAML::load(open("users/#{ARGV[0]}.yml"))["pgp_keyid"]
diff --git a/bin/pgp-list-keyids b/bin/pgp-list-keyids
deleted file mode 100755
index 93bc292..0000000
--- a/bin/pgp-list-keyids
+++ /dev/null
@@ -1,28 +0,0 @@
-#!/usr/bin/env ruby
-# Usage: pgp-list-keyids
-cfg_groups = {
- :trusted => [ "hackers", "bots" ],
- :secondary => [ "trustedusers" ]
-}
-
-######################################################################
-require 'yaml'
-
-users = Dir.glob("users/*.yml").map{|f|YAML::load(open(f))}
-
-users.each do |user|
- if user["groups"]
- if ! (user["groups"] & cfg_groups[:trusted]).empty?
- puts "trusted/#{user["username"]} #{user["pgp_keyid"]}"
- elsif ! (user["groups"] & cfg_groups[:secondary]).empty?
- puts "secondary/#{user["username"]} #{user["pgp_keyid"]}"
- elsif user["pgp_keyid"]
- puts "revoked/#{user["username"]} #{user["pgp_keyid"]}"
- end
- end
- if user["pgp_revoked_keyids"]
- user["pgp_revoked_keyids"].each do |keyid|
- puts "revoked/#{user["username"]} #{keyid}"
- end
- end
-end
diff --git a/bin/postfix-generate-virtual-map b/bin/postfix-generate-virtual-map
deleted file mode 100755
index 1203c63..0000000
--- a/bin/postfix-generate-virtual-map
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/env ruby
-# Usage: postfix-show-virtual-map > ${file} && postmap hash:${file}
-cfg_groups = [ "hackers", "fellows" ]
-
-######################################################################
-require 'yaml'
-
-users = Dir.glob("users/*.yml").map{|f|YAML::load(open(f))}
- .find_all{|u|u["groups"] and not (u["groups"] & cfg_groups).empty?}
-
-users.each do |user|
- if user["email"] and user["email"].length > 0
- if user["email"][0] =~ /.*@parabola.nu$/
- if user["email"].length > 1
- puts "#{user["username"]}@parabola.nu #{user["email"][1]}"
- end
- else
- puts "#{user["username"]}@parabola.nu #{user["email"][0]}"
- end
- end
-end
diff --git a/bin/ssh-list-authorized-keys b/bin/ssh-list-authorized-keys
deleted file mode 100755
index 6a03c8d..0000000
--- a/bin/ssh-list-authorized-keys
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env ruby
-# Usage: ssh-list-authorized-keys [username]
-cfg_groups = [ "repo", "git" ]
-
-######################################################################
-require 'set'
-require 'yaml'
-
-all_users = Dir.glob("users/*.yml").map{|f|YAML::load(open(f))}
-users = Set.new
-
-groupnames = ARGV & cfg_groups
-usernames = ARGV & all_users.map{|u|u["username"]}
-
-unless groupnames.empty?
- groupnames.push("hackers")
-end
-
-users = all_users.find_all{|u| usernames.include?(u["username"]) or not ((u["groups"]||[]) & groupnames).empty?}
-
-# Buffer the output to avoid EPIPE when the reader hangs up early
-output=""
-users.each do |user|
- if user["ssh_keys"]
- user["ssh_keys"].each do |addr,key|
- output+="#{key} #{user["fullname"]} (#{user["username"]}) <#{addr}>\n"
- end
- end
-end
-print output
diff --git a/bin/uid-map b/bin/uid-map
deleted file mode 100755
index 90dd472..0000000
--- a/bin/uid-map
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/usr/bin/env ruby
-# Usage: uid-map
-
-require 'yaml'
-
-users = Dir.glob("users/*.yml").each do |filename|
- uid = filename.sub(/users\/([0-9]*)\.yml/, "\\1").to_i
- user = YAML::load(open(filename))
- puts "#{uid}:#{user["username"]}"
-end