net-smb 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,236 @@
1
+ /*
2
+ * Ruby/Net::SMB - SMB/CIFS client (Samba libsmbclient binding) for Ruby
3
+ * Net::SMB::Dir class
4
+ * Copyright (C) 2012 SATOH Fumiyas @ OSS Technology Corp., Japan
5
+ *
6
+ * This program is free software; you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation; either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ #include "rb_smb.h"
21
+ #include "dlinklist.h"
22
+
23
+ #include <ruby/util.h>
24
+ #include <errno.h>
25
+
26
+ VALUE rb_cSMBDir;
27
+
28
+ /* ====================================================================== */
29
+
30
+ static void rb_smbdir_data_gc_mark(RB_SMBFILE_DATA *data)
31
+ {
32
+ rb_gc_mark(data->smb_obj);
33
+ }
34
+
35
+ static void rb_smbdir_close_by_data(RB_SMBFILE_DATA *data)
36
+ {
37
+ if (data->smbcfile == NULL) {
38
+ rb_raise(rb_eIOError, "Closed directory object");
39
+ }
40
+
41
+ smbc_closedir_fn fn = smbc_getFunctionClosedir(data->smbcctx);
42
+
43
+ if ((*fn)(data->smbcctx, data->smbcfile) != 0) {
44
+ rb_sys_fail("SMBC_closedir_ctx() failed");
45
+ }
46
+ }
47
+
48
+ static void rb_smbdir_close_and_deref_by_data(RB_SMBFILE_DATA *data)
49
+ {
50
+ RB_SMB_DEBUG("data=%p smbcctx=%p smbcfile=%p\n", data, data->smbcctx, data->smbcfile);
51
+
52
+ rb_smbdir_close_by_data(data);
53
+
54
+ data->smbcctx = NULL;
55
+ data->smbcfile = NULL;
56
+
57
+ DLIST_REMOVE(data->smb_data->smbfile_data_list, data);
58
+
59
+ RB_SMB_DEBUG("smbfile_data_list=%p smbfile_data=%p\n", data->smb_data->smbfile_data_list, data);
60
+ }
61
+
62
+ static void rb_smbdir_data_free(RB_SMBFILE_DATA *data)
63
+ {
64
+ RB_SMB_DEBUG("data=%p smbcctx=%p smbcfile=%p\n", data, data->smbcctx, data->smbcfile);
65
+
66
+ if (data->smbcfile != NULL) {
67
+ rb_smbdir_close_and_deref_by_data(data);
68
+ }
69
+
70
+ ruby_xfree(data->url);
71
+ ruby_xfree(data);
72
+ }
73
+
74
+ static VALUE rb_smbdir_data_alloc(VALUE klass)
75
+ {
76
+ RB_SMBFILE_DATA *data = ALLOC(RB_SMBFILE_DATA);
77
+
78
+ memset(data, 0, sizeof(*data));
79
+
80
+ data->smb_obj = Qnil;
81
+
82
+ return Data_Wrap_Struct(klass, rb_smbdir_data_gc_mark, rb_smbdir_data_free, data);
83
+ }
84
+
85
+ static VALUE rb_smbdir_close(VALUE self);
86
+
87
+ static VALUE rb_smbdir_initialize(VALUE self, VALUE smb_obj, VALUE url_obj)
88
+ {
89
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
90
+ RB_SMB_DATA_FROM_OBJ(smb_obj, smb_data);
91
+ smbc_opendir_fn fn;
92
+ const char *url = StringValueCStr(url_obj);
93
+
94
+ fn = smbc_getFunctionOpendir(smb_data->smbcctx);
95
+ data->smbcfile = (*fn)(smb_data->smbcctx, url);
96
+ if (data->smbcfile == NULL) {
97
+ rb_sys_fail("SMBC_opendir_ctx() failed");
98
+ }
99
+
100
+ /* FIXME: Take encoding from argument */
101
+ /* FIXME: Read unix charset (?) from smb.conf for default encoding */
102
+ data->enc = rb_enc_find("UTF-8");
103
+
104
+ data->smb_obj = smb_obj;
105
+ data->smb_data = smb_data;
106
+ data->smbcctx = smb_data->smbcctx;
107
+ data->url = ruby_strdup(url);
108
+
109
+ RB_SMB_DEBUG("smbcctx=%p smbcfile=%p\n", data->smbcctx, data->smbcfile);
110
+
111
+ if (rb_block_given_p()) {
112
+ rb_ensure(rb_yield, self, rb_smbdir_close, self);
113
+ return Qnil;
114
+ }
115
+
116
+ return self;
117
+ }
118
+
119
+ static VALUE rb_smbdir_smb(VALUE self)
120
+ {
121
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
122
+
123
+ return data->smb_obj;
124
+ }
125
+
126
+ static VALUE rb_smbdir_url(VALUE self)
127
+ {
128
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
129
+
130
+ return rb_str_new2(data->url);
131
+ }
132
+
133
+ static VALUE rb_smbdir_close(VALUE self)
134
+ {
135
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
136
+
137
+ RB_SMB_DEBUG("data=%p smbcctx=%p smbcfile=%p\n", data, data->smbcctx, data->smbcfile);
138
+
139
+ rb_smbdir_close_and_deref_by_data(data);
140
+
141
+ return self;
142
+ }
143
+
144
+ static VALUE rb_smbdir_tell(VALUE self)
145
+ {
146
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
147
+ smbc_telldir_fn fn;
148
+ off_t offset;
149
+
150
+ fn = smbc_getFunctionTelldir(data->smbcctx);
151
+
152
+ errno = 0;
153
+ offset = (*fn)(data->smbcctx, data->smbcfile);
154
+ if (offset == (off_t)-1) {
155
+ if (errno != 0) {
156
+ rb_sys_fail("SMBC_telldir_ctx() failed");
157
+ }
158
+ }
159
+
160
+ return LONG2NUM(offset);
161
+ }
162
+
163
+ static VALUE rb_smbdir_seek(VALUE self, VALUE offset_num)
164
+ {
165
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
166
+ smbc_lseekdir_fn fn;
167
+ off_t offset = (off_t)NUM2LONG(offset_num);
168
+
169
+ fn = smbc_getFunctionLseekdir(data->smbcctx);
170
+
171
+ errno = 0;
172
+ if ((*fn)(data->smbcctx, data->smbcfile, offset) == -1) {
173
+ rb_sys_fail("SMBC_lseekdir_ctx() failed");
174
+ }
175
+
176
+ return self;
177
+ }
178
+
179
+ static VALUE rb_smbdir_rewind(VALUE self)
180
+ {
181
+ return rb_smbdir_seek(self, LONG2NUM(0));
182
+ }
183
+
184
+ static VALUE rb_smbdir_read(VALUE self)
185
+ {
186
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
187
+ smbc_readdir_fn fn;
188
+ struct smbc_dirent *smbcdent;
189
+
190
+ fn = smbc_getFunctionReaddir(data->smbcctx);
191
+
192
+ errno = 0;
193
+ smbcdent = (*fn)(data->smbcctx, data->smbcfile);
194
+
195
+ if (smbcdent == NULL) {
196
+ if (errno) {
197
+ rb_sys_fail("SMBC_readdir_ctx() failed");
198
+ }
199
+
200
+ return Qnil;
201
+ }
202
+
203
+ return rb_external_str_new_with_enc(smbcdent->name, strlen(smbcdent->name), data->enc);
204
+ }
205
+
206
+ static VALUE rb_smbdir_each(VALUE self)
207
+ {
208
+ VALUE name;
209
+
210
+ RETURN_ENUMERATOR(self, 0, 0);
211
+
212
+ while (!NIL_P(name = rb_smbdir_read(self))) {
213
+ rb_yield(name);
214
+ }
215
+
216
+ return self;
217
+ }
218
+
219
+ /* ====================================================================== */
220
+
221
+ void Init_smbdir(void)
222
+ {
223
+ rb_cSMBDir = rb_define_class_under(rb_cSMB, "Dir", rb_cObject);
224
+ rb_define_alloc_func(rb_cSMBDir, rb_smbdir_data_alloc);
225
+ rb_define_method(rb_cSMBDir, "initialize", rb_smbdir_initialize, 2);
226
+ rb_define_method(rb_cSMBDir, "smb", rb_smbdir_smb, 0);
227
+ rb_define_method(rb_cSMBDir, "url", rb_smbdir_url, 0);
228
+ rb_define_method(rb_cSMBDir, "close", rb_smbdir_close, 0);
229
+ rb_define_method(rb_cSMBDir, "tell", rb_smbdir_tell, 0);
230
+ rb_define_alias(rb_cSMBDir, "pos", "tell");
231
+ rb_define_method(rb_cSMBDir, "seek", rb_smbdir_seek, 1);
232
+ rb_define_method(rb_cSMBDir, "rewind", rb_smbdir_rewind, 0);
233
+ rb_define_method(rb_cSMBDir, "read", rb_smbdir_read, 0);
234
+ rb_define_method(rb_cSMBDir, "each", rb_smbdir_each, 0);
235
+ }
236
+
@@ -0,0 +1,354 @@
1
+ /*
2
+ * Ruby/Net::SMB - SMB/CIFS client (Samba libsmbclient binding) for Ruby
3
+ * Net::SMB::File class
4
+ * Copyright (C) 2012 SATOH Fumiyas @ OSS Technology Corp., Japan
5
+ *
6
+ * This program is free software; you can redistribute it and/or modify
7
+ * it under the terms of the GNU General Public License as published by
8
+ * the Free Software Foundation; either version 3 of the License, or
9
+ * (at your option) any later version.
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+ */
19
+
20
+ #include "rb_smb.h"
21
+ #include "dlinklist.h"
22
+
23
+ #include <ruby/util.h>
24
+ #include <ruby/io.h>
25
+ #include <errno.h>
26
+
27
+ VALUE rb_cSMBFile;
28
+
29
+ /* ====================================================================== */
30
+
31
+ static void rb_smbfile_data_gc_mark(RB_SMBFILE_DATA *data)
32
+ {
33
+ rb_gc_mark(data->smb_obj);
34
+ }
35
+
36
+ static void rb_smbfile_close_by_data(RB_SMBFILE_DATA *data)
37
+ {
38
+ if (data->smbcfile == NULL) {
39
+ rb_raise(rb_eIOError, "Closed file object");
40
+ }
41
+
42
+ smbc_close_fn fn = smbc_getFunctionClose(data->smbcctx);
43
+
44
+ if ((*fn)(data->smbcctx, data->smbcfile) != 0) {
45
+ rb_sys_fail("SMBC_close_ctx() failed");
46
+ }
47
+ }
48
+
49
+ static void rb_smbfile_close_and_deref_by_data(RB_SMBFILE_DATA *data)
50
+ {
51
+ rb_smbfile_close_by_data(data);
52
+
53
+ data->smbcctx = NULL;
54
+ data->smbcfile = NULL;
55
+
56
+ DLIST_REMOVE(data->smb_data->smbfile_data_list, data);
57
+ }
58
+
59
+ static void rb_smbfile_data_free(RB_SMBFILE_DATA *data)
60
+ {
61
+ RB_SMB_DEBUG("smbcctx=%p smbcfile=%p\n", data->smbcctx, data->smbcfile);
62
+
63
+ if (data->smbcfile != NULL) {
64
+ rb_smbfile_close_and_deref_by_data(data);
65
+ }
66
+
67
+ ruby_xfree(data->url);
68
+ ruby_xfree(data->buffer);
69
+ ruby_xfree(data);
70
+ }
71
+
72
+ static VALUE rb_smbfile_data_alloc(VALUE klass)
73
+ {
74
+ RB_SMBFILE_DATA *data = ALLOC(RB_SMBFILE_DATA);
75
+
76
+ memset(data, 0, sizeof(*data));
77
+
78
+ data->smb_obj = Qnil;
79
+
80
+ return Data_Wrap_Struct(klass, rb_smbfile_data_gc_mark, rb_smbfile_data_free, data);
81
+ }
82
+
83
+ static void rb_smbfile_open_by_data(RB_SMBFILE_DATA *data)
84
+ {
85
+ smbc_open_fn fn = smbc_getFunctionOpen(data->smbcctx);
86
+
87
+ data->smbcfile = (*fn)(data->smbcctx, data->url, data->oflags, 0);
88
+ if (data->smbcfile == NULL) {
89
+ rb_sys_fail("SMBC_open_ctx() failed");
90
+ }
91
+
92
+ RB_SMB_DEBUG("smbcctx=%p smbcfile=%p\n", data->smbcctx, data->smbcfile);
93
+ }
94
+
95
+ static void rb_smbfile_seek_by_data(RB_SMBFILE_DATA *data)
96
+ {
97
+ smbc_lseek_fn fn = smbc_getFunctionLseek(data->smbcctx);
98
+
99
+ if ((*fn)(data->smbcctx, data->smbcfile, data->pos, SEEK_SET) == -1) {
100
+ rb_sys_fail("SMBC_lseek_ctx() failed");
101
+ }
102
+
103
+ data->buffer_used_size = 0;
104
+ data->buffer_pos = 0;
105
+ data->eof = 0;
106
+ }
107
+
108
+ static void rb_smbfile_reopen_by_data(RB_SMBFILE_DATA *data)
109
+ {
110
+ rb_smbfile_close_by_data(data);
111
+ rb_smbfile_open_by_data(data);
112
+ rb_smbfile_seek_by_data(data);
113
+ }
114
+
115
+ static void rb_smbfile_read_by_data(RB_SMBFILE_DATA *data)
116
+ {
117
+ smbc_read_fn fn;
118
+ ssize_t read_size;
119
+ char *buffer = data->buffer + data->buffer_used_size;
120
+ size_t buffer_size = data->buffer_size - data->buffer_used_size;
121
+
122
+ if (buffer_size == 0) {
123
+ /* Buffer is full */
124
+ if (data->buffer_pos < data->buffer_used_size) {
125
+ /* But remained data exists */
126
+ return;
127
+ }
128
+
129
+ /* Rewind */
130
+ data->buffer_used_size = 0;
131
+ data->buffer_pos = 0;
132
+ buffer = data->buffer;
133
+ buffer_size = data->buffer_size;
134
+ }
135
+
136
+ fn = smbc_getFunctionRead(data->smbcctx);
137
+
138
+ try:
139
+ read_size = (*fn)(data->smbcctx, data->smbcfile, buffer, buffer_size);
140
+ if (read_size < 0) {
141
+ if (errno != EBADF) {
142
+ rb_sys_fail("Bad SMBCFILE");
143
+ }
144
+ else {
145
+ rb_smbfile_reopen_by_data(data);
146
+ goto try;
147
+ }
148
+ }
149
+
150
+ data->buffer_used_size += read_size;
151
+ data->eof = (read_size == 0);
152
+ }
153
+
154
+ static VALUE rb_smbfile_initialize(int argc, VALUE *argv, VALUE self)
155
+ {
156
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
157
+ VALUE smb_obj, url_obj, mode_obj;
158
+
159
+ rb_scan_args(argc, argv, "21", &smb_obj, &url_obj, &mode_obj);
160
+ RB_SMB_DATA_FROM_OBJ(smb_obj, smb_data);
161
+
162
+ if (NIL_P(mode_obj)) {
163
+ data->fmode = FMODE_READABLE;
164
+ // FIXME data->fmode = FMODE_READABLE | DEFAULT_TEXTMODE;
165
+ data->oflags = O_RDONLY;
166
+ }
167
+ else if (FIXNUM_P(mode_obj)) {
168
+ rb_raise(rb_eArgError, "FIXME");
169
+ data->fmode = 0;
170
+ data->oflags = NUM2INT(mode_obj);
171
+ }
172
+ else {
173
+ const char *mode_str = StringValueCStr(mode_obj);
174
+ data->fmode = rb_io_modestr_fmode(mode_str);
175
+ data->oflags = rb_io_modestr_oflags(mode_str);
176
+ }
177
+
178
+ data->smb_obj = smb_obj;
179
+ data->smb_data = smb_data;
180
+ data->smbcctx = smb_data->smbcctx;
181
+ data->url = ruby_strdup(RSTRING_PTR(url_obj));
182
+
183
+ data->buffer = ruby_xmalloc(RB_SMBFILE_BUFFER_SIZE);
184
+ data->buffer_size = RB_SMBFILE_BUFFER_SIZE;
185
+
186
+ rb_smbfile_open_by_data(data);
187
+
188
+ return self;
189
+ }
190
+
191
+ static VALUE rb_smbfile_smb(VALUE self)
192
+ {
193
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
194
+
195
+ return data->smb_obj;
196
+ }
197
+
198
+ static VALUE rb_smbfile_url(VALUE self)
199
+ {
200
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
201
+
202
+ return rb_str_new2(data->url);
203
+ }
204
+
205
+ static VALUE rb_smbfile_close(VALUE self)
206
+ {
207
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
208
+
209
+ RB_SMB_DEBUG("data=%p smbcctx=%p smbcfile=%p\n", data, data->smbcctx, data->smbcfile);
210
+
211
+ rb_smbfile_close_and_deref_by_data(data);
212
+
213
+ return self;
214
+ }
215
+
216
+ static VALUE rb_smbfile_tell(VALUE self)
217
+ {
218
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
219
+
220
+ return SIZET2NUM(data->pos);
221
+ }
222
+
223
+ static VALUE rb_smbfile_seek(VALUE self, VALUE offset_num, VALUE whence_num)
224
+ {
225
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
226
+ off_t offset = NUM2OFFT(offset_num);
227
+ int whence = NUM2INT(whence_num);
228
+
229
+ switch (whence) {
230
+ case SEEK_SET:
231
+ data->pos = offset;
232
+ break;
233
+ case SEEK_CUR:
234
+ if (offset < 0 && offset < -data->pos) {
235
+ errno = EINVAL;
236
+ rb_sys_fail("SMBC_lseek_ctx() failed");
237
+ }
238
+ data->pos += offset;
239
+ break;
240
+ case SEEK_END:
241
+ rb_sys_fail("FIXME");
242
+ break;
243
+ default:
244
+ rb_sys_fail("FIXME");
245
+ break;
246
+ }
247
+
248
+ rb_smbfile_seek_by_data(data);
249
+
250
+ return self;
251
+ }
252
+
253
+ static VALUE rb_smbfile_rewind(VALUE self)
254
+ {
255
+ return rb_smbfile_seek(self, OFFT2NUM(0), INT2NUM(SEEK_SET));
256
+ }
257
+
258
+ static VALUE rb_smbfile_eof_p(VALUE self)
259
+ {
260
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
261
+
262
+ if (data->buffer_used_size - data->buffer_pos > 0) {
263
+ /* Remained data exist in buffer */
264
+ return Qfalse;
265
+ }
266
+
267
+ /* Try to read from file to buffer */
268
+ rb_smbfile_read_by_data(data);
269
+
270
+ if (data->buffer_used_size - data->buffer_pos > 0) {
271
+ /* Remained data exist in buffer */
272
+ return Qfalse;
273
+ }
274
+
275
+ return Qtrue;
276
+ }
277
+
278
+ static void rb_smbfile_readable_p_by_data(RB_SMBFILE_DATA *data)
279
+ {
280
+ if (data->oflags & O_WRONLY) {
281
+ rb_raise(rb_eIOError, "Not opened for reading");
282
+ }
283
+ }
284
+
285
+ static VALUE rb_smbfile_read(int argc, VALUE *argv, VALUE self)
286
+ {
287
+ RB_SMBFILE_DATA_FROM_OBJ(self, data);
288
+ ssize_t req_read_size;
289
+ VALUE str = rb_str_new2("");
290
+
291
+ rb_smbfile_readable_p_by_data(data);
292
+
293
+ if (argc == 0) {
294
+ req_read_size = -1;
295
+ }
296
+ else {
297
+ req_read_size = NUM2SSIZET(argv[0]);
298
+ if (req_read_size == 0) {
299
+ return str; /* Return empty string */
300
+ }
301
+ if (req_read_size < 0) {
302
+ rb_raise(rb_eArgError, "Negative length given: %zd", req_read_size);
303
+ }
304
+ }
305
+
306
+ while (req_read_size) {
307
+ ssize_t buffer_read_size = data->buffer_used_size - data->buffer_pos;
308
+
309
+ if (buffer_read_size == 0) {
310
+ /* No remained data in buffer */
311
+ rb_smbfile_read_by_data(data);
312
+
313
+ if (data->eof) {
314
+ /* No remained data in file */
315
+ return (req_read_size > 0 && RSTRING_LEN(str) == 0) ? Qnil : str;
316
+ }
317
+
318
+ buffer_read_size = data->buffer_used_size - data->buffer_pos;
319
+ }
320
+
321
+ if (req_read_size > 0 && buffer_read_size > req_read_size) {
322
+ buffer_read_size = req_read_size;
323
+ }
324
+
325
+ rb_str_cat(str, data->buffer + data->buffer_pos, buffer_read_size);
326
+
327
+ data->pos += buffer_read_size;
328
+ data->buffer_pos += buffer_read_size;
329
+ if (req_read_size > 0) {
330
+ req_read_size -= buffer_read_size;
331
+ }
332
+ }
333
+
334
+ return str;
335
+ }
336
+
337
+ /* ====================================================================== */
338
+
339
+ void Init_smbfile(void)
340
+ {
341
+ rb_cSMBFile = rb_define_class_under(rb_cSMB, "File", rb_cObject);
342
+ rb_define_alloc_func(rb_cSMBFile, rb_smbfile_data_alloc);
343
+ rb_define_method(rb_cSMBFile, "initialize", rb_smbfile_initialize, -1);
344
+ rb_define_method(rb_cSMBFile, "smb", rb_smbfile_smb, 0);
345
+ rb_define_method(rb_cSMBFile, "url", rb_smbfile_url, 0);
346
+ rb_define_method(rb_cSMBFile, "close", rb_smbfile_close, 0);
347
+ rb_define_method(rb_cSMBFile, "tell", rb_smbfile_tell, 0);
348
+ rb_define_alias(rb_cSMBFile, "pos", "tell");
349
+ rb_define_method(rb_cSMBFile, "seek", rb_smbfile_seek, 2);
350
+ rb_define_method(rb_cSMBFile, "rewind", rb_smbfile_rewind, 0);
351
+ rb_define_method(rb_cSMBFile, "eof?", rb_smbfile_eof_p, 0);
352
+ rb_define_method(rb_cSMBFile, "read", rb_smbfile_read, -1);
353
+ }
354
+
@@ -1,5 +1,5 @@
1
1
  module Net #:nodoc:
