ruby-activeldap 0.8.3 → 0.8.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +431 -0
- data/COPYING +340 -0
- data/LICENSE +58 -0
- data/README +104 -0
- data/Rakefile +165 -0
- data/TODO +22 -0
- data/benchmark/bench-al.rb +202 -0
- data/benchmark/config.yaml.sample +5 -0
- data/data/locale/en/LC_MESSAGES/active-ldap.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/active-ldap.mo +0 -0
- data/examples/al-admin/README +182 -0
- data/examples/al-admin/Rakefile +10 -0
- data/examples/al-admin/app/controllers/account_controller.rb +50 -0
- data/examples/al-admin/app/controllers/application.rb +15 -0
- data/examples/al-admin/app/controllers/directory_controller.rb +22 -0
- data/examples/al-admin/app/controllers/users_controller.rb +38 -0
- data/examples/al-admin/app/controllers/welcome_controller.rb +4 -0
- data/examples/al-admin/app/helpers/account_helper.rb +2 -0
- data/examples/al-admin/app/helpers/application_helper.rb +6 -0
- data/examples/al-admin/app/helpers/directory_helper.rb +2 -0
- data/examples/al-admin/app/helpers/users_helper.rb +13 -0
- data/examples/al-admin/app/helpers/welcome_helper.rb +2 -0
- data/examples/al-admin/app/models/entry.rb +19 -0
- data/examples/al-admin/app/models/ldap_user.rb +49 -0
- data/examples/al-admin/app/models/user.rb +91 -0
- data/examples/al-admin/app/views/account/login.rhtml +12 -0
- data/examples/al-admin/app/views/account/sign_up.rhtml +22 -0
- data/examples/al-admin/app/views/directory/index.rhtml +5 -0
- data/examples/al-admin/app/views/directory/populate.rhtml +2 -0
- data/examples/al-admin/app/views/layouts/application.rhtml +41 -0
- data/examples/al-admin/app/views/users/_attribute_information.rhtml +22 -0
- data/examples/al-admin/app/views/users/_entry.rhtml +12 -0
- data/examples/al-admin/app/views/users/_form.rhtml +29 -0
- data/examples/al-admin/app/views/users/_object_class_information.rhtml +23 -0
- data/examples/al-admin/app/views/users/edit.rhtml +10 -0
- data/examples/al-admin/app/views/users/index.rhtml +9 -0
- data/examples/al-admin/app/views/users/show.rhtml +3 -0
- data/examples/al-admin/app/views/welcome/index.rhtml +16 -0
- data/examples/al-admin/config/boot.rb +45 -0
- data/examples/al-admin/config/database.yml.example +19 -0
- data/examples/al-admin/config/environment.rb +68 -0
- data/examples/al-admin/config/environments/development.rb +21 -0
- data/examples/al-admin/config/environments/production.rb +18 -0
- data/examples/al-admin/config/environments/test.rb +19 -0
- data/examples/al-admin/config/ldap.yml.example +21 -0
- data/examples/al-admin/config/routes.rb +26 -0
- data/examples/al-admin/db/migrate/001_create_users.rb +16 -0
- data/examples/al-admin/lib/accept_http_rails_relative_url_root.rb +9 -0
- data/examples/al-admin/lib/authenticated_system.rb +131 -0
- data/examples/al-admin/lib/authenticated_test_helper.rb +113 -0
- data/examples/al-admin/lib/tasks/gettext.rake +35 -0
- data/examples/al-admin/po/en/al-admin.po +190 -0
- data/examples/al-admin/po/ja/al-admin.po +190 -0
- data/examples/al-admin/po/nl/al-admin.po +202 -0
- data/examples/al-admin/public/.htaccess +40 -0
- data/examples/al-admin/public/404.html +30 -0
- data/examples/al-admin/public/500.html +30 -0
- data/examples/al-admin/public/dispatch.cgi +10 -0
- data/examples/al-admin/public/dispatch.fcgi +24 -0
- data/examples/al-admin/public/dispatch.rb +10 -0
- data/examples/al-admin/public/favicon.ico +0 -0
- data/examples/al-admin/public/images/rails.png +0 -0
- data/examples/al-admin/public/javascripts/application.js +2 -0
- data/examples/al-admin/public/javascripts/controls.js +833 -0
- data/examples/al-admin/public/javascripts/dragdrop.js +942 -0
- data/examples/al-admin/public/javascripts/effects.js +1088 -0
- data/examples/al-admin/public/javascripts/prototype.js +2515 -0
- data/examples/al-admin/public/robots.txt +1 -0
- data/examples/al-admin/public/stylesheets/rails.css +35 -0
- data/examples/al-admin/public/stylesheets/screen.css +52 -0
- data/examples/al-admin/script/about +3 -0
- data/examples/al-admin/script/breakpointer +3 -0
- data/examples/al-admin/script/console +3 -0
- data/examples/al-admin/script/destroy +3 -0
- data/examples/al-admin/script/generate +3 -0
- data/examples/al-admin/script/performance/benchmarker +3 -0
- data/examples/al-admin/script/performance/profiler +3 -0
- data/examples/al-admin/script/plugin +3 -0
- data/examples/al-admin/script/process/inspector +3 -0
- data/examples/al-admin/script/process/reaper +3 -0
- data/examples/al-admin/script/process/spawner +3 -0
- data/examples/al-admin/script/runner +3 -0
- data/examples/al-admin/script/server +3 -0
- data/examples/al-admin/test/fixtures/users.yml +9 -0
- data/examples/al-admin/test/functional/account_controller_test.rb +24 -0
- data/examples/al-admin/test/functional/directory_controller_test.rb +18 -0
- data/examples/al-admin/test/functional/users_controller_test.rb +18 -0
- data/examples/al-admin/test/functional/welcome_controller_test.rb +18 -0
- data/examples/al-admin/test/run-test.sh +3 -0
- data/examples/al-admin/test/test_helper.rb +28 -0
- data/examples/al-admin/test/unit/user_test.rb +13 -0
- data/examples/al-admin/vendor/plugins/exception_notification/README +111 -0
- data/examples/al-admin/vendor/plugins/exception_notification/init.rb +1 -0
- data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifiable.rb +99 -0
- data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier.rb +67 -0
- data/examples/al-admin/vendor/plugins/exception_notification/lib/exception_notifier_helper.rb +77 -0
- data/examples/al-admin/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb +61 -0
- data/examples/al-admin/vendor/plugins/exception_notification/test/test_helper.rb +7 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_backtrace.rhtml +1 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_environment.rhtml +7 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_inspect_model.rhtml +16 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_request.rhtml +3 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_session.rhtml +2 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/_title.rhtml +3 -0
- data/examples/al-admin/vendor/plugins/exception_notification/views/exception_notifier/exception_notification.rhtml +6 -0
- data/examples/config.yaml.example +5 -0
- data/examples/example.der +0 -0
- data/examples/example.jpg +0 -0
- data/examples/groupadd +41 -0
- data/examples/groupdel +35 -0
- data/examples/groupls +49 -0
- data/examples/groupmod +42 -0
- data/examples/lpasswd +55 -0
- data/examples/objects/group.rb +13 -0
- data/examples/objects/ou.rb +4 -0
- data/examples/objects/user.rb +20 -0
- data/examples/ouadd +38 -0
- data/examples/useradd +45 -0
- data/examples/useradd-binary +50 -0
- data/examples/userdel +34 -0
- data/examples/userls +50 -0
- data/examples/usermod +42 -0
- data/examples/usermod-binary-add +47 -0
- data/examples/usermod-binary-add-time +51 -0
- data/examples/usermod-binary-del +48 -0
- data/examples/usermod-lang-add +43 -0
- data/lib/active_ldap.rb +978 -0
- data/lib/active_ldap/adapter/base.rb +512 -0
- data/lib/active_ldap/adapter/ldap.rb +233 -0
- data/lib/active_ldap/adapter/ldap_ext.rb +69 -0
- data/lib/active_ldap/adapter/net_ldap.rb +290 -0
- data/lib/active_ldap/adapter/net_ldap_ext.rb +29 -0
- data/lib/active_ldap/association/belongs_to.rb +47 -0
- data/lib/active_ldap/association/belongs_to_many.rb +42 -0
- data/lib/active_ldap/association/collection.rb +83 -0
- data/lib/active_ldap/association/has_many.rb +31 -0
- data/lib/active_ldap/association/has_many_utils.rb +35 -0
- data/lib/active_ldap/association/has_many_wrap.rb +46 -0
- data/lib/active_ldap/association/proxy.rb +102 -0
- data/lib/active_ldap/associations.rb +172 -0
- data/lib/active_ldap/attributes.rb +211 -0
- data/lib/active_ldap/base.rb +1256 -0
- data/lib/active_ldap/callbacks.rb +19 -0
- data/lib/active_ldap/command.rb +48 -0
- data/lib/active_ldap/configuration.rb +114 -0
- data/lib/active_ldap/connection.rb +234 -0
- data/lib/active_ldap/distinguished_name.rb +250 -0
- data/lib/active_ldap/escape.rb +12 -0
- data/lib/active_ldap/get_text/parser.rb +142 -0
- data/lib/active_ldap/get_text_fallback.rb +53 -0
- data/lib/active_ldap/get_text_support.rb +12 -0
- data/lib/active_ldap/helper.rb +23 -0
- data/lib/active_ldap/ldap_error.rb +74 -0
- data/lib/active_ldap/object_class.rb +93 -0
- data/lib/active_ldap/operations.rb +419 -0
- data/lib/active_ldap/populate.rb +44 -0
- data/lib/active_ldap/schema.rb +427 -0
- data/lib/active_ldap/timeout.rb +75 -0
- data/lib/active_ldap/timeout_stub.rb +17 -0
- data/lib/active_ldap/user_password.rb +93 -0
- data/lib/active_ldap/validations.rb +112 -0
- data/po/en/active-ldap.po +3011 -0
- data/po/ja/active-ldap.po +3044 -0
- data/rails/plugin/active_ldap/README +54 -0
- data/rails/plugin/active_ldap/generators/scaffold_al/scaffold_al_generator.rb +7 -0
- data/rails/plugin/active_ldap/generators/scaffold_al/templates/ldap.yml +21 -0
- data/rails/plugin/active_ldap/init.rb +19 -0
- data/test/al-test-utils.rb +362 -0
- data/test/command.rb +62 -0
- data/test/config.yaml.sample +6 -0
- data/test/run-test.rb +31 -0
- data/test/test-unit-ext.rb +4 -0
- data/test/test-unit-ext/always-show-result.rb +28 -0
- data/test/test-unit-ext/backtrace-filter.rb +17 -0
- data/test/test-unit-ext/long-display-for-emacs.rb +25 -0
- data/test/test-unit-ext/priority.rb +163 -0
- metadata +211 -4
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
require 'pathname'
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2005 Jamis Buck
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
# a copy of this software and associated documentation files (the
|
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
# the following conditions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be
|
|
14
|
+
# included in all copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
class ExceptionNotifier < ActionMailer::Base
|
|
24
|
+
@@sender_address = %("Exception Notifier" <exception.notifier@default.com>)
|
|
25
|
+
cattr_accessor :sender_address
|
|
26
|
+
|
|
27
|
+
@@exception_recipients = []
|
|
28
|
+
cattr_accessor :exception_recipients
|
|
29
|
+
|
|
30
|
+
@@email_prefix = "[ERROR] "
|
|
31
|
+
cattr_accessor :email_prefix
|
|
32
|
+
|
|
33
|
+
@@sections = %w(request session environment backtrace)
|
|
34
|
+
cattr_accessor :sections
|
|
35
|
+
|
|
36
|
+
def self.reloadable?; false; end
|
|
37
|
+
|
|
38
|
+
def exception_notification(exception, controller, request, data={})
|
|
39
|
+
subject "#{email_prefix}#{controller.controller_name}##{controller.action_name} (#{exception.class}) #{exception.message.inspect}"
|
|
40
|
+
|
|
41
|
+
recipients exception_recipients
|
|
42
|
+
from sender_address
|
|
43
|
+
|
|
44
|
+
body data.merge({ :controller => controller, :request => request,
|
|
45
|
+
:exception => exception, :host => request.env["HTTP_HOST"],
|
|
46
|
+
:backtrace => sanitize_backtrace(exception.backtrace),
|
|
47
|
+
:rails_root => rails_root, :data => data,
|
|
48
|
+
:sections => sections })
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def template_root
|
|
52
|
+
"#{File.dirname(__FILE__)}/../views"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
private
|
|
56
|
+
|
|
57
|
+
def sanitize_backtrace(trace)
|
|
58
|
+
re = Regexp.new(/^#{Regexp.escape(rails_root)}/)
|
|
59
|
+
trace.map { |line| Pathname.new(line.gsub(re, "[RAILS_ROOT]")).cleanpath.to_s }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def rails_root
|
|
63
|
+
return @rails_root if @rails_root
|
|
64
|
+
@rails_root = Pathname.new(RAILS_ROOT).cleanpath.to_s
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
require 'pp'
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2005 Jamis Buck
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
# a copy of this software and associated documentation files (the
|
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
# the following conditions:
|
|
12
|
+
#
|
|
13
|
+
# The above copyright notice and this permission notice shall be
|
|
14
|
+
# included in all copies or substantial portions of the Software.
|
|
15
|
+
#
|
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
module ExceptionNotifierHelper
|
|
24
|
+
VIEW_PATH = "views/exception_notifier"
|
|
25
|
+
APP_PATH = "#{RAILS_ROOT}/app/#{VIEW_PATH}"
|
|
26
|
+
PARAM_FILTER_REPLACEMENT = "[FILTERED]"
|
|
27
|
+
|
|
28
|
+
def render_section(section)
|
|
29
|
+
RAILS_DEFAULT_LOGGER.info("rendering section #{section.inspect}")
|
|
30
|
+
summary = render_overridable(section).strip
|
|
31
|
+
unless summary.blank?
|
|
32
|
+
title = render_overridable(:title, :locals => { :title => section }).strip
|
|
33
|
+
"#{title}\n\n#{summary.gsub(/^/, " ")}\n\n"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def render_overridable(partial, options={})
|
|
38
|
+
if File.exist?(path = "#{APP_PATH}/_#{partial}.rhtml")
|
|
39
|
+
render(options.merge(:file => path, :use_full_path => false))
|
|
40
|
+
elsif File.exist?(path = "#{File.dirname(__FILE__)}/../#{VIEW_PATH}/_#{partial}.rhtml")
|
|
41
|
+
render(options.merge(:file => path, :use_full_path => false))
|
|
42
|
+
else
|
|
43
|
+
""
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def inspect_model_object(model, locals={})
|
|
48
|
+
render_overridable(:inspect_model,
|
|
49
|
+
:locals => { :inspect_model => model,
|
|
50
|
+
:show_instance_variables => true,
|
|
51
|
+
:show_attributes => true }.merge(locals))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def inspect_value(value)
|
|
55
|
+
len = 512
|
|
56
|
+
result = object_to_yaml(value).gsub(/\n/, "\n ").strip
|
|
57
|
+
result = result[0,len] + "... (#{result.length-len} bytes more)" if result.length > len+20
|
|
58
|
+
result
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def object_to_yaml(object)
|
|
62
|
+
object.to_yaml.sub(/^---\s*/m, "")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def exclude_raw_post_parameters?
|
|
66
|
+
@controller && @controller.respond_to?(:filter_parameters)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def filter_sensitive_post_data_parameters(parameters)
|
|
70
|
+
exclude_raw_post_parameters? ? @controller.filter_parameters(parameters) : parameters
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def filter_sensitive_post_data_from_env(env_key, env_value)
|
|
74
|
+
return env_value unless exclude_raw_post_parameters?
|
|
75
|
+
(env_key =~ /RAW_POST_DATA/i) ? PARAM_FILTER_REPLACEMENT : env_value
|
|
76
|
+
end
|
|
77
|
+
end
|
data/examples/al-admin/vendor/plugins/exception_notification/test/exception_notifier_helper_test.rb
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
require 'exception_notifier_helper'
|
|
3
|
+
|
|
4
|
+
class ExceptionNotifierHelperTest < Test::Unit::TestCase
|
|
5
|
+
|
|
6
|
+
class ExceptionNotifierHelperIncludeTarget
|
|
7
|
+
include ExceptionNotifierHelper
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def setup
|
|
11
|
+
@helper = ExceptionNotifierHelperIncludeTarget.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# No controller
|
|
15
|
+
|
|
16
|
+
def test_should_not_exclude_raw_post_parameters_if_no_controller
|
|
17
|
+
assert !@helper.exclude_raw_post_parameters?
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Controller, no filtering
|
|
21
|
+
|
|
22
|
+
class ControllerWithoutFilterParameters; end
|
|
23
|
+
|
|
24
|
+
def test_should_not_filter_env_values_for_raw_post_data_keys_if_controller_can_not_filter_parameters
|
|
25
|
+
stub_controller(ControllerWithoutFilterParameters.new)
|
|
26
|
+
assert @helper.filter_sensitive_post_data_from_env("RAW_POST_DATA", "secret").include?("secret")
|
|
27
|
+
end
|
|
28
|
+
def test_should_not_exclude_raw_post_parameters_if_controller_can_not_filter_parameters
|
|
29
|
+
stub_controller(ControllerWithoutFilterParameters.new)
|
|
30
|
+
assert !@helper.exclude_raw_post_parameters?
|
|
31
|
+
end
|
|
32
|
+
def test_should_return_params_if_controller_can_not_filter_parameters
|
|
33
|
+
stub_controller(ControllerWithoutFilterParameters.new)
|
|
34
|
+
assert_equal :params, @helper.filter_sensitive_post_data_parameters(:params)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Controller with filtering
|
|
38
|
+
|
|
39
|
+
class ControllerWithFilterParameters
|
|
40
|
+
def filter_parameters(params); :filtered end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_should_filter_env_values_for_raw_post_data_keys_if_controller_can_filter_parameters
|
|
44
|
+
stub_controller(ControllerWithFilterParameters.new)
|
|
45
|
+
assert !@helper.filter_sensitive_post_data_from_env("RAW_POST_DATA", "secret").include?("secret")
|
|
46
|
+
assert @helper.filter_sensitive_post_data_from_env("SOME_OTHER_KEY", "secret").include?("secret")
|
|
47
|
+
end
|
|
48
|
+
def test_should_exclude_raw_post_parameters_if_controller_can_filter_parameters
|
|
49
|
+
stub_controller(ControllerWithFilterParameters.new)
|
|
50
|
+
assert @helper.exclude_raw_post_parameters?
|
|
51
|
+
end
|
|
52
|
+
def test_should_delegate_param_filtering_to_controller_if_controller_can_filter_parameters
|
|
53
|
+
stub_controller(ControllerWithFilterParameters.new)
|
|
54
|
+
assert_equal :filtered, @helper.filter_sensitive_post_data_parameters(:params)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
def stub_controller(controller)
|
|
59
|
+
@helper.instance_variable_set(:@controller, controller)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= @backtrace.join "\n" %>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<% max = @request.env.keys.max { |a,b| a.length <=> b.length } -%>
|
|
2
|
+
<% @request.env.keys.sort.each do |key| -%>
|
|
3
|
+
* <%= "%*-s: %s" % [max.length, key, filter_sensitive_post_data_from_env(key, @request.env[key].to_s.strip)] %>
|
|
4
|
+
<% end -%>
|
|
5
|
+
|
|
6
|
+
* Process: <%= $$ %>
|
|
7
|
+
* Server : <%= `hostname -s`.chomp %>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<% if show_attributes -%>
|
|
2
|
+
[attributes]
|
|
3
|
+
<% attrs = inspect_model.attributes -%>
|
|
4
|
+
<% max = attrs.keys.max { |a,b| a.length <=> b.length } -%>
|
|
5
|
+
<% attrs.keys.sort.each do |attr| -%>
|
|
6
|
+
* <%= "%*-s: %s" % [max.length, attr, object_to_yaml(attrs[attr]).gsub(/\n/, "\n ").strip] %>
|
|
7
|
+
<% end -%>
|
|
8
|
+
<% end -%>
|
|
9
|
+
|
|
10
|
+
<% if show_instance_variables -%>
|
|
11
|
+
[instance variables]
|
|
12
|
+
<% inspect_model.instance_variables.sort.each do |variable| -%>
|
|
13
|
+
<%- next if variable == "@attributes" -%>
|
|
14
|
+
* <%= variable %>: <%= inspect_value(inspect_model.instance_variable_get(variable)) %>
|
|
15
|
+
<% end -%>
|
|
16
|
+
<% end -%>
|
|
Binary file
|
|
Binary file
|
data/examples/groupadd
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/ruby -W0
|
|
2
|
+
|
|
3
|
+
base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
|
4
|
+
$LOAD_PATH << File.join(base, "lib")
|
|
5
|
+
$LOAD_PATH << File.join(base, "examples")
|
|
6
|
+
|
|
7
|
+
require 'active_ldap'
|
|
8
|
+
require 'objects/user'
|
|
9
|
+
require 'objects/group'
|
|
10
|
+
|
|
11
|
+
argv, opts, options = ActiveLdap::Command.parse_options do |opts, options|
|
|
12
|
+
opts.banner += " GROUP_NAME"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
if argv.size == 1
|
|
16
|
+
name = argv.shift
|
|
17
|
+
else
|
|
18
|
+
$stderr.puts opts
|
|
19
|
+
exit 1
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
pwb = Proc.new do |user|
|
|
23
|
+
ActiveLdap::Command.read_password("[#{user}] Password: ")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
ActiveLdap::Base.establish_connection(:password_block => pwb,
|
|
27
|
+
:allow_anonymous => false)
|
|
28
|
+
|
|
29
|
+
if Group.exists?(name)
|
|
30
|
+
$stderr.puts("Group #{name} already exists.")
|
|
31
|
+
exit 1
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
group = Group.new(name)
|
|
35
|
+
group.gid_number = 9000
|
|
36
|
+
|
|
37
|
+
unless group.save
|
|
38
|
+
puts "failed"
|
|
39
|
+
puts group.errors.full_messages
|
|
40
|
+
exit 1
|
|
41
|
+
end
|
data/examples/groupdel
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/ruby -W0
|
|
2
|
+
|
|
3
|
+
base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
|
4
|
+
$LOAD_PATH << File.join(base, "lib")
|
|
5
|
+
$LOAD_PATH << File.join(base, "examples")
|
|
6
|
+
|
|
7
|
+
require 'active_ldap'
|
|
8
|
+
require 'objects/user'
|
|
9
|
+
require 'objects/group'
|
|
10
|
+
|
|
11
|
+
argv, opts, options = ActiveLdap::Command.parse_options do |opts, options|
|
|
12
|
+
opts.banner += " GROUP_NAME"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
if argv.size == 1
|
|
16
|
+
name = argv.shift
|
|
17
|
+
else
|
|
18
|
+
$stderr.puts opts
|
|
19
|
+
exit 1
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
pwb = Proc.new do |user|
|
|
23
|
+
ActiveLdap::Command.read_password("[#{user}] Password: ")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
ActiveLdap::Base.establish_connection(:password_block => pwb,
|
|
27
|
+
:allow_anonymous => false)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
unless Group.exists?(name)
|
|
31
|
+
$stderr.puts("Group #{name} doesn't exist.")
|
|
32
|
+
exit 1
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
Group.destroy(name)
|
data/examples/groupls
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/ruby -W0
|
|
2
|
+
|
|
3
|
+
base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
|
4
|
+
$LOAD_PATH << File.join(base, "lib")
|
|
5
|
+
$LOAD_PATH << File.join(base, "examples")
|
|
6
|
+
|
|
7
|
+
require 'active_ldap'
|
|
8
|
+
require 'objects/user'
|
|
9
|
+
require 'objects/group'
|
|
10
|
+
|
|
11
|
+
argv, opts, options = ActiveLdap::Command.parse_options do |opts, options|
|
|
12
|
+
opts.banner += " GROUP_NAME"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
if argv.size == 1
|
|
16
|
+
name = argv.shift
|
|
17
|
+
else
|
|
18
|
+
$stderr.puts opts
|
|
19
|
+
exit 1
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
pwb = Proc.new do |user|
|
|
23
|
+
ActiveLdap::Command.read_password("[#{user}] Password: ")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
ActiveLdap::Base.establish_connection(:password_block => pwb,
|
|
27
|
+
:allow_anonymous => false)
|
|
28
|
+
|
|
29
|
+
unless Group.exists?(name)
|
|
30
|
+
$stderr.puts("Group #{name} doesn't exist.")
|
|
31
|
+
exit 1
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
group = Group.find(name)
|
|
35
|
+
|
|
36
|
+
members = []
|
|
37
|
+
group.primary_members.each do |mem|
|
|
38
|
+
members << "#{mem.uid}[#{mem.uidNumber}]"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
group.members.each do |mem|
|
|
42
|
+
if mem.new_entry?
|
|
43
|
+
members << "#{mem.uid}[????]"
|
|
44
|
+
else
|
|
45
|
+
members << "#{mem.uid}[#{mem.uidNumber}]"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
puts("#{group.id}(#{group.gid_number}): #{members.join(', ')}")
|
data/examples/groupmod
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/ruby -W0
|
|
2
|
+
|
|
3
|
+
base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
|
4
|
+
$LOAD_PATH << File.join(base, "lib")
|
|
5
|
+
$LOAD_PATH << File.join(base, "examples")
|
|
6
|
+
|
|
7
|
+
require 'active_ldap'
|
|
8
|
+
require 'objects/user'
|
|
9
|
+
require 'objects/group'
|
|
10
|
+
|
|
11
|
+
argv, opts, options = ActiveLdap::Command.parse_options do |opts, options|
|
|
12
|
+
opts.banner += " GROUP_NAME GID_NUMBER"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
if argv.size == 2
|
|
16
|
+
name, gid = argv
|
|
17
|
+
else
|
|
18
|
+
$stderr.puts opts
|
|
19
|
+
exit 1
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
pwb = Proc.new do |user|
|
|
23
|
+
ActiveLdap::Command.read_password("[#{user}] Password: ")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
ActiveLdap::Base.establish_connection(:password_block => pwb,
|
|
27
|
+
:allow_anonymous => false)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
unless Group.exists?(name)
|
|
31
|
+
$stderr.puts("Group #{name} doesn't exist.")
|
|
32
|
+
exit 1
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
group = Group.find(name)
|
|
36
|
+
group.gid_number = gid
|
|
37
|
+
|
|
38
|
+
unless group.save
|
|
39
|
+
puts "failed"
|
|
40
|
+
puts group.errors.full_messages
|
|
41
|
+
exit 1
|
|
42
|
+
end
|