Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CA-386281 CIFS username can be omitted in ISO SR #663

Merged
merged 1 commit into from
Jan 9, 2024

Conversation

rdn32
Copy link
Contributor

@rdn32 rdn32 commented Dec 15, 2023

ISOSR falling over when no username is given is a regression that looks to have been introduced in commit
cbd7226 when the use of a credentials file was removed.

The ISOSR unit tests were already covered cases of not having credentials - as evinced by having "guest" in the expected mount options. However, they were doing this in a rather confused way that hid the bug by supplying a username regardless. Now only the credentials tests do this.

ISOSR falling over when no username is given is a regression that looks
to have been introduced in commit
cbd7226 when the use of a credentials
file was removed.

The ISOSR unit tests were already covered cases of not having
credentials - as evinced by having "guest" in the expected mount
options. However, they were doing this in a rather confused way that hid
the bug by supplying a username regardless. Now only the credentials
tests do this.

Signed-off-by: Robin Newton <[email protected]>
username, domain = (
cifutils.splitDomainAndUsername(self.dconf['username'])
)

if domain:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just move this up into the else clause ?

Copy link
Contributor Author

@rdn32 rdn32 Dec 15, 2023

Choose a reason for hiding this comment

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

That's what I thought I did. Is the diff somehow showing back-to-front?
Oh, you're talking about the if domain. No, that has to be kept, because domain can come back None from splitDomainAndUsername.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might have been better if the stuff with the SMB version didn't come between the conditional blocks. But the unit tests are sensitive to the order in which options come - I toyed with making them less sensitive, but it seems like quite a lot of faff.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's what I thought I did. Is the diff somehow showing back-to-front? Oh, you're talking about the if domain. No, that has to be kept, because domain can come back None from splitDomainAndUsername.

Well, yes, but we know that there can never be a domain in the positive case of the if so making the else be

else: 
    _, domain = cifutils.splitDomainAndUsername(self.dconf['username'])
    if domain:
         options.append('domain=' + domain)

would then remove the need for the domain=None in the guest handling side of the branch.

Maybe we should do this as a future improvement to avoid the sensitivity of the UTs to the order of the provided options.

Copy link
Contributor

@edwintorok edwintorok left a comment

Choose a reason for hiding this comment

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

Looks like a plausible fix, I assume you've tried and you can successfully create a CIFS ISO SR when no username is specified now?

@rdn32
Copy link
Contributor Author

rdn32 commented Dec 15, 2023

Looks like a plausible fix, I assume you've tried and you can successfully create a CIFS ISO SR when no username is specified now?

Yes. In XenIA-Pre I found the SMB path for a collection of Windows ISOs that can be used without authenticating. I didn't test the case where authentication is required but no username is given - I got a bit bogged down try to set up an SMB server - so I'm assuming it would fail in the same way that it would if invalid credentials were given.

@MarkSymsCtx MarkSymsCtx merged commit df24f36 into xapi-project:master Jan 9, 2024
2 checks passed
@rdn32 rdn32 deleted the private/rnewton/CA-386281 branch January 9, 2024 10:33
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.

4 participants