Skip to content

Commit 268c7c5

Browse files
committed
📚 Prepare v0.4.0-rc1 release documentation
- Add comprehensive CHANGELOG.md with emoji legend and organized release notes - Update README.md with new v0.4.0 features: configuration system, Sudo.as_root DSL, graphical password prompts, and timeouts - Document ASK_PATH_CMD constant for convenient askpass program detection - Fix spelling errors and improve documentation clarity - Update VERSION constant to 0.4.0-rc1 for pre-release
1 parent 638d597 commit 268c7c5

3 files changed

Lines changed: 92 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# Sudo
22

3+
<!--
4+
Emoji Legend:
5+
🎉 Initial Release ✨ Feature 🐛 Bug Fix 🔒 Security
6+
🚀 Compatibility 💥 Breaking 🔧 Internal ✅ Testing
7+
📚 Documentation 📄 License 🗑️ Removed
8+
-->
9+
10+
## `v0.4.0-rc1` _(July 23, 2025)_
11+
12+
- 🔒 **Security**: Fix command injection vulnerabilities in system calls
13+
- 🔒 **Security**: Use SecureRandom for socket paths instead of predictable object_id
14+
-**Feature**: Add configuration system with global defaults
15+
-**Feature**: Implement sudo -A flag support for graphical password prompts
16+
-**Feature**: Add Sudo.as_root convenience method for better DSL
17+
-**Feature**: Add configurable timeouts
18+
-**Feature**: Add respond_to_missing? for proper method reflection
19+
- 💥 **Breaking**: Minimum Ruby version bumped to 2.7+ (EOL compliance)
20+
- 🔧 **Internal**: Modernize Ruby code with keyword arguments and array-form system calls
21+
- 🔧 **Internal**: Improve test coverage and add configuration tests
22+
23+
<details>
24+
<summary>📜 Historical Releases</summary>
25+
326
## `v0.3.0` _(July 04, 2023)_
427

528
- 🚀 **Compatibility**: Add Ruby 3.2 support
@@ -37,3 +60,5 @@
3760
-**Feature**: Unix domain socket communication
3861
-**Feature**: Process spawning and management
3962
-**Feature**: Basic object proxying through sudo
63+
64+
</details>

README.md

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ sudo[MyClass].my_class_method
5353
sudo.stop!
5454
```
5555

56-
A convienient utility for working with sudo is to use the `run` method and pass it a block.
56+
A convenient utility for working with sudo is to use the `run` method and pass it a block.
5757
Run will automatically start and stop the ruby sudo process around the block.
5858

5959
```ruby
@@ -66,11 +66,72 @@ end
6666
# Sockets and processes are closed automatically when the block exits
6767
```
6868

69-
Both `Sudo::Wrapper.run` and `Sudo::Wrapper.new` take the same named arguments: `ruby_opts` (default: `''` ) and `load_gems` (default: `true`).
69+
Both `Sudo::Wrapper.run` and `Sudo::Wrapper.new` accept configuration options:
7070

71-
If you'd like to pass options to the sudo-spawned ruby process, pass them as a string to `ruby_opts`.
71+
- `ruby_opts` (default: `''`) - Options to pass to the sudo-spawned ruby process
72+
- Any configuration option can be passed to override global settings (e.g., `timeout`, `load_gems`, `socket_dir`, etc.)
7273

73-
If you'd like to prevent the loading of `gems` currently loaded from the calling program, pass `false` to `load_gems`. This will give your sudo process a unmodifed environment. The only things required via the sudo process are `'drb/drb'`, `'fileutils'`, and of course `'sudo'`.
74+
If you'd like to prevent the loading of `gems` currently loaded from the calling program, pass `load_gems: false`. This will give your sudo process an unmodified environment. The only things required via the sudo process are `'drb/drb'`, `'fileutils'`, and of course `'sudo'`.
75+
76+
### New DSL (v0.4.0+)
77+
78+
For simple operations, you can use the convenience method:
79+
80+
```ruby
81+
require 'sudo'
82+
83+
# Accepts the same options as Wrapper.run:
84+
Sudo.as_root(load_gems: false) do |sudo|
85+
sudo[FileUtils].mkdir_p '/root/only/path'
86+
sudo[File].write '/etc/config', content
87+
end
88+
```
89+
90+
### Configuration (v0.4.0+)
91+
92+
Configure global defaults:
93+
94+
```ruby
95+
Sudo.configure do |config|
96+
config.timeout = 30 # Default: 10 seconds
97+
config.socket_dir = '/var/run' # Default: '/tmp'
98+
config.sudo_askpass = '/usr/bin/ssh-askpass' # For graphical password prompts
99+
config.load_gems = false # Default: true - whether to load current gems in sudo process
100+
end
101+
```
102+
103+
### Graphical Password Prompts (v0.4.0+)
104+
105+
Set `sudo_askpass` to use graphical password prompts via `sudo -A`:
106+
107+
```ruby
108+
Sudo.configure do |config|
109+
config.sudo_askpass = '/usr/bin/ssh-askpass'
110+
# Or use the auto-detected constant for convenience:
111+
# config.sudo_askpass = Sudo::ASK_PATH_CMD
112+
end
113+
114+
# Or per-wrapper:
115+
Sudo::Wrapper.run(sudo_askpass: '/usr/bin/ssh-askpass') do |sudo|
116+
sudo[FileUtils].mkdir_p '/secure/path'
117+
end
118+
```
119+
120+
### Timeouts (v0.4.0+)
121+
122+
Configure connection timeouts:
123+
124+
```ruby
125+
# Global configuration
126+
Sudo.configure do |config|
127+
config.timeout = 15 # Wait up to 15 seconds for sudo process to start
128+
end
129+
130+
# Or per-wrapper
131+
Sudo::Wrapper.run(timeout: 5) do |sudo|
132+
sudo[SomeClass].time_sensitive_operation
133+
end
134+
```
74135

75136
## Credits
76137

@@ -88,7 +149,7 @@ Robert M. Koch ([@threadmetal](https://github.com/threadmetal))
88149

89150
Wolfgang Teuber ([@wteuber](https://github.com/wteuber))
90151

91-
### Other aknowledgements
152+
### Other acknowledgements
92153

93154

94155
Thanks to Tony Arcieri and Brian Candler for suggestions on

lib/sudo/constants.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require 'pathname'
22

33
module Sudo
4-
VERSION = '0.3.0'
4+
VERSION = '0.4.0'
55

66
def self.root
77
@root ||= Pathname.new(File.expand_path('../../', __dir__))

0 commit comments

Comments
 (0)