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

lib/chkname.[ch]: login_name_max_size(): Add function, and add missing error handling #990

Merged
merged 3 commits into from May 21, 2024

Conversation

alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented May 10, 2024

It encapsulates some logic that we may want to reuse elsewhere.

Link: #989

Prompted by @MarcinDigitic's PR.


Revisions:

v2
  • Call this function in a few places to add error handling.
$ git range-diff gh/master gh/loginnamemax loginnamemax 
1:  53067b08 = 1:  53067b08 lib/chkname.[ch]: Fix includes
2:  5c0af110 = 2:  5c0af110 lib/chkname.[ch]: login_name_max_size(): Add function
-:  -------- > 3:  2ac009ea src/login.c: main(): Use login_name_max_size()
v2b
  • Add missing include
$ git range-diff gh/master gh/loginnamemax loginnamemax 
1:  53067b08 = 1:  53067b08 lib/chkname.[ch]: Fix includes
2:  5c0af110 = 2:  5c0af110 lib/chkname.[ch]: login_name_max_size(): Add function
3:  2ac009ea ! 3:  51709012 src/login.c: main(): Use login_name_max_size()
    @@ Commit message
         Signed-off-by: Alejandro Colomar <alx@kernel.org>
     
      ## src/login.c ##
    +@@
    + 
    + #include "alloc.h"
    + #include "attr.h"
    ++#include "chkname.h"
    + #include "defines.h"
    + #include "faillog.h"
    + #include "failure.h"
     @@ src/login.c: int main (int argc, char **argv)
        }
      #ifdef RLOGIN

Signed-off-by: Alejandro Colomar <alx@kernel.org>
It encapsulates some logic that we may want to reuse elsewhere.

Link: <shadow-maint#989>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Instead of raw sysconf(_SC_LOGIN_NAME_MAX) calls, which was being used
without error handling.

Fixes: 3b7cc05 ("lib: replace `USER_NAME_MAX_LENGTH` macro")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
@alejandro-colomar alejandro-colomar changed the title lib/chkname.[ch]: login_name_max_size(): Add function lib/chkname.[ch]: login_name_max_size(): Add function, and add missing error handling May 17, 2024
Copy link
Collaborator

@ikerexxe ikerexxe left a comment

Choose a reason for hiding this comment

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

I think this is fine.

Alejandro do you want to tackle MarcinDigitic's comment in this PR?

@alejandro-colomar
Copy link
Collaborator Author

I think this is fine.

Thanks!

Alejandro do you want to tackle MarcinDigitic's comment in this PR?

Nah. I'll leave that for his PR. I left many comments there, and I guess that after we merge this he will be able to address them.

@ikerexxe ikerexxe merged commit a6eb312 into shadow-maint:master May 21, 2024
9 checks passed
@alejandro-colomar alejandro-colomar deleted the loginnamemax branch May 21, 2024 14:22
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.

None yet

3 participants