AFS

 view release on metacpan or  search on metacpan

CHANGES  view on Meta::CPAN

 NOTICE:
 * This release does not support AFS system libraries version 3.4 or
   version 3.5
 * Two of the hash key names returned by the VLDB method "listaddrs" have
   changed in version 2.4.1 (see POD doku AFS::VLDB)
 * This release does not support any features and interfaces from
   AFSPerl "version 1"

 User-visible changes:
 * compiles with OpenAFS system libraries version 1.4.12
 * fixed method AFS::VLDB->listvldb: fixed segmentation error
 * improved Makefile.PL script for Perl 5.10.0 and "threaded PIC" libraries
 * updated example scripts for the modules AFS::VLDB and AFS::VOS
 * improved test drivers for the modules AFS::VLDB and AFS::VOS;


 Developer-visible changes:
 * convertet all VERSION variables to "dotted decimal version" with leading "v"
 * changed argument type from "int" to "string" for method AFS::VLDB->removeaddr


CHANGES  view on Meta::CPAN

 NOTICE:
 * This release does not support AFS system libraries version 3.4 or
   version 3.5
 * Two of the hash key names returned by the VLDB method "listaddrs" have
   changed in version 2.4.1 (see POD doku AFS::VLDB)
 * This release does not support any features and interfaces from
   AFSPerl "version 1"

 User-visible changes:
 * fixed method AFS::KAS->getentry: fixed return value for passwd_reuse
 * fixed method AFS::VLDB->listvldb: fixed segmentation error
 * updated example scripts for the modules AFS::KAS
 * fixed Makefile.PL to recognize Transarc/IBM system libraries


 Developer-visible changes:
 * cleaned up Makefile.PL



Version 2.6.0 (released 27 Oct 2008, revision 888)

CHANGES  view on Meta::CPAN

 User-visible changes:
 * improved several test drivers;
 * updated example scripts for the modules AFS:VOS, AFS::VLDB,
   AFS::Cell, AFS::CM, AFS::FS, AFS::BOS, and AFS::KTC_EKEY
 * improved POD documentation for AFS::FS and AFS
 * POD documentation gets installed automatically
 * fixed method AFS::VLDB->listaddrs: lists now all servers
 * fixed method AFS::VOS->listvol: returns correct name and volid when
   volume is busy
 * fixed method AFS::VOS->listvldb: returns proper "release" strings
 * improved error messages when OpenAFS configuration files are missing
 * compiles now with OpenAFS system libraries newer than 1.4.4
 * improved Makefile.PL script to avoid interactive queries


 Developer-visible changes:
 * modified initialization of the "cell" variable for "fs" functions
 * cleaned up source code and error handling for "vos" functions, "vldb"
   functions, and "bos" functions



Version 2.4.0 (released 20 Feb 2006, revision 777)

 NOTICE:
 * This release does not support AFS system libraries version 3.4 or
   version 3.5

CHANGES  view on Meta::CPAN



Version 2.2.3 (released 17 Feb 2005, revision 679)

 NOTICE:
 * This release does not support AFS system libraries version 3.4 or
   version 3.5

 User-visible changes:
 * now supports Perl "threaded" version on several platforms
 * fixed method AFS::VOS->backupsys: fixed segmentation error and
   added some error handling
 * fixed method AFS::VLDB->delentry: added some error handling


 Developer-visible changes:
 * modified AFS.xs functions "SendFile", "ReceiveFile",
   and "DoSalvage" to handle "threaded" and "unthreaded" case
 * modified AFS.xs: added dummy functions for "threaded" case
 * redesigned the computing of the VERSION numbers



CHANGES  view on Meta::CPAN

   version 3.5
 * This release does ONLY work with Perl "unthreaded" versions (this
   is true for all versions 2.2.X)

 User-visible changes:
 * improved most test drivers;
 * included checks for Perl "unthreaded" version;


 Developer-visible changes:
 * modified AFS.xs function "isafs": patched error handling




Version 2.2.1 (released 09 March 2004, revision 594)

 NOTICE: This release does not support AFS system libraries
         version 3.4 or version 3.5

 User-visible changes:

INSTALL  view on Meta::CPAN

    appreciate a note to tell me how you got on. Although I am
    particularly interested to hear about any problems you encounter
    when building the system, I would still like to hear from you even
    if you don't.

    Things I particularly would like to know

       * The Operating system name and version, e.g. SunOS 4.1.3
       * Architecture, e.g. Solaris
       * C compiler, e.g. gcc
       * Where there any warnings/errors printed by the C compiler? If so
         please send the exact output if possible.
       * The Perl version
       * The version of the AFS system libraries


KNOWN PROBLEMS
    Under SunOS, several people have encountered problems while compiling
    and installing the AFS module bundle.


INSTALL_64  view on Meta::CPAN

    appreciate a note to tell me how you got on. Although I am
    particularly interested to hear about any problems you encounter
    when building the system, I would still like to hear from you even
    if you don't.

    Things I particularly would like to know

       * The Operating system name and version, e.g. SunOS 4.1.3
       * Architecture, e.g. Solaris
       * C compiler, e.g. gcc
       * Where there any warnings/errors printed by the C compiler? If so
         please send the exact output if possible.
       * The Perl version
       * The version of the AFS system libraries


KNOWN PROBLEMS
    Under SunOS, several people have encountered problems while compiling
    and installing the AFS module bundle.


LICENCES/COPYING  view on Meta::CPAN

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

LICENCES/COPYING  view on Meta::CPAN

Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

LICENCES/COPYING  view on Meta::CPAN

    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

LICENCES/IBM-LICENCE  view on Meta::CPAN

   5. NO WARRANTY
   
   EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
   PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
   WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
   OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
   responsible for determining the appropriateness of using and
   distributing the Program and assumes all risks associated with its
   exercise of rights under this Agreement, including but not limited to
   the risks and costs of program errors, compliance with applicable
   laws, damage to or loss of data, programs or equipment, and
   unavailability or interruption of operations.
   
   6. DISCLAIMER OF LIABILITY
   
   EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
   ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
   WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
   DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED

MANIFEST  view on Meta::CPAN

examples/v2/acl/apply
examples/v2/acl/ascii2rights
examples/v2/acl/cleanacl
examples/v2/acl/copyacl
examples/v2/acl/crights
examples/v2/acl/is_clean
examples/v2/acl/modifyacl
examples/v2/acl/retrieve
examples/v2/acl/rights2ascii
examples/v2/base/constant
examples/v2/base/error_test
examples/v2/bos/addhost
examples/v2/bos/addkey
examples/v2/bos/adduser
examples/v2/bos/blockscanner
examples/v2/bos/constructor
examples/v2/bos/create
examples/v2/bos/delete
examples/v2/bos/exec
examples/v2/bos/getlog
examples/v2/bos/getrestart

MANIFEST  view on Meta::CPAN

src/afs_prototypes.h
src/BOS/BOS.pm
src/BOS/Makefile.PL
src/BOS/t/BOS.t
src/Cell/Cell.pm
src/Cell/Makefile.PL
src/Cell/t/Cell.t
src/CM/CM.pm
src/CM/Makefile.PL
src/CM/t/CM.t
src/com_err.h
src/FS/FS.pm
src/FS/Makefile.PL
src/FS/t/FS.t
src/inc/Test/Builder.pm
src/inc/Test/More.pm
src/inc/version.pm
src/inc/version/vpp.pm
src/KAS/KAS.pm
src/KAS/Makefile.PL
src/KAS/t/KAS.t

examples/README  view on Meta::CPAN



HOW TO USE THE EXAMPLES
    All scripts in "v2" are designed that you can run them without
    prior installation of the AFS module bundle.  After you have
    performed the steps "perl Makefile.pl", "make", and eventually
    "make test" you can run these test scripts.  Just step into the
    different subdirectories and run the available examples, e.g:
    
        cd AFS-2.6.4/examples/v2/base
        ./error_test


examples/v2/base/constant  view on Meta::CPAN

use strict;
use warnings;

use AFS qw (constant);

my $value;

$value = constant('PRIDEXIST'); # value = 267265
print "Value constant = $value \n";

$value = &AFS::PRIDEXIST;       # value = 267265, preferred method
print "Value function = $value \n";

$value = constant('VBUSY'); # value = 110
print "Value constant = $value \n";

$value = &AFS::VBUSY;       # value = 110, preferred method
print "Value function = $value \n";

# print "AFS::PRSUCCESS  = ",&AFS::PRSUCCESS ,"\n";
# print "AFS::PR_MAXNAMELEN  = ",&AFS::PR_MAXNAMELEN ,"\n";
# print "AFS::PR_MAXGROUPS  = ",&AFS::PR_MAXGROUPS ,"\n";
# print "AFS::PR_MAXLIST  = ",&AFS::PR_MAXLIST ,"\n";
# print "AFS::PRSIZE  = ",&AFS::PRSIZE ,"\n";
# print "AFS::COSIZE  = ",&AFS::COSIZE ,"\n";
# print "AFS::PR_SF_ALLBITS  = ",&AFS::PR_SF_ALLBITS ,"\n";
# print "AFS::PR_SF_NGROUPS  = ",&AFS::PR_SF_NGROUPS ,"\n";

examples/v2/base/error_test  view on Meta::CPAN

#!/usr/local/bin/perl

use blib;
use strict;
use warnings;

use AFS qw (error_message);

print error_message(&AFS::PRNOMORE),"\n";
print error_message(180502),"\n";
print error_message(0),"\n";
print error_message(13),"\n";

examples/v2/bos/prune  view on Meta::CPAN

elsif ($what eq 'old') {
    # warn "prune old \n";
    $ok = $bos->prune(0, 0, 1);    # delete .OLD files
}
elsif ($what eq 'core') {
    # warn "prune core \n";
    $ok = $bos->prune(0, 0, 0, 1);    # delete CORE files
}
else {
    # warn "prune nothing \n";
    $ok = $bos->prune;      # nothing specified ... give error message
}
print "Error Code: $AFS::CODE\n" if ($AFS::CODE);
#print "Status: $ok \n";

$bos->DESTROY;

examples/v2/bos/salvage  view on Meta::CPAN

my $localauth            = 0;


$ok = $bos->salvage($partition, $volume);
print "Error Code: $AFS::CODE\n" if ($AFS::CODE);
print "Something went wrong\n" unless $ok;

exit;


## some error conditions:
$ok = $bos->salvage();                            # no parameter is not allowed
$ok = $bos->salvage('/vicepz');                   # partition does not exist
$ok = $bos->salvage('/vicepa', 'does.not.exist'); # volume does not exist


($partition, $volume) = ('', '');
$all = 1;
$ok = $bos->salvage($partition, $volume, $all);
print "Error Code: $AFS::CODE\n" if ($AFS::CODE);
print "Something went wrong\n" unless $ok;

pod/v2/afsperl.pod  view on Meta::CPAN

=item * Access to the AFS structure ktc_encryptionkey

Methods that deal with encryption keys related to tokens.  See
L<AFS::KTC_EKEY>.

=item * Access to shared utility routines

Utility functions for the AFS module bundle which are not part of any
AFS command suite (i.e, the setpag command).  See L<AFS::Utils>.

=item * Access to basic AFS functions and to AFS error codes

Basic functions like raising a Perl exception when any AFS function call
fails (useful for debugging) or retrieving the status value of the last
AFS function call. See L<AFS::Base>.

=back

=head1 PREREQUISITES

=over 4

pod/v2/afsperl.pod  view on Meta::CPAN

B<David R. Boldt> - for his bug report on an undefined "typemap" entry

B<Alf Wachsmann> and B<Venkata Phani Achanta> - for their implementation
of the BOS, VOS, and VLDB modules

B<Phil Moore> - for his bug report on Itanium ia64 platform

B<Frank Burkhardt> and B<David Miller> - for their problem reports on
Perl "unthreaded" version within the Debian "unstable" distribution

B<Pierre-Yves Fontaniere> - for his configuration report for rs_aix51

B<Chaskiel M Grundman> and B<Derrick J Brashear> - for their valuable
information about threaded OpenAFS libraries

B<Russ Allbery> - for his improvements of the I<threaded case> Makefile.PL

B<Yannick Bergeron> - for his corrections for the AFS::KTC_TOKEN documentation

B<Mike Polek> - for his patch for the AFS::FS::getquota function

B<Peter Scott> - for his problem report on AFS::VOS->listvolume and
for his improvements of the AFS::FS POD documentation

pod/v2/afsperlbase.pod  view on Meta::CPAN

#------------------------------------------------------------------------------

=head1 NAME

B<AFS> - Basic functions and variables of the B<AFS> module

=head1 SYNOPSIS

   use AFS qw (
              afsok checkafs constant
              error_message raise_exception
              );

   my $acl = getacl($path);
   if (afsok) ....
   checkafs('getacl');

   $old = raise_exception(1);
   ... make some calls you want to raise exceptions for
   ... there is an error
   raise_exception($old);

   $mess = error_message($code);

   $value = constant('PRIDEXIST'); # value = 267265
   $value = &AFS::PRIDEXIST;       # value = 267265, preferred method

   if ($AFS::CODE eq "User or group doesn't exist") ....
   if ($AFS::CODE == &AFS::PRNOENT) ....

=head1 DESCRIPTION

This document describes the special variables and convenience functions
available from the AFS module.  You can convert error codes into error
messages.  It is possible to activate exception handling for the AFS
system calls.  You can retrieve the values for AFS constants.  Any
function required must by explicitly listed by the C<use> statement to be
exported into the calling package.

=head1 COMPATIBILITY

B<This release does NOT support any features and interfaces
from version 1.>

=head1 Special Variables

=over 4

=item B<$AFS::CODE>

The special variable $AFS::CODE contains the status value of the last AFS
function call. A non-zero value indicates an error occurred, while a
zero indicates success. This variable is magical. (like the $! variable)
If you reference it as a string you will get an error message, and
if you reference it as a numeric value (use the int() function or add 0 to
it) it will equal the numeric error code.

=back

=head1 EXPORTS

=head2 Standard Exports

none

=head2 Optional Exports

The following functions will be exported into your namespace if you
specifically ask that they be imported.

=over 4

=item B<checkafs(CHECKPOINT);>

Convenience function that calls die and prints an error message if
$AFS::CODE is not equal to 0. Used mainly for debugging.

=item B<if (afsok) { ... }>

Convenience function that returns true if $AFS::CODE is equal to 0

=item B<$cur_raise_flg = raise_exception([NEW]);>

If NEW is set to 1, then a Perl exception will be raised whenever
an error is returned from an AFS function call. This is used mainly for
debugging and testing.

=item B<$msg = error_message(NUM_CODE);>

Converts numeric code NUM_CODE into an error string.

=item B<$val = constant(NAME);>

Converts a constant NAME (i.e, #define) into scaler. Returns undef for
unknown constants.

=item B<$val = &AFS::CONSTANT;>

All values referenced through the constant function can be referenced as
functions in the AFS package. This is the preferred way of accessing
constants.

=back

=head1 CURRENT AUTHOR

Norbert E. Gruener E<lt>nog@MPA-Garching.MPG.deE<gt>

=head1 AUTHOR EMERITUS

pod/v2/afsperlbos.pod  view on Meta::CPAN


=item B<$ok = $bos-E<gt>delete(INSTANCE);>

=item B<$ok = $bos-E<gt>delete(\@INSTANCE);>

Deletes the entry INSTANCE from the local C<BosConfig> file.  INSTANCE
is either a scalar value or a reference to an array of instance names.

Before using this method, issue the stop method to stop the process
and set its status flag in the BosConfig file to NotRun. The delete
method fails with an error message if a process's status flag is Run.
It calls the AFS system library function I<BOZO_DeleteBnode>.

=item B<$ok = $bos-E<gt>exec(COMMAND);>

Executes the indicated COMMAND on the BOS server machine.  It calls
the AFS system library function I<BOZO_Exec>.

=item B<@logfile = $bos-E<gt>getlog(LOGFILE);>

Returns an array with the contents of the specified LOGFILE from the

pod/v2/afsperlcell.pod  view on Meta::CPAN


=item B<$dir = configdir;>

=item B<$ok = configdir(DIR);>

Gets or sets the configuration directory for an AFS server/client
machine. Default is C</usr/vice/etc>.

=item B<$cellname = expandcell(CELL);>

Expands CELL to the fully qualified cellname. Returns undef on error.

=cut

# does not work properly, return value $cell is not set properly ???

# =item B<($cell, @servers)  = getcell(INDEX [,IP]);>

# Displays the list of the database server machines that the Cache Manager
# stores in kernel memory for its home cell and foreign cells.

pod/v2/afsperlcell.pod  view on Meta::CPAN

# set to 1 then IP addresses will be returned instead of hostnames.
# Displays each database server machine's IP address rather than hostname.

=item B<($cell @servers) = getcellinfo([CELL [,IP]]);>

Gets information on CELL (default NULL) using CellServDB. If IP (default
0) is set to 1 then IP addresses will be returned instead of hostnames.

=item B<$cellname = localcell;>

Returns the cellname of the local cell. Returns undef on error.

=item B<$cellname = whichcell(PATH [,FOLLOW]);>

Returns the name of the cell in which the volume that houses PATH
resides.  Returns undef and sets CODE on error.

=item B<$cellname = wscell;>

Returns the name of the local machine's home cell.

=back

=head1 CURRENT AUTHOR

Norbert E. Gruener E<lt>nog@MPA-Garching.MPG.deE<gt>

pod/v2/afsperlfs.pod  view on Meta::CPAN


=item B<$ok = isafs(PATH [,FOLLOW]);>

Returns 1 if PATH is in AFS.

=item B<$volume = lsmount(PATH [,FOLLOW]);>

Returns the volume name for which PATH is a mount point.  The last
element in PATH must be an actual name, not a shorthand notation such
as one or two periods (. or ..).  If PATH is not a mount point or is
not in AFS it returns undef and an error code is set.

=item B<$ok = mkmount(PATH, VOLUME [, RW [, CELL]]);>

Creates a given mount point PATH for the VOLUME. If RW (default 0) is
set to 1 it creates a read/write mount point otherwise a regular mount
point.  If CELL (default NULL) is set, the cell indicator appears in the
mount point.

=item B<$ok = rmmount(PATH);>

Removes a given mount point PATH. If it was not successful it returns 0
and an error code is set.

=item B<$ok = setquota(PATH, QUOTA [,FOLLOW]);>

Sets the QUOTA (maximum possible size) of the read/write volume that
contains PATH.

=item B<@hosts = whereis(PATH [,IP [,FOLLOW]]);>

Returns the name of each file server machine housing PATH.  If IP
(default 0) is set to 1 then IP addresses will be returned instead of

pod/v2/afsperlkas.pod  view on Meta::CPAN

are essentially the same as the low-level AFS KAS APIs.  The other
methods are simply just wrappers around the KAM_* methods.  These have
been introduced in order to offer a more perlish interface :-)

