-
Notifications
You must be signed in to change notification settings - Fork 21
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
[WIP] issuegen: detect util-linux RPM version, set output directory appropriately #40
Conversation
23a8497
to
c2eb4b8
Compare
For the same reason as in coreos#39 (copying the phrasing below): With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. Instead, write the intermediate output to a variable before writing to the final output file. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
c2eb4b8
to
2b5da38
Compare
will review this one more thoroughly when we get #39 merged and this is rebased |
2b5da38
to
3f4e49a
Compare
;; | ||
esac | ||
|
||
# TODO: it would be nice to have /run/issue.d be an official directory, | ||
# see https://github.com/karelzak/util-linux/commit/1fc82a1360305f696dc1be6105c9c56a9ea03f52#commitcomment-27949895 | ||
# until then, $GENERATED_ISSUE writes to the privately scoped directory (not in /run/issue.d) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In particular, #7 is tracking this comment - no longer need to mention in the source.
3f4e49a
to
81458f2
Compare
ISSUE_SNIPPETS_PATH=${PKG_NAME}/issue.d | ||
ETC_SNIPPETS="/etc/${ISSUE_SNIPPETS_PATH}" | ||
RUN_SNIPPETS="/run/${ISSUE_SNIPPETS_PATH}" | ||
USR_LIB_SNIPPETS="/usr/lib/${ISSUE_SNIPPETS_PATH}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking the variable names should not need to distinguish the private/public path, at least for now, since for issuegen
all snippets are written into the "private" directories. Previously, ISSUE_DIR_PUBLIC
was unused. The *_SNIPPETS
variables will just refer to the snippet paths that will get read in order to create ${generated_file}
.
For #7, we may allow a choice of using the public or private locations for the snippet locations by invoking e.g. issuegen
or issuegen --legacy
respectively from the console-login-helper-messages-issuegen.service
unit (this choice would be needed for systems that have util-linux
version under 2.35 - e.g. RHCOS). We would probably try to split the ssh, udev, and generated issue parts up and have SSH_KEY_OUTDIR
and UDEV_IF_OUTDIR
set to either /run/issue.d
(public) or /run/console-login-helper-messages/issue.d
(private - i.e. the RUN_SNIPPETS
variable). The private locations would be used for the *_OUTDIR
variables if --legacy
was passed. However more discussion can be done on this in #7. In any case, the *_SNIPPETS
locations should be consumed only when creating ${generated_file}
- the *_SNIPPETS
variables shouldn't need to change after this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could either use a config file (like a file in /etc/console-login-helper-messages/foo.conf) to set the paths to output to or we could detect the version of util-linux and switch based on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
though would we still want to use a private directory for all the snippets and then just write out generated_file
to the public directory like we do for motdgen in #44
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 a config file would be good at some point. A specfile would make the choice on the output paths set in /etc/console-login-helper-messages/foo.conf
, based on the util-linux
version.
I'm thinking if a config file is added, we'd want to support an extensible config file format - which would allow on/off configuration for each piece of information (udev interfaces, ssh keys, etc) (#15), and whether the snippets are output in the issue, motd, or other. I've opened this to discuss #45.
For now, going with having issuegen
check the util-linux version and set SSH_KEY_OUTDIR
, UDEV_IF_OUTDIR
, and generated_file
appropriately seems simplest - this could be default behaviour if a config path was not specified if we added a config file. Will update this PR with the check on the util-linux version and setting the path shortly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now updated with the version check - kept so that the check would only make the switch automatically for RPM-based distributions for now.
For the same reason as in coreos#39 (copying the phrasing below): With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. Instead, write the intermediate output to a variable before writing to the final output file. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
For the same reason as in coreos#39 (copying the phrasing below): With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. Instead, write the intermediate output to a variable before writing to the final output file. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
81458f2
to
b6196b8
Compare
Clean up code by minimizing the number of variables and shortening the variable names. Remove unneeded comments, and add a few more clarifying comments. Separate code into clearer blocks for different operations (generating SSH key information, udev data, and the final output issue file).
For the same reason as in coreos#39 (copying the phrasing below): With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. Instead, write the intermediate output to a variable before writing to the final output file. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
If the util-linux version installed is greater than or equal to 2.35, when support for /run/issue.d was added, set the the output paths so that /run/issue.d is utilized. The version check for util-linux is done by using `rpm` to check the version of an installed util-linux RPM package. For non-RPM-based systems, the output paths will take a default value of the private directory location /run/console-login-helper-messages/issue.d. `rpm` is chosen to perform the check as the only kown consumers of console-login-helper-messages are RPM-based distributions, however support could always later be added for Debian-based or other Linux distributions.
b6196b8
to
abfced0
Compare
For now, putting this PR on hold and making the PR about the util-linux version check rather than just the issuegen code tidyups, due to #7 (comment). Bringing forward the same issuegen tidyups in #43 - let's do the review there |
For the same reason as in coreos#39 (copying the phrasing below): With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. Instead, write the intermediate output to a variable before writing to the final output file. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
For the same reason as in coreos#39 (copying the phrasing below): With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. Instead, write the intermediate output to a variable before writing to the final output file. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. A bug reported in `issuegen` for this reason is: coreos#35 Instead, write the intermediate output to a unique tempfile and mv the tempfile to the final output location. If the final output is on the same filesystem as the tempfile, this operation should be atomic. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. A bug reported in `issuegen` for this reason is: coreos#35 Instead, write the intermediate output to a unique tempfile and mv the tempfile to the final output location. If the final output is on the same filesystem as the tempfile, this operation should be atomic. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
For the same reason as in coreos#39 (copying the phrasing below): With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. Instead, write the intermediate output to a variable before writing to the final output file. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. A bug reported in `issuegen` for this reason is: coreos#35 Instead, write the intermediate output to a unique tempfile and mv the tempfile to the final output location. If the final output is on the same filesystem as the tempfile, this operation should be atomic. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. A bug reported in `issuegen` for this reason is: coreos#35 Instead, write the intermediate output to a unique tempfile and mv the tempfile to the final output location. If the final output is on the same filesystem as the tempfile, this operation should be atomic. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. A bug reported in `issuegen` for this reason is: coreos#35 Instead, write the intermediate output to a unique tempfile and mv the tempfile to the final output location. If the final output is on the same filesystem as the tempfile, this operation should be atomic. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. A bug reported in `issuegen` for this reason is: coreos#35 Instead, write the intermediate output to a unique tempfile and mv the tempfile to the final output location. If the final output is on the same filesystem as the tempfile, this operation should be atomic. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. A bug reported in `issuegen` for this reason is: coreos#35 Instead, write the intermediate output to a unique tempfile and mv the tempfile to the final output location. If the final output is on the same filesystem as the tempfile, this operation should be atomic. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. A bug reported in `issuegen` for this reason is: coreos#35 Instead, write the intermediate output to a unique tempfile and mv the tempfile to the final output location. If the final output is on the same filesystem as the tempfile, this operation should be atomic. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
With the `staged` file shared, there would be potential for two or more processes executing `motdgen` to write to it resulting in corrupted output, or the error in the `cat` command due to missing file reported in coreos#35 (comment). Currently, this is not a problem with motdgen, but could be if `motdgen` were invoked by something like the udev rules that invoke `issuegen`. A bug reported in `issuegen` for this reason is: coreos#35 Instead, write the intermediate output to a unique tempfile and mv the tempfile to the final output location. If the final output is on the same filesystem as the tempfile, this operation should be atomic. This ensures only valid output is written to the issue file shown to the terminal. Additionally, perform code tidyups similar to those done for `issuegen` in coreos#40.
The work in this PR is continued in #76. I created the new PR since the repo changed quite a bit since, and it would be quite a pain to resolve all the conflicts. Thanks Robert for the helpful comments. |
Closing for now. |
Builds on #36, with more general tidyups to the issuegen code. This is prep for more general work for #7 .