/usr/share/doc/ruby-activeldap-doc/examples/groupadd is in ruby-activeldap-doc 4.0.3-2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #!/usr/bin/ruby
base = File.expand_path(File.join(File.dirname(__FILE__), ".."))
$LOAD_PATH << File.join(base, "lib")
$LOAD_PATH << File.join(base, "examples")
require 'active_ldap'
require 'objects/user'
require 'objects/group'
argv, opts, options = ActiveLdap::Command.parse_options do |opts, options|
opts.banner += " GROUP_NAME"
end
if argv.size == 1
name = argv.shift
else
$stderr.puts opts
exit 1
end
pwb = Proc.new do |user|
ActiveLdap::Command.read_password("[#{user}] Password: ")
end
ActiveLdap::Base.setup_connection(:password_block => pwb,
:allow_anonymous => false)
if Group.exists?(name)
$stderr.puts("Group #{name} already exists.")
exit 1
end
group = Group.new(name)
group.gid_number = 9000
unless group.save
puts "failed"
puts group.errors.full_messages
exit 1
end
|