=item S< >

=item B<$token = $kas-E<gt>Authenticate(UNAME, UINST, SERVICE, EKEY, STIME, ETIME [, PWEXP]);>

Returns a token for the user entry UNAME.UINST for the specified
SERVICE.  The desired ticket lifetime is specified by STIME and ETIME
(given in 5 minute intervals). This ticket is referred to as the
AuthTicket.  EKEY contains the encrypted user password and must be an
instance of AFS::KTC_EKEY.  It assumes that a connection to the
AuthServer has already been established.  Possible values for SERVICE
are

    &AFS::KA_TICKET_GRANTING_SERVICE
    &AFS::KA_MAINTENANCE_SERVICE

It calls the AFS system library function 'ka_Authenticate'

pod/v2/afsperlkas.pod  view on Meta::CPAN

    misc_auth_bytes         modification_time      modification_user
    user_expiration

It calls the AFS system library function 'KAM_GetEntry'.

=item B<($num_admins, $kasstats, $kadstats) = $kas-E<gt>getstats;>

=item B<($num_admins, $kasstats, $kadstats) = $kas-E<gt>KAM_GetStats(VERSION);>

Returns statistics about the AuthServer and its database. If VERSION
does not match that used by the server, the call returns an error
code. The return values are references to the hash tables containing
the values from the C structures C<kasstats> and C<kadstats>.  This
call requires a connection encrypted with an AdminTicket.  Possible
values for VERSION are

   &AFS::KAMAJORVERSION

It calls the AFS system library function 'KAM_Getstats'.

=item B<$token = $kas-E<gt>GetToken(SNAME, SINST, STIME, ETIME, AUTH_TOKEN [, AUTH_CELL]);>

pod/v2/afsperlkas.pod  view on Meta::CPAN

=item B<($name, $inst) = $kas-E<gt>listentry(PREV, INDX, COUNT);>

=item B<($name, $inst) = $kas-E<gt>KAM_ListEntry(PREV, INDX, COUNT);>

Returns the name and instance of an entry in the database.  It provides
a way to step through all the entries in the database. The first call
should be made with previous index PREV set to zero. The method updates
COUNT, which is an estimate of the number of entries remaining to be
returned, and INDX, which should be passed in as previous index on the
next call. A negative COUNT or a non­zero return code indicates that an
error occurred.  A zero INDX means there were no more entries. A zero
COUNT means the last entry has been returned. This call requires a
connection encrypted with an AdminTicket.  It calls the AFS system
library function 'KAM_ListEntry'.

=item B<$rkey = $kas-E<gt>randomkey;>

=item B<$rkey = $kas-E<gt>KAM_GetRandomKey;>

Returns a random DES key (an instance of AFS::KTC_EKEY) and is preferred
over a calling routine just inventing a key.  It calls the AFS system
library function 'KAM_GetRandomKey'.

=item B<$ok = $kas-E<gt>setpassword(UNAME, UINST, KVNO, NKEY);>

=item B<$ok = $kas-E<gt>KAM_SetPassword(UNAME, UINST, KVNO, NKEY);>

Sets the key NKEY and key version number KVNO of the user entry
UNAME.UINST to the given values. NKEY must be an instance of
AFS::KTC_EKEY.  This call requires a connection encrypted with an

pod/v2/afsperlktck.pod  view on Meta::CPAN

returned as an AFS::KTC_EKEY object.  It calls the AFS system library
function 'ka_StringToKey'.

=item B<CLASS METHODS>

=item S< >

=item B<$string = AFS::KTC_EKEY-E<gt>UserReadPassword(PROMPT [, REASON]);>

Prints out a PROMPT and reads a string from the terminal, turning off
echoing.  This string is returned.  On error the error message is
returned in REASON.  It calls the AFS system library function
'ka_UserReadPassword'.

=item B<ATTRIBUTES ACCESS>

=item S< >

=item B<$key-E<gt>string;>

Returns the whole encryption key as a string.

pod/v2/afsperlktct.pod  view on Meta::CPAN

requires that you already possess a TGT (method GetAuthToken).  It
calls the AFS system library function 'ka_GetServerToken'.

=item B<$token = AFS::KTC_TOKEN-E<gt>GetAdminToken(USER, EKEY, LIFE [, NEWTK [, REASON]]);>

Creates an administration token for the specified USER. It saves the
token in the memory (kernel token cache) and additionally it returns
the token.  EKEY contains the encryption key and LIFE indicates how
long the token will be valid (in seconds, given in 5 minute
intervals). If NEWTK is set to 1 (default), then the function should
get a new token if necessary.  On error the error message is returned
in REASON. USER must be an instance of AFS::KTC_PRINCIPAL and EKEY an
instance of AFS::KTC_EKEY.  It calls the AFS system library function
'ka_GetAdminToken'.

=item B<$token = AFS::KTC_TOKEN-E<gt>nulltoken;>

Returns a NULL token. This token is only for use with the KAS methods
C<AuthServerConn> and C<SingleServerConn>. Do not use it with any other
methods or functions.

pod/v2/afsperlktct.pod  view on Meta::CPAN


Undertakes all necessary steps for a complete authentication of
principal USER.  It converts the string PASSWORD (the cleartext
password) for the principal USER to an encryption key. Then it creates
a TGT token. After that it asks for a service token for service I<AFS>
with a life time of LIFE (in seconds, given in 5 minute intervals).
Finally it saves the service token in the memory (kernel token cache).

Possible values for FLAGS are C<KA_USERAUTH_VERSION> and
C<KA_USERAUTH_DOSETPAG>.  If PWEXP (default -1) is given it returns the
number of days till the password expires.  On error the error message
is returned in REASON. It calls the AFS system library function
'ka_UserAuthenticateGeneral'.

=item B<$ok = AFS::KTC_TOKEN-E<gt>ForgetAllTokens;>

Discards all of the issuer's tokens.  It calls the AFS system library
function 'ktc_ForgetAllTokens'.

=item B<$token = AFS::KTC_TOKEN-E<gt>FromString(STRING);>

src/AFS.pm  view on Meta::CPAN


# Items to export into callers namespace by default
# (move infrequently used names to @EXPORT_OK below)
@EXPORT = (@CELL, @MISC, @PTS, @CM, @ACL, @KA, @KTC);

# Other items we are prepared to export if requested
@EXPORT_OK = qw(
                raise_exception
                constant
                convert_numeric_names
                error_message
               );

@ALL = (@EXPORT, @EXPORT_OK);

# convenience functions
#sub newacl { use AFS::ACL; AFS::ACL->new(@_); }
sub newacl { require AFS::ACL; AFS::ACL->import; AFS::ACL->new(@_); }

sub newpts { AFS::PTS->_new(@_); }

src/AFS.xs  view on Meta::CPAN

#include "ppport.h"

#include <afs/param.h>
/* tired of seeing messages about TRUE/FALSE being redefined in rx/xdr.h */
#undef TRUE
#undef FALSE
#include <rx/xdr.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>
#include <stdio.h>
#include <netinet/in.h>
#include <sys/stat.h>
#undef INIT
#include <afs/stds.h>
#include <afs/afs.h>
#include <afs/vice.h>
#include <afs/venus.h>
#undef VIRTUE
#undef VICE

src/AFS.xs  view on Meta::CPAN

#define RV_CPINCR       0x020000
#define RV_NOVLDB       0x040000
#define RV_NOCLONE      0x080000
#define RV_NODEL        0x100000
#endif
#include <afs/vlserver.h>
#include <afs/volint.h>
#include <afs/cmd.h>
#include <afs/usd.h>
#include <afs/ptclient.h>
#include <afs/pterror.h>
#include <afs/print.h>
#include <afs/kauth.h>
#include <afs/kautils.h>
#include <afs/bosint.h>
#include <afs/bnode.h>
#include <afs/ktime.h>
#if defined(AFS_OLD_COM_ERR)
#include <com_err.h>
#else
#include <afs/com_err.h>
#endif
#include <des.h>

#if defined(AFS_3_4) || defined(AFS_3_5)
#else
#define int32 afs_int32
#define uint32 afs_uint32
#endif

const char *const xs_version = "AFS.xs (Version 2.6.4)";

src/AFS.xs  view on Meta::CPAN

#define AFS_ABORT 1
#define AFS_FULL  2
#define AFS_INC   3

#ifdef AFS_PTHREAD_ENV
#undef clock_haveCurrentTime
#undef clock_UpdateTime
struct clock clock_now;
#endif /* AFS_PTHREAD_ENV*/

/* error handling macros */

#define ERROR_EXIT(code) {error=(code); goto error_exit;}

#define SETCODE(code) set_code(code)
#define BSETCODE(code, msg) bv_set_code(code, msg)
#define VSETCODE(code, msg) bv_set_code(code, msg)
#define KSETCODE(code, msg) k_set_code(code, msg)
#define PSETCODE(msg) p_set_code(msg)

static int32 raise_exception = 0;

void safe_hv_store (HV* ahv,char * key ,int i ,SV * asv,int j) {
   if (! hv_store(ahv, key, i, asv, j)) {
       fprintf(stderr,"Panic ... internal error. hv_store failed.\n");
       exit(1);
   }
   return;
}

static void bv_set_code(code, msg)
    int32 code;
    const char *msg;
{
    SV *sv = get_sv("AFS::CODE", TRUE);

src/AFS.xs  view on Meta::CPAN

        }
/*      printf("BV_SET_CODE %s (%d)\n", msg, code); */
        sv_setpv(sv, (char *) msg);
    }
    SvIOK_on(sv);
}

static void p_set_code(msg)
    const char *msg;
{
    int32 code = errno;
    SV *sv = get_sv("AFS::CODE", TRUE);
    sv_setiv(sv, (IV) code);
/*   printf("P_SET_CODE %s (%d)\n", msg, code); */
    if (code == 0) {
        sv_setpv(sv, "");
    }
    else {
        char buffer[1024];
        if (raise_exception) {
            sprintf(buffer, "AFS exception: %s (%s) (%d)", msg, error_message(code), code);
            croak(buffer);
        }
/*      printf("P_SET_CODE %s (%d)\n", msg, code); */
        sprintf(buffer, "%s: %s (%d)", msg, error_message(code), code);
        sv_setpv(sv, buffer);
    }
    SvIOK_on(sv);
}

static void k_set_code(code, msg)
    int32 code;
    const char *msg;
{
    SV *sv = get_sv("AFS::CODE", TRUE);
    sv_setiv(sv, (IV) code);
/*   printf("K_SET_CODE %s (%d)\n", msg, code); */
    if (code == 0) {
        sv_setpv(sv, "");
    }
    else {
        char buffer[1024];
        if (raise_exception) {
            sprintf(buffer, "AFS exception: %s (%s) (%d)", msg, error_message(code), code);
            croak(buffer);
        }
/*      printf("K_SET_CODE %s (%d)\n", msg, code); */
        sprintf(buffer, "%s: %s (%d)", msg, error_message(code), code);
        sv_setpv(sv, buffer);
    }
    SvIOK_on(sv);
}

static void set_code(code)
    int32 code;
{
    SV *sv = get_sv("AFS::CODE", TRUE);
    if (code == -1) { code = errno; }
/*     printf("SET_CODE %d\n", code); */
    sv_setiv(sv, (IV) code);
    if (code == 0) {
        sv_setpv(sv, "");
    }
    else {
        if (raise_exception) {
            char buffer[1024];
            sprintf(buffer, "AFS exception: %s (%d)", error_message(code), code);
            croak(buffer);
        }
        sv_setpv(sv, (char *) error_message(code));
    }
    SvIOK_on(sv);
}

/* taken from openafs-1.2.9  */
/* volser/vsprocs.c          */
int set_errbuff(buffer, errcode)
    char *buffer;
    int32 errcode;
{
    /*replace by a big switch statement */
    switch (errcode) {
      case 0:
          break;
      case -1:
          sprintf(buffer, "Possible communication failure\n");
          break;
      case VSALVAGE:
          sprintf(buffer, "Volume needs to be salvaged\n");
          break;
      case VNOVNODE:
          sprintf(buffer, "Bad vnode number quoted\n");

src/AFS.xs  view on Meta::CPAN

      case VOLSERDETACH_ERROR:
          sprintf(buffer, "VOLSER: Could not detach the volume\n");
          break;
      case VOLSERILLEGAL_PARTITION:
          sprintf(buffer, "VOLSER: encountered illegal partition number\n");
          break;
      case VOLSERBAD_ACCESS:
          sprintf(buffer, "VOLSER: permission denied, not a super user\n");
          break;
      case VOLSERVLDB_ERROR:
          sprintf(buffer, "VOLSER: error detected in the VLDB\n");
          break;
      case VOLSERBADNAME:
          sprintf(buffer, "VOLSER: error in volume name\n");
          break;
      case VOLSERVOLMOVED:
          sprintf(buffer, "VOLSER: volume has moved\n");
          break;
      case VOLSERBADOP:
          sprintf(buffer, "VOLSER: illegal operation\n");
          break;
      case VOLSERBADRELEASE:
          sprintf(buffer, "VOLSER: release could not be completed\n");
          break;

src/AFS.xs  view on Meta::CPAN

    if (acode == EACCES) {
        fprintf(STDERR, "You are not authorized to perform the 'vos %s' command (%d)\n",
                astring, acode);
    }
    else {
        fprintf(STDERR, "Error in vos %s command.\n", astring);
        PrintError("", acode);
    }
    return 0;
}
/* end of error handling macros */


/* general helper functions */

static struct afsconf_dir *cdir = NULL;
static char *config_dir = NULL;

static int32 internal_GetConfigDir()
{
    if (cdir == NULL) {

src/AFS.xs  view on Meta::CPAN

            config_dir = (char *) safemalloc(strlen(AFSDIR_CLIENT_ETC_DIRPATH) + 1);
            strcpy(config_dir, AFSDIR_CLIENT_ETC_DIRPATH);
#endif
        }

        cdir = afsconf_Open(config_dir);
        if (!cdir) {
            char buffer[256];
            sprintf(buffer, "GetConfigDir: Can't open configuration directory (%s)", config_dir);
            PSETCODE(buffer);
            return errno;
        }
    }
    return 0;
}

static int32 internal_GetServerConfigDir()
{
    if (cdir == NULL) {

        if (config_dir == NULL) {

src/AFS.xs  view on Meta::CPAN

            config_dir = (char *) safemalloc(strlen(AFSDIR_SERVER_ETC_DIRPATH) + 1);
            strcpy(config_dir, AFSDIR_SERVER_ETC_DIRPATH);
#endif
        }

        cdir = afsconf_Open(config_dir);
        if (!cdir) {
            char buffer[256];
            sprintf(buffer, "GetServerConfigDir: Can't open configuration directory (%s)", config_dir);
            PSETCODE(buffer);
            return errno;
        }
    }
    return 0;
}

