summaryrefslogtreecommitdiff
path: root/security/ruby-shadow
diff options
context:
space:
mode:
authortonnerre <tonnerre@pkgsrc.org>2013-04-10 09:25:21 +0000
committertonnerre <tonnerre@pkgsrc.org>2013-04-10 09:25:21 +0000
commit543b0b329f9f8492c5a4608497e73be2a0d5b7b1 (patch)
tree627fea5bdc56e9ead62d9e8c49d33345a8d1d9bb /security/ruby-shadow
parent2fad82c3fcfe71df18f9006144e34e54c758ba12 (diff)
downloadpkgsrc-543b0b329f9f8492c5a4608497e73be2a0d5b7b1.tar.gz
Import the ruby-shadow Ruby gem, version 2.2.0, into pkgsrc.
This module provides access to shadow passwords on Linux, Solaris and BSD like systems (falsely called OSX).
Diffstat (limited to 'security/ruby-shadow')
-rw-r--r--security/ruby-shadow/DESCR1
-rw-r--r--security/ruby-shadow/Makefile21
-rw-r--r--security/ruby-shadow/PLIST16
-rw-r--r--security/ruby-shadow/distinfo7
-rw-r--r--security/ruby-shadow/patches/patch-aa33
-rw-r--r--security/ruby-shadow/patches/patch-ab309
6 files changed, 387 insertions, 0 deletions
diff --git a/security/ruby-shadow/DESCR b/security/ruby-shadow/DESCR
new file mode 100644
index 00000000000..418ecb472ff
--- /dev/null
+++ b/security/ruby-shadow/DESCR
@@ -0,0 +1 @@
+This module provides access to shadow passwords on Linux and Solaris.
diff --git a/security/ruby-shadow/Makefile b/security/ruby-shadow/Makefile
new file mode 100644
index 00000000000..8b7df87602a
--- /dev/null
+++ b/security/ruby-shadow/Makefile
@@ -0,0 +1,21 @@
+# $NetBSD: Makefile,v 1.1.1.1 2013/04/10 09:25:21 tonnerre Exp $
+
+SHADOW_VER= 2.2.0
+DISTNAME= ruby-shadow-${SHADOW_VER}
+PKGNAME= ${RUBY_PKGPREFIX}-shadow-${SHADOW_VER}
+CATEGORIES= database
+
+MAINTAINER= pkgsrc-users@NetBSD.org
+HOMEPAGE= https://github.com/apalmblad/ruby-shadow
+COMMENT= Access to shadow passwords on Linux and Solaris
+
+USE_RUBY_EXTCONF= yes
+USE_TOOLS+= gmake
+
+CONFLICTS+= ruby[1-9][0-9][0-9]-shadow-[0-9]*
+
+.include "../../lang/ruby/gem.mk"
+
+.include "../../devel/libuuid/buildlink3.mk"
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/security/ruby-shadow/PLIST b/security/ruby-shadow/PLIST
new file mode 100644
index 00000000000..3ec14696c6a
--- /dev/null
+++ b/security/ruby-shadow/PLIST
@@ -0,0 +1,16 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2013/04/10 09:25:21 tonnerre Exp $
+${GEM_HOME}/cache/${GEM_NAME}.gem
+${GEM_LIBDIR}/HISTORY
+${GEM_LIBDIR}/MANIFEST
+${GEM_LIBDIR}/Makefile
+${GEM_LIBDIR}/README
+${GEM_LIBDIR}/README.euc
+${GEM_LIBDIR}/depend
+${GEM_LIBDIR}/extconf.rb
+${GEM_LIBDIR}/lib/shadow.so
+${GEM_LIBDIR}/mkmf.log
+${GEM_LIBDIR}/ruby-shadow.gemspec
+${GEM_LIBDIR}/shadow.c
+${GEM_LIBDIR}/shadow.o
+${GEM_LIBDIR}/shadow.so
+${GEM_HOME}/specifications/${GEM_NAME}.gemspec
diff --git a/security/ruby-shadow/distinfo b/security/ruby-shadow/distinfo
new file mode 100644
index 00000000000..c841d2f578a
--- /dev/null
+++ b/security/ruby-shadow/distinfo
@@ -0,0 +1,7 @@
+$NetBSD: distinfo,v 1.1.1.1 2013/04/10 09:25:21 tonnerre Exp $
+
+SHA1 (ruby-shadow-2.2.0.gem) = e9b2ee34c2b0b98552e3a6a939cc2dc09cc1a99f
+RMD160 (ruby-shadow-2.2.0.gem) = 03dcc27c75ac76cbb10efc07db9704c89fdc5484
+Size (ruby-shadow-2.2.0.gem) = 9216 bytes
+SHA1 (patch-aa) = 7500e90948f7aada86b45b152bcc346f0ddb04ba
+SHA1 (patch-ab) = 761f40443f1fec78a9023ff4600254ad4205d19e
diff --git a/security/ruby-shadow/patches/patch-aa b/security/ruby-shadow/patches/patch-aa
new file mode 100644
index 00000000000..308acfcabc4
--- /dev/null
+++ b/security/ruby-shadow/patches/patch-aa
@@ -0,0 +1,33 @@
+$NetBSD: patch-aa,v 1.1.1.1 2013/04/10 09:25:21 tonnerre Exp $
+
+Do something more sensible if we detect an OSX-like system.
+
+--- extconf.rb
++++ extconf.rb
+@@ -11,10 +11,11 @@ $CFLAGS = case RUBY_VERSION
+ when /^2\./; '-DRUBY19'
+ else; ''
+ end
++$CFLAGS += " -Wall -pedantic"
+
+ #$LDFLAGS = "-lshadow"
+
+-if( ! (ok = have_library("shadow","getspent")) )
++if !(ok = have_library("shadow","getspent"))
+ $LDFLAGS = ""
+ ok = have_func("getspent")
+ end
+@@ -36,9 +37,10 @@ else
+ osx_ok &= have_func( "getpwnam" )
+ osx_ok &= have_func( "getpwnam_r" )
+ osx_ok &= have_func( "getpwuid" )
++ #osx_ok &= have_func( "getuid_r" )
+ osx_ok &= have_func( "setpassent" )
+ osx_ok &= have_func( "setpwent" )
+- if osx_ok
+- raise "It looks like you're on OSX. There is a branch that might help here: https://github.com/apalmblad/ruby-shadow/tree/osx"
+- end
++ $CFLAGS += ' -DOSX'
++ create_makefile("shadow") if osx_ok
+ end
++
diff --git a/security/ruby-shadow/patches/patch-ab b/security/ruby-shadow/patches/patch-ab
new file mode 100644
index 00000000000..2f85b81589a
--- /dev/null
+++ b/security/ruby-shadow/patches/patch-ab
@@ -0,0 +1,309 @@
+$NetBSD: patch-ab,v 1.1.1.1 2013/04/10 09:25:22 tonnerre Exp $
+
+Handle OSX-like password APIs.
+
+--- shadow.c
++++ shadow.c
+@@ -7,8 +7,16 @@
+ * License: Free for any use with your own risk!
+ * Modified at: <1999/8/19 06:48:18 by ttate>
+ */
+-
++#ifndef OSX
+ #include <shadow.h>
++#define PWTYPE struct spwd
++#else
++#include <sys/types.h>
++#include <pwd.h>
++#include <time.h>
++#include <uuid/uuid.h>
++#define PWTYPE struct passwd
++#endif
+ #include "ruby.h"
+ #ifdef RUBY19
+ #include <ruby/io.h>
+@@ -33,54 +41,84 @@ static VALUE rb_eFileLock;
+ static VALUE
+ rb_shadow_setspent(VALUE self)
+ {
++ #ifdef OSX
++ setpassent(1);
++ #else
+ setspent();
++ #endif
+ return Qnil;
+-};
++}
+
+
+ static VALUE
+ rb_shadow_endspent(VALUE self)
+ {
++ #ifdef OSX
++ endpwent();
++ #else
+ endspent();
++ #endif
+ return Qnil;
+-};
+-
+-
++}
++#ifdef OSX
++static VALUE convert_pw_struct( struct passwd *entry )
++{
++ return rb_struct_new(rb_sPasswdEntry,
++ rb_tainted_str_new2(entry->pw_name),
++ rb_tainted_str_new2(entry->pw_passwd ),
++ difftime( entry->pw_change, 0 ) / 24*60*60,
++ Qnil, /* days that password must stay same */
++ Qnil, /* days until passwor changes. */
++ Qnil, /* days before expiration where user is warned */
++ Qnil, /* days after password expiration that account becomes inactive */
++ difftime( entry->pw_expire, 0 ) / 24*60*60,
++ Qnil,
++ NULL);
++}
++#else
++static VALUE convert_pw_struct( spwd *entry )
++{
++ result = rb_struct_new(rb_sPasswdEntry,
++ rb_tainted_str_new2(entry->sp_namp),
++ rb_tainted_str_new2(entry->sp_pwdp),
++ INT2FIX(entry->sp_lstchg),
++ INT2FIX(entry->sp_min),
++ INT2FIX(entry->sp_max),
++ INT2FIX(entry->sp_warn),
++ INT2FIX(entry->sp_inact),
++ INT2FIX(entry->sp_expire),
++ INT2FIX(entry->sp_flag),
++ NULL);
++}
++#endif
+ #ifndef SOLARIS
+ static VALUE
+ rb_shadow_sgetspent(VALUE self, VALUE str)
+ {
+- struct spwd *entry;
++ PWTYPE *entry;
+ VALUE result;
+
+ if( TYPE(str) != T_STRING )
+ rb_raise(rb_eException,"argument must be a string.");
+
++ #ifdef OSX
++ entry = getpwnam( StringValuePtr(str) );
++ #else
+ entry = sgetspent(StringValuePtr(str));
+-
++ #endif
+ if( entry == NULL )
+ return Qnil;
++ result = convert_pw_struct( entry );
+
+- result = rb_struct_new(rb_sPasswdEntry,
+- rb_tainted_str_new2(entry->sp_namp),
+- rb_tainted_str_new2(entry->sp_pwdp),
+- INT2FIX(entry->sp_lstchg),
+- INT2FIX(entry->sp_min),
+- INT2FIX(entry->sp_max),
+- INT2FIX(entry->sp_warn),
+- INT2FIX(entry->sp_inact),
+- INT2FIX(entry->sp_expire),
+- INT2FIX(entry->sp_flag),
+- NULL);
+ free(entry);
+ return result;
+-};
++}
+ #endif
+-
++#ifndef OSX
+ static VALUE
+ rb_shadow_fgetspent(VALUE self, VALUE file)
+ {
+- struct spwd *entry;
++ PWTYPE *entry;
+ VALUE result;
+
+ if( TYPE(file) != T_FILE )
+@@ -91,85 +129,62 @@ rb_shadow_fgetspent(VALUE self, VALUE file)
+ if( entry == NULL )
+ return Qnil;
+
+- result = rb_struct_new(rb_sPasswdEntry,
+- rb_tainted_str_new2(entry->sp_namp),
+- rb_tainted_str_new2(entry->sp_pwdp),
+- INT2FIX(entry->sp_lstchg),
+- INT2FIX(entry->sp_min),
+- INT2FIX(entry->sp_max),
+- INT2FIX(entry->sp_warn),
+- INT2FIX(entry->sp_inact),
+- INT2FIX(entry->sp_expire),
+- INT2FIX(entry->sp_flag),
+- NULL);
++ result = convert_pw_struct( entry );
+ return result;
+-};
++}
++#endif
+
+ static VALUE
+ rb_shadow_getspent(VALUE self)
+ {
+- struct spwd *entry;
++ PWTYPE *entry;
+ VALUE result;
+-
++ #ifdef OSX
++ entry = getpwent();
++ #else
+ entry = getspent();
++ #endif
+
+ if( entry == NULL )
+ return Qnil;
+
+- result = rb_struct_new(rb_sPasswdEntry,
+- rb_tainted_str_new2(entry->sp_namp),
+- rb_tainted_str_new2(entry->sp_pwdp),
+- INT2FIX(entry->sp_lstchg),
+- INT2FIX(entry->sp_min),
+- INT2FIX(entry->sp_max),
+- INT2FIX(entry->sp_warn),
+- INT2FIX(entry->sp_inact),
+- INT2FIX(entry->sp_expire),
+- INT2FIX(entry->sp_flag),
+- NULL);
++ result = convert_pw_struct( entry );
+ return result;
+-};
++}
+
+ static VALUE
+ rb_shadow_getspnam(VALUE self, VALUE name)
+ {
+- struct spwd *entry;
++ PWTYPE *entry;
+ VALUE result;
+
+ if( TYPE(name) != T_STRING )
+ rb_raise(rb_eException,"argument must be a string.");
+-
++ #ifdef OSX
++ entry = getpwnam(StringValuePtr(name));
++ #else
+ entry = getspnam(StringValuePtr(name));
++ #endif
+
+ if( entry == NULL )
+ return Qnil;
+
+- result = rb_struct_new(rb_sPasswdEntry,
+- rb_tainted_str_new2(entry->sp_namp),
+- rb_tainted_str_new2(entry->sp_pwdp),
+- INT2FIX(entry->sp_lstchg),
+- INT2FIX(entry->sp_min),
+- INT2FIX(entry->sp_max),
+- INT2FIX(entry->sp_warn),
+- INT2FIX(entry->sp_inact),
+- INT2FIX(entry->sp_expire),
+- INT2FIX(entry->sp_flag),
+- NULL);
++ result = convert_pw_struct( entry );
+ return result;
+-};
+-
++}
+
++#ifndef OSX
+ static VALUE
+ rb_shadow_putspent(VALUE self, VALUE entry, VALUE file)
+ {
+- struct spwd centry;
++ PWTYPE centry;
+ FILE* cfile;
+ VALUE val[9];
+ int i;
+ int result;
+
+ for(i=0; i<=8; i++)
+- val[i] = RSTRUCT_PTR( entry )[i]; //val[i] = RSTRUCT(entry)->ptr[i];
++ val[i] = RSTRUCT_PTR( entry )[i]; /* val[i] = RSTRUCT(entry)->ptr[i]; */
+ cfile = file_ptr( RFILE(file)->fptr );
+
+ centry.sp_namp = StringValuePtr(val[0]);
+@@ -188,7 +203,7 @@ rb_shadow_putspent(VALUE self, VALUE entry, VALUE file)
+ rb_raise(rb_eStandardError,"can't change password");
+
+ return Qtrue;
+-};
++}
+
+
+ static VALUE
+@@ -200,7 +215,7 @@ rb_shadow_lckpwdf(VALUE self)
+ rb_raise(rb_eFileLock,"password file was locked");
+ else
+ return Qtrue;
+-};
++}
+
+ static int in_lock;
+
+@@ -225,7 +240,7 @@ rb_shadow_lock(VALUE self)
+ else{
+ return rb_shadow_lckpwdf(self);
+ };
+-};
++}
+
+
+ static VALUE
+@@ -236,13 +251,13 @@ rb_shadow_ulckpwdf(VALUE self)
+ };
+ ulckpwdf();
+ return Qtrue;
+-};
++}
+
+ static VALUE
+ rb_shadow_unlock(VALUE self)
+ {
+ return rb_shadow_ulckpwdf(self);
+-};
++}
+
+ static VALUE
+ rb_shadow_lock_p(VALUE self)
+@@ -256,8 +271,9 @@ rb_shadow_lock_p(VALUE self)
+ else{
+ ulckpwdf();
+ return Qfalse;
+- };
+-};
++ }
++}
++#endif
+
+
+ void
+@@ -283,13 +299,17 @@ Init_shadow()
+ #ifndef SOLARIS
+ rb_define_module_function(rb_mPasswd,"sgetspent",rb_shadow_sgetspent,1);
+ #endif
++ #ifndef OSX
+ rb_define_module_function(rb_mPasswd,"fgetspent",rb_shadow_fgetspent,1);
++ #endif
+ rb_define_module_function(rb_mPasswd,"getspent",rb_shadow_getspent,0);
+ rb_define_module_function(rb_mPasswd,"getspnam",rb_shadow_getspnam,1);
++ #ifndef OSX
+ rb_define_module_function(rb_mPasswd,"putspent",rb_shadow_putspent,2);
+ rb_define_module_function(rb_mPasswd,"lckpwdf",rb_shadow_lckpwdf,0);
+ rb_define_module_function(rb_mPasswd,"lock",rb_shadow_lock,0);
+ rb_define_module_function(rb_mPasswd,"ulckpwdf",rb_shadow_ulckpwdf,0);
+ rb_define_module_function(rb_mPasswd,"unlock",rb_shadow_unlock,0);
+ rb_define_module_function(rb_mPasswd,"lock?",rb_shadow_lock_p,0);
+-};
++ #endif
++}