<?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>My Galagzee! &#187; bcron</title>
	<atom:link href="http://my.galagzee.com/tag/bcron/feed/" rel="self" type="application/rss+xml" />
	<link>http://my.galagzee.com</link>
	<description>Tech in a Galagzee, Not So Far Away.</description>
	<lastBuildDate>Wed, 28 Jul 2010 17:09:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Installing bcron on FreeBSD 7.0</title>
		<link>http://my.galagzee.com/2008/06/30/installing-bcron-on-freebsd-70/</link>
		<comments>http://my.galagzee.com/2008/06/30/installing-bcron-on-freebsd-70/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 23:42:46 +0000</pubDate>
		<dc:creator>Ville Walveranta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[bcron]]></category>
		<category><![CDATA[freebsd]]></category>
		<category><![CDATA[install]]></category>

		<guid isPermaLink="false">http://my.galagzee.com/?p=77</guid>
		<description><![CDATA[bcron is a better cron (though the &#8220;b&#8221; in the name probably comes from the first name of its writer, Bruce Guenter).  It was created with security in mind, and is especially well suited for multi-user systems where the individual users need to be given access to their respective crontabs. With bcron this can be]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.untroubled.org/bcron/" target="_blank">bcron</a> is a better cron (though the &#8220;b&#8221; in the name probably comes from the first name of its writer, Bruce Guenter).  It was created with security in mind, and is especially well suited for multi-user systems where the individual users need to be given access to their respective crontabs. With bcron this can be accomplished without compromising the system security.  Here&#8217;s a quote from the bcron page:</p>
<blockquote><p>This is bcron, a new cron system designed with secure operations in mind.  To do this, the system is divided into several seperate programs, each responsible for a seperate task, with strictly controlled communications between them.  The user interface is a drop-in replacement for similar systems (such as vixie-cron), but the internals differ greatly.</p></blockquote>
<p>As of writing of this bcron can not be found in the FreeBSD 7.0 ports system. Fortunately its installation is fairly straightforward.  Yet the included documentation is rather spartan so I provide a more complete outline below.</p>
<ol>
<li><strong>Install latest bglibs if not yet installed</strong>** bglibs is best to install from a <a href="http://www.untroubled.org/bglibs/" target="_blank">downloaded tarball</a> rather than from the ports (while the ports version installs the libs in a more logical location at /usr/local/lib/bglibs/ the programs that utilize the library (bcron, ucspi-unix, etc.) have difficulty locating it.
<p>** few symlinks are required (these refer to the locations bglibs installs itself when compiled from the tarball rather than from the ports):</p>
<p>/usr/local/bglibs -&gt; /usr/local/lib/bglibs<br />
/usr/local/bglibs/lib/libbg-sysdeps.so.2 -&gt; /usr/local/lib/libbg-sysdeps.so.2<br />
/usr/local/bglibs/lib/libbg.so.2 -&gt; /usr/local/lib/libbg.so.2</li>
<li><strong>Install </strong><strong>ucspi-unix if not yet installed </strong>as bcron components communicate via UNIX sockets.<strong> </strong>This requires bglibs and also compiles and installs well using a <a href="http://www.untroubled.org/ucspi-unix/" target="_blank">downloaded tarball</a> (it&#8217;s also available in ports at /usr/ports/sysutils/ucspi-unix, but I prefer to compile it from the downloaded tarball).</li>
<li><strong>Make sure /var has been moved off the root to /usr/var</strong> before proceeding. See an <a href="http://my.galagzee.com/index.php/2008/06/28/moving-var-tmp-off-the-root-in-freebsd/" target="_self">older post</a> for details.</li>
<li><strong>Make sure <a href="http://my.galagzee.com/index.php/2008/06/30/installing-daemontools-service-supervisor-on-freebsd-70/" target="_self">daemontools (and hence supervise) has been installed</a></strong> and is operational as bcron will be started with it.</li>
<li><strong>Create a system user &#8220;cron&#8221; </strong>(for example by using <strong>vipw</strong> command) <strong>and group &#8220;cron&#8221; </strong>(by editing /etc/group). This user/group will own all the crontab files (though not /etc/crontab as it&#8217;s system crontab and needs to be owned by root:wheel).<em> </em><em> </em><em> </em><br />
<em><br />
user:</em><br />
cron:*:50:50::0:0:BCron Sandbox:/nonexistent:/usr/sbin/nologin</p>
<p><em>group:</em><br />
cron:*:50:</li>
<li><strong>Create the spool &amp; tmp directories: </strong><br />
mkdir -p /var/spool/cron/crontabs /var/spool/cron/tmp<br />
mkfifo /var/spool/cron/trigger<br />
sh<br />
for i in crontabs tmp trigger; do<br />
chown cron:cron /var/spool/cron/$i<br />
chmod go-rwx /var/spool/cron/$i<br />
done</li>
<li><strong>Create the configuration directory /usr/local/etc/bcron:</strong>mkdir -p /usr/local/etc/bcron** You can put any common configuration settings into this directory (it is an &#8220;ENVDIR&#8221;), like alternate spool directories in BCRON_SPOOL.</li>
<li><strong>Create the bcron service directories (there are three services) and add the scripts below it:
<p></strong>mkdir -p /var/bcron/supervise/bcron-sched/log<br />
mkdir /var/bcron/supervise/bcron-spool<br />
mkdir /var/bcron/supervise/bcron-update</p>
<p>Set their permissions to 1750 for security purposes (no world access, sticky bit):</p>
<p>chmod 1750 /var/bcron/supervise/bcron-sched<br />
chmod 1750 /var/bcron/supervise/bcron-spool<br />
chmod 1750 /var/bcron/supervise/bcron-update</p>
<p>Make all the run and log/run scripts executable by root, readable by group:</p>
<p>chmod 740 /var/bcron/supervise/bcron-sched/run<br />
chmod 740 /var/bcron/supervise/bcron-sched/log/run<br />
chmod 740 /var/bcron/supervise/bcron-spool/run<br />
chmod 740 /var/bcron/supervise/bcron-update/run</p>
<p>and make log bcron-sched subdir accessible by root, group:</p>
<p>chmod 750 /var/bcron/supervise/bcron-sched/log</p>
<p><strong>RUN SCRIPTS:</strong><br />
<span style="text-decoration: underline;"><em>/var/bcron/supervise/bcron-sched/run:</em></span></p>
<p>#!/bin/sh<br />
exec 2&gt;&amp;1<br />
exec envdir /usr/local/etc/bcron bcron-start | multilog t /var/log/bcron</p>
<p><span style="text-decoration: underline;"><em>/var/bcron/supervise/bcron-sched/log/run:</em></span></p>
<p>#!/bin/sh<br />
exec &gt;/dev/null 2&gt;&amp;1<br />
exec \<br />
multilog t /var/log/bcron</p>
<p><span style="text-decoration: underline;"><em>/var/bcron/supervise/bcron-spool/run:</em></span></p>
<p>#!/bin/sh<br />
exec &gt;/dev/null 2&gt;&amp;1<br />
exec \<br />
envdir /usr/local/etc/bcron \<br />
envuidgid cron \<br />
sh -c &#8216;<br />
exec \<br />
unixserver -U ${BCRON_SOCKET:-/var/run/bcron-spool} \<br />
bcron-spool<br />
&#8216;</p>
<p><span style="text-decoration: underline;"><em>/var/bcron/supervise/bcron-update/run:</em></span></p>
<p>#!/bin/sh<br />
exec &gt;/dev/null 2&gt;&amp;1<br />
exec \<br />
bcron-update /etc/crontab</li>
<li><strong>Kill the deafult cron daemon and add the following to rc.conf so it won&#8217;t restart on reboot:</strong>
<p>#disable default cron; bcron is used instead (started by supervise)<br />
cron_enable=&#8221;NO&#8221;</li>
<li><strong>Symlink bcron services&#8217; primary supervise directories to under /var/service to start bcron services (you can also use svc-add command if you have installed supervise-scripts):</strong><br />
ln -s /var/bcron/supervise/bcron-sched /var/service/bcron-sched<br />
ln -s /var/bcron/supervise/bcron-spool /var/service/bcron-spool<br />
ln -s /var/bcron/supervise/bcron-update /var/service/bcron-update</li>
<li><strong>Set /etc/crontab permissions to 600, and make sure it&#8217;s owned by the root.</strong><br />
chmod 600 /etc/crontab<br />
chown root:wheel /etc/crontab</p>
<p>** For other users the owner of the crontab file in their respective home folders would be <strong>cron:cron</strong>.</li>
<li><strong>Edit /etc/crontab and test that it gets updated</strong>. Note that there is a brief delay, perhaps one minute or so, after you save the crontab until the change becomes effective. Also note that the default shell for the crontab is /bin/sh. You might want to change it to something more powerful like c-shell (/bin/csh) or bash (/bin/bash) that you&#8217;re familiar with. You may also want to augment the default path, for example, by including /usr/local/bin for user-installed commands.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://my.galagzee.com/2008/06/30/installing-bcron-on-freebsd-70/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