static int32 internal_GetCellInfo(cell, service, info)
    char *cell;
    char *service;
    struct afsconf_cell *info;
{

src/AFS.xs  view on Meta::CPAN

re_comp(register char *sp)
{
    register int c;
    register char *ep = expbuf;
    int cclcnt, numbra = 0;
    char *lastep = 0;
    char bracket[NBRA];
    char *bracketp = &bracket[0];
    static char *retoolong = "Regular expression too long";

#define	comperr(msg) {expbuf[0] = 0; numbra = 0; return(msg); }

    if (sp == 0 || *sp == '\0') {
	if (*ep == 0)
	    return ("No previous regular expression");
	return (0);
    }
    if (*sp == '^') {
	circf = 1;
	sp++;
    } else
	circf = 0;
    for (;;) {
	if (ep >= &expbuf[ESIZE - 10 /* fudge factor */])
	    comperr(retoolong);
	if ((c = *sp++) == '\0') {
	    if (bracketp != bracket)
		comperr("unmatched \\(");
	    *ep++ = CEOF;
	    *ep++ = 0;
	    return (0);
	}
	if (c != '*')
	    lastep = ep;
	switch (c) {

	case '.':
	    *ep++ = CDOT;

src/AFS.xs  view on Meta::CPAN

	case '[':
	    *ep++ = CCL;
	    *ep++ = 0;
	    cclcnt = 1;
	    if ((c = *sp++) == '^') {
		c = *sp++;
		ep[-2] = NCCL;
	    }
	    do {
		if (c == '\0')
		    comperr("missing ]");
		if (c == '-' && ep[-1] != 0) {
		    if ((c = *sp++) == ']') {
			*ep++ = '-';
			cclcnt++;
			break;
		    }
		    while (ep[-1] < c) {
			*ep = ep[-1] + 1;
			ep++;
			cclcnt++;
			if (ep >= &expbuf[ESIZE - 10 /* fudge factor */])
			    comperr(retoolong);
		    }
		}
		*ep++ = c;
		cclcnt++;
		if (ep >= &expbuf[ESIZE - 10 /* fudge factor */])
		    comperr(retoolong);
	    } while ((c = *sp++) != ']');
	    lastep[1] = cclcnt;
	    continue;

	case '\\':
	    if ((c = *sp++) == '(') {
		if (numbra >= NBRA)
		    comperr("too many \\(\\) pairs");
		*bracketp++ = numbra;
		*ep++ = CBRA;
		*ep++ = numbra++;
		continue;
	    }
	    if (c == ')') {
		if (bracketp <= bracket)
		    comperr("unmatched \\)");
		*ep++ = CKET;
		*ep++ = *--bracketp;
		continue;
	    }
	    if (c >= '1' && c < ('1' + NBRA)) {
		*ep++ = CBACK;
		*ep++ = c - '1';
		continue;
	    }
	    *ep++ = CCHR;

src/AFS.xs  view on Meta::CPAN

            return (code);
	}
	if (noAuthFlag)		/* -noauth */
	    scIndex = 0;
	else {			/* not -noauth */
	    strcpy(sname.cell, info.name);
	    sname.instance[0] = 0;
	    strcpy(sname.name, "afs");
	    code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
	    if (code) {		/* did not get ticket */
		fprintf(stderr,
			"%s: Could not get afs tokens, running unauthenticated.\n",
			funcName);
		scIndex = 0;
	    } else {		/* got a ticket */
		scIndex = 2;
		if ((ttoken.kvno < 0) || (ttoken.kvno > 256)) {
		    fprintf(stderr,
			    "%s: funny kvno (%d) in ticket, proceeding\n",
			    funcName, ttoken.kvno);
		}
	    }
	}

        char buffer[256];
	switch (scIndex) {
	case 0:
	    sc = rxnull_NewClientSecurityObject();

src/AFS.xs  view on Meta::CPAN

}

 /*sends the contents of file associated with <fd> and <blksize>  to Rx Stream 
    * associated  with <call> */
int SendFile(ufd, call, blksize)
    usd_handle_t ufd;
    register struct rx_call *call;
    long blksize;
{
    char *buffer = (char *) 0;
    afs_int32 error = 0;
    int done = 0;
    afs_uint32 nbytes;

    buffer = (char *) safemalloc(blksize);
    if (!buffer) {
        char buf[256];
        sprintf(buf, "malloc failed\n");
        VSETCODE(-1, buf);
        return -1;
    }

    while (!error && !done) {
#ifndef AFS_NT40_ENV            /* NT csn't select on non-socket fd's */
        fd_set in;
        FD_ZERO(&in);
        FD_SET((long) (ufd->handle), &in);
        /* don't timeout if read blocks */
#ifdef AFS_PTHREAD_ENV
        select(((long) (ufd->handle)) + 1, &in, 0, 0, 0);
#else
        IOMGR_Select(((long) (ufd->handle)) + 1, &in, 0, 0, 0); 
#endif /* AFS_PTHREAD_ENV*/
#endif
        error = USD_READ(ufd, buffer, blksize, &nbytes);
        if (error) {
            char buf[256];
            sprintf(buf, "File system read failed\n");
            VSETCODE(error, buf);
            break;
        }
        if (nbytes == 0) {
            done = 1;
            break;
        }
        if (rx_Write(call, buffer, nbytes) != nbytes) {
            error = -1;
            break;
        }
    }
    if (buffer)
        free(buffer);
    return error;
}

/* function invoked by UV_RestoreVolume, reads the data from rx_trx_stream and
 * writes it out to the volume. */
afs_int32 WriteData(call, rock)
    struct rx_call *call;
    char *rock;
{
    char *filename;
    usd_handle_t ufd;
    long blksize;
    afs_int32 error, code;
    int ufdIsOpen = 0;

    error = 0;

    filename = rock;
    if (!filename || !*filename) {
        usd_StandardInput(&ufd);
        blksize = 4096;
        ufdIsOpen = 1;
    }
    else {
        code = usd_Open(filename, USD_OPEN_RDONLY, 0, &ufd);
        if (code == 0) {
            ufdIsOpen = 1;
            code = USD_IOCTL(ufd, USD_IOCTL_GETBLKSIZE, &blksize);
        }
        if (code) {
            char buffer[256];
            sprintf(buffer, "Could not access file '%s'\n", filename);
            error = VOLSERBADOP;
            VSETCODE(error, buffer);
            goto wfail;
        }
    }
    code = SendFile(ufd, call, blksize);
    if (code) {
        error = code;
        goto wfail;
    }
  wfail:
    if (ufdIsOpen) {
        code = USD_CLOSE(ufd);
        if (code) {
            char buffer[256];
            sprintf(buffer, "Could not close dump file %s\n",
                    (filename && *filename) ? filename : "STDOUT");
            VSETCODE(code, buffer);
            if (!error)
                error = code;
        }
    }
    return error;
}

/* Receive data from <call> stream into file associated
 * with <fd> <blksize>
 */
int ReceiveFile(ufd, call, blksize)
    usd_handle_t ufd;
    struct rx_call *call;
    long blksize;
{
    char *buffer = (char *) 0;
    afs_int32 bytesread;
    afs_uint32 bytesleft, w;
    afs_int32 error = 0;

    buffer = (char *) safemalloc(blksize);
    if (!buffer) {
        char buf[256];
        sprintf(buf, "memory allocation failed\n");
        VSETCODE(-1, buf);
        ERROR_EXIT(-1);
    }

    while ((bytesread = rx_Read(call, buffer, blksize)) > 0) {

src/AFS.xs  view on Meta::CPAN

            fd_set out;
            FD_ZERO(&out);
            FD_SET((long) (ufd->handle), &out);
            /* don't timeout if write blocks */
#ifdef AFS_PTHREAD_ENV
            select(((long) (ufd->handle)) + 1, 0, &out, 0, 0);
#else
            IOMGR_Select(((long) (ufd->handle)) + 1, 0, &out, 0, 0); 
#endif /* AFS_PTHREAD_ENV*/
#endif
            error = USD_WRITE(ufd, &buffer[bytesread - bytesleft], bytesleft, &w);
            if (error) {
                char buf[256];
                sprintf(buf, "File system write failed\n");
                VSETCODE(-1, buf);
                ERROR_EXIT(-1);
            }
        }
    }

  error_exit:
    if (buffer)
        free(buffer);
    return (error);
}

afs_int32 DumpFunction(call, filename)
    struct rx_call *call;
    char *filename;
{
    usd_handle_t ufd;           /* default is to stdout */
    afs_int32 error = 0, code;
    afs_hyper_t size;
    long blksize;
    int ufdIsOpen = 0;

    /* Open the output file */
    if (!filename || !*filename) {
        usd_StandardOutput(&ufd);
        blksize = 4096;
        ufdIsOpen = 1;
    }

src/AFS.xs  view on Meta::CPAN

            sprintf(buffer, "Could not create file '%s'\n", filename);
            VSETCODE(VOLSERBADOP, buffer);
            ERROR_EXIT(VOLSERBADOP);
        }
    }

    code = ReceiveFile(ufd, call, blksize);
    if (code)
        ERROR_EXIT(code);

  error_exit:
    /* Close the output file */
    if (ufdIsOpen) {
        code = USD_CLOSE(ufd);
        if (code) {
            char buffer[256];
            sprintf(buffer, "Could not close dump file %s\n",
                    (filename && *filename) ? filename : "STDIN");
            VSETCODE(code, buffer);
            if (!error)
                error = code;
        }
    }

    return (error);
}

struct tqElem {
    afs_int32 volid;
    struct tqElem *next;
};

struct tqHead {
    afs_int32 count;
    struct tqElem *next;

src/AFS.xs  view on Meta::CPAN


/* keep those lines small */
static char *em(acode)
    afs_int32 acode;
{
    if (acode == -1)
        return "communications failure (-1)";
    else if (acode == -3)
        return "communications timeout (-3)";
    else
        return (char *) error_message(acode);
}

static struct rx_connection *internal_bos_new(code, hostname, localauth, noauth, aencrypt,
                                              tname)
    int32 *code;
    char *hostname;
    int localauth;
    int noauth;
    int aencrypt;
    char *tname;

src/AFS.xs  view on Meta::CPAN

        return NULL;
    }

    if (localauth)
        internal_GetServerConfigDir();
    else
        internal_GetConfigDir();
    /* printf("bos DEBUG-2: %s\n", cdir->name); */

    if (!cdir) {
        *code = errno;
        SETCODE(code);
/*         printf("bos DEBUG-4\n"); */
        return NULL;
    }

    struct afsconf_cell info;

    /* next call expands cell name abbrevs for us and handles looking up
     * local cell */
    *code = internal_GetCellInfo(tname, (char *) 0, &info);

src/AFS.xs  view on Meta::CPAN

    strcpy(sname.name, "afs");
    sc[0] = (struct rx_securityClass *) rxnull_NewClientSecurityObject();
    sc[1] = 0;
    sc[2] = (struct rx_securityClass *) NULL;
    scIndex = 0;

    if (!noauth) {              /* not -noauth */
        if (localauth) {        /* -localauth */
            *code = afsconf_GetLatestKey(cdir, 0, 0);
            if (*code)
                fprintf(stderr, "AFS::BOS %d (getting key from local KeyFile)", *code);
            else {
                if (aencrypt)
                    *code = afsconf_ClientAuthSecure(cdir, &sc[2], &scIndex);
                else
                    *code = afsconf_ClientAuth(cdir, &sc[2], &scIndex);
                if (*code)
                    fprintf(stderr, "AFS::BOS %d (calling ClientAuth)", *code);
                else if (scIndex != 2)  /* this shouldn't happen */
                    sc[scIndex] = sc[2];
            }
        }
        else {                  /* not -localauth, check for tickets */
            *code = ktc_GetToken(&sname, &ttoken, sizeof(ttoken), NULL);
            if (*code == 0) {
                /* have tickets, will travel */
                if (ttoken.kvno >= 0 && ttoken.kvno <= 256);
                else {
                    fprintf(stderr,
                            "AFS::BOS: funny kvno (%d) in ticket, proceeding\n",
                            ttoken.kvno);
                }
                /* kerberos tix */
                if (aencrypt)
                    encryptLevel = rxkad_crypt;
                else
                    encryptLevel = rxkad_clear;
                sc[2] = (struct rx_securityClass *)
                    rxkad_NewClientSecurityObject
                    (encryptLevel, &ttoken.sessionKey,
                     ttoken.kvno, ttoken.ticketLen, ttoken.ticket);
                scIndex = 2;
            }
            else
                fprintf(stderr, "AFS::BOS %d (getting tickets)", *code);
        }
        if ((scIndex == 0) || (sc[scIndex] == 0)) {
            fprintf(stderr, "AFS::BOS: running unauthenticated\n");
            scIndex = 0;
        }
    }
    tconn = rx_NewConnection(addr, htons(AFSCONF_NANNYPORT), 1, sc[scIndex], scIndex);
    if (!tconn) {
        char buffer[256];
        sprintf(buffer, "AFS::BOS: could not create rx connection\n");
        *code = -1;
        BSETCODE(code, buffer);
/*         printf("bos DEBUG-7\n"); */

src/AFS.xs  view on Meta::CPAN

        if (istatus.fileGoal)
            sprintf(info, "%s", "temporarily disabled");
        else
            sprintf(info, "%s", "temporarily enabled");
    }
    safe_hv_store(stats, "info", 4, newSVpv(info, strlen(info)), 0);
    safe_hv_store(stats, "goal", 4, newSViv(istatus.goal), 0);
    safe_hv_store(stats, "fileGoal", 8, newSViv(istatus.fileGoal), 0);

    if (istatus.flags & BOZO_ERRORSTOP) {
        /* printf("stopped for too many errors, "); */
        safe_hv_store(stats, "status", 6, newSViv(BOZO_ERRORSTOP), 0);
    }
    if (istatus.flags & BOZO_HASCORE) {
        /* printf("has core file, "); */
        safe_hv_store(stats, "status", 6, newSViv(BOZO_HASCORE), 0);
    }
    safe_hv_store(stats, "flags", 5, newSViv(istatus.flags), 0);

    tp = buffer;
    code = BOZO_GetStatus(aconn, aname, &temp, &tp);

