rkeychain 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGELOG +6 -0
  2. data/VERSION +1 -1
  3. data/ext/rkeychain.c +44 -8
  4. metadata +48 -41
data/CHANGELOG CHANGED
@@ -1,5 +1,11 @@
1
1
  = CHANGELOG
2
2
 
3
+ == Version 0.2.0
4
+ * Use rb_str_new to avoid problems with strings that are not null-terminated.
5
+ * Support for secure notes.
6
+
7
+ Thanks to Dave Vasilevsky (djvasi |at| gmail.com) for these new features!
8
+
3
9
  == Version 0.1.0
4
10
 
5
11
  Initial release.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -34,7 +34,7 @@ static VALUE __s_generic_passwd(VALUE self,
34
34
  &passwordLength, &passwordData, NULL);
35
35
 
36
36
  if (status == noErr) {
37
- str = rb_str_new2(passwordData);
37
+ str = rb_str_new(passwordData, passwordLength);
38
38
  SecKeychainItemFreeContent(NULL, passwordData);
39
39
  }
40
40
  else {
@@ -81,9 +81,40 @@ static VALUE s_lookup_generic_passwd(VALUE self, VALUE hash)
81
81
  return __s_generic_passwd(self, keychain, serviceName, accountName);
82
82
  }
83
83
 
84
+ /*
85
+ * On success the lookup returns the *first* secure note which
86
+ * matches the specified query else it returns nil.
87
+ * Unless you granted the application permanent access to a keychain,
88
+ * a dialog window will appear, asking for permission to read
89
+ * the password information from it.
90
+ *
91
+ * A hash with the following key/values is accepted:
92
+ * "keychain" => <path to keychain> (default: login.keychain)
93
+ * "name" => <secure note name> (mandatory)
94
+ */
95
+ static VALUE s_lookup_secure_note(VALUE self, VALUE hash)
96
+ {
97
+ VALUE keychain = rb_hash_aref(hash, rb_str_new2("keychain"));
98
+ VALUE name = rb_hash_aref(hash, rb_str_new2("name"));
99
+
100
+ if (name == Qnil) {
101
+ rb_raise(rb_eArgError, "no name provided");
102
+ }
103
+
104
+ /* A secure note is just a weird generic password */
105
+ VALUE ret = __s_generic_passwd(self, keychain, name, rb_str_new2(""));
106
+
107
+ if (ret != Qnil) {
108
+ /* Keychain forces CR, change to NL */
109
+ rb_funcall(ret, rb_intern("gsub!"), 2, rb_str_new2("\r"),
110
+ rb_str_new2("\n"));
111
+ }
112
+
113
+ return ret;
114
+ }
84
115
 
85
- static VALUE __s_internet_passwd(VALUE self, VALUE keychain, VALUE serverName, VALUE accountName)
86
116
 
117
+ static VALUE __s_internet_passwd(VALUE self, VALUE keychain, VALUE serverName, VALUE accountName)
87
118
  {
88
119
  VALUE str;
89
120
 
@@ -116,7 +147,7 @@ static VALUE __s_internet_passwd(VALUE self, VALUE keychain, VALUE serverName, V
116
147
 
117
148
 
118
149
  if (status == noErr) {
119
- str = rb_str_new2(passwordData);
150
+ str = rb_str_new(passwordData, passwordLength);
120
151
  SecKeychainItemFreeContent(NULL, passwordData);
121
152
  }
122
153
  else {
@@ -127,9 +158,7 @@ static VALUE __s_internet_passwd(VALUE self, VALUE keychain, VALUE serverName, V
127
158
  CFRelease(s_keychain);
128
159
  }
129
160
 
130
- return str;
131
-
132
-
161
+ return str;
133
162
  }
134
163
 
135
164
  /*
@@ -173,7 +202,14 @@ VALUE cKeychain;
173
202
  void Init_rkeychain()
174
203
  {
175
204
  cKeychain = rb_define_module("Keychain");
176
- rb_define_module_function(cKeychain, "lookup_generic_passwd", s_lookup_generic_passwd, 1);
177
- rb_define_module_function(cKeychain, "lookup_internet_passwd", s_lookup_internet_passwd, 1);
205
+
206
+ rb_define_module_function(cKeychain, "lookup_generic_passwd",
207
+ s_lookup_generic_passwd, 1);
208
+
209
+ rb_define_module_function(cKeychain, "lookup_internet_passwd",
210
+ s_lookup_internet_passwd, 1);
211
+
212
+ rb_define_module_function(cKeychain, "lookup_secure_note",
213
+ s_lookup_secure_note, 1);
178
214
  }
179
215
 
metadata CHANGED
@@ -1,65 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.1
3
- specification_version: 1
4
2
  name: rkeychain
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.1.0
7
- date: 2007-03-02 00:00:00 +13:00
8
- summary: rkeychain provides access to MacOS X' keychain facilities.
9
- require_paths:
10
- - libext
11
- email: olohmann@gmail.com
12
- homepage: http://rkeychain.rubyforge.org
13
- rubyforge_project: rkeychain
14
- description: rkeychain provides access to MacOS X' keychain facilities which are part of the security framework.
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:
4
+ version: 0.2.0
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
7
  - Oliver Lohmann
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-09-07 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: rkeychain provides access to MacOS X' keychain facilities which are part of the security framework.
17
+ email: olohmann@gmail.com
18
+ executables: []
19
+
20
+ extensions:
21
+ - ext/extconf.rb
22
+ extra_rdoc_files:
23
+ - README
24
+ - INSTALL
25
+ - TODO
26
+ - CHANGELOG
27
+ - LICENSE
28
+ - ext/rkeychain.c
31
29
  files:
32
30
  - CHANGELOG
33
- - example
34
- - ext
35
31
  - INSTALL
36
32
  - LICENSE
37
- - Rakefile
38
33
  - README
34
+ - Rakefile
39
35
  - TODO
40
36
  - VERSION
37
+ - example
41
38
  - example/example.rb
39
+ - ext
42
40
  - ext/extconf.rb
43
41
  - ext/rkeychain.c
44
- test_files: []
45
-
42
+ has_rdoc: true
43
+ homepage: http://rkeychain.rubyforge.org
44
+ post_install_message:
46
45
  rdoc_options:
47
46
  - --title
48
47
  - Keychain Documentation
49
48
  - --main
50
49
  - README
51
- extra_rdoc_files:
52
- - README
53
- - INSTALL
54
- - TODO
55
- - CHANGELOG
56
- - LICENSE
57
- - ext/rkeychain.c
58
- executables: []
59
-
60
- extensions:
61
- - ext/extconf.rb
50
+ require_paths:
51
+ - libext
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
62
64
  requirements: []
63
65
 
64
- dependencies: []
66
+ rubyforge_project: rkeychain
67
+ rubygems_version: 1.0.1
68
+ signing_key:
69
+ specification_version: 2
70
+ summary: rkeychain provides access to MacOS X' keychain facilities.
71
+ test_files: []
65
72