Giter Site home page Giter Site logo

whoami's Introduction

WhoAmI Logo

tests GitHub commit activity GitHub contributors
Crates.io Crates.io Crates.io (recent)
Crates.io Docs.rs

Retrieve the current user and environment through simple functions.

Check out the documentation for examples.

Features

  • Get the user's full name
  • Get the user's username
  • Get the user's preferred language(s)
  • Get the devices's hostname
  • Get the devices's "pretty" or "fancy" name
  • Get the devices's desktop environment
  • Get the devices's OS name and version
  • Get the devices's platform name
  • Get the devices's CPU architecture and its width

Supported Platforms

WhoAmI targets all platforms that can run Rust, including:

  • Linux
  • Windows
  • Mac OS
  • BSD variants (FreeBSD, others)
  • illumos variants (SmartOS, OmniOS, others) Target-Specific MSRV 1.65
  • Redox Target-Specific MSRV 1.65
  • Web Assembly
    • Fake implementation
    • Web Browser - DOM
    • WASI (Wasite, others) untested, testing planned later
    • Daku (Ardaku/Quantii, others) planned later
  • Android planned later
  • iOS / watchOS / tvOS planned later
  • Fuchsia planned later
  • Others? (make a PR or open an issue)

MSRV

WhoAmI 1.x.y targets Rust 1.40.0 stable and later, and the 1.x.y track will be maintained at least until the release of the Rust 2024 edition.

The MSRV will not be updated until version 2.0.0, after which breaking changes may happen on minor releases, and version 2.0.0 will target Rust 1.65.0 and later to make use of the let else syntax. The current plan is for all 2.x releases to be supported and receive bugfixes at least until sometime in 2027, bumping MSRV only as needed.

Binary

whome: whoami command RiR (Re-written in Rust) that depends on this crate.

Testing

The testing procedure is documented at https://github.com/ardaku/whoami/blob/v1/TESTING.md. The full manual test suite is run for each change that affects multiple platforms.

License

Copyright ยฉ 2017-2024 The WhoAmI Contributors.

Licensed under any of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as described above, without any additional terms or conditions.

Help

If you want help using or contributing to this library, feel free to send me an email at [email protected].

whoami's People

Contributors

9999years avatar adeschamps avatar aldaronlau avatar bardo avatar cygnus9 avatar dependabot-preview[bot] avatar dependabot[bot] avatar kiilerix avatar martinvonz avatar schaefer-dev avatar sondr3 avatar sphw avatar stevelauc avatar vlad-shcherbina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

whoami's Issues

Improved Language Detection

  • Detect priority list of languages on unix-like systems with the LANGUAGE environment variable.
  • Check LC_ALL, before checking LANG for primary language.

Call For Additional Maintainers

I think it would be generally good to have at least one additional maintainer on this crate to not only increase the bus factor, but lessen the amount of work I need to do to maintain this crate. Originally, whoami was added to https://github.com/rust-bus in case I got ran over by a bus, but now that's gone.

I think ideally additional maintainers would have one of the following qualifications:

  • have collaborated on any software project with me
  • depend on multiple features of whoami in another project they develop
  • depend on whoami in a larger project

There are a few different pieces I could use help with:

  • Q/A testing around releases
  • Issue response / PR review
  • 2.0 development / preparation

I can also continue doing any of them, if other maintainers are uninterested.

Consider allowing newer versions of wasm dependencies

In #38 you constrained the allowed versions for wasm-bindgen:

 [target.'cfg(target_arch = "wasm32")'.dependencies.wasm-bindgen]
-version = "0.2"
+version = ">= 0.2, <= 0.2.78"

However, this means that all transitive downstream dependencies are no longer allowed to depend on newer wasm-bindgen, which seems like a bad idea. If you want to test support for older MSRVs, it's probably worth downgrading your wasm-bindgen versions explicitly in the CI job instead of constraining the upper allowed version.

For example, I ran into this because I'd like to use chrono 0.4.22 (the latest version). I happen to have a transitive dependency on whoami through sqlx-core, which I wasn't aware of before today. Therefore, Cargo silently downgraded my chrono dependency as I pulled in, since chrono depends on iana-time-zone, which recently started depending on wasm-bindgen and (reasonably) requires the current version at the time (0.2.81).

This is an issue in particular for wasm-bindgen, because it is set up to be treated as a native library, which means only one version is allowed to be linked. Here's the error I get when I try to force usage of chrono 0.4.22:

error: failed to select a version for `wasm-bindgen`.
    ... required by package `whoami v1.2.2`
    ... which satisfies dependency `whoami = "^1.2.2"` of package `test-rs v0.1.0 (/Users/djc/src/test-rs)`
