Ticket #2032: 0001-Added-Parrot_get_effective_user_id.patch

File 0001-Added-Parrot_get_effective_user_id.patch, 3.3 KB (added by worr, 11 years ago)
  • include/parrot/platform_interface.h

    From 6bb6f5b85f7b8a43696e8d8e2f9ee75d6e285995 Mon Sep 17 00:00:00 2001
    From: William Orr <will@worrbase.com>
    Date: Sun, 27 Feb 2011 22:58:12 -0500
    Subject: [PATCH] Added Parrot_get_effective_user_id()
    
    Wrote test for get_effective_user_id
    
    Made test for get_effective_uid *nix only
    ---
     include/parrot/platform_interface.h |    3 +++
     src/dynpmc/os.pmc                   |   15 +++++++++++++++
     src/platform/generic/uid.c          |   16 ++++++++++++++++
     src/platform/win32/uid.c            |   17 +++++++++++++++++
     t/dynpmc/os.t                       |   18 +++++++++++++++++-
     5 files changed, 68 insertions(+), 1 deletions(-)
    
    diff --git a/include/parrot/platform_interface.h b/include/parrot/platform_interface.h
    index 1db1c2a..f0ca061 100644
    a b  
    392392PARROT_EXPORT 
    393393UINTVAL Parrot_get_user_id(void); 
    394394 
     395PARROT_EXPORT 
     396UINTVAL Parrot_get_effective_user_id(void); 
     397 
    395398/* 
    396399 * system memory 
    397400 */ 
  • src/dynpmc/os.pmc

    diff --git a/src/dynpmc/os.pmc b/src/dynpmc/os.pmc
    index 9dfa78b..f9c627c 100644
    a b  
    343343 
    344344/* 
    345345 
     346=item C<get_effective_user_id()> 
     347 
     348Returns the ID numver of the effective user. This is also platform dependent. 
     349 
     350=cut 
     351 
     352*/ 
     353 
     354    METHOD get_effective_user_id() { 
     355        const UINTVAL euid = Parrot_get_effective_user_id(); 
     356        RETURN(INTVAL euid); 
     357    } 
     358 
     359/* 
     360 
    346361=item C<can_execute(STRING *filename)> 
    347362 
    348363=item C<can_read(STRING *filename)> 
  • src/platform/generic/uid.c

    diff --git a/src/platform/generic/uid.c b/src/platform/generic/uid.c
    index a8c11c0..1a471b2 100644
    a b  
    4444 
    4545/* 
    4646 
     47=item C<UINTVAK Parrot_get_effective_user_id(void)> 
     48 
     49Get effective user id 
     50 
     51=cut 
     52 
     53*/ 
     54 
     55UINTVAL 
     56Parrot_get_effective_user_id(void)  
     57{ 
     58    return (UINTVAL)geteuid(); 
     59} 
     60 
     61/* 
     62 
    4763=back 
    4864 
    4965=cut 
  • src/platform/win32/uid.c

    diff --git a/src/platform/win32/uid.c b/src/platform/win32/uid.c
    index 52734b0..469ee45 100644
    a b  
    4545 
    4646/* 
    4747 
     48=item C<UINTVAK Parrot_get_effective_user_id(void)> 
     49 
     50Get effective user id 
     51 
     52=cut 
     53 
     54*/ 
     55 
     56UINTVAL 
     57Parrot_get_effective_user_id(void)  
     58{ 
     59    /* TODO */ 
     60    return (UINTVAL)0; 
     61} 
     62 
     63/* 
     64 
    4865=back 
    4966 
    5067=cut 
  • t/dynpmc/os.t

    diff --git a/t/dynpmc/os.t b/t/dynpmc/os.t
    index ec70e6c..8582185 100644
    a b  
    55use warnings; 
    66use lib qw( . lib ../lib ../../lib ); 
    77use Test::More; 
    8 use Parrot::Test tests => 34; 
     8use Parrot::Test tests => 35; 
    99use Parrot::Config; 
    1010use Cwd; 
    1111use File::Spec; 
     
    643643} 
    644644 
    645645use English '$UID'; 
     646use English '$EUID'; 
    646647 
    647648# Test chroot 
    648649SKIP: { 
     
    688689CODE 
    689690 
    690691SKIP: { 
     692    skip 'no effective user ids on Win32', 1 if ($MSWin32 || $cygwin); 
     693    pir_output_is( <<'CODE', $EUID, 'Test get_effective_user_id' ); 
     694    .sub main :main 
     695        $P0 = loadlib 'os' 
     696        $P1 = new ['OS'] 
     697 
     698        $I0 = $P1."get_effective_user_id"() 
     699        print $I0 
     700 
     701        end 
     702    .end 
     703CODE 
     704} 
     705 
     706SKIP: { 
    691707    skip 'no file modes on Win32', 3 if ($MSWin32 || $cygwin); 
    692708 
    693709    open my $fa, ">", "test_f_a";