shadow-maint / shadow

Upstream shadow tree
Other
290 stars 228 forks source link

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

Closed alejandro-colomar closed 2 months ago

alejandro-colomar commented 2 months ago

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

Link: https://github.com/shadow-maint/shadow/pull/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 ## 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 ```
alejandro-colomar commented 2 months ago

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.