ruby-lxc 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/ext/lxc/lxc.c +68 -38
  3. data/lib/lxc/version.rb +1 -1
  4. metadata +17 -24
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3ba5a64fe4b7b98f040795b91c9fda9da327999c
4
+ data.tar.gz: c53c4ce45db4ab47dac83892f677cc5411c3b8c6
5
+ SHA512:
6
+ metadata.gz: 133dd82ad145c563d785a16b08863b808fe026f1fc80c41e4504337214e9f6577d7e97a622a96a9ebb9fdac63415395ec6f40aad64ea99621bf51840c7cd4435
7
+ data.tar.gz: 9f21506154f0c2ca00e2c05c0e99a5107ceb7187922d53abce8a45d1ded25b473b41e05352141498955354fa1d7502384dcc028c30f93835606065476b7b75d9
data/ext/lxc/lxc.c CHANGED
@@ -546,10 +546,10 @@ is_string_array(VALUE v)
546
546
  }
547
547
 
548
548
  static int
549
- is_io(VALUE v)
549
+ has_file_descriptor(VALUE v)
550
550
  {
551
- return rb_respond_to(v, rb_intern("sysread")) &&
552
- rb_respond_to(v, rb_intern("syswrite"));
551
+ return rb_respond_to(v, rb_intern("fileno")) &&
552
+ rb_funcall(v, rb_intern("fileno"), 0) != Qnil;
553
553
  }
554
554
 
555
555
  static void
@@ -569,11 +569,12 @@ lxc_attach_free_options(lxc_attach_options_t *opts)
569
569
  static lxc_attach_options_t *
570
570
  lxc_attach_parse_options(VALUE rb_opts)
