Skip to content

Commit bfcdf44

Browse files
Add installation instructions for translation files
1 parent 4e94180 commit bfcdf44

3 files changed

Lines changed: 69 additions & 13 deletions

File tree

Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ PAM_SRC_DIR = src/pam
33
BINDGEN_CMD = bindgen --allowlist-function '^pam_.*$$' --allowlist-var '^PAM_.*$$' --opaque-type pam_handle_t --blocklist-function pam_vsyslog --blocklist-function pam_vprompt --blocklist-function pam_vinfo --blocklist-function pam_verror --blocklist-type '.*va_list.*' --ctypes-prefix std::ffi --no-layout-tests --sort-semantically
44

55
PAM_VARIANT = $$(./util/get-pam-variant.bash)
6+
MSGFMT ?= msgfmt
7+
LOCALEDIR ?= /usr/share/locale
68

7-
.PHONY: all clean pam-sys pam-sys-diff
9+
.PHONY: all clean install-mo pam-sys pam-sys-diff
810

911
pam-sys-diff:
1012
@$(BINDGEN_CMD) $(PAM_SRC_DIR)/wrapper.h | \
@@ -20,5 +22,13 @@ pam-sys:
2022
sed -i.bak 's/rust-bindgen [0-9]*\.[0-9]*\.[0-9]*/&, minified by cargo-minify/' $(PAM_SRC_DIR)/sys_$(PAM_VARIANT).rs
2123
rm $(PAM_SRC_DIR)/sys_$(PAM_VARIANT).rs.bak
2224

25+
install-mo:
26+
for file in po/*.po; do \
27+
lang=$${file##*/}; \
28+
lang=$${lang%.po}; \
29+
mkdir -p "$(LOCALEDIR)/$$lang/LC_MESSAGES"; \
30+
$(MSGFMT) --check -o "$(LOCALEDIR)/$$lang/LC_MESSAGES/sudo-rs.mo" "$$file"; \
31+
done
32+
2333
clean:
2434
rm $(PAM_SRC_DIR)/sys.rs

README.md

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,45 @@ To avoid that and/or to get the latest version, you can use our prepackaged bina
2626
### Ubuntu 25.10 (Questing Quokka)
2727

2828
sudo-rs is installed and enabled by default; you can control which sudo version is being used by running
29+
2930
```sh
3031
update-alternatives --config sudo
3132
```
33+
3234
The sudo-rs package is based on v0.2.8 with additional bug fixes that will be part of v0.2.9.
3335

3436
### Arch Linux
3537

3638
sudo-rs can be installed from the distribution repositories:
39+
3740
```sh
3841
pacman -S sudo-rs
3942
```
43+
4044
This will offer the functionality using the commands `sudo-rs`, `sudoedit-rs`, `visudo-rs` and `su-rs` to avoid conflicts.
4145

4246
The sudo-rs package on Arch Linux is typically up-to-date.
4347

4448
### Fedora
4549

4650
On Fedora you can use:
51+
4752
```sh
4853
dnf install sudo-rs
4954
```
55+
5056
This will offer the functionality using the commands `sudo-rs`, `visudo-rs` and `su-rs` to avoid conflicts.
5157

5258
The version packaged in Fedora is usually the latest.
5359

5460
### Debian
61+
5562
If you are running Debian 13 (trixie) or later you can use:
63+
5664
```sh
5765
apt-get install sudo-rs
5866
```
67+
5968
This will offer the functionality using the commands `sudo-rs`, `visudo-rs`. If you want to invoke sudo-rs
6069
via the usual commands `sudo` and `visudo` instead, prepend `/usr/lib/cargo/bin` to your current `$PATH` variable.
6170

@@ -68,16 +77,20 @@ Debian unstable (sid) may have a newer version.
6877
### FreeBSD
6978

7079
We are maintaining the FreeBSD port of sudo-rs ourselves, which is available in the ports tree. Sudo-rs is available in two flavours:
71-
```
80+
81+
```sh
7282
pkg install sudo-rs
7383
```
84+
7485
To get sudo-rs using the commands `sudo`, `visudo` and `sudoedit`. This conflicts with the `security/sudo` package and so you cannot have both
7586
installed at the same time.
7687

7788
Alternatively,
78-
```
89+
90+
```sh
7991
pkg install sudo-rs-coexist
8092
```
93+
8194
Installs the commands as `sudo-rs`, `visudo-rs`' and `sudoedit-rs` and does not conflict with the `security/sudo` package.
8295

8396
To run these commands, the `pkg` utility needs to be using the `2025Q4` quarterly version (or later) of the ports tree. To use the
@@ -100,13 +113,17 @@ We currently only offer these for x86-64 Linux systems.
100113

