Amanda-2.6.1

Amanda::Util


NAME

Amanda::Util - Runtime support for Amanda applications


Application Initialization

Application initialization generally looks like this:

  use Amanda::Config qw( :init );
  use Amanda::Util qw( :constants );
  use Amanda::Debug;
  Amanda::Util::setup_application("myapp", "server", $CONTEXT_CMDLINE);
  # .. command-line processing ..
  Amanda::Config::config_init(...);
  Amanda::Util::finish_setup($RUNNING_AS_DUMPUSER);
setup_application($name, $type, $context)

Set up the operating environment for an application, without requiring any configuration.

$name is the name of the application, used in log messages, etc. $type is usualy one of ``server'' or ``client''. It specifies the subdirectory in which debug logfiles will be created. $context indicates the usual manner in which this application is invoked; one of $CONTEXT_CMDLINE for a user-invoked command-line utility (e.g., amadmin) which should send human-readable error messages to stderr; $CONTEXT_DAEMON for a program started by amandad, e.g., sendbackup; or $CONTEXT_SCRIPTUTIL for a small program used from shell scripts, e.g., amgetconf

Based on $type and $context, this function does the following:

finish_setup($running_as_flags)

Perform final initialization tasks that require a loaded configuration. Specifically, move the debug log into a configuration-specific subdirectory, and check that the current userid is appropriate for this applciation.

The user is specified by one of the following flags, which are available in export tag :check_running_as_flags:

  $RUNNING_AS_ANY                 # any user is OK
  $RUNNING_AS_ROOT                # root
  $RUNNING_AS_DUMPUSER            # dumpuser, from configuration
  $RUNNING_AS_DUMPUSER_PREFERRED  # dumpuser, but client_login is OK too
  $RUNNING_AS_CLIENT_LOGIN        # client_login (--with-user at build time)

If the flag $RUNNING_AS_UID_ONLY is bit-or'd into $running_as_flags, then the euid is ignored; this is used for programs that expect to be setuid-root.

get_original_cwd()

Return the original current directory with get_original_cwd.


Miscellaneous Utilities

safe_env()

Return a ``safe'' environment hash. For non-setuid programs, this means filtering out any localization variables.

quote_string($str)

Quote a string using Amanda's quoting algorithm. Strings with no whitespace, control, or quote characters are returned unchanged. An empty string is represented as the two-character string "". Otherwise, tab, newline, carriage return, form-feed, backslash, and double-quote (") characters are escaped with a backslash and the string is surrounded by double quotes.

unquote_string($str)

Unquote a string as quoted with quote_string.

skip_quoted_string($str)

my($q, $remaider) = skip_quoted_string($str)

Return the first quoted string and the remainder of the string.

Both quote_string, unquote_string and skip_quoted_string are available under the export tag :quoting.

generate_timestamp()

Generate a timestamp from the current time, obeying the 'USETIMESTAMPS' config parameter. The Amanda configuration must already be loaded.


ABOUT THIS PAGE

This page was automatically generated Fri Feb 5 19:41:21 2010 from the Amanda source tree, and documents the most recent development version of Amanda. For documentation specific to the version of Amanda on your system, use the 'perldoc' command.


Amanda-2.6.1