xref: /third_party/node/deps/npm/node_modules/tar/lib/mode-fix.js
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/node/deps/npm/node_modules/tar/lib/
11cb0ef41Sopenharmony_ci'use strict'
21cb0ef41Sopenharmony_cimodule.exports = (mode, isDir, portable) => {
31cb0ef41Sopenharmony_ci  mode &= 0o7777
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci  // in portable mode, use the minimum reasonable umask
61cb0ef41Sopenharmony_ci  // if this system creates files with 0o664 by default
71cb0ef41Sopenharmony_ci  // (as some linux distros do), then we'll write the
81cb0ef41Sopenharmony_ci  // archive with 0o644 instead.  Also, don't ever create
91cb0ef41Sopenharmony_ci  // a file that is not readable/writable by the owner.
101cb0ef41Sopenharmony_ci  if (portable) {
111cb0ef41Sopenharmony_ci    mode = (mode | 0o600) & ~0o22
121cb0ef41Sopenharmony_ci  }
131cb0ef41Sopenharmony_ci
141cb0ef41Sopenharmony_ci  // if dirs are readable, then they should be listable
151cb0ef41Sopenharmony_ci  if (isDir) {
161cb0ef41Sopenharmony_ci    if (mode & 0o400) {
171cb0ef41Sopenharmony_ci      mode |= 0o100
181cb0ef41Sopenharmony_ci    }
191cb0ef41Sopenharmony_ci    if (mode & 0o40) {
201cb0ef41Sopenharmony_ci      mode |= 0o10
211cb0ef41Sopenharmony_ci    }
221cb0ef41Sopenharmony_ci    if (mode & 0o4) {
231cb0ef41Sopenharmony_ci      mode |= 0o1
241cb0ef41Sopenharmony_ci    }
251cb0ef41Sopenharmony_ci  }
261cb0ef41Sopenharmony_ci  return mode
271cb0ef41Sopenharmony_ci}
28

Indexes created Thu Nov 07 10:32:03 CST 2024