mirror of
https://github.com/apognu/tuigreet.git
synced 2024-09-11 07:25:29 +03:00
Added a test and changed README.
This commit is contained in:
parent
e27705b40f
commit
9712edfc35
6
.github/workflows/dev.yml
vendored
6
.github/workflows/dev.yml
vendored
@ -22,10 +22,16 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- run: |
|
||||
sudo apt update && sudo apt install -y libnss-wrapper
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Test
|
||||
env:
|
||||
NSS_WRAPPER_PASSWD: contrib/fixtures/passwd
|
||||
NSS_WRAPPER_GROUP: contrib/fixtures/group
|
||||
run: |
|
||||
cargo test
|
||||
LD_PRELOAD=libnss_wrapper.so cargo test --features nsswrapper nsswrapper_
|
||||
|
||||
build:
|
||||
strategy:
|
||||
|
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@ -22,10 +22,16 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- run: |
|
||||
sudo apt update && sudo apt install -y libnss-wrapper
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Test
|
||||
env:
|
||||
NSS_WRAPPER_PASSWD: contrib/fixtures/passwd
|
||||
NSS_WRAPPER_GROUP: contrib/fixtures/group
|
||||
run: |
|
||||
cargo test
|
||||
LD_PRELOAD=libnss_wrapper.so cargo test --features nsswrapper nsswrapper_
|
||||
|
||||
build:
|
||||
strategy:
|
||||
|
6
.github/workflows/tip.yml
vendored
6
.github/workflows/tip.yml
vendored
@ -22,10 +22,16 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- run: |
|
||||
sudo apt update && sudo apt install -y libnss-wrapper
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- name: Test
|
||||
env:
|
||||
NSS_WRAPPER_PASSWD: contrib/fixtures/passwd
|
||||
NSS_WRAPPER_GROUP: contrib/fixtures/group
|
||||
run: |
|
||||
cargo test
|
||||
LD_PRELOAD=libnss_wrapper.so cargo test --features nsswrapper nsswrapper_
|
||||
|
||||
build:
|
||||
strategy:
|
||||
|
@ -5,6 +5,10 @@ authors = ["Antoine POPINEAU <antoine.popineau@appscho.com>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
nsswrapper = []
|
||||
|
||||
[dependencies]
|
||||
chrono = { version = "^0.4", features = ["unstable-locales"] }
|
||||
crossterm = { version = "^0.27", features = ["event-stream"] }
|
||||
|
@ -195,7 +195,7 @@ Note that, by default, all commands are prefixed with `setsid` to completely det
|
||||
|
||||
### User menu
|
||||
|
||||
Optionally, a user can be selected from a menu instead of typing out their name, with the `--user-menu` option, this will present all users present in `/etc/passwd` at the time `tuigreet` was run, with a UID within the acceptable range. The values for the minimum and maximum UIDs are selected as follows, for each value:
|
||||
Optionally, a user can be selected from a menu instead of typing out their name, with the `--user-menu` option, this will present all users returned by NSS at the time `tuigreet` was run, with a UID within the acceptable range. The values for the minimum and maximum UIDs are selected as follows, for each value:
|
||||
|
||||
* A user-provided value, through `--user-menu-min-uid` or `--user-menu-max-uid`;
|
||||
* **Or**, the available values for `UID_MIN` or `UID_MAX` from `/etc/login.defs`;
|
||||
|
0
contrib/fixtures/group
Normal file
0
contrib/fixtures/group
Normal file
4
contrib/fixtures/passwd
Normal file
4
contrib/fixtures/passwd
Normal file
@ -0,0 +1,4 @@
|
||||
root:x:0:0::/root:/bin/bash
|
||||
joe:x:1000:1000:Joe:/home/joe:/bin/bash
|
||||
bob:x:1500:1500::/home/bob:/bin/zsh
|
||||
postgres:x:2100:2100::/srv/postgresql:/usr/bin/nologin
|
@ -377,7 +377,7 @@ impl Greeter {
|
||||
}
|
||||
|
||||
// Parses command line arguments to configured the software accordingly.
|
||||
async fn parse_options(&mut self) {
|
||||
pub async fn parse_options(&mut self) {
|
||||
let opts = Greeter::options();
|
||||
|
||||
self.config = match opts.parse(env::args().collect::<Vec<String>>()) {
|
||||
|
17
src/info.rs
17
src/info.rs
@ -256,3 +256,20 @@ pub fn capslock_status() -> bool {
|
||||
Err(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "nsswrapper")]
|
||||
#[cfg(test)]
|
||||
mod nsswrapper_tests {
|
||||
#[test]
|
||||
fn nsswrapper_get_users_from_nss() {
|
||||
use super::get_users;
|
||||
|
||||
let users = get_users(1000, 2000);
|
||||
|
||||
assert_eq!(users.len(), 2);
|
||||
assert_eq!(users[0].username, "joe");
|
||||
assert_eq!(users[0].name, Some("Joe".to_string()));
|
||||
assert_eq!(users[1].username, "bob");
|
||||
assert_eq!(users[1].name, None);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user