Manual:DIL Manual/set password()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:16, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

set_password()

Procedure. Sets a player's password.

set_password(pc : unitptr, pwd : string)

The password is stored the classic Unix way, hashed with crypt() with the character's name as the salt. Only the first 8 characters count: "secretpassword" and "secretpa" are the same password. The new password is kept with the character and written to disk when the player is next saved.

Only a program started in a zone with access level 0 (the fourth column of vme/etc/zonelist) can use it. What counts is the zone of the program's first template, the one that was dilcopy'd or run as a command. Elsewhere the zone log gets "attempt to violate system access security (setpassword)" and the program stops.

Parameters

Name Type Meaning
pc unitptr The player.
pwd string The new password, in plain text.

Notes

  • Players only: on an NPC, object or room the program stops with "Type error in Not a pc unit" in the zone log.
  • A null unit variable is logged ("set_password with no unit") and nothing changes; so does an empty (null) string.
  • It doesn't check the password at all. The password command in commands.zon asks twice and wants 5 to 16 characters.
  • If crypt() fails, the old password stays and vme.log says so.

Example

dilbegin new_password(pc : unitptr, pwd : string);
code
{
   if (pc.type != UNIT_ST_PC)
      return;
   if ((length(pwd) < 5) or (length(pwd) > 16))
   {
      sendtext("A password has 5 to 16 characters.<br/>", self);
      return;
   }
   log("PASSWORD: " + self.name + " changed " + pc.name + "'s password.");
   set_password(pc, pwd);
   sendtext("Password changed.<br/>", self);
}
dilend

A god sets another player's password and it is logged, as the set command does for its pwd field (set.zon).

See also