Start reading users from /etc/passwd

This commit is contained in:
Juhani Krekelä 2018-07-16 16:20:22 +00:00
parent ceb629a90a
commit d7840e0ccf
1 changed files with 20 additions and 3 deletions

View File

@ -135,10 +135,27 @@ ssize_t writeall(int fd, const char *buf, size_t amount) {
}
void handle_userlist(int sock) {
const char *response = "Who do you want to finger?\r\n";
if(writeall(sock, response, strlen(response)) < 0) {
log_perror("write");
// Go over users' home dirs and see if .finger-response is present
FILE *passwd = fopen("/etc/passwd", "r");
while(!feof(passwd)) {
char *line = NULL;
size_t line_length;
// FIXME: Funkiness with eof
if(getline(&line, &line_length, passwd) < 0) {
// Bail out on error
perror("getline");
free(line);
return;
}
printf("%s", line); //debg
free(line);
}
fclose(passwd);
}
void handle_query(int sock, const char *username) {