571
571
  {
572
+ char *error = NULL;
572
573
  lxc_attach_options_t default_opts = LXC_ATTACH_OPTIONS_DEFAULT;
573
574
  lxc_attach_options_t *opts;
574
575
  VALUE rb_attach_flags, rb_namespaces, rb_personality, rb_initial_cwd;
575
576
  VALUE rb_uid, rb_gid, rb_env_policy, rb_extra_env_vars, rb_extra_keep_env;
576
- VALUE rb_stdin, rb_stdout, rb_stderr;
577
+ VALUE rb_stdin_opt, rb_stdout_opt, rb_stderr_opt;
577
578
 
578
579
  opts = malloc(sizeof(*opts));
579
580
  if (opts == NULL)
@@ -583,96 +584,125 @@ lxc_attach_parse_options(VALUE rb_opts)
583
584
  if (NIL_P(rb_opts))
584
585
  return opts;
585
586
 
587
+ error = NULL;
588
+
586
589
  rb_attach_flags = rb_hash_aref(rb_opts, SYMBOL("flags"));
587
590
  if (!NIL_P(rb_attach_flags)) {
588
- if (is_integer(rb_attach_flags))
591
+ if (is_integer(rb_attach_flags)) {
589
592
  opts->attach_flags = NUM2INT(rb_attach_flags);
590
- else
593
+ } else {
594
+ error = "flags must be an integer";
591
595
  goto err;
596
+ }
592
597
  }
593
598
  rb_namespaces = rb_hash_aref(rb_opts, SYMBOL("namespaces"));
594
599
  if (!NIL_P(rb_namespaces)) {
595
- if (is_integer(rb_namespaces))
600
+ if (is_integer(rb_namespaces)) {
596
601
  opts->namespaces = NUM2INT(rb_namespaces);
597
- else
602
+ } else {
603
+ error = "namespaces must be an integer";
598
604
  goto err;
605
+ }
599
606
  }
600
607
  rb_personality = rb_hash_aref(rb_opts, SYMBOL("personality"));
601
608
  if (!NIL_P(rb_personality)) {
602
- if (is_integer(rb_personality))
609
+ if (is_integer(rb_personality)) {
603
610
  opts->personality = NUM2INT(rb_personality);
604
- else
611
+ } else {
612
+ error = "personality must be an integer";
605
613
  goto err;
614
+ }
606
615
  }
607
616
  rb_initial_cwd = rb_hash_aref(rb_opts, SYMBOL("initial_cwd"));
608
617
  if (!NIL_P(rb_initial_cwd)) {
609
- if (is_string(rb_initial_cwd))
618
+ if (is_string(rb_initial_cwd)) {
610
619
  opts->initial_cwd = StringValuePtr(rb_initial_cwd);
611
- else
620
+ } else {
621
+ error = "initial_cwd must be a string";
612
622
  goto err;
623
+ }
613
624
  }
614
625
  rb_uid = rb_hash_aref(rb_opts, SYMBOL("uid"));
615
626
  if (!NIL_P(rb_uid)) {
616
- if (is_integer(rb_uid))
627
+ if (is_integer(rb_uid)) {
617
628
  opts->uid = NUM2INT(rb_uid);
618
- else
629
+ } else {
630
+ error = "uid must be an integer";
619
631
  goto err;
632
+ }
620
633
  }
621
634
  rb_gid = rb_hash_aref(rb_opts, SYMBOL("gid"));
622
635
  if (!NIL_P(rb_gid)) {
623
- if (is_integer(rb_gid))
636
+ if (is_integer(rb_gid)) {
624
637
  opts->gid = NUM2INT(rb_gid);
625
- else
638
+ } else {
639
+ error = "gid must be an integer";
626
640
  goto err;
641
+ }
627
642
  }
628
643
  rb_env_policy = rb_hash_aref(rb_opts, SYMBOL("env_policy"));
629
644
  if (!NIL_P(rb_env_policy)) {
630
- if (is_integer(rb_env_policy))
645
+ if (is_integer(rb_env_policy)) {
631
646
  opts->env_policy = NUM2INT(rb_env_policy);
632
- else
647
+ } else {
648
+ error = "env_policy must be an integer";
633
649
  goto err;
650
+ }
634
651
  }
635
652
  rb_extra_env_vars = rb_hash_aref(rb_opts, SYMBOL("extra_env_vars"));
636
653
  if (!NIL_P(rb_extra_env_vars)) {
637
- if (is_string_array(rb_extra_env_vars))
654
+ if (is_string_array(rb_extra_env_vars)) {
638
655
  opts->extra_env_vars = ruby_to_c_string_array(rb_extra_env_vars);
639
- else
656
+ } else {
657
+ error = "extra_env_vars must be a array of strings";
640
658
  goto err;
659
+ }
641
660
  }
642
661
  rb_extra_keep_env = rb_hash_aref(rb_opts, SYMBOL("extra_keep_env"));
643
662
  if (!NIL_P(rb_extra_keep_env)) {
644
- if (is_string_array(rb_extra_keep_env))
663
+ if (is_string_array(rb_extra_keep_env)) {
645
664
  opts->extra_keep_env = ruby_to_c_string_array(rb_extra_keep_env);
646
- else
665
+ } else {
666
+ error = "extra_keep_env must be a array of strings";
647
667
  goto err;
668
+ }
648
669
  }
649
- rb_stdin = rb_hash_aref(rb_opts, SYMBOL("stdin"));
650
- if (!NIL_P(rb_stdin)) {
651
- if (is_io(rb_stdin))
652
- opts->stdin_fd = io_fileno(rb_stdin);
653
- else
670
+ rb_stdin_opt = rb_hash_aref(rb_opts, SYMBOL("stdin"));
671
+ if (!NIL_P(rb_stdin_opt)) {
672
+ if (has_file_descriptor(rb_stdin_opt)) {
673
+ opts->stdin_fd = io_fileno(rb_stdin_opt);
674
+ } else {
675
+ error = "stdin object must have a file descriptor";
654
676
  goto err;
677
+ }
655
678
  }
656
- rb_stdout = rb_hash_aref(rb_opts, SYMBOL("stdout"));
657
- if (!NIL_P(rb_stdout)) {
658
- if (is_io(rb_stdout))
659
- opts->stdout_fd = io_fileno(rb_stdout);
660
- else
679
+ rb_stdout_opt = rb_hash_aref(rb_opts, SYMBOL("stdout"));
680
+ if (!NIL_P(rb_stdout_opt)) {
681
+ if (has_file_descriptor(rb_stdout_opt)) {
682
+ opts->stdout_fd = io_fileno(rb_stdout_opt);
683
+ } else {
684
+ error = "stdout object must have a file descriptor";
661
685
  goto err;
686
+ }
662
687
  }
663
- rb_stderr = rb_hash_aref(rb_opts, SYMBOL("stderr"));
664
- if (!NIL_P(rb_stderr)) {
665
- if (is_io(rb_stderr))
666
- opts->stderr_fd = io_fileno(rb_stderr);
667
- else
688
+ rb_stderr_opt = rb_hash_aref(rb_opts, SYMBOL("stderr"));
689
+ if (!NIL_P(rb_stderr_opt)) {
690
+ if (has_file_descriptor(rb_stderr_opt)) {
691
+ opts->stderr_fd = io_fileno(rb_stderr_opt);
692
+ } else {
693
+ error = "stderr object must have a file descriptor";
668
694
  goto err;
695
+ }
669
696
  }
670
697
 
671
698
  return opts;
672
699
 
673
700
  err:
674
701
  lxc_attach_free_options(opts);
675
- return NULL;
702
+ if (error != NULL)
703
+ rb_raise(rb_eArgError, "%s", error);
704
+ else
705
+ return NULL;
676
706
  }
677
707
 
678
708
  static RETURN_WITHOUT_GVL_TYPE
data/lib/lxc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module LXC
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
metadata CHANGED
@@ -1,98 +1,91 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lxc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
5
- prerelease:
4
+ version: 1.2.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Andre Nathan
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-06-13 00:00:00.000000000 Z
11
+ date: 2016-01-04 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rdoc
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rdoc-data
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake-compiler
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
- description: ! " Ruby-LXC is a Ruby binding for the liblxc library, allowing\n
63
- \ Ruby scripts to create and manage Linux containers.\n"
55
+ description: |2
56
+ Ruby-LXC is a Ruby binding for the liblxc library, allowing
57
+ Ruby scripts to create and manage Linux containers.
64
58
  email: andre@digirati.com.br
65
59
  executables: []
66
60
  extensions:
67
61
  - ext/lxc/extconf.rb
68
62
  extra_rdoc_files: []
69
63
  files:
70
- - ext/lxc/lxc.c
71
64
  - ext/lxc/extconf.rb
65
+ - ext/lxc/lxc.c
72
66
  - lib/lxc.rb
73
67
  - lib/lxc/version.rb
74
68
  homepage: https://github.com/lxc/ruby-lxc
75
69
  licenses: []
70
+ metadata: {}
76
71
  post_install_message:
77
72
  rdoc_options: []
78
73
  require_paths:
79
74
  - lib
80
75
  required_ruby_version: !ruby/object:Gem::Requirement
81
- none: false
82
76
  requirements:
83
- - - ! '>='
77
+ - - ">="
84
78
  - !ruby/object:Gem::Version
85
79
  version: '0'
86
80
  required_rubygems_version: !ruby/object:Gem::Requirement
87
- none: false
88
81
  requirements:
89
- - - ! '>='
82
+ - - ">="
90
83
  - !ruby/object:Gem::Version
91
84
  version: '0'
92
85
  requirements: []
93
86
  rubyforge_project:
94
- rubygems_version: 1.8.23
87
+ rubygems_version: 2.4.5
95
88
  signing_key:
96
- specification_version: 3
89
+ specification_version: 4
97
90
  summary: Ruby bindings for liblxc
98
91
  test_files: []