src/AFS.xs  view on Meta::CPAN

        /*        DateOf(istatus.procStartTime), istatus.procStarts); */
        safe_hv_store(stats, "procStartTime", 13, newSViv(istatus.procStartTime), 0);
        safe_hv_store(stats, "procStarts", 10, newSViv(istatus.procStarts), 0);
    }
    if (istatus.lastAnyExit) {
        /* printf("    Last exit at %s\n", DateOf(istatus.lastAnyExit)); */
        safe_hv_store(stats, "lastAnyExit", 11, newSViv(istatus.lastAnyExit), 0);
    }
    if (istatus.lastErrorExit) {
        is1 = is2 = is3 = is4 = (char *) 0;
        /* printf("    Last error exit at %s, ", DateOf(istatus.lastErrorExit)); */
        safe_hv_store(stats, "lastErrorExit", 13, newSViv(istatus.lastErrorExit), 0);
        code = BOZO_GetInstanceStrings(aconn, aname, &is1, &is2, &is3, &is4);
        /* don't complain about failing call, since could simply mean
         * interface mismatch.
         */
        if (code == 0) {
            if (*is1 != 0) {
                /* non-null instance string */
                /* printf("by %s, ", is1); */
                safe_hv_store(stats, "by", 2, newSVpv(is1, strlen(is1)), 0);
            }
            if (is1)
                free(is1);
            if (is2)
                free(is2);
            if (is3)
                free(is3);
            if (is4)
                free(is4);
        }
        if (istatus.errorSignal) {
            /* if (istatus.errorSignal == SIGTERM) */
            /*    printf("due to shutdown request\n"); */
            /* else */
            /*    printf("due to signal %d\n", istatus.errorSignal); */
            safe_hv_store(stats, "errorSignal", 11, newSViv(istatus.errorSignal), 0);
        }
        else {
            /* printf("by exiting with code %d\n", istatus.errorCode); */
            safe_hv_store(stats, "errorCode", 9, newSViv(istatus.errorCode), 0);
        }
    }

    if (aint32p > 1) {
        AV *av = (AV *) sv_2mortal((SV *) newAV());

        /* try to display all the parms */
        for (i = 0;; i++) {
            tp = buffer;
            code = BOZO_GetInstanceParm(aconn, aname, i, &tp);
            if (code)
                break;
            /* fprintf(stderr, "    Command %d is '%s'\n", i+1, buffer); */
            av_push(av, newSVpv(buffer, strlen(buffer)));
        }
        safe_hv_store(stats, "command", 7, newRV_inc((SV *) (av)), 0);

        tp = buffer;
        code = BOZO_GetInstanceParm(aconn, aname, 999, &tp);
        if (!code) {
            /* Any type of failure is treated as not having a notifier program */
            /* printf("    Notifier  is '%s'\n", buffer); */
            safe_hv_store(stats, "notifier", 8, newSVpv(buffer, strlen(buffer)), 0);

src/AFS.xs  view on Meta::CPAN

        partNumber = volutil_GetPartitionID(aparm1);
        if (partNumber < 0) {
            char buffer[256];
            sprintf(buffer, "AFS::BOS: could not parse partition ID '%s'\n", aparm1);
            BSETCODE(EINVAL, buffer);
            return EINVAL;
        }
        tp = (char *) volutil_PartitionName(partNumber);
        if (!tp) {
            char buffer[256];
            sprintf(buffer, "AFS::BOS: internal error parsing partition ID '%s'\n",
                    aparm1);
            BSETCODE(EINVAL, buffer);
            return EINVAL;
        }
        strcpy(partName, tp);
    }
    else
        partName[0] = 0;

    /* open the file name */

src/AFS.xs  view on Meta::CPAN

    while (1) {
#ifdef AFS_PTHREAD_ENV
        sleep(5);
#else
        IOMGR_Sleep(5);
#endif /* AFS_PTHREAD_ENV*/
        tp = tbuffer;
        code = BOZO_GetInstanceInfo(aconn, "salvage-tmp", &tp, &istatus);
        if (code)
            break;
        /* fprintf(stderr, "AFS::BOS: waiting for salvage to complete.\n"); */
    }
    if (code != BZNOENT) {
        char buffer[256];
        sprintf(buffer, "AFS::BOS: salvage failed (%s)\n", em(code));
        BSETCODE(code, buffer);
        goto done;
    }
    code = 0;

    /* now print the log file to the output file */
    /* fprintf(stderr, "AFS::BOS: salvage completed\n"); */
    if (aoutName || showlog) {
        fprintf(outFile, "SalvageLog:\n");
        tcall = rx_NewCall(aconn);
        /* MUST pass canonical (wire-format) salvager log path to bosserver */
        code = StartBOZO_GetLog(tcall, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH);
        if (code) {
            rx_EndCall(tcall, code);
            goto done;
        }
        /* copy data */

src/AFS.xs  view on Meta::CPAN

    struct ViceIoctl vi;
    register int32 code;
    char space[MAXSIZE];

    vi.in_size = 0;
    vi.out_size = MAXSIZE;
    vi.out = space;

    code = pioctl(path, VIOC_FILE_CELL_NAME, &vi, follow);
    if (code) {
        if ((errno == EINVAL) || (errno == ENOENT))
            return 0;
        if (errno == ENOSYS)
            return 0;
    }
    return 1;
}

static char *format_rights(rights)
    int32 rights;
{
    static char buff[32];
    char *p;

src/AFS.xs  view on Meta::CPAN

            printf("Trying %s (port %d):\n", inet_ntoa(hostAddr), ntohs(port_num));

        s = socket(AF_INET, SOCK_DGRAM, 0);
        taddr.sin_family = AF_INET;
        taddr.sin_port = 0;
        taddr.sin_addr.s_addr = 0;

        code = bind(s, (struct sockaddr *) &taddr, sizeof(struct sockaddr_in));
        SETCODE(code);
        if (code) {
            perror("bind");
            XSRETURN_UNDEF;
        }

        code = rx_GetServerVersion(s, host, port_num, length, version);
        ST(0) = sv_newmortal();
        if (code < 0) {
            SETCODE(code);
        }
        else {
            sv_setpv(ST(0), version);

src/AFS.xs  view on Meta::CPAN


int32
fs_isafs(path,follow=1)
        char *  path
        int32   follow
    CODE:
    {
        int32 code;
        RETVAL = isafs(path, follow);
        if (!RETVAL)
            code = errno;
        else
            code = 0;
        SETCODE(code);
    }
    OUTPUT:
        RETVAL

int32
fs_cm_access(path,perm="read",follow=1)
        char *  path

src/AFS.xs  view on Meta::CPAN

        XSRETURN(1);
    }

int32
vos_release(cstruct, name, force=Nullsv)
        AFS::VOS cstruct
        char *name
        SV *  force
    PREINIT:
        struct nvldbentry entry;
        afs_int32 avolid, aserver, apart, vtype, code, err;
        int iforce;
    CODE:
    {
        if (!force) {
            force = newSViv(0);
        }
        if (!SvIOKp(force)) {
            char buffer[256];
            sprintf(buffer, "Flag \"force\" should be numeric.\n");
            VSETCODE(EINVAL, buffer);
            XSRETURN_UNDEF;
        }
        iforce = SvIV(force);
        RETVAL = 0;
        avolid = vsu_GetVolumeID(name, cstruct, &err);
        if (avolid == 0) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "AFS::VOS: can't find volume '%s'\n", name);
            VSETCODE(err ? err : ENOENT, buffer);
            goto done;
        }
        code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
        if (code) {
            SETCODE(code);
            goto done;
        }
        if (vtype != RWVOL) {
            char buffer[256];
            sprintf(buffer, "%s not a RW volume\n", name);

src/AFS.xs  view on Meta::CPAN

        pnum = volutil_GetPartitionID(partition);
        if (pnum < 0) {
            char buffer[256];
            sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", partition);
            VSETCODE(ENOENT, buffer);
            goto done;
        }
        if (!IsPartValid(pnum, tserver, &code)) {      /*check for validity of the partition */
            char buffer[256];
            if (code)
                set_errbuff(buffer, code);
            else
                sprintf(buffer, "AFS::VOS: partition %s does not exist on the server\n",
                        partition);
            VSETCODE(code ? code : ENOENT, buffer);
            goto done;
        }
        if (!ISNAMEVALID(name)) {
            char buffer[256];
            sprintf(buffer,
                    "AFS::VOS: the name of the root volume %s exceeds the size limit of %d\n",

src/AFS.xs  view on Meta::CPAN

        ;
    }
    OUTPUT:
        RETVAL

int32
vos_backup(cstruct, name)
        AFS::VOS cstruct
        char *name
    PREINIT:
        int32 avolid, aserver, apart, vtype, code, err;
        int32 buvolid, buserver, bupart, butype;
        struct nvldbentry entry;
        struct nvldbentry buentry;
    CODE:
    {
        RETVAL = 0;
        avolid = vsu_GetVolumeID(name, cstruct, &err);
        if (avolid == 0) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "AFS::VOS: can't find volume ID or name '%s'\n", name);
            VSETCODE(err ? err : ENOENT, buffer);
            goto done;
        }
        code = GetVolumeInfo(avolid, &aserver, &apart, &vtype, &entry);
        if (code) {
            SETCODE(code);
            goto done;
        }
                /* verify this is a readwrite volume */

        if (vtype != RWVOL) {

src/AFS.xs  view on Meta::CPAN

        if (entry.flags & BACK_EXISTS) {
            /* yep, where is it? */

            buvolid = entry.volumeId[BACKVOL];
            code = GetVolumeInfo(buvolid, &buserver, &bupart, &butype, &buentry);
            if (code) {
                SETCODE(code);
                goto done;
            }
            /* is it local? */
            code = VLDB_IsSameAddrs(buserver, aserver, &err);
            if (err) {
                char buffer[256];
                sprintf(buffer,
                        "Failed to get info about server's %d address(es) from vlserver; aborting call!\n",
                        buserver);
                VSETCODE(err, buffer);
                goto done;
            }
            if (!code) {
                char buffer[256];
                sprintf(buffer, "FATAL ERROR: backup volume %u exists on server %u\n",
                        buvolid, buserver);
                VSETCODE(-1, buffer);
                goto done;
            }
        }

src/AFS.xs  view on Meta::CPAN

    OUTPUT:
        RETVAL

int32
vos_remove(cstruct, name, servername=NULL, parti=NULL)
        AFS::VOS cstruct
        char *name
        char *servername
        char *parti
    PREINIT:
        afs_int32 err, code = 0;
        afs_int32 server = 0, partition = -1, volid;
        afs_int32 idx, j;
    CODE:
    {
        RETVAL = 0;
        if (servername && strlen(servername) != 0) {
            server = GetServer(servername);
            if (!server) {
                char buffer[256];
                sprintf(buffer, "AFS::VOS: server '%s' not found in host table\n", servername);

src/AFS.xs  view on Meta::CPAN

                char buffer[256];
                sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", parti);
                VSETCODE(EINVAL, buffer);
                goto done;
            }

            /* Check for validity of the partition */
            if (!IsPartValid(partition, server, &code)) {
                char buffer[256];
                if (code)
                    set_errbuff(buffer, code);
                else
                    sprintf(buffer, "AFS::VOS: partition %s does not exist on the server\n",
                            parti);
                VSETCODE(ENOENT, buffer);
                goto done;
            }
        }

        volid = vsu_GetVolumeID(name, cstruct, &err);
        if (volid == 0) {
            char buffer[256];
            sprintf(buffer, "Can't find volume name '%s' in VLDB\n", name);
            if (err)
                set_errbuff(buffer, err);
            VSETCODE(ENOENT, buffer);
            goto done;
        }

            /* If the server or partition option are not complete, try to fill
             * them in from the VLDB entry.
             */
        if ((partition == -1) || !server) {
            struct nvldbentry entry;

src/AFS.xs  view on Meta::CPAN

vos__setfields(cstruct, name, mquota=Nullsv, clearuse=Nullsv)
        AFS::VOS cstruct
        char *name
        SV * mquota
        SV * clearuse
    PREINIT:
#ifdef OpenAFS
        struct nvldbentry entry;
        volintInfo info;
        int32 volid;
        int32 clear, code, err;
        int32 aserver, apart;
        int previdx = -1;
#endif
    CODE:
    {
#ifdef OpenAFS
        if (!mquota)
            mquota = newSViv(-1);
        if (!clearuse)
            clearuse = newSViv(0);

src/AFS.xs  view on Meta::CPAN

        }
        if ((!SvIOKp(clearuse))) {     /* -clearuse */
            char buffer[256];
            sprintf(buffer, "flag \"clearuse\" is not an integer\n");
            VSETCODE(EINVAL, buffer);
            goto done;
        }

        /* printf("vos-setfields DEBUG-1 name %s mquota %d clearuse %d \n", name, (int)SvIV(mquota), (int)SvIV(clearuse)); */
        RETVAL = 0;
        volid = vsu_GetVolumeID(name, cstruct, &err);   /* -id */
        if (volid == 0) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "Unknown volume ID or name '%s'\n", name);
            VSETCODE(err ? err : -1, buffer);
            goto done;
        }

        code = VLDB_GetEntryByID(volid, RWVOL, &entry);
        if (code) {
            char buffer[256];
            sprintf(buffer, "Could not fetch the entry for volume number %u from VLDB \n", volid);
            VSETCODE(code, buffer);
            goto done;
        }

src/AFS.xs  view on Meta::CPAN

        char *server
        char *partition
        char *name
        char *file
        char *id
        SV *  inter
        char *overwrite
        SV *  offline
        SV *  readonly
    PREINIT:
        afs_int32 avolid, aparentid, aserver, apart, code, vcode, err;
        afs_int32 aoverwrite = AFS_ASK;
        int restoreflags, voltype = RWVOL, ireadonly = 0, ioffline = 0;
        char afilename[NameLen], avolname[VOLSER_MAXVOLNAME +1];
        char volname[VOLSER_MAXVOLNAME +1];
        struct nvldbentry entry;
    CODE:
    {
        aparentid = 0;
        if (!inter) {
            inter = newSViv(0);

src/AFS.xs  view on Meta::CPAN

            char buffer[256];
            sprintf(buffer, "Flag \"readonly\" should be numeric.\n");
            VSETCODE(EINVAL, buffer);
            RETVAL = 0;
            goto done;
        }
        else
            ireadonly = SvIV(readonly);

        if (id && strlen(id) != 0) {
            avolid = vsu_GetVolumeID(id, cstruct, &err);
            if (avolid == 0) {
                char buffer[256];
                if (err)
                    set_errbuff(buffer, err);
                else
                    sprintf(buffer, "AFS::VOS: can't find volume '%s'\n", id);
                VSETCODE(err ? err : -1, buffer);
                RETVAL = 0;
                goto done;
            }
        }
        else
            avolid = 0;

        if (overwrite && strlen(overwrite) != 0) {
            if ((strcmp(overwrite, "a") == 0) || (strcmp(overwrite, "abort") == 0)) {
                aoverwrite = AFS_ABORT;

src/AFS.xs  view on Meta::CPAN

        if (apart < 0) {
            char buffer[256];
            sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", partition);
            VSETCODE(-1, buffer);
            RETVAL = 0;
            goto done;
        }
        if (!IsPartValid(apart, aserver, &code)) {      /*check for validity of the partition */
            char buffer[256];
            if (code)
                set_errbuff(buffer, code);
            else
                sprintf(buffer, "AFS::VOS: partition %s does not exist on the server\n",
                        partition);
            VSETCODE(code ? code : -1, buffer);
            RETVAL = 0;
            goto done;
        }
        strcpy(avolname, name);
        if (!ISNAMEVALID(avolname)) {
            char buffer[256];

src/AFS.xs  view on Meta::CPAN

            if ((aoverwrite == AFS_INC) || (aoverwrite == AFS_ABORT)) {
                char buffer[256];
                sprintf(buffer, "Volume does not exist; Will perform a full restore\n");
                VSETCODE(vcode, buffer);
            }
        }
        else if ((!ireadonly && Lp_GetRwIndex(&entry) == -1)     /* RW volume does not exist - do a full */
                 ||(ireadonly && !Lp_ROMatch(0, 0, &entry))) {   /* RO volume does not exist - do a full */
            restoreflags = RV_FULLRST;
            if ((aoverwrite == AFS_INC) || (aoverwrite == AFS_ABORT))
                fprintf(stderr, "%s Volume does not exist; Will perform a full restore\n",
                        ireadonly ? "RO" : "RW");

            if (avolid == 0) {
                avolid = entry.volumeId[voltype];
            }
            else if (entry.volumeId[voltype] != 0 && entry.volumeId[voltype] != avolid) {
                avolid = entry.volumeId[voltype];
            }
            aparentid = entry.volumeId[RWVOL];
        }

src/AFS.xs  view on Meta::CPAN

            aparentid = entry.volumeId[RWVOL];

            /* A file name was specified  - check if volume is on another partition */
            vcode = GetVolumeInfo(avolid, &Oserver, &Opart, &Otype, &Oentry);
            if (vcode) {
                SETCODE(0);
                RETVAL = 0;
                goto done;
            }

            vcode = VLDB_IsSameAddrs(Oserver, aserver, &err);
            if (err) {
                char buffer[256];
                sprintf(buffer,
                        "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
                        Oserver, err);
                VSETCODE(err, buffer);
                RETVAL = 0;
                goto done;
            }
            if (!vcode || (Opart != apart))
                vol_elsewhere = 1;

            if (aoverwrite == AFS_ASK) {
                if (strcmp(afilename, "") == 0) {       /* The file is from standard in */
                    char buffer[256];
                    sprintf(buffer,

src/AFS.xs  view on Meta::CPAN

                    goto done;
                }

                /* Ask what to do */
                if (vol_elsewhere) {
                    char buffer[256];
                    sprintf(buffer,
                            "The volume %s %u already exists on a different server/part\n",
                            volname, entry.volumeId[voltype]);
                    VSETCODE(-1, buffer);
                    fprintf(stderr, "Do you want to do a full restore or abort? [fa](a): ");
                }
                else {
                    char buffer[256];
                    sprintf(buffer, "The volume %s %u already exists in the VLDB\n",
                            volname, entry.volumeId[voltype]);
                    VSETCODE(-1, buffer);
                    fprintf(stderr,
                            "Do you want to do a full/incremental restore or abort? [fia](a): ");
                }
                dc = c = getchar();
                while (!(dc == EOF || dc == '\n'))
                    dc = getchar();     /* goto end of line */
                if ((c == 'f') || (c == 'F'))
                    aoverwrite = AFS_FULL;
                else if ((c == 'i') || (c == 'I'))
                    aoverwrite = AFS_INC;
                else

src/AFS.xs  view on Meta::CPAN


            if (aoverwrite == AFS_ABORT) {
                char buffer[256];
                sprintf(buffer, "Volume exists; Aborting restore command\n");
                VSETCODE(-1, buffer);
                RETVAL = 0;
                goto done;
            }
            else if (aoverwrite == AFS_FULL) {
                restoreflags = RV_FULLRST;
                fprintf(stderr, "Volume exists; Will delete and perform full restore\n");
            }
            else if (aoverwrite == AFS_INC) {
                restoreflags = 0;
                if (vol_elsewhere) {
                    char buffer[256];
                    sprintf(buffer,
                            "%s volume %u already exists on a different server/part; not allowed\n",
                            ireadonly ? "RO" : "RW", avolid);
                    VSETCODE(-1, buffer);
                    RETVAL = 0;

src/AFS.xs  view on Meta::CPAN

vos_dump(cstruct, id, time=NULL, file=NULL, server=NULL, partition=NULL, clone=Nullsv, omit=Nullsv)
        AFS::VOS cstruct
        char *id
        char *time
        char *file
        char *server
        char *partition
        SV *  clone
        SV *  omit
    PREINIT:
        afs_int32 avolid, aserver, apart, voltype, fromdate=0, code=0, err, i;
        char filename[NameLen];
        struct nvldbentry entry;
        afs_int32 omitdirs = 0;
    CODE:
    {
        if (!clone)
            clone = newSViv(0);
        if (!omit)
            omit = newSViv(0);
        if ((!SvIOKp(omit))) {

src/AFS.xs  view on Meta::CPAN

        rx_SetRxDeadTime(60 * 10);
        for (i = 0; i < MAXSERVERS; i++) {
            struct rx_connection *rxConn = ubik_GetRPCConn((struct ubik_client *) cstruct, i);
            if (rxConn == 0)
                break;
            rx_SetConnDeadTime(rxConn, rx_connDeadTime);
            if (rxConn->service)
                rxConn->service->connDeadTime = rx_connDeadTime;
        }

        avolid = vsu_GetVolumeID(id, cstruct, &err);
        if (avolid == 0) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "AFS::VOS: can't find volume '%s'\n", id);
            VSETCODE(err ? err : ENOENT, buffer);
            goto done;
        }

        if ((server && (strlen(server) != 0)) || (partition && (strlen(partition) != 0))) {
            if (!(server && (strlen(server) != 0)) || !(partition && (strlen(partition) != 0))) {
                char buffer[256];
                sprintf(buffer, "Must specify both SERVER and PARTITION arguments\n");
                VSETCODE(-1, buffer);
                goto done;
            }

src/AFS.xs  view on Meta::CPAN

            if (code) {
                SETCODE(code);
                goto done;
            }
        }

        if (time && strcmp(time, "0")) {
            code = ktime_DateToInt32(time, &fromdate);
            if (code) {
                char buffer[256];
                sprintf(buffer, "AFS::VOS: failed to parse date '%s' (error=%d))\n", time, code);
                VSETCODE(code, buffer);
                goto done;
            }
        }
        if (file && (strlen(file) != 0)) {
            strcpy(filename, file);
        }
        else {
            strcpy(filename, "");
        }

src/AFS.xs  view on Meta::CPAN

                XSRETURN_UNDEF;
            }
            dummyPartList.partId[0] = apart;
            dummyPartList.partFlags[0] = PARTVALID;
            cnt = 1;
        }
        if (apart != -1) {
            if (!IsPartValid(apart, aserver, &code)) {  /*check for validity of the partition */
                char buffer[256];
                if (code)
                    set_errbuff(buffer, code);
                else
                    sprintf(buffer, "AFS::VOS: partition %s does not exist on the server\n",
                            partname);
                VSETCODE(code ? code : -1, buffer);
                XSRETURN_UNDEF;
            }
        }
        else {
            code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
            if (code) {

src/AFS.xs  view on Meta::CPAN

            char buffer[256];
            sprintf(buffer, "AFS::VOS: server '%s' not found in host table\n", server);
            VSETCODE(-1, buffer);
            XSRETURN_UNDEF;
        }

        if (apart != -1) {
            if (!IsPartValid(apart, aserver, &code)) {  /*check for validity of the partition */
                char buffer[256];
                if (code)
                    set_errbuff(buffer, code);
                else
                    sprintf(buffer, "AFS::VOS: partition %s does not exist on the server\n",
                            partname);
                VSETCODE(code ? code : -1, buffer);
                XSRETURN_UNDEF;
            }
        }
        else {
            code = UV_ListPartitions(aserver, &dummyPartList, &cnt);
            if (code) {

src/AFS.xs  view on Meta::CPAN


int32
vos_move(cstruct, id, froms, fromp, tos, top)
        AFS::VOS cstruct
        char *id
        char *froms
        char *fromp
        char *tos
        char *top
    PREINIT:
        afs_int32 volid, fromserver, toserver, frompart, topart,code, err;
        char fromPartName[10], toPartName[10];
#ifdef OpenAFS_1_4_64
        struct diskPartition64 partition;   /* for space check */
#else
        struct diskPartition partition;         /* for space check */
#endif
        volintInfo *p;
    CODE:
    {
        RETVAL = 0;
        volid = vsu_GetVolumeID(id, cstruct, &err);
        if (volid == 0) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "AFS::VOS: can't find volume ID or name '%s'\n", id);
            VSETCODE(err ? err : ENOENT, buffer);
            goto done;
        }
        fromserver = GetServer(froms);
        if (fromserver == 0) {
            char buffer[256];
            sprintf(buffer, "AFS::VOS: server '%s' not found in host table\n", froms);
            VSETCODE(ENOENT, buffer);
            goto done;
        }
        toserver = GetServer(tos);

src/AFS.xs  view on Meta::CPAN

        frompart = volutil_GetPartitionID(fromp);
        if (frompart < 0) {
            char buffer[256];
            sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", fromp);
            VSETCODE(EINVAL, buffer);
            goto done;
        }
        if (!IsPartValid(frompart, fromserver, &code)) {        /*check for validity of the partition */
            char buffer[256];
            if (code)
                set_errbuff(buffer, code);
            else
                sprintf(buffer, "AFS::VOS: partition %s does not exist on the server\n", fromp);
            VSETCODE(code ? code : ENOENT, buffer);
            goto done;
        }
        topart = volutil_GetPartitionID(top);
        if (topart < 0) {
            char buffer[256];
            sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", top);
            VSETCODE(EINVAL, buffer);
            goto done;
        }
        if (!IsPartValid(topart, toserver, &code)) {    /*check for validity of the partition */
            char buffer[256];
            if (code)
                set_errbuff(buffer, code);
            else
                sprintf(buffer, "AFS::VOS: partition %s does not exist on the server\n", top);
            VSETCODE(code ? code : ENOENT, buffer);
            goto done;
        }

                /*
                   check source partition for space to clone volume
                 */

src/AFS.xs  view on Meta::CPAN

int32
vos_zap(cstruct, servername, parti, id, force=Nullsv, backup=Nullsv)
        AFS::VOS cstruct
        char *servername
        char *parti
        char *id
        SV *  force
        SV *  backup
    PREINIT:
        struct nvldbentry entry;
        int32 volid, code, server, part, iforce=0, zapbackupid=0, backupid=0, err;
    CODE:
    {
        if (!force)
            force = newSViv(0);
        if (!backup)
            backup = newSViv(0);
        if ((!SvIOKp(force))) {
            char buffer[256];
            sprintf(buffer, "Flag \"force\" should be numeric.\n");
            VSETCODE(EINVAL, buffer);

src/AFS.xs  view on Meta::CPAN

            char buffer[256];
            sprintf(buffer, "Flag \"backup\" should be numeric.\n");
            VSETCODE(EINVAL, buffer);
            RETVAL = 0;
            goto done;
        }
        else
            zapbackupid = 1;           /* -backup */
         RETVAL = 0;

        volid = vsu_GetVolumeID(id, cstruct, &err);
        if (volid == 0) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "AFS::VOS: can't find volume '%s'\n", id);
            VSETCODE(err ? err : -1, buffer);
            goto done;
        }
        part = volutil_GetPartitionID(parti);
        if (part < 0) {
            char buffer[256];
            sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", parti);
            VSETCODE(-1, buffer);
            goto done;
        }
        server = GetServer(servername);

src/AFS.xs  view on Meta::CPAN

                goto done;
            }
            SETCODE(0);
            RETVAL = volid;
            goto done;
        }

        if (!IsPartValid(part, server, &code)) {        /*check for validity of the partition */
            char buffer[256];
            if (code)
                set_errbuff(buffer, code);
            else
                sprintf(buffer, "AFS::VOS: partition %s does not exist on the server\n",
                        servername);
            VSETCODE(code ? code : -1, buffer);
            goto done;
        }
        code = VLDB_GetEntryByID(volid, -1, &entry);
        if (!code) {
            if (volid == entry.volumeId[RWVOL])
                backupid = entry.volumeId[BACKVOL];
            #fprintf(stderr,
            #        "Warning: Entry for volume number %u exists in VLDB (but we're zapping it anyway!)\n",
            #        volid);
        }
        if (zapbackupid) {
            volintInfo *pntr = (volintInfo *) 0;

            if (!backupid) {
                code = UV_ListOneVolume(server, part, volid, &pntr);
                if (!code) {
                    if (volid == pntr->parentID)

src/AFS.xs  view on Meta::CPAN

int32
vos_offline(cstruct, servername, parti, id, busy=Nullsv, sleep=Nullsv)
        AFS::VOS cstruct
        char* servername
        char* parti
        char *id
        SV *  busy
        SV *  sleep
    PREINIT:
        int32 server, partition, volid;
        int32 code, err=0;
        int32 ibusy=0, isleep=0, transflag, transdone;
    CODE:
    {
        if (!busy)
            busy = newSViv(0);
        if (!sleep)
            sleep = newSViv(0);
        if ((!SvIOKp(busy))) {
            char buffer[256];
            sprintf(buffer, "Flag \"busy\" should be numeric.\n");

src/AFS.xs  view on Meta::CPAN

        }

        partition = volutil_GetPartitionID(parti);
        if (partition < 0) {
            char buffer[256];
            sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", parti);
            VSETCODE(ENOENT, buffer);
            goto done;
        }

        volid = vsu_GetVolumeID(id, cstruct, &err);     /* -id */
        if (!volid) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "Unknown volume ID or name '%s'\n", servername);
            VSETCODE(err ? err : -1, buffer);
            goto done;
        }

        transflag = (ibusy ? ITBusy : ITOffline);
        transdone = (isleep ? 0 /*online */ : VTOutOfService);
        if (ibusy && !isleep) {
            char buffer[256];
            sprintf(buffer, "SLEEP argument must be used with BUSY flag\n");
            VSETCODE(-1, buffer);
            goto done;

src/AFS.xs  view on Meta::CPAN

        RETVAL

int32
vos_online(cstruct, servername, parti, id)
        AFS::VOS cstruct
        char* servername
        char* parti
        char *id
    PREINIT:
        int32 server, partition, volid;
        int32 code, err=0;
    CODE:
    {
        RETVAL = 0;
        server = GetServer(servername);
        if (server == 0) {
            char buffer[256];
            sprintf(buffer, "AFS::VOS: server '%s' not found in host table\n", servername);
            VSETCODE(-1, buffer);
            goto done;
        }

        partition = volutil_GetPartitionID(parti);
        if (partition < 0) {
            char buffer[256];
            sprintf(buffer, "AFS::VOS: could not interpret partition name '%s'\n", parti);
            VSETCODE(ENOENT, buffer);
            goto done;
        }

        volid = vsu_GetVolumeID(id, cstruct, &err);     /* -id */
        if (!volid) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "Unknown volume ID or name '%s'\n", servername);
            VSETCODE(err ? err : -1, buffer);
            goto done;
        }

        code = UV_SetVolume(server, partition, volid, ITOffline, 0 /*online */ , 0 /*sleep */ );
        if (code) {
            char buffer[256];
            sprintf(buffer, "Failed to set volume. Code = %d\n", code);
            VSETCODE(code, buffer);
            goto done;
        }

src/AFS.xs  view on Meta::CPAN

        int32 apart=0, avolid;
        int32 aserver=0, code, aserver1, apart1;
        int32 vcode, iexclude=0, inoaction=0;
        struct VldbListByAttributes attributes;
        nbulkentries arrayEntries;
        register struct nvldbentry *vllist;
        int32 nentries;
        int j, i, len, verbose = 1;
        afs_int32 totalBack=0;
        afs_int32 totalFail=0;
        int previdx=-1, error, same;
        char *ccode, *itp;
        int match = 0;
        STRLEN prfxlength=0;
        SV *regex;
        AV *av;
        AV *av1 = (AV*)sv_2mortal((SV*)newAV());
        AV *av2 = (AV*)sv_2mortal((SV*)newAV());
    PPCODE:
    {
        /* printf("vos-backupsys DEBUG-1 server %s part %s exclude %d noaction %d \n", servername, partition, (int)SvIV(exclude), (int)SvIV(noaction)); */

src/AFS.xs  view on Meta::CPAN

            MapHostToNetwork(vllist);
            GetServerAndPart(vllist, RWVOL, &aserver1, &apart1, &previdx);
            if (aserver1 == -1 || apart1 == -1) {
                av_push(av2, newSVpv(vllist->name, strlen(vllist->name)));
                fprintf(STDOUT, "could not backup %s, invalid VLDB entry\n", vllist->name);
                totalFail++;
                continue;
            }
            /* printf("vos-backupsys DEBUG-19\n"); */
            if (aserver) {
                same = VLDB_IsSameAddrs(aserver, aserver1, &error);
                if (error) {
                    av_push(av2, newSVpv(vllist->name, strlen(vllist->name)));
                    fprintf(stderr,
                            "Failed to get info about server's %d address(es) from vlserver (err=%d); aborting call!\n",
                            aserver, error);
                    totalFail++;
                    continue;
                }
            }
            /* printf("vos-backupsys DEBUG-20\n"); */
            if ((aserver && !same) || (apart && (apart != apart1))) {
                if (verbose) {
                    fprintf(STDOUT,
                            "Omitting to backup %s since the RW is in a different location\n",
                            vllist->name);

src/AFS.xs  view on Meta::CPAN


void
vos_listvolume(cstruct, name)
        AFS::VOS cstruct
        char *name
    PREINIT:
        struct nvldbentry entry;
        afs_int32 vcode = 0;
        volintInfo *pntr = (volintInfo *)0;
        afs_int32 volid;
        afs_int32 code, err;
        int voltype, foundserv = 0, foundentry = 0;
        afs_int32 aserver, apart;
        char apartName[10];
        int previdx = -1;
        HV *volinfo = (HV*)sv_2mortal((SV*)newHV());
    PPCODE:
    {
        volid = vsu_GetVolumeID(name, cstruct, &err);   /* -id */
        if (volid == 0) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "Unknown volume ID or name '%s'\n", name);
            VSETCODE(err ? err : -1, buffer);
            XSRETURN_UNDEF;
        }
        vcode = VLDB_GetEntryByID(volid, -1, &entry);
        if (vcode) {
            char buffer[256];
            sprintf(buffer, "Could not fetch the entry for volume number %u from VLDB \n", volid);
            VSETCODE(vcode, buffer);
            XSRETURN_UNDEF;
        }
        MapHostToNetwork(&entry);

src/AFS.xs  view on Meta::CPAN

       AFS::VLDB cstruct
       char *server
       char *partition
       char *id
       char *roid
       int  valid
    PREINIT:
       int32 code = 1;
    CODE:
    {
        afs_int32 avolid, aserver, apart, err, arovolid=0;
        char avolname[VOLSER_MAXVOLNAME + 1];
        if (roid && (roid[0] == '\0' || roid[0] == '0'))
            roid = NULL;
        RETVAL = 0;
        /* printf("vldb_addsite DEBUG-1 server %s part %s Vol/Id %s RO-Vol/ID %s ValID %d \n", server, partition, id, roid, valid); */
#ifdef OpenAFS_1_4
        vsu_ExtractName(avolname, id);
#else
        strcpy(avolname, id);
#endif
        /* printf("vldb_addsite DEBUG-2 id %s avolname %s \n", id, avolname); */
        avolid = vsu_GetVolumeID(avolname, cstruct, &err);
        /* printf("vldb_addsite DEBUG-3 Vol-Nam %s Vol-ID %d \n", avolname, avolid); */
        if (avolid == 0) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "AFS::VLDB: can't find volume '%s'\n", id);
            VSETCODE(err ? err : -1, buffer);
            goto done;
        }
#ifdef OpenAFS_1_4_12
        if (roid) {
            /* printf("vldb_addsite DEBUG-4 Roid %s AROVolid %d\n", roid, arovolid); */
            vsu_ExtractName(avolname, roid);
            arovolid = vsu_GetVolumeID(avolname, cstruct, &err);
            /* printf("vldb_addsite DEBUG-5 Roid %s AROVolid %d\n", roid, arovolid); */
            if (!arovolid) {
                char buffer[256];
                sprintf(buffer, "AFS::VLDB: invalid ro volume id '%s'\n", roid);
                VSETCODE(-1, buffer);
                goto done;
            }
        }
#endif
        aserver = GetServer(server);

src/AFS.xs  view on Meta::CPAN

        apart = volutil_GetPartitionID(partition);
        if (apart < 0) {
            char buffer[256];
            sprintf(buffer, "AFS::VLDB: could not interpret partition name '%s'\n", partition);
            VSETCODE(-1, buffer);
            goto done;
        }
        if (!IsPartValid(apart, aserver, &code)) {      /*check for validity of the partition */
            char buffer[256];
            if (code)
                set_errbuff(buffer, code);
            else
                sprintf(buffer, "AFS::VLDB: partition %s does not exist on the server\n",
                        partition);
            VSETCODE(code ? code : -1, buffer);
            goto done;
        }
#if defined(OpenAFS_1_4_12)
        code = UV_AddSite2(aserver, apart, avolid, arovolid, valid);
#else
#if defined(OpenAFS_1_4_07)

src/AFS.xs  view on Meta::CPAN

        RETVAL

int32
vldb_changeloc(cstruct, id, server, partition)
        AFS::VLDB cstruct
        char *id
        char *server
        char *partition
    PREINIT:
#ifdef OpenAFS
        afs_int32 avolid, aserver, apart, code, err;
#endif
    CODE:
    {
#ifdef OpenAFS
        /* printf("DEBUG-1\n"); */
        RETVAL = 0;
        avolid = vsu_GetVolumeID(id, cstruct, &err);
        if (avolid == 0) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "AFS::VLDB: can't find volume '%s'\n", id);
            VSETCODE(err ? err : -1, buffer);
            goto done;
        }
        /* printf("DEBUG-2\n"); */
        aserver = GetServer(server);
        if (aserver == 0) {
            char buffer[256];
            sprintf(buffer, "AFS::VLDB: server '%s' not found in host table\n", server);
            VSETCODE(-1, buffer);
            goto done;
        }

src/AFS.xs  view on Meta::CPAN

            char buffer[256];
            sprintf(buffer, "AFS::VLDB: could not interpret partition name '%s'\n", partition);
            VSETCODE(-1, buffer);
            /* printf("DEBUG-3.1\n"); */
            goto done;
        }
        /* printf("DEBUG-4\n"); */
        if (!IsPartValid(apart, aserver, &code)) {      /*check for validity of the partition */
            char buffer[256];
            if (code)
                set_errbuff(buffer, code);
            else
                sprintf(buffer, "AFS::VLDB: partition %s does not exist on the server\n", server);
            VSETCODE(code ? code : -1, buffer);
            goto done;
        }
        /* printf("DEBUG-5\n"); */
        code = UV_ChangeLocation(aserver, apart, avolid);
        if (code) {
            VSETCODE(code, "changeloc");
            goto done;

src/AFS.xs  view on Meta::CPAN

                sprintf(buffer,
                        "AFS::VLDB: illegal use of '-locked' switch, need to specify server and/or partition\n");
                VSETCODE(-1, buffer);
                XSRETURN_UNDEF;
            }
            /* printf("DEBUG-4 \n"); */
            stats = (HV *) sv_2mortal((SV *) newHV());
            code = VolumeInfoCmd(stats, name);
            if (code) {
                char buffer[256];
                set_errbuff(buffer, code);
                VSETCODE(code, buffer);
                XSRETURN_UNDEF;
            }
            /* printf("DEBUG-5 \n"); */
            safe_hv_store(status, name, strlen(name), newRV_inc((SV *) (stats)), 0);
            goto finish;
        }

            /* Server specified */
        /* printf("DEBUG-6 \n"); */

src/AFS.xs  view on Meta::CPAN

        struct VldbListByAttributes attributes;
        nbulkentries arrayEntries;
        register struct nvldbentry *vllist;
        SV *vol;
        char *itp;
        afs_int32 nentries;
        int j;
        char prefix[VOLSER_MAXVOLNAME+1];
        int seenprefix=0;
        STRLEN volumelength=0;
        afs_int32 totalBack=0, totalFail=0, err;
        AV *av;
    PPCODE:
    {
        if (prfx && strlen(prfx) == 0)
            prfx = NULL;
        if (partition && strlen(partition) == 0)
            partition = NULL;
        if (server && strlen(server) == 0)
            server = NULL;

src/AFS.xs  view on Meta::CPAN

                VSETCODE(-1, "You cannot use SERVER, PARTITION, or PREFIX with the VOLUME argument");
                XSRETURN_UNDEF;
            }
            av = (AV *) SvRV(volume);
            len = av_len(av);
            if (len != -1) {
                for (j = 0; j <= len; j++) {
                    vol = *av_fetch(av, j, 0);
                    itp = SvPV_nolen(vol);
                    if (itp) {
                        avolid = vsu_GetVolumeID(itp, cstruct, &err);
                        if (avolid == 0) {
                            char buffer[256];
                            if (err)
                                set_errbuff(buffer, err);
                            else
                                sprintf(buffer, "AFS::VLDB: can't find volume '%s'\n", itp);
                            VSETCODE(err ? err : -1, buffer);
                            continue;
                        }
                        if (noexecute) {        /* -noexecute */
                            fprintf(STDOUT, "Would have deleted VLDB entry for %s \n", itp);
                            fflush(STDOUT);
                            continue;
                        }
                        vcode = ubik_Call(VL_DeleteEntry, cstruct, 0, avolid, RWVOL);
                        if (vcode) {
                            char buffer[256];

src/AFS.xs  view on Meta::CPAN


        done:
        ;
    }

int32
vldb_lock(cstruct, id)
        AFS::VLDB cstruct
        char *id
    PREINIT:
        afs_int32 avolid, vcode, err;
    CODE:
    {
        RETVAL = 0;
        avolid = vsu_GetVolumeID(id, cstruct, &err);
        if (avolid == 0) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "AFS::VLDB: can't find volume '%s'\n", id);
            VSETCODE(err ? err : -1, buffer);
            goto done;
        }
        vcode = ubik_Call(VL_SetLock, cstruct, 0, avolid, -1, VLOP_DELETE);
        if (vcode) {
            char buffer[256];
            sprintf(buffer, "Could not lock VLDB entry for volume %s\n", id);
            VSETCODE(vcode, buffer);
            goto done;
        }
            /*     fprintf(STDOUT, "Locked VLDB entry for volume %s\n", id); */

src/AFS.xs  view on Meta::CPAN

        ;
    }
    OUTPUT:
        RETVAL

int32
vldb_unlock(cstruct, id)
        AFS::VLDB cstruct
        char *id
    PREINIT:
        afs_int32 avolid, code, err;
    CODE:
    {
        RETVAL = 0;
        avolid = vsu_GetVolumeID(id, cstruct, &err);
        if (avolid == 0) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "AFS::VLDB: can't find volume '%s'\n", id);
            VSETCODE(err ? err : -1, buffer);
            goto done;
        }

        code = UV_LockRelease(avolid);
        if (code) {
            VSETCODE(code, "unlock");
            goto done;
        }
                /* fprintf(STDOUT,"Released lock on vldb entry for volume %s\n",id); */
        SETCODE(0);

src/AFS.xs  view on Meta::CPAN

            if (apart < 0) {
                char buffer[256];
                sprintf(buffer, "AFS::VLDB: could not interpret partition name '%s'\n",
                        partition);
                VSETCODE(-1, buffer);
                goto done;
            }
            if (!IsPartValid(apart, aserver, &code)) {  /*check for validity of the partition */
                char buffer[256];
                if (code)
                    set_errbuff(buffer, code);
                else
                    sprintf(buffer, "AFS::VLDB: partition %s does not exist on the server\n",
                            partition);
                VSETCODE(code ? code : -1, buffer);
                goto done;
            }
            attributes.partition = apart;
            attributes.Mask |= VLLIST_PARTITION;
        }
        attributes.flag = VLOP_ALLOPERS;

src/AFS.xs  view on Meta::CPAN

            if (!tserver) {
                char buffer[256];
                sprintf(buffer, "The PARTITION argument requires a SERVER argument\n");
                VSETCODE(-1, buffer);
                goto done;
            }

            if (!IsPartValid(pname, tserver, &code)) {  /*check for validity of the partition */
                char buffer[256];
                if (code)
                    set_errbuff(buffer, code);
                else
                    sprintf(buffer, "AFS::VLDB: partition %s does not exist on the server\n",
                            partition);
                VSETCODE(code ? code : -1, buffer);
                goto done;
            }
            flags = 1;
        }

        if (volname && (strlen(volname) != 0)) {

src/AFS.xs  view on Meta::CPAN

                char buffer[256];
                sprintf(buffer, "Without a VOLUME argument, the server argument is required\n");
                VSETCODE(-1, buffer);
                goto done;
            }
            code = UV_SyncVldb(tserver, pname, flags, 0 /*unused */ );
        }

        if (code) {
            char buffer[256];
            set_errbuff(buffer, code);
            VSETCODE(code, buffer);
            #PrintDiagnostics("syncvldb", code);
            #SETCODE(code);
            goto done;
        }
        else
            SETCODE(0);

        RETVAL = 1;

src/AFS.xs  view on Meta::CPAN

    OUTPUT:
        RETVAL

int32
vldb_remsite(cstruct,server,partition,name)
        AFS::VLDB cstruct
        char *server
        char *partition
        char *name
    PREINIT:
        afs_int32 avolid, aserver, apart, code = 1, err;
        char avolname[VOLSER_MAXVOLNAME + 1];
    CODE:
    {
        RETVAL = 0;
#ifdef OpenAFS_1_4
        vsu_ExtractName(avolname, name);
#else
        strcpy(avolname, name);
#endif
        avolid = vsu_GetVolumeID(avolname, cstruct, &err);
        if (avolid == 0) {
            char buffer[256];
            if (err)
                set_errbuff(buffer, err);
            else
                sprintf(buffer, "AFS::VLDB: can't find volume '%s'\n", avolname);
            VSETCODE(err ? err : -1, buffer);
            goto done;
        }
        aserver = GetServer(server);
        if (aserver == 0) {
            char buffer[256];
            sprintf(buffer, "AFS::VLDB: server '%s' not found in host table\n", server);
            VSETCODE(-1, buffer);
            goto done;
        }
        apart = volutil_GetPartitionID(partition);

src/AFS.xs  view on Meta::CPAN

            pname = volutil_GetPartitionID(parti);
            if (pname < 0) {
                char buffer[256];
                sprintf(buffer, "AFS::VLDB: could not interpret partition name '%s'\n", parti);
                VSETCODE(-1, buffer);
                goto done;
            }
            if (!IsPartValid(pname, tserver, &code)) {  /*check for validity of the partition */
                char buffer[256];
                if (code)
                    set_errbuff(buffer, code);
                else
                    sprintf(buffer, "AFS::VLDB: partition %s does not exist on the server\n",
                            parti);
                VSETCODE(code ? code : -1, buffer);
                goto done;
            }
            flags = 1;
        }

        code = UV_SyncServer(tserver, pname, flags, 0 /*unused */ );

src/AFS.xs  view on Meta::CPAN

    {
        for (i = 0;; i++) {
            tp = tbuffer;
            code = BOZO_ListSUsers(self, i, &tp);
            if (code)
                break;
            XPUSHs(sv_2mortal(newSVpv(tbuffer, strlen(tbuffer))));
        }

        if (code != 1) {
            /* a real error code, instead of scanned past end */
            char buffer[256];
            sprintf(buffer, "AFS::BOS: failed to retrieve super-user list (%s)\n", em(code));
            BSETCODE(code, buffer);
            XSRETURN_UNDEF;
        }
        else {
            SETCODE(0);
            XSRETURN(i);
        }
    }

src/AFS.xs  view on Meta::CPAN

        RETVAL

void
bos_getlog(self, file)
        AFS::BOS self
        char* file
    PREINIT:
        register struct rx_call *tcall;
        int32 code = 0;
        char buf, c[255];
        int error, num = 0, i = 0;
    PPCODE:
    {
        tcall = rx_NewCall(self);
        code = StartBOZO_GetLog(tcall, file);
        if (code) {
            char buffer[256];
            rx_EndCall(tcall, code);
            sprintf(buffer, "AFS::BOS error %d (while reading log)\n", code);
            BSETCODE(code, buffer);
            XSRETURN_UNDEF;
        }

            /* copy data */
        error = 0;
        while (1) {
            code = rx_Read(tcall, &buf, 1);
            if (code != 1) {
                error = EIO;
                break;
            }
            if (buf == 0)
                break;                  /* the end delimeter */
            /* putchar(buf); */
            c[i++] = buf;
            if (buf == '\n') {
                XPUSHs(sv_2mortal(newSVpv(c, i)));
                i = 0;
                num++;
            }
        }

        code = rx_EndCall(tcall, error);
        #if (tcall)
        #    Safefree(tcall);
            /* fall through into cleanup code */
        XSRETURN(num);
    }

int32
bos__start(self, object=NULL)
        AFS::BOS self
        SV * object

src/AFS.xs  view on Meta::CPAN

                }
                else {
                    safe_hv_store(key, "keyCheckSum", 11, newSVuv(keyInfo.keyCheckSum), 0);
                }
            }
            sprintf(index, "%d", kvno);
            safe_hv_store(list, index, strlen(index), newRV_inc((SV *) (key)), 0);
        }                               /* for loop */

        if (everWorked) {
            /* fprintf(stderr, "Keys last changed on %d.\n", keyInfo.mod_sec); */
            EXTEND(sp, 2);
            PUSHs(sv_2mortal(newSViv(keyInfo.mod_sec)));
            PUSHs(newRV_inc((SV *) (list)));
        }
        if (code != BZDOM) {
            char buffer[256];
            sprintf(buffer, "AFS::BOS: %s error encountered while listing keys\n", em(code));
            BSETCODE(code, buffer);
        }
        else {
            code = 0;
        }

        if (everWorked) {
            XSRETURN(2);
        }
        else {

src/AFS.xs  view on Meta::CPAN

                sprintf(buffer, "Parameter only possible for MR-AFS fileserver.\n");
                BSETCODE(-1, buffer);
                goto done;
            }
        }

        if (all) {
            /* salvage whole enchilada */
            curGoal = GetServerGoal(self, "fs");
            if (curGoal == BSTAT_NORMAL) {
                fprintf(stderr, "AFS::BOS: shutting down fs.\n");
                code = BOZO_SetTStatus(self, "fs", BSTAT_SHUTDOWN);
                if (code) {
                    char buffer[256];
                    sprintf(buffer, "AFS::BOS: failed to stop 'fs' (%s)\n", em(code));
                    BSETCODE(code, buffer);
                    goto done;
                }
                code = BOZO_WaitAll(self);    /* wait for shutdown to complete */
                if (code) {
                    char buffer[256];
                    sprintf(buffer,
                            "AFS::BOS: failed to wait for file server shutdown, continuing.\n");
                    BSETCODE(code, buffer);
                }
            }
            /* now do the salvage operation */
            /* fprintf(stderr, "Starting salvage of everything.\n"); */
            rc = DoSalvage(self, (char *) 0, (char *) 0, outName, showlog, parallel, tmpDir,
                           orphans);
            if (curGoal == BSTAT_NORMAL) {
                /* fprintf(stderr, "AFS::BOS: restarting fs.\n"); */
                code = BOZO_SetTStatus(self, "fs", BSTAT_NORMAL);
                if (code) {
                    char buffer[256];
                    sprintf(buffer, "AFS::BOS: failed to restart 'fs' (%s)\n", em(code));
                    BSETCODE(code, buffer);
                    goto done;
                }
            }
            if (rc) {
                code = rc;

src/AFS.xs  view on Meta::CPAN

                 * file server.
                 */
                char buffer[256];
                sprintf(buffer, "AFS::BOS: can't interpret %s as partition ID.\n", partition);
                BSETCODE(-1, buffer);
                goto done;
            }
            curGoal = GetServerGoal(self, "fs");
            /* salvage a whole partition (specified by parms[1]) */
            if (curGoal == BSTAT_NORMAL) {
                /* fprintf(stderr, "AFS::BOS: shutting down fs.\n"); */
                code = BOZO_SetTStatus(self, "fs", BSTAT_SHUTDOWN);
                if (code) {
                    char buffer[256];
                    sprintf(buffer, "AFS::BOS: can't stop 'fs' (%s)\n", em(code));
                    BSETCODE(code, buffer);
                    goto done;
                }
                code = BOZO_WaitAll(self);    /* wait for shutdown to complete */
                if (code) {
                    char buffer[256];
                    sprintf(buffer,
                            "AFS::BOS: failed to wait for file server shutdown, continuing.\n");
                    BSETCODE(code, buffer);
                }
            }
            /* now do the salvage operation */
            /* fprintf(stderr, "Starting salvage of partition %s.\n", partition); */
            rc = DoSalvage(self, partition, (char *) 0,
                           outName, showlog, parallel, tmpDir, orphans);
            if (curGoal == BSTAT_NORMAL) {
                /* fprintf(stderr, "AFS::BOS: restarting fs.\n"); */
                code = BOZO_SetTStatus(self, "fs", BSTAT_NORMAL);
                if (code) {
                    char buffer[256];
                    sprintf(buffer, "AFS::BOS: failed to restart 'fs' (%s)\n", em(code));
                    BSETCODE(code, buffer);
                    goto done;
                }
            }
            if (rc) {
                code = rc;
                goto done;
            }
        }
        else {
            /* salvage individual volume (don't shutdown fs first), just use
             * single-shot cron bnode.  Must leave server running when using this
             * option, since salvager will ask file server for the volume */
            afs_int32 err;
            const char *confdir;

            confdir = (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH);
            code = internal_vsu_ClientInit( /* noauth */ 1, confdir, tmpname,
                                  /* server auth */ 0, &cstruct, (int (*)()) 0);
            if (code == 0) {
                newID = vsu_GetVolumeID(volume, cstruct, &err);
                if (newID == 0) {
                    char buffer[256];
                    sprintf(buffer, "AFS::BOS: can't interpret %s as volume name or ID\n",
                            volume);
                    BSETCODE(-1, buffer);
                    goto done;
                }
                sprintf(tname, "%u", newID);
            }
            else {

src/AFS.xs  view on Meta::CPAN

            }
            if (volutil_GetPartitionID(partition) < 0) {
                /* can't parse volume ID, so complain before shutting down
                 * file server.
                 */
                char buffer[256];
                sprintf(buffer, "AFS::BOS: can't interpret %s as partition ID.\n", partition);
                BSETCODE(-1, buffer);
                goto done;
            }
            /* fprintf(stderr, "Starting salvage of volume %d on partition %s.\n",
               newID, partition); */
            rc = DoSalvage(self, partition, tname, outName, showlog, parallel, tmpDir, orphans);
            if (rc) {
                code = rc;
                goto done;
            }
        }

        code = 0;
        SETCODE(code);

