Skip to content

Commit b434d4d

Browse files
authored
Release 0.2.8 (#1232)
2 parents f052506 + 93c58cd commit b434d4d

File tree

14 files changed

+184
-33
lines changed

14 files changed

+184
-33
lines changed

CHANGELOG.md

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

3+
## [0.2.8] - 2025-08-04
4+
5+
### Added
6+
- `sudo -e`, `sudoedit` to safely edit files as another user.
7+
8+
### Fixed
9+
- `NOEXEC:` could not be used to prevent all shell escapes on multi-architecture
10+
installations (#1229)
11+
- `sudo --list` would not show `NOEXEC`, `SETENV` and `APPARMOR_PROFILE` (#1228)
12+
- Skip paths not accessible by the target user during command resolution (#1234)
13+
314
## [0.2.7] - 2025-07-01
415

516
### Added

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "sudo-rs"
33
description = "A memory safe implementation of sudo and su."
4-
version = "0.2.7"
4+
version = "0.2.8"
55
license = "Apache-2.0 OR MIT"
66
edition = "2021"
77
repository = "https://github.com/trifectatechfoundation/sudo-rs"

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ We currently only offer these for x86-64 systems.
5151
We recommend installing sudo-rs and su-rs in your `/usr/local` hierarchy so it can co-exist with
5252
your existing sudo installation. You can achieve this using the commands:
5353
```sh
54-
sudo tar -C /usr/local -xvf sudo-0.2.7.tar.gz
54+
sudo tar -C /usr/local -xvf sudo-0.2.8.tar.gz
5555
```
5656
and for su-rs:
5757
```sh
58-
sudo tar -C /usr/local -xvf su-0.2.7.tar.gz
58+
sudo tar -C /usr/local -xvf su-0.2.8.tar.gz
5959
```
6060
This will install sudo-rs and su-rs in `/usr/local/bin` using the usual commands `sudo` and `su`; it
6161
will also install our version of `visudo` in that location.
@@ -157,6 +157,7 @@ Exceptions to the above, with respect to your `/etc/sudoers` configuration:
157157
`match_group_by_gid` are not applicable to our implementation, but ignored for
158158
compatibility reasons.
159159
* `timestamp_type` is always set at `tty`.
160+
* `sudoedit_checkdir` is always `on`, and `sudoedit_follow` is always `off`.
160161

161162
Some other notable restrictions to be aware of:
162163

docs/man/su.1.man

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Automatically generated by Pandoc 3.6.3
22
.\"
3-
.TH "SU" "1" "" "sudo\-rs 0.2.7" "sudo\-rs"
3+
.TH "SU" "1" "" "sudo\-rs 0.2.8" "sudo\-rs"
44
.SH NAME
55
\f[CR]su\f[R] \- run a shell or command as another user
66
.SH SYNOPSIS

docs/man/su.1.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: SU(1) sudo-rs 0.2.7 | sudo-rs
2+
title: SU(1) sudo-rs 0.2.8 | sudo-rs
33
---
44

55
# NAME

docs/man/sudo.8.man

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
.\" Automatically generated by Pandoc 3.6.3
22
.\"
3-
.TH "SUDO" "8" "" "sudo\-rs 0.2.7" "sudo\-rs"
3+
.TH "SUDO" "8" "" "sudo\-rs 0.2.8" "sudo\-rs"
44
.SH NAME
5-
\f[CR]sudo\f[R] \- execute a command as another user
5+
\f[CR]sudo\f[R], \f[CR]sudoedit\f[R] \- execute a command as another
6+
user
67
.SH SYNOPSIS
7-
\f[CR]sudo\f[R] [\f[CR]\-u\f[R] \f[I]user\f[R]] [\f[CR]\-g\f[R]
8-
\f[I]group\f[R]] [\f[CR]\-D\f[R] \f[I]directory\f[R]]
8+
\f[CR]sudo\f[R] \f[CR]\-h\f[R] | \f[CR]\-K\f[R] | \f[CR]\-k\f[R] |
9+
\f[CR]\-V\f[R] \f[CR]sudo\f[R] [\f[CR]\-u\f[R] \f[I]user\f[R]]
10+
[\f[CR]\-g\f[R] \f[I]group\f[R]] [\f[CR]\-D\f[R] \f[I]directory\f[R]]
911
[\f[CR]\-BknS\f[R]] [\f[CR]\-i\f[R] | \f[CR]\-s\f[R]]
10-
[\f[CR]VAR=value\f[R]] [<\f[I]command\f[R]>]
11-
.PD 0
12-
.P
13-
.PD
14-
\f[CR]sudo\f[R] \f[CR]\-l\f[R] [\f[CR]\-BknS\f[R]] [\f[CR]\-U\f[R]
15-
\f[I]user\f[R]] [\f[CR]\-u\f[R] \f[I]user\f[R]] [\f[CR]\-g\f[R]
16-
\f[I]group\f[R]] [command [arg \&...]] \f[CR]sudo\f[R] \f[CR]\-h\f[R] |
17-
\f[CR]\-K\f[R] | \f[CR]\-k\f[R] | \f[CR]\-V\f[R]
12+
[\f[CR]VAR=value\f[R]] [<\f[I]command\f[R]>] \f[CR]sudo\f[R]
13+
\f[CR]\-v\f[R] [\f[CR]\-BknS\f[R]] [\f[CR]\-u\f[R] \f[I]user\f[R]]
14+
[\f[CR]\-g\f[R] \f[I]group\f[R]] \f[CR]sudo\f[R] \f[CR]\-l\f[R]
15+
[\f[CR]\-BknS\f[R]] [\f[CR]\-U\f[R] \f[I]user\f[R]] [\f[CR]\-u\f[R]
16+
\f[I]user\f[R]] [\f[CR]\-g\f[R] \f[I]group\f[R]] [command [arg \&...]]
17+
\f[CR]sudo\f[R] \f[CR]\-e\f[R] [\f[CR]\-BknS\f[R]] [\f[CR]\-u\f[R]
18+
\f[I]user\f[R]] [\f[CR]\-g\f[R] \f[I]group\f[R]] file \&...
19+
\f[CR]sudoedit\f[R] [\f[CR]\-BknS\f[R]] [\f[CR]\-u\f[R] \f[I]user\f[R]]
20+
[\f[CR]\-g\f[R] \f[I]group\f[R]] file \&...
1821
.SH DESCRIPTION
1922
\f[CR]sudo\f[R] allows a user that is permitted to do so to execute a
2023
\f[I]command\f[R] as another user (for example \f[I]root\f[R]).
@@ -31,6 +34,12 @@ The timeout for session records can be specified in the policy.
3134
.PP
3235
Some care is taken to pass signals received by sudo\-rs to the child
3336
process, even if that process runs in its own pseudo terminal.
37+
.PP
38+
On systems where sudo is the primary method of gaining superuser
39+
privileges, it is imperative to avoid syntax errors in the
40+
\f[CR]/etc/sudoers\f[R] file.
41+
Changes to this file should be made using the visudo(8) utility which
42+
will ensure that no syntax errors are introduced.
3443
.SH OPTIONS
3544
.TP
3645
\f[CR]\-B\f[R], \f[CR]\-\-bell\f[R]
@@ -121,6 +130,28 @@ If no shell was specified, the shell from the user\[cq]s password
121130
database entry will be used instead.
122131
If a \f[I]command\f[R] is specified, it is passed to the shell using the
123132
\f[CR]\-c\f[R] option.
133+
.PP
134+
\f[CR]\-e\f[R], \f[CR]sudoedit\f[R]
135+
.IP
136+
.EX
137+
Edit one or more files instead of running a command. In lieu of a path name, the string \[dq]sudoedit\[dq] is used when consulting the security policy. If the user is authorized by the policy, the following steps are taken:
138+
139+
1. Temporary copies are made of the files to be edited with the owner set to the invoking user.
140+
141+
2. The editor specified by the policy is run to edit the temporary files. The sudoers policy uses the SUDO_EDITOR, VISUAL and EDITOR environment variables (in that order). If none of SUDO_EDITOR, VISUAL or EDITOR are set, the first program listed in the editor sudoers(5) option is used.
142+
143+
3. If they have been modified, the content of the temporary files is copied back to the originals and the temporary versions are removed.
144+
145+
To help prevent the editing of unauthorized files, the following restrictions are enforced (unless the user is root):
146+
147+
* Symbolic links may not be edited.
148+
149+
* If any component of the path leading to the file is writable by the invoking user, the file may not be edited.
150+
151+
* Users are never allowed to edit device special files.
152+
153+
If the specified file does not exist, it will be created. Unlike most commands run by sudo, the editor is run with the invoking user\[aq]s environment unmodified. If the temporary file becomes empty after editing, the user will be prompted before it is installed.
154+
.EE
124155
.TP
125156
\f[CR]\-u\f[R] \f[I]user\f[R], \f[CR]\-\-user\f[R]=\f[I]user\f[R]
126157
Run the \f[I]command\f[R] as another user than the default

docs/man/sudo.8.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
---
2-
title: SUDO(8) sudo-rs 0.2.7 | sudo-rs
2+
title: SUDO(8) sudo-rs 0.2.8 | sudo-rs
33
---
44

55
# NAME
66

7-
`sudo` - execute a command as another user
7+
`sudo`, `sudoedit` - execute a command as another user
88

99
# SYNOPSIS
1010

11-
`sudo` [`-u` *user*] [`-g` *group*] [`-D` *directory*] [`-BknS`] [`-i` | `-s`] [`VAR=value`] [<*command*>] \
12-
`sudo` `-l` [`-BknS`] [`-U` *user*] [`-u` *user*] [`-g` *group*] [command [arg ...]]
1311
`sudo` `-h` | `-K` | `-k` | `-V`
12+
`sudo` [`-u` *user*] [`-g` *group*] [`-D` *directory*] [`-BknS`] [`-i` | `-s`] [`VAR=value`] [<*command*>]
13+
`sudo` `-v` [`-BknS`] [`-u` *user*] [`-g` *group*]
14+
`sudo` `-l` [`-BknS`] [`-U` *user*] [`-u` *user*] [`-g` *group*] [command [arg ...]]
15+
`sudo` `-e` [`-BknS`] [`-u` *user*] [`-g` *group*] file ...
16+
`sudoedit` [`-BknS`] [`-u` *user*] [`-g` *group*] file ...
17+
1418

1519
# DESCRIPTION
1620

@@ -28,6 +32,11 @@ timeout for session records can be specified in the policy.
2832
Some care is taken to pass signals received by sudo-rs to the child process,
2933
even if that process runs in its own pseudo terminal.
3034

35+
On systems where sudo is the primary method of gaining superuser privileges, it is
36+
imperative to avoid syntax errors in the `/etc/sudoers` file. Changes to this file
37+
should be made using the visudo(8) utility which will ensure that no syntax errors
38+
are introduced.
39+
3140
# OPTIONS
3241

3342
`-B`, `--bell`
@@ -101,6 +110,26 @@ even if that process runs in its own pseudo terminal.
101110
was specified, the shell from the user's password database entry will be
102111
used instead. If a *command* is specified, it is passed to the shell using the `-c` option.
103112

113+
`-e`, `sudoedit`
114+
115+
Edit one or more files instead of running a command. In lieu of a path name, the string "sudoedit" is used when consulting the security policy. If the user is authorized by the policy, the following steps are taken:
116+
117+
1. Temporary copies are made of the files to be edited with the owner set to the invoking user.
118+
119+
2. The editor specified by the policy is run to edit the temporary files. The sudoers policy uses the SUDO_EDITOR, VISUAL and EDITOR environment variables (in that order). If none of SUDO_EDITOR, VISUAL or EDITOR are set, the first program listed in the editor sudoers(5) option is used.
120+
121+
3. If they have been modified, the content of the temporary files is copied back to the originals and the temporary versions are removed.
122+
123+
To help prevent the editing of unauthorized files, the following restrictions are enforced (unless the user is root):
124+
125+
* Symbolic links may not be edited.
126+
127+
* If any component of the path leading to the file is writable by the invoking user, the file may not be edited.
128+
129+
* Users are never allowed to edit device special files.
130+
131+
If the specified file does not exist, it will be created. Unlike most commands run by sudo, the editor is run with the invoking user's environment unmodified. If the temporary file becomes empty after editing, the user will be prompted before it is installed.
132+
104133
`-u` *user*, `--user`=*user*
105134
: Run the *command* as another user than the default (**root**).
106135

docs/man/sudoers.5.man

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Again, the value of an item may be negated with the `!' operator.
252252
\[aq]!\[aq]* directory |
253253
\[aq]!\[aq]* Cmnd_Alias
254254
\[aq]!\[aq]* \[dq]list\[dq]
255-
\[aq]!\[aq]* \[dq]sudoedit\[dq]
255+
\[aq]!\[aq]* \[dq]sudoedit\[dq] [file name]
256256
.EE
257257
.PP
258258
A Cmnd_List is a list of one or more command names, directories, and
@@ -292,9 +292,17 @@ option.
292292
No command line arguments may be specified with the \[lq]list\[rq]
293293
built\-in.
294294
.PP
295-
The \[lq]sudoedit\[rq] built\-in will be used in the future to permit a
296-
user to run sudo with the \-e option (or as sudoedit).
297-
This feature is currently under development.
295+
The \[lq]sudoedit\[rq] built\-in is used to permit a user to run sudo
296+
with the \-e option (or as sudoedit).
297+
It may take command line arguments just as a normal command does.
298+
Unlike other commands, \[lq]sudoedit\[rq] is built into sudo itself and
299+
must be specified in the sudoers file without a leading path.
300+
If a leading path is present, for example /usr/bin/sudoedit, this will
301+
not give the user permissions to use sudoedit.
302+
If no arguments are provided, \[lq]sudoedit\[rq] will give the user the
303+
permission to edit any files; if an argument is present it must be an
304+
absolute path name that does not contain symbolic links, or the command
305+
will not be matched.
298306
.SS Defaults
299307
Certain configuration options may be changed from their default values
300308
at run\-time via one or more Default_Entry lines.
@@ -784,6 +792,18 @@ passwd database as an argument to the \-u option.
784792
This flag is off by default.
785793
.RE
786794
.IP \[bu] 2
795+
umask_override
796+
.RS 2
797+
.PP
798+
If set, sudo will set the umask as specified in the sudoers file without
799+
modification.
800+
This makes it possible to specify a umask in the sudoers file that is
801+
more permissive than the user\[cq]s own umask.
802+
If umask_override is not set, sudo will set the umask to be the union of
803+
the user\[cq]s umask and what is specified in sudoers.
804+
This flag is off by default.
805+
.RE
806+
.IP \[bu] 2
787807
use_pty
788808
.RS 2
789809
.PP
@@ -821,6 +841,43 @@ insufficient, for example 2.5.
821841
The default is 15.
822842
Set this to 0 to always prompt for a password.
823843
.RE
844+
.IP \[bu] 2
845+
umask
846+
.RS 2
847+
.PP
848+
File mode creation mask to use when running the command.
849+
Negate this option or set it to 0777 to prevent sudo from changing the
850+
umask.
851+
Unless the umask_override flag is set, the actual umask will be the
852+
union of the user\[cq]s umask and the value of the umask setting, which
853+
defaults to 0022.
854+
This guarantees that sudo never lowers the umask when running a command.
855+
.PP
856+
If umask is explicitly set, it will override any umask setting in PAM.
857+
If umask is not set, the umask specified by PAM will take precedence.
858+
The umask setting in PAM is not used for sudoedit, which does not create
859+
a new PAM session.
860+
.RE
861+
.SS Strings
862+
.IP \[bu] 2
863+
editor
864+
.RS 2
865+
.PP
866+
A colon (`:') separated list of editor path names used by
867+
\f[B]sudoedit\f[R] and \f[B]visudo\f[R].
868+
For \f[B]sudoedit\f[R], this list is used to find an editor when none of
869+
the SUDO_EDITOR, VISUAL or EDITOR environment variables are set to an
870+
editor that exists and is executable.
871+
For \f[B]visudo\f[R], it is used as a white list of allowed editors;
872+
\f[B]visudo\f[R] will choose the editor that matches the user\[cq]s
873+
SUDO_EDITOR, VISUAL or EDITOR environment variable if possible, or the
874+
first editor in the list that exists and is executable if not.
875+
Unless invoked as \f[B]sudoedit\f[R], sudo does not preserve the
876+
SUDO_EDITOR, VISUAL or EDITOR environment variables unless they are
877+
present in the \f[B]env_keep\f[R] list.
878+
The default on Linux is \f[I]/usr/bin/editor\f[R], on FreeBSD
879+
\f[I]/usr/vim/vi\f[R].
880+
.RE
824881
.SS Strings that can be used in a boolean context:
825882
.IP \[bu] 2
826883
apparmor_profile
@@ -899,6 +956,9 @@ Preserving the HOME environment variable has security implications since
899956
many programs use it when searching for configuration or data files.
900957
Adding HOME to env_keep may enable a user to run unrestricted commands
901958
via sudo and is strongly discouraged.
959+
Users wishing to edit files with sudo should run \f[B]sudoedit\f[R] (or
960+
\f[B]sudo \-e\f[R]) to get their accustomed editor configuration instead
961+
of invoking the editor directly.
902962
.RE
903963
.SS LOG FORMAT
904964
sudo\-rs logs events via syslog(3).
@@ -980,6 +1040,8 @@ against future syscalls that can do an exec() like the proposed
9801040
And it also doesn\[cq]t protect against honest programs that
9811041
intentionally or not allow the user to write to /proc/self/mem for the
9821042
same reasons as that it doesn\[cq]t protect against malicious programs.
1043+
You should always try out if \f[B]noexec\f[R] indeed prevents shell
1044+
escapes for the programs it is intended to be used with.
9831045
.SS Timestamp file checks
9841046
sudo\-rs will check the ownership of its timestamp directory
9851047
(/run/sudo/ts by default) and ignore the directory\[cq]s contents if it

0 commit comments

Comments
 (0)