AFS-PAG-1.01000755001750000000 012224337676 11673 5ustar00eagleroot000000000000AFS-PAG-1.01/NEWS000444001750000000 115012224337676 12524 0ustar00eagleroot000000000000 User-Visible AFS::PAG Changes AFS::PAG 1.01 (2013-10-06) Define the correct preprocessor symbols to build properly if a libkafs or libkopenafs library was found. Mark autodie required for configure and use for correct automated testing behavior on Perl 5.10.0. (autodie was added to core in 5.10.1.) AFS::PAG 1.00 (2013-09-12) Initial public release with support for libkafs, libkopenafs, and Linux systems with no support library. pioctl is not yet supported, only hasafs, haspag, setpag, and unlog. The build system has only been tested on Debian. AFS-PAG-1.01/MANIFEST.SKIP000444001750000000 114712224337676 13731 0ustar00eagleroot000000000000# -*- conf -*- # Avoid version control files. ^\.git/ # Avoid generated build files. \bblib/ ^config\.log$ ^glue/ ^lib/AFS/PAG\.c$ \.o$ # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid MYMETA files ^MYMETA\. # Avoid archives of this distribution \bAFS-PAG-[\d\.\_]+ AFS-PAG-1.01/LICENSE000444001750000000 434212224337676 13040 0ustar00eagleroot000000000000Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Comment: This file documents the copyright statements and licenses for every file in this package in a machine-readable format. For a less detailed, higher-level overview, see README. . For any copyright year range specified as YYYY-ZZZZ in this file, the range specifies every single year in that closed interval. Copyright: 2013 The Board of Trustees of the Leland Stanford Junior University License: Expat Files: * Copyright: 2006-2013 The Board of Trustees of the Leland Stanford Junior University License: Expat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: . The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. . THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Files: kafs/sys-syscall.c portable/k_haspag.c portable/macros.h portable/stdbool.h portable/system.h Copyright: no copyright notice, see License License: rra-public-domain The authors hereby relinquish any claim to any copyright that they may have in this work, whether granted under contract or by operation of law or international treaty, and hereby commit to the public, at large, that they shall not, at any time in the future, seek to enforce any copyright in this work against any person or entity, or prevent any person or entity from copying, publishing, distributing or creating derivative works of this work. AFS-PAG-1.01/TODO000444001750000000 157712224337676 12532 0ustar00eagleroot000000000000 AFS::PAG To-Do List API: * Expose pioctl and find a good way to let callers use it. This will require some way of constructing the pioctl call number and arguments from inside Perl, or at least some documented guidance as to how to use pack. Build: * Add config.guess and support the libkafs replacement for the other operating systems on which it works. (Mac OS X, Solaris, and other system-call-only platforms.) * Add the necessary probes to link with OpenAFS libraries on AIX and IRIX. * Contribute back support for check_func to Config::AutoConf to clean up the code in Build.PL. * Honor all of the build settings passed to Module::Build when doing probes with Config::AutoConf. This will probably require pulling the ExtUtils::CBuilder object from Module::Build and modifying Config::AutoConf to use the same builder. AFS-PAG-1.01/META.json000444001750000000 216612224337676 13456 0ustar00eagleroot000000000000{ "abstract" : "Perl bindings for AFS PAG manipulation", "author" : [ "Russ Allbery " ], "dynamic_config" : 1, "generated_by" : "Module::Build version 0.4007, CPAN::Meta::Converter version 2.132510", "license" : [ "mit" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "AFS-PAG", "prereqs" : { "build" : { "requires" : { "ExtUtils::CBuilder" : "0" } }, "configure" : { "requires" : { "Config::AutoConf" : "0", "Module::Build" : "0.28", "autodie" : "0", "perl" : "5.010" } }, "runtime" : { "requires" : { "autodie" : "0", "perl" : "5.010" } } }, "provides" : { "AFS::PAG" : { "file" : "lib/AFS/PAG.pm", "version" : "1.01" } }, "release_status" : "stable", "resources" : { "license" : [ "http://www.opensource.org/licenses/mit-license.php" ] }, "version" : "1.01" } AFS-PAG-1.01/Build.PL000444001750000000 2311712224337676 13350 0ustar00eagleroot000000000000#!/usr/bin/perl # # Build script for the AFS::PAG distribution. # # Written by Russ Allbery # Copyright 2013 # The Board of Trustees of the Leland Stanford Junior University # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. use 5.010; use autodie; use strict; use warnings; use Config::AutoConf; use File::Basename qw(basename); use File::Path qw(remove_tree); use File::Spec; use Module::Build; # Check whether it's possible to link a program that uses a particular # function. This is written like a Config::AutoConf method and should ideally # be incorporated into that module. This macro caches its result in the # ac_cv_func_FUNCTION variable. # # $self - The Config::AutoConf state object # $function - The function to check for # $found_ref - Code reference to call if the function was found # $notfound_ref - Code reference to call if the function wasn't found # # Returns: True if the function was found, false otherwise sub check_func { my ($self, $function, $found_ref, $notfound_ref) = @_; $self = $self->_get_instance(); # Build the name of the cache variable. my $cache_name = $self->_cache_name('func', $function); # Wrap the actual check in a closure so that we can use check_cached. my $check_sub = sub { my $have_func = $self->link_if_else($self->lang_call(q{}, $function)); if ($have_func) { if (defined($found_ref) && ref($found_ref) eq 'CODE') { $found_ref->(); } } else { if (defined($notfound_ref) && ref($notfound_ref) eq 'CODE') { $notfound_ref->(); } } return $have_func; }; # Run the check and cache the results. return $self->check_cached($cache_name, "for $function", $check_sub); } # The same as check_func, but takes a list of functions to look for and checks # for each in turn. Define HAVE_FUNCTION for each function that was found, # and also run the $found_ref code each time a function was found. Run the # $notfound_ref code each time a function wasn't found. Both code references # are passed the name of the function that was found. # # $self - The Config::AutoConf state object # $functions_ref - Reference to an array of functions to check for # $found_ref - Code reference to call if a function was found # $notfound_ref - Code reference to call if a function wasn't found # # Returns: True if all functions were found, false otherwise. sub check_funcs { my ($self, $functions_ref, $user_found_ref, $user_notfound_ref) = @_; $self = $self->_get_instance(); # Build the code reference to run when a function was found. This defines # a HAVE_FUNCTION symbol, plus runs the current $found_ref if there is # one. my $func_found_ref = sub { my ($function) = @_; # Generate the name of the symbol we'll define. my $have_func_name = 'HAVE_' . uc($function); $have_func_name =~ tr/_A-Za-z0-9/_/c; # Define the symbol. $self->define_var($have_func_name, 1, "Defined when $function is available"); # Run the user-provided hook, if there is one. if (defined($user_found_ref) && ref($user_found_ref) eq 'CODE') { $user_found_ref->($function); } }; # Go through the list of functions and call check_func for each one. We # generate new closures for the found and not-found functions that pass in # the relevant function name. my $return = 1; for my $function (@{$functions_ref}) { my $found_ref = sub { $func_found_ref->($function) }; my $notfound_ref = sub { $user_notfound_ref->($function) }; $return &= check_func($self, $function, $found_ref, $notfound_ref); } return $return; } # Returns C code that includes the given headers. Used to construct prologues # for check functions. # # @headers - The headers to include # # Returns: C source as a string that includes those headers sub include { my @headers = @_; my $result = q{}; for my $header (@headers) { $result .= "#include <$header>\n"; } return $result; } # Probes the C compilation environment for the information required to build # the embedded libkafs compatibility layer. This should be a Perl equivalent # of the m4/kafs.m4 Autoconf macros from rra-c-util, plus the additional # probes needed for the compatibility layer for building the cod. Writes the # results to glue/config.h and returns a list of extra C files to add to the # module build. # # $build - The module build object, used to add additional libraries # # Returns: List of extra directories to add to the module build # Throws: Text exception if the module cannot be built in this environment sub config_kafs { my ($build) = @_; my $config = Config::AutoConf->new; # Checks needed for the generic portability layer. $config->check_default_headers; if (!$config->check_header('stdbool.h')) { $config->check_type('_Bool'); } $config->check_type('sig_atomic_t', undef, undef, include(qw(sys/types.h signal.h))); $config->check_type('ssize_t', undef, undef, include('sys/types.h')); # Checks needed by all libkafs code. $config->check_header('sys/ioccom.h'); # If the user passed extra flags into Build.PL, use them for probes. if ($build->extra_linker_flags) { my $flags = $build->extra_linker_flags; my @flags = ref($flags) ? @{$flags} : ($flags); $config->push_link_flags(@flags); } # Check if we have a library available to us. If so, check whether it # provides k_pioctl and k_haspag and then return. my $lib = $config->search_libs('k_hasafs', ['kafs', 'kopenafs']); my @files; if ($lib) { $config->define_var('HAVE_K_HASAFS', 1, 'Define to 1 if you have the k_hasafs function.'); my $flags = $build->extra_linker_flags; my @flags = ref($flags) ? @{$flags} : ($flags); $build->extra_linker_flags(@flags, '-l' . $lib); if ($lib eq 'kafs') { $config->check_header('kafs.h'); } elsif ($lib eq 'kopenafs') { $config->check_header('kopenafs.h'); } check_funcs($config, ['k_pioctl']); if (!check_funcs($config, ['k_haspag'])) { @files = qw(portable/k_haspag.c); } } else { @files = qw(kafs/kafs.c portable/k_haspag.c); $config->define_var('HAVE_KAFS_REPLACEMENT', 1, 'Define to 1 if the libkafs replacement is built.'); $config->define_var('HAVE_KAFS_LINUX', 1, 'Define to 1 to use the Linux AFS /proc interface.'); } # Write out the configuration. $config->write_config_h('glue/config.h'); # Return the list of files to add to the build. return @files; } # Basic package configuration. my $build = Module::Build->new( module_name => 'AFS::PAG', dist_version_from => 'lib/AFS/PAG.pm', dist_author => 'Russ Allbery ', license => 'mit', recursive_test_files => 1, add_to_cleanup => [qw(config.log cover_db glue/*.o)], # XS configuration. c_source => 'glue', extra_compiler_flags => ['-I.'], # Other package relationships. configure_requires => { 'Config::AutoConf' => 0, 'Module::Build' => '0.28', autodie => 0, perl => '5.010', }, requires => { autodie => 0, perl => '5.010', }, ); # Create the directory that will be used for config.h and stub files. remove_tree('glue'); mkdir('glue'); # Write out the config.h file and get the list of files to add to the build. my @c_files = config_kafs($build); # We can't just add the C source files directly to the build for a couple of # reasons. First, Perl ships its own config.h, so we need to be sure we # include our own instead of Perl's before building any source, since all of # the files (copied from rra-c-util, so we don't want to change them) include # config.h as the first action. Second, Module::Build can only handle one # directory of supplemental source files. # # We deal with both of these issues by creating stub files in a subdirectory # named glue that include glue/config.h and then the actual C source file. for my $file (@c_files) { my $glue_file = File::Spec->catfile('glue', basename($file)); open(my $wrapper, '>', $glue_file); say {$wrapper} '#include ' or die "Cannot write to $glue_file: $!\n"; say {$wrapper} "#include <$file>" or die "Cannot write to $glue_file: $!\n"; close($wrapper); } # Generate the build script. $build->create_build_script; AFS-PAG-1.01/README000444001750000000 1342212224337676 12732 0ustar00eagleroot000000000000 AFS::PAG 1.01 (Perl bindings for AFS PAG manipulation) Written by Russ Allbery Copyright 2013 The Board of Trustees of the Leland Stanford Junior University. This software is distributed under a BSD-style license. Please see the section LICENSE below for more information. BLURB AFS::PAG provides the standard PAG and token manipulation functions setpag and unlog to Perl programs as a native module. It also provides the hasafs and haspag functions to detect whether AFS is running and whether the current process is in a PAG. Unlike the more general AFS module, it will build with any recent OpenAFS, Heimdal's libkafs, or on Linux without any AFS libraries at all. DESCRIPTION AFS is a distributed file system allowing cross-platform sharing of files among multiple computers. It associates client credentials (called AFS tokens) with a Process Authentication Group, or PAG. AFS::PAG makes available in Perl the PAG manipulation functions provided by the libkafs or libkopenafs libraries. With the functions provided by this module, a Perl program can detect whether AFS is available on the local system and whether it is currently running inside a PAG. It can also create a new PAG and put the current process in it, and remove any AFS tokens in the current PAG. This module doesn't provide a direct way to obtain new AFS tokens, only to create a new PAG so that any obtained tokens are isolated from other processes on the system and can be inherited by child processes. REQUIREMENTS Perl 5.10.1 or later, the Config::AutoConf module, and a C compiler are required to build this module. On any platform other than Linux, either the kafs library (from Heimdal) or the kopenafs library (from recent versions of OpenAFS) are also required. The following additional Perl modules will be used by the test suite if present: IPC::System::Simple Test::MinimumVersion Test::Perl::Critic Test::Pod Test::Pod::Coverage Test::Spelling Test::Strict Test::Synopsis All are available on CPAN. Those tests will be skipped if the modules are not available. To enable tests that may be sensitive to the local environment or that produce a lot of false positives without uncovering many problems, set RRA_MAINTAINER_TESTS to a true value. BUILDING AND INSTALLATION AFS::PAG uses Module::Build and can be installed using the same process as any other Module::Build module: perl Build.PL ./Build ./Build test ./Build install If your libkafs or libkopenafs libraries are in a path that's not searched by your linker by default, pass them to Build.PL using the --extra-linker-flags option, as in: perl Build.PL --extra-linker-flags '-L/opt/openafs/lib' You will have to run the last command as root unless you're installing into a local Perl module tree in your home directory. SUPPORT The AFS::PAG web page at: http://www.eyrie.org/~eagle/software/afs-pag/ will always have the current version of this package, the current documentation, and pointers to any additional resources. For bug tracking, this package uses the CPAN bug tracker at: https://rt.cpan.org/Public/Dist/Display.html?Name=AFS-PAG I welcome bug reports and patches for this package at rra@stanford.edu or via the CPAN bug tracker. However, please be aware that I tend to be extremely busy and work projects often take priority. I'll save your mail and get to it as soon as I can, but it may take me a couple of months. SOURCE REPOSITORY AFS::PAG is maintained using Git. You can access the current source by cloning the repository at: git://git.eyrie.org/afs/afs-pag.git or view the repository via the web at: http://git.eyrie.org/?p=afs/afs-pag.git When contributing modifications, either patches (possibly generated by git format-patch) or Git pull requests are welcome. LICENSE The AFS::PAG package as a whole is covered by the following copyright statement and license: Copyright 2013 The Board of Trustees of the Leland Stanford Junior University Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. All individual files without an explicit exception below are released under this license. Some files may have additional copyright holders as noted in those files. There is detailed information about the licensing of each file in the LICENSE file in this distribution. Some files in this distribution are individually released under different licenses, all of which are compatible with the above general package license but which may require preservation of additional notices. All required notices are preserved in the LICENSE file. AFS-PAG-1.01/.gitignore000444001750000000 17512224337676 14003 0ustar00eagleroot000000000000/Build /MANIFEST.bak /MYMETA.json /MYMETA.yml /_build/ /lib/WebAuth.c /blib/ /config.log /cover_db /glue/ /lib/AFS/PAG.c *.o AFS-PAG-1.01/MANIFEST000444001750000000 115312224337676 13161 0ustar00eagleroot000000000000.gitignore Build.PL kafs/kafs.c kafs/sys-darwin10.c kafs/sys-darwin8.c kafs/sys-linux.c kafs/sys-solaris.c kafs/sys-syscall.c lib/AFS/PAG.pm lib/AFS/PAG.xs LICENSE MANIFEST This list of files MANIFEST.SKIP NEWS portable/k_haspag.c portable/kafs.h portable/macros.h portable/stdbool.h portable/system.h README t/data/perl.conf t/data/perlcriticrc t/data/perltidyrc t/docs/pod-coverage.t t/docs/pod-spelling.t t/docs/pod.t t/docs/synopsis.t t/lib/Test/RRA.pm t/lib/Test/RRA/Config.pm t/pag/basic.t t/pag/isolation.t t/style/coverage.t t/style/critic.t t/style/minimum-version.t t/style/strict.t TODO META.yml META.json AFS-PAG-1.01/META.yml000444001750000000 120012224337676 13272 0ustar00eagleroot000000000000--- abstract: 'Perl bindings for AFS PAG manipulation' author: - 'Russ Allbery ' build_requires: ExtUtils::CBuilder: 0 configure_requires: Config::AutoConf: 0 Module::Build: 0.28 autodie: 0 perl: 5.010 dynamic_config: 1 generated_by: 'Module::Build version 0.4007, CPAN::Meta::Converter version 2.132510' license: mit meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: AFS-PAG provides: AFS::PAG: file: lib/AFS/PAG.pm version: 1.01 requires: autodie: 0 perl: 5.010 resources: license: http://www.opensource.org/licenses/mit-license.php version: 1.01 AFS-PAG-1.01/lib000755001750000000 012224337676 12441 5ustar00eagleroot000000000000AFS-PAG-1.01/lib/AFS000755001750000000 012224337676 13052 5ustar00eagleroot000000000000AFS-PAG-1.01/lib/AFS/PAG.xs000444001750000000 446712224337676 14205 0ustar00eagleroot000000000000/* -*- c -*- * Perl bindings for the libkafs PAG functions. * * This is an XS source file, suitable for processing by xsubpp, that * generates Perl bindings for the PAG functions in the libkafs library or any * similar library that provides the same interface. The module exports those * functions to Perl without the k_* prefix, since Perl already has good * namespace management for imports. * * Written by Russ Allbery * Copyright 2013 * The Board of Trustees of the Leland Stanford Junior University * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #include #include #include #include #include #include #include /* XS code below this point. */ MODULE = AFS::PAG PACKAGE = AFS::PAG PROTOTYPES: DISABLE void hasafs() PPCODE: if (k_hasafs()) XSRETURN_YES; else XSRETURN_UNDEF; void haspag() PPCODE: if (k_haspag()) XSRETURN_YES; else XSRETURN_UNDEF; void setpag() PPCODE: if (k_setpag() == 0) XSRETURN_YES; else croak("PAG creation failed: %s", strerror(errno)); void unlog() PPCODE: if (k_unlog() == 0) XSRETURN_YES; else croak("Token deletion failed: %s", strerror(errno)); AFS-PAG-1.01/lib/AFS/PAG.pm000444001750000000 1216012224337676 14174 0ustar00eagleroot000000000000# Perl bindings for the PAG functions in libkafs. # # This is the Perl boostrap file for the AFS::PAG module, nearly all of which # is implemented in XS. For the actual source, see PAG.xs. This file # contains the bootstrap and export code and the documentation. # # Written by Russ Allbery # Copyright 2013 # The Board of Trustees of the Leland Stanford Junior University # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. package AFS::PAG; use 5.008; use strict; use warnings; use base qw(DynaLoader); use Exporter qw(import); our (@EXPORT_OK, $VERSION); # Set all import-related variables in a BEGIN block for robustness. BEGIN { @EXPORT_OK = qw(hasafs haspag setpag unlog); $VERSION = '1.01'; } # Load the binary module. bootstrap AFS::PAG $VERSION; 1; __END__ =for stopwords Allbery AFS PAG libkafs libkopenafs Kerberos aklog UID kdestroy =head1 NAME AFS::PAG - Perl bindings for AFS PAG manipulation =head1 SYNOPSIS use AFS::PAG qw(hasafs setpag unlog); if (hasafs()) { setpag(); system('aklog') == 0 or die "cannot get tokens\n"; do_afs_things(); unlog(); } =head1 DESCRIPTION AFS is a distributed file system allowing cross-platform sharing of files among multiple computers. It associates client credentials (called AFS tokens) with a Process Authentication Group, or PAG. AFS::PAG makes available in Perl the PAG manipulation functions provided by the libkafs or libkopenafs libraries. With the functions provided by this module, a Perl program can detect whether AFS is available on the local system (hasafs()) and whether it is currently running inside a PAG (haspag()). It can also create a new PAG and put the current process in it (setpag()) and remove any AFS tokens in the current PAG (unlog()). Note that this module doesn't provide a direct way to obtain new AFS tokens. Programs that need AFS tokens should normally obtain Kerberos tickets (via whatever means) and then run the program B, which comes with most AFS distributions. This program will create AFS tokens from the current Kerberos ticket cache and store them in the current PAG. To isolate those credentials from the rest of the system, call setpag() before running B. =head1 FUNCTIONS This module provides the following functions, none of which are exported by default: =over 4 =item hasafs() Returns true if the local host is running an AFS client and false otherwise. =item haspag() Returns true if the current process is running inside a PAG and false otherwise. AFS tokens obtained outside of a PAG are visible to any process on the system outside of a PAG running as the same UID. AFS tokens obtained inside a PAG are visible to any process in the same PAG, regardless of UID. =item setpag() Creates a new, empty PAG and put the current process in it. This should normally be called before obtaining new AFS tokens to isolate those tokens from other processes on the system. Returns true on success and throws an exception on failure. =item unlog() Deletes all AFS tokens in the current PAG, similar to the action of B on a Kerberos ticket cache. Returns true on success and throws an exception on failure. =back =head1 DIAGNOSTICS =over 4 =item PAG creation failed: %s setpag() failed. The end of the error message will be a translation of the system call error number. =item Token deletion failed: %s unlog() failed. The end of the error message will be a translation of the system call error number. =back =head1 RESTRICTIONS This module currently doesn't provide the k_pioctl() or pioctl() function to make lower-level AFS system calls. It also doesn't provide the libkafs functions to obtain AFS tokens from Kerberos tickets directly without using an external ticket cache. This prevents use of internal Kerberos ticket caches (such as memory caches), since the Kerberos tickets used to generate AFS tokens have to be visible to an external B program. =head1 AUTHOR Russ Allbery =head1 SEE ALSO aklog(1) The current version of this module is always available from its web site at L. =cut AFS-PAG-1.01/portable000755001750000000 012224337676 13503 5ustar00eagleroot000000000000AFS-PAG-1.01/portable/system.h000444001750000000 564312224337676 15345 0ustar00eagleroot000000000000/* * Standard system includes and portability adjustments. * * Declarations of routines and variables in the C library. Including this * file is the equivalent of including all of the following headers, * portably: * * #include * #include * #include * #include * #include * #include * #include * #include * #include * #include * * Missing functions are provided via #define or prototyped if available from * the portable helper library. Also provides some standard #defines. * * The canonical version of this file is maintained in the rra-c-util package, * which can be found at . * * Written by Russ Allbery * * The authors hereby relinquish any claim to any copyright that they may have * in this work, whether granted under contract or by operation of law or * international treaty, and hereby commit to the public, at large, that they * shall not, at any time in the future, seek to enforce any copyright in this * work against any person or entity, or prevent any person or entity from * copying, publishing, distributing or creating derivative works of this * work. */ #ifndef PORTABLE_SYSTEM_H #define PORTABLE_SYSTEM_H 1 /* Make sure we have our configuration information. */ #include /* BEGIN_DECL and __attribute__. */ #include /* A set of standard ANSI C headers. We don't care about pre-ANSI systems. */ #include #include #include #include #include #include #if HAVE_STRINGS_H # include #endif #if HAVE_INTTYPES_H # include #endif #if HAVE_STDINT_H # include #endif #if HAVE_UNISTD_H # include #endif /* SCO OpenServer gets int32_t from here. */ #if HAVE_SYS_BITYPES_H # include #endif /* Get the bool type. */ #include /* Windows provides snprintf under a different name. */ #ifdef _WIN32 # define snprintf _snprintf #endif /* Define sig_atomic_t if it's not available in signal.h. */ #ifndef HAVE_SIG_ATOMIC_T typedef int sig_atomic_t; #endif /* Windows does not define ssize_t. */ #ifndef HAVE_SSIZE_T typedef ptrdiff_t ssize_t; #endif /* * POSIX requires that these be defined in . If one of them has * been defined, all the rest almost certainly have. */ #ifndef STDIN_FILENO # define STDIN_FILENO 0 # define STDOUT_FILENO 1 # define STDERR_FILENO 2 #endif /* * C99 requires va_copy. Older versions of GCC provide __va_copy. Per the * Autoconf manual, memcpy is a generally portable fallback. */ #ifndef va_copy # ifdef __va_copy # define va_copy(d, s) __va_copy((d), (s)) # else # define va_copy(d, s) memcpy(&(d), &(s), sizeof(va_list)) # endif #endif #endif /* !PORTABLE_SYSTEM_H */ AFS-PAG-1.01/portable/k_haspag.c000444001750000000 626512224337676 15572 0ustar00eagleroot000000000000/* * Replacement for missing k_haspag kafs function. * * k_haspag is a relatively new addition to the kafs interface (implemented by * Heimdal's libkafs and OpenAFS's libkopenafs). It returns true if the * current process is in a PAG and false otherwise. This is a replacement * function for libraries that don't have it or for use with a replacement * kafs layer. It falls back on looking at the current process's supplemental * groups if the system call isn't supported or if k_pioctl isn't available. * * The canonical version of this file is maintained in the rra-c-util package, * which can be found at . * * Written by Russ Allbery * * The authors hereby relinquish any claim to any copyright that they may have * in this work, whether granted under contract or by operation of law or * international treaty, and hereby commit to the public, at large, that they * shall not, at any time in the future, seek to enforce any copyright in this * work against any person or entity, or prevent any person or entity from * copying, publishing, distributing or creating derivative works of this * work. */ #include #include #include #ifdef HAVE_SYS_IOCCOM_H # include #endif #include /* * The haspag function. Returns true if the current process is in a PAG, * false otherwise. This attempts a system call, and if that fails, falls * back on looking for supplemental groups that match the AFS groups. */ int k_haspag(void) { int ngroups, i; gid_t *groups; uint32_t pag, g0, g1, hi, lo; /* First, try the system call if k_pioctl is available. */ #ifdef HAVE_K_PIOCTL int result; struct ViceIoctl iob; iob.in = NULL; iob.in_size = 0; iob.out = (void *) &pag; iob.out_size = sizeof(pag); result = k_pioctl(NULL, _IOW('C', 13, struct ViceIoctl), &iob, 0); if (result == 0) return pag != (uint32_t) -1; #endif /* * If that failed, the cache manager may not support the VIOC_GETPAG * system call. Fall back on analyzing the groups. */ ngroups = getgroups(0, NULL); groups = malloc(sizeof(*groups) * ngroups); if (groups == NULL) return 0; ngroups = getgroups(ngroups, groups); /* * Strictly speaking, the single group PAG is only used on Linux, but * check it everywhere anyway to simplify life. */ for (i = 0; i < ngroups; i++) if (((groups[i] >> 24) & 0xff) == 'A') { free(groups); return 1; } /* * Check for the PAG group pair. The first two groups, when combined with * a rather strange formula, must result in a number matching the single * group number we already checked for. */ if (ngroups < 2) { free(groups); return 0; } g0 = (groups[0] & 0xffff) - 0x3f00; g1 = (groups[1] & 0xffff) - 0x3f00; free(groups); if (g0 < 0xc0000 && g1 < 0xc0000) { lo = ((g0 & 0x3fff) << 14) | (g1 & 0x3fff); hi = (g1 >> 14) + (g0 >> 14) * 3; pag = ((hi << 28) | lo); return ((pag >> 24) & 0xff) == 'A'; } return 0; } AFS-PAG-1.01/portable/macros.h000444001750000000 463212224337676 15302 0ustar00eagleroot000000000000/* * Portability macros used in include files. * * The canonical version of this file is maintained in the rra-c-util package, * which can be found at . * * Written by Russ Allbery * * The authors hereby relinquish any claim to any copyright that they may have * in this work, whether granted under contract or by operation of law or * international treaty, and hereby commit to the public, at large, that they * shall not, at any time in the future, seek to enforce any copyright in this * work against any person or entity, or prevent any person or entity from * copying, publishing, distributing or creating derivative works of this * work. */ #ifndef PORTABLE_MACROS_H #define PORTABLE_MACROS_H 1 /* * __attribute__ is available in gcc 2.5 and later, but only with gcc 2.7 * could you use the __format__ form of the attributes, which is what we use * (to avoid confusion with other macros). */ #ifndef __attribute__ # if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7) # define __attribute__(spec) /* empty */ # endif #endif /* * We use __alloc_size__, but it was only available in fairly recent versions * of GCC. Suppress warnings about the unknown attribute if GCC is too old. * We know that we're GCC at this point, so we can use the GCC variadic macro * extension, which will still work with versions of GCC too old to have C99 * variadic macro support. */ #if !defined(__attribute__) && !defined(__alloc_size__) # if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3) # define __alloc_size__(spec, args...) /* empty */ # endif #endif /* * LLVM and Clang pretend to be GCC but don't support all of the __attribute__ * settings that GCC does. For them, suppress warnings about unknown * attributes on declarations. This unfortunately will affect the entire * compilation context, but there's no push and pop available. */ #if !defined(__attribute__) && (defined(__llvm__) || defined(__clang__)) # pragma GCC diagnostic ignored "-Wattributes" #endif /* * BEGIN_DECLS is used at the beginning of declarations so that C++ * compilers don't mangle their names. END_DECLS is used at the end. */ #undef BEGIN_DECLS #undef END_DECLS #ifdef __cplusplus # define BEGIN_DECLS extern "C" { # define END_DECLS } #else # define BEGIN_DECLS /* empty */ # define END_DECLS /* empty */ #endif #endif /* !PORTABLE_MACROS_H */ AFS-PAG-1.01/portable/kafs.h000444001750000000 1020512224337676 14753 0ustar00eagleroot000000000000/* * Portability wrapper around the kafs API. * * This header includes kafs.h if it's available, prototypes k_hasafs, * k_setpag, and k_unlog replacements (generally provided by the kafs * replacement library) imlemented in terms of our system call layer or * lsetpag if it is available and libkafs isn't, and as a last resort provides * a k_hasafs function that always fails and k_setpag and k_unlog functions * that always succeed. * * It also defines the HAVE_KAFS macro to 1 if some AFS support was available, * in case programs that use it want to handle the case of no AFS support * differently (such as in help output). * * The canonical version of this file is maintained in the rra-c-util package, * which can be found at . * * Written by Russ Allbery * Copyright 2006, 2007, 2008, 2010, 2013 * The Board of Trustees of the Leland Stanford Junior University * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #ifndef PORTABLE_KAFS_H #define PORTABLE_KAFS_H 1 #include #ifdef HAVE_KERBEROS # include #endif #include #include #ifdef HAVE_SYS_IOCCOM_H # include #endif #include BEGIN_DECLS /* Assume we have some AFS support available and #undef below if not. */ #define HAVE_KAFS 1 /* We have a libkafs or libkopenafs library. */ #if HAVE_K_HASAFS # if HAVE_KAFS_H # include # elif HAVE_KOPENAFS_H # include # else struct ViceIoctl { void *in, *out; short in_size; short out_size; }; int k_hasafs(void); int k_pioctl(char *, struct ViceIoctl *, void *, int); int k_setpag(void); int k_unlog(void); # endif # ifdef HAVE_K_HASPAG # if !defined(HAVE_KAFS_H) && !defined(HAVE_KOPENAFS_H) int k_haspag(void); # endif # else int k_haspag(void) __attribute__((__visibility__("hidden"))); # endif /* We're linking directly to the OpenAFS libraries. */ #elif HAVE_LSETPAG # if HAVE_AFS_AFSSYSCALLS_H # include # else int lsetpag(void); int lpioctl(char *, int, void *, int); # endif # define k_hasafs() (1) # define k_pioctl(p, c, a, f) lpioctl((p), (c), (a), (f)) # define k_setpag() lsetpag() # define k_unlog() (errno = ENOSYS, -1) int k_haspag(void) __attribute__((__visibility__("hidden"))); /* We're using our local kafs replacement. */ #elif HAVE_KAFS_REPLACEMENT # define HAVE_K_PIOCTL 1 struct ViceIoctl { void *in, *out; short in_size; short out_size; }; /* Default to a hidden visibility for all portability functions. */ #pragma GCC visibility push(hidden) int k_hasafs(void); int k_haspag(void); int k_pioctl(char *, int, struct ViceIoctl *, int); int k_setpag(void); int k_unlog(void); /* Undo default visibility change. */ #pragma GCC visibility pop /* We have no kafs implementation available. */ #else # undef HAVE_KAFS # define k_hasafs() (0) # define k_haspag() (0) # define k_pioctl(p, c, a, f) (errno = ENOSYS, -1) # define k_setpag() (errno = ENOSYS, -1) # define k_unlog() (errno = ENOSYS, -1) #endif END_DECLS #endif /* PORTABLE_KAFS_H */ AFS-PAG-1.01/portable/stdbool.h000444001750000000 337412224337676 15466 0ustar00eagleroot000000000000/* * Portability wrapper around . * * Provides the bool and _Bool types and the true and false constants, * following the C99 specification, on hosts that don't have stdbool.h. This * logic is based heavily on the example in the Autoconf manual. * * The canonical version of this file is maintained in the rra-c-util package, * which can be found at . * * Written by Russ Allbery * * The authors hereby relinquish any claim to any copyright that they may have * in this work, whether granted under contract or by operation of law or * international treaty, and hereby commit to the public, at large, that they * shall not, at any time in the future, seek to enforce any copyright in this * work against any person or entity, or prevent any person or entity from * copying, publishing, distributing or creating derivative works of this * work. */ #ifndef PORTABLE_STDBOOL_H #define PORTABLE_STDBOOL_H 1 /* * Allow inclusion of config.h to be skipped, since sometimes we have to use a * stripped-down version of config.h with a different name. */ #ifndef CONFIG_H_INCLUDED # include #endif #if HAVE_STDBOOL_H # include #else # if HAVE__BOOL # define bool _Bool # else # ifdef __cplusplus typedef bool _Bool; # elif _WIN32 # include # define bool BOOL # else typedef unsigned char _Bool; # define bool _Bool # endif # endif # define false 0 # define true 1 # define __bool_true_false_are_defined 1 #endif /* * If we define bool and don't tell Perl, it will try to define its own and * fail. Only of interest for programs that also include Perl headers. */ #ifndef HAS_BOOL # define HAS_BOOL 1 #endif #endif /* !PORTABLE_STDBOOL_H */ AFS-PAG-1.01/t000755001750000000 012224337676 12136 5ustar00eagleroot000000000000AFS-PAG-1.01/t/lib000755001750000000 012224337676 12704 5ustar00eagleroot000000000000AFS-PAG-1.01/t/lib/Test000755001750000000 012224337676 13623 5ustar00eagleroot000000000000AFS-PAG-1.01/t/lib/Test/RRA.pm000444001750000000 1730112224337676 14764 0ustar00eagleroot000000000000# Helper functions for test programs written in Perl. # # This module provides a collection of helper functions used by test programs # written in Perl. This is a general collection of functions that can be used # by both C packages with Automake and by stand-alone Perl modules. See # Test::RRA::Automake for additional functions specifically for C Automake # distributions. # # The canonical version of this file is maintained in the rra-c-util package, # which can be found at . # # Written by Russ Allbery # Copyright 2013 # The Board of Trustees of the Leland Stanford Junior University # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including without limitation # the rights to use, copy, modify, merge, publish, distribute, sublicense, # and/or sell copies of the Software, and to permit persons to whom the # Software is furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. package Test::RRA; use 5.006; use strict; use warnings; use Exporter; use Test::More; # For Perl 5.006 compatibility. ## no critic (ClassHierarchies::ProhibitExplicitISA) # Declare variables that should be set in BEGIN for robustness. our (@EXPORT_OK, @ISA, $VERSION); # Set $VERSION and everything export-related in a BEGIN block for robustness # against circular module loading (not that we load any modules, but # consistency is good). BEGIN { @ISA = qw(Exporter); @EXPORT_OK = qw(skip_unless_maintainer use_prereq); # This version should match the corresponding rra-c-util release, but with # two digits for the minor version, including a leading zero if necessary, # so that it will sort properly. $VERSION = '4.09'; } # Skip this test unless maintainer tests are requested. Takes a short # description of what tests this script would perform, which is used in the # skip message. Calls plan skip_all, which will terminate the program. # # $description - Short description of the tests # # Returns: undef sub skip_unless_maintainer { my ($description) = @_; if (!$ENV{RRA_MAINTAINER_TESTS}) { plan skip_all => "$description only run for maintainer"; } return; } # Attempt to load a module and skip the test if the module could not be # loaded. If the module could be loaded, call its import function manually. # If the module could not be loaded, calls plan skip_all, which will terminate # the program. # # The special logic here is based on Test::More and is required to get the # imports to happen in the caller's namespace. # # $module - Name of the module to load # @imports - Any arguments to import, possibly including a version # # Returns: undef sub use_prereq { my ($module, @imports) = @_; # If the first import looks like a version, pass it as a bare string. my $version = q{}; if (@imports >= 1 && $imports[0] =~ m{ \A \d+ (?: [.]\d+ )* \z }xms) { $version = shift(@imports); } # Get caller information to put imports in the correct package. my ($package) = caller; # Do the import with eval, and try to isolate it from the surrounding # context as much as possible. Based heavily on Test::More::_eval. ## no critic (BuiltinFunctions::ProhibitStringyEval) ## no critic (ValuesAndExpressions::ProhibitImplicitNewlines) my ($result, $error, $sigdie); { local $@ = undef; local $! = undef; local $SIG{__DIE__} = undef; $result = eval qq{ package $package; use $module $version \@imports; 1; }; $error = $@; $sigdie = $SIG{__DIE__} || undef; } # If the use failed for any reason, skip the test. if (!$result || $error) { plan skip_all => "$module required for test"; } # If the module set $SIG{__DIE__}, we cleared that via local. Restore it. ## no critic (Variables::RequireLocalizedPunctuationVars) if (defined($sigdie)) { $SIG{__DIE__} = $sigdie; } return; } 1; __END__ =for stopwords Allbery Allbery's DESC bareword sublicense MERCHANTABILITY NONINFRINGEMENT rra-c-util =head1 NAME Test::RRA - Support functions for Perl tests =head1 SYNOPSIS use Test::RRA qw(skip_unless_maintainer use_prereq); # Skip this test unless maintainer tests are requested. skip_unless_maintainer('Coding style tests'); # Load modules, skipping the test if they're not available. use_prereq('File::Slurp'); use_prereq('Test::Script::Run', '0.04'); =head1 DESCRIPTION This module collects utility functions that are useful for Perl test scripts. It assumes Russ Allbery's Perl module layout and test conventions and will only be useful for other people if they use the same conventions. =head1 FUNCTIONS None of these functions are imported by default. The ones used by a script should be explicitly imported. =over 4 =item skip_unless_maintainer(DESC) Checks whether RRA_MAINTAINER_TESTS is set in the environment and skips the whole test (by calling C from Test::More) if it is not. DESC is a description of the tests being skipped. A space and C will be appended to it and used as the skip reason. =item use_prereq(MODULE[, VERSION][, IMPORT ...]) Attempts to load MODULE with the given VERSION and import arguments. If this fails for any reason, the test will be skipped (by calling C from Test::More) with a skip reason saying that MODULE is required for the test. VERSION will be passed to C as a version bareword if it looks like a version number. The remaining IMPORT arguments will be passed as the value of an array. =back =head1 AUTHOR Russ Allbery =head1 COPYRIGHT AND LICENSE Copyright 2013 The Board of Trustees of the Leland Stanford Junior University Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. =head1 SEE ALSO Test::More(3), Test::RRA::Automake(3), Test::RRA::Config(3) This module is maintained in the rra-c-util package. The current version is available from L. =cut AFS-PAG-1.01/t/lib/Test/RRA000755001750000000 012224337676 14247 5ustar00eagleroot000000000000AFS-PAG-1.01/t/lib/Test/RRA/Config.pm000444001750000000 1535212224337676 16175 0ustar00eagleroot000000000000# Configuration for Perl test cases. # # In order to reuse the same Perl test cases in multiple packages, I use a # configuration file to store some package-specific data. This module loads # that configuration and provides the namespace for the configuration # settings. # # The canonical version of this file is maintained in the rra-c-util package, # which can be found at . package Test::RRA::Config; use 5.006; use strict; use warnings; # For Perl 5.006 compatibility. ## no critic (ClassHierarchies::ProhibitExplicitISA) use Exporter; use Test::More; # Declare variables that should be set in BEGIN for robustness. our (@EXPORT_OK, @ISA, $VERSION); # Set $VERSION and everything export-related in a BEGIN block for robustness # against circular module loading (not that we load any modules, but # consistency is good). BEGIN { @ISA = qw(Exporter); @EXPORT_OK = qw( $COVERAGE_LEVEL @COVERAGE_SKIP_TESTS @CRITIC_IGNORE $LIBRARY_PATH $MINIMUM_VERSION %MINIMUM_VERSION @POD_COVERAGE_EXCLUDE ); # This version should match the corresponding rra-c-util release, but with # two digits for the minor version, including a leading zero if necessary, # so that it will sort properly. $VERSION = '4.09'; } # If BUILD or SOURCE are set in the environment, look for data/perl.conf under # those paths for a C Automake package. Otherwise, look in t/data/perl.conf # for a standalone Perl module. Don't use Test::RRA::Automake since it may # not exist. our $PATH; for my $base ($ENV{BUILD}, $ENV{SOURCE}, 't') { next if !defined($base); my $path = "$base/data/perl.conf"; if (-r $path) { $PATH = $path; last; } } if (!defined($PATH)) { BAIL_OUT('cannot find data/perl.conf'); } # Pre-declare all of our variables and set any defaults. our $COVERAGE_LEVEL = 100; our @COVERAGE_SKIP_TESTS; our @CRITIC_IGNORE; our $LIBRARY_PATH; our $MINIMUM_VERSION = '5.008'; our %MINIMUM_VERSION; our @POD_COVERAGE_EXCLUDE; # Load the configuration. if (!do($PATH)) { my $error = $@ || $! || 'loading file did not return true'; BAIL_OUT("cannot load data/perl.conf: $error"); } 1; __END__ =for stopwords Allbery rra-c-util Automake perlcritic .libs namespace subdirectory sublicense MERCHANTABILITY NONINFRINGEMENT =head1 NAME Test::RRA::Config - Perl test configuration =head1 SYNOPSIS use Test::RRA::Config qw($MINIMUM_VERSION); print "Required Perl version is $MINIMUM_VERSION\n"; =head1 DESCRIPTION Test::RRA::Config encapsulates per-package configuration for generic Perl test programs that are shared between multiple packages using the rra-c-util infrastructure. It handles locating and loading the test configuration file for both C Automake packages and stand-alone Perl modules. Test::RRA::Config looks for a file named F relative to the root of the test directory. That root is taken from the environment variables BUILD or SOURCE (in that order) if set, which will be the case for C Automake packages using C TAP Harness. If neither is set, it expects the root of the test directory to be a directory named F relative to the current directory, which will be the case for stand-alone Perl modules. The following variables are supported: =over 4 =item $COVERAGE_LEVEL The coverage level achieved by the test suite for Perl test coverage testing using Test::Strict, as a percentage. The test will fail if test coverage less than this percentage is achieved. If not given, defaults to 100. =item @COVERAGE_SKIP_TESTS Directories under F whose tests should be skipped when doing coverage testing. This can be tests that won't contribute to coverage or tests that don't run properly under Devel::Cover for some reason (such as ones that use taint checking). F and F