{ "info": { "author": "Andrew Teixeira", "author_email": "teixeira@broadinstitute.org", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# pysudoers\n\nThis library provides a [Python][1] interface to the Linux sudoers file. python-sudoers is open sourced under the [BSD 3-Clause license](LICENSE.txt).\n\n[![CircleCI](https://circleci.com/gh/broadinstitute/python-sudoers/tree/master.svg?style=svg)](https://circleci.com/gh/broadinstitute/python-sudoers/tree/master)\n[![codecov](https://codecov.io/gh/broadinstitute/python-sudoers/branch/master/graph/badge.svg)](https://codecov.io/gh/broadinstitute/python-sudoers)\n\n## Basics\n\npysudoers still runs on Python 2.7, and Python >= 3.4\n\n## Features\n\nThis library parses a sudoers file into its component parts. It's not 100% compliant with the EBNF format of the file (yet), but it's getting there. Currently, the script parses out 6 distinct line types from the file:\n\n* Defaults (This is only a string currently. Pieces of a Defaults setting are not parsed/separated.)\n* Cmnd_Alias\n* Host_Alias\n* Runas_Alias\n* User_Alias\n* User specifications (which we call **rules**)\n\nAs user specifications are the most complicated, they are most likely the area that needs the most improvement. Currently, the following pieces of a user specification are separated out as part of the parsing:\n\n* User list\n* Host list\n* Command list (containing):\n ** Tags\n ** Run As notations\n ** Commands\n\n## Installing\n\nYou can use pip to install pysudoers:\n\n```sh\npip install pysudoers\n```\n\n## Examples\n\nParsing of the `sudoers` file is done as part of initializing the `Sudoers` object. So, you can start using the properties under `Sudoers` immediately. The following example will print out all the different \"types\" from the file:\n\n```python\nfrom pysudoers import Sudoers\n\nsobj = Sudoers(path=\"tmp/sudoers\")\n\nfor default in sobj.defaults:\n print(default)\n\nfor key in sobj.host_aliases:\n print(key)\n print(sobj.host_aliases[key])\n\nfor key in sobj.cmnd_aliases:\n print(key)\n print(sobj.cmnd_aliases[key])\n\nfor key in sobj.runas_aliases:\n print(key)\n print(sobj.runas_aliases[key])\n\nfor key in sobj.user_aliases:\n print(key)\n print(sobj.user_aliases[key])\n\nfor rule in sobj.rules:\n print(rule)\n```\n\nNow, suppose you want to print out all the user specifications (rules), but you only want to see the users and hosts for each rule.\n\n```python\nfrom pysudoers import Sudoers\n\nsobj = Sudoers(path=\"tmp/sudoers\")\n\nfor rule in sobj.rules:\n print(\"%s | %s\" % (\",\".join(rule[\"users\"]), \",\".join(rule[\"hosts\"])))\n```\n\n## Contributing\n\nPull requests to add functionality and fix bugs are always welcome. Please check the CONTRIBUTING.md for specifics on contributions.\n\n### Testing\n\nWe try to have a high level of test coverage on the code. Therefore, when adding anything to the repo, tests should be written to test a new feature or to test a bug fix so that there won't be a regression. This library is setup to be pretty simple to build a working development environment using [Docker][4]. Therefore, it is suggested that you have [Docker][4] installed where you clone this repository to make development easier.\n\nTo start a development environment, you should be able to just run the `dev.sh` script. This script will use the `Dockerfile` in this repository to build a [Docker][4] container with all the dependencies for development installed using [Pipenv][3].\n\n```sh\n./dev.sh\n```\n\nThe first time you run the script, it should build the [Docker][4] image and then drop you into the container's shell. The directory where you cloned this repository should be volume mounted in to `/usr/src`, which should also be the current working directory. From there, you can make changes as you see fit. Tests can be run from the `/usr/src` directory by simply typing `green` as [green][5] has been setup to with the correct parameters.\n\n[1]: https://www.python.org/ \"Python\"\n[3]: https://pipenv.readthedocs.io/en/latest/ \"Pipenv\"\n[4]: https://www.docker.com/ \"Docker\"\n[5]: https://github.com/CleanCut/green \"green\"\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/broadinstitute/python-sudoers", "keywords": "linux,sudoers", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "pysudoers", "package_url": "https://pypi.org/project/pysudoers/", "platform": "", "project_url": "https://pypi.org/project/pysudoers/", "project_urls": { "Homepage": "https://github.com/broadinstitute/python-sudoers" }, "release_url": "https://pypi.org/project/pysudoers/1.2.0/", "requires_dist": null, "requires_python": ">=2.7, <4", "summary": "Python interface to the Linux sudoers file", "version": "1.2.0" }, "last_serial": 5209467, "releases": { "1.0.1": [ { "comment_text": "", "digests": { "md5": "b9891a50d2a7c57bcd4f45f93620f855", "sha256": "2da6cf29b34fd3986b27f904f76be1b426df1757527c309f257e5f8b33bba52e" }, "downloads": -1, "filename": "pysudoers-1.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "b9891a50d2a7c57bcd4f45f93620f855", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7, <4", "size": 7736, "upload_time": "2019-04-24T19:27:52", "url": "https://files.pythonhosted.org/packages/5d/2a/3bbdc791fbeabea2283ca93eb82f38f3271e6b1e02bb1d63c79d5e0a8d8b/pysudoers-1.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e7ef808758012fefdd2c5e6fd45f219a", "sha256": "211afb1ca2905405f1d3ae566410cd285b594e97af48c2c1ec061d568702f1db" }, "downloads": -1, "filename": "pysudoers-1.0.1.tar.gz", "has_sig": false, "md5_digest": "e7ef808758012fefdd2c5e6fd45f219a", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, <4", "size": 27253, "upload_time": "2019-04-24T19:27:58", "url": "https://files.pythonhosted.org/packages/e1/99/a1f1545b73428c8f46a676e1ea496fd1afb714bb02beaf7736bee67128f4/pysudoers-1.0.1.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "69bf4b6f8e1d07389e17dfa6307f22e1", "sha256": "896e973a485df51dd3a9b887e2c79dc603002b600ca29860e0f7d98df00adec8" }, "downloads": -1, "filename": "pysudoers-1.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "69bf4b6f8e1d07389e17dfa6307f22e1", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7, <4", "size": 9920, "upload_time": "2019-04-26T19:16:10", "url": "https://files.pythonhosted.org/packages/46/5c/3fa6ae02a3a65c87b10367cf9e3fb8e2693613d82d84c8b87e0638485a63/pysudoers-1.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f4d86856671981562b086b90b4002caf", "sha256": "2140ec9823cd0cd53b5173d0d204d8d1c7b2e594458835d95ed13743b73937ec" }, "downloads": -1, "filename": "pysudoers-1.1.0.tar.gz", "has_sig": false, "md5_digest": "f4d86856671981562b086b90b4002caf", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, <4", "size": 27406, "upload_time": "2019-04-26T19:16:12", "url": "https://files.pythonhosted.org/packages/e9/c6/e6f43ad352d4fa09b344aead3b1ea0bfc25cea2e586af8186664efaabf54/pysudoers-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "da892a563f13eb3a6e05753a9a8f1bd3", "sha256": "2e66e86d6d9a584ed94eb10d54c92e8880e9ebcde33d2295c6d1a7b463b06302" }, "downloads": -1, "filename": "pysudoers-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "da892a563f13eb3a6e05753a9a8f1bd3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7, <4", "size": 10412, "upload_time": "2019-04-30T18:03:43", "url": "https://files.pythonhosted.org/packages/00/bd/cd8495d6e619050ebe58a3fccc99d60aebb4d9e34ac37da4f671d8e22b72/pysudoers-1.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ecc6740da2b8ed190190551cc5e5d3d2", "sha256": "51f0f6f317f4cfdcf9fa7842696eec1b8a11691ca3dfe141e357238d688701d6" }, "downloads": -1, "filename": "pysudoers-1.2.0.tar.gz", "has_sig": false, "md5_digest": "ecc6740da2b8ed190190551cc5e5d3d2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, <4", "size": 30066, "upload_time": "2019-04-30T18:03:46", "url": "https://files.pythonhosted.org/packages/28/eb/2437658747910fcc022920633122acb2f1fe656f973af4b147420d0bf34f/pysudoers-1.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "da892a563f13eb3a6e05753a9a8f1bd3", "sha256": "2e66e86d6d9a584ed94eb10d54c92e8880e9ebcde33d2295c6d1a7b463b06302" }, "downloads": -1, "filename": "pysudoers-1.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "da892a563f13eb3a6e05753a9a8f1bd3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7, <4", "size": 10412, "upload_time": "2019-04-30T18:03:43", "url": "https://files.pythonhosted.org/packages/00/bd/cd8495d6e619050ebe58a3fccc99d60aebb4d9e34ac37da4f671d8e22b72/pysudoers-1.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ecc6740da2b8ed190190551cc5e5d3d2", "sha256": "51f0f6f317f4cfdcf9fa7842696eec1b8a11691ca3dfe141e357238d688701d6" }, "downloads": -1, "filename": "pysudoers-1.2.0.tar.gz", "has_sig": false, "md5_digest": "ecc6740da2b8ed190190551cc5e5d3d2", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, <4", "size": 30066, "upload_time": "2019-04-30T18:03:46", "url": "https://files.pythonhosted.org/packages/28/eb/2437658747910fcc022920633122acb2f1fe656f973af4b147420d0bf34f/pysudoers-1.2.0.tar.gz" } ] }