src/AFS.xs  view on Meta::CPAN

            KSETCODE(code, buffer);
            safefree(t);
            XSRETURN_UNDEF;
        }
    }


MODULE = AFS    PACKAGE = AFS   PREFIX = afs_

BOOT:
    initialize_bz_error_table();
    initialize_vols_error_table();
    initialize_vl_error_table();
    initialize_u_error_table();
    initialize_pt_error_table();
    initialize_ka_error_table();
    initialize_acfg_error_table();
    initialize_ktc_error_table();
    initialize_rxk_error_table();
/*     initialize_cmd_error_table(); */
/*     initialize_budb_error_table(); */
/*     initialize_butm_error_table(); */
/*     initialize_butc_error_table(); */

void
afs__finalize()
    CODE:
    {
        if (rx_initialized) {
            rx_Finalize();
            /* printf("AFS DEBUG rx_Finalize\n"); */
        }
    }

src/AFS.xs  view on Meta::CPAN

        else {
            safefree(t);
            switch (code) {
              case KABADREQUEST:
                  message = "password was incorrect";
                  break;
              case KAUBIKCALL:
                  message = "Authentication Server was unavailable";
                  break;
              default:
                  message = (char *) error_message(code);
            }
            sv_setpv(ST(4), message);
        }

    }


void
afs_ka_GetAuthToken(p,key,lifetime,pwexpires=-1)
        AFS::KTC_PRINCIPAL p

src/AFS.xs  view on Meta::CPAN

    PPCODE:
    {
        int32 code;
        code = ktc_ForgetAllTokens();
        SETCODE(code);
        ST(0) = sv_2mortal(newSViv(code == 0));
        XSRETURN(1);
    }

void
afs_error_message(code)
        int32   code
    PPCODE:
    {
        ST(0) = sv_newmortal();
        sv_setpv(ST(0), (char *) error_message(code));
        XSRETURN(1);
    }


  /* this function is generated automatically by constant_gen */
  /* You didn't think I would type in this crap did you? */
  /* thats what perl is for :-) */

#if defined(AFS_3_4)

void
constant(name, arg=0)
        char *  name
        int     arg
   PPCODE:
   {
  ST(0) = sv_newmortal();

  errno = EINVAL;

  switch (name[0]) {
  case 'A':
        switch (name[1]) {
        case 'F':
                switch (name[2]) {
                case 'S':
                if (strEQ(name,"AFSCONF_FAILURE")) sv_setiv(ST(0),AFSCONF_FAILURE);
                else if (strEQ(name,"AFSCONF_FULL")) sv_setiv(ST(0),AFSCONF_FULL);
                else if (strEQ(name,"AFSCONF_NOCELL")) sv_setiv(ST(0),AFSCONF_NOCELL);

src/AFS.xs  view on Meta::CPAN

        default:
                ST(0) = ST(1) = &PL_sv_undef;
                return;
        }
        break;
  default:
        ST(0) = ST(1) = &PL_sv_undef;
        return;
  }

  errno = 0;
  XSRETURN(1);
  return;
 }

#else

void
constant(name, arg=0)
        char *  name
        int     arg
   PPCODE:
   {
  ST(0) = sv_newmortal();

  errno = EINVAL;

  switch (name[0]) {
  case 'A':
        switch (name[1]) {
        case 'F':
                switch (name[2]) {
                case 'S':
                if (strEQ(name,"AFSCONF_FAILURE")) sv_setiv(ST(0),AFSCONF_FAILURE);
                else if (strEQ(name,"AFSCONF_FULL")) sv_setiv(ST(0),AFSCONF_FULL);
                else if (strEQ(name,"AFSCONF_NOCELL")) sv_setiv(ST(0),AFSCONF_NOCELL);

src/AFS.xs  view on Meta::CPAN

        default:
                ST(0) = ST(1) = &PL_sv_undef;
                return;
        }
        break;
  default:
        ST(0) = ST(1) = &PL_sv_undef;
        return;
  }

  errno = 0;
  XSRETURN(1);
  return;
 }

#endif

src/Makefile.PL  view on Meta::CPAN

                          -lubik
                          -lauth

                          -lrxkad
                          -lrxstat
                          -lrx

                          -lsys
                          -ldes
                          -llwp
                          -lcom_err
                          -lutil
                          -lusd
                          -laudit
                         )
                 );
}

# give me the path to the AFS system libraries
# used to build the AFS extension module
my $guess_path;

src/Makefile.PL  view on Meta::CPAN

WriteMakefile(%MakefileArgs);

# change the library name of the AFS system library "util.a"
my $command = "\'s#-lutil#$AFSPath/lib/afs/util.a#\'";
system("perl -p -i.bak -e $command Makefile") unless -f "$AFSPath/lib/afs/libutil.a";

# change the library name of the AFS system library "vlib.a"
# my $command = "\'s#-lvlib#$AFSPath/lib/afs/vlib.a#\'";
# system("perl -p -i.bak -e $command Makefile") unless -f "$AFSPath/lib/afs/libvlib.a";

# change the library name of the AFS system library "libcom_err"
$command = "\'s#-lcom_err#$AFSPath/lib/afs/libcom_err.a#\'";
system("perl -p -i.bak -e $command Makefile");

# change the library name of the AFS system library "-lafsrpc"
if ($alpha_sys =~ /linux/ && $alpha_sys !~ /i386_linux2/) {
    $command = "\'s#-lc -lafsrpc -lc#$AFSPath/lib/libafsrpc_pic.a#g\'";
}
else {
    $command = "\'s#-lc -lafsrpc -lc#$AFSPath/lib/libafsrpc.a#g\'";
}
system("perl -p -i.bak -e $command Makefile");

src/afs_prototypes.h  view on Meta::CPAN

/*
 * afs_prototypes.h for AFS Perl Extension module
 *
 * Prototypes for OpenAFS subroutines
 * picked up from the OpenAFS header files
 */

#if defined(OpenAFS_1_0) || defined(OpenAFS_1_1) || defined(OpenAFS_1_2) || defined(OpenAFS_1_3)
extern const char *error_message();
#endif
extern int UV_SetSecurity(struct rx_securityClass *, afs_int32);
extern char *hostutil_GetNameByINet();
extern struct hostent *hostutil_GetHostByName(register char *ahost);
extern char *volutil_PartitionName();
extern int afsconf_ClientAuthSecure(struct afsconf_dir *,struct rx_securityClass **, int *);
extern int afsUUID_from_string(const char *str, afsUUID * uuid);
extern int afsUUID_to_string(const afsUUID * uuid, char *str, size_t strsz);
extern int des_read_pw_string(char *, int, char *, int);
extern int Lp_GetRwIndex(struct nvldbentry *);
extern int Lp_ROMatch(afs_int32, afs_int32, struct nvldbentry *entry);
extern void MapPartIdIntoName(afs_int32 partId, char *partName);
extern void MapNetworkToHost(struct nvldbentry *old, struct nvldbentry *new);
extern void MapHostToNetwork(struct nvldbentry *entry);
extern int pioctl(char *,int, struct ViceIoctl *, int);
extern int PrintError(char *msg, afs_int32 errcode);
extern char *re_comp(char *sp);
extern int rc_exec(char *p);
extern int setpag();
extern int ubik_Call();
extern int ubik_Call_New();
#ifdef OpenAFS_1_4_07
extern int UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid, afs_int32 valid);
#else
extern int UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid);
#endif

src/com_err.h  view on Meta::CPAN

/*
 * Header file for common error description library.
 *
 * Copyright 1988, Student Information Processing Board of the
 * Massachusetts Institute of Technology.
 *
 * For copyright and distribution info, see the documentation supplied
 * with this package.
 */

#ifndef __AFS_COM_ERR_H

#include <stdarg.h>

extern void afs_com_err(const char *, afs_int32, const char *, ...);
extern void afs_com_err_va(const char *whoami, afs_int32 code, const char *fmt,
		       va_list args);
extern const char *afs_error_table_name(afs_int32);
extern const char *afs_error_message(afs_int32);
extern
void (*afs_set_com_err_hook
      (void (*)(const char *, afs_int32, const char *, va_list)))
  (const char *, afs_int32, const char *, va_list);
extern void (*afs_reset_com_err_hook(void)) (const char *, afs_int32,
					 const char *, va_list);

#define __AFS_COM_ERR_H
#ifdef AFS_OLD_COM_ERR 
#define com_err                 afs_com_err
#define com_err_va              afs_com_err_va
#define error_table_name        afs_error_table_name
#define error_message           afs_error_message
#define set_com_err_hook        afs_set_com_err_hook
#define reset_com_err_hook      afs_reset_com_err_hook
#endif /* AFS_OLD_COM_ERR */
#endif /* ! defined(__AFS_COM_ERR_H) */

src/inc/Test/Builder.pm  view on Meta::CPAN

    # Figure out if we passed or failed and print helpful messages.
    if( @Test_Results ) {
        # The plan?  We have no plan.
        if( $No_Plan ) {
            $self->_print("1..$Curr_Test\n") unless $self->no_header;
            $Expected_Tests = $Curr_Test;
        }

        # 5.8.0 threads bug.  Shared arrays will not be auto-extended 
        # by a slice.  Worse, we have to fill in every entry else
        # we'll get an "Invalid value for shared scalar" error
        for my $idx ($#Test_Results..$Expected_Tests-1) {
            my %empty_result = ();
            share(%empty_result);
            $Test_Results[$idx] = \%empty_result
              unless defined $Test_Results[$idx];
        }

        my $num_failed = grep !$_->{'ok'}, @Test_Results[0..$Expected_Tests-1];
        $num_failed += abs($Expected_Tests - @Test_Results);

src/inc/Test/More.pm  view on Meta::CPAN

    my $diag;
    $obj_name = 'The object' unless defined $obj_name;
    my $name = "$obj_name isa $class";
    if( !defined $object ) {
        $diag = "$obj_name isn't defined";
    }
    elsif( !ref $object ) {
        $diag = "$obj_name isn't a reference";
    }
    else {
        # We can't use UNIVERSAL::isa because we want to honor isa() overrides
        local($@, $!);  # eval sometimes resets $!
        my $rslt = eval { $object->isa($class) };
        if( $@ ) {
            if( $@ =~ /^Can't call method "isa" on unblessed reference/ ) {
                if( !UNIVERSAL::isa($object, $class) ) {
                    my $ref = ref $object;
                    $diag = "$obj_name isn't a '$class' it's a '$ref'";
                }
            } else {
                die <<WHOA;
WHOA! I tried to call ->isa on your object and got some weird error.
This should never happen.  Please contact the author immediately.
Here's the error.
$@
WHOA
            }
        }
        elsif( !$rslt ) {
            my $ref = ref $object;
            $diag = "$obj_name isn't a '$class' it's a '$ref'";
        }
    }
            

src/inc/version/vpp.pm  view on Meta::CPAN

    my ($char) = shift->thischar();
    return ($char =~ /[a-zA-Z]/);
}

sub isSPACE {
    my ($char) = shift->thischar();
    return ($char =~ /\s/);
}

sub BADVERSION {
    my ($s, $errstr, $error) = @_;
    if ($errstr) {
	$$errstr = $error;
    }
    return $s;
}

sub prescan_version {
    my ($s, $strict, $errstr, $sqv, $ssaw_decimal, $swidth, $salpha) = @_;
    my $qv          = defined $sqv          ? $$sqv          : FALSE;
    my $saw_decimal = defined $ssaw_decimal ? $$ssaw_decimal : 0;
    my $width       = defined $swidth       ? $$swidth       : 3;
    my $alpha       = defined $salpha       ? $$salpha       : FALSE;

    my $d = $s;

    if ($qv && isDIGIT($d)) {
	goto dotted_decimal_version;
    }

    if ($d eq 'v') { # explicit v-string
	$d++;
	if (isDIGIT($d)) {
	    $qv = TRUE;
	}
	else { # degenerate v-string
	    # requires v1.2.3
	    return BADVERSION($s,$errstr,"Invalid version format (dotted-decimal versions require at least three parts)");
	}

dotted_decimal_version:
	if ($strict && $d eq '0' && isDIGIT($d+1)) {
	    # no leading zeros allowed
	    return BADVERSION($s,$errstr,"Invalid version format (no leading zeros)");
	}

	while (isDIGIT($d)) { 	# integer part
	    $d++;
	}

	if ($d eq '.')
	{
	    $saw_decimal++;
	    $d++; 		# decimal point
	}
	else
	{
	    if ($strict) {
		# require v1.2.3
		return BADVERSION($s,$errstr,"Invalid version format (dotted-decimal versions require at least three parts)");
	    }
	    else {
		goto version_prescan_finish;
	    }
	}

	{
	    my $i = 0;
	    my $j = 0;
	    while (isDIGIT($d)) {	# just keep reading
		$i++;
		while (isDIGIT($d)) {
		    $d++; $j++;
		    # maximum 3 digits between decimal
		    if ($strict && $j > 3) {
			return BADVERSION($s,$errstr,"Invalid version format (maximum 3 digits between decimals)");
		    }
		}
		if ($d eq '_') {
		    if ($strict) {
			return BADVERSION($s,$errstr,"Invalid version format (no underscores)");
		    }
		    if ( $alpha ) {
			return BADVERSION($s,$errstr,"Invalid version format (multiple underscores)");
		    }
		    $d++;
		    $alpha = TRUE;
		}
		elsif ($d eq '.') {
		    if ($alpha) {
			return BADVERSION($s,$errstr,"Invalid version format (underscores before decimal)");
		    }
		    $saw_decimal++;
		    $d++;
		}
		elsif (!isDIGIT($d)) {
		    last;
		}
		$j = 0;
	    }

	    if ($strict && $i < 2) {
		# requires v1.2.3
		return BADVERSION($s,$errstr,"Invalid version format (dotted-decimal versions require at least three parts)");
	    }
	}
    } 					# end if dotted-decimal
    else
    {					# decimal versions
	# special $strict case for leading '.' or '0'
	if ($strict) {
	    if ($d eq '.') {
		return BADVERSION($s,$errstr,"Invalid version format (0 before decimal required)");
	    }
	    if ($d eq '0' && isDIGIT($d+1)) {
		return BADVERSION($s,$errstr,"Invalid version format (no leading zeros)");
	    }
	}

	# and we never support negative version numbers
	if ($d eq '-') {
	    return BADVERSION($s,$errstr,"Invalid version format (negative version number)");
	}

	# consume all of the integer part
	while (isDIGIT($d)) {
	    $d++;
	}

	# look for a fractional part
	if ($d eq '.') {
	    # we found it, so consume it
	    $saw_decimal++;
	    $d++;
	}
	elsif (!$d || $d eq ';' || isSPACE($d) || $d eq '}') {
	    if ( $d == $s ) {
		# found nothing
		return BADVERSION($s,$errstr,"Invalid version format (version required)");
	    }
	    # found just an integer
	    goto version_prescan_finish;
	}
	elsif ( $d == $s ) {
	    # didn't find either integer or period
	    return BADVERSION($s,$errstr,"Invalid version format (non-numeric data)");
	}
	elsif ($d eq '_') {
	    # underscore can't come after integer part
	    if ($strict) {
		return BADVERSION($s,$errstr,"Invalid version format (no underscores)");
	    }
	    elsif (isDIGIT($d+1)) {
		return BADVERSION($s,$errstr,"Invalid version format (alpha without decimal)");
	    }
	    else {
		return BADVERSION($s,$errstr,"Invalid version format (misplaced underscore)");
	    }
	}
	elsif ($d) {
	    # anything else after integer part is just invalid data
	    return BADVERSION($s,$errstr,"Invalid version format (non-numeric data)");
	}

	# scan the fractional part after the decimal point
	if ($d && !isDIGIT($d) && ($strict || ! ($d eq ';' || isSPACE($d) || $d eq '}') )) {
		# $strict or lax-but-not-the-end
		return BADVERSION($s,$errstr,"Invalid version format (fractional part required)");
	}

	while (isDIGIT($d)) {
	    $d++;
	    if ($d eq '.' && isDIGIT($d-1)) {
		if ($alpha) {
		    return BADVERSION($s,$errstr,"Invalid version format (underscores before decimal)");
		}
		if ($strict) {
		    return BADVERSION($s,$errstr,"Invalid version format (dotted-decimal versions must begin with 'v')");
		}
		$d = $s; # start all over again
		$qv = TRUE;
		goto dotted_decimal_version;
	    }
	    if ($d eq '_') {
		if ($strict) {
		    return BADVERSION($s,$errstr,"Invalid version format (no underscores)");
		}
		if ( $alpha ) {
		    return BADVERSION($s,$errstr,"Invalid version format (multiple underscores)");
		}
		if ( ! isDIGIT($d+1) ) {
		    return BADVERSION($s,$errstr,"Invalid version format (misplaced underscore)");
		}
		$d++;
		$alpha = TRUE;
	    }
	}
    }

version_prescan_finish:
    while (isSPACE($d)) {
	$d++;
    }

    if ($d && !isDIGIT($d) && (! ($d eq ';' || $d eq '}') )) {
	# trailing non-numeric data
	return BADVERSION($s,$errstr,"Invalid version format (non-numeric data)");
    }

    if (defined $sqv) {
	$$sqv = $qv;
    }
    if (defined $swidth) {
	$$swidth = $width;
    }
    if (defined $ssaw_decimal) {
	$$ssaw_decimal = $saw_decimal;

src/inc/version/vpp.pm  view on Meta::CPAN

	$$salpha = $alpha;
    }
    return $d;
}

