summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--user.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/user.c b/user.c
index 9eaa7e1..831ee4a 100644
--- a/user.c
+++ b/user.c
@@ -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);