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

Give more useful error message when /etc/login.defs isn't present #89

Open
Merlin04 opened this issue Oct 2, 2024 · 12 comments
Open

Give more useful error message when /etc/login.defs isn't present #89

Merlin04 opened this issue Oct 2, 2024 · 12 comments

Comments

@Merlin04
Copy link

Merlin04 commented Oct 2, 2024

Some distros (in my case, opensuse tumbleweed) don't have an /etc/login.defs - instead, it's located at /usr/etc/login.defs. If you try running regreet on a standard tumbleweed system, it panics with a generic unable to read file error, not saying what file it tried to read. Ideally, it would try the /usr path if the normal path isn't found, and if that still doesn't exist, then print an error indicating that neither file was found.

@max-ishere
Copy link
Contributor

Hmm, I looked up the man login.defs for tumbleweed:
https://manpages.opensuse.org/Tumbleweed/login_defs/login.defs.5.en.html
and even there it says the file should be at /etc.

The /etc/login.defs file defines the site-specific configuration for the shadow password suite. This file is required. Absence of this file will not prevent system operation, but will probably result in undesirable operation.

🤷 ...

Anyways I can work on fixing this one.

As for the location of the file, are you sure it only exists in /usr and not symlinked to /etc? If it is actually moved there I can add an ENV to override it's location at build time.

And considering the fact that regreet is not packaged on tumbleweeed (https://software.opensuse.org/search?q=regreet&baseproject=openSUSE%3AFactory) you have probably built it from source so I think you can test out the patch.

@max-ishere
Copy link
Contributor

max-ishere commented Oct 14, 2024

@Merlin04 can you test #91 please, there should be a warning in the logs now. You dont have to install it system wide, just run

fakegreet 'cargo r'

If the issue is resolved, I can add a build time env constant and that should resolve this one

@Merlin04
Copy link
Author

Sorry for the delay - it appears to be working, I'm getting this error in the logs when I test with #91:

2024-10-18T18:39:02.341228919-07:00 WARN regreet::sysutil: Failed to read /etc/login.defs

Maybe the man page is out of date? but it appears that the file in /etc/login.defs just doesn't exist: https://forums.opensuse.org/t/on-installing-keyd-configuration-error-unknown-item-useradd-cmd/179060/4

@max-ishere
Copy link
Contributor

Welp, at least it doesn't panic anymore. I will work on adding a const override via ENVs, should probably add an override for the default values for UID_MIN and UID_MAX because the defaults may differ across distros too?...

@max-ishere
Copy link
Contributor

@rharish101 I think the override path should allow : separated paths, this way the source can hardcode the default to be both etc and usr, but I doubt the distro maintainers would find this useful...

@max-ishere
Copy link
Contributor

@Merlin04 I pushed an update to #91, it will now try all paths from a list and this list can be overriden at compile time. So now it should work on your distro without you doing anything special.

@max-ishere
Copy link
Contributor

@Merlin04 does the 🎉 mean the issue is resolved by #91?

@Merlin04
Copy link
Author

Yeah, I think so!

@max-ishere
Copy link
Contributor

Okie

@mbekkomo
Copy link

mbekkomo commented Nov 4, 2024

In Solus, neither /etc/login.defs nor /usr/etc/login.defs exist.

@mbekkomo
Copy link

mbekkomo commented Nov 4, 2024

I just rechecked, it exists in /usr/share/defaults/etc/login.defs.

@max-ishere
Copy link
Contributor

I did a quick search and this post says its in /etc. My suspicion is that the /usr/share/defaults contains default values and is not supposed to be mutated. However it could be the same confusing path as /etc/default/grub. This is easy to verify. Can you open your /usr/share/defaults/etc/login.defs, remember the UID_MAX value and then run useradd to change it:

useradd --key UID_MIN=60001

man useradd

Then see if the override is placed into /usr or a file is created in /etc.

@Merlin04 I am assuming that for you, it would just go into /usr/etc/login.defs, but can you check too?

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

No branches or pull requests

3 participants