Skip to content

Commit

Permalink
Switch to dzil
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Steinert committed Apr 1, 2012
1 parent 8d89087 commit 5d23a35
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 56 deletions.
1 change: 0 additions & 1 deletion .gitignore
@@ -1,7 +1,6 @@
blib/ blib/
const-c.inc const-c.inc
const-xs.inc const-xs.inc
inc/
MANIFEST.bak MANIFEST.bak
Makefile Makefile
Makefile.old Makefile.old
Expand Down
3 changes: 3 additions & 0 deletions Changes
@@ -1,3 +1,6 @@
-- dzil fixed build environment from last build, META files were out of date.
-- Switch to dzil

0.30 0.30
-- Make it actually compile and work on OSX -- Make it actually compile and work on OSX
-- Make constants problems show up at compile time -- Make constants problems show up at compile time
Expand Down
23 changes: 0 additions & 23 deletions MANIFEST

This file was deleted.

3 changes: 3 additions & 0 deletions MANIFEST.SKIP
@@ -0,0 +1,3 @@
inc/PAMMakeMaker.pm
MANIFEST.SKIP
dist.ini
5 changes: 0 additions & 5 deletions README

This file was deleted.

23 changes: 23 additions & 0 deletions dist.ini
@@ -0,0 +1,23 @@
name = PAM
version = 0.30
author = Jonathan Steinert <hachi@cpan.org>
license = Perl_5
copyright_holder = Jonathan Steinert

[@Filter]
-bundle = @Classic
-remove = MakeMaker

[=inc::PAMMakeMaker / PAMMakeMaker]

[Prereqs / ConfigureRequires ]
ExtUtils::Depends = 0
XS::Object::Magic = 0

[Prereqs / BuildRequires ]
ExtUtils::Constant = 0
ExtUtils::Embed = 0
XS::Object::Magic = 0

[Prereqs / RuntimeRequires ]
XS::Object::Magic = 0
64 changes: 41 additions & 23 deletions Makefile.PL → inc/PAMMakeMaker.pm
@@ -1,32 +1,48 @@
use inc::Module::Install; package inc::PAMMakeMaker;
use ExtUtils::Depends;


# Define metadata use strict;
name 'PAM'; use warnings;
all_from 'lib/PAM.pm';


requires 'ExtUtils::Constant' => 0; use Moose;
requires 'ExtUtils::Embed' => 0;
requires 'ExtUtils::Depends' => 0;
requires 'XS::Object::Magic' => 0;


my $pkg = ExtUtils::Depends->new('PAM', 'XS::Object::Magic'); extends 'Dist::Zilla::Plugin::MakeMaker::Awesome';


makemaker_args( override _build_WriteMakefile_args => sub { +{
$pkg->get_makefile_vars, %{ super() },
depend => { 'PAM.c' => 'const-xs.inc', '$(OBJECT)' => 'const-c.inc' },
LIBS => [ '-lpam' ], LIBS => [ '-lpam' ],
); clean => { FILES => "perlxsi.c perlxsi.o perl_helper.o perl_helper.so pam_perl.o pam_perl.so const-c.inc const-xs.inc" },
} };


my $pam_lib_dir = "/lib/security/"; override _build_WriteMakefile_dump => sub {
return super() . <<'EOT';
$pam_lib_dir = "/usr/lib/pam" if $^O eq 'darwin'; use ExtUtils::Depends;
my $pkg = ExtUtils::Depends->new('PAM', 'XS::Object::Magic');
preamble(<<"EOT"); %WriteMakefileArgs = ($pkg->get_makefile_vars, %WriteMakefileArgs);
PAM_LIB_DIR = $pam_lib_dir
EOT EOT
};

override _build_MakeFile_PL_template => sub {
my ($self) = @_;
my $template = super();

$template .= <<'TEMPLATE';
package MY;
postamble(<<'EOT'); sub depend {
return <<'EOT';
PAM.c : const-xs.inc
$(OBJECT) : const-c.inc
EOT
}
sub postamble {
my $pam_lib_dir = "/lib/security/";
$pam_lib_dir = "/usr/lib/pam" if $^O eq 'darwin';
return "PAM_LIB_DIR = $pam_lib_dir\n" . <<'EOT'
CCOPTS = $(shell $(PERLRUN) -MExtUtils::Embed -e ccopts) CCOPTS = $(shell $(PERLRUN) -MExtUtils::Embed -e ccopts)
LDOPTS = $(shell $(PERLRUN) -MExtUtils::Embed -e ldopts) LDOPTS = $(shell $(PERLRUN) -MExtUtils::Embed -e ldopts)
Expand Down Expand Up @@ -55,15 +71,17 @@ pam-install: pam_perl.so perl_helper.so
const-xs.inc const-c.inc :: pm_to_blib const-xs.inc const-c.inc :: pm_to_blib
$(PERLRUN) -MExtUtils::Constant=WriteConstants -Mblib -MPAM::Constants \ $(PERLRUN) -MExtUtils::Constant=WriteConstants -Mblib -MPAM::Constants \
-e 'WriteConstants(NAME => "PAM", NAMES => [ map { { name => $$_, macro => 1 } } @PAM::Constants::EXPORT_OK ])' -e 'WriteConstants(NAME => "PAM", NAMES => [ map { { name => $$_, macro => 1 } } @PAM::Constants::EXPORT_OK ])'
all :: pam all :: pam
install :: pam-install install :: pam-install
EOT EOT
}
TEMPLATE


clean_files(qw(perlxsi.c perlxsi.o perl_helper.o perl_helper.so pam_perl.o pam_perl.so const-c.inc const-xs.inc)); return $template;
};


WriteAll; __PACKAGE__->meta->make_immutable;
17 changes: 13 additions & 4 deletions lib/PAM.pm
Expand Up @@ -25,19 +25,28 @@ This Perl and PAM module allow you to invoke a perl interpreter and call package
methods during pam phases. It also includes bindings for most of the pam functions methods during pam phases. It also includes bindings for most of the pam functions
and constants. and constants.
=head1 STATUS
Most of the interface is working at this point. I expect to be compatible at this
point with both Linux PAM and OSX (Darwin) PAM. The major functions in pam_*
should all be working. Some of the pam_{get,set}_item items are not implemented yet.
I wouldn't call this module secure just yet. I will mark version 1.0 when I feel
that is the case.
This all said, the module is safe enough to be used. It should be cleaning up all
memory that it consumes and barring mistakes in the perl code it invokes there
should be no chance of it causing unexpected failures.
=cut =cut


require 5.008001; require 5.008001;
use parent qw(DynaLoader); use parent qw(DynaLoader);


our $VERSION = '0.30';

sub dl_load_flags {0x01} sub dl_load_flags {0x01}


__PACKAGE__->bootstrap($VERSION); __PACKAGE__->bootstrap($VERSION);


$VERSION = eval $VERSION;

1; 1;


=head1 COPYRIGHT =head1 COPYRIGHT
Expand Down
6 changes: 6 additions & 0 deletions lib/PAM/Constants.pm
@@ -1,5 +1,11 @@
package PAM::Constants; package PAM::Constants;


=head1 NAME
PAM::Constants - Module to import constants for use with PAM
=cut

use strict; use strict;
use warnings; use warnings;


Expand Down
6 changes: 6 additions & 0 deletions lib/PAM/Handle.pm
@@ -1,5 +1,11 @@
package PAM::Handle; package PAM::Handle;


=head1 NAME
PAM::Handle - Perl representation of pam_handle_t object
=cut

use PAM; use PAM;


1; 1;

0 comments on commit 5d23a35

Please sign in to comment.