Skip to content

Conversation

@adombeck
Copy link
Contributor

@adombeck adombeck commented Jan 5, 2026

Important

This is based on #1087

Generate authctl docs via cobra.

UDENG-8760

@adombeck
Copy link
Contributor Author

adombeck commented Jan 6, 2026

@edibotopic do you understand why the build of the docs fails in the CI but not when I build it locally via make html? The command-line options passed to sphinx seem to be about the same.

In the CI I these warnings which I assume are the reason the build fails:

/home/docs/checkouts/readthedocs.org/user_builds/canonical-authd/checkouts/1179/docs/reference/cli/authctl.md.rst:1: WARNING: Document headings start at H2, not H1
/home/docs/checkouts/readthedocs.org/user_builds/canonical-authd/checkouts/1179/docs/reference/cli/authctl_group.md.rst:1: WARNING: Document headings start at H2, not H1
/home/docs/checkouts/readthedocs.org/user_builds/canonical-authd/checkouts/1179/docs/reference/cli/authctl_group_set-gid.md.rst:1: WARNING: Document headings start at H2, not H1
/home/docs/checkouts/readthedocs.org/user_builds/canonical-authd/checkouts/1179/docs/reference/cli/authctl_user.md.rst:1: WARNING: Document headings start at H2, not H1
/home/docs/checkouts/readthedocs.org/user_builds/canonical-authd/checkouts/1179/docs/reference/cli/authctl_user_lock.md.rst:1: WARNING: Document headings start at H2, not H1
looking for now-outdated files... /home/docs/checkouts/readthedocs.org/user_builds/canonical-authd/checkouts/1179/docs/reference/cli/authctl_user_set-uid.md.rst:1: WARNING: Document headings start at H2, not H1
/home/docs/checkouts/readthedocs.org/user_builds/canonical-authd/checkouts/1179/docs/reference/cli/authctl_user_unlock.md.rst:1: WARNING: Document headings start at H2, not H1

I don't see those locally.

@adombeck
Copy link
Contributor Author

adombeck commented Jan 6, 2026

In the CI I these warnings which I assume are the reason the build fails:

FTR, we were able to resolve that - @edibotopic figured out how to ignore these warnings

@adombeck adombeck marked this pull request as ready for review January 6, 2026 16:34
@adombeck adombeck requested a review from a team as a code owner January 6, 2026 16:34
@adombeck adombeck requested a review from edibotopic January 6, 2026 16:34
@edibotopic
Copy link
Contributor

edibotopic commented Jan 6, 2026

FTR, we were able to resolve that - @edibotopic figured out how to ignore these warnings

Thanks @adombeck .

I think it's OK to ignore these warnings for now so that we are better able to support users with these docs. In the long run, we should fix the header levels so that they conform with the rest of the docs.

In future, we can work on improving the doc generation and formatting of the rendered output, depending on capacity, etc.

@adombeck
Copy link
Contributor Author

adombeck commented Jan 6, 2026

@edibotopic I think this is now ready for an initial review. Please ignore all the commits which are not touching the documentation, those are from #1087.

The documentation is very rudimentary for now, we might want to write a more extensive overview of authctl and maybe inline the documentation of the separate commands in the index.md. As discussed on MM, we might also want to use gencodo to improve the generated markdown.

@adombeck
Copy link
Contributor Author

adombeck commented Jan 6, 2026

we might also want to use gencodo to improve the generated markdown.

For later reference, I pushed a WIP commit which uses gencodo to https://github.com/adombeck/authd/tree/authctl-docs-gencodo

Copy link
Contributor

@edibotopic edibotopic left a comment

Choose a reason for hiding this comment

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

Excellent work @adombeck .

I've left a few minor suggestions and comments.

Some of the more elaborate synopses tend to push the basic usage example (Use) quite far down, and visually pair it with a separate command, example:

Image

I think that's probably just a limitation of the native Cobra docgen, but it's something we can look at in future.

Comment on lines +27 to +31
Files outside the user's home directory are not updated and must be changed
manually. Note that changing a UID can be unsafe if files on the system are
still owned by the original UID: those files may become accessible to a different
account that is later assigned that UID. To change ownership of all files on the
system from the old UID to the new UID, run:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Files outside the user's home directory are not updated and must be changed
manually. Note that changing a UID can be unsafe if files on the system are
still owned by the original UID: those files may become accessible to a different
account that is later assigned that UID. To change ownership of all files on the
system from the old UID to the new UID, run:
Files outside the user's home directory are not updated and must be changed
manually.
Note that changing a UID can be unsafe if files on the system are
still owned by the original UID: those files may become accessible to a different
account that is later assigned that UID. To change ownership of all files on the
system from the old UID to the new UID, run:

I think these are separate paragraphs.

Copy link
Contributor Author

@adombeck adombeck Jan 7, 2026

Choose a reason for hiding this comment

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

I see that starting the sentence with "Note ..." makes it feel like a new paragraph, but conceptually it's about the exact same thing: ownership of files outside the user's home directory must be updated manually

Maybe we could rephrase things to make better fit the sentences into the same paragraph?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it just needs something like this to provide a link between the first and second sentences:

