/* PIPServer - A deamon for finger protocol v2 * * Copyright (C) 1999 Michael Baumer * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include #ifdef HAVE_PATHS_H #include #endif /* HAVE_PATHS_H */ #include #include #include #include #include "finger.h" #include "parser.h" #include "local_user.h" #include "statusdb.h" #include "in.fingerd.h" /* answer to a login request * * subpackets: the username * the unencypted password * * todo: check permission of requesting party */ void login_handler(Node *node) { Node *subnode; char *username = NULL; char *passwd = NULL; char *hostname = NULL; char *tmp; login_info *linfo, *current; time_t idle; fprintf(stdout, "\n"); if (node->child) { subnode = node->child; while(subnode) { if (!strcmp(subnode->id, "user")) { username = subnode->value; /* entspace it */ while (*username && isspace(*username)) username++; tmp = username + strlen(username) - 1; while((tmp >= username) && (isspace(*tmp))) { *tmp = '\0'; tmp--; } } else if (!strcmp(subnode->id, "passwd")) { passwd = subnode->value; } else if (!strcmp(subnode->id, "hostname")) { hostname = subnode->value; } subnode = subnode->next; } } if ((!passwd) || (!username)) { /* this must be an error */ fprintf(stdout, "Username or Password missing\n"); } else { /* search for that login */ if (!hostname) hostname = conn.hostname; switch (db_login(username, passwd, hostname)) { case -1: fprintf(stdout, "Wrong username or password\n"); break; case 0: fprintf(stdout, "Internal error\n"); break; case 1: fprintf(stdout, "Login Sucessful\n"); break; } } fprintf(stdout, "\n"); }