ruby-shadow 2.1.2
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/HISTORY +53 -0
- data/MANIFEST +8 -0
- data/README +87 -0
- data/README.euc +80 -0
- data/depend +9 -0
- data/extconf.rb +29 -0
- data/ruby-shadow.gemspec +17 -0
- data/shadow.c +295 -0
- metadata +69 -0
data/HISTORY
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
[2011/02/08]
|
2
|
+
* Version 2.1.2
|
3
|
+
- Jeff Blaine <>, Adam Palmblad <adam.palmblad@teampages.com>:
|
4
|
+
Fix issues with compiling against Solaris. Apparently solaris does not offer sgetspent
|
5
|
+
compiling against ruby 1.8; fixes were made to the ruby header path.
|
6
|
+
[2011/02/08]
|
7
|
+
* Version 2.1.1
|
8
|
+
- Eric Hankins <ssilver@stormsilver.net>: Looks like there was a minor bug in
|
9
|
+
compiling against ruby 1.8; fixes were made to the ruby header path.
|
10
|
+
[2011/01/27]
|
11
|
+
* Version 2.1
|
12
|
+
- Ian Marlier <imarlier@brightcove.com>: Make ruby-shadow compile under Ruby 1.9.2
|
13
|
+
* STR2CSTR macro was removed in Ruby 1.9.2, after being deprecated in Ruby 1.8. Change
|
14
|
+
to StringValuePtr() in its place.
|
15
|
+
|
16
|
+
[2010/07/27]
|
17
|
+
* Version 2.0
|
18
|
+
- Adam Palmblad <adam.palmblad@teampages.com>: Make ruby-shadow compile under Ruby 1.9
|
19
|
+
|
20
|
+
[1999/08/18]
|
21
|
+
* version 1.4.1
|
22
|
+
- extconf.rb supports glibc2(libc6).
|
23
|
+
|
24
|
+
[1999/03/09]
|
25
|
+
* version 1.4
|
26
|
+
- require ruby-1.3 or later version.
|
27
|
+
- sShadowPasswd,mShadow,eFileLock was renamed.
|
28
|
+
- FileLock class is inner class of Shadow Module.
|
29
|
+
- lock,unlock was changed.
|
30
|
+
- lock? method was added.
|
31
|
+
- getspent,fgetspent doesn't raise EOFError
|
32
|
+
- class hierarchy was changed.
|
33
|
+
Shadow Module
|
34
|
+
+ Passwd Module
|
35
|
+
+ Entry Structure
|
36
|
+
+ Group Module (not implemented yet)
|
37
|
+
+ Entry Structure (not implemented yet)
|
38
|
+
+ FileLock Class
|
39
|
+
|
40
|
+
[1998/12/17]
|
41
|
+
* version 1.3
|
42
|
+
- require ruby-1.1d0 or later version.
|
43
|
+
|
44
|
+
[1998/10/31]
|
45
|
+
* version 1.2
|
46
|
+
- only some bug fix.
|
47
|
+
|
48
|
+
[1998/08/31]
|
49
|
+
* version 1.1
|
50
|
+
- structure Shadow::ShadowPasswd is added.
|
51
|
+
|
52
|
+
[1998/07/15]
|
53
|
+
* version 1.0 released.
|
data/MANIFEST
ADDED
data/README
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
Shadow Password module
|
2
|
+
|
3
|
+
Copyright (C) 1998-1999 Takaaki Tateishi <ttate@jaist.ac.jp>
|
4
|
+
Modified at: <1999/8/19 06:47:14 by ttate>
|
5
|
+
License: Free for any use with your own risk!
|
6
|
+
|
7
|
+
|
8
|
+
1. What's this
|
9
|
+
|
10
|
+
This is the module which used when you access linux shadow password files.
|
11
|
+
|
12
|
+
Recent versions work on both Linux and Solaris.
|
13
|
+
|
14
|
+
2. install
|
15
|
+
|
16
|
+
ruby extconf.rb
|
17
|
+
make
|
18
|
+
(make install)
|
19
|
+
|
20
|
+
* Note:
|
21
|
+
Version 2 was developed to compile on Ruby 1.9. 1.8 compatibility should be
|
22
|
+
still present, but no promises about earlier versions of Ruby.
|
23
|
+
|
24
|
+
3. Shadow::Passwd module's methods
|
25
|
+
|
26
|
+
getspent
|
27
|
+
getspnam(name)
|
28
|
+
setspent
|
29
|
+
endspent
|
30
|
+
fgetspent(file)
|
31
|
+
sgetspent(str)
|
32
|
+
putspent(entry,file)
|
33
|
+
lckpwdf,lock
|
34
|
+
ulckpwdf,unlock
|
35
|
+
lock?
|
36
|
+
|
37
|
+
* Note: sgetspent is not available under Solaris and some other operating
|
38
|
+
systems. In current versions, that method will be completely missing.
|
39
|
+
|
40
|
+
|
41
|
+
4. Structure
|
42
|
+
|
43
|
+
Shadow::Passwd::Entry (Struct::PasswdEntry)
|
44
|
+
sp_namp - pointer to null-terminated user name.
|
45
|
+
sp_pwdp - pointer to null-terminated password.
|
46
|
+
sp_lstchg - days since Jan 1, 1970 password was last
|
47
|
+
changed.
|
48
|
+
sp_min - days before which password may not be changed.
|
49
|
+
sp_max - days after which password must be changed.
|
50
|
+
sp_warn - days before password is to expire that user is
|
51
|
+
warned of pending password expiration.
|
52
|
+
sp_inact - days after password expires that account is
|
53
|
+
considered inactive and disabled.
|
54
|
+
sp_expire - days since Jan 1, 1970 when account will be
|
55
|
+
|
56
|
+
|
57
|
+
5. Description
|
58
|
+
|
59
|
+
getspent, getspname, fgetspent and sgetspent each return
|
60
|
+
a structure Shadow::Passwd::Entry. getspent returns the
|
61
|
+
next entry from the file, and fgetspent returns the next
|
62
|
+
entry from the given stream. sgetspent returns a structure
|
63
|
+
Shadow::Passwd::Entry using the provided string as input.
|
64
|
+
getspnam searches from the current position in the file for
|
65
|
+
an entry matching name.
|
66
|
+
if you get EOF from each operation, you will get nil.
|
67
|
+
|
68
|
+
setspent and endspent may be used to begin and end, respe-
|
69
|
+
ctively, access to the shadow password file.
|
70
|
+
|
71
|
+
lckpwdf(lock) and ulckpwdf(unlock) methods should be used
|
72
|
+
to insure exclusive access to the /etc/shadow file.
|
73
|
+
when either method fail, Exception Shadow::FileLock is raised.
|
74
|
+
if you use lock as the iterator, unlock is automatically called
|
75
|
+
when you exit the iterator block.
|
76
|
+
|
77
|
+
6. Reference
|
78
|
+
|
79
|
+
* man shadow
|
80
|
+
* /usr/include/shadow.h
|
81
|
+
|
82
|
+
|
83
|
+
Original Author:
|
84
|
+
Takaaki Tateishi <ttate@jaist.ac.jp>
|
85
|
+
|
86
|
+
This GitHub repository is maintained by Adam Palmblad <adam.palmblad@teampages.com>. I'll
|
87
|
+
do my best to keep the repository reasonably up-to-date if you care to send pull requests.
|
data/README.euc
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
Shadow Password module
|
2
|
+
|
3
|
+
Copyright (C) 1998-1999 Takaaki Tateishi <ttate@jaist.ac.jp>
|
4
|
+
Modified at: <1999/8/19 06:48:01 by ttate>
|
5
|
+
License: Free for any use with your own risk!
|
6
|
+
|
7
|
+
|
8
|
+
1. ����
|
9
|
+
|
10
|
+
linux�ˤ�����shadow password�ե����������
|
11
|
+
�Υ⥸�塼�롣
|
12
|
+
|
13
|
+
|
14
|
+
2. ���ȡ���
|
15
|
+
|
16
|
+
ruby extconf.rb
|
17
|
+
make
|
18
|
+
make install
|
19
|
+
|
20
|
+
* ����
|
21
|
+
shadow-1.3�Ǥ�ruby-1.3�⤷���Ϥ���ʹߤΥС������
|
22
|
+
��ɬ�פǤ���
|
23
|
+
|
24
|
+
3. Shadow::Passwd�⥸�塼��Υ�å�ã
|
25
|
+
|
26
|
+
getspent
|
27
|
+
getspnam(name)
|
28
|
+
setspent
|
29
|
+
endspent
|
30
|
+
fgetspent(file)
|
31
|
+
sgetspent(str)
|
32
|
+
putspent(entry,file)
|
33
|
+
lckpwdf,lock
|
34
|
+
ulckpwdf,unlock
|
35
|
+
lock?
|
36
|
+
|
37
|
+
4. Structure
|
38
|
+
|
39
|
+
Shadow::Passwd::Entry (Struct::PasswdEntry)
|
40
|
+
sp_namp - pointer to null-terminated user name.
|
41
|
+
sp_pwdp - pointer to null-terminated password.
|
42
|
+
sp_lstchg - days since Jan 1, 1970 password was last
|
43
|
+
changed.
|
44
|
+
sp_min - days before which password may not be changed.
|
45
|
+
sp_max - days after which password must be changed.
|
46
|
+
sp_warn - days before password is to expire that user is
|
47
|
+
warned of pending password expiration.
|
48
|
+
sp_inact - days after password expires that account is
|
49
|
+
considered inactive and disabled.
|
50
|
+
sp_expire - days since Jan 1, 1970 when account will be
|
51
|
+
|
52
|
+
|
53
|
+
5. ����
|
54
|
+
|
55
|
+
getspent, getspname, fgetspent, sgetspent��Shadow::Passwd::Entry
|
56
|
+
���ȥ饯������֤��ޤ���getspent �ϥե����뤫�鼡�Υѥ���
|
57
|
+
���ɥ���ȥ���֤���fgetspent ��Ϳ����줿IO���鼡�Υ����
|
58
|
+
����֤��ޤ���sgetspent��Ϳ����줿ʸ����Shadow::Passwd::Entry
|
59
|
+
���ȥ饯������֤��ޤ���getspnam�ϥ桼��̾��Ϳ�����/etc/shadow
|
60
|
+
���餽�Υ桼����Shadow::Passwd::Entry���ȥ饯������֤��ޤ���
|
61
|
+
�ե�����ν�ü��ã�����nil���ͤ��֤��ޤ���
|
62
|
+
|
63
|
+
setspent,endspent�Ϥ��줾�졢�ե�����ؤΥ��������ΤϤ����
|
64
|
+
�����˻Ȥ��ޤ���
|
65
|
+
|
66
|
+
lckpwdf(lock),ulckpwdf(unlock)��/etc/shadow�ؤ���¾Ū��������
|
67
|
+
��¸����뤿��ˤ���ޤ���
|
68
|
+
lock�˼��Ԥ����Shadow::FileLock�Ȥ����㳰��ȯ�������ޤ���
|
69
|
+
lock�ƥ졼���Ȥ��ƻȤ����Ȥˤ�äơ����ƥ졼���֥��å���ȴ����
|
70
|
+
�Ȥ��˼�ưŪ��unlock��Ԥʤ��ޤ���
|
71
|
+
|
72
|
+
|
73
|
+
6. ����
|
74
|
+
|
75
|
+
* man shadow
|
76
|
+
* /usr/include/shadow.h
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
ttate@jaist.ac.jp
|
data/depend
ADDED
data/extconf.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# extconf.rb
|
3
|
+
#
|
4
|
+
# Modified at: <1999/8/19 06:38:55 by ttate>
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'mkmf'
|
8
|
+
|
9
|
+
$CFLAGS = RUBY_VERSION =~ /1\.9/ ? '-DRUBY19' : ''
|
10
|
+
|
11
|
+
#$LDFLAGS = "-lshadow"
|
12
|
+
|
13
|
+
if( ! (ok = have_library("shadow","getspent")) )
|
14
|
+
$LDFLAGS = ""
|
15
|
+
ok = have_func("getspent")
|
16
|
+
end
|
17
|
+
|
18
|
+
ok &= have_func("fgetspent")
|
19
|
+
ok &= have_func("setspent")
|
20
|
+
ok &= have_func("endspent")
|
21
|
+
ok &= have_func("lckpwdf")
|
22
|
+
ok &= have_func("ulckpwdf")
|
23
|
+
|
24
|
+
if ok
|
25
|
+
if !have_func("sgetspent")
|
26
|
+
$CFLAGS += ' -DSOLARIS'
|
27
|
+
end
|
28
|
+
create_makefile("shadow")
|
29
|
+
end
|
data/ruby-shadow.gemspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.authors = ['Adam Palmblad', 'Eric Hankins', 'Ian Marlier', 'Jeff Blaine', 'Remi Broemeling', 'Takaaki Tateishi']
|
5
|
+
spec.description = 'This module provides access to shadow passwords on Linux and Solaris'
|
6
|
+
spec.email = ['adam.palmblad@teampages.com']
|
7
|
+
spec.extensions = ['extconf.rb']
|
8
|
+
spec.files = []
|
9
|
+
File.open('MANIFEST').each { |file|
|
10
|
+
spec.files << file.chomp
|
11
|
+
}
|
12
|
+
spec.homepage = 'https://github.com/apalmblad/ruby-shadow'
|
13
|
+
spec.name = 'ruby-shadow'
|
14
|
+
spec.required_ruby_version = '>= 1.8'
|
15
|
+
spec.summary = '*nix Shadow Password Module'
|
16
|
+
spec.version = '2.1.2'
|
17
|
+
end
|
data/shadow.c
ADDED
@@ -0,0 +1,295 @@
|
|
1
|
+
/*
|
2
|
+
* shadow.c
|
3
|
+
*
|
4
|
+
* Ruby extention module for using Linux shadow password.
|
5
|
+
*
|
6
|
+
* Copyright (C) 1998-1999 by Takaaki.Tateishi(ttate@jaist.ac.jp)
|
7
|
+
* License: Free for any use with your own risk!
|
8
|
+
* Modified at: <1999/8/19 06:48:18 by ttate>
|
9
|
+
*/
|
10
|
+
|
11
|
+
#include <shadow.h>
|
12
|
+
#include "ruby.h"
|
13
|
+
#ifdef RUBY19
|
14
|
+
#include <ruby/io.h>
|
15
|
+
#else
|
16
|
+
#include "rubyio.h"
|
17
|
+
#endif
|
18
|
+
|
19
|
+
#ifdef RUBY19
|
20
|
+
#define file_ptr(x) (x)->stdio_file
|
21
|
+
#else
|
22
|
+
#define file_ptr(x) (x)->f
|
23
|
+
#endif
|
24
|
+
|
25
|
+
static VALUE rb_mShadow;
|
26
|
+
static VALUE rb_mPasswd;
|
27
|
+
static VALUE rb_sPasswdEntry;
|
28
|
+
static VALUE rb_mGroup;
|
29
|
+
static VALUE rb_sGroupEntry;
|
30
|
+
static VALUE rb_eFileLock;
|
31
|
+
|
32
|
+
|
33
|
+
static VALUE
|
34
|
+
rb_shadow_setspent(VALUE self)
|
35
|
+
{
|
36
|
+
setspent();
|
37
|
+
return Qnil;
|
38
|
+
};
|
39
|
+
|
40
|
+
|
41
|
+
static VALUE
|
42
|
+
rb_shadow_endspent(VALUE self)
|
43
|
+
{
|
44
|
+
endspent();
|
45
|
+
return Qnil;
|
46
|
+
};
|
47
|
+
|
48
|
+
|
49
|
+
#ifndef SOLARIS
|
50
|
+
static VALUE
|
51
|
+
rb_shadow_sgetspent(VALUE self, VALUE str)
|
52
|
+
{
|
53
|
+
struct spwd *entry;
|
54
|
+
VALUE result;
|
55
|
+
|
56
|
+
if( TYPE(str) != T_STRING )
|
57
|
+
rb_raise(rb_eException,"argument must be a string.");
|
58
|
+
|
59
|
+
entry = sgetspent(StringValuePtr(str));
|
60
|
+
|
61
|
+
if( entry == NULL )
|
62
|
+
return Qnil;
|
63
|
+
|
64
|
+
result = rb_struct_new(rb_sPasswdEntry,
|
65
|
+
rb_tainted_str_new2(entry->sp_namp),
|
66
|
+
rb_tainted_str_new2(entry->sp_pwdp),
|
67
|
+
INT2FIX(entry->sp_lstchg),
|
68
|
+
INT2FIX(entry->sp_min),
|
69
|
+
INT2FIX(entry->sp_max),
|
70
|
+
INT2FIX(entry->sp_warn),
|
71
|
+
INT2FIX(entry->sp_inact),
|
72
|
+
INT2FIX(entry->sp_expire),
|
73
|
+
INT2FIX(entry->sp_flag),
|
74
|
+
NULL);
|
75
|
+
free(entry);
|
76
|
+
return result;
|
77
|
+
};
|
78
|
+
#endif
|
79
|
+
|
80
|
+
static VALUE
|
81
|
+
rb_shadow_fgetspent(VALUE self, VALUE file)
|
82
|
+
{
|
83
|
+
struct spwd *entry;
|
84
|
+
VALUE result;
|
85
|
+
|
86
|
+
if( TYPE(file) != T_FILE )
|
87
|
+
rb_raise(rb_eTypeError,"argument must be a File.");
|
88
|
+
|
89
|
+
entry = fgetspent( file_ptr( (RFILE(file)->fptr) ) );
|
90
|
+
|
91
|
+
if( entry == NULL )
|
92
|
+
return Qnil;
|
93
|
+
|
94
|
+
result = rb_struct_new(rb_sPasswdEntry,
|
95
|
+
rb_tainted_str_new2(entry->sp_namp),
|
96
|
+
rb_tainted_str_new2(entry->sp_pwdp),
|
97
|
+
INT2FIX(entry->sp_lstchg),
|
98
|
+
INT2FIX(entry->sp_min),
|
99
|
+
INT2FIX(entry->sp_max),
|
100
|
+
INT2FIX(entry->sp_warn),
|
101
|
+
INT2FIX(entry->sp_inact),
|
102
|
+
INT2FIX(entry->sp_expire),
|
103
|
+
INT2FIX(entry->sp_flag),
|
104
|
+
NULL);
|
105
|
+
return result;
|
106
|
+
};
|
107
|
+
|
108
|
+
static VALUE
|
109
|
+
rb_shadow_getspent(VALUE self)
|
110
|
+
{
|
111
|
+
struct spwd *entry;
|
112
|
+
VALUE result;
|
113
|
+
|
114
|
+
entry = getspent();
|
115
|
+
|
116
|
+
if( entry == NULL )
|
117
|
+
return Qnil;
|
118
|
+
|
119
|
+
result = rb_struct_new(rb_sPasswdEntry,
|
120
|
+
rb_tainted_str_new2(entry->sp_namp),
|
121
|
+
rb_tainted_str_new2(entry->sp_pwdp),
|
122
|
+
INT2FIX(entry->sp_lstchg),
|
123
|
+
INT2FIX(entry->sp_min),
|
124
|
+
INT2FIX(entry->sp_max),
|
125
|
+
INT2FIX(entry->sp_warn),
|
126
|
+
INT2FIX(entry->sp_inact),
|
127
|
+
INT2FIX(entry->sp_expire),
|
128
|
+
INT2FIX(entry->sp_flag),
|
129
|
+
NULL);
|
130
|
+
return result;
|
131
|
+
};
|
132
|
+
|
133
|
+
static VALUE
|
134
|
+
rb_shadow_getspnam(VALUE self, VALUE name)
|
135
|
+
{
|
136
|
+
struct spwd *entry;
|
137
|
+
VALUE result;
|
138
|
+
|
139
|
+
if( TYPE(name) != T_STRING )
|
140
|
+
rb_raise(rb_eException,"argument must be a string.");
|
141
|
+
|
142
|
+
entry = getspnam(StringValuePtr(name));
|
143
|
+
|
144
|
+
if( entry == NULL )
|
145
|
+
return Qnil;
|
146
|
+
|
147
|
+
result = rb_struct_new(rb_sPasswdEntry,
|
148
|
+
rb_tainted_str_new2(entry->sp_namp),
|
149
|
+
rb_tainted_str_new2(entry->sp_pwdp),
|
150
|
+
INT2FIX(entry->sp_lstchg),
|
151
|
+
INT2FIX(entry->sp_min),
|
152
|
+
INT2FIX(entry->sp_max),
|
153
|
+
INT2FIX(entry->sp_warn),
|
154
|
+
INT2FIX(entry->sp_inact),
|
155
|
+
INT2FIX(entry->sp_expire),
|
156
|
+
INT2FIX(entry->sp_flag),
|
157
|
+
NULL);
|
158
|
+
return result;
|
159
|
+
};
|
160
|
+
|
161
|
+
|
162
|
+
static VALUE
|
163
|
+
rb_shadow_putspent(VALUE self, VALUE entry, VALUE file)
|
164
|
+
{
|
165
|
+
struct spwd centry;
|
166
|
+
FILE* cfile;
|
167
|
+
VALUE val[9];
|
168
|
+
int i;
|
169
|
+
int result;
|
170
|
+
|
171
|
+
for(i=0; i<=8; i++)
|
172
|
+
val[i] = RSTRUCT_PTR( entry )[i]; //val[i] = RSTRUCT(entry)->ptr[i];
|
173
|
+
cfile = file_pr( RFILE(file)->fptr );
|
174
|
+
|
175
|
+
centry.sp_namp = StringValuePtr(val[0]);
|
176
|
+
centry.sp_pwdp = StringValuePtr(val[1]);
|
177
|
+
centry.sp_lstchg = FIX2INT(val[2]);
|
178
|
+
centry.sp_min = FIX2INT(val[3]);
|
179
|
+
centry.sp_max = FIX2INT(val[4]);
|
180
|
+
centry.sp_warn = FIX2INT(val[5]);
|
181
|
+
centry.sp_inact = FIX2INT(val[6]);
|
182
|
+
centry.sp_expire = FIX2INT(val[7]);
|
183
|
+
centry.sp_flag = FIX2INT(val[8]);
|
184
|
+
|
185
|
+
result = putspent(¢ry,cfile);
|
186
|
+
|
187
|
+
if( result == -1 )
|
188
|
+
rb_raise(rb_eStandardError,"can't change password");
|
189
|
+
|
190
|
+
return Qtrue;
|
191
|
+
};
|
192
|
+
|
193
|
+
|
194
|
+
static VALUE
|
195
|
+
rb_shadow_lckpwdf(VALUE self)
|
196
|
+
{
|
197
|
+
int result;
|
198
|
+
result = lckpwdf();
|
199
|
+
if( result == -1 )
|
200
|
+
rb_raise(rb_eFileLock,"password file was locked");
|
201
|
+
else
|
202
|
+
return Qtrue;
|
203
|
+
};
|
204
|
+
|
205
|
+
static int in_lock;
|
206
|
+
|
207
|
+
static VALUE
|
208
|
+
rb_shadow_lock(VALUE self)
|
209
|
+
{
|
210
|
+
int result;
|
211
|
+
|
212
|
+
if( rb_iterator_p() ){
|
213
|
+
result = lckpwdf();
|
214
|
+
if( result == -1 ){
|
215
|
+
rb_raise(rb_eFileLock,"password file was locked");
|
216
|
+
}
|
217
|
+
else{
|
218
|
+
in_lock++;
|
219
|
+
rb_yield(Qnil);
|
220
|
+
in_lock--;
|
221
|
+
ulckpwdf();
|
222
|
+
};
|
223
|
+
return Qtrue;
|
224
|
+
}
|
225
|
+
else{
|
226
|
+
return rb_shadow_lckpwdf(self);
|
227
|
+
};
|
228
|
+
};
|
229
|
+
|
230
|
+
|
231
|
+
static VALUE
|
232
|
+
rb_shadow_ulckpwdf(VALUE self)
|
233
|
+
{
|
234
|
+
if( in_lock ){
|
235
|
+
rb_raise(rb_eFileLock,"you call unlock method in lock iterator.");
|
236
|
+
};
|
237
|
+
ulckpwdf();
|
238
|
+
return Qtrue;
|
239
|
+
};
|
240
|
+
|
241
|
+
static VALUE
|
242
|
+
rb_shadow_unlock(VALUE self)
|
243
|
+
{
|
244
|
+
return rb_shadow_ulckpwdf(self);
|
245
|
+
};
|
246
|
+
|
247
|
+
static VALUE
|
248
|
+
rb_shadow_lock_p(VALUE self)
|
249
|
+
{
|
250
|
+
int result;
|
251
|
+
|
252
|
+
result = lckpwdf();
|
253
|
+
if( result == -1 ){
|
254
|
+
return Qtrue;
|
255
|
+
}
|
256
|
+
else{
|
257
|
+
ulckpwdf();
|
258
|
+
return Qfalse;
|
259
|
+
};
|
260
|
+
};
|
261
|
+
|
262
|
+
|
263
|
+
void
|
264
|
+
Init_shadow()
|
265
|
+
{
|
266
|
+
rb_sPasswdEntry = rb_struct_define("PasswdEntry",
|
267
|
+
"sp_namp","sp_pwdp","sp_lstchg",
|
268
|
+
"sp_min","sp_max","sp_warn",
|
269
|
+
"sp_inact","sp_expire","sp_flag", NULL);
|
270
|
+
rb_sGroupEntry = rb_struct_define("GroupEntry",
|
271
|
+
"sg_name","sg_passwd",
|
272
|
+
"sg_adm","sg_mem",NULL);
|
273
|
+
|
274
|
+
rb_mShadow = rb_define_module("Shadow");
|
275
|
+
rb_eFileLock = rb_define_class_under(rb_mShadow,"FileLock",rb_eException);
|
276
|
+
rb_mPasswd = rb_define_module_under(rb_mShadow,"Passwd");
|
277
|
+
rb_define_const(rb_mPasswd,"Entry",rb_sPasswdEntry);
|
278
|
+
rb_mGroup = rb_define_module_under(rb_mShadow,"Group");
|
279
|
+
rb_define_const(rb_mGroup,"Entry",rb_sGroupEntry);
|
280
|
+
|
281
|
+
rb_define_module_function(rb_mPasswd,"setspent",rb_shadow_setspent,0);
|
282
|
+
rb_define_module_function(rb_mPasswd,"endspent",rb_shadow_endspent,0);
|
283
|
+
#ifndef SOLARIS
|
284
|
+
rb_define_module_function(rb_mPasswd,"sgetspent",rb_shadow_sgetspent,1);
|
285
|
+
#endif
|
286
|
+
rb_define_module_function(rb_mPasswd,"fgetspent",rb_shadow_fgetspent,1);
|
287
|
+
rb_define_module_function(rb_mPasswd,"getspent",rb_shadow_getspent,0);
|
288
|
+
rb_define_module_function(rb_mPasswd,"getspnam",rb_shadow_getspnam,1);
|
289
|
+
rb_define_module_function(rb_mPasswd,"putspent",rb_shadow_putspent,2);
|
290
|
+
rb_define_module_function(rb_mPasswd,"lckpwdf",rb_shadow_lckpwdf,0);
|
291
|
+
rb_define_module_function(rb_mPasswd,"lock",rb_shadow_lock,0);
|
292
|
+
rb_define_module_function(rb_mPasswd,"ulckpwdf",rb_shadow_ulckpwdf,0);
|
293
|
+
rb_define_module_function(rb_mPasswd,"unlock",rb_shadow_unlock,0);
|
294
|
+
rb_define_module_function(rb_mPasswd,"lock?",rb_shadow_lock_p,0);
|
295
|
+
};
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-shadow
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 2.1.2
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Adam Palmblad
|
9
|
+
- Eric Hankins
|
10
|
+
- Ian Marlier
|
11
|
+
- Jeff Blaine
|
12
|
+
- Remi Broemeling
|
13
|
+
- Takaaki Tateishi
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-13 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: This module provides access to shadow passwords on Linux and Solaris
|
23
|
+
email:
|
24
|
+
- adam.palmblad@teampages.com
|
25
|
+
executables: []
|
26
|
+
|
27
|
+
extensions:
|
28
|
+
- extconf.rb
|
29
|
+
extra_rdoc_files: []
|
30
|
+
|
31
|
+
files:
|
32
|
+
- extconf.rb
|
33
|
+
- depend
|
34
|
+
- HISTORY
|
35
|
+
- MANIFEST
|
36
|
+
- README
|
37
|
+
- README.euc
|
38
|
+
- ruby-shadow.gemspec
|
39
|
+
- shadow.c
|
40
|
+
has_rdoc: true
|
41
|
+
homepage: https://github.com/apalmblad/ruby-shadow
|
42
|
+
licenses: []
|
43
|
+
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "1.8"
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
requirements: []
|
62
|
+
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.5.2
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: "*nix Shadow Password Module"
|
68
|
+
test_files: []
|
69
|
+
|