{"id":19984626,"url":"https://github.com/twilightcoders/rubysu","last_synced_at":"2025-06-24T15:40:09.142Z","repository":{"id":46163375,"uuid":"1008318","full_name":"TwilightCoders/rubysu","owner":"TwilightCoders","description":"Give Ruby objects superuser privileges","archived":false,"fork":false,"pushed_at":"2023-07-10T21:55:56.000Z","size":62,"stargazers_count":15,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-19T11:21:25.502Z","etag":null,"topics":["gems","ruby","ruby-sudo","sudo","system"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/sudo/","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TwilightCoders.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-10-20T06:54:15.000Z","updated_at":"2024-06-02T02:27:37.000Z","dependencies_parsed_at":"2024-06-21T17:33:43.827Z","dependency_job_id":"42f33eec-9799-4e65-a109-e3d8e5d702c7","html_url":"https://github.com/TwilightCoders/rubysu","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwilightCoders%2Frubysu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwilightCoders%2Frubysu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwilightCoders%2Frubysu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TwilightCoders%2Frubysu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TwilightCoders","download_url":"https://codeload.github.com/TwilightCoders/rubysu/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252299432,"owners_count":21725716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gems","ruby","ruby-sudo","sudo","system"],"created_at":"2024-11-13T04:19:41.843Z","updated_at":"2025-05-04T06:33:21.962Z","avatar_url":"https://github.com/TwilightCoders.png","language":"Ruby","readme":"[![Gem Version](https://badge.fury.io/rb/sudo.svg)](https://badge.fury.io/rb/sudo)[![Build Status](https://travis-ci.com/gderosa/rubysu.svg?branch=master)](https://travis-ci.com/gderosa/rubysu)\n[![Maintainability](https://api.codeclimate.com/v1/badges/3fdebfb836bebb531fb3/maintainability)](https://codeclimate.com/github/gderosa/rubysu/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/3fdebfb836bebb531fb3/test_coverage)](https://codeclimate.com/github/gderosa/rubysu/test_coverage)\n\n# Ruby Sudo\n\nGive Ruby objects superuser privileges.\n\nBased on [dRuby](http://ruby-doc.org/stdlib-2.5.3/libdoc/drb/rdoc/DRb.html) and [sudo](http://www.sudo.ws/).\n\nOnly tested with [MRI](http://en.wikipedia.org/wiki/Ruby_MRI).\n\n## Usage\n\nYour user must be allowed, in `/etc/sudoers`, to run `ruby` and `kill`\ncommands as root.\n\nA password may be required from the console, depending on the\n`NOPASSWD` options in `/etc/sudoers`.\n\nSpawns a sudo-ed Ruby process running a\n[DRb](http://ruby-doc.org/stdlib-2.5.3/libdoc/drb/rdoc/DRb.html) server. Communication is\ndone via a Unix socket (and, of course, permissions are set to `0600`).\n\nNo long-running daemons involved, everything is created on demand.\n\nAccess control is entirely delegated to `sudo`.\n\n### Application Code\n\nLet's start with a trivial example:\n\n```ruby\nrequire 'my_gem/my_class'\nrequire 'sudo'\n\nobj   = MyGem::MyClass.new\n\n# Now, create a Sudo::Wrapper object:\nsudo  = Sudo::Wrapper.new\n\n# 'mygem/myclass' will be automatically required in the\n# sudo DRb server\n\n# Start the sudo-ed Ruby process:\nsudo.start!\nsudo[obj].my_instance_method\nsudo[MyClass].my_class_method\n\n# Call stop! when finished, otherwise, that will be done\n# when the `sudo` object gets garbage-collected.\nsudo.stop!\n```\n\nA convienient utility for working with sudo is to use the `run` method and pass it a block.\nRun will automatically start and stop the ruby sudo process around the block.\n\n```ruby\nrequire 'fileutils'\nrequire 'sudo'\n\nSudo::Wrapper.run do |sudo|\n  sudo[FileUtils].mkdir_p '/ONLY/ROOT/CAN/DO/THAT'\nend\n# Sockets and processes are closed automatically when the block exits\n```\n\nBoth `Sudo::Wrapper.run` and `Sudo::Wrapper.new` take the same named arguments: `ruby_opts` (default: `''` ) and `load_gems` (default: `true`).\n\nIf you'd like to pass options to the sudo-spawned ruby process, pass them as a string to `ruby_opts`.\n\nIf you'd like to prevent the loading of `gems` currently loaded from the calling program, pass `false` to `load_gems`. This will give your sudo process a unmodifed environment. The only things required via the sudo process are `'drb/drb'`, `'fileutils'`, and of course `'sudo'`.\n\n## Todo\n\n`sudo` has a `-A` option to accept password via an external program (maybe\ngraphical): support this feature.\n\n## Credits\n\n### Author and Copyright\n\nGuido De Rosa ([@gderosa](http://github.com/gderosa/)).\n\nSee LICENSE.\n\n### Contributors\n\nDale Stevens ([@voltechs](https://github.com/voltechs))\n\nRobert M. Koch ([@threadmetal](https://github.com/threadmetal))\n\nWolfgang Teuber ([@wteuber](https://github.com/wteuber))\n\n### Other aknowledgements\nThanks to Tony Arcieri and Brian Candler for suggestions on \n[ruby-talk](http://www.ruby-forum.com/topic/262655).\n\nInitially developed by G. D. while working at [@vemarsas](https://github.com/vemarsas).\n\n## Contributing\n\n1. Fork it ( https://github.com/gderosa/rubysu/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwilightcoders%2Frubysu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwilightcoders%2Frubysu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwilightcoders%2Frubysu/lists"}