Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fs-admin

Package Overview
Dependencies
Maintainers
6
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-admin

Manipulate files with escalated privileges

  • 0.10.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
624
decreased by-24.36%
Maintainers
6
Weekly downloads
 
Created
Source

fs-admin

Build Status Build status

Perform file system operations with administrator privileges.

Installing

npm install fs-admin

Packaging (Linux only)

This library uses PolicyKit to escalate privileges when calling createWriteStream(path) on Linux. In particular, it will invoke pkexec dd of=path to stream the desired bytes into the specified location.

PolicyKit

Not all Linux distros may include PolicyKit as part of their standard installation. As such, it is recommended to make it an explicit dependency of your application package. The following is an example Debian control file that requires policykit-1 to be installed as part of my-application:

Package: my-application
Version: 1.0.0
Depends: policykit-1

Policies

When using this library as part of a Linux application, you may want to install a Policy as well. Although not mandatory, policy files allow customizing the behavior of pkexec by e.g., displaying a custom password prompt or retaining admin privileges for a short period of time:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
 "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<policyconfig>
  <vendor>Your Application Name</vendor>
  <action id="my-application.pkexec.dd">
    <description gettext-domain="my-application">Admin privileges required</description>
    <message gettext-domain="my-application">Please enter your password to save this file</message>
    <annotate key="org.freedesktop.policykit.exec.path">/bin/dd</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
    <defaults>
      <allow_any>auth_admin_keep</allow_any>
      <allow_inactive>auth_admin_keep</allow_inactive>
      <allow_active>auth_admin_keep</allow_active>
    </defaults>
  </action>
</policyconfig>

Policy files should be installed in /usr/share/polkit-1/actions as part of your application's installation script.

For more information, you can find a complete example of requiring PolicyKit and distributing policy files in the Atom repository.

Keywords

FAQs

Package last updated on 01 Oct 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc