prison 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +7 -0
- data/bin/prison +25 -0
- data/build.sh +1 -0
- data/ext/prison/extconf.rb +4 -0
- data/ext/prison/prison.c +338 -0
- data/ext/prison/prison.h +6 -0
- data/lib/jail.rb +14 -0
- data/lib/prison/version.rb +3 -0
- data/prison.gemspec +59 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 283161d70dc2f82c2e1408eaf7669d4bbd29fce3
|
4
|
+
data.tar.gz: 943c7451b3eeb0ffdc76698b903029a37e402a19
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5b186b38021ffef0348541f2f6285b31fb3f445f6f8779440d6c35bc66d63b5abc9f4d1bfb2550809153073a5d66c13a1c815aed29d0fa7f5c0b6084be83adb1
|
7
|
+
data.tar.gz: 71678b11330fbf2bb87059942e4650577feb3b91e2487215fd3a17a870309a1d9adb36705a9cbb28669e81b7bc518b0f61a4a978ff6df89242e61edaf0f9c4ae
|
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
.build.sh
|
2
|
+
*.gem
|
3
|
+
*.rbc
|
4
|
+
.bundle
|
5
|
+
.config
|
6
|
+
.yardoc
|
7
|
+
Gemfile.lock
|
8
|
+
InstalledFiles
|
9
|
+
_yardoc
|
10
|
+
coverage
|
11
|
+
doc/
|
12
|
+
lib/bundler/man
|
13
|
+
pkg
|
14
|
+
rdoc
|
15
|
+
spec/reports
|
16
|
+
test/tmp
|
17
|
+
test/version_tmp
|
18
|
+
tmp
|
19
|
+
*.bundle
|
20
|
+
*.so
|
21
|
+
*.o
|
22
|
+
*.a
|
23
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 TODO: Write your name
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Prison
|
2
|
+
|
3
|
+
FreeBSD jail wrapper.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'prison'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install prison
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
prison list
|
22
|
+
|
23
|
+
prison create
|
24
|
+
|
25
|
+
prison config
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( https://github.com/[my-github-username]/prison/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/prison
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "jail"
|
3
|
+
require "prison/prison"
|
4
|
+
require "pp"
|
5
|
+
|
6
|
+
argv = ARGV.dup
|
7
|
+
|
8
|
+
if argv.include?("-v") || argv.include?("--version")
|
9
|
+
require "prison/version"
|
10
|
+
puts "Prison #{Prison::VERSION}"
|
11
|
+
end
|
12
|
+
|
13
|
+
#if argv.include?("create")
|
14
|
+
#
|
15
|
+
#end
|
16
|
+
|
17
|
+
if argv.include?("list")
|
18
|
+
prison = Prison.new
|
19
|
+
list = prison.list
|
20
|
+
|
21
|
+
list.each do |i|
|
22
|
+
puts "#{i.jp_name} : #{i.jp_value}"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/build.sh
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
gem build prison.gemspec && gem uninstall prison && gem install ./prison-0.0.1.gem && rbenv rehash
|
data/ext/prison/prison.c
ADDED
@@ -0,0 +1,338 @@
|
|
1
|
+
#include "prison.h"
|
2
|
+
#include <sys/cdefs.h>
|
3
|
+
__FBSDID("$FreeBSD$");
|
4
|
+
#include <arpa/inet.h>
|
5
|
+
#include <sys/jail.h>
|
6
|
+
|
7
|
+
#include <err.h>
|
8
|
+
#include <errno.h>
|
9
|
+
|
10
|
+
#include <sys/sysctl.h>
|
11
|
+
#include <limits.h>
|
12
|
+
|
13
|
+
#define JP_USER 0x01000000
|
14
|
+
#define JP_OPT 0x02000000
|
15
|
+
|
16
|
+
#define PRINT_DEFAULT 0x01
|
17
|
+
#define PRINT_HEADER 0x02
|
18
|
+
#define PRINT_NAMEVAL 0x04
|
19
|
+
#define PRINT_QUOTED 0x08
|
20
|
+
#define PRINT_SKIP 0x10
|
21
|
+
#define PRINT_VERBOSE 0x20
|
22
|
+
#define PRINT_JAIL_NAME 0x40
|
23
|
+
|
24
|
+
static struct jailparam *params;
|
25
|
+
static int *param_parent;
|
26
|
+
static int nparams;
|
27
|
+
static int add_param(const char *name, void *value, size_t valuelen,
|
28
|
+
struct jailparam *source, unsigned flags);
|
29
|
+
static int sort_param(const void *a, const void *b);
|
30
|
+
static int print_jail(int pflags, int jflags, VALUE *rb_jailparams);
|
31
|
+
static void quoted_print(char *str);
|
32
|
+
|
33
|
+
VALUE cPrison;
|
34
|
+
|
35
|
+
VALUE list_func(VALUE self);
|
36
|
+
|
37
|
+
VALUE list_func(VALUE self){
|
38
|
+
|
39
|
+
int i, jflags, jid, lastjid, pflags;
|
40
|
+
|
41
|
+
char *dot, *ep, *jname;
|
42
|
+
i = pflags = jflags = jid = 0;
|
43
|
+
|
44
|
+
pflags = (pflags & ~(PRINT_HEADER | PRINT_VERBOSE)) |
|
45
|
+
PRINT_NAMEVAL | PRINT_QUOTED | PRINT_SKIP;
|
46
|
+
|
47
|
+
#ifdef INET6
|
48
|
+
ip6_ok = feature_present("inet6");
|
49
|
+
#endif
|
50
|
+
#ifdef INET
|
51
|
+
ip4_ok = feature_present("inet");
|
52
|
+
#endif
|
53
|
+
|
54
|
+
/* Add the parameters to print. */
|
55
|
+
if (pflags & (PRINT_HEADER | PRINT_NAMEVAL))
|
56
|
+
add_param("all", NULL, (size_t)0, NULL, JP_USER);
|
57
|
+
else if (pflags & PRINT_VERBOSE) {
|
58
|
+
add_param("jid", NULL, (size_t)0, NULL, JP_USER);
|
59
|
+
add_param("host.hostname", NULL, (size_t)0, NULL,
|
60
|
+
JP_USER);
|
61
|
+
add_param("path", NULL, (size_t)0, NULL, JP_USER);
|
62
|
+
add_param("name", NULL, (size_t)0, NULL, JP_USER);
|
63
|
+
add_param("dying", NULL, (size_t)0, NULL, JP_USER);
|
64
|
+
add_param("cpuset.id", NULL, (size_t)0, NULL, JP_USER);
|
65
|
+
#ifdef INET
|
66
|
+
if (ip4_ok)
|
67
|
+
add_param("ip4.addr", NULL, (size_t)0, NULL,
|
68
|
+
JP_USER);
|
69
|
+
#endif
|
70
|
+
#ifdef INET6
|
71
|
+
if (ip6_ok)
|
72
|
+
add_param("ip6.addr", NULL, (size_t)0, NULL,
|
73
|
+
JP_USER | JP_OPT);
|
74
|
+
#endif
|
75
|
+
} else {
|
76
|
+
pflags |= PRINT_DEFAULT;
|
77
|
+
if (pflags & PRINT_JAIL_NAME)
|
78
|
+
add_param("name", NULL, (size_t)0, NULL, JP_USER);
|
79
|
+
else
|
80
|
+
add_param("jid", NULL, (size_t)0, NULL, JP_USER);
|
81
|
+
#ifdef INET
|
82
|
+
if (ip4_ok)
|
83
|
+
add_param("ip4.addr", NULL, (size_t)0, NULL,
|
84
|
+
JP_USER);
|
85
|
+
#endif
|
86
|
+
add_param("host.hostname", NULL, (size_t)0, NULL,
|
87
|
+
JP_USER);
|
88
|
+
add_param("path", NULL, (size_t)0, NULL, JP_USER);
|
89
|
+
}
|
90
|
+
|
91
|
+
if (pflags & PRINT_SKIP) {
|
92
|
+
/* Check for parameters with jailsys parents. */
|
93
|
+
for (i = 0; i < nparams; i++) {
|
94
|
+
if ((params[i].jp_flags & JP_USER) &&
|
95
|
+
(dot = strchr(params[i].jp_name, '.'))) {
|
96
|
+
*dot = 0;
|
97
|
+
param_parent[i] = add_param(params[i].jp_name,
|
98
|
+
NULL, (size_t)0, NULL, JP_OPT);
|
99
|
+
*dot = '.';
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
/* Add the index key parameters. */
|
105
|
+
if (jid != 0)
|
106
|
+
add_param("jid", &jid, sizeof(jid), NULL, 0);
|
107
|
+
else if (jname != NULL)
|
108
|
+
add_param("name", jname, strlen(jname), NULL, 0);
|
109
|
+
else
|
110
|
+
add_param("lastjid", &lastjid, sizeof(lastjid), NULL, 0);
|
111
|
+
|
112
|
+
|
113
|
+
VALUE rb_jailparams = rb_ary_new();
|
114
|
+
for (lastjid = 0; (lastjid = print_jail(pflags, jflags, &rb_jailparams)) >= 0; );
|
115
|
+
|
116
|
+
return rb_jailparams;
|
117
|
+
}
|
118
|
+
|
119
|
+
void Init_prison(){
|
120
|
+
cPrison = rb_define_class("Prison", rb_cObject);
|
121
|
+
rb_define_method(cPrison, "list", RUBY_METHOD_FUNC(list_func),0);
|
122
|
+
}
|
123
|
+
|
124
|
+
|
125
|
+
static int
|
126
|
+
add_param(const char *name, void *value, size_t valuelen,
|
127
|
+
struct jailparam *source, unsigned flags)
|
128
|
+
{
|
129
|
+
struct jailparam *param, *tparams;
|
130
|
+
int i, tnparams;
|
131
|
+
|
132
|
+
static int paramlistsize;
|
133
|
+
|
134
|
+
/* The pseudo-parameter "all" scans the list of available parameters. */
|
135
|
+
if (!strcmp(name, "all")) {
|
136
|
+
tnparams = jailparam_all(&tparams);
|
137
|
+
if (tnparams < 0)
|
138
|
+
errx(1, "%s", jail_errmsg);
|
139
|
+
qsort(tparams, (size_t)tnparams, sizeof(struct jailparam),
|
140
|
+
sort_param);
|
141
|
+
for (i = 0; i < tnparams; i++)
|
142
|
+
add_param(tparams[i].jp_name, NULL, (size_t)0,
|
143
|
+
tparams + i, flags);
|
144
|
+
free(tparams);
|
145
|
+
return -1;
|
146
|
+
}
|
147
|
+
|
148
|
+
/* Check for repeat parameters. */
|
149
|
+
for (i = 0; i < nparams; i++)
|
150
|
+
if (!strcmp(name, params[i].jp_name)) {
|
151
|
+
if (value != NULL && jailparam_import_raw(params + i,
|
152
|
+
value, valuelen) < 0)
|
153
|
+
errx(1, "%s", jail_errmsg);
|
154
|
+
params[i].jp_flags |= flags;
|
155
|
+
if (source != NULL)
|
156
|
+
jailparam_free(source, 1);
|
157
|
+
return i;
|
158
|
+
}
|
159
|
+
|
160
|
+
/* Make sure there is room for the new param record. */
|
161
|
+
if (!nparams) {
|
162
|
+
paramlistsize = 32;
|
163
|
+
params = malloc(paramlistsize * sizeof(*params));
|
164
|
+
param_parent = malloc(paramlistsize * sizeof(*param_parent));
|
165
|
+
if (params == NULL || param_parent == NULL)
|
166
|
+
err(1, "malloc");
|
167
|
+
} else if (nparams >= paramlistsize) {
|
168
|
+
paramlistsize *= 2;
|
169
|
+
params = realloc(params, paramlistsize * sizeof(*params));
|
170
|
+
param_parent = realloc(param_parent,
|
171
|
+
paramlistsize * sizeof(*param_parent));
|
172
|
+
if (params == NULL || param_parent == NULL)
|
173
|
+
err(1, "realloc");
|
174
|
+
}
|
175
|
+
|
176
|
+
/* Look up the parameter. */
|
177
|
+
param_parent[nparams] = -1;
|
178
|
+
param = params + nparams++;
|
179
|
+
if (source != NULL) {
|
180
|
+
*param = *source;
|
181
|
+
param->jp_flags |= flags;
|
182
|
+
return param - params;
|
183
|
+
}
|
184
|
+
if (jailparam_init(param, name) < 0)
|
185
|
+
errx(1, "%s", jail_errmsg);
|
186
|
+
param->jp_flags = flags;
|
187
|
+
if ((value != NULL ? jailparam_import_raw(param, value, valuelen)
|
188
|
+
: jailparam_import(param, value)) < 0) {
|
189
|
+
if (flags & JP_OPT) {
|
190
|
+
nparams--;
|
191
|
+
return (-1);
|
192
|
+
}
|
193
|
+
errx(1, "%s", jail_errmsg);
|
194
|
+
}
|
195
|
+
return param - params;
|
196
|
+
}
|
197
|
+
|
198
|
+
|
199
|
+
static int
|
200
|
+
sort_param(const void *a, const void *b)
|
201
|
+
{
|
202
|
+
const struct jailparam *parama, *paramb;
|
203
|
+
char *ap, *bp;
|
204
|
+
|
205
|
+
/* Put top-level parameters first. */
|
206
|
+
parama = a;
|
207
|
+
paramb = b;
|
208
|
+
ap = strchr(parama->jp_name, '.');
|
209
|
+
bp = strchr(paramb->jp_name, '.');
|
210
|
+
if (ap && !bp)
|
211
|
+
return (1);
|
212
|
+
if (bp && !ap)
|
213
|
+
return (-1);
|
214
|
+
return (strcmp(parama->jp_name, paramb->jp_name));
|
215
|
+
}
|
216
|
+
|
217
|
+
|
218
|
+
static int
|
219
|
+
print_jail(int pflags, int jflags, VALUE *rb_jailparams)
|
220
|
+
{
|
221
|
+
char *nname;
|
222
|
+
char **param_values;
|
223
|
+
int i, ai, jid, count, n, spc;
|
224
|
+
char ipbuf[INET6_ADDRSTRLEN];
|
225
|
+
|
226
|
+
jid = jailparam_get(params, nparams, jflags);
|
227
|
+
|
228
|
+
if (jid < 0)
|
229
|
+
return jid;
|
230
|
+
else {
|
231
|
+
|
232
|
+
ID class_id = rb_intern("Jailparam");
|
233
|
+
VALUE class = rb_const_get(rb_cObject, class_id);
|
234
|
+
VALUE name;
|
235
|
+
VALUE val;
|
236
|
+
|
237
|
+
param_values = alloca(nparams * sizeof(*param_values));
|
238
|
+
for (i = 0; i < nparams; i++) {
|
239
|
+
if (!(params[i].jp_flags & JP_USER))
|
240
|
+
continue;
|
241
|
+
param_values[i] = jailparam_export(params + i);
|
242
|
+
if (param_values[i] == NULL)
|
243
|
+
errx(1, "%s", jail_errmsg);
|
244
|
+
}
|
245
|
+
for (i = spc = 0; i < nparams; i++) {
|
246
|
+
if (!(params[i].jp_flags & JP_USER))
|
247
|
+
continue;
|
248
|
+
if ((pflags & PRINT_SKIP) &&
|
249
|
+
((!(params[i].jp_ctltype &
|
250
|
+
(CTLFLAG_WR | CTLFLAG_TUN))) ||
|
251
|
+
(param_parent[i] >= 0 &&
|
252
|
+
*(int *)params[param_parent[i]].jp_value !=
|
253
|
+
JAIL_SYS_NEW)))
|
254
|
+
continue;
|
255
|
+
if (spc)
|
256
|
+
putchar(' ');
|
257
|
+
else
|
258
|
+
spc = 1;
|
259
|
+
if (pflags & PRINT_NAMEVAL) {
|
260
|
+
/*
|
261
|
+
* * Generally "name=value", but for booleans
|
262
|
+
* * either "name" or "noname".
|
263
|
+
* */
|
264
|
+
if (params[i].jp_flags &
|
265
|
+
(JP_BOOL | JP_NOBOOL)) {
|
266
|
+
if (*(int *)params[i].jp_value){
|
267
|
+
name = rb_str_new2(params[i].jp_name);
|
268
|
+
printf("%s", params[i].jp_name);
|
269
|
+
} else {
|
270
|
+
nname = (params[i].jp_flags &
|
271
|
+
JP_NOBOOL) ?
|
272
|
+
nononame(params[i].jp_name)
|
273
|
+
: noname(params[i].jp_name);
|
274
|
+
name = rb_str_new2(nname);
|
275
|
+
printf("%s", nname);
|
276
|
+
free(nname);
|
277
|
+
}
|
278
|
+
|
279
|
+
continue;
|
280
|
+
}
|
281
|
+
name = rb_str_new2(params[i].jp_name);
|
282
|
+
printf("%s=", params[i].jp_name);
|
283
|
+
}
|
284
|
+
if (params[i].jp_valuelen == 0) {
|
285
|
+
if (pflags & PRINT_QUOTED)
|
286
|
+
printf("\"\"");
|
287
|
+
else if (!(pflags & PRINT_NAMEVAL))
|
288
|
+
printf('-');
|
289
|
+
} else {
|
290
|
+
val = rb_str_new2(param_values[i]);
|
291
|
+
quoted_print(param_values[i]);
|
292
|
+
}
|
293
|
+
VALUE argv[] = {name, val};
|
294
|
+
int argc = sizeof argv / sizeof argv[0];
|
295
|
+
VALUE new_jp = rb_class_new_instance(argc, argv, class);
|
296
|
+
rb_ary_push(*rb_jailparams, new_jp);
|
297
|
+
}
|
298
|
+
putchar('\n');
|
299
|
+
for (i = 0; i < nparams; i++)
|
300
|
+
if (params[i].jp_flags & JP_USER)
|
301
|
+
free(param_values[i]);
|
302
|
+
}
|
303
|
+
|
304
|
+
return (jid);
|
305
|
+
}
|
306
|
+
|
307
|
+
|
308
|
+
static void
|
309
|
+
quoted_print(char *str)
|
310
|
+
{
|
311
|
+
int c, qc;
|
312
|
+
char *p = str;
|
313
|
+
|
314
|
+
/* An empty string needs quoting. */
|
315
|
+
if (!*p) {
|
316
|
+
fputs("\"\"", stdout);
|
317
|
+
return;
|
318
|
+
}
|
319
|
+
|
320
|
+
/*
|
321
|
+
* * The value will be surrounded by quotes if it contains spaces
|
322
|
+
* * or quotes.
|
323
|
+
* */
|
324
|
+
qc = strchr(p, '\'') ? '"'
|
325
|
+
: strchr(p, '"') ? '\''
|
326
|
+
: strchr(p, ' ') || strchr(p, '\t') ? '"'
|
327
|
+
: 0;
|
328
|
+
if (qc)
|
329
|
+
putchar(qc);
|
330
|
+
while ((c = *p++)) {
|
331
|
+
if (c == '\\' || c == qc)
|
332
|
+
putchar('\\');
|
333
|
+
putchar(c);
|
334
|
+
}
|
335
|
+
if (qc)
|
336
|
+
putchar(qc);
|
337
|
+
}
|
338
|
+
|
data/ext/prison/prison.h
ADDED
data/lib/jail.rb
ADDED
data/prison.gemspec
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'prison/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "prison"
|
8
|
+
spec.version = Prison::VERSION
|
9
|
+
spec.authors = ["kazuhide maeda"]
|
10
|
+
spec.email = ["kzhd15med3pub@gmail.com"]
|
11
|
+
spec.summary = %q{FreeBSD jail wrapper.}
|
12
|
+
spec.description = %q{The easiest way to management FreeBSD jail.}
|
13
|
+
spec.homepage = "https://github.com/kzhd15med3gh/prison"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.extensions = %w[ext/prison/extconf.rb]
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
# spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.executables = %w(prison)
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
|
26
|
+
#added to realize that prison can use on the shell.
|
27
|
+
|
28
|
+
root_path = File.dirname(__FILE__)
|
29
|
+
all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
|
30
|
+
all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
|
31
|
+
all_files.reject! { |file| file.start_with?("website/") }
|
32
|
+
gitignore_path = File.join(root_path, ".gitignore")
|
33
|
+
gitignore = File.readlines(gitignore_path)
|
34
|
+
gitignore.map! { |line| line.chomp.strip }
|
35
|
+
gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
|
36
|
+
|
37
|
+
unignored_files = all_files.reject do |file|
|
38
|
+
# Ignore any directories, the gemspec only cares about files
|
39
|
+
next true if File.directory?(file)
|
40
|
+
|
41
|
+
# Ignore any paths that match anything in the gitignore. We do
|
42
|
+
# two tests here:
|
43
|
+
#
|
44
|
+
# - First, test to see if the entire path matches the gitignore.
|
45
|
+
# - Second, match if the basename does, this makes it so that things
|
46
|
+
# like '.DS_Store' will match sub-directories too (same behavior
|
47
|
+
# as git).
|
48
|
+
#
|
49
|
+
gitignore.any? do |ignore|
|
50
|
+
File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
|
51
|
+
File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
spec.files = unignored_files
|
57
|
+
# spec.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
|
58
|
+
spec.require_path = 'lib'
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prison
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kazuhide maeda
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: The easiest way to management FreeBSD jail.
|
42
|
+
email:
|
43
|
+
- kzhd15med3pub@gmail.com
|
44
|
+
executables:
|
45
|
+
- prison
|
46
|
+
extensions:
|
47
|
+
- ext/prison/extconf.rb
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- Gemfile
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/prison
|
56
|
+
- build.sh
|
57
|
+
- ext/prison/extconf.rb
|
58
|
+
- ext/prison/prison.c
|
59
|
+
- ext/prison/prison.h
|
60
|
+
- lib/jail.rb
|
61
|
+
- lib/prison/version.rb
|
62
|
+
- prison.gemspec
|
63
|
+
homepage: https://github.com/kzhd15med3gh/prison
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.2.2
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: FreeBSD jail wrapper.
|
87
|
+
test_files: []
|