2
2
  module SMB #:nodoc:
3
- VERSION = "0.0.1" #:nodoc:
3
+ VERSION = "0.0.2" #:nodoc:
4
4
  end
5
5
  end
data/net-smb.gemspec CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ["SATOH Fumiyasu"]
9
9
  s.email = ["fumiyas@osstech.co.jp"]
10
10
  s.homepage = "https://github.com/fumiyas/ruby-net-smb"
11
- s.summary = %q{SMB/CIFS client}
12
- s.description = %q{SMB/CIFS client}
11
+ s.summary = %q{SMB/CIFS client (Samba libsmbclient binding)}
12
+ s.description = %q{SMB/CIFS client (Samba libsmbclient binding)}
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
15
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ ENV['LC_ALL'] = 'C'
4
+
5
+ command = [
6
+ ENV['TEST_SMBD'],
7
+ "--configfile=#{ENV['TEST_SMB_CONF']}",
8
+ "--debuglevel=#{ENV['TEST_SAMBA_DEBUGLEVEL']}",
9
+ "--log-basename=#{ENV['TEST_SAMBA_LOG_DIR']}",
10
+ ]
11
+
12
+ if ENV['TEST_SMBD_STRACE']
13
+ strace = [ENV['TEST_SMBD_STRACE']]
14
+ strace << ENV['TEST_SMBD_STRACE_OPTIONS'] if ENV['TEST_SMBD_STRACE_OPTIONS']
15
+ strace << "-o#{ENV['TEST_SAMBA_LOG_DIR']}/smbd.strace.log"
16
+ command.unshift(*strace)
17
+ end
18
+
19
+ begin
20
+ Process.setsid
21
+ rescue Errno::EPERM
22
+ ## This process is a process group leader already.
23
+ end
24
+
25
+ exec(*command)
26
+
data/test/etc/smb.conf ADDED
@@ -0,0 +1,32 @@
1
+ [global]
2
+ private dir = %$(TEST_SAMBA_VAR_DIR)
3
+ lock directory = %$(TEST_SAMBA_VAR_DIR)
4
+ state directory = %$(TEST_SAMBA_VAR_DIR)
5
+ cache directory = %$(TEST_SAMBA_VAR_DIR)
6
+ pid directory = %$(TEST_SAMBA_VAR_DIR)
7
+ ncalrpc dir = %$(TEST_SAMBA_VAR_DIR)
8
+
9
+ map to guest = BAD USER
10
+
11
+ [template]
12
+ path = %$(TEST_SHARE_DIR)
13
+ writeable = yes
14
+ guest ok = no
15
+
16
+ [private]
17
+ copy = template
18
+
19
+ [public]
20
+ copy = template
21
+ guest ok = yes
22
+
23
+ [readonly]
24
+ copy = template
25
+ writeable = no
26
+
27
+ [共有]
28
+ copy = template
29
+
30
+ [共有フォルダー]
31
+ copy = template
32
+