101114
We recommend installing sudo-rs and su-rs in your `/usr/local` hierarchy so it does not affect the integrity of the package
102115
manager of your Linux distribution. You can achieve this using the commands:
116+
103117
```sh
104118
sudo tar -C /usr/local -xvf sudo-0.2.13.tar.gz
105119
```
120+
106121
and for su-rs:
122+
107123
```sh
108124
sudo tar -C /usr/local -xvf su-0.2.13.tar.gz
109125
```
126+
110127
This will install sudo-rs and su-rs in `/usr/local/bin` using the usual commands `sudo`, `visudo`, `sudoedit` and `su`. Please double check
111128
that in your default `PATH`, the folders `/usr/local/bin` and `/usr/local/sbin` have priority over `/usr/bin` and `/usr/sbin`.
112129

@@ -140,20 +157,25 @@ If you **don't** have Todd Miller's `sudo` installed, you also have to make sure
140157
Sudo-rs is written in Rust. The minimum required Rust version is 1.85. If your
141158
Linux distribution does not package that version (or a later one), you can always
142159
install the most recent version through [rustup]. You also need the C development
143-
files for PAM (`libpam0g-dev` on Debian, `pam-devel` on Fedora).
160+
files for PAM (`libpam0g-dev` on Debian, `pam-devel` on Fedora). If you want to
161+
install translated messages, you also need gettext tools for `msgfmt` (`gettext`
162+
on Debian and Ubuntu).
144163

145164
On Ubuntu or Debian-based systems, use the following command to install the PAM development library:
146-
```
165+
166+
```sh
147167
sudo apt-get install libpam0g-dev
148168
```
149169

150170
On Fedora, CentOS and other Red Hat-based systems, you can use the following command:
151-
```
171+
172+
```sh
152173
sudo yum install pam-devel
153174
```
154175

155176
With dependencies installed, building sudo-rs is a simple matter of:
156-
```
177+
178+
```sh
157179
cargo build --release
158180
```
159181

@@ -167,25 +189,49 @@ suggestions in the previous section.
167189
### Feature flags
168190

169191
#### --features pam-login
192+
170193
By default, sudo-rs will use the PAM service name `sudo`. On Debian and Fedora
171194
systems, it is customary that the name `sudo-i` is used when the `-i / --login`
172195
command line option is used. To get this behaviour, enable the `pam-login`
173196
feature when building:
174-
```
197+
198+
```sh
175199
cargo build --release --features pam-login
176200
```
201+
177202
This feature is enabled on our pre-supplied binaries.
178203

179204
#### --features apparmor
205+
180206
sudo-rs has support for selecting AppArmor profile on Linux distributions that
181207
support AppArmor such as Debian and Ubuntu. To enable this feature, build sudo-rs
182208
with apparmor support enabled:
183-
```
209+
210+
```sh
184211
cargo build --release --features apparmor
185212
```
186213

187214
This feature is disabled on our pre-supplied binaries.
188215

216+
#### --features gettext
217+
218+
sudo-rs has support for translated user-facing messages. To enable this feature,
219+
build sudo-rs with gettext support enabled:
220+
221+
```sh
222+
cargo build --release --features gettext
223+
```
224+
225+
You can install the translation files from `po/*.po` using:
226+
227+
```sh
228+
sudo make install-mo
229+
```
230+
231+
This uses `msgfmt` to compile each `<lang>.po` file to
232+
`/usr/share/locale/<lang>/LC_MESSAGES/sudo-rs.mo`. If needed, you can override
233+
the install location by setting `LOCALEDIR` when invoking `make`.
234+
189235
[rustup]: https://rustup.rs/
190236

191237
## Differences from original sudo
@@ -270,4 +316,4 @@ Sudo-rs is an independent implementation, but it incorporates documentation and
270316

271317
An independent security audit of sudo-rs was made possible by the [NLNet Foundation](https://nlnet.nl/), who also [sponsored](https://nlnet.nl/project/sudo-rs/) work on increased compatibility with the original sudo and the FreeBSD port.
272318

273-
The sudo-rs project would not have existed without the support of its sponsors, a full overview is maintained at https://trifectatech.org/initiatives/privilege-boundary/
319+
The sudo-rs project would not have existed without the support of its sponsors, a full overview is maintained at <https://trifectatech.org/initiatives/privilege-boundary/>

src/sudoers/policy.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ impl Judgement {
147147
}
148148

149149
pub(crate) fn preferred_editor(&self) -> (PathBuf, Vec<OsString>) {
150-
//if no editor could be selected, fall back to /bin/vi;
151-
//note that /bin/vi is also likely to have been tried as part of
152-
//the "editor" setting, so this is a last-resort
150+
// if no editor could be selected, fall back to /bin/vi;
151+
// note that /bin/vi is also likely to have been tried as part of
152+
// the "editor" setting, so this is a last-resort
153153
super::select_editor(&self.settings, true)
154154
.unwrap_or_else(|| (std::path::PathBuf::from("/usr/bin/vi"), vec![]))
155155
}

0 commit comments

Comments
 (0)