<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ronin coder &#187; unix</title>
	<atom:link href="http://rcoder.net/content/tag/unix/feed" rel="self" type="application/rss+xml" />
	<link>http://rcoder.net</link>
	<description>Code, food, pinball, beer, and bikes. It&#039;s hard living in a place this awesome.</description>
	<lastBuildDate>Mon, 26 Jul 2010 20:30:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Granting just enough power, but no more</title>
		<link>http://rcoder.net/content/granting-just-enough-power-but-no-more</link>
		<comments>http://rcoder.net/content/granting-just-enough-power-but-no-more#comments</comments>
		<pubDate>Thu, 13 Nov 2008 00:32:17 +0000</pubDate>
		<dc:creator>lennon</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://rcoder.net/?p=308</guid>
		<description><![CDATA[Sometimes you have a group of users who need to run certain commands on a server, and no others. It&#8217;s not necessarily that you don&#8217;t trust them. The point is simply that they don&#8217;t need a full-blown shell account, and you&#8217;re understandably reluctant to give it to them.
There are countless ways to set up a [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you have a group of users who need to run certain commands on a server, and no others. It&#8217;s not necessarily that you don&#8217;t trust them. The point is simply that they don&#8217;t <em>need</em> a full-blown shell account, and you&#8217;re understandably reluctant to give it to them.</p>
<p>There are countless ways to set up a restricted account that can use only certain commands, but most of them are either extremely special-purpose, or rather difficult to set up. (Locking down SSH sessions inside a chroot jail, for example, requires almost as work as just setting up a dedicated virtual machine for your untrusted users.)</p>
<p>Furthermore, none of the existing solutions were written by me, to address exactly the needs I have for such a &#8220;sandbox&#8221; environment. Most notably, I don&#8217;t want users to even have to remember which commands are available to them. In many cases, they may only be using these tools every few months, and remembering cryptic UNIX-y command paths and syntax is hard enough even when you use something every day.</p>
<p>And so, I give you <a href="http://github.com/rcoder/menush/tree/master">menush</a>, a simple shell replacement which presents users with a list of available commands from which the user may choose. It loops until the user exits via the menu (or uses Ctrl-C/Ctrl-D to end the session).</p>
<p>To set it up on your own server, you&#8217;ll need to copy the file into a known location (say, <code>/usr/local/sbin</code>), then add a line to your <code>/etc/shells</code> file pointing to it. For each user you want to lock into a sandbox, edit their password entry using <code>vipw</code> (or your <code>passwd</code> editing method of choice) and change the last field from <code>/bin/bash</code> or similar to the full path to <code>menush</code>.</p>
<p>Then, create the directory <code>/etc/menush</code>, and write your default menu file (<code>/etc/menush/__default__</code>). On startup, <code>menush</code> will look in that directory for a file with the same name as the user being logged in; if that file is absent, the default will be loaded instead. The format for the menu files is documented in the README, but it&#8217;s just a YAML file. (Also, bonus points for the first person to correctly identify the gaping security hole in the provided example.)</p>
<p>The code is written in a fairly portable, POSIX-y style, so it should work on Linux, BSD, or OS X. Feel free to send me suggestions, pull requests, or rants about the horrible security holes I left because I banged this whole thing out in like two hours and then spent a bunch of time blogging about it instead of reviewing my own code.</p>
]]></content:encoded>
			<wfw:commentRss>http://rcoder.net/content/granting-just-enough-power-but-no-more/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