versions that meet the requirements `>=0.2, <=0.2.78` are: 0.2.78, 0.2.77, 0.2.76, 0.2.75, 0.2.74, 0.2.73, 0.2.72, 0.2.71, 0.2.70, 0.2.69, 0.2.68, 0.2.67, 0.2.66, 0.2.65, 0.2.64, 0.2.63, 0.2.62, 0.2.61, 0.2.60, 0.2.59, 0.2.58, 0.2.57, 0.2.56, 0.2.55, 0.2.54, 0.2.53, 0.2.52, 0.2.51, 0.2.50, 0.2.49, 0.2.48, 0.2.47, 0.2.46, 0.2.45, 0.2.44, 0.2.43, 0.2.42, 0.2.41, 0.2.40, 0.2.39, 0.2.38, 0.2.37, 0.2.36, 0.2.35, 0.2.34, 0.2.33, 0.2.32, 0.2.31, 0.2.30, 0.2.29, 0.2.28, 0.2.27, 0.2.26, 0.2.25, 0.2.24, 0.2.23, 0.2.22, 0.2.21, 0.2.20, 0.2.19, 0.2.18, 0.2.17, 0.2.16, 0.2.15, 0.2.14, 0.2.13, 0.2.12, 0.2.11, 0.2.10, 0.2.9, 0.2.8, 0.2.7, 0.2.6, 0.2.5, 0.2.4, 0.2.3, 0.2.2, 0.2.1, 0.2.0

the package `wasm-bindgen` links to the native library `wasm_bindgen`, but it conflicts with a previous package which links to `wasm_bindgen` as well:
package `wasm-bindgen-shared v0.2.81`
    ... which satisfies dependency `wasm-bindgen-shared = "=0.2.81"` of package `wasm-bindgen-backend v0.2.81`
    ... which satisfies dependency `wasm-bindgen-backend = "=0.2.81"` of package `wasm-bindgen-macro-support v0.2.81`
    ... which satisfies dependency `wasm-bindgen-macro-support = "=0.2.81"` of package `wasm-bindgen-macro v0.2.81`
    ... which satisfies dependency `wasm-bindgen-macro = "=0.2.81"` of package `wasm-bindgen v0.2.81`
    ... which satisfies dependency `wasm-bindgen = "^0.2.81"` of package `iana-time-zone v0.1.45`
    ... which satisfies dependency `iana-time-zone = "^0.1.44"` of package `chrono v0.4.22`
    ... which satisfies dependency `chrono = "^0.4.22"` of package `test-rs v0.1.0 (/Users/djc/src/test-rs)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the links ='wasm-bindgen' value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

all possible versions conflict with previously selected packages.

  previously selected package `wasm-bindgen v0.2.81`
    ... which satisfies dependency `wasm-bindgen = "^0.2.81"` of package `iana-time-zone v0.1.45`
    ... which satisfies dependency `iana-time-zone = "^0.1.44"` of package `chrono v0.4.22`
    ... which satisfies dependency `chrono = "^0.4.22"` of package `test-rs v0.1.0 (/Users/djc/src/test-rs)`

failed to select a version for `wasm-bindgen` which could resolve this conflict

So I would like to request you reconsider how you support older MSRVs.

Whoami Languages From Within Toolbox

Describe the bug
Running the toolbox command and calling lang() returns ["C", "C"], this is incorrect for a couple reasons:

  1. Should be able to find that it's English (or other language)
  2. Shouldn't return duplicate entries

To Reproduce
Steps to reproduce the behavior:

  1. Launch toolbox
  2. Run whoami-demo example

Expected behavior
Should print out non-duplicated language strings.

Desktop (please complete the following information):

  • OS: Fedora 37 (Silverblue)

Language Handling

Currently, on Unix-like platforms for English speakers in the US, something along the lines of ["en-US", "en"] will be reported by lang(). On Windows, just ["en-US"] will be reported. How should language fallbacks be expected to be handled? It would be nice to have some kind of consistency here.

Xcode 13.2.1 import fails at build: `Undefined symbols for architecture x86_64`

Hello,
I found a bug at the import in Xcode.
Any idea?

Describe the bug
Fail to import the lib in Xcode 13.2.1, as part of a backend Rust library used by a MacOS app.
whoami::devicename() throws:

Undefined symbols for architecture x86_64:
  "_SCDynamicStoreCopyComputerName", referenced from:
      whoami::unix::devicename_os::a41b3da222bd09bd0 in redacted.a(whoami-b71e222d3f2cfa22.whoami.25222f57-cgu.0.rcgu.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

To Reproduce
Steps to reproduce the behavior:

  1. import the crate to a Rust library
  2. Export the Rust library through cargo build --lib --release --all-targets
  3. Import the library.a file in XCode (TARGETS > MacOS > General > Frameworks, Libraries, and Embedded Content)
  4. The build fails with the output code above.

Expected behavior
No build failure

Versions

  • MacOS 12.1
  • Xcode 13.2.1
  • Rust edition = "2021"
  • whoami = "1.2.1"

Other template sections not relevant

Update WASM (Web) Example

The example showing how to use whoami in the web browser uses wee_alloc, which is completely unnecessary. It also doesn't need to depend on wasm-pack.

Make platform-specific functions return `io::Result`, and fallback values in lib.rs

Currently, if a platform-specific function fails then it will return "Unknown", "unknown", or "localhost" depending on the function. This functionality should be moved to lib.rs where the platform-independent functions are.

If we do this, then it makes it possible to add a fallible API. It will also improve the organization of the code and reduce duplication.

Required for #64

Create 2.0.0 Pre-release

Eventually, there will need to be some breaking changes, including bumping the MSRV to 1.65 / upgrade to the 2021 edition. My current plan is to have several pre-releases of 2.0.0 before stabilization, for some pre-testing (since it's planned as a LTS release, with support until at least the release of the 2027 edition). The 2.0 pre-release track will likely be it's own non-default branch before being merged (for 2.0.0 release), after which possibly 1.0 track will become it's own branch and receive any critical patches.

Perhaps we should bump our MSRV

I am running into this error:

$ cargo metadata
warning: please specify `--format-version` flag explicitly to avoid compatibility problems
error: failed to download `bumpalo v3.11.1`

Caused by:
  unable to get packages from source

Caused by:
  failed to download replaced source registry `https://github.com/rust-lang/crates.io-index`

