NAME

Razor2::Client::Config - Configuration management for Vipul's Razor

SYNOPSIS

# Typically used via Razor2::Client::Agent, not directly
use Razor2::Client::Agent;

my $agent = Razor2::Client::Agent->new('razor-check');
$agent->read_options() or die $agent->errstr;
$agent->do_conf()      or die $agent->errstr;

# Access configuration values
my $debuglevel = $agent->{conf}{debuglevel};

DESCRIPTION

Razor2::Client::Config handles all configuration file and identity management for the Razor2 client. It reads and writes the razor-agent.conf configuration file, resolves the razorhome directory, and manages user identity files used for authentication with Razor servers.

This module is a parent class of Razor2::Client::Agent and is not typically instantiated directly.

METHODS

read_conf($params)

Reads the Razor configuration. Resolves which config file to use (command-line override, user home, or system default), merges defaults with file values and command-line options, and stores the result in $self->{conf}.

$params is an optional hash reference of additional overrides.

Returns the configuration hash reference on success.

compute_razorconf()

Determines the path to the razor-agent.conf file. Checks the user's razorhome first (~/.razor/razor-agent.conf), then the system default (/etc/razor/razor-agent.conf). Sets $self->{razorconf} and $self->{computed_razorconf}.

write_conf($hash)

Writes configuration to the razor-agent.conf file. If $hash is not provided, reads the current file and merges with defaults.

find_home($rhome)

Resolves the razorhome directory. Search order: command-line -home option, razorhome from config file, $HOME/.razor/, config file directory. Sets $self->{razorhome}.

On VMS, uses _razor instead of .razor.

create_home($rhome)

Creates the razorhome directory at $rhome with mode 0755.

compute_identity()

Resolves the identity file path from command-line options, configuration, or the default (<razorhome>/identity). Follows symlinks.

get_ident()

Reads and returns the identity file as a hash reference with user and pass keys. Warns if the file is world-readable.

save_ident($ident)

Writes an identity hash (user, pass) to disk with mode 0600. Creates a symlink from identity to the user-specific file unless -i was specified. Falls back to file copy on systems without symlink support.

Returns the identity file path on success.

read_file($filename, $defaults, $nothash)

General-purpose config file reader. In hash mode (default), parses key = value lines into a hash reference, skipping comments. In array mode ($nothash true), returns an array reference of lines.

$defaults provides initial values that file contents override.

write_file($filename, $data, $append, $header, $lock)

Writes data to a file. Accepts a hash reference (written as key = value), array reference (one item per line), or scalar reference (raw content). Supports append mode, a header string, and advisory file locking via flock(2).

default_agent_conf()

Returns a hash reference of default agent configuration values.

default_server_conf()

Returns a hash reference of default per-server configuration values.

FILES

/etc/razor/razor-agent.conf

System-wide configuration file.

~/.razor/razor-agent.conf

Per-user configuration file (takes precedence over system config).

~/.razor/identity

Symlink to the active identity file.

~/.razor/identity-<user>

Identity file containing credentials for a registered user.

SEE ALSO

razor-agent.conf(5), Razor2::Client::Agent, Razor2::Client::Core

AUTHORS

Vipul Ved Prakash, <mail@vipul.net>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.