Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

atom/fs-admin

Repository files navigation

Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our official announcement

fs-admin

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 Namevendor>
<action id="my-application.pkexec.dd">
<description gettext-domain="my-application">Admin privileges requireddescription>
<message gettext-domain="my-application">Please enter your password to save this filemessage>
<annotate key="org.freedesktop.policykit.exec.path">/bin/ddannotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">trueannotate>
<defaults>
<allow_any>auth_admin_keepallow_any>
<allow_inactive>auth_admin_keepallow_inactive>
<allow_active>auth_admin_keepallow_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.

About

Perform file system operations with admin privileges

Resources

Readme

License

MIT license

Code of conduct

Code of conduct

Contributing

Contributing

Stars

Watchers

Forks

Packages

Contributors