clear_pwd.c 978 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. /*
  13. * slapd hashed password routines
  14. *
  15. */
  16. #include <stdio.h>
  17. #include <string.h>
  18. #include <sys/types.h>
  19. #include "pwdstorage.h"
  20. int
  21. clear_pw_cmp( const char *userpwd, const char *dbpwd )
  22. {
  23. return( strcmp( userpwd, dbpwd ));
  24. }
  25. char *
  26. clear_pw_enc( const char *pwd )
  27. {
  28. /* Just return NULL if pwd is NULL */
  29. if (!pwd)
  30. return NULL;
  31. /* If the modify operation specified the "{clear}" storage scheme
  32. * prefix, we should strip it off.
  33. */
  34. if ((*pwd == PWD_HASH_PREFIX_START) && (pwd == PL_strcasestr( pwd, "{clear}" ))) {
  35. return( slapi_ch_strdup( pwd + 7 ));
  36. } else {
  37. return( slapi_ch_strdup( pwd ));
  38. }
  39. }