Skip to content

Commit 68f1855

Browse files
committed
Initial release
1 parent 264fb20 commit 68f1855

14 files changed

+1171
-0
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Perl
2+
13
/blib/
24
/.build/
35
_build/
@@ -18,3 +20,13 @@ nytprof.out
1820
*.o
1921
*.bs
2022
/_eumm/
23+
*.tar
24+
*.tar.gz
25+
*.tar.bz2
26+
.Inline/
27+
_Inline/
28+
*.c
29+
30+
# vim
31+
*.sw[o-z]
32+

.travis.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
language: 'perl'
2+
perl:
3+
- '5.22'
4+
- '5.18'
5+
- '5.14'
6+
- '5.12'
7+
- '5.10'
8+
before_install:
9+
- 'sudo apt-get update -qq'
10+
- 'sudo apt-get install -qq libkeyutils-dev libkeyutils1'
11+
sudo: 'required'
12+
dist: 'trusty'

INLINE.h

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#define Inline_Stack_Vars dXSARGS
2+
#define Inline_Stack_Items items
3+
#define Inline_Stack_Item(x) ST(x)
4+
#define Inline_Stack_Reset sp = mark
5+
#define Inline_Stack_Push(x) XPUSHs(x)
6+
#define Inline_Stack_Done PUTBACK
7+
#define Inline_Stack_Return(x) XSRETURN(x)
8+
#define Inline_Stack_Void XSRETURN(0)
9+
10+
#define INLINE_STACK_VARS Inline_Stack_Vars
11+
#define INLINE_STACK_ITEMS Inline_Stack_Items
12+
#define INLINE_STACK_ITEM(x) Inline_Stack_Item(x)
13+
#define INLINE_STACK_RESET Inline_Stack_Reset
14+
#define INLINE_STACK_PUSH(x) Inline_Stack_Push(x)
15+
#define INLINE_STACK_DONE Inline_Stack_Done
16+
#define INLINE_STACK_RETURN(x) Inline_Stack_Return(x)
17+
#define INLINE_STACK_VOID Inline_Stack_Void
18+
19+
#define inline_stack_vars Inline_Stack_Vars
20+
#define inline_stack_items Inline_Stack_Items
21+
#define inline_stack_item(x) Inline_Stack_Item(x)
22+
#define inline_stack_reset Inline_Stack_Reset
23+
#define inline_stack_push(x) Inline_Stack_Push(x)
24+
#define inline_stack_done Inline_Stack_Done
25+
#define inline_stack_return(x) Inline_Stack_Return(x)
26+
#define inline_stack_void Inline_Stack_Void

INSTALL

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Installation with cpanm
2+
3+
> cpanm Kernel::Keyring
4+
5+
If there's no permission to install modules to the system dirs, cpanm
6+
will automatically set up and install to a local::lib in the home directory.
7+
See the local::lib documentation (https://metacpan.org/pod/local::lib).
8+
9+
## Installing with the CPAN shell
10+
11+
> cpan Kernel::Keyring
12+
13+
## Manual installation
14+
15+
> perl Makefile.PL
16+
> make
17+
> make test
18+
19+
> make install
20+
21+
## Documentation
22+
23+
The documentation is available as pod.
24+
Run perldoc from a shell to read it.
25+
26+
> perldoc Kernel::Keyring
27+

Keyring.xs

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#include "EXTERN.h"
2+
#include "perl.h"
3+
#include "XSUB.h"
4+
#include "INLINE.h"
5+
6+
#include <keyutils.h>
7+
8+
int _key_add(char* type, char* desc, char* data, int datalen, int keyring) {
9+
return add_key(type, desc, data, datalen, keyring);
10+
}
11+
12+
void _key_read(key_serial_t key_id) {
13+
Inline_Stack_Vars;
14+
void* key = NULL;
15+
int ret = keyctl_read_alloc(key_id, &key);
16+
17+
Inline_Stack_Reset;
18+
Inline_Stack_Push(sv_2mortal(newSViv(ret)));
19+
if (key != NULL)
20+
Inline_Stack_Push(sv_2mortal(newSVpv(key, ret)));
21+
Inline_Stack_Done;
22+
}
23+
24+
long _key_timeout(key_serial_t key_id, unsigned int timeout) {
25+
return keyctl_set_timeout(key_id, timeout);
26+
}
27+
28+
long _key_unlink(key_serial_t key_id, key_serial_t keyring) {
29+
return keyctl_unlink(key_id, keyring);
30+
}
31+
32+
int _key_session(char* desc) {
33+
return keyctl_join_session_keyring(desc);
34+
}
35+
36+
long _key_perm(key_serial_t key_id, key_perm_t perm) {
37+
return keyctl_setperm(key_id, perm);
38+
}
39+
40+
long _key_revoke(key_serial_t key_id) {
41+
return keyctl_revoke(key_id);
42+
}
43+
44+
MODULE = Kernel::Keyring PACKAGE = Kernel::Keyring
45+
46+
PROTOTYPES: DISABLE
47+
48+
49+
int
50+
_key_add (type, desc, data, datalen, keyring)
51+
char * type
52+
char * desc
53+
char * data
54+
int datalen
55+
int keyring
56+
57+
void
58+
_key_read (key_id)
59+
int key_id
60+
PREINIT:
61+
I32* temp;
62+
PPCODE:
63+
temp = PL_markstack_ptr++;
64+
_key_read(key_id);
65+
if (PL_markstack_ptr != temp) {
66+
/* truly void, because dXSARGS not invoked */
67+
PL_markstack_ptr = temp;
68+
XSRETURN_EMPTY; /* return empty stack */
69+
}
70+
/* must have used dXSARGS; list context implied */
71+
return; /* assume stack size is correct */
72+
73+
long
74+
_key_timeout (key_id, timeout)
75+
int key_id
76+
unsigned int timeout
77+
78+
long
79+
_key_unlink (key_id, keyring)
80+
int key_id
81+
int keyring
82+
83+
int
84+
_key_session (desc)
85+
char * desc
86+
87+
long
88+
_key_perm (key_id, perm)
89+
int key_id
90+
unsigned int perm
91+
92+
long
93+
_key_revoke (key_id)
94+
int key_id
95+

0 commit comments

Comments
 (0)