rubylibcrack 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,3 @@
1
+ == 0.1.0 / 2007-08-07
2
+
3
+ * Initial release.
data/Manifest.txt ADDED
@@ -0,0 +1,13 @@
1
+ History.txt
2
+
3
+ Manifest.txt
4
+
5
+ README.txt
6
+
7
+ Rakefile
8
+
9
+ test/test_rubylibcrack.rb
10
+
11
+ ext/rubylibcrack.c
12
+
13
+ ext/extconf.rb
data/README.txt ADDED
@@ -0,0 +1,208 @@
1
+ rubylibcrack
2
+
3
+ By: Mark Somerville (on behalf of Purchasing Card Consultancy limited)
4
+
5
+ URL: http://mark.scottishclimbs.com/ (http://www.pccl.info/)
6
+
7
+ == DESCRIPTION:
8
+
9
+ A Ruby binding to the password strength checker, libcrack/cracklib.
10
+
11
+ == FEATURES/PROBLEMS:
12
+
13
+ A very simple password class with methods, weak? and strong? to check a password.
14
+ A suitable message is provided if the password is weak.
15
+
16
+ == SYNOPSIS:
17
+
18
+ Usage:
19
+
20
+ >> require "rubygems"
21
+ => true
22
+ >> require "rubylibcrack"
23
+ => true
24
+ >> my_password = Password.new("hello001")
25
+ => "hello001"
26
+ >> my_password.strong?
27
+ => false
28
+ >> my_password.message
29
+ => "it is based on a dictionary word"
30
+
31
+ == REQUIREMENTS:
32
+
33
+ * Cracklib and the development libraries:
34
+ - Gentoo will have these if cracklib is installed
35
+ - Redhat and Fedora will require cracklib-devel
36
+ - Ubuntu will require cracklib-devel
37
+
38
+ == INSTALL:
39
+
40
+ * sudo gem install rubycracklib
41
+
42
+ == LICENSE:
43
+
44
+ GNU LESSER GENERAL PUBLIC LICENSE
45
+ Version 3, 29 June 2007
46
+
47
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
48
+ Everyone is permitted to copy and distribute verbatim copies
49
+ of this license document, but changing it is not allowed.
50
+
51
+
52
+ This version of the GNU Lesser General Public License incorporates
53
+ the terms and conditions of version 3 of the GNU General Public
54
+ License, supplemented by the additional permissions listed below.
55
+
56
+ 0. Additional Definitions.
57
+
58
+ As used herein, "this License" refers to version 3 of the GNU Lesser
59
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
60
+ General Public License.
61
+
62
+ "The Library" refers to a covered work governed by this License,
63
+ other than an Application or a Combined Work as defined below.
64
+
65
+ An "Application" is any work that makes use of an interface provided
66
+ by the Library, but which is not otherwise based on the Library.
67
+ Defining a subclass of a class defined by the Library is deemed a mode
68
+ of using an interface provided by the Library.
69
+
70
+ A "Combined Work" is a work produced by combining or linking an
71
+ Application with the Library. The particular version of the Library
72
+ with which the Combined Work was made is also called the "Linked
73
+ Version".
74
+
75
+ The "Minimal Corresponding Source" for a Combined Work means the
76
+ Corresponding Source for the Combined Work, excluding any source code
77
+ for portions of the Combined Work that, considered in isolation, are
78
+ based on the Application, and not on the Linked Version.
79
+
80
+ The "Corresponding Application Code" for a Combined Work means the
81
+ object code and/or source code for the Application, including any data
82
+ and utility programs needed for reproducing the Combined Work from the
83
+ Application, but excluding the System Libraries of the Combined Work.
84
+
85
+ 1. Exception to Section 3 of the GNU GPL.
86
+
87
+ You may convey a covered work under sections 3 and 4 of this License
88
+ without being bound by section 3 of the GNU GPL.
89
+
90
+ 2. Conveying Modified Versions.
91
+
92
+ If you modify a copy of the Library, and, in your modifications, a
93
+ facility refers to a function or data to be supplied by an Application
94
+ that uses the facility (other than as an argument passed when the
95
+ facility is invoked), then you may convey a copy of the modified
96
+ version:
97
+
98
+ a) under this License, provided that you make a good faith effort to
99
+ ensure that, in the event an Application does not supply the
100
+ function or data, the facility still operates, and performs
101
+ whatever part of its purpose remains meaningful, or
102
+
103
+ b) under the GNU GPL, with none of the additional permissions of
104
+ this License applicable to that copy.
105
+
106
+ 3. Object Code Incorporating Material from Library Header Files.
107
+
108
+ The object code form of an Application may incorporate material from
109
+ a header file that is part of the Library. You may convey such object
110
+ code under terms of your choice, provided that, if the incorporated
111
+ material is not limited to numerical parameters, data structure
112
+ layouts and accessors, or small macros, inline functions and templates
113
+ (ten or fewer lines in length), you do both of the following:
114
+
115
+ a) Give prominent notice with each copy of the object code that the
116
+ Library is used in it and that the Library and its use are
117
+ covered by this License.
118
+
119
+ b) Accompany the object code with a copy of the GNU GPL and this license
120
+ document.
121
+
122
+ 4. Combined Works.
123
+
124
+ You may convey a Combined Work under terms of your choice that,
125
+ taken together, effectively do not restrict modification of the
126
+ portions of the Library contained in the Combined Work and reverse
127
+ engineering for debugging such modifications, if you also do each of
128
+ the following:
129
+
130
+ a) Give prominent notice with each copy of the Combined Work that
131
+ the Library is used in it and that the Library and its use are
132
+ covered by this License.
133
+
134
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
135
+ document.
136
+
137
+ c) For a Combined Work that displays copyright notices during
138
+ execution, include the copyright notice for the Library among
139
+ these notices, as well as a reference directing the user to the
140
+ copies of the GNU GPL and this license document.
141
+
142
+ d) Do one of the following:
143
+
144
+ 0) Convey the Minimal Corresponding Source under the terms of this
145
+ License, and the Corresponding Application Code in a form
146
+ suitable for, and under terms that permit, the user to
147
+ recombine or relink the Application with a modified version of
148
+ the Linked Version to produce a modified Combined Work, in the
149
+ manner specified by section 6 of the GNU GPL for conveying
150
+ Corresponding Source.
151
+
152
+ 1) Use a suitable shared library mechanism for linking with the
153
+ Library. A suitable mechanism is one that (a) uses at run time
154
+ a copy of the Library already present on the user's computer
155
+ system, and (b) will operate properly with a modified version
156
+ of the Library that is interface-compatible with the Linked
157
+ Version.
158
+
159
+ e) Provide Installation Information, but only if you would otherwise
160
+ be required to provide such information under section 6 of the
161
+ GNU GPL, and only to the extent that such information is
162
+ necessary to install and execute a modified version of the
163
+ Combined Work produced by recombining or relinking the
164
+ Application with a modified version of the Linked Version. (If
165
+ you use option 4d0, the Installation Information must accompany
166
+ the Minimal Corresponding Source and Corresponding Application
167
+ Code. If you use option 4d1, you must provide the Installation
168
+ Information in the manner specified by section 6 of the GNU GPL
169
+ for conveying Corresponding Source.)
170
+
171
+ 5. Combined Libraries.
172
+
173
+ You may place library facilities that are a work based on the
174
+ Library side by side in a single library together with other library
175
+ facilities that are not Applications and are not covered by this
176
+ License, and convey such a combined library under terms of your
177
+ choice, if you do both of the following:
178
+
179
+ a) Accompany the combined library with a copy of the same work based
180
+ on the Library, uncombined with any other library facilities,
181
+ conveyed under the terms of this License.
182
+
183
+ b) Give prominent notice with the combined library that part of it
184
+ is a work based on the Library, and explaining where to find the
185
+ accompanying uncombined form of the same work.
186
+
187
+ 6. Revised Versions of the GNU Lesser General Public License.
188
+
189
+ The Free Software Foundation may publish revised and/or new versions
190
+ of the GNU Lesser General Public License from time to time. Such new
191
+ versions will be similar in spirit to the present version, but may
192
+ differ in detail to address new problems or concerns.
193
+
194
+ Each version is given a distinguishing version number. If the
195
+ Library as you received it specifies that a certain numbered version
196
+ of the GNU Lesser General Public License "or any later version"
197
+ applies to it, you have the option of following the terms and
198
+ conditions either of that published version or of any later version
199
+ published by the Free Software Foundation. If the Library as you
200
+ received it does not specify a version number of the GNU Lesser
201
+ General Public License, you may choose any version of the GNU Lesser
202
+ General Public License ever published by the Free Software Foundation.
203
+
204
+ If the Library as you received it specifies that a proxy can decide
205
+ whether future versions of the GNU Lesser General Public License shall
206
+ apply, that proxy's public statement of acceptance of any version is
207
+ permanent authorization for you to choose that version for the
208
+ Library.
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'rubygems'
2
+ require 'hoe'
3
+
4
+ Hoe.new('rubylibcrack', "0.1.0") do |p|
5
+ p.rubyforge_name = 'rubylibcrack'
6
+ p.author = p.paragraphs_of('README.txt', 1..1).to_s.strip.sub("By: ", "")
7
+ p.email = 'rubyforge@scottishclimbs.com'
8
+ p.summary = p.paragraphs_of('README.txt', 3).to_s.sub("== DESCRIPTION:", "")
9
+ p.description = p.paragraphs_of('README.txt', 3).to_s.sub("== DESCRIPTION:", "")
10
+ p.url = p.paragraphs_of('README.txt', 2..2).to_s.strip.sub("URL: ", "")
11
+ p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
12
+ p.spec_extras["files"] = [ "ext/rubylibcrack.c", "Rakefile" ]
13
+ p.spec_extras["extensions"] = "ext/extconf.rb"
14
+ end
15
+
16
+ desc "Builds the extension"
17
+ task :build_extension do
18
+ system "cd ext; ruby extconf.rb; make; cd ../"
19
+ end
20
+
21
+ desc "Cleans the files compiled by build_extension"
22
+ task :clean_extension do
23
+ system "cd ext; rm dictconfig.h rubylibcrack.so rubylibcrack.o Makefile; cd ../"
24
+ end
25
+
26
+ desc "Run the unit tests"
27
+ task :test => [ :build_extension ] do
28
+ Rake::Task[ :clean_extension ].invoke
29
+ end
data/ext/extconf.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'mkmf'
2
+ File.open(File.dirname(__FILE__)+'/dictconfig.h', "a") do |dictconfig|
3
+ dictconfig << '#define DICTPATH "/usr/lib64/cracklib_dict"'
4
+ dictconfig << "\n"
5
+ end
6
+ $libs = append_library($libs, "crack")
7
+ create_makefile('rubylibcrack')
@@ -0,0 +1,49 @@
1
+ #include <ruby.h>
2
+ #include <crack.h>
3
+ #include "dictconfig.h"
4
+
5
+ /*
6
+ * Runs FascistCheck and returns if the password is regarded as weak or not.
7
+ * If it is, the class variable @message is set to the value of the error message.
8
+ */
9
+ static VALUE t_weak(VALUE self)
10
+ {
11
+ char *failure_message;
12
+ failure_message = (char *) FascistCheck(STR2CSTR(self), DICTPATH);
13
+ if(failure_message)
14
+ {
15
+ rb_iv_set(self, "@message", rb_str_new2(failure_message));
16
+ return Qtrue;
17
+ }
18
+ else
19
+ {
20
+ return Qfalse;
21
+ }
22
+ }
23
+
24
+ /*
25
+ * Runs FascistCheck and returns if the password is regarded as strong or not.
26
+ * If it isn't, the class variable @message is set to the value of the error message.
27
+ */
28
+ static VALUE t_strong(VALUE self)
29
+ {
30
+ VALUE weak;
31
+ weak = t_weak(self);
32
+ if(weak == Qtrue)
33
+ {
34
+ return Qfalse;
35
+ }
36
+ else
37
+ {
38
+ return Qtrue;
39
+ }
40
+ }
41
+
42
+ VALUE cPassword;
43
+
44
+ void Init_rubylibcrack() {
45
+ cPassword = rb_define_class("Password", rb_cString);
46
+ rb_define_attr(cPassword, "message", 1, 0);
47
+ rb_define_method(cPassword, "weak?", t_weak, 0);
48
+ rb_define_method(cPassword, "strong?", t_strong, 0);
49
+ }
@@ -0,0 +1,23 @@
1
+ require "test/unit"
2
+ unless File.exist?(File.dirname(__FILE__)+"/../ext/rubylibcrack.so")
3
+ puts "You must build the extension before running these tests. The rake task :test calls the :build_extension task and does all this for you."
4
+ puts 'Alternatively, you can run this command: "cd ext; ruby extconf.rb; make; cd ../"'
5
+ exit 0
6
+ end
7
+ require File.dirname(__FILE__)+"/../ext/rubylibcrack"
8
+
9
+ class PasswordTest < Test::Unit::TestCase
10
+ def test_password
11
+ poor_password = Password.new("hello")
12
+ assert_kind_of Password, poor_password
13
+ assert !poor_password.strong?
14
+ assert poor_password.weak?
15
+ assert_not_nil poor_password.message
16
+
17
+ good_password = Password.new("jUY d3 i5 gr38")
18
+ assert_kind_of Password, good_password
19
+ assert good_password.strong?
20
+ assert !good_password.weak?
21
+ assert_nil good_password.message
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: rubylibcrack
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2007-12-28 00:00:00 +00:00
8
+ summary: A Ruby binding to the password strength checker, libcrack/cracklib.
9
+ require_paths:
10
+ - ext
11
+ email: rubyforge@scottishclimbs.com
12
+ homepage: http://mark.scottishclimbs.com/ (http://www.pccl.info/)
13
+ rubyforge_project: rubylibcrack
14
+ description: A Ruby binding to the password strength checker, libcrack/cracklib.
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Mark Somerville (on behalf of Purchasing Card Consultancy limited)
31
+ files:
32
+ - ext/rubylibcrack.c
33
+ - Rakefile
34
+ - History.txt
35
+ - Manifest.txt
36
+ - README.txt
37
+ test_files:
38
+ - test/test_rubylibcrack.rb
39
+ rdoc_options:
40
+ - --main
41
+ - README.txt
42
+ extra_rdoc_files:
43
+ - History.txt
44
+ - Manifest.txt
45
+ - README.txt
46
+ executables: []
47
+
48
+ extensions:
49
+ - ext/extconf.rb
50
+ requirements: []
51
+
52
+ dependencies:
53
+ - !ruby/object:Gem::Dependency
54
+ name: hoe
55
+ version_requirement:
56
+ version_requirements: !ruby/object:Gem::Version::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.4.0
61
+ version: