Crypt-Sodium-XS

 view release on metacpan or  search on metacpan

inc/memvault.xs  view on Meta::CPAN


  CODE:
  switch (ix) {
    case 1:
      path_buf = SvPVbyte_nolen(file);
      /* really need to be checking path_buf for nul termination, etc */

      fd = open(path_buf, O_WRONLY|O_CLOEXEC|O_NOCTTY|O_CREAT|O_TRUNC, mode);
      if (fd < 0)
        croak("to_fd: %s: open failed", path_buf);
      if (fstat(fd, &stat_buf) < 0) {
        close(fd);
        croak("to_fd: %s: fstat failed", path_buf);
      }
      if (((stat_buf.st_mode & ~S_IFMT) | mode) ^ mode) {
        /* only caring if file has extra (most likely less-restrictive) modes.
         * it would be invalid to assume that it's safe to fchmod here, as anything
         * else could already have gotten a handle opened. */
        croak("to_fd: %s: invalid modes on already-existing file", path_buf);
      }
      break;



( run in 0.530 second using v1.01-cache-2.11-cpan-beeb90c9504 )