Caused by:
  failed to parse manifest at `/home/steve/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/bumpalo-3.11.1/Cargo.toml`

Caused by:
  failed to parse the `edition` key

Caused by:
  supported edition values are `2015` or `2018`, but `2021` is unknown

$ rg "bumpalo"
Cargo.toml
31:[target.'cfg(target_arch = "wasm32")'.dependencies.bumpalo]

This is because bumpalo bumps their MSRV to 1.56, so perhaps we should also bump our MSRV.

Since whoami won't bump MSRV until a major version update, an alternative approach is to use an older version of bumpalo.

Cannot compile version 0.6.0

I get the following error when I try to compile crate from crates.io with rustc 1.34.2 (6c2484dc3 2019-05-13).

error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
  --> /home/chavdar/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/whoami-0.6.0/src/unix.rs:60:22
   |
60 |     let mut buffer = mem::MaybeUninit::<[u8; BUF_SIZE]>::uninit();
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
  --> /home/chavdar/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/whoami-0.6.0/src/unix.rs:61:22
   |
61 |     let mut passwd = mem::MaybeUninit::<PassWd>::uninit();
   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
  --> /home/chavdar/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/whoami-0.6.0/src/unix.rs:62:23
   |
62 |     let mut _passwd = mem::MaybeUninit::<*mut PassWd>::uninit();
   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0658]: use of unstable library feature 'maybe_uninit' (see issue #53491)
   --> /home/chavdar/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/whoami-0.6.0/src/unix.rs:157:22
    |
157 |     let mut string = mem::MaybeUninit::<[u8; 256]>::uninit();
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: no function or associated item named `uninit` found for type `std::mem::MaybeUninit<[u8; 16384]>` in the current scope
  --> /home/chavdar/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/whoami-0.6.0/src/unix.rs:60:58
   |
60 |     let mut buffer = mem::MaybeUninit::<[u8; BUF_SIZE]>::uninit();
   |                      ------------------------------------^^^^^^
   |                      |
   |                      function or associated item not found in `std::mem::MaybeUninit<[u8; 16384]>`

error[E0599]: no function or associated item named `uninit` found for type `std::mem::MaybeUninit<unix::PassWd>` in the current scope
  --> /home/chavdar/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/whoami-0.6.0/src/unix.rs:61:50
   |
61 |     let mut passwd = mem::MaybeUninit::<PassWd>::uninit();
   |                      ----------------------------^^^^^^
   |                      |
   |                      function or associated item not found in `std::mem::MaybeUninit<unix::PassWd>`

error[E0599]: no function or associated item named `uninit` found for type `std::mem::MaybeUninit<*mut unix::PassWd>` in the current scope
  --> /home/chavdar/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/whoami-0.6.0/src/unix.rs:62:56
   |
62 |     let mut _passwd = mem::MaybeUninit::<*mut PassWd>::uninit();
   |                       ---------------------------------^^^^^^
   |                       |
   |                       function or associated item not found in `std::mem::MaybeUninit<*mut unix::PassWd>`

error[E0599]: no function or associated item named `uninit` found for type `std::mem::MaybeUninit<[u8; 256]>` in the current scope
   --> /home/chavdar/.local/share/cargo/registry/src/github.com-1ecc6299db9ec823/whoami-0.6.0/src/unix.rs:157:53
    |
157 |     let mut string = mem::MaybeUninit::<[u8; 256]>::uninit();
    |                      -------------------------------^^^^^^
    |                      |
    |                      function or associated item not found in `std::mem::MaybeUninit<[u8; 256]>`

error: aborting due to 8 previous errors

Some errors occurred: E0599, E0658.
For more information about an error, try `rustc --explain E0599`.
error: Could not compile `whoami`.

WebAssembly Unit Tests

Currently WhoAmI is tested manually by running on target. Additional unit testing could be implemented; If the C functions are be mocked out for each platform and run within a WebAssembly runtime to verify that errors (such as from errno) are properly handled.

realname() (former user()) is broken on Windows

To reproduce, run the following program:

// [dependencies]
// whoami = "0.8.1"
fn main() {
    whoami::user();
}

or

// whoami = trunk
fn main() {
    whoami::realname();
}

It fails:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `16`,
 right: `15`

The assertion is here: https://github.com/libcala/whoami/blob/14f0e4a4cebb5debf7284da5b83152689161857c/src/windows.rs#L149

This happens because realname_os() is copy-pasted from username_os(), with GetUserNameW replaced with GetUserNameExW. But unlike GetUserNameW, GetUserNameExW on success returns the number of characters NOT counting the null terminator.

`realname` does not respect the format of the gecos field

Describe the bug
whoami may try to get the name from the passwd file. In that file there's a gecos field (https://en.wikipedia.org/wiki/Gecos_field) which whoami assumes is the name of the user. This is however incorrect. The gecos field is a comma separated list of which only the first element is the user's name.

To Reproduce
On my computer calling whoami::realname results in Aron,,, (note the extra commas).

Expected behavior
Calling whoami::realname should result in Aron (no commas).

Desktop (please complete the following information):

  • OS: [e.g. Ubuntu 20.04.2 LTS]
  • Version [e.g. 1.1.1]

WhoAmI 2.0 Roadmap / Mentoring

If you'd like to help contribute to some of the bigger projects, and would like mentoring/guidance, let me know. If you wish to contribute without doing that, make sure your PRs are either small or without controversial changes.

Platform Support

  • #76
  • Official Daku support
  • Official Android support

Documentation

Testing

Internals

Support getting OS arch(32-bit or 64-bit)

Is your feature request related to a problem? Please describe.
No. It would be a nice to have feature.

Describe the solution you'd like
Ability to get the arch of the OS.

Describe alternatives you've considered
There is a crate available for that https://crates.io/crates/bitness crate

Additional context
Although there are crates available that does the same thing but it would be nice to have it included in whoami

Switch to using libc dependency

There should be no MSRV concerns with this.

Eventually libc 0.2 will stop receiving updates, when libc 1.0 with a new MSRV policy is out, but until then the MSRV is compatible. WhoAmI 1.0 support is only guaranteed until then end of this year, although it will be supported for up to 3 more years if possible.

The benefits to using their definitions should outweigh any other concerns.

Android wapm crash at missing /etc/os-release

Describe the bug
Tried building Android version wapm which uses whoami, getting crashes when running wapm on Android
Not sure how to try experiment patching as I am unfamiliar how cargo works
Deps and all are picked up by cargo automatically

To Reproduce
Unlikely to suggest a very fast way to set up as I am using a complex environment
But it will be a good try to see what happens when /etc/os-release does not exist which is true for Android

Expected behavior
Should not crash

Screenshots
Screenshot_20210923-152546_Termux

Smartphone (please complete the following information):

  • Device: Galaxy A30s
  • OS: Android
  • Browser Chrome? Not relevant
  • Version 11

Additional context
Tried upgrading from whoami 0.5.3 to whoami 1.1.3 in wapm still stuck here

Hostname is all capitals on Windows

Describe the bug
The hostname returned by whoami::hostname is in all capitals on Windows.

To Reproduce

[dependencies]
whoami = "1"
hostname = "0.3"
fn main() {
    println!("whoami {:?}", whoami::hostname());
    println!("hostname {:?}", hostname::get());
}

Expected behavior
The hostname should be returned in the correct casing.

Screenshots
image

1.5.0 Release

Any pre-release bugs, typos, or other issues can be reported in the comments. Official testing will happen before 1.5.0 release.

All pre-releases will be announced in the comments here.

Use Result enum instead of hardcoding "Unknown" username

It would be nice to be consistent with the Rust convention of using Result. There could be an actual user with the name "Unknown".

Please consider changing that in version 2 ... or provide additional functions with new result types.

Crash on illumos due to different passwd struct definition

Describe the bug

Hi there, and thanks for maintaining this library!

I'm trying to use a project that depends on whoami, on illumos, and I'm seeing memory corruption occur due to this.

This appears to be because the passwd struct is different on illumos than on other Unixes -- so the getpwuid_r call corrupts memory.

On illumos, the passwd struct is listed here (search for "passwd Structure"):

struct passwd {
    char *pw_name;      /* user's login name */
    char *pw_passwd;    /* no longer used */
    uid_t pw_uid;       /* user's uid */
    gid_t pw_gid;       /* user's gid */
    char *pw_age;       /* not used */
    char *pw_comment;   /* not used */
    char *pw_gecos;     /* typically user's full name */
    char *pw_dir;       /* user's home dir */
    char *pw_shell;     /* user's login shell */
};

But what whoami uses on illumos is defined here:

#[repr(C)]
struct PassWd {
    pw_name: *const c_void,
    pw_passwd: *const c_void,
    pw_uid: u32,
    pw_gid: u32,
    pw_gecos: *const c_void,
    pw_dir: *const c_void,
    pw_shell: *const c_void,
}

To Reproduce

On an illumos system, run:

#[test]
fn test_names() {
    println!("{:?}", whoami::username());
}

Then, run cargo test --release -- --nocapture.

This fails with:

     Running tests/basic.rs (target/release/deps/basic-3cc3589bf34767da)

running 1 test
"unknown"
error: test failed, to rerun pass `--test basic`

Caused by:
  process didn't exit successfully: `/home/rain/dev/whoami/target/release/deps/basic-3cc3589bf34767da --nocapture` (signal: 6, SIGABRT: process abort signal)

Expected behavior

No crash occurs.

Additional context

It looks like the nix library implements this call safely, using the passwd definition in libc here.

Would it be okay to switch the Unix impl of this library to using nix rather than doing this call by hand? That would make it so that whoami would work on any platforms supported by nix and libc (which is roughly all of them).

I'm happy to do the work here if you're okay with it. Thanks!

Bug during compilation

Hi,

I get a compile time error while using the "username" function. I can't find a way to solve this problem, do you have any idea?

Thanking you

Return from rustc:

error: linking with x86_64-w64-mingw32-gcc failed: exit code: 1
|
= note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "-nostartfiles" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\self-contained\crt2.o" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\rsbegin.o" "-L" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib" "-L" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\self-contained" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.109c28khmx95elvc.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.1223k2d4v02qj3ms.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.17yqc9mqzjrsf9oq.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.1bayprrlqypl9j4g.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.1ihzmeil77tmmheb.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.1j7pcsv9ba1ytggy.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.2222yq4vudnwfpaj.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.24r2k4wruxgdydrv.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.27ib1kwb6p7uut02.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.28nldai6tecqsv1d.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.2935chmc4l8qtm2h.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.2a5qdfrtq65iwlwp.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.2gh22ofplwye86pt.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.2k78uxgyypon0jb3.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.2mkua32ge31crvil.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.2ocl1ietcwdam1r8.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.2v5i5y9zjvywd8vg.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.2wrlojn0fbodm7v5.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.2wsj3ffg9y4v82lt.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.2ykxa8jp4x2sm6gi.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.32dco5oaguw2wl4m.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.33gmezpffj91sj9f.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.33tckxcg5mkvs3du.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.3a95b73ytfglm501.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.3e1j851t8u6lqf0y.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.3j10ohoj1kla7pxz.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.3k4lf65i6x0p0mvs.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.3pp4dnxmsfgkfqt0.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.3qpnutkseyzpz2u9.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.3swarsyehecwmzd8.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.3v4pedk5zr3575co.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.3v4rwo7ad1sg5kw1.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.48ohn8ysmbi9u4dn.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.49j9n3c63lqznw1o.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.49naylhxr6gqll22.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.4dyg2acl8kmzb9xz.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.4fm5rtps0kgoubj1.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.4fzcreygkyx1t6q1.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.4h66vdrgtqsnllj0.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.4ijwvuqdllv5pk55.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.4xrxjqpv6uxayr0p.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.555wf0858r8ebps0.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.a3xiakg01qyquvc.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.cqshyrlzawft44k.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.kxhju3a67d69xmt.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.ncnppctqanudlkr.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.neu9m21ekb8q0wt.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.r4gi9xwfrt9jjqq.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.s2pncqniqzcfogb.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.tlujmru701k9g7g.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.u90zuka6a8e0agx.rcgu.o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.yujrwp2tqt44dhu.rcgu.o" "-o" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.exe" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\client-a1919aa5cdcab024.1oigcjupep789ln3.rcgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps" "-L" "C:\Users\%USERNAME%\.cargo\registry\src\github.com-1ecc6299db9ec823\winapi-x86_64-pc-windows-gnu-0.4.0\lib" "-L" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib" "-Wl,-Bstatic" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\libjson-a26e1aa48bcfbdec.rlib" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\libdirs-d5eed462948b9cb3.rlib" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\libdirs_sys-3497b7a942ce20bf.rlib" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\libwinapi-bab88ce11a64d9b5.rlib" "D:\Users\%USERNAME%\Desktop\Toto\Rust\Program\Client\target\debug\deps\libwhoami-cf504303bec067aa.rlib" "-Wl,--start-group" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libstd-c1f4a34954f44b86.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libpanic_unwind-63d918f6a4328727.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libobject-df02665a14c23c3f.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libaddr2line-8a2ca8def5625c96.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libgimli-f8602c621ed79cb5.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\librustc_demangle-8124381f500c8a69.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libhashbrown-2260daa86b23c242.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\librustc_std_workspace_alloc-5b3ec382765aebe0.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libunwind-58f1a51695d3489d.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libcfg_if-46b81e008718457e.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\liblibc-f4a48eaff8400529.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\liballoc-7094347f61afa1d3.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\librustc_std_workspace_core-be0238fd280e8b76.rlib" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libcore-bb3b979426878ebc.rlib" "-Wl,--end-group" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\libcompiler_builtins-021a8bc03364b43c.rlib" "-Wl,-Bdynamic" "-lwinapi_advapi32" "-lwinapi_cfgmgr32" "-lwinapi_gdi32" "-lwinapi_kernel32" "-lwinapi_msimg32" "-lwinapi_ole32" "-lwinapi_opengl32" "-lwinapi_shell32" "-lwinapi_user32" "-lwinapi_winspool" "-lsecur32" "-lntdll" "-lkernel32" "-ladvapi32" "-lws2_32" "-luserenv" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "C:\Users\%USERNAME%\.rustup\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\rsend.o"
= note: ld: cannot find -lntdll

Redox Support

Redox can be supported by reading paths on the system, rather than use unsafe relibc unix-like APIs. Unsure about language support (probably check same unix environment variables) and no "fancy device name" is implemented in Redox as far as I can tell.

/etc/redox-release
    Redox version followed by newline

/etc/passwd
    Effective Versions:
         https://docs.rs/redox_syscall/latest/syscall/call/fn.geteuid.html
         https://docs.rs/redox_syscall/latest/syscall/call/fn.getegid.html
    Username;Uid;Gid;FullName,*;โ€ฆ
    root;0;0;root;file:/root;file:/bin/ion
    jeron::1000:1000:Jeron Lau:/var/home/jeron:/bin/bash

sys:uname
    Kernel Name
    
    Kernel Release
    
    Machine Architecture

Support retrieving information from web browsers?

Right now, running the basic example on a chromium browser gives me these results:

realname 'Anonymous'
username 'anonymous'
lang '["en-US", "en"]'
prettyname 'Safari 537.36'
hostname 'localhost'
platform 'Linux'
distro 'Unknown Linux'
desktop_env 'Web Browser'

In particular, Safari 537.36 is pretty obviously wrong.

Do you think it'd make sense to use something like this to get better information about the browser? It's literally a pile of hacks, but a pile of hacks is pretty much what I'd expect to be seeing in the implementation of something like whoami ๐Ÿ˜…

Now, I guess a subsequent question is also which fields to expose and/or whether only prettyname should be affected or if the WebBrowser variant of desktop_env should also get metadata about the browser with all the things suggested in the link above. WDYT?

Roadmap

If anyone wants to discuss API designs for the following (or missing) items on the roadmap, please do:

  • No panics #29
  • Figure out API for arch() (Version 1.3.0) #25
  • #40
  • Add fallible functions (returning io::Result) (depends on Depends on #30)
  • #45
  • #54 Official WASI (currently with Wasite) support
  • #76 Official Redox support
  • Official Daku support
  • Official Android support
  • Official other platform support?

error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1

Describe the bug
i'm trying to compile on windows and i get this error, without the "whoami" crate compiles normally

To Reproduce
Steps to reproduce the behavior:

run cargo new project_teste
add whoami = "1.1.1" to Cargo.yaml
run cargo build

Expected behavior
compile without errors

Screenshots

**Desktop **

  • OS: Windows 11

Additional context

PS C:\MyRustProjects\fsbackup_engine> cargo clean
PS C:\MyRustProjects\fsbackup_engine> cargo build
   Compiling whoami v1.2.0
   Compiling fsbackup_engine v0.1.0 (C:\MyRustProjects\fsbackup_engine)
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-m64" "-Wl,--high-entropy-va" "C:\\rust\\toolchains\\stable-x86_64-pc-win
dows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\self-contained\\crt2.o" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsbegin.o" "C:\
\MyRustProjects\\fsbackup_engine\\target\\debug\\deps\\fsbackup_engine-d32542f439e80aee.1pt9prttv128uo2j.rcgu.o" "C:\\MyRustProjects\\fsbackup_engine\\target\\debug\\deps\\fsbackup_engin
e-d32542f439e80aee.1ruhj7kwh7vzv8d9.rcgu.o" "C:\\MyRustProjects\\fsbackup_engine\\target\\debug\\deps\\fsbackup_engine-d32542f439e80aee.2kon509fe5wo3oop.rcgu.o" "C:\\MyRustProjects\\fsba
ckup_engine\\target\\debug\\deps\\fsbackup_engine-d32542f439e80aee.2pfaf41ga7eblwlz.rcgu.o" "C:\\MyRustProjects\\fsbackup_engine\\target\\debug\\deps\\fsbackup_engine-d32542f439e80aee.34
jri740lrs3thiq.rcgu.o" "C:\\MyRustProjects\\fsbackup_engine\\target\\debug\\deps\\fsbackup_engine-d32542f439e80aee.3kt0bao5o8x0lxlh.rcgu.o" "C:\\MyRustProjects\\fsbackup_engine\\target\\
debug\\deps\\fsbackup_engine-d32542f439e80aee.42xpqzv6kez0il64.rcgu.o" "C:\\MyRustProjects\\fsbackup_engine\\target\\debug\\deps\\fsbackup_engine-d32542f439e80aee.4xk7yxj5pa0x9lip.rcgu.o
" "C:\\MyRustProjects\\fsbackup_engine\\target\\debug\\deps\\fsbackup_engine-d32542f439e80aee.568xwdd21d5x67h1.rcgu.o" "C:\\MyRustProjects\\fsbackup_engine\\target\\debug\\deps\\fsbackup
_engine-d32542f439e80aee.56iitxaeizf5c8nz.rcgu.o" "C:\\MyRustProjects\\fsbackup_engine\\target\\debug\\deps\\fsbackup_engine-d32542f439e80aee.tobg70orvraksrv.rcgu.o" "C:\\MyRustProjects\
\fsbackup_engine\\target\\debug\\deps\\fsbackup_engine-d32542f439e80aee.2kunw55j7bwqfbnb.rcgu.o" "-L" "C:\\MyRustProjects\\fsbackup_engine\\target\\debug\\deps" "-L" "C:\\windows\\system
32" "-L" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-Wl,--start-group" "-Wl,-Bstatic" "C:\\rust\\toolchains\\stable-x86_64-pc-windows
-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd-c949a5d9f8ea17eb.rlib" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libpanic_unwi
nd-4efbd26dc95f473b.rlib" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libobject-11df657f271ec0b5.rlib" "C:\\rust\\toolchains\\stable-x8
6_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libmemchr-ed6e817a89285a21.rlib" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\
lib\\libaddr2line-a16c4de5bb48a9a6.rlib" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libgimli-b5d4a31ea91f9e86.rlib" "C:\\rust\\toolcha
ins\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libstd_detect-01e22831e506e0c6.rlib" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_6
4-pc-windows-gnu\\lib\\librustc_demangle-85865d75ad690c5e.rlib" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libhashbrown-91e2696c8ccb44
61.rlib" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-186512436a4043bc.rlib" "C:\\rust\\toolchains\\stable-
x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libunwind-d0f4aee65f54d86f.rlib" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu
\\lib\\libcfg_if-42335e6cb2553e87.rlib" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liblibc-662baf24e2595e01.rlib" "C:\\rust\\toolchain
s\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\liballoc-131219d6deabaad8.rlib" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-wi
ndows-gnu\\lib\\librustc_std_workspace_core-6530d4af942dc9d4.rlib" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcore-d1ec034e2d5fe483
.rlib" "-Wl,--end-group" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\libcompiler_builtins-885492184211f20a.rlib" "-Wl,-Bdynamic" "-lker
nel32" "-lws2_32" "-ladvapi32" "-luserenv" "-lkernel32" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-nost
artfiles" "-L" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib" "-L" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_
64-pc-windows-gnu\\lib\\self-contained" "-o" "C:\\MyRustProjects\\fsbackup_engine\\target\\debug\\deps\\fsbackup_engine-d32542f439e80aee.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlib
s" "C:\\rust\\toolchains\\stable-x86_64-pc-windows-gnu\\lib\\rustlib\\x86_64-pc-windows-gnu\\lib\\rsend.o"
  = note: C:\rust\toolchains\stable-x86_64-pc-windows-gnu\lib\rustlib\x86_64-pc-windows-gnu\lib\self-contained\crt2.o:crtexe.c:(.text+0x2a0): undefined reference to `_set_invalid_paramet
er_handler'

  = help: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
  = note: use the `-l` flag to specify native libraries to link
  = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-li
bkindname)

error: could not compile `fsbackup_engine` due to previous error
PS C:\MyRustProjects\fsbackup_engine>

rustup show

PS C:\MyRustProjects\fsbackup_engine> rustup show
Default host: x86_64-pc-windows-msvc
rustup home:  C:\rust

installed toolchains
--------------------

stable-x86_64-pc-windows-gnu (default)
stable-x86_64-pc-windows-msvc

active toolchain
----------------

stable-x86_64-pc-windows-gnu (default)
rustc 1.56.1 (59eed8a2a 2021-11-01)

PS C:\MyRustProjects\fsbackup_engine>


[package]
name = "fsbackup_engine"
version = "0.1.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
#ssh2 = "0.9.0" # Bindings to libssh2 for interacting with SSH servers and executing remote commands
whoami = "1.1.1" # Retrieve the current user and environment.
#toml = "0.5.8" # A native Rust encoder and decoder of TOML-formatted files and streams.
#rand = "0.8.4" # Random number generators and other randomness functionality.
#regex = "1.5.4"
#lazy_static = "1.4.0"
#log = "0.4.14"
#bytesize = "1.1.0"
#chrono = "0.4.19"
#wildmatch = "2.0.0"
#thiserror = "^1.0.0"

#[target."cfg(target_family = \"unix\")"]
#[target."cfg(target_family = \"unix\")".dependencies]
#users = "0.11.0"

#[target."cfg(target_os = \"windows\")"]
#[target."cfg(target_os = \"windows\")".dependencies]
#path-slash = "0.1.4"

Cross compilation to windows fails as of v0.5.3 - `/usr/bin/x86_64-w64-mingw32-ld: cannot find -lSecur32`

I ran into a linux to windows cross compilation failure on my project and traced the issue down to a change made in this repository between 0.5.2 and 0.5.3. I put together the minimal failure case available at https://github.com/pcorliss/whoami_failure_repro

Downgrading to 0.5.2 seems to solve the problem. Any thoughts on what the cause could be or a workaround?

โžœ  hello git:(master) โœ— cargo build --release --target x86_64-pc-windows-gnu
    Updating crates.io index
   Compiling hello v0.1.0 (/home/ubuntu/git/hello)
error: linking with `x86_64-w64-mingw32-gcc` failed: exit code: 1
  |
  = note: "x86_64-w64-mingw32-gcc" "-fno-use-linker-plugin" "-Wl,--nxcompat" "-nostdlib" "-m64" "/usr/x86_64-w64-mingw32/lib/crt2.o" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/rsbegin.o" "-L" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib" "/home/ubuntu/git/hello/target/x86_64-pc-windows-gnu/release/deps/hello-9084fff30e007914.hello.4maci1qj-cgu.0.rcgu.o" "/home/ubuntu/git/hello/target/x86_64-pc-windows-gnu/release/deps/hello-9084fff30e007914.hello.4maci1qj-cgu.1.rcgu.o" "/home/ubuntu/git/hello/target/x86_64-pc-windows-gnu/release/deps/hello-9084fff30e007914.hello.4maci1qj-cgu.2.rcgu.o" "/home/ubuntu/git/hello/target/x86_64-pc-windows-gnu/release/deps/hello-9084fff30e007914.hello.4maci1qj-cgu.3.rcgu.o" "/home/ubuntu/git/hello/target/x86_64-pc-windows-gnu/release/deps/hello-9084fff30e007914.hello.4maci1qj-cgu.4.rcgu.o" "-o" "/home/ubuntu/git/hello/target/x86_64-pc-windows-gnu/release/deps/hello-9084fff30e007914.exe" "/home/ubuntu/git/hello/target/x86_64-pc-windows-gnu/release/deps/hello-9084fff30e007914.3uc9bdh4rdq5eyl8.rcgu.o" "-Wl,--gc-sections" "-nodefaultlibs" "-L" "/home/ubuntu/git/hello/target/x86_64-pc-windows-gnu/release/deps" "-L" "/home/ubuntu/git/hello/target/release/deps" "-L" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib" "-Wl,-Bstatic" "/home/ubuntu/git/hello/target/x86_64-pc-windows-gnu/release/deps/libwhoami-d1c1f07b55987090.rlib" "-Wl,--start-group" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libstd-b856675eeb99d410.rlib" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libpanic_unwind-7d9318240b1ba43e.rlib" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libhashbrown-1ea2d9c4ec771682.rlib" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/librustc_std_workspace_alloc-d40a2a1378721a73.rlib" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libbacktrace-e7c77cc61316712f.rlib" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libbacktrace_sys-160c2ebb98665c54.rlib" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/librustc_demangle-bd6bce6239a05021.rlib" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libunwind-c933f93cd63b2ad0.rlib" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libcfg_if-cabd342650cb5eba.rlib" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/liblibc-14fea7a91cbd1d65.rlib" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/liballoc-13f8aa678796468f.rlib" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/librustc_std_workspace_core-d5b2602ca33debca.rlib" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libcore-d0a6bfc5adb4da72.rlib" "-Wl,--end-group" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/libcompiler_builtins-9bf35bb038f7db43.rlib" "-Wl,-Bdynamic" "-lSecur32" "-ladvapi32" "-lws2_32" "-luserenv" "-Wl,-Bstatic" "-lgcc_eh" "-lpthread" "-Wl,-Bdynamic" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-lmsvcrt" "-luser32" "-lkernel32" "/home/ubuntu/.asdf/installs/rust/1.43.1/toolchains/1.43.1-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/rsend.o"
  = note: /usr/bin/x86_64-w64-mingw32-ld: cannot find -lSecur32
          collect2: error: ld returned 1 exit status


error: aborting due to previous error

error: could not compile `hello`.

To learn more, run the command again with --verbose.

Potential segfault / memory safety issue in getpwuid

I discovered this bug while running sqlx in a minimal docker image that did not contain a passwd file. When a record is not found for a user, whoami segfaults.

This is due to whoami incorrectly handling this case. According to the man page for getpwuid_r when no entry is found in the passwd file, the status will still equal 0. Crucially, result will be set to NULL, and no write will occur into pwd. That leaves passwd uninitialized and makes assume_init an unsafe call that can trigger undefined behavior.

I believe I have fixed this problem in #33

Reproduction steps

  1. Enter an environment without a `passwd file
  2. Run some code that relies on getpwuid
  3. Observe segfault

Expose unmodified hostname (non-lowercase)

Is your feature request related to a problem? Please describe.
The hostname is currently being coerced into lowercase, but hostnames on Windows are usually expected to be all-uppercase and on unix systems hostnames aren't guaranteed to be lowercase either (starship/starship#5666).

Describe the solution you'd like
Expose an API that returns the unmodified system-provided hostname.

Describe alternatives you've considered
Change the API not to modify the system-provided hostname.

Additional context
starship/starship#5666
#39

Add Feature Flag For Web

wasm32-unknown-unknown does not necessarily target the web.

This change probably requires a version 2.0.0

This could be enabled with a default feature.

Reduce use of `unsafe` by using `libc` crate

I see that whoami used to depend on libc until commit 12d9910, but the commit doesn't explain why. Are you open to a PR that adds back a dependency on libc to avoid unsafe and reimplementations of its functions?

Test on Mac OS

System Support Request

Make sure that the library works on Mac OS.

  • Fix Getting OS Name
  • Fix Getting Computer Name
  • Fix Getting Environment

add AzureAD login

Is your feature request related to a problem? Please describe.
I need to get in Windows AzureAD login name, it's not in system env
you can get this name running command in cmd/powershell in Windows connected to AzureAD:

whoami.exe /UPN

result:

before migration to AzureAD i was using this function:

whoami::username();

Describe the solution you'd like
add function to get AzureAD name

Describe alternatives you've considered
now im using workaround by running this code:

    let cmd = Command::new("cmd")
        .args(["/C", "whoami.exe /UPN"])
        .output()
        .expect("failed to execute process")
        .stdout;
    let full_user_name = String::from_utf8(cmd).unwrap();

it's not elegant because it's run cmd in background

Additional context
we are using login name with timestamp and few others things to set user clipboard, before migration to AzureAD it works because name in system env was same as login name, with AzureAD it's different, it's FirstnameLastname

Better Document The Testing Procedure

There's a fairly involved testing procedure for WhoAmI, but it's done mostly by memory and could easily be done poorly. Add a TESTING.md, and link to it in README.md

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.