untermud/DOC/
untermud/DOC/U/
untermud/DOC/U/U-examples/
untermud/DOC/internals/
untermud/DOC/wizard/
untermud/MISC/
untermud/MISC/dbchk/
untermud/RWHO/
untermud/RWHO/rwhod/
/*
    Copyright (C) 1991, Marcus J. Ranum. All rights reserved.
*/

/* configure all options BEFORE including system stuff. */
#include    "config.h"
#include    "mud.h"
#include    "match.h"
#include    "vars.h"

/*
set passwords
*/

/* ARGSUSED */
int cmd_password (int argc, char *argv[], char *who, char *aswho)
{
  char pbuf[MAXOID];
  int wiz;
  char *opw;

  if ((wiz = ut_flagged (aswho, var_wiz)) == 0 && !ut_isobjown (aswho, who)) {
    say (who, "not owner.\n", (char *) 0);
    return (UERR_PERM);
  }

  if ((opw = ut_getatt (who, 0, typ_str, var_pass, (char *) 0)) == (char *) 0)
    return (UERR_NONE);

  /* if there is already no password, farg it */
  if (*opw != '\0' && !wiz) {
    rot_init (who);
    rot_decode (opw, pbuf);
    if (strcmp (argv[1], pbuf)) {
      say (who, "bad password.\n", (char *) 0);
      return (UERR_PERM);
    }
  }

  if (strlen (argv[2]) < 6) {
    say (who, "passwords must be longer than 6 characters.\n", (char *) 0);
    return (UERR_PERM);
  }

  if (ut_setpass (who, argv[2])) {
    say (who, "cannot set password.\n", (char *) 0);
    return (UERR_FATAL);
  }
  say (who, "set password.\n", (char *) 0);
  return (UERR_NONE);
}




/* ARGSUSED */
int cmd__password (int argc, char *argv[], char *who, char *aswho)
{
  char ob[MAXOID];

  if (matchlocal (who, argv[1], ut_loc (who),
      MTCH_UNIQ | MTCH_MEOK | MTCH_NONLOC, ob))
    return (UERR_NOMATCH);
  if (ut_setpass (ob, argv[2])) {
    say (who, "cannot set password.\n", (char *) 0);
    return (UERR_FATAL);
  }
  return (UERR_NONE);
}