pike.git / src / modules / _Stdio / file.c

version» Context lines:

pike.git/src/modules/_Stdio/file.c:12:   #include "svalue.h"   #include "stralloc.h"   #include "array.h"   #include "mapping.h"   #include "object.h"   #include "pike_macros.h"   #include "backend.h"   #include "fd_control.h"   #include "module_support.h"   #include "operators.h" - #include "pike_security.h" +    #include "bignum.h"   #include "builtin_functions.h"   #include "gc.h"   #include "time_stuff.h"   #include "buffer.h"   #include "file_machine.h"   #include "file.h"   #include "pike_error.h"   #include "signal_handler.h"   #include "pike_types.h"
pike.git/src/modules/_Stdio/file.c:2719:    str=Pike_sp[-args].u.string;       if (string_has_null(str)) {    /* Filenames with NUL are not supported. */    ERRNO = errno = ENOENT;    pop_n_elems(args);    push_int(0);    return;    }    - #ifdef PIKE_SECURITY -  if(!CHECK_SECURITY(SECURITY_BIT_SECURITY)) -  { -  if(!CHECK_SECURITY(SECURITY_BIT_CONDITIONAL_IO)) -  Pike_error("Permission denied.\n"); -  -  if(flags & (FILE_APPEND | FILE_TRUNC | FILE_CREATE | FILE_WRITE)) -  { -  push_text("write"); -  }else{ -  push_text("read"); -  } -  -  ref_push_object(Pike_fp->current_object); -  ref_push_string(str); -  ref_push_string(flag_str); -  push_int(access); -  -  safe_apply(OBJ2CREDS(CURRENT_CREDS)->user,"valid_open",5); -  switch(TYPEOF(Pike_sp[-1])) -  { -  case PIKE_T_INT: -  switch(Pike_sp[-1].u.integer) -  { -  case 0: /* return 0 */ -  ERRNO=errno=EPERM; -  pop_n_elems(args+1); -  push_int(0); -  return; -  -  case 1: /* return 1 */ -  pop_n_elems(args+1); -  push_int(1); -  return; -  -  case 2: /* ok */ -  pop_stack(); -  break; -  -  case 3: /* permission denied */ -  Pike_error("Stdio.file->open: permission denied.\n"); -  -  default: -  Pike_error("Error in user->valid_open, wrong return value.\n"); -  } -  break; -  -  default: -  Pike_error("Error in user->valid_open, wrong return type.\n"); -  -  case PIKE_T_STRING: -  str=Pike_sp[-1].u.string; -  args++; -  } -  } - #endif -  +     if(!( flags & (FILE_READ | FILE_WRITE)))    Pike_error("Must open file for at least one of read and write.\n");       do {    THREADS_ALLOW_UID();    fd=fd_open(str->str,map(flags), access);    err = errno;    THREADS_DISALLOW_UID();    if ((fd < 0) && (err == EINTR))    check_threads_etc();
pike.git/src/modules/_Stdio/file.c:2807:    ERRNO=errno=err;    }    else    {    init_fd(fd, flags | fd_query_properties(fd, FILE_CAPABILITIES), 0);    set_close_on_exec(fd,1);    }    }    else    { - #ifdef PIKE_SECURITY -  if(!CHECK_SECURITY(SECURITY_BIT_SECURITY)) -  { -  if(!CHECK_SECURITY(SECURITY_BIT_CONDITIONAL_IO)) -  Pike_error("Permission denied.\n"); -  Pike_error("Permission denied.\n"); -  /* FIXME!! Insert better security here */ -  } - #endif +     fd=Pike_sp[-args].u.integer;    if (fd<0)    Pike_error("Not a valid FD.\n");       /* FIXME: What are the intended semantics for the flag FILE_NOT_OPENED?    * (grubba 2004-09-01    */    init_fd(fd, flags | low_fd_query_properties(fd), FILE_NOT_OPENED);    }   
pike.git/src/modules/_Stdio/file.c:2867: Inside #if defined(HAVE_OPENAT)
   flags = parse(flag_str->str);       if (string_has_null(str)) {    /* Filenames with NUL are not supported. */    ERRNO = errno = ENOENT;    pop_n_elems(args);    push_int(0);    return;    }    - #ifdef PIKE_SECURITY -  if(!CHECK_SECURITY(SECURITY_BIT_SECURITY)) -  { -  if(!CHECK_SECURITY(SECURITY_BIT_CONDITIONAL_IO)) -  Pike_error("Permission denied.\n"); -  -  if(flags & (FILE_APPEND | FILE_TRUNC | FILE_CREATE | FILE_WRITE)) -  { -  push_text("write"); -  }else{ -  push_text("read"); -  } -  -  ref_push_object(Pike_fp->current_object); -  ref_push_string(str); -  ref_push_string(flag_str); -  push_int(access); -  -  safe_apply(OBJ2CREDS(CURRENT_CREDS)->user,"valid_openat",5); -  switch(TYPEOF(Pike_sp[-1])) -  { -  case PIKE_T_INT: -  switch(Pike_sp[-1].u.integer) -  { -  case 0: /* return 0 */ -  ERRNO=errno=EPERM; -  pop_n_elems(args+1); -  push_int(0); -  return; -  - #if 0 -  case 1: /* return 1 */ -  pop_n_elems(args+1); -  push_int(1); -  return; - #endif -  -  case 2: /* ok */ -  pop_stack(); -  break; -  -  case 3: /* permission denied */ -  Pike_error("Stdio.file->openat: permission denied.\n"); -  -  default: -  Pike_error("Error in user->valid_openat, wrong return value.\n"); -  } -  break; -  -  default: -  Pike_error("Error in user->valid_openat, wrong return type.\n"); -  -  case PIKE_T_STRING: -  /* Alternate path. */ -  str=Pike_sp[-1].u.string; -  args++; -  } -  } - #endif -  +     if(!(flags & (FILE_READ | FILE_WRITE)))    Pike_error("Must open file for at least one of read and write.\n");       do {    THREADS_ALLOW_UID();    fd = openat(dir_fd, str->str, map(flags), access);    err = errno;    THREADS_DISALLOW_UID();    if ((fd < 0) && (err == EINTR))    check_threads_etc();
pike.git/src/modules/_Stdio/file.c:3448: Inside #if defined(HAVE_FSTATAT) and #if defined(HAVE_UNLINKAT)
   */   static void file_unlinkat(INT32 args)   {    int dir_fd;    PIKE_STAT_T st;    struct pike_string *str;    INT32 i;       destruct_objects_to_destruct();    -  VALID_FILE_IO("rm","write"); -  +     if((dir_fd = FD) < 0)    Pike_error("File not open.\n");       get_all_args("unlinkat", args, "%S", &str);       if (string_has_null(str)) {    /* Filenames with NUL are not supported. */    ERRNO = ENOENT;    pop_n_elems(args);    push_int(0);