Socket
Socket
Sign inDemoInstall

infer-owner

Package Overview
Dependencies
0
Maintainers
3
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    infer-owner

Infer the owner of a path based on the owner of its nearest existing parent


Version published
Weekly downloads
10M
increased by0.59%
Maintainers
3
Install size
5.17 kB
Created
Weekly downloads
 

Package description

What is infer-owner?

The infer-owner npm package is designed to infer the owner of a file or directory based on the ownership of its parent directories. It is particularly useful in file system operations where maintaining the correct file ownership is crucial, such as in deployment scripts or file management utilities. This package helps ensure that files and directories are created with the appropriate ownership, reflecting the ownership of their parent directories, thus maintaining consistency and security in file operations.

What are infer-owner's main functionalities?

Infer ownership of a file or directory

This feature allows you to infer the ownership (user ID and group ID) of a file or directory by analyzing its parent directories. The function returns a Promise that resolves with an object containing the `uid` and `gid` of the inferred owner.

const inferOwner = require('infer-owner');

inferOwner('/path/to/file/or/directory').then(owner => {
  console.log(owner); // { uid: 1000, gid: 1000 }
});

Other packages similar to infer-owner

Readme

Source

infer-owner

Infer the owner of a path based on the owner of its nearest existing parent

USAGE

const inferOwner = require('infer-owner')

inferOwner('/some/cache/folder/file').then(owner => {
  // owner is {uid, gid} that should be attached to
  // the /some/cache/folder/file, based on ownership
  // of /some/cache/folder, /some/cache, /some, or /,
  // whichever is the first to exist
})

// same, but not async
const owner = inferOwner.sync('/some/cache/folder/file')

// results are cached!  to reset the cache (eg, to change
// permissions for whatever reason), do this:
inferOwner.clearCache()

This module endeavors to be as performant as possible. Parallel requests for ownership of the same path will only stat the directories one time.

API

  • inferOwner(path) -> Promise<{ uid, gid }>

    If the path exists, return its uid and gid. If it does not, look to its parent, then its grandparent, and so on.

  • inferOwner(path) -> { uid, gid }

    Sync form of inferOwner(path).

  • inferOwner.clearCache()

    Delete all cached ownership information and in-flight tracking.

FAQs

Last updated on 19 Jul 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc