NAME

LCFG::Utils::PasswdFile::Entry - Unix passwd file entry

VERSION

This documentation refers to LCFG::Utils::PasswdFile::Entry version 1.2.1

SYNOPSIS

use LCFG::Utils::PasswdFile::Entry;

my $entry = LCFG::Utils::PasswdFile::Entry->new_from_string(
                     "root:x:0:0:root:/root:/bin/bash");

$entry->shell("/bin/sh");

print $entry->to_string;

DESCRIPTION

This module provides an object-oriented representation of an entry in the Unix passwd file. It can parse the traditional, colon-delimited, Unix passwd file entry format. Fields can be updated and entirely new entries can also be created.

The primary purpose of this module is to be used with the LCFG::Utils::PasswdFile class.

ATTRIBUTES

name

This field represents the username. This is a read-only field, it cannot be altered.

uid

This field represents the user ID (UID). This is a read-only field, it cannot be altered.

passwd

This is the password field for the user. Note that this module does not support encrypting the password for you, that needs to be done separately.

gid

This field represents the primary group ID (gid) for the user.

gecos

This field represents the GECOS, this is typically used to record general information about the account or its user.

dir

This field represents the home directory for the user.

shell

This field represents the login shell for the user.

SUBROUTINES/METHODS

Class Methods

new

This creates a new, empty, LCFG::Utils::PasswdFile::Entry object.

new_from_string($entry)

This method parses the string which contains a Unix passwd file entry in the standard colon-separated format. The fields are then used to create a new LCFG::Utils::PasswdFile::Entry object.

This method will die if too many or too few fields are found in the string.

Instance Methods

to_string

This will take the stored values for the various fields (see above for details) and return a string in the standard colon-separated format. Any fields which have not been defined will be left empty.

equals($other)

This compares an object to another and returns a boolean which represents whether or not the contents of the two objects are identical.

compatible($other)

This compares an object to another and returns a boolean which represents whether or not the contents of the two objects are compatible. The definition of compatible is that the two objects have the same UID and username (all other fields are allowed to be different).

compare_to($other)

This method can be used to sort entries, it returns the standard values -1, 0, or 1 to signify which entry should come first. The order is based on numerically sorting on UID and then, if necessary, alphabetically sorting on username.

DEPENDENCIES

This module requires Class::Accessor, List::MoreUtils, and Readonly.

SEE ALSO

LCFG::Utils::PasswdFile, LCFG::Utils::GroupFile, LCFG::Utils::GroupFile::Entry, LCFG::Component::Auth

PLATFORMS

This is the list of platforms on which we have tested this software. We expect this software to work on any Unix-like platform which is supported by Perl.

Scientific5, Scientific6, Fedora13

BUGS AND LIMITATIONS

Please report any bugs or problems (or praise!) to bugs@lcfg.org, feedback and patches are also always very welcome.

AUTHOR

Alastair Scobie <ascobie@inf.ed.ac.uk>, Stephen Quinney <squinney@inf.ed.ac.uk>

LICENSE AND COPYRIGHT

Copyright (C) 2011 University of Edinburgh. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the terms of the GPL, version 2 or later.