nis 0.1.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/.gitignore +6 -0
- data/MANIFEST +12 -0
- data/README +27 -0
- data/README.html +37 -0
- data/Rakefile +47 -0
- data/doc/NIS-HOWTO.html +118 -0
- data/ext/nis/extconf.rb +13 -0
- data/ext/nis/nis.c +11 -0
- data/ext/nis/nis.h +14 -0
- data/ext/nis/yp.c +308 -0
- data/lib/nis.rb +9 -0
- data/lib/nis/version.rb +3 -0
- data/nis.gemspec +62 -0
- data/test/yp_all.rb +19 -0
- data/test/yp_all2.rb +21 -0
- data/test/yp_first.rb +11 -0
- data/test/yp_match.rb +7 -0
- metadata +88 -0
data/.gitignore
ADDED
data/MANIFEST
ADDED
data/README
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Ruby/NIS
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2001, Takaaki Tateishi (ttate@jaist.ac.jp)
|
|
4
|
+
-------------------------------------------------------------------------------
|
|
5
|
+
|
|
6
|
+
Description
|
|
7
|
+
|
|
8
|
+
This module provides only the module for NIS(YP) API.
|
|
9
|
+
-------------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
YP Module
|
|
12
|
+
|
|
13
|
+
Constant:
|
|
14
|
+
|
|
15
|
+
* YPERR_....
|
|
16
|
+
* YPOP_....
|
|
17
|
+
|
|
18
|
+
Module Functions:
|
|
19
|
+
|
|
20
|
+
* yp_all(domain, map, callback)
|
|
21
|
+
* yp_all(domain, map){|status, key, val| ... }
|
|
22
|
+
* key, val = yp_first(domain, map)
|
|
23
|
+
* next_key, next_val = yp_next(domain, map, key)
|
|
24
|
+
* val = yp_match(domain, map, key)
|
|
25
|
+
* yp_update(domain, map, ypop, key, val)
|
|
26
|
+
|
|
27
|
+
-------------------------------------------------------------------------------
|
data/README.html
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head><title>Ruby/NIS</title></head>
|
|
3
|
+
<body>
|
|
4
|
+
|
|
5
|
+
<center>
|
|
6
|
+
<h1>Ruby/NIS</h1>
|
|
7
|
+
Copyright (C) 2001, Takaaki Tateishi (ttate@jaist.ac.jp)
|
|
8
|
+
</center>
|
|
9
|
+
|
|
10
|
+
<hr>
|
|
11
|
+
<h2>Description</h2>
|
|
12
|
+
|
|
13
|
+
This module provides the module for NIS(YP) API.
|
|
14
|
+
|
|
15
|
+
<hr>
|
|
16
|
+
<h2>YP Module</h2>
|
|
17
|
+
|
|
18
|
+
Constant:
|
|
19
|
+
<ul>
|
|
20
|
+
<li>YPERR_....
|
|
21
|
+
<li>YPOP_....
|
|
22
|
+
</ul>
|
|
23
|
+
|
|
24
|
+
Module Functions:
|
|
25
|
+
<ul>
|
|
26
|
+
<li>yp_all(domain, map, callback)
|
|
27
|
+
<li>yp_all(domain, map){|status, key, val| ... }
|
|
28
|
+
<li>key, val = yp_first(domain, map)
|
|
29
|
+
<li>next_key, next_val = yp_next(domain, map, key)
|
|
30
|
+
<li>val = yp_match(domain, map, key)
|
|
31
|
+
<li>yp_update(domain, map, ypop, key, val)
|
|
32
|
+
</ul>
|
|
33
|
+
|
|
34
|
+
<hr>
|
|
35
|
+
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
data/Rakefile
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'hoe'
|
|
2
|
+
|
|
3
|
+
require 'lib/nis/version.rb'
|
|
4
|
+
|
|
5
|
+
begin
|
|
6
|
+
require 'jeweler'
|
|
7
|
+
Jeweler::Tasks.new do |gem|
|
|
8
|
+
gem.name = "nis"
|
|
9
|
+
gem.summary = %Q{Provides an interface for NIS(YP) API.}
|
|
10
|
+
gem.description = %Q{Provides an interface for NIS(YP) API.}
|
|
11
|
+
gem.email = 'ttate@users.sourceforge.net'
|
|
12
|
+
gem.homepage = 'http://raa.ruby-lang.org/project/ruby-nis/'
|
|
13
|
+
gem.authors = ['Takaaki Tateishi']
|
|
14
|
+
gem.version = NIS::VERSION
|
|
15
|
+
gem.files.include "lib/nis/nis.so"
|
|
16
|
+
end
|
|
17
|
+
Jeweler::GemcutterTasks.new
|
|
18
|
+
rescue LoadError
|
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# HOE = Hoe.spec 'nokogiri' do
|
|
23
|
+
# developer 'Takaaki Tateishi', 'ttate@users.sourceforge.net'
|
|
24
|
+
# self.clean_globs = [
|
|
25
|
+
# 'ext/nis/*.{o,so,bundle,a,log,dll}',
|
|
26
|
+
# 'lib/nis/*.{o,so,bundle,a,log,dll}',
|
|
27
|
+
# ]
|
|
28
|
+
# self.spec_extras = { :extensions => ["ext/nis/extconf.rb"] }
|
|
29
|
+
# end
|
|
30
|
+
# Hoe.add_include_dirs '.'
|
|
31
|
+
|
|
32
|
+
task 'ext/nis/Makefile' do
|
|
33
|
+
Dir.chdir('ext/nis') do
|
|
34
|
+
ruby "extconf.rb"
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
task 'lib/nis/nis.so' => 'ext/nis/Makefile' do
|
|
39
|
+
Dir.chdir('ext/nis') do
|
|
40
|
+
sh 'make'
|
|
41
|
+
end
|
|
42
|
+
FileUtils.cp 'ext/nis/nis.so', 'lib/nis'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
task :build => 'lib/nis/nis.so'
|
|
46
|
+
|
|
47
|
+
task :default => [:build]
|
data/doc/NIS-HOWTO.html
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
2
|
+
<HTML>
|
|
3
|
+
<HEAD>
|
|
4
|
+
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
|
|
5
|
+
<TITLE>The Linux NIS(YP)/NYS/NIS+ HOWTO</TITLE>
|
|
6
|
+
<LINK HREF="NIS-HOWTO-1.html" REL=next>
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
</HEAD>
|
|
10
|
+
<BODY>
|
|
11
|
+
<A HREF="NIS-HOWTO-1.html">Next</A>
|
|
12
|
+
Previous
|
|
13
|
+
Contents
|
|
14
|
+
<HR>
|
|
15
|
+
<H1>The Linux NIS(YP)/NYS/NIS+ HOWTO</H1>
|
|
16
|
+
|
|
17
|
+
<H2>Thorsten Kukuk</H2>v1.0, 09. March 1999
|
|
18
|
+
<P><HR>
|
|
19
|
+
<EM>
|
|
20
|
+
<!--
|
|
21
|
+
HOWTOs!NIS
|
|
22
|
+
-->
|
|
23
|
+
|
|
24
|
+
<!--
|
|
25
|
+
HOWTOs!YP
|
|
26
|
+
-->
|
|
27
|
+
|
|
28
|
+
<!--
|
|
29
|
+
HOWTOs!NYS
|
|
30
|
+
-->
|
|
31
|
+
|
|
32
|
+
<!--
|
|
33
|
+
HOWTOs!NIS+
|
|
34
|
+
-->
|
|
35
|
+
|
|
36
|
+
This document describes how to configure Linux as NIS(YP) or NIS+ client
|
|
37
|
+
and how to install as NIS server.</EM>
|
|
38
|
+
<HR>
|
|
39
|
+
<P>
|
|
40
|
+
<H2><A NAME="toc1">1.</A> <A HREF="NIS-HOWTO-1.html">Introduction</A></H2>
|
|
41
|
+
|
|
42
|
+
<UL>
|
|
43
|
+
<LI><A HREF="NIS-HOWTO-1.html#ss1.1">1.1 New Versions of this Document</A>
|
|
44
|
+
<LI><A HREF="NIS-HOWTO-1.html#ss1.2">1.2 Disclaimer</A>
|
|
45
|
+
<LI><A HREF="NIS-HOWTO-1.html#ss1.3">1.3 Feedback and Corrections</A>
|
|
46
|
+
<LI><A HREF="NIS-HOWTO-1.html#ss1.4">1.4 Acknowledgements</A>
|
|
47
|
+
</UL>
|
|
48
|
+
<P>
|
|
49
|
+
<H2><A NAME="toc2">2.</A> <A HREF="NIS-HOWTO-2.html">Glossary and General Information</A></H2>
|
|
50
|
+
|
|
51
|
+
<UL>
|
|
52
|
+
<LI><A HREF="NIS-HOWTO-2.html#ss2.1">2.1 Glossary of Terms</A>
|
|
53
|
+
<LI><A HREF="NIS-HOWTO-2.html#ss2.2">2.2 Some General Information</A>
|
|
54
|
+
</UL>
|
|
55
|
+
<P>
|
|
56
|
+
<H2><A NAME="toc3">3.</A> <A HREF="NIS-HOWTO-3.html">NIS, NYS or NIS+ ?</A></H2>
|
|
57
|
+
|
|
58
|
+
<UL>
|
|
59
|
+
<LI><A HREF="NIS-HOWTO-3.html#ss3.1">3.1 libc 4/5 with traditional NIS or NYS ?</A>
|
|
60
|
+
<LI><A HREF="NIS-HOWTO-3.html#ss3.2">3.2 glibc 2 and NIS/NIS+</A>
|
|
61
|
+
<LI><A HREF="NIS-HOWTO-3.html#ss3.3">3.3 NIS or NIS+ ?</A>
|
|
62
|
+
</UL>
|
|
63
|
+
<P>
|
|
64
|
+
<H2><A NAME="toc4">4.</A> <A HREF="NIS-HOWTO-4.html">How it works</A></H2>
|
|
65
|
+
|
|
66
|
+
<UL>
|
|
67
|
+
<LI><A HREF="NIS-HOWTO-4.html#ss4.1">4.1 How NIS works</A>
|
|
68
|
+
<LI><A HREF="NIS-HOWTO-4.html#ss4.2">4.2 How NIS+ works</A>
|
|
69
|
+
</UL>
|
|
70
|
+
<P>
|
|
71
|
+
<H2><A NAME="toc5">5.</A> <A HREF="NIS-HOWTO-5.html">The RPC Portmapper</A></H2>
|
|
72
|
+
|
|
73
|
+
<P>
|
|
74
|
+
<H2><A NAME="toc6">6.</A> <A HREF="NIS-HOWTO-6.html">What do you need to set up NIS?</A></H2>
|
|
75
|
+
|
|
76
|
+
<UL>
|
|
77
|
+
<LI><A HREF="NIS-HOWTO-6.html#ss6.1">6.1 Determine whether you are a Server, Slave or Client.</A>
|
|
78
|
+
<LI><A HREF="NIS-HOWTO-6.html#ss6.2">6.2 The Software</A>
|
|
79
|
+
<LI><A HREF="NIS-HOWTO-6.html#ss6.3">6.3 The ypbind daemon</A>
|
|
80
|
+
<LI><A HREF="NIS-HOWTO-6.html#ss6.4">6.4 Setting up a NIS Client using Traditional NIS</A>
|
|
81
|
+
<LI><A HREF="NIS-HOWTO-6.html#ss6.5">6.5 Setting up a NIS Client using NYS</A>
|
|
82
|
+
<LI><A HREF="NIS-HOWTO-6.html#ss6.6">6.6 Setting up a NIS Client using glibc 2.x</A>
|
|
83
|
+
<LI><A HREF="NIS-HOWTO-6.html#ss6.7">6.7 The nsswitch.conf File</A>
|
|
84
|
+
<LI><A HREF="NIS-HOWTO-6.html#ss6.8">6.8 Shadow Passwords with NIS</A>
|
|
85
|
+
</UL>
|
|
86
|
+
<P>
|
|
87
|
+
<H2><A NAME="toc7">7.</A> <A HREF="NIS-HOWTO-7.html">What do you need to set up NIS+ ?</A></H2>
|
|
88
|
+
|
|
89
|
+
<UL>
|
|
90
|
+
<LI><A HREF="NIS-HOWTO-7.html#ss7.1">7.1 The Software</A>
|
|
91
|
+
<LI><A HREF="NIS-HOWTO-7.html#ss7.2">7.2 Setting up a NIS+ client</A>
|
|
92
|
+
<LI><A HREF="NIS-HOWTO-7.html#ss7.3">7.3 NIS+, keylogin, login and PAM</A>
|
|
93
|
+
<LI><A HREF="NIS-HOWTO-7.html#ss7.4">7.4 The nsswitch.conf File</A>
|
|
94
|
+
</UL>
|
|
95
|
+
<P>
|
|
96
|
+
<H2><A NAME="toc8">8.</A> <A HREF="NIS-HOWTO-8.html">Setting up a NIS Server</A></H2>
|
|
97
|
+
|
|
98
|
+
<UL>
|
|
99
|
+
<LI><A HREF="NIS-HOWTO-8.html#ss8.1">8.1 The Server Program ypserv</A>
|
|
100
|
+
<LI><A HREF="NIS-HOWTO-8.html#ss8.2">8.2 The Server Program yps</A>
|
|
101
|
+
<LI><A HREF="NIS-HOWTO-8.html#ss8.3">8.3 The Program rpc.ypxfrd</A>
|
|
102
|
+
<LI><A HREF="NIS-HOWTO-8.html#ss8.4">8.4 The Program rpc.yppasswdd</A>
|
|
103
|
+
</UL>
|
|
104
|
+
<P>
|
|
105
|
+
<H2><A NAME="toc9">9.</A> <A HREF="NIS-HOWTO-9.html">Verifying the NIS/NYS Installation</A></H2>
|
|
106
|
+
|
|
107
|
+
<P>
|
|
108
|
+
<H2><A NAME="toc10">10.</A> <A HREF="NIS-HOWTO-10.html">Common Problems and Troubleshooting NIS</A></H2>
|
|
109
|
+
|
|
110
|
+
<P>
|
|
111
|
+
<H2><A NAME="toc11">11.</A> <A HREF="NIS-HOWTO-11.html">Frequently Asked Questions</A></H2>
|
|
112
|
+
|
|
113
|
+
<HR>
|
|
114
|
+
<A HREF="NIS-HOWTO-1.html">Next</A>
|
|
115
|
+
Previous
|
|
116
|
+
Contents
|
|
117
|
+
</BODY>
|
|
118
|
+
</HTML>
|
data/ext/nis/extconf.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'mkmf'
|
|
2
|
+
|
|
3
|
+
dir_config('yp')
|
|
4
|
+
dir_config('nis')
|
|
5
|
+
|
|
6
|
+
nis_h = have_header('rpcsvc/nis.h')
|
|
7
|
+
ypclnt_h = have_header('rpcsvc/ypclnt.h')
|
|
8
|
+
ypprot_h = have_header('rpcsvc/yp_prot.h')
|
|
9
|
+
libnsl = have_library('nsl')
|
|
10
|
+
|
|
11
|
+
if( libnsl && ypclnt_h && ypprot_h )
|
|
12
|
+
create_makefile('nis')
|
|
13
|
+
end
|
data/ext/nis/nis.c
ADDED
data/ext/nis/nis.h
ADDED
data/ext/nis/yp.c
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/* -*- C -*-
|
|
2
|
+
* $Id: yp.c,v 1.4 2001/04/20 07:07:42 ttate Exp $
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#include "nis.h"
|
|
6
|
+
#include <rpcsvc/ypclnt.h>
|
|
7
|
+
#include <rpcsvc/yp_prot.h>
|
|
8
|
+
|
|
9
|
+
#ifndef YPERR_SUCCESS
|
|
10
|
+
# define YPERR_SUCCESS (0)
|
|
11
|
+
#endif
|
|
12
|
+
|
|
13
|
+
VALUE rb_mYP;
|
|
14
|
+
VALUE rb_eYPError;
|
|
15
|
+
|
|
16
|
+
void
|
|
17
|
+
rb_yp_check_yperr(err)
|
|
18
|
+
{
|
|
19
|
+
switch( err ){
|
|
20
|
+
case YPERR_SUCCESS:
|
|
21
|
+
break;
|
|
22
|
+
default:
|
|
23
|
+
rb_raise(rb_eYPError, yperr_string(err));
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
VALUE
|
|
28
|
+
rb_yp_get_default_domain(VALUE self)
|
|
29
|
+
{
|
|
30
|
+
char *domainname;
|
|
31
|
+
int err;
|
|
32
|
+
|
|
33
|
+
if((err = yp_get_default_domain(&domainname)) != 0){
|
|
34
|
+
rb_raise(rb_eYPError, yperr_string(err));
|
|
35
|
+
};
|
|
36
|
+
return rb_tainted_str_new2(domainname);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
VALUE
|
|
40
|
+
rb_yperr_string(VALUE self, VALUE err)
|
|
41
|
+
{
|
|
42
|
+
return rb_tainted_str_new2(yperr_string(FIX2INT(err)));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
static int
|
|
46
|
+
rb_ypall_callback(int status, char *inkey, int inkeylen, char *inval,
|
|
47
|
+
int invallen, char *indata)
|
|
48
|
+
{
|
|
49
|
+
VALUE cb = (VALUE)indata;
|
|
50
|
+
VALUE res, key, val;
|
|
51
|
+
|
|
52
|
+
if( inkeylen > 0 ){
|
|
53
|
+
key = rb_tainted_str_new(inkey, inkeylen);
|
|
54
|
+
}
|
|
55
|
+
else{
|
|
56
|
+
key = Qnil;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
if( invallen > 0 ){
|
|
60
|
+
val = rb_tainted_str_new(inval, invallen);
|
|
61
|
+
}
|
|
62
|
+
else{
|
|
63
|
+
val = Qnil;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
if( SYMBOL_P(cb) ){
|
|
67
|
+
res = rb_funcall(rb_mKernel, SYM2ID(cb), 3,
|
|
68
|
+
INT2NUM(status), key, val);
|
|
69
|
+
}
|
|
70
|
+
else if( cb == Qnil ){
|
|
71
|
+
res = rb_yield(rb_ary_new3(3, INT2NUM(status), key, val));
|
|
72
|
+
}
|
|
73
|
+
else{
|
|
74
|
+
res = rb_funcall(cb, rb_intern("call"), 3,
|
|
75
|
+
INT2NUM(status), key, val);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/* return value:
|
|
79
|
+
* 0: call again for additional key-value pair
|
|
80
|
+
* nonzero: don't call again
|
|
81
|
+
*/
|
|
82
|
+
if( TYPE(res) != T_FIXNUM ){
|
|
83
|
+
if( res == Qfalse || res == Qnil ){
|
|
84
|
+
return 0;
|
|
85
|
+
}
|
|
86
|
+
else{
|
|
87
|
+
return 1;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
else{
|
|
91
|
+
return FIX2INT(res);
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
VALUE
|
|
96
|
+
rb_yp_all(int argc, VALUE argv[], VALUE self)
|
|
97
|
+
{
|
|
98
|
+
int res;
|
|
99
|
+
struct ypall_callback ypcb;
|
|
100
|
+
VALUE domainname, map, cb;
|
|
101
|
+
|
|
102
|
+
rb_scan_args(argc, argv, "21", &domainname, &map, &cb);
|
|
103
|
+
if( domainname == Qnil ){
|
|
104
|
+
domainname = rb_yp_get_default_domain(self);
|
|
105
|
+
};
|
|
106
|
+
switch( argc ){
|
|
107
|
+
case 3:
|
|
108
|
+
ypcb.foreach = rb_ypall_callback;
|
|
109
|
+
ypcb.data = (char*)cb;
|
|
110
|
+
break;
|
|
111
|
+
case 2:
|
|
112
|
+
ypcb.foreach = rb_ypall_callback;
|
|
113
|
+
ypcb.data = (char*)Qnil;
|
|
114
|
+
break;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
res = yp_all(STR2CSTR(domainname), STR2CSTR(map), &ypcb);
|
|
118
|
+
rb_yp_check_yperr(res);
|
|
119
|
+
|
|
120
|
+
return Qnil;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
VALUE
|
|
124
|
+
rb_yp_first(VALUE self, VALUE domain, VALUE map)
|
|
125
|
+
{
|
|
126
|
+
char *key, *val;
|
|
127
|
+
int keylen, vallen;
|
|
128
|
+
int res;
|
|
129
|
+
VALUE vkey, vval;
|
|
130
|
+
|
|
131
|
+
if( domain == Qnil ){
|
|
132
|
+
domain = rb_yp_get_default_domain(self);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
res = yp_first(STR2CSTR(domain), STR2CSTR(map), &key, &keylen, &val, &vallen);
|
|
136
|
+
rb_yp_check_yperr(res);
|
|
137
|
+
|
|
138
|
+
if( keylen > 0 ){
|
|
139
|
+
vkey = rb_tainted_str_new(key, keylen);
|
|
140
|
+
}
|
|
141
|
+
else{
|
|
142
|
+
vkey = Qnil;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
if( vallen > 0 ){
|
|
146
|
+
vval = rb_tainted_str_new(val, vallen);
|
|
147
|
+
}
|
|
148
|
+
else{
|
|
149
|
+
vval = Qnil;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
return rb_assoc_new(vkey, vval);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
VALUE
|
|
156
|
+
rb_yp_next(VALUE self, VALUE domain, VALUE map, VALUE inkey)
|
|
157
|
+
{
|
|
158
|
+
char *key, *val;
|
|
159
|
+
int keylen, vallen;
|
|
160
|
+
int res;
|
|
161
|
+
VALUE vkey, vval;
|
|
162
|
+
|
|
163
|
+
if( domain == Qnil ){
|
|
164
|
+
domain = rb_yp_get_default_domain(self);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
res = yp_next(STR2CSTR(domain), STR2CSTR(map),
|
|
168
|
+
STR2CSTR(inkey), RSTRING(inkey)->len,
|
|
169
|
+
&key, &keylen, &val, &vallen);
|
|
170
|
+
rb_yp_check_yperr(res);
|
|
171
|
+
|
|
172
|
+
if( keylen > 0 ){
|
|
173
|
+
vkey = rb_tainted_str_new(key, keylen);
|
|
174
|
+
}
|
|
175
|
+
else{
|
|
176
|
+
vkey = Qnil;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
if( vallen > 0 ){
|
|
180
|
+
vval = rb_tainted_str_new(val, vallen);
|
|
181
|
+
}
|
|
182
|
+
else{
|
|
183
|
+
vval = Qnil;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
return rb_assoc_new(vkey, vval);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
VALUE
|
|
190
|
+
rb_yp_update(VALUE self, VALUE domain, VALUE map, VALUE ypop, VALUE inkey, VALUE inval)
|
|
191
|
+
{
|
|
192
|
+
int res;
|
|
193
|
+
|
|
194
|
+
if( domain == Qnil ){
|
|
195
|
+
domain = rb_yp_get_default_domain(self);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
res = yp_update(STR2CSTR(domain), STR2CSTR(map), FIX2INT(ypop),
|
|
199
|
+
STR2CSTR(inkey), RSTRING(inkey)->len,
|
|
200
|
+
STR2CSTR(inval), RSTRING(inval)->len);
|
|
201
|
+
rb_yp_check_yperr(res);
|
|
202
|
+
|
|
203
|
+
return INT2NUM(res);
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
VALUE
|
|
207
|
+
rb_yp_match(VALUE self, VALUE domain, VALUE map, VALUE inkey)
|
|
208
|
+
{
|
|
209
|
+
int res;
|
|
210
|
+
char *val;
|
|
211
|
+
int vallen;
|
|
212
|
+
|
|
213
|
+
if( domain == Qnil ){
|
|
214
|
+
domain = rb_yp_get_default_domain(self);
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
res = yp_match(STR2CSTR(domain), STR2CSTR(map),
|
|
218
|
+
STR2CSTR(inkey), RSTRING(inkey)->len,
|
|
219
|
+
&val, &vallen);
|
|
220
|
+
rb_yp_check_yperr(res);
|
|
221
|
+
|
|
222
|
+
if( vallen > 0 ){
|
|
223
|
+
return rb_tainted_str_new(val, vallen);
|
|
224
|
+
}
|
|
225
|
+
else{
|
|
226
|
+
return Qnil;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
VALUE
|
|
231
|
+
rb_yp_order(VALUE self, VALUE domain, VALUE map)
|
|
232
|
+
{
|
|
233
|
+
int res, order;
|
|
234
|
+
|
|
235
|
+
if( domain == Qnil ){
|
|
236
|
+
domain = rb_yp_get_default_domain(self);
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
res = yp_order(STR2CSTR(domain), STR2CSTR(map), &order);
|
|
240
|
+
rb_yp_check_yperr(res);
|
|
241
|
+
|
|
242
|
+
return INT2NUM(order);
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
VALUE
|
|
246
|
+
rb_yp_master(VALUE self, VALUE domain, VALUE map)
|
|
247
|
+
{
|
|
248
|
+
int res;
|
|
249
|
+
char *master;
|
|
250
|
+
VALUE obj;
|
|
251
|
+
|
|
252
|
+
if( domain == Qnil ){
|
|
253
|
+
domain = rb_yp_get_default_domain(self);
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
res = yp_master(STR2CSTR(domain), STR2CSTR(map), &master);
|
|
257
|
+
rb_yp_check_yperr(res);
|
|
258
|
+
|
|
259
|
+
obj = rb_tainted_str_new2(master);
|
|
260
|
+
free(master);
|
|
261
|
+
|
|
262
|
+
return obj;
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
void
|
|
266
|
+
Init_yp()
|
|
267
|
+
{
|
|
268
|
+
rb_mYP = rb_define_module("YP");
|
|
269
|
+
rb_eYPError = rb_define_class_under(rb_mYP, "YPError", rb_eRuntimeError);
|
|
270
|
+
|
|
271
|
+
#define rb_yp_define_yperr(x) rb_define_const(rb_mYP, #x, INT2FIX(x));
|
|
272
|
+
rb_yp_define_yperr(YPERR_SUCCESS);
|
|
273
|
+
rb_yp_define_yperr(YPERR_BADARGS);
|
|
274
|
+
rb_yp_define_yperr(YPERR_RPC);
|
|
275
|
+
rb_yp_define_yperr(YPERR_DOMAIN);
|
|
276
|
+
rb_yp_define_yperr(YPERR_MAP);
|
|
277
|
+
rb_yp_define_yperr(YPERR_KEY);
|
|
278
|
+
rb_yp_define_yperr(YPERR_YPERR);
|
|
279
|
+
rb_yp_define_yperr(YPERR_RESRC);
|
|
280
|
+
rb_yp_define_yperr(YPERR_NOMORE);
|
|
281
|
+
rb_yp_define_yperr(YPERR_PMAP);
|
|
282
|
+
rb_yp_define_yperr(YPERR_YPBIND);
|
|
283
|
+
rb_yp_define_yperr(YPERR_YPSERV);
|
|
284
|
+
rb_yp_define_yperr(YPERR_NODOM);
|
|
285
|
+
rb_yp_define_yperr(YPERR_BADDB);
|
|
286
|
+
rb_yp_define_yperr(YPERR_VERS);
|
|
287
|
+
rb_yp_define_yperr(YPERR_ACCESS);
|
|
288
|
+
rb_yp_define_yperr(YPERR_BUSY);
|
|
289
|
+
#undef rb_yp_define_yperr
|
|
290
|
+
|
|
291
|
+
#define rb_yp_define_ypop(x) rb_define_const(rb_mYP, #x, INT2FIX(x));
|
|
292
|
+
rb_yp_define_ypop(YPOP_CHANGE);
|
|
293
|
+
rb_yp_define_ypop(YPOP_INSERT);
|
|
294
|
+
rb_yp_define_ypop(YPOP_DELETE);
|
|
295
|
+
rb_yp_define_ypop(YPOP_STORE);
|
|
296
|
+
#undef rb_yp_define_ypop
|
|
297
|
+
|
|
298
|
+
rb_define_module_function(rb_mYP, "get_default_domain",
|
|
299
|
+
rb_yp_get_default_domain, 0);
|
|
300
|
+
rb_define_module_function(rb_mYP, "yp_all", rb_yp_all, -1);
|
|
301
|
+
rb_define_module_function(rb_mYP, "yp_first", rb_yp_first, 2);
|
|
302
|
+
rb_define_module_function(rb_mYP, "yp_next", rb_yp_next, 3);
|
|
303
|
+
rb_define_module_function(rb_mYP, "yp_update", rb_yp_update, 5);
|
|
304
|
+
rb_define_module_function(rb_mYP, "yp_match", rb_yp_match, 3);
|
|
305
|
+
rb_define_module_function(rb_mYP, "yp_order", rb_yp_order, 2);
|
|
306
|
+
rb_define_module_function(rb_mYP, "yp_master", rb_yp_master, 2);
|
|
307
|
+
rb_define_module_function(rb_mYP, "err_string", rb_yperr_string, 1);
|
|
308
|
+
};
|
data/lib/nis.rb
ADDED
data/lib/nis/version.rb
ADDED
data/nis.gemspec
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = %q{nis}
|
|
8
|
+
s.version = "0.1.1"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Takaaki Tateishi"]
|
|
12
|
+
s.date = %q{2010-10-07}
|
|
13
|
+
s.description = %q{Provides an interface for NIS(YP) API.}
|
|
14
|
+
s.email = %q{ttate@users.sourceforge.net}
|
|
15
|
+
s.extensions = ["ext/nis/extconf.rb"]
|
|
16
|
+
s.extra_rdoc_files = [
|
|
17
|
+
"README",
|
|
18
|
+
"README.html"
|
|
19
|
+
]
|
|
20
|
+
s.files = [
|
|
21
|
+
".gitignore",
|
|
22
|
+
"MANIFEST",
|
|
23
|
+
"README",
|
|
24
|
+
"README.html",
|
|
25
|
+
"Rakefile",
|
|
26
|
+
"doc/NIS-HOWTO.html",
|
|
27
|
+
"ext/nis/extconf.rb",
|
|
28
|
+
"ext/nis/nis.c",
|
|
29
|
+
"ext/nis/nis.h",
|
|
30
|
+
"ext/nis/yp.c",
|
|
31
|
+
"lib/nis.rb",
|
|
32
|
+
"lib/nis/nis.so",
|
|
33
|
+
"lib/nis/version.rb",
|
|
34
|
+
"nis.gemspec",
|
|
35
|
+
"test/yp_all.rb",
|
|
36
|
+
"test/yp_all2.rb",
|
|
37
|
+
"test/yp_first.rb",
|
|
38
|
+
"test/yp_match.rb"
|
|
39
|
+
]
|
|
40
|
+
s.homepage = %q{http://raa.ruby-lang.org/project/ruby-nis/}
|
|
41
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
|
42
|
+
s.require_paths = ["lib"]
|
|
43
|
+
s.rubygems_version = %q{1.3.7}
|
|
44
|
+
s.summary = %q{Provides an interface for NIS(YP) API.}
|
|
45
|
+
s.test_files = [
|
|
46
|
+
"test/yp_all.rb",
|
|
47
|
+
"test/yp_first.rb",
|
|
48
|
+
"test/yp_match.rb",
|
|
49
|
+
"test/yp_all2.rb"
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
if s.respond_to? :specification_version then
|
|
53
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
54
|
+
s.specification_version = 3
|
|
55
|
+
|
|
56
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
57
|
+
else
|
|
58
|
+
end
|
|
59
|
+
else
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
data/test/yp_all.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
# $Id: yp_all.rb,v 1.1.1.1 2001/04/20 05:38:57 ttate Exp $
|
|
3
|
+
|
|
4
|
+
require 'nis'
|
|
5
|
+
|
|
6
|
+
def print_data(status, key, val)
|
|
7
|
+
case status
|
|
8
|
+
when YP::YPERR_SUCCESS
|
|
9
|
+
return status
|
|
10
|
+
else
|
|
11
|
+
if( key && val )
|
|
12
|
+
print("#{key}: #{val}\n")
|
|
13
|
+
end
|
|
14
|
+
return 0
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
ypdomain = YP.get_default_domain
|
|
19
|
+
YP.yp_all(ypdomain, 'passwd.byname', :print_data)
|
data/test/yp_all2.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
# $Id: yp_all2.rb,v 1.1.1.1 2001/04/20 05:38:57 ttate Exp $
|
|
3
|
+
|
|
4
|
+
require 'nis'
|
|
5
|
+
|
|
6
|
+
def print_data(status, key, val)
|
|
7
|
+
case status
|
|
8
|
+
when YP::YPERR_SUCCESS
|
|
9
|
+
return status
|
|
10
|
+
else
|
|
11
|
+
if( key && val )
|
|
12
|
+
print("#{key}: #{val}\n")
|
|
13
|
+
end
|
|
14
|
+
return 0
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
ypdomain = YP.get_default_domain
|
|
19
|
+
YP.yp_all(ypdomain, 'passwd.byname'){|status, key, val|
|
|
20
|
+
print_data(status, key, val)
|
|
21
|
+
}
|
data/test/yp_first.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
# $Id: yp_first.rb,v 1.1.1.1 2001/04/20 05:38:57 ttate Exp $
|
|
3
|
+
|
|
4
|
+
require 'nis'
|
|
5
|
+
|
|
6
|
+
ypdomain = YP.get_default_domain
|
|
7
|
+
key,val = YP.yp_first(ypdomain, 'passwd.byname')
|
|
8
|
+
while( key && val )
|
|
9
|
+
print("#{key}: #{val}\n")
|
|
10
|
+
key,val = YP.yp_next(ypdomain, 'passwd.byname', key)
|
|
11
|
+
end
|
data/test/yp_match.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: nis
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
hash: 25
|
|
5
|
+
prerelease: false
|
|
6
|
+
segments:
|
|
7
|
+
- 0
|
|
8
|
+
- 1
|
|
9
|
+
- 1
|
|
10
|
+
version: 0.1.1
|
|
11
|
+
platform: ruby
|
|
12
|
+
authors:
|
|
13
|
+
- Takaaki Tateishi
|
|
14
|
+
autorequire:
|
|
15
|
+
bindir: bin
|
|
16
|
+
cert_chain: []
|
|
17
|
+
|
|
18
|
+
date: 2010-10-07 00:00:00 -04:00
|
|
19
|
+
default_executable:
|
|
20
|
+
dependencies: []
|
|
21
|
+
|
|
22
|
+
description: Provides an interface for NIS(YP) API.
|
|
23
|
+
email: ttate@users.sourceforge.net
|
|
24
|
+
executables: []
|
|
25
|
+
|
|
26
|
+
extensions:
|
|
27
|
+
- ext/nis/extconf.rb
|
|
28
|
+
extra_rdoc_files:
|
|
29
|
+
- README
|
|
30
|
+
- README.html
|
|
31
|
+
files:
|
|
32
|
+
- .gitignore
|
|
33
|
+
- MANIFEST
|
|
34
|
+
- README
|
|
35
|
+
- README.html
|
|
36
|
+
- Rakefile
|
|
37
|
+
- doc/NIS-HOWTO.html
|
|
38
|
+
- ext/nis/extconf.rb
|
|
39
|
+
- ext/nis/nis.c
|
|
40
|
+
- ext/nis/nis.h
|
|
41
|
+
- ext/nis/yp.c
|
|
42
|
+
- lib/nis.rb
|
|
43
|
+
- lib/nis/nis.so
|
|
44
|
+
- lib/nis/version.rb
|
|
45
|
+
- nis.gemspec
|
|
46
|
+
- test/yp_all.rb
|
|
47
|
+
- test/yp_all2.rb
|
|
48
|
+
- test/yp_first.rb
|
|
49
|
+
- test/yp_match.rb
|
|
50
|
+
has_rdoc: true
|
|
51
|
+
homepage: http://raa.ruby-lang.org/project/ruby-nis/
|
|
52
|
+
licenses: []
|
|
53
|
+
|
|
54
|
+
post_install_message:
|
|
55
|
+
rdoc_options:
|
|
56
|
+
- --charset=UTF-8
|
|
57
|
+
require_paths:
|
|
58
|
+
- lib
|
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
|
+
none: false
|
|
61
|
+
requirements:
|
|
62
|
+
- - ">="
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
hash: 3
|
|
65
|
+
segments:
|
|
66
|
+
- 0
|
|
67
|
+
version: "0"
|
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
|
+
none: false
|
|
70
|
+
requirements:
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
hash: 3
|
|
74
|
+
segments:
|
|
75
|
+
- 0
|
|
76
|
+
version: "0"
|
|
77
|
+
requirements: []
|
|
78
|
+
|
|
79
|
+
rubyforge_project:
|
|
80
|
+
rubygems_version: 1.3.7
|
|
81
|
+
signing_key:
|
|
82
|
+
specification_version: 3
|
|
83
|
+
summary: Provides an interface for NIS(YP) API.
|
|
84
|
+
test_files:
|
|
85
|
+
- test/yp_all.rb
|
|
86
|
+
- test/yp_first.rb
|
|
87
|
+
- test/yp_match.rb
|
|
88
|
+
- test/yp_all2.rb
|