| 1 | package Linux::Setns; | ||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||
| 7 | 1 | require Exporter; | |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||
| 9 | 1 | our @ISA = qw(Exporter); | |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||
| 11 | # Items to export into callers namespace by default. Note: do not export | ||||||||||||||||||||||||||||||
| 12 | # names by default without a very good reason. Use EXPORT_OK instead. | ||||||||||||||||||||||||||||||
| 13 | # Do not simply export all your public functions/methods/constants. | ||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||
| 15 | # This allows declaration use Linux::Setns ':all'; | ||||||||||||||||||||||||||||||
| 16 | # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK | ||||||||||||||||||||||||||||||
| 17 | # will save memory. | ||||||||||||||||||||||||||||||
| 18 | 1 | our %EXPORT_TAGS = ( 'all' => [ qw( | |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||
| 20 | ) ] ); | ||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||
| 22 | 1 | our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); | |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||
| 24 | 1 | our @EXPORT = qw( | |||||||||||||||||||||||||||||
| 25 | setns CLONE_ALL CLONE_NEWNS CLONE_NEWIPC CLONE_NEWNET CLONE_NEWUTS CLONE_NEWPID CLONE_NEWUSER | ||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||
| 28 | 1 | our $VERSION = '1.05'; | |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||
| 30 | use constant { | ||||||||||||||||||||||||||||||
| 31 | 1 | CLONE_ALL => 0, | |||||||||||||||||||||||||||||
| 32 | CLONE_NEWNS => 0x00020000, | ||||||||||||||||||||||||||||||
| 33 | CLONE_NEWIPC => 0x08000000, | ||||||||||||||||||||||||||||||
| 34 | CLONE_NEWNET => 0x40000000, | ||||||||||||||||||||||||||||||
| 35 | CLONE_NEWUTS => 0x04000000, | ||||||||||||||||||||||||||||||
| 36 | CLONE_NEWPID => 0x20000000, | ||||||||||||||||||||||||||||||
| 37 | CLONE_NEWUSER => 0x10000000 | ||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | }; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||
| 40 | 1 | require XSLoader; | |||||||||||||||||||||||||||||
| 41 | 1 | XSLoader::load('Linux::Setns', $VERSION); | |||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||
| 43 | # Preloaded methods go here. | ||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||
| 45 | sub setns { | ||||||||||||||||||||||||||||||
| 46 | 2 | ▶ | my $ret = setns_wrapper($_[0], $_[1]); | ||||||||||||||||||||||||||||
|
Subroutine
setns: called CC=7 SCAR=25.1
Pod
undocumented
| |||||||||||||||||||||||||||||||
| 47 | 2 | ▶ | if ($ret == 0) { | ||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||
| 48 | 0 | return 1; | |||||||||||||||||||||||||||||
| 49 | } elsif ($ret == 1) { | ||||||||||||||||||||||||||||||
| 50 | 0 | print STDERR "Error: setns() The calling thread did not have the required privilege (CAP_SYS_ADMIN) for this operation\n"; | |||||||||||||||||||||||||||||
| 51 | } elsif ($ret == 2) { | ||||||||||||||||||||||||||||||
| 52 | 1 | print STDERR "Error: setns() Unable to open file $_[0]\n"; | |||||||||||||||||||||||||||||
| 53 | } elsif ($ret == 9) { | ||||||||||||||||||||||||||||||
| 54 | 0 | print STDERR "Error: setns() FD is not a valid file descriptor\n"; | |||||||||||||||||||||||||||||
| 55 | } elsif ($ret == 12) { | ||||||||||||||||||||||||||||||
| 56 | 0 | print STDERR "Error: setns() Cannot allocate sufficient memory to change the specified namespace\n"; | |||||||||||||||||||||||||||||
| 57 | } elsif ($ret == 22) { | ||||||||||||||||||||||||||||||
| 58 | 0 | print STDERR "Error: setns() FD refers to a namespace whose type does not match that specified in nstype, or there is problem with reassociating the the thread with the specified namespace\n"; | |||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||
| 60 | 2 | return 0; | |||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||
| 63 | 1 | 1; | |||||||||||||||||||||||||||||
| 64 | __END__ | ||||||||||||||||||||||||||||||