java.lang.Object
com.aoindustries.aoserv.daemon.posix.ShadowFile
Manages access to the
/etc/shadow
file.- Author:
- AO Industries, Inc.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Represents one line of the/etc/shadow
file on a POSIX server. -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
buildShadowFile
(Set<User.Name> usernames) Builds a new version of the shadow file with necessary adjustments made.getEncryptedPassword
(User.Name username) Gets the encrypted password for one user on the system include thechangeDate
, if known.static void
setEncryptedPassword
(User.Name username, String encryptedPassword, Integer newChangedDate) Sets the encrypted password for one user on the system.static void
setPassword
(User.Name username, String plaintext, PosixFile.CryptAlgorithm cryptAlgorithm, boolean updateChangedDate) Sets the password for one user on the system.static void
writeShadowFile
(byte[] newContents, Set<PosixFile> restorecon) Must holdshadowLock
.
-
Field Details
-
shadowLock
Locks the shadow file for updates.
-
-
Method Details
-
getEncryptedPassword
public static Tuple2<String,Integer> getEncryptedPassword(User.Name username) throws IOException, SQLException Gets the encrypted password for one user on the system include thechangeDate
, if known.If there is no entry for the user in the shadow file, returns
(
.User.NO_PASSWORD_CONFIG_VALUE
, null)- Throws:
IOException
SQLException
-
writeShadowFile
public static void writeShadowFile(byte[] newContents, Set<PosixFile> restorecon) throws SQLException, IOException Must holdshadowLock
.- Throws:
SQLException
IOException
-
buildShadowFile
Builds a new version of the shadow file with necessary adjustments made.Must hold
shadowLock
.- Throws:
IOException
-
setEncryptedPassword
public static void setEncryptedPassword(User.Name username, String encryptedPassword, Integer newChangedDate) throws IOException, SQLException Sets the encrypted password for one user on the system. This password must already behashed
.This method is synchronized with
doRebuild
to ensure that passwords are never lost during updates.- Parameters:
newChangedDate
- The new changeDate ornull
to not alter- Throws:
IOException
SQLException
- See Also:
-
setPassword
public static void setPassword(User.Name username, String plaintext, PosixFile.CryptAlgorithm cryptAlgorithm, boolean updateChangedDate) throws IOException, SQLException Sets the password for one user on the system.- Throws:
IOException
SQLException
-