bsdcontrol.rb 0.2.1 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bcd52d19202a55fc6176b596436dba3ec085b6ad1306061a542025f0734f23c
4
- data.tar.gz: bc8d18ded3d2be28dd13ebd894a3d427ea2fc8c7e6cd3318a3c2af1a2e7206a3
3
+ metadata.gz: b226b4654ead9d86f8658f1f2578b589bde0647c87ed6bdd2393afa8a70b3a14
4
+ data.tar.gz: 7fe0f050a4c3168456785f51cbea8f033aa01ff822bc70efbacd7f237478b674
5
5
  SHA512:
6
- metadata.gz: da3aee74d3443f889cf5b6458054f0b1ae6000597f0a639105852d37806586ab8753bb1c8f87ba102cdfdcf59c26559ffa62cbbf20df969087732c7307c4b619
7
- data.tar.gz: 38ac41550d6d9b8ab8873fd6bd846648e929e7d4c078cc5b9a7152c3ae8611bbfffaf23d0e965cb54d783e333e86ba86003ae9b4c59638dcd56e9077c5f6ebee
6
+ metadata.gz: ea15d78c722aee649f614248364d28aed968572590cfab91be2995a8607d75df534ccf0af459973d1174a81841753e68c851b8f6a2eab5c4d1fc3dba9f0a5917
7
+ data.tar.gz: 32141573f2ce20eb1be88267fa5f657017522f31cff6e7610c080ddbbd84fe10325e925d266e1b3e21da9e83d7e3c77f338b74adb804b4f1c9ae9fd0e5ec769c
data/LICENSE CHANGED
File without changes
data/README.md CHANGED
@@ -1,13 +1,15 @@
1
1
  ## About
2
2
 
