TDE base libraries and programs
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.8KB

  1. /*
  2. * Copyright (c) 1998 Christian Esken <esken@kde.org>
  3. * Copyright (c) 2003 Oswald Buddenhagen <ossi@kde.org>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public
  16. * License along with this program; if not, write to the Free
  17. * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. *
  19. * Copyright (C) 1998, Christian Esken <esken@kde.org>
  20. */
  21. #include "kcheckpass.h"
  22. #ifdef HAVE_ETCPASSWD
  23. /*******************************************************************
  24. * This is the authentication code for /etc/passwd passwords
  25. *******************************************************************/
  26. #include <string.h>
  27. #include <stdlib.h>
  28. AuthReturn Authenticate(const char *method,
  29. const char *login, char *(*conv) (ConvRequest, const char *))
  30. {
  31. struct passwd *pw;
  32. char *passwd;
  33. if (strcmp(method, "classic"))
  34. return AuthError;
  35. /* Get the password entry for the user we want */
  36. if (!(pw = getpwnam(login)))
  37. return AuthBad;
  38. if (!*pw->pw_passwd)
  39. return AuthOk;
  40. if (!(passwd = conv(ConvGetHidden, 0)))
  41. return AuthAbort;
  42. if (!strcmp(pw->pw_passwd, crypt(passwd, pw->pw_passwd))) {
  43. dispose(passwd);
  44. return AuthOk; /* Success */
  45. }
  46. dispose(passwd);
  47. return AuthBad; /* Password wrong or account locked */
  48. }
  49. #endif