pax_global_header00006660000000000000000000000064130017303770014513gustar00rootroot0000000000000052 comment=51a5e272b9ba2bf7eb70dc8eddc633da6893e4bd parse-passwd-1.0.0/000077500000000000000000000000001300173037700141225ustar00rootroot00000000000000parse-passwd-1.0.0/.editorconfig000066400000000000000000000002531300173037700165770ustar00rootroot00000000000000root = true [*] indent_style = space indent_size = 2 charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = false parse-passwd-1.0.0/.eslintrc.json000066400000000000000000000111251300173037700167160ustar00rootroot00000000000000{ "ecmaFeatures": { "modules": true, "experimentalObjectRestSpread": true }, "env": { "browser": false, "es6": true, "node": true, "mocha": true }, "globals": { "document": false, "navigator": false, "window": false }, "rules": { "accessor-pairs": 2, "arrow-spacing": [ 2, { "before": true, "after": true } ], "block-spacing": [ 2, "always" ], "brace-style": [ 2, "1tbs", { "allowSingleLine": true } ], "comma-dangle": [ 2, "never" ], "comma-spacing": [ 2, { "before": false, "after": true } ], "comma-style": [ 2, "last" ], "constructor-super": 2, "curly": [ 2, "multi-line" ], "dot-location": [ 2, "property" ], "eol-last": 2, "eqeqeq": [ 2, "allow-null" ], "generator-star-spacing": [ 2, { "before": true, "after": true } ], "handle-callback-err": [ 2, "^(err|error)$" ], "indent": [ 2, 2, { "SwitchCase": 1 } ], "key-spacing": [ 2, { "beforeColon": false, "afterColon": true } ], "keyword-spacing": [ 2, { "before": true, "after": true } ], "new-cap": [ 2, { "newIsCap": true, "capIsNew": false } ], "new-parens": 2, "no-array-constructor": 2, "no-caller": 2, "no-class-assign": 2, "no-cond-assign": 2, "no-const-assign": 2, "no-control-regex": 2, "no-debugger": 2, "no-delete-var": 2, "no-dupe-args": 2, "no-dupe-class-members": 2, "no-dupe-keys": 2, "no-duplicate-case": 2, "no-empty-character-class": 2, "no-eval": 2, "no-ex-assign": 2, "no-extend-native": 2, "no-extra-bind": 2, "no-extra-boolean-cast": 2, "no-extra-parens": [ 2, "functions" ], "no-fallthrough": 2, "no-floating-decimal": 2, "no-func-assign": 2, "no-implied-eval": 2, "no-inner-declarations": [ 2, "functions" ], "no-invalid-regexp": 2, "no-irregular-whitespace": 2, "no-iterator": 2, "no-label-var": 2, "no-labels": 2, "no-lone-blocks": 2, "no-mixed-spaces-and-tabs": 2, "no-multi-spaces": 2, "no-multi-str": 2, "no-multiple-empty-lines": [ 2, { "max": 1 } ], "no-native-reassign": 0, "no-negated-in-lhs": 2, "no-new": 2, "no-new-func": 2, "no-new-object": 2, "no-new-require": 2, "no-new-wrappers": 2, "no-obj-calls": 2, "no-octal": 2, "no-octal-escape": 2, "no-proto": 0, "no-redeclare": 2, "no-regex-spaces": 2, "no-return-assign": 2, "no-self-compare": 2, "no-sequences": 2, "no-shadow-restricted-names": 2, "no-spaced-func": 2, "no-sparse-arrays": 2, "no-this-before-super": 2, "no-throw-literal": 2, "no-trailing-spaces": 0, "no-undef": 2, "no-undef-init": 2, "no-unexpected-multiline": 2, "no-unneeded-ternary": [ 2, { "defaultAssignment": false } ], "no-unreachable": 2, "no-unused-vars": [ 2, { "vars": "all", "args": "none" } ], "no-useless-call": 0, "no-with": 2, "one-var": [ 0, { "initialized": "never" } ], "operator-linebreak": [ 0, "after", { "overrides": { "?": "before", ":": "before" } } ], "padded-blocks": [ 0, "never" ], "quotes": [ 2, "single", "avoid-escape" ], "radix": 2, "semi": [ 2, "always" ], "semi-spacing": [ 2, { "before": false, "after": true } ], "space-before-blocks": [ 2, "always" ], "space-before-function-paren": [ 2, "never" ], "space-in-parens": [ 2, "never" ], "space-infix-ops": 2, "space-unary-ops": [ 2, { "words": true, "nonwords": false } ], "spaced-comment": [ 0, "always", { "markers": [ "global", "globals", "eslint", "eslint-disable", "*package", "!", "," ] } ], "use-isnan": 2, "valid-typeof": 2, "wrap-iife": [ 2, "any" ], "yoda": [ 2, "never" ] } } parse-passwd-1.0.0/.gitattributes000066400000000000000000000000141300173037700170100ustar00rootroot00000000000000* text=auto parse-passwd-1.0.0/.gitignore000066400000000000000000000000251300173037700161070ustar00rootroot00000000000000node_modules coverageparse-passwd-1.0.0/.travis.yml000066400000000000000000000001531300173037700162320ustar00rootroot00000000000000sudo: false language: node_js os: - linux - osx node_js: - "6" - "5" - "4" - "0.12" - "0.10" parse-passwd-1.0.0/.verb.md000066400000000000000000000001331300173037700154550ustar00rootroot00000000000000## Usage ```js var parse = require('{%= name %}'); ``` ## API {%= apidocs("index.js") %} parse-passwd-1.0.0/LICENSE000066400000000000000000000020711300173037700151270ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2016 Brian Woodward Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. parse-passwd-1.0.0/README.md000066400000000000000000000046701300173037700154100ustar00rootroot00000000000000# parse-passwd [![NPM version](https://img.shields.io/npm/v/parse-passwd.svg?style=flat)](https://www.npmjs.com/package/parse-passwd) [![NPM downloads](https://img.shields.io/npm/dm/parse-passwd.svg?style=flat)](https://npmjs.org/package/parse-passwd) [![Linux Build Status](https://img.shields.io/travis/doowb/parse-passwd.svg?style=flat&label=Travis)](https://travis-ci.org/doowb/parse-passwd) [![Windows Build Status](https://img.shields.io/appveyor/ci/doowb/parse-passwd.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/doowb/parse-passwd) > Parse a passwd file into a list of users. ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm install --save parse-passwd ``` ## Usage ```js var parse = require('parse-passwd'); ``` ## API **Example** ```js // assuming '/etc/passwd' contains: // doowb:*:123:123:Brian Woodward:/Users/doowb:/bin/bash console.log(parse(fs.readFileSync('/etc/passwd', 'utf8'))); //=> [ //=> { //=> username: 'doowb', //=> password: '*', //=> uid: '123', //=> gid: '123', //=> gecos: 'Brian Woodward', //=> homedir: '/Users/doowb', //=> shell: '/bin/bash' //=> } //=> ] ``` **Params** * `content` **{String}**: Content of a passwd file to parse. * `returns` **{Array}**: Array of user objects parsed from the content. ## About ### Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). Please read the [contributing guide](contributing.md) for avice on opening issues, pull requests, and coding standards. ### Building docs _(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ To generate the readme and API documentation with [verb](https://github.com/verbose/verb): ```sh $ npm install -g verb verb-generate-readme && verb ``` ### Running tests Install dev dependencies: ```sh $ npm install -d && npm test ``` ### Author **Brian Woodward** * [github/doowb](https://github.com/doowb) * [twitter/doowb](http://twitter.com/doowb) ### License Copyright © 2016, [Brian Woodward](https://github.com/doowb). Released under the [MIT license](LICENSE). *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.2.0, on October 19, 2016._parse-passwd-1.0.0/appveyor.yml000066400000000000000000000011211300173037700165050ustar00rootroot00000000000000# Test against this version of Node.js environment: matrix: # node.js - nodejs_version: "6.0" - nodejs_version: "5.0" - nodejs_version: "4.0" - nodejs_version: "0.12" - nodejs_version: "0.10" # Install scripts. (runs after repo cloning) install: # Get the latest stable version of Node.js or io.js - ps: Install-Product node $env:nodejs_version # install modules - npm install # Post-install test scripts. test_script: # Output useful info for debugging. - node --version - npm --version # run tests - npm test # Don't actually build. build: off parse-passwd-1.0.0/contributing.md000066400000000000000000000063011300173037700171530ustar00rootroot00000000000000# Contributing to parse-passwd First and foremost, thank you! We appreciate that you want to contribute to parse-passwd, your time is valuable, and your contributions mean a lot to us. **What does "contributing" mean?** Creating an issue is the simplest form of contributing to a project. But there are many ways to contribute, including the following: - Updating or correcting documentation - Feature requests - Bug reports If you'd like to learn more about contributing in general, the [Guide to Idiomatic Contributing](https://github.com/jonschlinkert/idiomatic-contributing) has a lot of useful information. **Showing support for parse-passwd** Please keep in mind that open source software is built by people like you, who spend their free time creating things the rest the community can use. Don't have time to contribute? No worries, here are some other ways to show your support for parse-passwd: - star the [project](https://github.com/doowb/parse-passwd) - tweet your support for parse-passwd ## Issues ### Before creating an issue Please try to determine if the issue is caused by an underlying library, and if so, create the issue there. Sometimes this is difficult to know. We only ask that you attempt to give a reasonable attempt to find out. Oftentimes the readme will have advice about where to go to create issues. Try to follow these guidelines - **Investigate the issue**: - **Check the readme** - oftentimes you will find notes about creating issues, and where to go depending on the type of issue. - Create the issue in the appropriate repository. ### Creating an issue Please be as descriptive as possible when creating an issue. Give us the information we need to successfully answer your question or address your issue by answering the following in your issue: - **version**: please note the version of parse-passwd are you using - **extensions, plugins, helpers, etc** (if applicable): please list any extensions you're using - **error messages**: please paste any error messages into the issue, or a [gist](https://gist.github.com/) ## Above and beyond Here are some tips for creating idiomatic issues. Taking just a little bit extra time will make your issue easier to read, easier to resolve, more likely to be found by others who have the same or similar issue in the future. - read the [Guide to Idiomatic Contributing](https://github.com/jonschlinkert/idiomatic-contributing) - take some time to learn basic markdown. This [markdown cheatsheet](https://gist.github.com/jonschlinkert/5854601) is super helpful, as is the GitHub guide to [basic markdown](https://help.github.com/articles/markdown-basics/). - Learn about [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown/). And if you want to really go above and beyond, read [mastering markdown](https://guides.github.com/features/mastering-markdown/). - use backticks to wrap code. This ensures that code will retain its format, making it much more readable to others - use syntax highlighting by adding the correct language name after the first "code fence" [node-glob]: https://github.com/isaacs/node-glob [micromatch]: https://github.com/jonschlinkert/micromatch [so]: http://stackoverflow.com/questions/tagged/parse-passwdparse-passwd-1.0.0/index.js000066400000000000000000000025501300173037700155710ustar00rootroot00000000000000'use strict'; /** * Parse the content of a passwd file into a list of user objects. * This function ignores blank lines and comments. * * ```js * // assuming '/etc/passwd' contains: * // doowb:*:123:123:Brian Woodward:/Users/doowb:/bin/bash * console.log(parse(fs.readFileSync('/etc/passwd', 'utf8'))); * * //=> [ * //=> { * //=> username: 'doowb', * //=> password: '*', * //=> uid: '123', * //=> gid: '123', * //=> gecos: 'Brian Woodward', * //=> homedir: '/Users/doowb', * //=> shell: '/bin/bash' * //=> } * //=> ] * ``` * @param {String} `content` Content of a passwd file to parse. * @return {Array} Array of user objects parsed from the content. * @api public */ module.exports = function(content) { if (typeof content !== 'string') { throw new Error('expected a string'); } return content .split('\n') .map(user) .filter(Boolean); }; function user(line, i) { if (!line || !line.length || line.charAt(0) === '#') { return null; } // see https://en.wikipedia.org/wiki/Passwd for field descriptions var fields = line.split(':'); return { username: fields[0], password: fields[1], uid: fields[2], gid: fields[3], // see https://en.wikipedia.org/wiki/Gecos_field for GECOS field descriptions gecos: fields[4], homedir: fields[5], shell: fields[6] }; } parse-passwd-1.0.0/package.json000066400000000000000000000017541300173037700164170ustar00rootroot00000000000000{ "name": "parse-passwd", "description": "Parse a passwd file into a list of users.", "version": "1.0.0", "homepage": "https://github.com/doowb/parse-passwd", "author": "Brian Woodward (https://github.com/doowb)", "repository": "doowb/parse-passwd", "bugs": { "url": "https://github.com/doowb/parse-passwd/issues" }, "license": "MIT", "files": [ "index.js", "LICENSE" ], "main": "index.js", "engines": { "node": ">=0.10.0" }, "scripts": { "test": "mocha" }, "devDependencies": { "gulp-format-md": "^0.1.11", "mocha": "^3.1.2" }, "keywords": [ "etc", "etc-passwd", "etc/passwd", "parse", "parse-passwd", "passwd" ], "verb": { "toc": false, "layout": "default", "tasks": [ "readme" ], "plugins": [ "gulp-format-md" ], "lint": { "reflinks": true }, "related": { "list": [] }, "reflinks": [ "verb", "verb-generate-readme" ] } } parse-passwd-1.0.0/test/000077500000000000000000000000001300173037700151015ustar00rootroot00000000000000parse-passwd-1.0.0/test/fixtures/000077500000000000000000000000001300173037700167525ustar00rootroot00000000000000parse-passwd-1.0.0/test/fixtures/passwd000066400000000000000000000007611300173037700202020ustar00rootroot00000000000000## # User Database # # Note that this file is consulted directly only when the system is running # in single-user mode. At other times this information is provided by # Open Directory. # # See the opendirectoryd(8) man page for additional information about # Open Directory. ## nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false root:*:0:0:System Administrator:/var/root:/bin/sh daemon:*:1:1:System Services:/var/root:/usr/bin/false doowb:*:123:123:Brian Woodward:/Users/doowb:/bin/bash parse-passwd-1.0.0/test/test.js000066400000000000000000000024571300173037700164260ustar00rootroot00000000000000'use strict'; require('mocha'); var fs = require('fs'); var path = require('path'); var assert = require('assert'); var parse = require('../'); var fixture = path.join(__dirname, 'fixtures', 'passwd'); describe('parse-passwd', function() { it('should export a function', function() { assert.equal(typeof parse, 'function'); }); it('should throw an error when invalid args are passed', function(cb) { try { parse(); cb(new Error('expected an error')); } catch (err) { assert(err); assert.equal(err.message, 'expected a string'); cb(); } }); it('should parse a passwd file', function() { var expected = [ {username: 'nobody', password: '*', uid: '-2', gid: '-2', gecos: 'Unprivileged User', homedir: '/var/empty', shell: '/usr/bin/false'}, {username: 'root', password: '*', uid: '0', gid: '0', gecos: 'System Administrator', homedir: '/var/root', shell: '/bin/sh'}, {username: 'daemon', password: '*', uid: '1', gid: '1', gecos: 'System Services', homedir: '/var/root', shell: '/usr/bin/false'}, {username: 'doowb', password: '*', uid: '123', gid: '123', gecos: 'Brian Woodward', homedir: '/Users/doowb', shell: '/bin/bash'} ]; var actual = parse(fs.readFileSync(fixture, 'utf8')); assert.deepEqual(actual, expected); }); });