@stdlib/process-umask

Get/set the process mask.

https://github.com/stdlib-js/process-umask

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.4%) to scientific vocabulary

Keywords

chmod filesystem fs javascript mask node node-js nodejs permissions process restrictions security stdlib umask util utilities utility utils
Last synced: 6 months ago · JSON representation ·

Repository

Get/set the process mask.

Basic Info
Statistics
  • Stars: 2
  • Watchers: 3
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Topics
chmod filesystem fs javascript mask node node-js nodejs permissions process restrictions security stdlib umask util utilities utility utils
Created over 4 years ago · Last pushed 8 months ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Security

README.md

About stdlib...

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

umask

NPM version Build Status Coverage Status <!-- dependencies -->

Get/set the process mask.

A **mask** is a set of bits, each of which restricts how its corresponding permission is set for newly created files. On POSIX platforms, each file has a set of attributes that control who can read, write, or execute that file. Upon creating a file, file permissions must be set to an initial setting. The process mask restricts those permission settings. If the mask contains a bit set to `1`, the corresponding initial file permission is disabled. If the mask contains a bit set to `0`, the corresponding permission is left to be determined by the requesting process and the system. The process mask is thus a filter that **removes** permissions as a file is created; i.e., each bit set to a `1` removes its corresponding permission. In octal representation, a mask is a four digit number comprised as follows (using `0077` as an example): - `0`: special permissions (setuid, setgid, sticky bit) - `0`: (u)ser/owner permissions - `7`: (g)roup permissions - `7`: (o)thers/non-group permissions Octal codes correspond to the following permissions: - `0`: read, write, execute - `1`: read, write - `2`: read, execute - `3`: read - `4`: write, execute - `5`: write - `6`: execute - `7`: no permissions If provided fewer than four digits, the mask is left-padded with zeros. Note, however, that **only** the last three digits (i.e., the file permissions digits) of the mask are actually used when the mask is applied (i.e., `mask & 0777`). Permissions can be represented using the following symbolic form: ```text u=rwx,g=rwx,o=rwx ``` where - **u**: user permissions - **g**: group permissions - **o**: other/non-group permissions - **r**: read - **w**: write - **x**: execute When setting permissions using symbolic notation, one may use a _mask expression_ of the form: ```text [] ``` where `` may be a combination of - **u**: user - **g**: group - **o**: other/non-group - **a**: all `` may be a combination of - **r**: read - **w**: write - **x**: execute - **X**: special execute - **s**: setuid/gid on execution - **t**: sticky and `` may be one of - **+**: enable - **-**: disable - **=**: enable specified and disable unspecified permissions For example, - `u-w`: disable user write permissions - `u+w`: enable user write permissions - `u=w`: enable user write permissions and disable user read and execute To specify multiple changes, one can specify a comma-separated list of mask expressions. For example, ```text u+rwx,g-x,o=r ``` would enable user read, write, and execute permissions, disable group execute permissions, enable other read permissions, and disable other write and execute permissions. The `a` class indicates "all", which is the same as specifying `ugo`. This is the default class if a class is omitted when specifying permissions. For example, `+x` is equivalent to `a+x` which is equivalent to `ugo+x` which is equivalent to `u+x,g+x,o+x` and enables execution for all classes.
## Installation ```bash npm install @stdlib/process-umask ``` Alternatively, - To load the package in a website via a `script` tag without installation and bundlers, use the [ES Module][es-module] available on the [`esm`][esm-url] branch (see [README][esm-readme]). - If you are using Deno, visit the [`deno`][deno-url] branch (see [README][deno-readme] for usage intructions). - For use in Observable, or in browser/node environments, use the [Universal Module Definition (UMD)][umd] build available on the [`umd`][umd-url] branch (see [README][umd-readme]). - To use as a general utility for the command line, install the corresponding [CLI package][cli-section] globally. The [branches.md][branches-url] file summarizes the available branches and displays a diagram illustrating their relationships. To view installation and usage instructions specific to each branch build, be sure to explicitly navigate to the respective README files on each branch, as linked to above.
## Usage ```javascript var umask = require( '@stdlib/process-umask' ); ``` #### umask( \[mask,] \[options] ) Returns the process mask. ```javascript var mask = umask(); // returns ``` To set the process mask, provide a `mask` argument. When provided a `mask`, the function returns the previous mask value. ```javascript var mask = umask(); // returns var prev = umask( 0 ); // returns var bool = ( prev === mask ); // returns true ``` The `mask` argument may be either an integer value or a `string` representing the mask using symbolic notation. ```javascript var mask = umask( 'u=rwx,g=rw,o=rw' ); ``` The function accepts the following `options`: - **symbolic**: `boolean` indicating whether to return the mask in symbolic notation. Default: `false`. To return the process mask in symbolic notation, set the `symbolic` option to `true`. ```javascript var opts = { 'symbolic': true }; // Get the mask: var mask = umask( opts ); // e.g., returns 'u=rwx,g=rw,o=rw' // Set the mask: mask = umask( 0, opts ); // e.g., returns 'u=rwx,g=rw,o=rw' ```
## Notes - To set the process mask using an octal `string` (e.g., `0777`), use `parseInt` to convert the `string` to an integer value. ```javascript umask( parseInt( '0777', 8 ) ); ``` - See [umask(2)][umask].
## Examples ```javascript var lpad = require( '@stdlib/string-left-pad' ); var umask = require( '@stdlib/process-umask' ); // Print the process mask as an integer: var mask = umask(); console.log( mask.toString() ); // Print the process mask as an octal string: console.log( lpad( mask.toString(), 4, '0' ) ); // Print the process mask using symbolic notation: var opts = { 'symbolic': true }; console.log( umask( opts ) ); ```

## CLI
## Installation To use as a general utility, install the CLI package globally ```bash npm install -g @stdlib/process-umask-cli ```
### Usage ```text Usage: umask [options] Options: -h, --help Print this message. -V, --version Print the package version. -p, --print Print the mask command. -S, --symbolic Print the mask using symbolic notation. ```
### Examples ```bash $ umask ``` To print the mask in command format, set the `-p` flag. ```bash $ umask -p ```

* * * ## Notice This package is part of [stdlib][stdlib], a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more. For more information on the project, filing bug reports and feature requests, and guidance on how to develop [stdlib][stdlib], see the main project [repository][stdlib]. #### Community [![Chat][chat-image]][chat-url] --- ## License See [LICENSE][stdlib-license]. ## Copyright Copyright © 2016-2025. The Stdlib [Authors][stdlib-authors].

Owner

  • Name: stdlib
  • Login: stdlib-js
  • Kind: organization

Standard library for JavaScript.

Citation (CITATION.cff)

cff-version: 1.2.0
title: stdlib
message: >-
  If you use this software, please cite it using the
  metadata from this file.

type: software

authors:
  - name: The Stdlib Authors
    url: https://github.com/stdlib-js/stdlib/graphs/contributors

repository-code: https://github.com/stdlib-js/stdlib
url: https://stdlib.io

abstract: |
  Standard library for JavaScript and Node.js.

keywords:
  - JavaScript
  - Node.js
  - TypeScript
  - standard library
  - scientific computing
  - numerical computing
  - statistical computing

license: Apache-2.0 AND BSL-1.0

date-released: 2016

GitHub Events

Total
  • Push event: 23
Last Year
  • Push event: 23

Committers

Last synced: 8 months ago

All Time
  • Total Commits: 67
  • Total Committers: 1
  • Avg Commits per committer: 67.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 11
  • Committers: 1
  • Avg Commits per committer: 11.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
stdlib-bot n****y@s****o 67
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • npm 28 last-month
  • Total dependent packages: 2
  • Total dependent repositories: 0
  • Total versions: 13
  • Total maintainers: 4
npmjs.org: @stdlib/process-umask

Get/set the process mask.

  • Homepage: https://stdlib.io
  • License: Apache-2.0
  • Latest release: 0.2.2
    published over 1 year ago
  • Versions: 13
  • Dependent Packages: 2
  • Dependent Repositories: 0
  • Downloads: 28 Last month
Rankings
Dependent packages count: 9.5%
Downloads: 13.1%
Average: 16.4%
Stargazers count: 16.8%
Forks count: 17.4%
Dependent repos count: 25.3%
Funding
  • type: opencollective
  • url: https://opencollective.com/stdlib
Last synced: 6 months ago

Dependencies

package.json npm
  • @stdlib/assert-is-browser ^0.0.x development
  • @stdlib/assert-is-windows ^0.0.x development
  • @stdlib/bench ^0.0.x development
  • @stdlib/number-uint16-base-to-binary-string ^0.0.x development
  • @stdlib/process-exec-path ^0.0.x development
  • @stdlib/string-right-trim ^0.0.x development
  • istanbul ^0.4.1 development
  • tap-spec 5.x.x development
  • tape git+https://github.com/kgryte/tape.git#fix/globby development
  • @stdlib/assert-has-own-property ^0.0.x
  • @stdlib/assert-is-boolean ^0.0.x
  • @stdlib/assert-is-nonnegative-integer ^0.0.x
  • @stdlib/assert-is-plain-object ^0.0.x
  • @stdlib/assert-is-string ^0.0.x
  • @stdlib/cli-ctor ^0.0.x
  • @stdlib/fs-read-file ^0.0.x
  • @stdlib/string-format ^0.0.x
  • @stdlib/string-left-pad ^0.0.x
.github/workflows/benchmark.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/cancel.yml actions
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/close_pull_requests.yml actions
  • superbrothers/close-pull-request v3 composite
.github/workflows/examples.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/npm_downloads.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • actions/upload-artifact v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/productionize.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • stdlib-js/bundle-action main composite
  • stdlib-js/transform-errors-action main composite
.github/workflows/publish.yml actions
  • JS-DevTools/npm-publish v1 composite
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • styfle/cancel-workflow-action 0.11.0 composite
.github/workflows/test.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/test_bundles.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • denoland/setup-deno v1 composite
.github/workflows/test_coverage.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
  • codecov/codecov-action v3 composite
  • distributhor/workflow-webhook v3 composite
.github/workflows/test_install.yml actions
  • act10ns/slack v1 composite
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/publish_cli.yml actions
  • JS-DevTools/npm-publish fe72237be0920f7a0cafd6a966c9b929c9466e9b composite
  • act10ns/slack ed1309ab9862e57e9e583e51c7889486b9a00b0f composite
  • actions/checkout 8ade135a41bc03ea155e62e844d188df1ea18608 composite
  • actions/setup-node 5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d composite
  • styfle/cancel-workflow-action b173b6ec0100793626c2d9e6b90435061f4fc3e5 composite