diff options
author | Jakob Kaivo <jkk@ungol.org> | 2020-04-01 15:33:09 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ungol.org> | 2020-04-01 15:33:09 -0400 |
commit | f4fefef930aa03f0ad63a2ef4bad1cde5717b62d (patch) | |
tree | 9b957e6b1dec42f2a32bb101516f41e143b253d5 | |
parent | cbd712a43b8702517a1b4cbe50df6a0b8a39bae6 (diff) |
provide space for gecos and password, set missing password to "--"
-rw-r--r-- | user.c | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -25,6 +25,7 @@ #define _POSIX_C_SOURCE 200809L #include <fcntl.h> #include <dirent.h> +#include <limits.h> #include <pwd.h> #include <stdint.h> #include <stdio.h> @@ -33,13 +34,17 @@ #include <sys/stat.h> #include <unistd.h> +#ifndef LINE_MAX +#define LINE_MAX _POSIX2_LINE_MAX +#endif + #define USERS_DIRECTORY "/var/secure/users" static DIR *users_dir = NULL; struct user { struct passwd pw; - char *gecos; - char *password; + char gecos[LINE_MAX]; + char password[LINE_MAX]; }; enum selection { UID, NAME, ALL }; @@ -62,10 +67,10 @@ static struct user *user_read(char *name) u.pw.pw_name = name; u.pw.pw_uid = st.st_uid; u.pw.pw_gid = st.st_gid; - u.pw.pw_dir = "/"; // TODO: read symlink at userfd, home - u.pw.pw_shell = "/bin/sh"; // TOOD: read symlink at userfd, shell - u.gecos = name; // TODO: read file at userfd, gecos - u.password = ""; // TODO: read file at userfd, password + u.pw.pw_dir = "/"; // TODO: read symlink at userfd, home + u.pw.pw_shell = "/bin/sh"; // TOOD: read symlink at userfd, shell + strcpy(u.gecos, name); // TODO: read file at userfd, gecos + strcpy(u.password, "--"); // TODO: read file at userfd, password close(user); |