Note that changing a UID manually can be unsafe if files on the system are
still owned by the original UID

Note that changing a UID in this way can be unsafe if files on the system are
still owned by the original UID

What do you think?

Copy link
Contributor Author

@adombeck adombeck Jan 7, 2026

Choose a reason for hiding this comment

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

No, that's not the intended meaning. It's not the "manual change [of file ownership]" in the first sentence which can be unsafe. It's the change of the UID, i.e. the authctl user set-uid command which can be unsafe if there are files on the system still owned by that UID. So what we want to say is "make sure that you do update file ownerships manually for files outside the home directory". Does that make it clearer? If not, I can try to explain the issue in more detail.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, indeed, that makes it more clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do we best rephrase this sentence to also make it clear to the user?

Copy link
Contributor

@edibotopic edibotopic Jan 12, 2026

Choose a reason for hiding this comment

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

I think we should leave it as the original. The misinterpretation was my own and I understand that after your clarification.

If this was a regular doc, I would probably put the note in its own block so that the first and third sentences flow together more clearly but we can revisit that another time.

Comment on lines +28 to +33
Files outside users' home directories are not updated and must be changed
manually. Note that changing a GID can be unsafe if files on the system are
still owned by the original GID: those files may become accessible to a
different group that is later assigned that GID. To change group ownership of
all files on the system from the old GID to the new GID, run:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Files outside users' home directories are not updated and must be changed
manually. Note that changing a GID can be unsafe if files on the system are
still owned by the original GID: those files may become accessible to a
different group that is later assigned that GID. To change group ownership of
all files on the system from the old GID to the new GID, run:
Files outside users' home directories are not updated and must be changed
manually.
Note that changing a GID can be unsafe if files on the system are
still owned by the original GID: those files may become accessible to a
different group that is later assigned that GID. To change group ownership of
all files on the system from the old GID to the new GID, run:

Copy link
Contributor

Choose a reason for hiding this comment

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

Can reconsider based on discussion of similar case above.

@adombeck
Copy link
Contributor Author

adombeck commented Jan 7, 2026

Some of the more elaborate synopses tend to push the basic usage example (Use) quite far down, and visually pair it with a separate command

Yeah, that also annoyed me. I think the description just doesn't belong in the "Synopsis" section. My understanding of a "Synopsis" is that it's only the formal description of how to run the command what command line options it takes (like authctl user lock <user> [flags]). In my opinion the description should go in a separate section, like in man pages. I already opened a PR upstream to change that: spf13/cobra#2344

This is an issue which we could fix with gencodo.

@edibotopic
Copy link
Contributor

Some of the more elaborate synopses tend to push the basic usage example (Use) quite far down, and visually pair it with a separate command

Yeah, that also annoyed me.
[...]
This is an issue which we could fix with gencodo.

Thanks for the context @adombeck . I agree, let's wait for gencodo. It's OK for now.

There's nothing encrypted in this string.
... instead of prefixing the error message with "permission denied"
Required to change the ownership of the user's home directory when
changing the user's UID.
We use this to recursively change the owner and group of the user's home
directory when changing the user's UID.
Needed to test fileutils.ChownRecursiveFrom. We can't use bubblewrap for
that because bubblewrap only creates UID mapping for one user, using
chown with a different UID fails with:

    chown: changing ownership of 'file': Invalid argument
Do the same usermod does when changing a UID of a user: If the home
directory is currently owned by the user, recursively change the owner
and group of the home directory and all files in the home directory from
the old UID and GID to the new UID and GID.
We need that for the SetUserID tests
We now support chown in bubblewrap, so we don't have to run the test as
root anymore.
adombeck and others added 27 commits January 12, 2026 14:55
When executing `unshare --map-user` via exec.Command and connecting the
process's stdout or stderr, the command hangs forever if unprivileged
user namespaces are disabled.

We avoid that by checking via `unshare --user` if unprivileged user
namespaces are enabled.
The "Run autopkgtests" CI job runs the tests in an LXD container which
doesn't allow using bubblewrap. It fails with:

    bwrap: Failed to make / slave: Permission denied

To avoid that these jobs fail, we allow them to skip the bubblewrap
tests. We still run the tests in the "Go Tests" CI jobs.
Running our tests with -v produces so much output that it makes it
harder to inspect test failures, for example when viewing the logs of
the "Run autopkgtests" CI job in GitHub.

Running the tests without -v still prints the logs of the failed tests
which should include all the information we need to debug test failures.
As suggested by reviewer. It's not implemented for now, warnings are
always returned in English.
Produces prettier docs
So that it can be imported by the docgen tool we're about to add.
Indenting with four spaces formats the command as a code block in the
generated markdown document.
Having the "This command requires root privileges." sentence after the
`chown -R` command was confusing, it sounded like it was referring to
that command instead of the authctl command.
To generate the CLI docs
The auto-generated Cobra markdown docs use headings starting at H2, not
H1. That results in Sphinx printing warnings, which causes the build to
fail in the CI (but not locally).

Let's ignore these kind of warnings for now.
Via `go generate ./docs/...`
Copy link
Contributor

@edibotopic edibotopic left a comment

Choose a reason for hiding this comment

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

Great work! Nice to have this in the docs.

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