-
Notifications
You must be signed in to change notification settings - Fork 17
commands: handle /usr/etc/nsswitch.conf #148
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
Conversation
sambacc/textfile.py
Outdated
|
|
||
| def write(self) -> None: | ||
| tpath = self._tmp_path(self.path) | ||
| def write(self, path: typing.Optional[str] = None) -> None: |
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.
Most of this patch looks OK to me, but this part I find a bit confusing. The path is provided to the object at initialization time, and then again (optionally) here - that seems redundant to me.
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.
On systems where this matters, /usr is typically read-only. Any changes to the config files in /usr/etc are written to /etc and prioritized over the ones in /usr/etc. This change allows us to write the contents of the read-in (and modified) file back out to a different location. When the path is unspecified, the existing behavior is preserved.
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.
OK, I see that. I am not thrilled by that aspect of the api though. However, I can see how other changes, like copying the content from one NameServiceSwitchLoader to another is probably more of a hassle. Maybe change the name of the new argument to alternate_path will be a little more self-documenting and ease my concerns.
There's also a formatting failure in the test suite. You should be able to simply run tox exec -e formatting -- black . to have the pinned version of black fix it for you.
|
I'd like to see this move forward. Do you think you'll have time soon to fix the tests? (and maybe rename that argument :-) ) Thanks! |
|
@jeffmahoney ping ^ |
On some newer OS releases, standard config files are installed in
/usr/etc with site changes to copies in /etc.
That results in the following startup failure:
Traceback (most recent call last):
File "/usr/bin/samba-container", line 8, in <module>
sys.exit(main())
^^^^^^
File "sambacc/commands/main.py", line 231, in main
cfunc(CommandContext(cli))
File "sambacc/commands/run.py", line 75, in run_container
init_container(ctx)
File "sambacc/commands/initialize.py", line 116, in init_container
cmds[step_name].cmd_func(ctx)
File "sambacc/commands/initialize.py", line 38, in _import_nsswitch
nss.read()
File "sambacc/textfile.py", line 28, in read
with open(self.path) as f:
^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/etc/nsswitch.conf'
This changes the initialization so that we fall back to reading from
/usr/etc/nsswitch.conf if reading from /etc/nsswitch.conf fails but still
write out any changes to /etc/nsswitch.conf.
Signed-off-by: Jeff Mahoney <[email protected]>
|
Ack. Changes made and tox run. Rebased on current HEAD to get rid of that merge commit. |
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.
lgtm, thanks
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.
ACK
On some newer OS releases, standard config files are installed in /usr/etc with site changes to copies in /etc.
That results in the following startup failure:
Traceback (most recent call last):
File "/usr/bin/samba-container", line 8, in
sys.exit(main())
^^^^^^
File "sambacc/commands/main.py", line 231, in main
cfunc(CommandContext(cli))
File "sambacc/commands/run.py", line 75, in run_container
init_container(ctx)
File "sambacc/commands/initialize.py", line 116, in init_container
cmds[step_name].cmd_func(ctx)
File "sambacc/commands/initialize.py", line 38, in _import_nsswitch
nss.read()
File "sambacc/textfile.py", line 28, in read
with open(self.path) as f:
^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/etc/nsswitch.conf'
This changes the initialization so that we fall back to reading from /usr/etc/nsswitch.conf if reading from /etc/nsswitch.conf fails but still write out any changes to /etc/nsswitch.conf.