3
- bsdcontrol.rb provides Ruby bindings for libhbsdcontrol from the
4
- [HardenedBSD](https://HardenedBSD.org) project.
3
+ bsdcontrol.rb provides Ruby bindings for
4
+ [libhbsdcontrol](https://git.hardenedbsd.org/hardenedbsd/HardenedBSD/-/tree/hardened/current/master/lib/libhbsdcontrol/).
5
5
 
6
6
  ## Examples
7
7
 
8
- __Features__
8
+ ### BSD::Control
9
9
 
10
- The first example prints a list of HardenedBSD features that
10
+ #### Features
11
+
12
+ The following example prints a list of HardenedBSD features that
11
13
  can be enabled, disabled or restored to the system default
12
14
  setting:
13
15
 
@@ -22,9 +24,9 @@ BSD::Control
22
24
  end
23
25
  ```
24
26
 
25
- __Enable__
27
+ #### Enable
26
28
 
27
- The following example enables the mprotect feature for the emacs binary. When
29
+ The next example enables the mprotect feature for the emacs binary. When
28
30
  a feature is enabled for a given file, that setting takes precendence
29
31
  over the system default. The system default can be restored with
30
32
  [BSD::Control::Feature#sysdef!](http://0x1eef.github.io/x/bsdcontrol.rb/BSD/Control/Feature.html#sysdef!-instance_method):
@@ -35,10 +37,10 @@ over the system default. The system default can be restored with
35
37
  require "bsdcontrol"
36
38
  BSD::Control
37
39
  .feature(:mprotect)
38
- .enable!("/usr/local/bin/emacs-29.2")
40
+ .enable! File.realpath("/usr/local/bin/emacs")
39
41
  ```
40
42
 
41
- __Status__
43
+ #### Status
42
44
 
43
45
  There are five recognized statuses: `unknown`, `enabled`, `disabled`,
44
46
  `sysdef`, and `invalid`. The `sysdef` status indicates that a feature
@@ -54,15 +56,34 @@ BSD::Control
54
56
  .status("/bin/ls") # => :sysdef
55
57
  ```
56
58
 
59
+ #### Namespaces
60
+
61
+ The libhbsdcontrol library is implemented via extended attribute namespaces
62
+ (see [extattr(2)](https://man.freebsd.org/extattr)), and the default namespace
63
+ is the "system" namespace. The "system" namespace requires root privileges if
64
+ you want to modify or read attributes, but the "user" namespace can be accessed by
65
+ unprivileged users.
66
+
67
+ At the moment the HardenedBSD kernel works purely with the system namespace, but
68
+ there are plans to add support for the user namespace in the future. Switching between
69
+ namespaces can be achieved with the [BSD::Control::Feature#set_namespace](http://0x1eef.github.io/x/bsdcontrol.rb/BSD/Control/Feature.html#namespace=-instance_method)
70
+ method:
71
+
72
+ ``` ruby
73
+ #!/usr/bin/env ruby
74
+ # Required privileges: user
75
+ require "bsdcontrol"
76
+ BSD::Control.set_namespace(:user)
77
+ BSD::Control["mprotect"].status("/bin/ls") # => :sysdef
78
+ ```
79
+
57
80
  ## Documentation
58
81
 
59
82
  A complete API reference is available at
60
- [0x1eef.github.io/x/bsdcontrol.rb](https://0x1eef.github.io/x/bsdcontrol.rb).
83
+ [0x1eef.github.io/x/bsdcontrol.rb](https://0x1eef.github.io/x/bsdcontrol.rb)
61
84
 
62
85
  ## Install
63
86
 
64
- **Rubygems.org**
65
-
66
87
  bsdcontrol.rb can be installed via rubygems.org:
67
88
 
68
89
  gem install bsdcontrol.rb
@@ -71,11 +92,11 @@ bsdcontrol.rb can be installed via rubygems.org:
71
92
 
72
93
  * [GitHub](https://github.com/0x1eef/bsdcontrol.rb)
73
94
  * [GitLab](https://gitlab.com/0x1eef/bsdcontrol.rb)
74
- * [git.HardenedBSD.org](https://git.HardenedBSD.org/0x1eef/bsdcontrol.rb)
95
+ * [git.HardenedBSD.org/@0x1eef](https://git.HardenedBSD.org/0x1eef/bsdcontrol.rb)
96
+ * [brew.bsd.cafe/@0x1eef](https://brew.bsd.cafe/0x1eef/bsdcontrol.rb)
75
97
 
76
98
  ## License
77
99
 
78
- [BSD Zero Clause](https://choosealicense.com/licenses/0bsd/).
100
+ [BSD Zero Clause](https://choosealicense.com/licenses/0bsd/)
79
101
  <br>
80
- See [LICENSE](./LICENSE).
81
-
102
+ See [LICENSE](./LICENSE)
@@ -1,6 +1,11 @@
1
1
  #include <ruby.h>
2
+ #include <libhbsdcontrol.h>
3
+ #include <fcntl.h>
4
+ #include <errno.h>
5
+
2
6
  #include "context.h"
3
7
  #include "feature.h"
8
+ #include "bsdcontrol.h"
4
9
 
5
10
  void
6
11
  Init_bsdcontrol(void)
@@ -12,6 +17,10 @@ Init_bsdcontrol(void)
12
17
  rb_define_alloc_func(rb_cContext, bsdcontrol_context_alloc);
13
18
  rb_define_method(
14
19
  rb_cContext, "library_version", bsdcontrol_context_library_version, 0);
20
+ rb_define_method(
21
+ rb_cContext, "set_namespace", bsdcontrol_context_set_namespace, 1);
22
+ rb_define_method(
23
+ rb_cContext, "namespace", bsdcontrol_context_get_namespace, 0);
15
24
  rb_define_method(rb_cContext,
16
25
  "available_features",
17
26
  bsdcontrol_context_available_features,
@@ -22,3 +31,16 @@ Init_bsdcontrol(void)
22
31
  rb_define_const(rb_cFeature, "ENABLED", INT2NUM(HBSDCTRL_STATE_ENABLED));
23
32
  rb_define_const(rb_cFeature, "DISABLED", INT2NUM(HBSDCTRL_STATE_DISABLED));
24
33
  }
34
+
35
+ int
36
+ bsdcontrol_open(VALUE path)
37
+ {
38
+ int fd;
39
+ Check_Type(path, T_STRING);
40
+ fd = open(RSTRING_PTR(path), O_PATH);
41
+ if (fd == -1)
42
+ {
43
+ rb_syserr_fail(errno, "open");
44
+ }
45
+ return fd;
46
+ }
@@ -0,0 +1,5 @@
1
+ #pragma once
2
+ #include <ruby.h>
3
+ #include <libhbsdcontrol.h>
4
+
5
+ int bsdcontrol_open(VALUE);
@@ -1,7 +1,9 @@
1
1
  #include <ruby.h>
2
2
  #include <libhbsdcontrol.h>
3
+ #include <sys/extattr.h>
4
+ #include <libutil.h>
3
5
  #include "context.h"
4
- #include "glue.h"
6
+ #include "bsdcontrol.h"
5
7
 
6
8
  static int FLAGS = HBSDCTRL_FEATURE_STATE_FLAG_NONE;
7
9
  static const char *NAMESPACE = LIBHBSDCONTROL_DEFAULT_NAMESPACE;
@@ -39,7 +41,7 @@ bsdcontrol_context_available_features(VALUE self)
39
41
  feature = 0, features = rb_ary_new();
40
42
  hbsdctrl_ctx_t *ctx;
41
43
  char **name;
42
- ctx = bsdcontrol_unwrap(self);
44
+ ctx = bsdcontrol_context_unwrap(self);
43
45
  name = hbsdctrl_ctx_all_feature_names(ctx);
44
46
  while (*name != NULL)
45
47
  {
@@ -59,6 +61,63 @@ VALUE
59
61
  bsdcontrol_context_library_version(VALUE self)
60
62
  {
61
63
  hbsdctrl_ctx_t *ctx;
62
- ctx = bsdcontrol_unwrap(self);
64
+ ctx = bsdcontrol_context_unwrap(self);
63
65
  return ULONG2NUM(ctx->hc_version);
64
66
  }
67
+
68
+ /*
69
+ * BSD::Control::Context#namespace
70
+ * BSD::Control.namespace
71
+ */
72
+ VALUE
73
+ bsdcontrol_context_get_namespace(VALUE self)
74
+ {
75
+ hbsdctrl_ctx_t *ctx;
76
+ char *namespace;
77
+ ctx = bsdcontrol_context_unwrap(self);
78
+ if (extattr_namespace_to_string(ctx->hc_namespace, &namespace) == 0)
79
+ {
80
+ return ID2SYM(rb_intern(namespace));
81
+ }
82
+ else
83
+ {
84
+ return Qnil;
85
+ }
86
+ }
87
+
88
+ /*
89
+ * BSD::Control::Context#set_namespace
90
+ * BSD::Control.set_namespace
91
+ */
92
+ VALUE
93
+ bsdcontrol_context_set_namespace(VALUE self, VALUE namespace)
94
+ {
95
+ Check_Type(namespace, T_STRING);
96
+ hbsdctrl_ctx_t *ctx;
97
+ char *ns;
98
+ ns = RSTRING_PTR(namespace);
99
+ if (strcmp(ns, "system") == 0 || strcmp(ns, "user") == 0)
100
+ {
101
+ ctx = bsdcontrol_context_unwrap(self);
102
+ if (extattr_string_to_namespace(ns, &(ctx->hc_namespace)) == 0)
103
+ {
104
+ return Qtrue;
105
+ }
106
+ else
107
+ {
108
+ return Qfalse;
109
+ }
110
+ }
111
+ else
112
+ {
113
+ rb_raise(rb_eArgError, "namespace must be 'system' or 'user'");
114
+ }
115
+ }
116
+
117
+ hbsdctrl_ctx_t *
118
+ bsdcontrol_context_unwrap(VALUE rbcontext)
119
+ {
120
+ hbsdctrl_ctx_t *ctx;
121
+ Data_Get_Struct(rbcontext, hbsdctrl_ctx_t, ctx);
122
+ return ctx;
123
+ }
@@ -4,3 +4,6 @@
4
4
  VALUE bsdcontrol_context_alloc(VALUE);
5
5
  VALUE bsdcontrol_context_library_version(VALUE);
6
6
  VALUE bsdcontrol_context_available_features(VALUE);
7
+ VALUE bsdcontrol_context_set_namespace(VALUE, VALUE);
8
+ VALUE bsdcontrol_context_get_namespace(VALUE);
9
+ hbsdctrl_ctx_t* bsdcontrol_context_unwrap(VALUE);
File without changes
@@ -4,7 +4,7 @@
4
4
  #include <errno.h>
5
5
  #include "feature.h"
6
6
  #include "context.h"
7
- #include "glue.h"
7
+ #include "bsdcontrol.h"
8
8
 
9
9
  /*
10
10
  * BSD::Control::Feature#status
@@ -19,8 +19,8 @@ bsdcontrol_feature_status(VALUE self, VALUE path)
19
19
  hbsdctrl_ctx_t *ctx;
20
20
  rbcontext = rb_funcall(self, rb_intern("context"), 0);
21
21
  fd = bsdcontrol_open(path);
22
- ctx = bsdcontrol_unwrap(rbcontext);
23
- feature = bsdcontrol_find_feature(ctx, self);
22
+ ctx = bsdcontrol_context_unwrap(rbcontext);
23
+ feature = bsdcontrol_feature_find_by_name(ctx, self);
24
24
  errno = 0;
25
25
  if (feature->hf_get(ctx, feature, &fd, &state) == RES_FAIL)
26
26
  {
@@ -50,8 +50,8 @@ bsdcontrol_feature_set(VALUE self, VALUE path, VALUE rbstate)
50
50
  int state;
51
51
  rbcontext = rb_funcall(self, rb_intern("context"), 0);
52
52
  fd = bsdcontrol_open(path);
53
- ctx = bsdcontrol_unwrap(rbcontext);
54
- feature = bsdcontrol_find_feature(ctx, self);
53
+ ctx = bsdcontrol_context_unwrap(rbcontext);
54
+ feature = bsdcontrol_feature_find_by_name(ctx, self);
55
55
  state = NUM2INT(rbstate);
56
56
  errno = 0;
57
57
  if (feature->hf_apply(ctx, feature, &fd, &state) == RES_FAIL)
@@ -79,8 +79,8 @@ bsdcontrol_feature_sysdef(VALUE self, VALUE path)
79
79
  hbsdctrl_ctx_t *ctx;
80
80
  rbcontext = rb_funcall(self, rb_intern("context"), 0);
81
81
  fd = bsdcontrol_open(path);
82
- ctx = bsdcontrol_unwrap(rbcontext);
83
- feature = bsdcontrol_find_feature(ctx, self);
82
+ ctx = bsdcontrol_context_unwrap(rbcontext);
83
+ feature = bsdcontrol_feature_find_by_name(ctx, self);
84
84
  errno = 0;
85
85
  if (feature->hf_unapply(ctx, feature, &fd, NULL) == RES_FAIL)
86
86
  {
@@ -94,3 +94,12 @@ bsdcontrol_feature_sysdef(VALUE self, VALUE path)
94
94
  return Qtrue;
95
95
  }
96
96
  }
97
+
98
+ hbsdctrl_feature_t *
99
+ bsdcontrol_feature_find_by_name(hbsdctrl_ctx_t *ctx, VALUE rbfeature)
100
+ {
101
+ VALUE name;
102
+ name = rb_funcall(rbfeature, rb_intern("name"), 0);
103
+ Check_Type(name, T_STRING);
104
+ return hbsdctrl_ctx_find_feature_by_name(ctx, RSTRING_PTR(name));
105
+ }
@@ -1,4 +1,9 @@
1
+ #pragma once
2
+
1
3
  #include <ruby.h>
4
+ #include <libhbsdcontrol.h>
5
+
2
6
  VALUE bsdcontrol_feature_status(VALUE, VALUE);
3
7
  VALUE bsdcontrol_feature_set(VALUE,VALUE,VALUE);
4
8
  VALUE bsdcontrol_feature_sysdef(VALUE, VALUE);
9
+ hbsdctrl_feature_t* bsdcontrol_feature_find_by_name(hbsdctrl_ctx_t*, VALUE);
File without changes
@@ -14,13 +14,10 @@ module BSD::Control
14
14
 
15
15
  ##
16
16
  # Enables a feature for a given file
17
- #
18
17
  # @param [String] path
19
18
  # The path to a file
20
- #
21
19
  # @raise [SystemCallError]
22
20
  # Might raise a number of Errno exceptions
23
- #
24
21
  # @return [Boolean]
25
22
  # Returns true on success
26
23
  def enable!(path)
@@ -29,13 +26,10 @@ module BSD::Control
29
26
 
30
27
  ##
31
28
  # Disables a feature for a given file
32
- #
33
29
  # @param [String] path
34
30
  # The path to a file
35
- #
36
31
  # @raise [SystemCallError]
37
32
  # Might raise a number of Errno exceptions
38
- #
39
33
  # @return [Boolean]
40
34
  # Returns true on success
41
35
  def disable!(path)
@@ -45,13 +39,10 @@ module BSD::Control
45
39
  ##
46
40
  # @!method sysdef!(path)
47
41
  # Restores the system default for a given file
48
- #
49
42
  # @param [String] path
50
43
  # The path to a file
51
- #
52
44
  # @raise [SystemCallError]
53
45
  # Might raise a number of Errno exceptions
54
- #
55
46
  # @return [Boolean]
56
47
  # Returns true on success
57
48
 
@@ -63,7 +54,6 @@ module BSD::Control
63
54
  ##
64
55
  # @param [String] path
65
56
  # The path to a file
66
- #
67
57
  # @return [Boolean]
68
58
  # Returns true when a feature is enabled
69
59
  def enabled?(path)
@@ -73,7 +63,6 @@ module BSD::Control
73
63
  ##
74
64
  # @param [String] path
75
65
  # The path to a file.
76
- #
77
66
  # @return [Boolean]
78
67
  # Returns true when a feature is disabled
79
68
  def disabled?(path)
@@ -83,7 +72,6 @@ module BSD::Control
83
72
  ##
84
73
  # @param [String] path
85
74
  # The path to a file
86
- #
87
75
  # @return [Boolean]
88
76
  # Returns true when the system default setting is used
89
77
  def sysdef?(path)
@@ -93,7 +81,6 @@ module BSD::Control
93
81
  ##
94
82
  # @param [String] path
95
83
  # The path to a file
96
- #
97
84
  # @return [Boolean]
98
85
  # Returns true when a feature is in an invalid state
99
86
  # (eg: the feature is both enabled and disabled at the same time)
@@ -105,10 +92,8 @@ module BSD::Control
105
92
  # @!method status(path)
106
93
  # @param [String] path
107
94
  # The path to a file
108
- #
109
95
  # @raise [SystemCallError]
110
96
  # Might raise a number of Errno exceptions
111
- #
112
97
  # @return [Symbol]
113
98
  # Returns the status of a feature for a given file.
114
99
  # Status could be: `:unknown`, `:enabled`, `:disabled`,
@@ -2,6 +2,6 @@
2
2
 
3
3
  module BSD
4
4
  module Control
5
- VERSION = "0.2.1"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
data/lib/bsd/control.rb CHANGED
@@ -20,6 +20,23 @@ module BSD::Control
20
20
  context.library_version
21
21
  end
22
22
 
23
+ ##
24
+ # @param [#to_s] namespace
25
+ # Either "user" or "system"
26
+ # @raise [ArgumentError]
27
+ # When an invalid namespace was given
28
+ # @return [void]
29
+ def self.set_namespace(namespace)
30
+ context.set_namespace(namespace.to_s)
31
+ end
32
+
33
+ ##
34
+ # @return [String]
35
+ # Returns the current namespace
36
+ def self.namespace
37
+ context.namespace
38
+ end
39
+
23
40
  ##
24
41
  # @return [Array<BSD::Control::Feature>]
25
42
  # Returns an array of available features
@@ -29,16 +46,16 @@ module BSD::Control
29
46
 
30
47
  ##
31
48
  # @example
49
+ # # This works
32
50
  # BSD::Control
33
51
  # .feature(:mprotect)
34
52
  # .enable!("/usr/local/bin/emacs-29.2")
35
- #
53
+ # # This also works
54
+ # BSD::Control[:mprotect].enable!("/usr/local/bin/emacs-29.2")
36
55
  # @param [String] name
37
56
  # The name of a feature
38
- #
39
57
  # @raise [BSD::Control::Error]
40
58
  # When a feature wasn't found
41
- #
42
59
  # @return [BSD::Control::Feature]
43
60
  # Returns an instance of {BSD::Control::Feature BSD::Control::Feature}
44
61
  def self.feature(name)
@@ -46,6 +63,10 @@ module BSD::Control
46
63
  feature || raise(Error, "'#{name}' wasn't found")
47
64
  end
48
65
 
66
+ class << self
67
+ alias_method :[], :feature
68
+ end
69
+
49
70
  require_relative "control/context"
50
71
  require_relative "control/feature"
51
72
  require_relative "../bsdcontrol.rb.so"
data/lib/bsdcontrol.rb CHANGED
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Required privileges: superuser
5
+ require "bsdcontrol"
6
+ BSD::Control
7
+ .feature(:mprotect)
8
+ .enable! File.realpath("/usr/local/bin/emacs")
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # Required privileges: superuser
5
+ require "bsdcontrol"
6
+ BSD::Control
7
+ .feature(:mprotect)
8
+ .status("/bin/ls") # => :sysdef
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bsdcontrol.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - '0x1eef'
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-14 00:00:00.000000000 Z
11
+ date: 2025-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.8'
47
+ version: '0.12'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.8'
54
+ version: '0.12'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: test-unit
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: irb
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.15'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.15'
69
83
  description: Ruby bindings for libhbsdcontrol
70
84
  email:
71
85
  - 0x1eef@protonmail.com
@@ -75,19 +89,20 @@ extensions:
75
89
  extra_rdoc_files: []
76
90
  files:
77
91
  - "./ext/bsdcontrol.rb/bsdcontrol.c"
92
+ - "./ext/bsdcontrol.rb/bsdcontrol.h"
78
93
  - "./ext/bsdcontrol.rb/context.c"
79
94
  - "./ext/bsdcontrol.rb/context.h"
80
95
  - "./ext/bsdcontrol.rb/extconf.rb"
81
96
  - "./ext/bsdcontrol.rb/feature.c"
82
97
  - "./ext/bsdcontrol.rb/feature.h"
83
- - "./ext/bsdcontrol.rb/glue.c"
84
- - "./ext/bsdcontrol.rb/glue.h"
85
98
  - "./lib/bsd/control.rb"
86
99
  - "./lib/bsd/control/context.rb"
87
100
  - "./lib/bsd/control/feature.rb"
88
101
  - "./lib/bsd/control/version.rb"
89
102
  - "./lib/bsdcontrol.rb"
90
103
  - "./share/bsdcontrol.rb/examples/1_available_features.rb"
104
+ - "./share/bsdcontrol.rb/examples/2_feature_enable.rb"
105
+ - "./share/bsdcontrol.rb/examples/3_feature_status.rb"
91
106
  - LICENSE
92
107
  - README.md
93
108
  - ext/bsdcontrol.rb/extconf.rb
@@ -110,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
125
  - !ruby/object:Gem::Version
111
126
  version: '0'
112
127
  requirements: []
113
- rubygems_version: 3.5.9
128
+ rubygems_version: 3.5.23
114
129
  signing_key:
115
130
  specification_version: 4
116
131
  summary: Ruby bindings for libhbsdcontrol
@@ -1,36 +0,0 @@
1
- #include <ruby.h>
2
- #include <libhbsdcontrol.h>
3
- #include <fcntl.h>
4
- #include <errno.h>
5
- #include "glue.h"
6
- #include "context.h"
7
-
8
- int
9
- bsdcontrol_open(VALUE path)
10
- {
11
- int fd;
12
- Check_Type(path, T_STRING);
13
- fd = open(RSTRING_PTR(path), O_PATH);
14
- if (fd == -1)
15
- {
16
- rb_syserr_fail(errno, "open");
17
- }
18
- return fd;
19
- }
20
-
21
- hbsdctrl_ctx_t *
22
- bsdcontrol_unwrap(VALUE rbcontext)
23
- {
24
- hbsdctrl_ctx_t *ctx;
25
- Data_Get_Struct(rbcontext, hbsdctrl_ctx_t, ctx);
26
- return ctx;
27
- }
28
-
29
- hbsdctrl_feature_t *
30
- bsdcontrol_find_feature(hbsdctrl_ctx_t *ctx, VALUE rbfeature)
31
- {
32
- VALUE name;
33
- name = rb_funcall(rbfeature, rb_intern("name"), 0);
34
- Check_Type(name, T_STRING);
35
- return hbsdctrl_ctx_find_feature_by_name(ctx, RSTRING_PTR(name));
36
- }
@@ -1,7 +0,0 @@
1
- #pragma once
2
- #include <ruby.h>
3
- #include <libhbsdcontrol.h>
4
-
5
- int bsdcontrol_open(VALUE);
6
- hbsdctrl_ctx_t* bsdcontrol_unwrap(VALUE);
7
- hbsdctrl_feature_t* bsdcontrol_find_feature(hbsdctrl_ctx_t*, VALUE);