hfingerd

hhvn.uk:79
Log | Files | Refs | LICENSE

commit 38015141462c83aa88c6ca7e7b713e61453138e8
parent 1857fc0fdb233ffff4d9c6c365cf44dc24d0cf82
Author: hhvn <dev@hhvn.uk>
Date:   Sat,  5 Jun 2021 22:39:37 +0100

handler.c: implement user list

Diffstat:
Mhandler.c | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/handler.c b/handler.c @@ -13,7 +13,17 @@ extern char *planfile; void get_userlist(int fd) { - /* TODO */ + struct passwd *udata; + struct table_t *table; + char path[1024]; + + dprintf(fd, "Login\tName\n"); + while ((udata = getpwent()) != NULL) { + snprintf(path, sizeof(path), "%s/%s", udata->pw_dir, planfile); + + if (access(path, R_OK) != -1) + dprintf(fd, "%s\t%s\n", udata->pw_name, udata->pw_gecos); + } return; }