sub scan_version {
    my ($s, $rv, $qv) = @_;
    my $start;
    my $pos;
    my $last;
    my $errstr;
    my $saw_decimal = 0;
    my $width = 3;
    my $alpha = FALSE;
    my $vinf = FALSE;
    my @av;

    $s = new charstar $s;

    while (isSPACE($s)) { # leading whitespace is OK
	$s++;
    }

    $last = prescan_version($s, FALSE, \$errstr, \$qv, \$saw_decimal,
	\$width, \$alpha);

    if ($errstr) {
	# 'undef' is a special case and not an error
	if ( $s ne 'undef') {
	    use Carp;
	    Carp::croak($errstr);
	}
    }

    $start = $s;
    if ($s eq 'v') {
	$s++;
    }
    $pos = $s;

    if ( $qv ) {

src/ppport.h  view on Meta::CPAN


  --version                   show version

  --patch=file                write one patch file with changes
  --copy=suffix               write changed copies with suffix
  --diff=program              use diff program and options

  --compat-version=version    provide compatibility with Perl version
  --cplusplus                 accept C++ comments

  --quiet                     don't output anything except fatal errors
  --nodiag                    don't show diagnostics
  --nohints                   don't show hints
  --nochanges                 don't suggest changes
  --nofilter                  don't filter input files

  --strip                     strip all script and doc functionality from
                              ppport.h

  --list-provided             list provided API
  --list-unsupported          list unsupported API

src/ppport.h  view on Meta::CPAN


=head2 --cplusplus

Usually, F<ppport.h> will detect C++ style comments and
replace them with C style comments for portability reasons.
Using this option instructs F<ppport.h> to leave C++
comments untouched.

=head2 --quiet

Be quiet. Don't print anything except fatal errors.

=head2 --nodiag

Don't output any diagnostic messages. Only portability
alerts will be printed.

=head2 --nohints

Don't output any hints. Hints often contain useful portability
notes. Warnings will still be displayed.

src/ppport.h  view on Meta::CPAN

PL_comppad||5.008001|
PL_copline|5.019002||p
PL_curcop|5.004050||p
PL_curpad||5.005000|
PL_curstash|5.004050||p
PL_debstash|5.004050||p
PL_defgv|5.004050||p
PL_diehook|5.004050||p
PL_dirty|5.004050||p
PL_dowarn|||pn
PL_errgv|5.004050||p
PL_error_count|5.019002||p
PL_expect|5.019002||p
PL_hexdigit|5.005000||p
PL_hints|5.005000||p
PL_in_my_stash|5.019002||p
PL_in_my|5.019002||p
PL_keyword_plugin||5.011002|
PL_last_in_gv|||n
PL_laststatval|5.005000||p
PL_lex_state|5.019002||p
PL_lex_stuff|5.019002||p

src/ppport.h  view on Meta::CPAN

PadnameIsSTATE|||
PadnameLEN||5.019003|
PadnameOURSTASH|||
PadnameOUTER|||
PadnamePV||5.019003|
PadnameSV||5.019003|
PadnameTYPE|||
PadnameUTF8||5.019003|
PadnamelistARRAY||5.019003|
PadnamelistMAX||5.019003|
PerlIO_clearerr||5.007003|
PerlIO_close||5.007003|
PerlIO_context_layers||5.009004|
PerlIO_eof||5.007003|
PerlIO_error||5.007003|
PerlIO_fileno||5.007003|
PerlIO_fill||5.007003|
PerlIO_flush||5.007003|
PerlIO_get_base||5.007003|
PerlIO_get_bufsiz||5.007003|
PerlIO_get_cnt||5.007003|
PerlIO_get_ptr||5.007003|
PerlIO_read||5.007003|
PerlIO_seek||5.007003|
PerlIO_set_cnt||5.007003|
PerlIO_set_ptrcnt||5.007003|
PerlIO_setlinebuf||5.007003|
PerlIO_stderr||5.007003|
PerlIO_stdin||5.007003|
PerlIO_stdout||5.007003|
PerlIO_tell||5.007003|
PerlIO_unread||5.007003|
PerlIO_write||5.007003|
Perl_signbit||5.009005|n
PoisonFree|5.009004||p
PoisonNew|5.009004||p
PoisonWith|5.009004||p
Poison|5.008000||p

src/ppport.h  view on Meta::CPAN

ptr_table_new||5.009005|
ptr_table_split||5.009005|
ptr_table_store||5.009005|
push_scope|||
put_byte|||
put_latin1_charclass_innards|||
pv_display|5.006000||p
pv_escape|5.009004||p
pv_pretty|5.009004||p
pv_uni_display||5.007003|
qerror|||
qsortsvu|||
re_compile||5.009005|
re_croak2|||
re_dup_guts|||
re_intuit_start||5.019001|
re_intuit_string||5.006000|
re_op_compile|||
readpipe_override|||
realloc||5.007002|n
reentrant_free||5.019003|
reentrant_init||5.019003|
reentrant_retry||5.019003|vn
reentrant_size||5.019003|
ref_array_or_hash|||
refcounted_he_chain_2hv|||
refcounted_he_fetch_pvn|||
refcounted_he_fetch_pvs|||
refcounted_he_fetch_pv|||

src/ppport.h  view on Meta::CPAN

warner_nocontext|||vn
warner|5.006000|5.004000|pv
warn|||v
was_lvalue_sub|||
watch|||
whichsig_pvn||5.015004|
whichsig_pv||5.015004|
whichsig_sv||5.015004|
whichsig|||
win32_croak_not_implemented|||n
with_queued_errors|||
wrap_op_checker||5.015008|
write_to_stderr|||
xmldump_all_perl|||
xmldump_all|||
xmldump_attr|||
xmldump_eval|||
xmldump_form|||
xmldump_indent|||v
xmldump_packsubs_perl|||
xmldump_packsubs|||
xmldump_sub_perl|||
xmldump_sub|||
xmldump_vindent|||
xs_apiversion_bootcheck|||
xs_version_bootcheck|||
yyerror_pvn|||
yyerror_pv|||
yyerror|||
yylex|||
yyparse|||
yyunlex|||
yywarn|||
);

if (exists $opt{'list-unsupported'}) {
  my $f;
  for $f (sort { lc $a cmp lc $b } keys %API) {
    next unless $API{$f}{todo};

src/ppport.h  view on Meta::CPAN

  }

  my $s = $warnings != 1 ? 's' : '';
  my $warn = $warnings ? " ($warnings warning$s)" : '';
  info("Analysis completed$warn");

  if ($file{changes}) {
    if (exists $opt{copy}) {
      my $newfile = "$filename$opt{copy}";
      if (-e $newfile) {
        error("'$newfile' already exists, refusing to write copy of '$filename'");
      }
      else {
        local *F;
        if (open F, ">$newfile") {
          info("Writing copy of '$filename' with changes to '$newfile'");
          print F $c;
          close F;
        }
        else {
          error("Cannot open '$newfile' for writing: $!");
        }
      }
    }
    elsif (exists $opt{patch} || $opt{changes}) {
      if (exists $opt{patch}) {
        unless ($patch_opened) {
          if (open PATCH, ">$opt{patch}") {
            $patch_opened = 1;
          }
          else {
            error("Cannot open '$opt{patch}' for writing: $!");
            delete $opt{patch};
            $opt{changes} = 1;
            goto fallback;
          }
        }
        mydiff(\*PATCH, $filename, $c);
      }
      else {
fallback:
        info("Suggested changes:");

src/ppport.h  view on Meta::CPAN


  if (!defined $diff) {
    $diff = run_diff('diff -u', $file, $str);
  }

  if (!defined $diff) {
    $diff = run_diff('diff', $file, $str);
  }

  if (!defined $diff) {
    error("Cannot generate a diff. Please install Text::Diff or use --copy.");
    return;
  }

  print F $diff;
}

sub run_diff
{
  my($prog, $file, $str) = @_;
  my $tmp = 'dppptemp';

src/ppport.h  view on Meta::CPAN

        $diff .= $_;
      }
      close F;
      unlink $tmp;
      return $diff;
    }

    unlink $tmp;
  }
  else {
    error("Cannot open '$tmp' for writing: $!");
  }

  return undef;
}

sub rec_depend
{
  my($func, $seen) = @_;
  return () unless exists $depends{$func};
  $seen = {%{$seen||{}}};

src/ppport.h  view on Meta::CPAN

  $opt{quiet} and return;
  $opt{diag} and print @_, "\n";
}

sub warning
{
  $opt{quiet} and return;
  print "*** ", @_, "\n";
}

sub error
{
  print "*** ERROR: ", @_, "\n";
}

my %given_hints;
my %given_warnings;
sub hint
{
  $opt{quiet} and return;
  my $func = shift;

src/ppport.h  view on Meta::CPAN

#  endif
#endif

#define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10))
#define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION))

/* It is very unlikely that anyone will try to use this with Perl 6
   (or greater), but who knows.
 */
#if PERL_REVISION != 5
#  error ppport.h only works with Perl version 5
#endif /* PERL_REVISION != 5 */
#ifndef dTHR
#  define dTHR                           dNOOP
#endif
#ifndef dTHX
#  define dTHX                           dNOOP
#endif

#ifndef dTHXa
#  define dTHXa(x)                       dNOOP

src/ppport.h  view on Meta::CPAN


#ifndef isXDIGIT
#  define isXDIGIT(c)                    isxdigit(c)
#endif

#else
# if (PERL_BCDVERSION < 0x5010000)
/* Hint: isPRINT
 * The implementation in older perl versions includes all of the
 * isSPACE() characters, which is wrong. The version provided by
 * Devel::PPPort always overrides a present buggy version.
 */
#  undef isPRINT
# endif

#ifdef HAS_QUAD
# define WIDEST_UTYPE U64TYPE
#else
# define WIDEST_UTYPE U32
#endif
#ifndef isALNUMC

src/ppport.h  view on Meta::CPAN

#  define PL_bufptr                 bufptr
#  define PL_compiling              compiling
#  define PL_copline                copline
#  define PL_curcop                 curcop
#  define PL_curstash               curstash
#  define PL_debstash               debstash
#  define PL_defgv                  defgv
#  define PL_diehook                diehook
#  define PL_dirty                  dirty
#  define PL_dowarn                 dowarn
#  define PL_errgv                  errgv
#  define PL_error_count            error_count
#  define PL_expect                 expect
#  define PL_hexdigit               hexdigit
#  define PL_hints                  hints
#  define PL_in_my                  in_my
#  define PL_laststatval            laststatval
#  define PL_lex_state              lex_state
#  define PL_lex_stuff              lex_stuff
#  define PL_linestr                linestr
#  define PL_na                     na
#  define PL_perl_destruct_level    perl_destruct_level

src/ppport.h  view on Meta::CPAN

# define PL_rsfp           D_PPP_my_PL_parser_var(rsfp)
# define PL_rsfp_filters   D_PPP_my_PL_parser_var(rsfp_filters)
# define PL_linestr        D_PPP_my_PL_parser_var(linestr)
# define PL_bufptr         D_PPP_my_PL_parser_var(bufptr)
# define PL_bufend         D_PPP_my_PL_parser_var(bufend)
# define PL_lex_state      D_PPP_my_PL_parser_var(lex_state)
# define PL_lex_stuff      D_PPP_my_PL_parser_var(lex_stuff)
# define PL_tokenbuf       D_PPP_my_PL_parser_var(tokenbuf)
# define PL_in_my          D_PPP_my_PL_parser_var(in_my)
# define PL_in_my_stash    D_PPP_my_PL_parser_var(in_my_stash)
# define PL_error_count    D_PPP_my_PL_parser_var(error_count)


#else

/* ensure that PL_parser != NULL and cannot be dereferenced */
# define PL_parser         ((void *) 1)

#endif
#ifndef mPUSHs
#  define mPUSHs(s)                      PUSHs(sv_2mortal(s))

src/ppport.h  view on Meta::CPAN

# else
#  define call_sv(sv, flags)  ((flags) & G_METHOD ? Perl_call_method(aTHX_ (char *) SvPV_nolen_const(sv), \
                                (flags) & ~G_METHOD) : Perl_call_sv(aTHX_ sv, flags))
# endif
#endif

/* Replace perl_eval_pv with eval_pv */

#ifndef eval_pv
#if defined(NEED_eval_pv)
static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
static
#else
extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error);
#endif

#ifdef eval_pv
#  undef eval_pv
#endif
#define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b)
#define Perl_eval_pv DPPP_(my_eval_pv)

#if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL)

SV*
DPPP_(my_eval_pv)(char *p, I32 croak_on_error)
{
    dSP;
    SV* sv = newSVpv(p, 0);

    PUSHMARK(sp);
    eval_sv(sv, G_SCALAR);
    SvREFCNT_dec(sv);

    SPAGAIN;
    sv = POPs;
    PUTBACK;

    if (croak_on_error && SvTRUE(GvSV(errgv)))
        croak(SvPVx(GvSV(errgv), na));

    return sv;
}

#endif
#endif

#ifndef vload_module
#if defined(NEED_vload_module)
static void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args);

src/ppport.h  view on Meta::CPAN

#    define     UVof      "lo"
#    define     UVxf      "lx"
#    define     UVXf      "lX"
#  elif IVSIZE == INTSIZE
#    define   IVdf      "d"
#    define   UVuf      "u"
#    define   UVof      "o"
#    define   UVxf      "x"
#    define   UVXf      "X"
#  else
#    error "cannot define IV/UV formats"
#  endif
#endif

#ifndef NVef
#  if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \
      defined(PERL_PRIfldbl) && (PERL_BCDVERSION != 0x5006000)
            /* Not very likely, but let's try anyway. */
#    define NVef          PERL_PRIeldbl
#    define NVff          PERL_PRIfldbl
#    define NVgf          PERL_PRIgldbl

src/ppport.h  view on Meta::CPAN

#ifndef ckWARN
#  ifdef G_WARN_ON
#    define  ckWARN(a)                  (PL_dowarn & G_WARN_ON)
#  else
#    define  ckWARN(a)                  PL_dowarn
#  endif
#endif

#if (PERL_BCDVERSION >= 0x5004000) && !defined(warner)
#if defined(NEED_warner)
static void DPPP_(my_warner)(U32 err, const char *pat, ...);
static
#else
extern void DPPP_(my_warner)(U32 err, const char *pat, ...);
#endif

#define Perl_warner DPPP_(my_warner)

#if defined(NEED_warner) || defined(NEED_warner_GLOBAL)

void
DPPP_(my_warner)(U32 err, const char *pat, ...)
{
  SV *sv;
  va_list args;

  PERL_UNUSED_ARG(err);

  va_start(args, pat);
  sv = vnewSVpvf(pat, &args);
  va_end(args);
  sv_2mortal(sv);
  warn("%s", SvPV_nolen(sv));
}

#define warner  Perl_warner

src/t/AFS.t  view on Meta::CPAN

# -*-cperl-*-
use strict;

use lib qw(../../inc ../inc ./inc);
use blib;

use Test::More tests => 10;

BEGIN {
    use_ok('AFS', qw (
                      error_message constant
                     )
          );
}

sub foo { return &AFS::KA_USERAUTH_DOSETPAG }

# test error_message
is(error_message(&AFS::PRNOMORE), 'may not create more groups', 'Return Code AFS::PRNOMORE');
is(error_message(180502), 'too many Ubik security objects outstanding', 'Return Code 180502');

# test subroutine returning a constant
is(foo(42,17), 65536, 'Sub Foo returns constant (2 args)');
is(foo(42), 65536, 'Sub Foo returns constant (1 arg)');
is(foo(), 65536, 'Sub Foo returns constant (no args)');

# test constant
is(constant('PRIDEXIST'), 267265, 'Constant PRIDEXIST');
is(constant('PRIDEXIST', 2), 267265, 'Constant PRIDEXIST with argument');
isnt(constant('zzz'), 267265, 'Unknown Constant zzz');



( run in 1.430 second using v1.01-cache-2.11-cpan-49f99fa48dc )