Skip to content

implemented domainname - #183

Open
Anonymous-AAA wants to merge 9 commits into
uutils:mainfrom
Anonymous-AAA:main
Open

Anonymous-AAA wants to merge 9 commits into
uutils:mainfrom
Anonymous-AAA:main

Conversation

@Anonymous-AAA

Copy link
Copy Markdown

No description provided.

@cakebaker
cakebaker requested a review from sylvestre July 16, 2025 12:57
@Anonymous-AAA Anonymous-AAA changed the title implemented domainname for unix implemented domainname Jul 31, 2025
@Anonymous-AAA

Copy link
Copy Markdown
Author

Is anyone looking into this pr?

@codecov

codecov Bot commented Aug 3, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (a4d31ca) to head (46ae3be).
⚠️ Report is 41 commits behind head on main.

Additional details and impacted files
@@     Coverage Diff     @@
##   main   #183   +/-   ##
===========================
===========================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hz2

hz2 commented Aug 10, 2025 •

Copy link
Copy Markdown

@Anonymous-AAA

might want to add what issue this would be closing

#5

additionally, may be good to add in tests here

@Anonymous-AAA

Copy link
Copy Markdown
Author

ok I will add the tests

))]
use std::ffi::c_int;

pub(crate) fn domain_name() -> UResult<Option<CString>> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is almost exactly domain_name() from src/uu/hostname/src/net/unix.rs
same for utils.rs, the validation and errors.rs
could be shared instead of duplicated, no?

Comment thread src/bin/domainname.rs

fn main() {
let args: Vec<OsString> = env::args_os().collect();
let exit_code = domainname::uumain(args.into_iter());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this binary?
src/bin/hostname.rs is already a multicall binary that should pick up domainname from the feature


pub(crate) fn domain_name() -> std::io::Result<Option<OsString>> {
// TODO: Should we specify ComputerNameDnsDomain instead?
// TODO: Should we call NetGetJoinInformation() instead?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ComputerNamePhysicalDnsDomain is the DNS domain, not the NIS/YP one
is it really what we want on windows? please remove the TODOs either way

#[test]
fn test_set_domainname_from_invalid_file() {
domainname_cmd()
.arg("-F invalid-path")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this passes "-F invalid-path" as a single arg, so the file is " invalid-path"
please use .arg("-F").arg("invalid-path")
also "No such file or directory" won't match on windows

ArgGroup::new("source-group")
.args([options::FILE, options::DOMAINNAME])
.multiple(false),
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conflicts_with is already set on both args, do we need these two groups?
without them the expect() above could go too

fn test_set_invalid_domainname() {
domainname_cmd()
.arg("invalid_domain_name")
.fails()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the net-tools domainname reject _ too?
NIS domain names are not DNS names, please check the behavior


let mut domain_name = domain_name.into_owned();
domain_name.push(0_u8);
Ok(unsafe { CString::from_vec_with_nul_unchecked(domain_name) })

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a // SAFETY: comment

description = "domainname ~ (uutils) show or set the system's NIS/YP domain name"

homepage = "https://github.com/uutils/hostname"
repository = "https://github.com/uutils/hostname/tree/main/src/uu/hostname"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong path here, and the "acl" keyword makes no sense :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants