ruby-magic 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -0
- data/CONTRIBUTORS.md +1 -2
- data/dependencies.yml +6 -77
- data/ext/magic/common.h +11 -7
- data/ext/magic/extconf.rb +16 -1
- data/ext/magic/functions.c +32 -14
- data/ext/magic/functions.h +18 -12
- data/ext/magic/ruby-magic.c +536 -315
- data/ext/magic/ruby-magic.h +96 -135
- data/lib/magic/version.rb +1 -1
- data/lib/magic.rb +16 -1
- data.tar.gz.sig +0 -0
- metadata +32 -9
- metadata.gz.sig +0 -0
- data/patches/libmagic/0001-Don-t-attempt-to-build-tests-documentation-and-Python-bindings.patch +0 -44
- data/ports/archives/file-5.39.tar.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f6fd376f0f6b9df5dd11ad1165a4c060a7391ae626feb57356782cb97ca3db0
|
4
|
+
data.tar.gz: 9c583624bee1a090a4098ea9ff6526d414efe624b437738a19f3f7a7b7895b82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 190f13b5566e31b180f32b1f83b970998a6a95018d3cf71055d31f22de30ccf6e18221223dfe9a7826b53063300036cdabb501670ae09af95b175f6dd5b1e41e
|
7
|
+
data.tar.gz: add7827d9a2663a612f9b5d486efa9fe4eb064aadf67f62ed314d8d173f5dfd172ae9851640ff9d01fe55031bb2810758fabcdf69643148bfb7a1259ef8bbef8
|
checksums.yaml.gz.sig
ADDED
@@ -0,0 +1,3 @@
|
|
1
|
+
;Cd���}�����=1�O.���\~�Z#���%��:&hW�m�T<���o����v߅]���\Vg���p�/�cL9��Y@_\_Ά?�y�nHM$�[���<qy�ۓ��
|
2
|
+
1���+��j�,�߯�l����*U���}�����gp���QOU�d�
|
3
|
+
^V�,*}cJa�;�po���ݎ ��}�<�x���gX��]�S�9����ƥ?.����O�OS|�4a 4ދ5���m���Fa=��g���,��#�a�^�to��&��K�Y��0[B��߅���AG���qoۑ���s4�^�E���C����/z�D$�&�l_��3��؟�=�,#c��!��'��'C���z�H��
|
data/CONTRIBUTORS.md
CHANGED
@@ -7,10 +7,9 @@ of Ruby Magic. They are hereby acknowledged and collectively identified as "The
|
|
7
7
|
Ruby Magic Authors". Copyright is held by the original contributor according to
|
8
8
|
the versioning history; see [LICENSE](LICENSE) file.
|
9
9
|
|
10
|
-
|
11
|
-
- Mike Dalessio ([@flavorjones](https://github.com/flavorjones))
|
12
10
|
- Igor Victor ([@gogainda](https://github.com/gogainda))
|
13
11
|
- John Hawthorn ([@jhawthorn](https://github.com/jhawthorn))
|
12
|
+
- Mike Dalessio ([@flavorjones](https://github.com/flavorjones))
|
14
13
|
- Shinya Maeda ([@dosuken123](https://github.com/dosuken123))
|
15
14
|
- Stan Hu ([@stanhu](https://github.com/stanhu))
|
16
15
|
|
data/dependencies.yml
CHANGED
@@ -14,80 +14,9 @@ libmagic:
|
|
14
14
|
#
|
15
15
|
# Using this PGP signature:
|
16
16
|
#
|
17
|
-
# -----BEGIN PGP
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# 4/tcKorXoD5QBgOWaYFzkOcQ5jrwA/9tn0MEkkVqez88xGhOjq6jooRWrP2lhNWb+Q7ayEvW
|
24
|
-
# 9Wm9CYS0dXxlCCJfqBOc+cZo8iVVbqiOzwAQ7uAAUv8azuaeRWpOD7MSjkXjYtkPwZevEd6x
|
25
|
-
# FKODaB2BDO4WMlxO9mp3Q/gPfrM41v9n33tYsAzQMW7c9W5mX/XH2Cv/57QyQ2hyaXN0b3Mg
|
26
|
-
# Wm91bGFzIChOZXRCU0Qga2V5KSA8Y2hyaXN0b3NAbmV0YnNkLm9yZz6IXgQQEQgABgUCWcg8
|
27
|
-
# UAAKCRCWb7A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
+
# -----BEGIN PGP SIGNATURE-----
|
18
|
+
#
|
19
|
+
# iEYEABECAAYFAl7mu3AACgkQcREqsWyzOzppXACgoqokKabq7bwN9aKvd/H/yhF+
|
20
|
+
# 9PUAoOPrAtxFkfNUvtqK/trY+v/Gk5JM
|
21
|
+
# =tA6a
|
22
|
+
# -----END PGP SIGNATURE-----
|
data/ext/magic/common.h
CHANGED
@@ -87,11 +87,13 @@ extern "C" {
|
|
87
87
|
#define ARRAY_P(x) (RB_TYPE_P((x), T_ARRAY))
|
88
88
|
#define FILE_P(x) (RB_TYPE_P((x), T_FILE))
|
89
89
|
|
90
|
-
#define RVAL2CBOOL(
|
91
|
-
#define CBOOL2RVAL(
|
90
|
+
#define RVAL2CBOOL(b) (RTEST(b))
|
91
|
+
#define CBOOL2RVAL(b) ((b) ? Qtrue : Qfalse)
|
92
92
|
|
93
|
-
#define RVAL2CSTR(
|
94
|
-
#define CSTR2RVAL(
|
93
|
+
#define RVAL2CSTR(s) (NIL_P(s) ? NULL : StringValueCStr(s))
|
94
|
+
#define CSTR2RVAL(s) ((s) == NULL ? Qnil : rb_str_new2((const char *)s))
|
95
|
+
|
96
|
+
#define RSTRING_EMPTY_P(s) (RSTRING_LEN(s) == 0)
|
95
97
|
|
96
98
|
#define RARRAY_EMPTY rb_ary_new()
|
97
99
|
#define RARRAY_EMPTY_P(a) (RARRAY_LEN(a) == 0)
|
@@ -126,7 +128,7 @@ extern "C" {
|
|
126
128
|
# define FPTR_TO_FD(p) (fileno(GetReadFile(p)))
|
127
129
|
#endif /* GetReadFile */
|
128
130
|
|
129
|
-
#define NOGVL_FUNCTION (VALUE
|
131
|
+
#define NOGVL_FUNCTION (VALUE(*)(void *))
|
130
132
|
|
131
133
|
#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL) && \
|
132
134
|
defined(HAVE_RUBY_THREAD_H) && HAVE_RUBY_THREAD_H
|
@@ -151,8 +153,10 @@ fake_blocking_region(VALUE (*f)(ANYARGS), void *data)
|
|
151
153
|
}
|
152
154
|
# define NOGVL(f, d) \
|
153
155
|
fake_blocking_region(NOGVL_FUNCTION(f), (d))
|
154
|
-
#endif /*
|
155
|
-
|
156
|
+
#endif /*
|
157
|
+
* HAVE_RB_THREAD_CALL_WITHOUT_GVL
|
158
|
+
* HAVE_RUBY_THREAD_H
|
159
|
+
*/
|
156
160
|
|
157
161
|
#if defined(__cplusplus)
|
158
162
|
}
|
data/ext/magic/extconf.rb
CHANGED
@@ -9,7 +9,7 @@ PACKAGE_ROOT_DIR = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'
|
|
9
9
|
|
10
10
|
# The gem version constraint in the Rakefile is not respected at install time.
|
11
11
|
# Keep this version in sync with the one in the Rakefile !
|
12
|
-
REQUIRED_MINI_PORTILE_VERSION = "~> 2.
|
12
|
+
REQUIRED_MINI_PORTILE_VERSION = "~> 2.6"
|
13
13
|
|
14
14
|
MAGIC_HELP_MESSAGE = <<~HELP
|
15
15
|
USAGE: ruby #{$0} [options]
|
@@ -301,6 +301,14 @@ else
|
|
301
301
|
$LIBS += " " + pkg_config('libmagic', 'libs --static')
|
302
302
|
$LIBS += " " + File.join(libmagic_recipe.path, 'lib', "libmagic.#{$LIBEXT}")
|
303
303
|
end
|
304
|
+
|
305
|
+
if cross_build_p
|
306
|
+
# database files will be packaged up by the cross-compiling callback in the ExtensionTask
|
307
|
+
to_path = File.join(PACKAGE_ROOT_DIR, "ext/magic/share")
|
308
|
+
FileUtils.rm_rf(to_path, secure: true)
|
309
|
+
FileUtils.mkdir(to_path)
|
310
|
+
FileUtils.cp_r(Dir[File.join(libmagic_recipe.path, 'share/misc/*.mgc')], to_path)
|
311
|
+
end
|
304
312
|
end
|
305
313
|
|
306
314
|
$CFLAGS += ' -std=c99'
|
@@ -371,6 +379,13 @@ unless have_header('ruby.h')
|
|
371
379
|
EOS
|
372
380
|
end
|
373
381
|
|
382
|
+
# these are needed for `rb_thread_call_without_gvl` to be properly detected on some linux systems.
|
383
|
+
# specifically, rake-compiler-dock's redhat-based image needs these.
|
384
|
+
have_library('pthread')
|
385
|
+
have_library('rt')
|
386
|
+
have_library('dl')
|
387
|
+
have_library('crypt')
|
388
|
+
|
374
389
|
have_func('rb_thread_call_without_gvl')
|
375
390
|
have_func('rb_thread_blocking_region')
|
376
391
|
|
data/ext/magic/functions.c
CHANGED
@@ -4,14 +4,14 @@ extern "C" {
|
|
4
4
|
|
5
5
|
#include "functions.h"
|
6
6
|
|
7
|
-
int check_fd(int fd);
|
7
|
+
static int check_fd(int fd);
|
8
8
|
static int safe_dup(int fd);
|
9
9
|
static int safe_close(int fd);
|
10
10
|
static int safe_cloexec(int fd);
|
11
|
-
int override_error_output(void *data);
|
12
|
-
int restore_error_output(void *data);
|
11
|
+
static int override_error_output(void *data);
|
12
|
+
static int restore_error_output(void *data);
|
13
13
|
|
14
|
-
inline int
|
14
|
+
static inline int
|
15
15
|
check_fd(int fd)
|
16
16
|
{
|
17
17
|
errno = 0;
|
@@ -42,6 +42,7 @@ safe_dup(int fd)
|
|
42
42
|
goto error;
|
43
43
|
}
|
44
44
|
}
|
45
|
+
|
45
46
|
if (safe_cloexec(new_fd) < 0) {
|
46
47
|
local_errno = errno;
|
47
48
|
goto error;
|
@@ -78,6 +79,7 @@ safe_cloexec(int fd)
|
|
78
79
|
local_errno = errno;
|
79
80
|
goto error;
|
80
81
|
}
|
82
|
+
|
81
83
|
if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) {
|
82
84
|
local_errno = errno;
|
83
85
|
goto error;
|
@@ -89,18 +91,18 @@ error:
|
|
89
91
|
return -1;
|
90
92
|
}
|
91
93
|
|
92
|
-
int
|
94
|
+
static int
|
93
95
|
override_error_output(void *data)
|
94
96
|
{
|
95
97
|
int local_errno;
|
96
|
-
|
98
|
+
int flags = O_WRONLY | O_APPEND;
|
97
99
|
save_t *s = data;
|
98
100
|
|
99
101
|
#if defined(HAVE_O_CLOEXEC)
|
100
|
-
|
102
|
+
flags |= O_CLOEXEC;
|
101
103
|
#endif
|
102
104
|
|
103
|
-
assert(s != NULL &&
|
105
|
+
assert(s != NULL &&
|
104
106
|
"Must be a valid pointer to `save_t' type");
|
105
107
|
|
106
108
|
s->file.old_fd = -1;
|
@@ -116,7 +118,7 @@ override_error_output(void *data)
|
|
116
118
|
goto error;
|
117
119
|
}
|
118
120
|
|
119
|
-
s->file.new_fd = open("/dev/null",
|
121
|
+
s->file.new_fd = open("/dev/null", flags, 0222);
|
120
122
|
if (s->file.new_fd < 0) {
|
121
123
|
local_errno = errno;
|
122
124
|
|
@@ -128,10 +130,12 @@ override_error_output(void *data)
|
|
128
130
|
safe_close(s->file.old_fd);
|
129
131
|
goto error;
|
130
132
|
}
|
133
|
+
|
131
134
|
if (safe_cloexec(s->file.new_fd) < 0) {
|
132
135
|
local_errno = errno;
|
133
136
|
goto error;
|
134
137
|
}
|
138
|
+
|
135
139
|
if (dup2(s->file.new_fd, fileno(stderr)) < 0) {
|
136
140
|
local_errno = errno;
|
137
141
|
goto error;
|
@@ -146,13 +150,13 @@ error:
|
|
146
150
|
return -1;
|
147
151
|
}
|
148
152
|
|
149
|
-
int
|
153
|
+
static int
|
150
154
|
restore_error_output(void *data)
|
151
155
|
{
|
152
156
|
int local_errno;
|
153
157
|
save_t *s = data;
|
154
158
|
|
155
|
-
assert(s != NULL &&
|
159
|
+
assert(s != NULL &&
|
156
160
|
"Must be a valid pointer to `save_t' type");
|
157
161
|
|
158
162
|
if (s->file.old_fd < 0 && s->status != 0)
|
@@ -278,15 +282,21 @@ inline int
|
|
278
282
|
magic_load_wrapper(magic_t magic, const char *magic_file, int flags)
|
279
283
|
{
|
280
284
|
int rv;
|
285
|
+
|
281
286
|
MAGIC_FUNCTION(magic_load, rv, flags, magic, magic_file);
|
287
|
+
|
282
288
|
return rv;
|
283
289
|
}
|
284
290
|
|
285
291
|
inline int
|
286
|
-
magic_load_buffers_wrapper(magic_t magic, void **buffers, size_t *sizes,
|
292
|
+
magic_load_buffers_wrapper(magic_t magic, void **buffers, size_t *sizes,
|
293
|
+
size_t count, int flags)
|
287
294
|
{
|
288
295
|
int rv;
|
289
|
-
|
296
|
+
|
297
|
+
MAGIC_FUNCTION(magic_load_buffers, rv, flags, magic, buffers, sizes,
|
298
|
+
count);
|
299
|
+
|
290
300
|
return rv;
|
291
301
|
}
|
292
302
|
|
@@ -294,7 +304,9 @@ inline int
|
|
294
304
|
magic_compile_wrapper(magic_t magic, const char *magic_file, int flags)
|
295
305
|
{
|
296
306
|
int rv;
|
307
|
+
|
297
308
|
MAGIC_FUNCTION(magic_compile, rv, flags, magic, magic_file);
|
309
|
+
|
298
310
|
return rv;
|
299
311
|
}
|
300
312
|
|
@@ -302,15 +314,19 @@ inline int
|
|
302
314
|
magic_check_wrapper(magic_t magic, const char *magic_file, int flags)
|
303
315
|
{
|
304
316
|
int rv;
|
317
|
+
|
305
318
|
MAGIC_FUNCTION(magic_check, rv, flags, magic, magic_file);
|
319
|
+
|
306
320
|
return rv;
|
307
321
|
}
|
308
322
|
|
309
323
|
inline const char*
|
310
|
-
magic_file_wrapper(magic_t magic, const char*
|
324
|
+
magic_file_wrapper(magic_t magic, const char *filename, int flags)
|
311
325
|
{
|
312
326
|
const char *cstring;
|
327
|
+
|
313
328
|
MAGIC_FUNCTION(magic_file, cstring, flags, magic, filename);
|
329
|
+
|
314
330
|
return cstring;
|
315
331
|
}
|
316
332
|
|
@@ -318,7 +334,9 @@ inline const char*
|
|
318
334
|
magic_buffer_wrapper(magic_t magic, const void *buffer, size_t size, int flags)
|
319
335
|
{
|
320
336
|
const char *cstring;
|
337
|
+
|
321
338
|
MAGIC_FUNCTION(magic_buffer, cstring, flags, magic, buffer, size);
|
339
|
+
|
322
340
|
return cstring;
|
323
341
|
}
|
324
342
|
|
data/ext/magic/functions.h
CHANGED
@@ -9,7 +9,7 @@ extern "C" {
|
|
9
9
|
|
10
10
|
#define MAGIC_FUNCTION(f, r, x, ...) \
|
11
11
|
do { \
|
12
|
-
if ((x) & MAGIC_DEBUG)
|
12
|
+
if ((x) & (MAGIC_DEBUG | MAGIC_CHECK)) \
|
13
13
|
r = f(__VA_ARGS__); \
|
14
14
|
else { \
|
15
15
|
save_t __##f; \
|
@@ -17,7 +17,7 @@ extern "C" {
|
|
17
17
|
r = f(__VA_ARGS__); \
|
18
18
|
restore_error_output(&(__##f)); \
|
19
19
|
} \
|
20
|
-
} while(0)
|
20
|
+
} while (0)
|
21
21
|
|
22
22
|
typedef struct file_data {
|
23
23
|
fpos_t position;
|
@@ -33,30 +33,36 @@ typedef struct save {
|
|
33
33
|
extern magic_t magic_open_wrapper(int flags);
|
34
34
|
extern void magic_close_wrapper(magic_t magic);
|
35
35
|
|
36
|
-
extern const char*
|
36
|
+
extern const char *magic_error_wrapper(magic_t magic);
|
37
37
|
extern int magic_errno_wrapper(magic_t magic);
|
38
38
|
|
39
|
-
extern const char*
|
39
|
+
extern const char *magic_getpath_wrapper(void);
|
40
40
|
|
41
|
-
extern int magic_getparam_wrapper(magic_t magic, int parameter,
|
41
|
+
extern int magic_getparam_wrapper(magic_t magic, int parameter,
|
42
|
+
void *value);
|
42
43
|
extern int magic_setparam_wrapper(magic_t magic, int parameter,
|
43
44
|
const void *value);
|
44
45
|
|
45
46
|
extern int magic_getflags_wrapper(magic_t magic);
|
46
47
|
extern int magic_setflags_wrapper(magic_t magic, int flags);
|
47
48
|
|
48
|
-
extern int magic_load_wrapper(magic_t magic, const char *magic_file,
|
49
|
+
extern int magic_load_wrapper(magic_t magic, const char *magic_file,
|
50
|
+
int flags);
|
49
51
|
extern int magic_load_buffers_wrapper(magic_t magic, void **buffers,
|
50
|
-
size_t *sizes, size_t count,
|
52
|
+
size_t *sizes, size_t count,
|
53
|
+
int flags);
|
51
54
|
|
52
|
-
extern int magic_compile_wrapper(magic_t magic, const char *magic_file,
|
53
|
-
|
55
|
+
extern int magic_compile_wrapper(magic_t magic, const char *magic_file,
|
56
|
+
int flags);
|
57
|
+
extern int magic_check_wrapper(magic_t magic, const char *magic_file,
|
58
|
+
int flags);
|
54
59
|
|
55
|
-
extern const char*
|
60
|
+
extern const char *magic_file_wrapper(magic_t magic, const char *filename,
|
56
61
|
int flags);
|
57
|
-
extern const char*
|
62
|
+
extern const char *magic_buffer_wrapper(magic_t magic, const void *buffer,
|
58
63
|
size_t size, int flags);
|
59
|
-
extern const char*
|
64
|
+
extern const char *magic_descriptor_wrapper(magic_t magic, int fd,
|
65
|
+
int flags);
|
60
66
|
|
61
67
|
extern int magic_version_wrapper(void);
|
62
68
|
|