Index: head/en_US.ISO8859-1/articles/problem-reports/article.sgml
===================================================================
--- head/en_US.ISO8859-1/articles/problem-reports/article.sgml (revision 29515)
+++ head/en_US.ISO8859-1/articles/problem-reports/article.sgml (revision 29516)
@@ -1,1113 +1,1113 @@
%articles.ent;
]>
Writing &os; Problem Reports$FreeBSD$
&tm-attrib.freebsd;
&tm-attrib.cvsup;
&tm-attrib.ibm;
&tm-attrib.intel;
&tm-attrib.sparc;
&tm-attrib.sun;
&tm-attrib.general;
This article describes how to best formulate and submit a
problem report to the &os; Project.Dag-ErlingSmørgravContributed by MarkLinimonproblem reportsIntroductionOne of the most frustrating experiences one can have as a
software user is to submit a problem report only to have it
summarily closed with a terse and unhelpful explanation like
not a bug or bogus PR. Similarly,
one of the most frustrating experiences as a software developer
is to be flooded with problem reports that are not really
problem reports but requests for support, or that contain little
or no information about what the problem is and how to reproduce
it.This document attempts to describe how to write good problem
reports. What, you ask, is a good problem report? Well, to go
straight to the bottom line, a good problem report is one that
can be analyzed and dealt with swiftly, to the mutual
satisfaction of both user and developer.Although the primary focus of this article is on &os;
problem reports, most of it should apply quite well to other
software projects.Note that this article is organized thematically, not
chronologically, so you should read through the entire document
before submitting a problem report, rather than treat it as a
step-by-step tutorial.When to submit a problem reportThere are many types of problems, and not all of them should
engender a problem report. Of course, nobody is perfect, and
there will be times when you are convinced you have found a bug
in a program when in fact you have misunderstood the syntax for
a command or made a typographical error in a configuration file
(though that in
itself may sometimes be indicative of poor documentation or poor
error handling in the application). There are still many cases
where submitting a problem report is clearly
not the right
course of action, and will only serve to frustrate you and the
developers. Conversely, there are cases where it might be
appropriate to submit a problem report about something else than
a bug—an enhancement or a feature request, for
instance.So how do you determine what is a bug and what is not? As a
simple rule of thumb your problem is not a
bug if it can be expressed as a question (usually of the form
How do I do X? or Where can I find
Y?). It is not always quite so black and white, but the
question rule covers a large majority of cases. If you are looking
for an answer, consider posing your question to the
&a.questions;.Some cases where it may be appropriate to submit a problem
report about something that is not a bug are:Requests for feature enhancements. It is generally a
good idea to air these on the mailing lists before
submitting a problem report.Notification of updates to externally maintained
software (mainly ports, but also externally maintained base
system components such as BIND or various GNU
utilities).For unmaintained ports (MAINTAINER contains
ports@FreeBSD.org), such update notifications
might get picked up by an interested
committer, or you might be asked to provide a patch to update
the port; providing it upfront will greatly improve your chances
that the port will get updated in a timely manner.If the port is maintained, PRs announcing new upstream releases
are usually not very useful since they generate supplementary work
for the committers, and the maintainer likely knows already there is
a new version, they have probably worked with the developers on it,
they are probably testing to see there is no regression, etc.In either case, following the process described in Porter's
Handbook will yield the best results.A bug that can not be reproduced can rarely be
fixed. If the bug only occurred once and you can not reproduce
it, and it does not seem to happen to anybody else, chances are
none of the developers will be able to reproduce it or figure
out what is wrong. That does not mean it did not happen, but it
does mean that the chances of your problem report ever leading
to a bug fix are very slim. To make matters worse, often
these kinds of bugs are actually caused by failing hard drives
or overheating processors — you should always try to rule
out these causes, whenever possible, before submitting a PR.Next, to decide to whom you should file your problem
report, you need to understand that the software that makes
up &os; is composed of several different elements:Code in the base system that is written and maintained
by &os; contributors, such as the kernel, the C library,
and the device drivers (categorized as kern);
the binary utilities (bin); the manual
pages and documentation (docs); and
the web pages (www). All bugs in
these areas should be reported to the &os; developers.Code in the base system that is written and maintained
by others, and imported into &os; and adapted. Examples
include bind, &man.gcc.1;, and
&man.sendmail.8;. Most bugs in these areas should be reported
to the &os; developers; but in some cases they may need to be
reported to the original authors instead if the problems are
not &os;-specific. Usually these bugs will fall under either
the bin or gnu
categories.Individual applications that are not in the base system
but are instead part of the &os; Ports Collection (category
ports). Most of these applications are
not written by &os; developers; what &os; provides is merely
a framework for installing the application. Therefore, you
should only report a problem to the &os; developers when you
believe the problem is &os;-specific; otherwise, you should
report it to the authors of the software.Then you should ascertain whether or not the problem is
timely. There are few things
that will annoy a developer more than receiving a problem report
about a bug she has already fixed.If the problem is in the base system, you should first read
the FAQ section on
&os; versions, if you are not already familiar with
the topic. It is not possible for &os; to fix problems in
anything other than certain recent branches of the base system,
so filing a bug report about an older version will probably
only result in a developer advising you to upgrade to a
supported version to see if the problem still recurs. The
Security Officer team maintains the
list of supported
versions.If the problem is in a port, note that you must first
upgrade to the latest version of the Ports Collection and see
if the problem still applies. Due to the rapid pace of changes
in these applications, it is infeasible for &os; to support
anything other than the absolute latest versions, and problems
with older version of applications simply cannot be fixed.PreparationsA good rule to follow is to always do a background search
before submitting a problem report. Maybe your problem has
already been reported; maybe it is being discussed on the
mailing lists, or recently was; it may even already be fixed in
a newer version than what you are running. You should therefore
check all the obvious places before submitting your problem
report. For &os;, this means:The &os;
Frequently Asked
Questions (FAQ) list.
The FAQ attempts to provide answers for a wide range of questions,
such as those concerning
hardware
compatibility,
user
applications,
and kernel
configuration.The
mailing
lists—if you are not subscribed, use
the
searchable archives on the &os; web site. If your
problem has not been discussed on the lists, you might try
posting a message about it and waiting a few days to see if
someone can spot something you have overlooked.Optionally, the entire web—use your favorite
search engine to locate any references to your problem. You
may even get hits from archived mailing lists or newsgroups
you did not know of or had not thought to search
through.Next, the searchable
&os; PR database (GNATS). Unless your problem
is recent or obscure, there is a fair chance it has already
been reported.Most importantly, you should attempt to see if existing
documentation in the source base addresses your problem.For the base &os; code, you should
carefully study the contents of the
/usr/src/UPDATING file on your system
or its latest version at
.
(This is vital information
if you are upgrading from one version to
another—especially if you are upgrading to the
&os.current; branch).However, if the problem is in something that was installed
as a part of the &os; Ports Collection, you should refer to
/usr/ports/UPDATING (for individual ports)
or /usr/ports/CHANGES (for changes
that affect the entire Ports Collection).
and
are also available via CVSweb.Writing the problem reportNow that you have decided that your issue merits a problem
report, and that it is a &os; problem, it is time to write
the actual problem report. Before we get into the mechanics
of the program used to generate and submit PRs, here are some
tips and tricks to help make sure that your PR will be most
effective.Tips and tricks for writing a good problem reportDo not leave the Synopsis
line empty. The PRs go both onto a mailing list
that goes all over the world (where the Synopsis
is used
for the Subject: line), but also into a
database. Anyone who comes along later and browses the
database by synopsis, and finds a PR with a blank subject
line, tends just to skip over it. Remember that PRs stay
in this database until they are closed by someone; an
anonymous one will usually just disappear in the
noise.Avoid using a weak Synopsis
line. You should not assume that anyone reading
your PR has any context for your submission, so the more
you provide, the better. For instance, what part of the
system does the problem apply to? Do you only see the
problem while installing, or while running? To
illustrate, instead of Synopsis: portupgrade is
broken, see how much more informative this
- seems: Synopsis: port sysutils/portupgrade
+ seems: Synopsis: port ports-mgmt/portupgrade
coredumps on -current. (In the case of ports,
it is especially helpful to have both the category and
portname in the Synopsis line.)If you have a patch, say so.
A PR with a patch included is much more likely to be
looked at than one without. If you are including one,
put the string [patch] at the
beginning of the Synopsis. (Although it is
not mandatory to use that exact string, by convention,
that is the one that is used.)If you are a maintainer, say so.
If you are maintaining a part of the source code (for
instance, a port), you might consider adding the string
[maintainer update] at the beginning of
your synopsis line, and you definitely should set the
Class of
your PR to maintainer-update. This way
any committer that handles your PR will not have to check.Be specific.
The more information you supply about what problem you
are having, the better your chance of getting a response.Include the version of &os; you are running (there
is a place to put that, see below) and on which architecture.
You should include whether you are running from a release
(e.g. from a CDROM or download), or from
a system maintained by &man.cvsup.1; (and, if so, how
recently you updated). If you are tracking the
&os.current; branch, that is the very first thing someone
will ask, because fixes (especially for high-profile
problems) tend to get committed very quickly, and
&os.current; users are expected to keep up.Include which global options you have specified in
your make.conf. Note: specifying
-O2 and above to &man.gcc.1; is
known to be buggy in many situations. While the
&os; developers will accept patches, they are
generally unwilling to investigate such issues due
to simple lack of time and volunteers, and may
instead respond that this just is not supported.If this is a kernel problem, then be prepared to
supply the following information. (You do not
have to include these by default, which only tends to
fill up the database, but you should include excerpts
that you think might be relevant):your kernel configuration (including which
hardware devices you have installed)whether or not you have debugging options enabled
(such as WITNESS), and if so,
whether the problem persists when you change the
sense of that optiona backtrace, if one was generatedthe fact that you have read
src/UPDATING and that your problem
is not listed there (someone is guaranteed to ask)whether or not you can run any other kernel as
a fallback (this is to rule out hardware-related
issues such as failing disks and overheating CPUs,
which can masquerade as kernel problems)If this is a ports problem, then be prepared to
supply the following information. (You do not
have to include these by default, which only tends to
fill up the database, but you should include excerpts
that you think might be relevant):which ports you have installedany environment variables that override the
defaults in bsd.port.mk, such
as PORTSDIRthe fact that you have read
ports/UPDATING and that your problem
is not listed there (someone is guaranteed to ask)Avoid vague requests for features.
PRs of the form someone should really implement something
that does so-and-so are less likely to get results than
very specific requests. Remember, the source is available
to everyone, so if you want a feature, the best way to
ensure it being included is to get to work! Also consider
the fact that many things like this would make a better
topic for discussion on freebsd-questions
than an entry in the PR database, as discussed above.Make sure no one else has already submitted
a similar PR. Although this has already been
mentioned above, it bears repeating here. It only take a
minute or two to use the web-based search engine at
.
(Of course, everyone is guilty of forgetting to do this
now and then.)Avoid controversial requests.
If your PR addresses an area that has been controversial
in the past, you should probably be prepared to not only
offer patches, but also justification for why the patches
are The Right Thing To Do. As noted above,
a careful search of the mailing lists using the archives
at
is always good preparation.Be polite.
Almost anyone who would potentially work on your PR is a
volunteer. No one likes to be told that they have to do
something when they are already doing it for some
motivation other than monetary gain. This is a good thing
to keep in mind at all times on Open Source
projects.Before you beginIf you are using the &man.send-pr.1; program, make sure your
VISUAL (or EDITOR if
VISUAL is not set) environment variable is set
to something sensible.You should also make sure that mail delivery works fine.
&man.send-pr.1; uses mail messages for the submission and
tracking of problem reports. If you cannot post mail messages
from the machine you are running &man.send-pr.1; on, your
problem report will not reach the GNATS database. For details
on the setup of mail on &os;, see the Electronic
Mail chapter of the &os; Handbook at
.Make sure that your mailer will not mangle the message on
its way to GNATS. In particular, if your mailer automatically
breaks lines, changes tabs to spaces, or escapes newline
characters, any patch that you submit will be rendered
unusable. For the text sections, however, we request that
you insert manual linebreaks somewhere around 70 characters,
so that the web display of the PR will be readable.Similar considerations apply if you are using the web-based
PR submittal form instead of &man.send-pr.1;. Note that
cut-and-paste operations can have their own side-effects on
text formatting. In certain cases it may be necessary to use
&man.uuencode.1; to ensure that patches arrive unmodified.Finally, if your submission will be lengthy, you should
to prepare your work offline so that nothing will be lost in
case there is a problem submitting it. This can be an especial
problem with the web form.Attaching patches or filesThe following applies to submitting PRs via email:The &man.send-pr.1; program has provisions for attaching
files to a problem report. You can attach as many files as
you want provided that each has a unique base name (i.e. the
name of the file proper, without the path). Just use the
command-line option to specify the names
of the files you wish to attach:&prompt.user; send-pr -a /var/run/dmesg -a /tmp/errorsDo not worry about binary files, they will be automatically
encoded so as not to upset your mail agent.If you attach a patch, make sure you use the
or option to
&man.diff.1; to create a context or unified diff (unified is
preferred), and make
sure to specify the exact CVS revision numbers of the files
you modified so the developers who read your report will be
able to apply them easily. For problems with the kernel or the
base utilities, a patch against &os.current; (the HEAD
CVS branch) is preferred since all new code should be applied
and tested there first. After appropriate or substantial testing
has been done, the code will be merged/migrated to the &os.stable;
branch.If you attach a patch inline, instead of as an attachment,
note that the most common problem by far is the tendency of some
email programs to render tabs as spaces, which will completely
ruin anything intended to be part of a Makefile.Do not send patches as attachments using
Content-Transfer-Encoding: quoted-printable.
These will perform character escaping and the entire patch
will be useless.Also note that while including small patches in a PR is
generally all right—particularly when they fix the problem
described in the PR—large patches and especially new code
which may require substantial review before committing should
be placed on a web or ftp server, and the URL should be
included in the PR instead of the patch. Patches in email
tend to get mangled, especially when GNATS is involved, and
the larger the patch, the harder it will be for interested
parties to unmangle it. Also, posting a patch on the web
allows you to modify it without having to resubmit the entire
patch in a followup to the original PR. Finally, large
patches simply increase the size of the database, since
closed PRs are not actually deleted but instead kept and
simply marked as closed.You should also take note that unless you explicitly
specify otherwise in your PR or in the patch itself, any
patches you submit will be assumed to be licensed under the
same terms as the original file you modified.Filling out the templateThe next section applies to the email method only:When you run &man.send-pr.1;, you are presented with a
template. The template consists of a list of fields, some of
which are pre-filled, and some of which have comments explaining
their purpose or listing acceptable values. Do not worry
about the comments; they will be removed automatically if you
do not modify them or remove them yourself.At the top of the template, below the
SEND-PR: lines, are the email headers. You
do not normally need to modify these, unless you are sending
the problem report from a machine or account that can send but
not receive mail, in which case you will want to set the
From: and Reply-To: to
your real email address. You may also want to send yourself
(or someone else) a carbon copy of the problem report by
adding one or more email addresses to the
Cc: header.In the email template you will find the following two
single-line fields:Submitter-Id: Do not change this.
The default value of current-users is
correct, even if you run &os.stable;.Confidential: This is prefilled
to no. Changing it makes no sense as
there is no such thing as a confidential &os; problem
report—the PR database is distributed worldwide by
CVSup.The next section describes fields that are common to both
the email interface and the web interface:Originator:
Please specify your real name, optionally followed
by your email address in angle brackets.
In the email interface, this is normally
prefilled with the gecos field of the
currently logged-in
user.The email address you use will become public information
and may become available to spammers. You should either
have spam handling procedures in place, or use a temporary
email account. However, please note that if you do not
use a valid email account at all, we will not be able to
ask you questions about your PR.Organization: Whatever you feel
like. This field is not used for anything
significant.Synopsis: Fill this out with a
short and accurate description of the problem. The
synopsis is used as the subject of the problem report
email, and is used in problem report listings and
summaries; problem reports with obscure synopses tend to
get ignored.As noted above, if your problem report includes a patch,
please have the synopsis start with [patch];
if this is a ports PR and you are the
maintainer, you may consider adding
[maintainer update] and set the
Class of your PR to
maintainer-update.Severity: One of
non-critical,
serious or
critical. Do not overreact; refrain
from labeling your problem critical
unless it really is (e.g. data corruption issues, serious
regression from previous functionality in -CURRENT)
or serious unless
it is something that will affect many users (kernel
panics or freezes; problems with
particular device drivers or system utilities). &os;
developers will not necessarily work on your problem faster
if you inflate its importance since there are so many other
people who have done exactly that — in fact, some
developers pay little attention to this field
because of this.Major security problems should not
be filed in GNATS, because all GNATS information is public
knowledge. Please send such problems in private email to
&a.security-officer;.Priority: One of
low, medium or
high. high should
be reserved for problems that will affect practically
every user of &os; and medium for
something that will affect many users.This field has become so widely abused that it is
almost completely meaningless.Category: Choose an appropriate
category.There are a number of "platform" categories into which
bugs in the base system that are specific to one particular
hardware architecture should be filed. Problems that are
generic all across versions of &os; should probably be
filed as kern or bin;
see discussion of those categories below.Example: you have a common PC-based machine, and think
you have encountered a problem specific to a particular
chipset or a particular motherboard: i386
is the right category.Example: You are having a problem with an add-in
peripheral card on a commonly seen bus, or a problem with
a particular type of hard disk drive: in this case, it
probably applies to more than one architecture, and
kern is the right category.Here is the current list of categories (taken from
):advocacy: problems relating to
&os;'s public image. Rarely used.alpha: problems specific to the
Alpha platform.amd64: problems specific to the
AMD64 platform.bin: problems with userland
programs in the base system. If running &man.whereis.1;
shows /bin, /usr/sbin,
or something similar, then this is probably the right
category. (A few contributed programs might instead
need to be in gnu; see below.)conf: problems with
configuration files, default values, and so forth.
Things that affect /usr/share
or /etc/rc* belong here.docs: problems with manual pages
or on-line documentation.gnu: problems with imported GNU software
such as &man.gcc.1; or &man.grep.1;.i386: problems specific to the
&i386; platform.ia64: problems specific to the
ia64 platform.java: problems related to the &java;
Virtual Machine. (Ports that merely depend on &java; to
run should be filed under ports.)
kern: problems with
the kernel, (non-platform-specific) device drivers,
or the base libraries.misc: anything that does not fit
in any of the other categories. (Note that there is
almost nothing that truly belongs in this category,
except for problems with the release and build
infrastructure. Temporary build failures on
HEAD do not belong here. Also note
that it is
easy for things to get lost in this category).ports: problems relating to the
ports tree.powerpc: problems specific to the
&powerpc; platform.sparc64: problems specific to the
&sparc64; platform.standards: Standards conformance
issues.threads: problems related to the
&os; threads implementation (especially on &os.current;).usb: problems related to the
&os; USB implementation.www: Changes or enhancements to
the &os; website.
Problems with code found in /usr/ports/www
do not belong here, they belong in
ports instead.Class: Choose one of the
following:sw-bug: software bugs.doc-bug: errors in
documentation.change-request: requests for
additional features or changes in existing
features.update: updates to ports or
other contributed software.maintainer-update: updates to
ports for which you are the maintainer.Release: The version of &os;
that you are running. This is filled out automatically if
you are using
&man.send-pr.1; and need only be changed if you are
sending a problem report from a different system than the
one that exhibits the problem.Finally, there is a series of multi-line fields:Environment: This should
describe, as accurately as possible, the environment in
which the problem has been observed. This includes the
operating system version, the version of the specific
program or file that contains the problem, and any other
relevant items such as system configuration, other
installed software that influences the problem,
etc.—quite simply everything a developer needs to
know to reconstruct the environment in which the problem
occurs.Description: A complete and
accurate description of the problem you are experiencing.
Try to avoid speculating about the causes of the problem
unless you are certain that you are on the right track, as
it may mislead a developer into making incorrect
assumptions about the problem.How-To-Repeat: A summary of the
actions you need to take to reproduce the problem.Fix: Preferably a patch, or at
least a workaround (which not only helps other people with
the same problem work around it, but may also help a
developer understand the cause for the problem), but if
you do not have any firm ideas for either, it is better to
leave this field blank than to speculate.Sending off the problem reportIf you are using &man.send-pr.1;:Once you are done filling out the template, have saved it,
and exit your editor, &man.send-pr.1; will prompt you with
s)end, e)dit or a)bort?. You can then hit
s to go ahead and submit the problem report,
e to restart the editor and make
further modifications, or a to abort.
If you choose the latter, your problem report will remain on
disk (&man.send-pr.1; will tell you the filename before it
terminates), so you can edit it at your leisure, or maybe
transfer it to a system with better net connectivity, before
sending it with the to
&man.send-pr.1;:&prompt.user; send-pr -f ~/my-problem-reportThis will read the specified file, validate the contents,
strip comments and send it off.If you are using the web form:Before you hit submit, you will need to
fill in a field containing text that is represented in image
form on the page. This unfortunate measure has had to be
adopted due to misuse by automated systems and a few misguided
individuals. It is a necessary evil that no one likes; please
do not ask us to remove it.Note that you are strongly advised to
save your work somewhere before hitting submit.
A common problem for users is to have their web browser displaying
a stale image from its cache. If this happens to you, your
submission will be rejected and you may lose your work.If you are unable to view images for any reason, and are also
unable to use &man.send-pr.1;, please accept our apologies for
the inconvenience and email your problem report to the bugbuster
team at freebsd-bugbusters@FreeBSD.org.Follow-upOnce your problem report has been filed, you will receive a
confirmation by email which will include the tracking number
that was assigned to your problem report and a URL you can use
to check its status. With a little luck, someone will take an
interest in your problem and try to address it, or, as the case
may be, explain why it is not a problem. You will be
automatically notified of any change of status, and you will
receive copies of any comments or patches someone may attach to
your problem report's audit trail.If someone requests additional information from you, or you
remember or discover something you did not mention in the
initial report, please use one of two methods to submit your
followup:The easiest way is to use the followup link on
the individual PR's web page, which you can reach from the
PR search page. Clicking on this link will bring up an
an email window with the correct To: and Subject: lines filled in
(if your browser is configured to do this).Alternatively, you can just mail it to
&a.bugfollowup;, making sure that the
tracking number is included in the subject so the bug tracking
system will know what problem report to attach it to.If you do not include the tracking
number, GNATS will become confused and create an entirely
new PR which it then assigns to the GNATS administrator,
and then your followup will become lost until someone
comes in to clean up the mess, which could be days or
weeks afterwards.Wrong way: Subject: that PR I sent
Right way: Subject: Re: ports/12345: compilation problem with foo/barIf the problem report remains open after the problem has
gone away, just send a follow-up (in the manner prescribed
above) saying that the problem report can be closed, and, if
possible, explaining how or when the problem was fixed.If you are having problemsMost PRs go through the system and are accepted quickly;
however, at times GNATS runs behind and you may not get your
email confirmation for 10 minutes or even longer. Please try to
be patient.In addition, because GNATS receives all its input via email,
it is absolutely vital that &os; runs all its submissions through
spam filters. If you do not get a response within an hour or
two, you may have fallen afoul of them; if so, please contact
the GNATS administrators at bugmeister@FreeBSD.org
and ask for help.Among the anti-spam measures is one that weighs against
many common abuses seen HTML-based email (although not necessarily
the mere inclusion of HTML in a PR). We strongly recommend
against the use of HTML-based email when sending PRs: not
only is it more likely to fall afoul of the filters, it also
tends to merely clutter up the database. Plain old email is
strongly preferred.On rare occasions you will encounter a GNATS bug where a
PR is accepted and assigned a tracking number but it does not
show up on the list of PRs on any of the web query pages. What
may have happened is that the database index has gotten out of
synchronization with the database itself. The way that you
can test whether this has happened is to pull up the
view a single PR page and see whether the PR shows up.
If it does, please notify the GNATS administrators at
bugmeister@FreeBSD.org. Note that there is a
cron job that periodically rebuilds the database,
so unless you are in a hurry, no action needs to be taken.Further ReadingThis is a list of resources relevant to the proper writing
and processing of problem reports. It is by no means complete.
How to Report Bugs Effectively—an excellent
essay by Simon G. Tatham on composing useful (non-&os;-specific)
problem reports.Problem
Report Handling Guidelines—valuable insight
into how problem reports are handled by the &os;
developers.
Index: head/en_US.ISO8859-1/articles/relaydelay/article.sgml
===================================================================
--- head/en_US.ISO8859-1/articles/relaydelay/article.sgml (revision 29515)
+++ head/en_US.ISO8859-1/articles/relaydelay/article.sgml (revision 29516)
@@ -1,288 +1,288 @@
%articles.ent;
]>
Using Greylist with &os;TomRhodestrhodes@FreeBSD.org2004The &os; Documentation ProjectAn article written for the sole purpose of explaining
the relaydelay system on a &os; mail server. A relaydelay
or greylisting server cuts down on spam simply by issuing
a TEMPFAIL error message to
every incoming email. The purpose behind this idea
is that most spammers use their personal computers with
software to do their spamming. A real mail server should
queue the message and try to send it later. Thus the
spammer most likely moves on to the next host in place
of trying to send the email again. This is an excellent
idea; at least until the spammers begin to use software
that offers to try again. But how does this work exactly?
Well, when an email is received the message
ID is stored in a database and the
TEMPFAIL is returned along with the
email. If the email is resent, the message
ID will be checked against the message
IDs currently stored in the database.
If it exists in the database then the email is permitted to reach its
intended recipient. Otherwise, the ID
will be stored and a TEMPFAIL will
be issued. This cycle will repeat with every email which
comes into the server. From my personal experience, this
really does cut out 90% of the spam.Basic Configuration&os; 4.X includes perl in the base
system, but we need the threaded perl.
Users of &os; 5.X may start the process after reading the forthcoming
note.Remove the base perl and all
traces of perl from the system with
the following command:&prompt.root find / -name '*perl*' | xargs rm -rfThis will require all ports which require
perl to be rebuilt and reinstalled;
- sysutils/portupgrade
+ ports-mgmt/portupgrade
is perfect for this. At least it will point out which
ports have been removed and which will need to be
reinstalled.Install lang/perl5.8
with the USE_THREADS=yes variable
set. The current version of perl
may need to be removed first; errors will be reported
by the install process if this is necessary.&os; 4.X users will need to run the
use.perl command in the
work work directory. The
permissions may need to be altered to make the
file executable first, I just set it to 755
with chmod. From this point
on, all users of &os; 4.X should uncomment the
NOPERL option in their local
make.conf file. Otherwise
the base perl will be reinstalled
during the next upgrade.Now for the database server;
MySQL is perfect for this
sort of work. Install the
databases/mysql40-server
along with
databases/p5-DBD-mysql40.
The previous port should imply the installation of
databases/p5-DBI-137
so that knocks off another step.Install the perl based portable
server plugin, net/p5-Net-Daemon
port. Most of these port installations should have
been straight forward. The next step will be more
involved.Now install the
mail/p5-Sendmail-Milter
port. As of this writing the Makefile
contains a line beginning with BROKEN,
just remove it or comment it out. It is only marked
this way because &os; neither has nor installs
a threaded perl package by default. Once that
line is removed it should build and install perfectly
fine.Create a directory to hold temporary configuration
files:&prompt.root; mkdir /tmp/relaydelay
&prompt.root; cd /tmp/relaydelayNow that we have a temporary directory to work in, the
following URLs should be sent to the
fetch command:&prompt.root; fetch http://projects.puremagic.com/greylisting/releases/relaydelay-0.04.tgz
&prompt.root; fetch http://lists.puremagic.com/pipermail/greylist-users/attachments/20030904/b8dafed9/relaydelay-0.04.binThe source code should now be unpacked:&prompt.root; gunzip -c relaydelay-0.04.tgz | tar xvf -There should now be several files into the temporary directory
by this point. The appropriate information can now be passed to
the database server by importing it from the
mysql.sql file:&prompt.root; mysql < relaydelay-0.04/mysql.sqlAnd patch the other files with the
relaydelay.bin by running:&prompt.root; patch -d /tmp/relaydelay/relaydelay-0.04 < relaydelay.binEdit the relaydelay.conf and the
db_maintenance.pl file to append the
correct username and password for the
MySQL database. If the database was
built and installed like the above then no users or passwords
exist. This should be altered before putting this into
production, that is covered in the database documentation and
is beyond the scope of this document.Change the working directory to the
relaydelay-0.04
directory:&prompt.root; cd relaydelay-0.04Copy or move the configuration files to their respective
directories:&prompt.root; mv db_maintenance.pl relaydelay.pl /usr/local/sbin
&prompt.root; mv relaydelay.conf /etc/mail
&prompt.root; mv relaydelay.sh /usr/local/etc/rc.d/Test the current configuration by running:&prompt.root; sh /usr/local/etc/rc.d/relaydelay.sh startThis file will not exist if the previous &man.mv.1; commands
were neglected.If everything worked correctly a new file,
relaydelay.log, should exist in
/var/log. It should
contain something similar to the following text:Loaded Config File: /etc/mail/relaydelay.conf
Using connection 'local:/var/run/relaydelay.sock' for filter relaydelay
DBI Connecting to DBI:mysql:database=relaydelay:host=localhost:port=3306
Spawned relaydelay daemon process 38277.
Starting Sendmail::Milter 0.18 engine.If this does not appear then something went wrong, review
the screen output or look for anything new in the
messages log file.Glue everything together by adding the following line to
/etc/mail/sendmail.mc or the customized
site specific mc file:INPUT_MAIL_FILTER(`relaydelay', `S=local:/var/run/relaydelay.sock, T=S:1m;R:2m;E:3m')dnlRebuild and reinstall the files in the
/etc/mail directory and restart
sendmail. A quick makerestart should do the trick.Obtain the perl script located at
http://lists.puremagic.com/pipermail/greylist-users/2003-November/000327.html
and save it in the
relaydelay-0.04
directory. In the following examples this script is
referred to as addlist.pl.Edit the whitelist_ip.txt file and
modify it to include IP addresses of servers
which should have the explicit abilities to bypass the
relaydelay filters. i.e., domains
from which email will not be issued a
TEMPFAIL when received.Some examples could include:192.168. # My internal network.
66.218.66 # Yahoo groups has unique senders.The blacklist_ip.txt file should
be treated similarly but with reversed rules. List within
this file IPs which should be denied without
being issued a TEMPFAIL. This list of
domains will never have the opportunity to prove that they are
legitimate email servers.These files should now be imported into the database with
the addlist.pl script obtained a few
lines ago:&prompt.root; perl addlist.pl -whitelist 9999-12-31 23:59:59 < whitelist_ip.txt
&prompt.root; perl addlist.pl -blacklist 9999-12-31 23:59:59 < blacklist_ip.txtTo have relaydelay start with
every system boot, add the
to the
/etc/rc.conf file.The /var/log/relaydelay.log log file
should slowly fill up with success stories. Lines like the
following should appear after a short time, depending on how
busy the mail server is.=== 2004-05-24 21:03:22 ===
Stored Sender: <someasshole@flawed-example.com>
Passed Recipient: <local_user@pittgoth.com>
Relay: example.net [XXX.XX.XXX.XX] - If_Addr: MY_IP_ADDRESS
RelayIP: XX.XX.XX.XX - RelayName: example.net - RelayIdent: - PossiblyForged: 0
From: someasshole@flawed-example.com - To: local_user
InMailer: esmtp - OutMailer: local - QueueID: i4P13Lo6000701111
Email is known but block has not expired. Issuing a tempfail. rowid: 51
IN ABORT CALLBACK - PrivData: 0<someasshole@flawed-example.com>The following line may now be added to
/etc/newsyslog.conf to cause for
relaydelay.log rotation at every
100 Kb:/var/log/relaydelay.log 644 3 100 * ZAt some point there was an error about improper
perl variables in the
/etc/mail/relaydelay.conf. If those
two variables are commented out then configuration may
proceed as normal. Just remember to uncomment them before
starting the relaydelay process.
Index: head/en_US.ISO8859-1/books/faq/book.sgml
===================================================================
--- head/en_US.ISO8859-1/books/faq/book.sgml (revision 29515)
+++ head/en_US.ISO8859-1/books/faq/book.sgml (revision 29516)
@@ -1,11787 +1,11787 @@
%books.ent;
]>
Frequently Asked Questions for FreeBSD 4.X, 5.X, and 6.XThe FreeBSD Documentation Project$FreeBSD$199519961997199819992000200120022003200420052006The FreeBSD Documentation Project
&bookinfo.legalnotice;
&tm-attrib.freebsd;
&tm-attrib.3com;
&tm-attrib.adobe;
&tm-attrib.creative;
&tm-attrib.cvsup;
&tm-attrib.ibm;
&tm-attrib.ieee;
&tm-attrib.intel;
&tm-attrib.iomega;
&tm-attrib.linux;
&tm-attrib.microsoft;
&tm-attrib.mips;
&tm-attrib.netscape;
&tm-attrib.opengroup;
&tm-attrib.oracle;
&tm-attrib.sgi;
&tm-attrib.sparc;
&tm-attrib.sun;
&tm-attrib.usrobotics;
&tm-attrib.xfree86;
&tm-attrib.general;
This is the FAQ for FreeBSD versions 4.X, 5.X, and 6.X.
All entries are assumed to be relevant to FreeBSD 4.0 and
later, unless otherwise noted. If you are interested in
helping with this project, send email to the &a.doc;. The
latest version of this document is always available from the
FreeBSD
World Wide Web server. It may also be downloaded as
one large HTML file with HTTP
or as plain text, &postscript;, PDF, etc. from the FreeBSD FTP
server. You may also want to Search the
FAQ.IntroductionWelcome to the FreeBSD 4.X-6.X FAQ!As is usual with Usenet FAQs, this document aims to cover the
most frequently asked questions concerning the FreeBSD operating
system (and of course answer them!). Although originally intended
to reduce bandwidth and avoid the same old questions being asked
over and over again, FAQs have become recognized as valuable
information resources.Every effort has been made to make this FAQ as informative as
possible; if you have any suggestions as to how it may be improved,
please feel free to mail them to the &a.doc;.What is FreeBSD?Briefly, FreeBSD is a &unix; like operating system for
the Alpha/AXP, AMD64 and &intel; EM64T, &i386; IA-64,
PC-98, and &ultrasparc; platforms
based on U.C. Berkeley's 4.4BSD-Lite
release, with some 4.4BSD-Lite2
enhancements. It is also based indirectly on William
Jolitz's port of U.C. Berkeley's Net/2 to
the &i386;, known as 386BSD, though very
little of the 386BSD code remains. A fuller description of
what FreeBSD is and how it can work for you may be found on
the FreeBSD home
page.FreeBSD is used by companies, Internet Service Providers,
researchers, computer professionals, students and home users
all over the world in their work, education and recreation.For more detailed information on FreeBSD, please see the
FreeBSD
Handbook.What is the goal of the FreeBSD Project?The goal of the FreeBSD Project is to provide software
that may be used for any purpose and without strings attached.
Many of us have a significant investment in the code (and
project) and would certainly not mind a little financial
compensation now and then, but we definitely do not
insist on it. We believe that our first and foremost
mission is to provide code to any and all
comers, and for whatever purpose, so that the code gets the
widest possible use and provides the widest possible benefit.
This is, we believe, one of the most fundamental goals of Free
Software and one that we enthusiastically support.That code in our source tree which falls under the
GNU
General Public License (GPL) or GNU
Library General Public License (LGPL) comes with
slightly more strings attached, though at least on the
side of enforced access rather than the usual opposite.
Due to the additional complexities that can evolve in the
commercial use of GPL software, we do, however, endeavor
to replace such software with submissions under the more
relaxed
FreeBSD license whenever possible.Does the FreeBSD license have any restrictions?Yes. Those restrictions do not control how you use
the code, merely how you treat the FreeBSD Project itself.
If you have serious license concerns, read the actual
license. For the simply curious, the license can
be summarized like this.Do not claim that you wrote this.Do not sue us if it breaks.Can FreeBSD replace my current operating system?For most people, yes. But this question is not quite
that cut-and-dried.Most people do not actually use an operating system.
They use applications. The applications are what really
use the operating system. FreeBSD is designed to provide
a robust and full-featured environment for applications.
It supports a wide variety of web browsers, office suites,
email readers, graphics programs, programming
environments, network servers, and just about everything
else you might want. Most of these applications can be
managed through the Ports
Collection.If you need to use an application that is only
available on one operating system, you simply cannot
replace that operating system. Chances are there is a very
similar application on FreeBSD, however. If you want a
solid office or Internet server, a reliable workstation,
or just the ability to do your job without interruptions,
FreeBSD will almost certainly do everything you need.
Many computer users across the world, including both
novices and experienced &unix; administrators, use FreeBSD
as their only desktop operating system.If you are migrating to FreeBSD from some other &unix;
environment, you already know most of what you need to.
If your background is in graphic-driven operating systems
such as &windows; and older versions of &macos;, expect to
invest additional time learning the &unix; way of doing
things. This FAQ and the FreeBSD Handbook are
excellent places to start.Why is it called FreeBSD?It may be used free of charge, even by commercial
users.Full source for the operating system is freely
available, and the minimum possible restrictions have
been placed upon its use, distribution and incorporation
into other work (commercial or non-commercial).Anyone who has an improvement or bug fix is free
to submit their code and have it added to the source tree
(subject to one or two obvious provisions).It is worth pointing out that the word
free is being used in two ways here, one meaning
at no cost, the other meaning you can do
whatever you like. Apart from one or two things you
cannot do with the FreeBSD code, for
example pretending you wrote it, you can really do whatever you
like with it.What are the differences between FreeBSD and NetBSD, OpenBSD,
and other open source BSD operating systems?James Howard wrote a good explanation of the history
and differences between the various projects for DaemonNews,
called The
BSD Family Tree which goes a fair way to answering
this question.What is the latest version of FreeBSD?At this point in FreeBSD's development, there are three
parallel development branches; releases are being made from
two of the three branches. The 5.X series of releases
is being made from the 5-STABLE branch
and the 6.X series of releases from 6-STABLE.
Up until the release of 5.3, the 4.X series was the
one known as -STABLE. However,
as of 5.3, the 4.X branch will be designated for
an extended support status and receive
only fixes for major problems, such as security-related
fixes. There will be more releases made from the
5-STABLE branch, but it is considered
a legacy branch and most current work will
only become a part of 6-STABLE.
Version &rel.current;
is the latest release from the
6-STABLE branch; it was released in
&rel.current.date;. Version &rel2.current;
is the latest release from the
5-STABLE branch; it was released in
&rel2.current.date;.Briefly, -STABLE is aimed at the
ISP, corporate user, or any user who wants stability and a
minimal number of changes compared to the new (and
possibly unstable) features of the latest
-CURRENT snapshot. Releases can come
from either branch, but -CURRENT
should only be used if you are prepared for its increased
volatility (relative to -STABLE, that
is).Releases are made every
few months. While many people stay more up-to-date with
the FreeBSD sources (see the questions on &os.current; and &os.stable;) than that, doing so
is more of a commitment, as the sources are a moving
target.More information on FreeBSD releases can be found on
the Release
Engineering page on the FreeBSD Web site.What is FreeBSD-CURRENT?&os.current;
is the development version of the operating system, which
will in due course become the new &os.stable; branch.
As such, it is
really only of interest to developers working on the
system and die-hard hobbyists. See the relevant
section in the handbook for details
on running -CURRENT.If you are not familiar with the operating system or are
not capable of identifying the difference between a real
problem and a temporary problem, you should not use
&os.current;. This branch sometimes evolves quite quickly
and can be un-buildable for a number of days at a time.
People that use &os.current; are expected to be able to
analyze any problems and only report them if they are deemed
to be mistakes rather than glitches. Questions
such as make world produces some error about
groups on the -CURRENT mailing list may be
treated with contempt.Every day, snapshot
releases are made based on the current state of the
-CURRENT and -STABLE branches. Distributions of the
occasional snapshot are made available. The goals
behind each snapshot release are:To test the latest version of the installation
software.To give people who would like to run -CURRENT or
-STABLE but who do not have the time or bandwidth to
follow it on a day-to-day basis an easy way of
bootstrapping it onto their systems.To preserve a fixed reference point for the code in
question, just in case we break something really badly
later. (Although CVS normally prevents anything horrible
like this happening :)To ensure that all new features and fixes in need
of testing have the greatest possible number of
potential testers.No claims are made that any -CURRENT snapshot can be
considered production quality for any purpose.
If you want to run a stable and fully tested system, you will
have to stick to full releases, or use the -STABLE
snapshots.Snapshot releases are directly available from
ftp://current.FreeBSD.org/pub/FreeBSD/snapshots/.Snapshots are generated, on the average, daily for
all actively developed branches.What is the FreeBSD-STABLE concept?Back when FreeBSD 2.0.5 was released, FreeBSD
development branched in two. One branch was named -STABLE,
one -CURRENT.
FreeBSD-STABLE is intended for Internet Service Providers
and other commercial enterprises for whom sudden shifts or
experimental features are quite undesirable. It receives
only well-tested bug fixes and other small incremental
enhancements. FreeBSD-CURRENT, on the other hand, has
been one unbroken line since 2.0 was released, leading
towards 6.0-RELEASE and beyond. Just before 6.0-RELEASE, the
6-STABLE branch was created, and
&os.current; became 7-CURRENT. For more detailed information,
see
FreeBSD Release Engineering:
Creating the Release Branch.The 2.2-STABLE branch was retired with the release of 2.2.8.
The 3-STABLE branch has ended with the release of 3.5.1, the
final 3.X release. The only changes made to either of these
branches will be, for the most part, security-related bug
fixes. Support for the 4-STABLE and 5-STABLE branches will
continue for some time but focus primarily on security-related
bug fixes and other serious issues.&rel.current;-STABLE is the actively developed -STABLE branch.
The latest release on the &rel.current;-STABLE branch is
&rel.current;-RELEASE, which was released in
&rel.current.date;.The 7-CURRENT branch is the actively developed
-CURRENT branch toward the next generation of &os;.
See What is &os;-CURRENT? for more
information on this branch.When are FreeBSD releases made?The &a.re; releases a new version of FreeBSD about every
four months, on average. Release dates are announced well in
advance, so that the people working on the system know
when their projects need to be finished and tested.
A testing period precedes each release, in order to ensure
that the addition of new features does not compromise the
stability of the release.
Many users regard this caution as one of the best things about
FreeBSD, even though waiting for all the latest goodies to reach
-STABLE can be a little frustrating.More information on the release engineering process
(including a schedule of upcoming releases) can be found
on the release
engineering pages on the FreeBSD Web site.For people who need or want a little more excitement,
binary snapshots are made daily as discussed above.Who is responsible for FreeBSD?The key decisions concerning the FreeBSD project, such
as the overall direction of the project and who is allowed
to add code to the source tree, are made by a core
team of 9 people. There is a much larger team of
more than 300 committers
who are authorized to make changes directly to the FreeBSD
source tree.However, most non-trivial changes are discussed in advance
in the mailing lists, and there
are no restrictions on who may take part in the
discussion.Where can I get FreeBSD?Every significant release of FreeBSD is available via
anonymous FTP from the
FreeBSD FTP site:The latest 6-STABLE release, &rel.current;-RELEASE can be
found in the &rel.current;-RELEASE directory.
Snapshot releases are made daily for the
-CURRENT branch, these being
of service purely to bleeding-edge testers and
developers.The latest 5-STABLE release, &rel2.current;-RELEASE can be
found in the &rel2.current;-RELEASE directory.5.X
snapshots are usually made daily.Information about obtaining FreeBSD on CD, DVD, and other
media can be found in the
Handbook.How do I access the Problem Report database?The Problem Report database of all user change requests
may be queried by using our web-based PR
query
interface.The &man.send-pr.1; command can be used to submit problem
reports and change requests via electronic mail. Alternatively,
the web-based
problem report submission interface can be used to submit
problem reports through a web browser.Before submitting a problem report, please read Writing
FreeBSD Problem Reports, an article on how to write
good problem reports.What other sources of information are there?Please check the Documentation
list on the main FreeBSD web
site.Documentation and SupportWhat good books are there about FreeBSD?The project produces a wide range of documentation,
available online from this link: . The same
documents are available as packages, that you can easily
install on your FreeBSD system. More details on
documentation packages can be found in the next
paragraphs.In addition, the Bibliography at the end of this
FAQ, and the one in the Handbook reference other
recommended books.Is the documentation available in other formats, such as plain
text (ASCII), or &postscript;?Yes. The documentation is available in a number of
different formats and compression schemes on the FreeBSD
FTP site, in the /pub/FreeBSD/doc/
directory.The documentation is categorized in a number of different
ways. These include:The document's name, such as faq, or
handbook.The document's language and encoding. These are
based on the locale names you will find under
/usr/share/locale on your FreeBSD
system. The current languages and encodings that we
have for documentation are as follows:NameMeaningen_US.ISO8859-1US Englishde_DE.ISO8859-1Germanes_ES.ISO8859-1Spanishfr_FR.ISO8859-1Frenchit_IT.ISO8859-15Italianja_JP.eucJPJapanese (EUC encoding)ru_RU.KOI8-RRussian (KOI8-R encoding)zh_CN.GB2312Simplified Chinese (GB2312 encoding)zh_TW.Big5Traditional Chinese (Big5 encoding)Some documents may not be available in all
languages.The document's format. We produce the documentation in a
number of different output formats. Each format has its own
advantages and disadvantages. Some formats are better suited
for online reading, while others are meant to be aesthetically
pleasing when printed on paper. Having the documentation
available in any of these formats ensures that our readers
will be able to read the parts they are interested in, either
on their monitor, or on paper after printing the documents.
The currently available formats are:FormatMeaninghtml-splitA collection of small, linked, HTML
files.htmlOne large HTML file containing the entire
documentpdbPalm Pilot database format, for use with the
iSilo
reader.pdfAdobe's Portable Document Formatps&postscript;rtfMicrosoft's Rich Text FormatPage numbers are not automatically
updated when loading this format into Word.
Press CTRLA,
CTRLEND,
F9 after loading the
document, to update the page numbers.txtPlain textThe compression and packaging scheme. There are three of
these currently in use.Where the format is
html-split, the files are
bundled up using &man.tar.1;. The resulting
.tar file is then compressed
using the compression schemes detailed in the next
point.All the other formats generate one file,
called
book.format
(i.e., book.pdb,
book.html, and so on).These files are then compressed using two
compression schemes.SchemeDescriptionzipThe Zip format. If you want to
uncompress this on FreeBSD you will need
to install the archivers/unzip
port first.bz2The BZip2 format. Less widespread
than Zip, but generally gives
smaller files. Install the archivers/bzip2
port to uncompress these files.So the &postscript; version of the Handbook,
compressed using BZip2 will be stored in a file
called book.ps.bz2 in the
handbook/ directory.After choosing the format and compression mechanism that you
want to download, you must then decide whether or not you want to
download the document as a FreeBSD
package.The advantage of downloading and installing the package is
that the documentation can then be managed using the normal
FreeBSD package management comments, such as &man.pkg.add.1; and
&man.pkg.delete.1;.If you decide to download and install the package then
you must know the filename to download. The
documentation-as-packages files are stored in a directory
called packages. Each package file
looks like
document-name.lang.encoding.format.tgz.For example, the FAQ, in English, formatted as PDF, is in the
package called
faq.en_US.ISO8859-1.pdf.tgz.Knowing this, you can use the following command to
install the English PDF FAQ package.&prompt.root; pkg_add ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/packages/faq.en_US.ISO8859-1.pdf.tgzHaving done that, you can use &man.pkg.info.1; to determine
where the file has been installed.&prompt.root; pkg_info -f faq.en_US.ISO8859-1.pdf
Information for faq.en_US.ISO8859-1.pdf:
Packing list:
Package name: faq.en_US.ISO8859-1.pdf
CWD to /usr/share/doc/en_US.ISO8859-1/books/faq
File: book.pdf
CWD to .
File: +COMMENT (ignored)
File: +DESC (ignored)As you can see, book.pdf will
have been installed into
/usr/share/doc/en_US.ISO8859-1/books/faq.If you do not want to use the packages then you will have to
download the compressed files yourself, uncompress them, and then
copy the appropriate documents into place.For example, the split HTML version of the FAQ,
compressed using &man.bzip2.1;, can be found in the
doc/en_US.ISO8859-1/books/faq/book.html-split.tar.bz2
file. To download and uncompress that file you would have
to do this.&prompt.root; fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/en_US.ISO8859-1/books/faq/book.html-split.tar.bz2
&prompt.root; bzip2 -d book.html-split.tar.bz2
&prompt.root; tar xvf book.html-split.tarYou will be left with a collection of
.html files. The main one is called
index.html, which will contain the
table of contents, introductory material, and links to the
other parts of the document. You can then copy or move
these to their final location as necessary.Where do I find info on the FreeBSD mailing lists?You can find full information in the Handbook
entry on mailing-lists.What FreeBSD news groups are available?You can find full information in the Handbook entry on
newsgroups.Are there FreeBSD IRC (Internet Relay Chat)
channels?Yes, most major IRC networks host a FreeBSD chat
channel:Channel #FreeBSD on
EFNet
is a FreeBSD forum, but do not go there for tech
support or try to get folks there to help you avoid
the pain of reading manual pages or doing your own research.
It is a chat channel, first and foremost, and topics there
are just as likely to involve sex, sports or nuclear
weapons as they are FreeBSD. You Have Been Warned!
Available at server irc.chat.org.Channel #FreeBSDhelp on
EFNet
is a channel dedicated to helping FreeBSD users. They
are much more sympathetic to questions than
#FreeBSD is.Channel #FreeBSD on
DALNET
is available at irc.dal.net in the
US and irc.eu.dal.net in Europe.Channel #FreeBSDHelp on
DALNET
is available at irc.dal.net in the
US and irc.eu.dal.net in Europe.Channel #FreeBSD on
UNDERNET
is available at us.undernet.org
in the US and eu.undernet.org in Europe.
Since it is a help channel, be prepared to read the
documents you are referred to.Channel #FreeBSD on
RUSNET
is a russian-language oriented channel dedicated
to helping &os; users. This is also good place
for non-technical discussions.Each of these channels are distinct and are not
connected to each other. Their chat styles also differ,
so you may need to try each to find one suited to your
chat style. As with all types of IRC
traffic, if you are easily offended or cannot deal with
lots of young people (and more than a few older ones)
doing the verbal equivalent of jello wrestling, do not
even bother with it.Where can I get commercial FreeBSD training and support?DaemonNews provides commercial training and support for
FreeBSD. More information can be found at their
BSD Mall
site.The FreeBSD Mall provides commercial FreeBSD support.
You can get more information at their web site.Any other organizations providing training and support should
contact the project in order to be listed here.NikClaytonnik@FreeBSD.orgInstallationWhich file do I download to get FreeBSD?For 4.X you need two floppy images:
floppies/kernel.flp and
floppies/mfsroot.flp. These images need to
be copied onto floppies by tools like
fdimage or &man.dd.1;.
In &os; 5.3 and later, the boot floppies have been restructured
and you need floppies/boot.flp and
all the floppies/kernX
files (of which there are currently two).If you need to download the distributions yourself (for a
DOS filesystem install, for instance), below are some
recommendations for distributions to grab:base/ (bin/ in 4.X)manpages/compat*/doc/src/ssys.*Full instructions on this procedure and a little bit more
about installation issues in general can be found in the
Handbook entry on
installing FreeBSD.What do I do if the floppy images does not fit on a single
floppy?A 3.5 inch (1.44MB) floppy can accommodate 1474560 bytes
of data. The boot image is exactly 1474560 bytes in size.Common mistakes when preparing the boot floppy are:Not downloading the floppy image in
binary mode when using
FTP.Some FTP clients default their transfer mode to
ascii and attempt to change any
end-of-line characters received to match the conventions
used by the client's system. This will almost invariably
corrupt the boot image. Check the size of the downloaded
boot image: if it is not exactly that
on the server, then the download process is suspect.To workaround: type binary at the
FTP command prompt after getting connected to the server
and before starting the download of the image.Using the DOS copy command (or
equivalent GUI tool) to transfer the boot image to
floppy.Programs like copy will not work as
the boot image has been created to be booted into directly.
The image has the complete content of the floppy, track for
track, and is not meant to be placed on the floppy as a
regular file. You have to transfer it to the floppy
raw, using the low-level tools (e.g.
fdimage or rawrite)
described in the installation guide to
FreeBSD.Where are the instructions for installing FreeBSD?Installation instructions can be found in the
Handbook entry on installing FreeBSD.What do I need in order to run FreeBSD?For versions prior to 5.X, you will need a 386 or better
PC, with 5 MB or more of RAM
and at least 60 MB of hard disk space. The &os;
installation process requires somewhat more memory so in
practice, 16 MB of RAM is a minimum requirement for a
standalone &os; system.For &os; 5.X and later you will need a 486 or better
PC, with 24 MB or more of RAM and at least 150 MB of hard disk
space.All versions of &os; can run with a low
end MDA graphics card but to run X11R6, a VGA or better video
card is needed.See also .I have only 4 MB of RAM. Can I install FreeBSD?Installing &os; 4.X requires at least 5MB RAM, and
installing &os; 5.X and later requires at least
8MB.All versions of FreeBSD prior to 5.X will
run in 4MB of RAM, they just cannot
run the installation program in 4MB. You can add extra
memory for the install process, and then revert to 4MB
after the system is running. Or you could move your disk
into a system which has sufficient memory, install onto
the disk and then swap it back.You must build a custom kernel to run in 4MB. Someone
has even successfully booted &os; with 2 MB RAM, although
the system was almost unusable.How can I make my own custom install floppy?Currently there is no way to just
make a custom install floppy. You have to cut a whole new
release, which will include your install floppy.To make a custom release, follow the instructions in the
Release
Engineering article.Can I have more than one operating system on my PC?Have a look at
the multi-OS page.Can &windows; co-exist with FreeBSD?Install &windows; first, then FreeBSD.
FreeBSD's boot manager will then manage to boot &windows; and
FreeBSD. If you install &windows; second, it will boorishly
overwrite your boot manager without even asking. If that
happens, see the next section.&windows; killed my boot manager!
How do I get it back?You can reinstall the boot manager FreeBSD comes with in
one of three ways:Running DOS, go into the tools/ directory of your
FreeBSD distribution and look for
bootinst.exe. You run it like
so:...\TOOLS>bootinst.exe boot.binand the boot manager will be reinstalled.Boot the FreeBSD boot floppy again and go to the
Custom installation menu item. Choose Partition. Select the
drive which used to contain your boot manager (likely the
first one) and when you come to the partition editor for
it, as the very first thing (e.g. do not make any changes)
select (W)rite. This will ask for confirmation, say yes,
and when you get the Boot Manager selection prompt, be
sure to select Boot Manager. This will
re-write the boot manager to disk. Now quit out of the
installation menu and reboot off the hard disk as
normal.Boot the FreeBSD boot floppy (or CDROM) and choose the
Fixit menu item. Select either the Fixit
floppy or CDROM #2 (the live filesystem
option) as appropriate and enter the fixit shell. Then
execute the following command:Fixit#fdisk -B -b /boot/boot0 bootdevicesubstituting bootdevice for
your real
boot device such as ad0 (first IDE
disk), ad4 (first IDE disk on
auxiliary controller), da0 (first
SCSI disk), etc.My A, T, or X series IBM Thinkpad locks up when I first
booted up my FreeBSD installation. How can I solve this?A bug in early revisions of IBM's BIOS on these machines
mistakenly identifies the FreeBSD partition as a potential FAT
suspend-to-disk partition. When the BIOS tries to parse the
FreeBSD partition it hangs.According to IBMIn an e-mail from Keith
Frechette
kfrechet@us.ibm.com., the
following model/BIOS release numbers incorporate the fix.ModelBIOS revisionT20IYET49WW or laterT21KZET22WW or laterA20pIVET62WW or laterA20mIWET54WW or laterA21pKYET27WW or laterA21mKXET24WW or laterA21eKUET30WWIt has been reported that later IBM BIOS revisions may
have reintroduced the bug. This
message from Jacques Vidrine to the &a.mobile;
describes a procedure which may work if your newer IBM
laptop does not boot FreeBSD properly, and you can upgrade
or downgrade the BIOS.If you have an earlier BIOS, and upgrading is not an option, a
workaround is to install FreeBSD, change the partition ID FreeBSD
uses, and install new boot blocks that can handle the different
partition ID.First, you will need to restore the machine to a state where
it can get through its self-test screen. Doing this requires
powering up the machine without letting it find a FreeBSD
partition on its primary disk. One way is to remove the hard disk
and temporarily move it to an older ThinkPad (such as a ThinkPad
600) or a desktop PC with an appropriate conversion cable. Once
it is there, you can delete the FreeBSD partition and move the hard
disk back. The ThinkPad should now be in a bootable state
again.With the machine functional again, you can use the workaround
procedure described here to get a working FreeBSD
installation.Download boot1 and
boot2 from .
Put these files somewhere you will be able to retrieve them
later.Install FreeBSD as normal on to the ThinkPad.
Do not use Dangerously
Dedicated mode. Do not
reboot when the install has finished.Either switch to the Emergency Holographic
Shell (ALTF4) or start a
fixit shell.Use &man.fdisk.8; to change the FreeBSD partition ID from
165 to 166 (this is the
type used by OpenBSD).Bring the boot1 and
boot2 files to the local
filesystem.Use &man.disklabel.8; to write boot1
and boot2 to your FreeBSD slice.&prompt.root; disklabel -B -b boot1 -s boot2 ad0snn is the number of the slice
where you installed FreeBSD.Reboot. At the boot prompt you will be given the option
of booting OpenBSD. This will actually
boot FreeBSD.Getting this to work in the case where you want to dual boot
OpenBSD and FreeBSD on the same laptop is left as an exercise for
the reader.Can I install on a disk with bad blocks?You can, but it is a bad idea.If you are seeing bad block errors with a modern IDE
drive, chances are the drive is going to die very soon (the
drive's internal remapping functions are no longer sufficient
to fix the bad blocks, which means the disk is heavily
corrupted); we suggest you buy a new hard drive.If you have a SCSI drive with bad blocks, see
this answer.Strange things happen when I boot the install floppy!
What is happening?If you are seeing things like the machine grinding to a halt
or spontaneously rebooting when you try to boot the install
floppy, here are three questions to ask yourself:-Did you use a new, freshly-formatted, error-free floppy
(preferably a brand-new one straight out of the box, as
opposed to the magazine cover disk that has been lying under
the bed for the last three years)?Did you download the floppy image in binary (or image)
mode? (do not be embarrassed, even the best of us have
accidentally downloaded a binary file in ASCII mode at
least once!)If you are using &windows; 95 or 98 did you run
fdimage or
rawrite in pure DOS mode? These
operating systems can interfere with programs that
write directly to hardware, which the disk creation
program does; even running it inside a DOS shell in
the GUI can cause this problem.There have also been reports of &netscape; causing problems
when downloading the boot floppy, so it is probably best to use
a different FTP client if you can.I booted from my ATAPI CDROM, but the install program
says no CDROM is found. Where did it go?The usual cause of this problem is a mis-configured CDROM
drive. Many PCs now ship with the CDROM as the slave device on
the secondary IDE controller, with no master device on that
controller. This is illegal according to the ATAPI specification,
but &windows; plays fast and loose with the specification, and the
BIOS ignores it when booting. This is why the BIOS was able to
see the CDROM to boot from it, but why FreeBSD cannot see it to
complete the install.Reconfigure your system so that the CDROM is either the
master device on the IDE controller it is attached to, or make
sure that it is the slave on an IDE controller that also has a
master device.Can I install on my laptop over PLIP (Parallel Line
IP)?Yes. Use a standard Laplink cable. If necessary, you
can check out the PLIP
section of the Handbook for details on parallel
port networking.Which geometry should I use for a disk drive?By the geometry of a disk, we mean
the number of cylinders, heads and sectors/track on a
disk. We will refer to this as C/H/S for
convenience. This is how the PC's BIOS works out which
area on a disk to read/write from.This causes a lot of confusion among new system
administrators. First of all, the
physical geometry of a SCSI drive is
totally irrelevant, as FreeBSD works in term of disk
blocks. In fact, there is no such thing as
the physical geometry, as the sector
density varies across the disk. What manufacturers claim
is the physical geometry is usually the
geometry that they have determined wastes the least
space. For IDE disks, FreeBSD does work in terms of C/H/S,
but all modern drives internally convert this into block
references.All that matters is the logical
geometry. This is the answer that the BIOS gets when it
asks the drive what is your geometry? It
then uses this geometry to access the disk. As FreeBSD
uses the BIOS when booting, it is very important to get
this right. In particular, if you have more than one
operating system on a disk, they must all agree on the
geometry. Otherwise you will have serious problems
booting!For SCSI disks, the geometry to use depends on whether
extended translation support is turned on in your
controller (this is often referred to as support for
DOS disks >1GB or something similar). If it is
turned off, then use N
cylinders, 64 heads and 32 sectors/track, where
N is the capacity of the disk in
MB. For example, a 2GB disk should pretend to have 2048
cylinders, 64 heads and 32 sectors/track.If it is turned on (it is often
supplied this way to get around certain limitations in
&ms-dos;) and the disk capacity is more than 1GB, use M
cylinders, 63 sectors per track (not
64), and 255 heads, where M is the disk capacity in MB
divided by 7.844238 (!). So our example 2GB drive would
have 261 cylinders, 63 sectors per track and 255
heads.If you are not sure about this, or FreeBSD fails to
detect the geometry correctly during installation, the
simplest way around this is usually to create a small DOS
partition on the disk. The BIOS should then detect the
correct geometry, and you can always remove the DOS
partition in the partition editor if you do not want to
keep it. You might want to leave it around for
programming network cards and the like, however.Alternatively, there is a freely available utility
distributed with FreeBSD called
pfdisk.exe. You can find it in the
tools subdirectory on the FreeBSD
CDROM or on the various FreeBSD FTP sites. This program
can be used to work out what geometry the other operating
systems on the disk are using. You can then enter this
geometry in the partition editor.Are there any restrictions on how I divide the disk up?Yes. You must make sure that your root partition is below 1024
cylinders so the BIOS can boot the kernel from it. (Note that
this is a limitation in the PC's BIOS, not FreeBSD).For a SCSI drive, this will normally imply that the root
partition will be in the first 1024MB (or in the first 4096MB
if extended translation is turned on - see previous question).
For IDE, the corresponding figure is 504MB.Is FreeBSD compatible with any disk managers?FreeBSD recognizes the Ontrack Disk Manager and makes
allowances for it. Other disk managers are not supported.If you just want to use the disk with FreeBSD you do not
need a disk manager. Just configure the disk for as much space
as the BIOS can deal with (usually 504 megabytes), and FreeBSD
should figure out how much space you really have. If you are
using an old disk with an MFM controller, you may need to
explicitly tell FreeBSD how many cylinders to use.If you want to use the disk with FreeBSD and another
operating system, you may be able to do without a disk manager:
just make sure the FreeBSD boot partition and the slice for
the other operating system are in the first 1024 cylinders. If
you are reasonably careful, a 20 megabyte boot partition should
be plenty.When I boot FreeBSD for the first time after install I get Missing Operating
System. What is happening?This is classically a case of FreeBSD and DOS or some other
OS conflicting over their ideas of disk geometry. You will have to reinstall
FreeBSD, but obeying the instructions given above will almost
always get you going.Why can I not get past the boot manager's F?
prompt?This is another symptom of the problem described in the
preceding question. Your BIOS geometry and FreeBSD geometry
settings do not agree! If your controller or BIOS supports
cylinder translation (often marked as >1GB drive
support), try toggling its setting and reinstalling
FreeBSD.Do I need to install the complete sources?In general, no. However, we would strongly recommend that
you install, at a minimum, the base source
kit, which includes several of the files mentioned here, and
the sys (kernel) source kit, which includes
sources for the kernel. There is nothing in the system which
requires the presence of the sources to operate, however,
except for the kernel-configuration program &man.config.8;.
With the exception of the kernel sources, our build structure
is set up so that you can read-only mount the sources from
elsewhere via NFS and still be able to make new binaries
(due to the kernel-source restriction, we recommend that
you not mount this on /usr/src directly,
but rather in some other location with appropriate symbolic
links to duplicate the top-level structure of the source
tree).Having the sources on-line and knowing how to build a
system with them will make it much easier for you to upgrade
to future releases of FreeBSD.To actually select a subset of the sources, use the Custom
menu item when you are in the Distributions menu of the
system installation tool.Do I need to build a kernel?Building a new kernel was originally pretty much a required
step in a FreeBSD installation, but more recent releases have
benefited from the introduction of much friendlier kernel
configuration methods. In 4.X and earlier, when at the FreeBSD boot prompt (boot:),
use the flag and you will be dropped into a
visual configuration screen which allows you to configure the
kernel's settings for most common ISA cards. In &os; 5.X and later
this has been replaced by much more flexible "hints" which
can be set from the loader prompt.It may still be worthwhile building a new
kernel containing just the drivers that you need, just to save a
bit of RAM, but it is no longer necessary for most
systems.Should I use DES, Blowfish, or MD5 passwords and how
do I specify which form my users receive?The default password format on FreeBSD is to use
MD5-based passwords. These are
believed to be more secure than the traditional &unix;
password format, which used a scheme based on the
DES algorithm. DES passwords are
still available if you need to share your password file
with legacy operating systems which still use the less
secure password format (they are available if you choose
to install the crypto distribution in
sysinstall, or by installing the crypto sources if
building from source). Installing the crypto libraries
will also allow you to use the Blowfish password format,
which is more secure. Which password format to use for
new passwords is controlled by the
passwd_format login capability in
/etc/login.conf, which takes values
of des, blf (if these are
available) or md5. See the
&man.login.conf.5; manual page for more information about
login capabilities.Why does the boot floppy start, but hang at the
Probing Devices... screen?If you have a IDE &iomegazip; or &jaz; drive installed, remove it
and try again. The boot floppy can get confused by the drives.
After the system is installed you can reconnect the drive.
Hopefully this will be fixed in a later release.Why do I get a panic: can't mount root
error when rebooting the system after installation?This error comes from confusion between the boot
block's and the kernel's understanding of the disk
devices. The error usually manifests on two-disk IDE
systems, with the hard disks arranged as the master or
single device on separate IDE controllers, with FreeBSD
installed on the secondary IDE controller. The boot blocks
think the system is installed on ad0 (the second BIOS
disk) while the kernel assigns the first disk on the
secondary controller device, ad2. After the device
probing, the kernel tries to mount what the boot blocks
think is the boot disk, ad0, while it is really ad2, and
fails.To fix the problem, do one of the following:Reboot the system and hit Enter
at the Booting kernel in 10 seconds; hit
[Enter] to interrupt prompt. This will
drop you into the boot loader.Then type
set
root_disk_unit="disk_number"
. disk_number
will be 0 if FreeBSD is installed
on the master drive on the first IDE controller,
1 if it is installed on the slave
on the first IDE controller, 2 if
it is installed on the master of the second IDE
controller, and 3 if it is
installed on the slave of the second IDE
controller.Then type boot, and your
system should boot correctly.To make this change permanent (i.e, so you do not
have to do this every time you reboot or turn on
your FreeBSD machine), put the line
root_disk_unit="disk_number"
in /boot/loader.conf.local
.Move the FreeBSD disk onto the primary IDE
controller, so the hard disks are
consecutive.What are the limits for memory?The limit is 4 gigabytes on a standard &i386; install.
Beginning with &os; versions 4.9 and 5.1, more memory can be
supported through &man.pae.4;. This does require a kernel
recompile, with an extra option to enable PAE:options PAE&os;/pc98 has a limit of 4 GB memory, and PAE can not
be used with it. On &os;/alpha, the limit on memory depends
on the type of hardware in use - consult the Alpha Hardware
Release Notes for details. Other architectures
supported by &os; have much higher theoretical limits on
maximum memory (many terabytes).What are the limits for ffs filesystems?For ffs filesystems, the maximum theoretical limit is 8
terabytes (2G blocks), or 16TB for the default block size of
8K. In practice, there is a soft limit of 1 terabyte, but with
modifications filesystems with 4 terabytes are possible (and
exist).The maximum size of a single ffs file is approximately 1G
blocks, or 4TB with a block size of 4K.
Maximum file sizesfs block sizeworksshould work4K4T-1>4T8K>32G32T-116K>128G32T-132K>512G64T-164K>2048G128T-1
When the fs block size is 4K, triple indirect blocks work
and everything should be limited by the maximum fs block number
that can be represented using triple indirect blocks (approx.
1K^3 + 1K^2 + 1K), but everything is limited by a (wrong) limit
of 1G-1 on fs block numbers. The limit on fs block numbers
should be 2G-1. There are some bugs for fs block numbers near
2G-1, but such block numbers are unreachable when the fs block
size is 4K.For block sizes of 8K and larger, everything should be
limited by the 2G-1 limit on fs block numbers, but is
actually limited by the 1G-1 limit on fs block numbers.
Using the correct limit of 2G-1 blocks does cause
problems.Why do I get an error message,
archsw.readin.failed after compiling
and booting a new kernel?Because your world and kernel are out of sync. This
is not supported. Be sure you use make
buildworld and make
buildkernel to update your kernel.You can boot by specifying the kernel directly at the
second stage, pressing any key when the | shows up before
loader is started.What are these security profiles?A security profile is a set of configuration
options that attempts to achieve the desired ratio of security
to convenience by enabling and disabling certain programs and
other settings. For full details, see the Security
Profile section of the Handbook's post-install
chapter.Installation crashes while booting, what can I do?Try disabling ACPI support. When the bootloader loads, press
the space key. The system displays OK. Type
unset acpi_load and then
boot.Hardware compatibilityGeneralI want to get a piece of hardware for my FreeBSD
system. Which model/brand/type is best?This is discussed continually on the FreeBSD mailing
lists. Since hardware changes so quickly, however, we
expect this. We still strongly
recommend that you read through the Hardware notes for &os;
&rel.current;
or
&rel2.current;
and search the mailing list
archives before asking about the latest and
greatest hardware. Chances are a discussion about the
type of hardware you are looking for took place just last
week.If you are looking for a laptop, check the
FreeBSD-mobile mailing list archives. Otherwise, you
probably want the archives for FreeBSD-questions, or
possibly a specific mailing list for a particular hardware
type.Architectures and processorsDoes FreeBSD support architectures other than the x86?Yes. FreeBSD currently runs on the Intel x86 and DEC
(now Compaq) Alpha architectures. As of FreeBSD 5.0, the
AMD64 and Intel EM64T, IA-64, and &sparc64; architectures
are also supported. Upcoming platforms are &mips; and
&powerpc;, join the &a.ppc; or the &a.mips; respectively
for more information about ongoing work on these
platforms. For general discussion on new architectures,
join the &a.platforms;.If your machine has a different architecture and you
need something right now, we suggest you look at NetBSD or OpenBSD.Does FreeBSD support Symmetric Multiprocessing
(SMP)?Yes. SMP was enabled by default in the
GENERIC kernel as of &os; 5.2.The intention was also to enable it by default for
the &os; 5.3 release, but problems running the SMP kernel
on certain UP machines led to the decision to disable it
until those problems can be addressed. This is a priority
for &os; 5.4.In &os; 4.X, SMP is not enabled in the default kernel,
so you must recompile your kernel to enable SMP. Take a
look at /sys/i386/conf/LINT to learn
which options to put in your kernel config file.Hard drives, tape drives, and CD and DVD drivesWhat kind of hard drives does FreeBSD support?FreeBSD supports EIDE and SCSI drives (with a compatible
controller; see the next section), and all drives using the
original Western Digital interface (MFM, RLL,
ESDI, and of course IDE). A few ESDI controllers that use
proprietary interfaces may not work: stick to WD1002/3/6/7
interfaces and clones.Which SCSI controllers are supported?See the complete list in the Hardware Notes for &os;
&rel.current; or
&rel2.current;.What types of tape drives are supported?FreeBSD supports SCSI and QIC-36 (with a QIC-02 interface).
This includes 8-mm (aka Exabyte) and DAT drives.Some of the early 8-mm drives are not quite compatible
with SCSI-2, and may not work well with FreeBSD.Does FreeBSD support tape changers?FreeBSD supports SCSI changers using the &man.ch.4;
device and the &man.chio.1; command. The details of how you
actually control the changer can be found in the &man.chio.1;
manual page.If you are not using AMANDA
or some other product that already understands changers,
remember that they only know how to move a tape from one
point to another, so you need to keep track of which slot a
tape is in, and which slot the tape currently in the drive
needs to go back to.Which CDROM drives are supported by FreeBSD?Any SCSI drive connected to a supported controller is
supported.The following proprietary CDROM interfaces are also
supported:Mitsumi LU002 (8bit), LU005 (16bit) and FX001D
(16bit 2x Speed).Sony CDU 31/33ASound Blaster Non-SCSI CDROMMatsushita/Panasonic CDROMATAPI compatible IDE CDROMsAll non-SCSI cards are known to be extremely slow compared
to SCSI drives, and some ATAPI CDROMs may not work.The official FreeBSD CDROM ISO, and CDROMs from Daemon
News and FreeBSD Mall, support booting directly from the
CD.Which CD-RW drives are supported by FreeBSD?FreeBSD supports any ATAPI-compatible IDE CD-R or CD-RW
drive. See &man.burncd.8; for details.FreeBSD also supports any SCSI CD-R or CD-RW drives.
Install and use the cdrecord command from the
ports or packages system, and make sure that you have the
pass device compiled in your
kernel.Does FreeBSD support &iomegazip; drives?FreeBSD supports SCSI and ATAPI (IDE) &iomegazip; drives out
of the box. SCSI ZIP drives can only be set to
run at SCSI target IDs 5 or 6, but if your SCSI host
adapter's BIOS supports it you can even boot from it. It
is not clear which host adapters support booting from
targets other than 0 or 1, so you will have to consult
your adapter's documentation if you would like to use this
feature.FreeBSD also supports Parallel Port Zip Drives. Check
that your kernel contains the
scbus0,
da0,
ppbus0, and
vp0 drivers (the GENERIC kernel
contains everything except
vp0). With all these drivers
present, the Parallel Port drive should be available as
/dev/da0s4. Disks can be mounted
using mount /dev/da0s4 /mnt OR (for dos
disks) mount_msdos /dev/da0s4 /mnt as
appropriate.Also check out the FAQ on
removable drives later in this chapter, and the note on
formattingin the Administration
chapter.Does FreeBSD support &jaz;, EZ and other removable
drives?They work. Most of these are SCSI devices, so they
look like SCSI disks to FreeBSD. The IDE EZ looks like an
IDE drive.Make sure that any external units are powered on when
booting the system.To change the media while
running, check out &man.mount.8;, &man.umount.8;, and
&man.camcontrol.8; (for SCSI devices) or
&man.atacontrol.8; (for IDE devices), plus the discussion on using removable
drives later in the FAQ.Keyboards and miceDoes FreeBSD support my USB keyboard?FreeBSD supports USB keyboards
out-of-the-box. Enable USB support in
/etc/rc.conf.Once you have USB keyboard support enabled on your
system, the AT keyboard becomes
/dev/kbd0 and the USB keyboard
becomes /dev/kbd1, if both are
connected to the system. If there is the USB keyboard
only, it will be
/dev/ukbd0.If you want to use the USB keyboard in the console,
you have to explicitly tell the console driver to use the
existing USB keyboard. This can be done by running the
following command as a part of system
initialization.&prompt.root; kbdcontrol -k /dev/kbd1 < /dev/ttyv0 > /dev/nullNote that if the USB keyboard is the only keyboard, it
is accessed as /dev/ukbd0, thus,
the command should look like:&prompt.root; kbdcontrol -k /dev/ukbd0 < /dev/ttyv0 > /dev/null/etc/rc.i386 is a good place to
add the above command.Once this is done, the USB keyboard should work in the
X environment as well without any special settings.Hot-plugging and unplugging of the USB keyboard may
not work quite right yet. We recommend connecting the
keyboard before starting the system and leaving it
connected until the system is shutdown to avoid
troubles.See the &man.ukbd.4; manual page for more information.I have an unusual bus mouse. How do I set it
up?FreeBSD supports the bus mouse and the InPort bus
mouse from such manufacturers as Microsoft, Logitech and
ATI. The GENERIC kernel does not include the device
driver. To build a custom kernel with the bus mouse
driver, add the following line to the kernel config
file:device mse0 at isa? port 0x23c irq5Bus mice usually come with dedicated interface cards.
These cards may allow you to set the port address and the
IRQ number other than shown above. Refer to the manual of
your mouse and the &man.mse.4; manual page for more
information.How do I use my PS/2 (mouse port or
keyboard) mouse?The PS/2 mouse is supported out-of-the-box. The
necessary device driver, psm, is
included in the kernel.If your custom kernel does not have this, add the
following line to your kernel configuration and compile a
new kernel.device psm0 at atkbdc? irq 12Once the kernel detects psm0
correctly at boot time, make sure that an entry for
psm0 exists in
/dev. You can create this entry by
typing:&prompt.root; cd /dev; sh MAKEDEV psm0when logged in as root.You can omit this step if you are running FreeBSD
5.0-RELEASE or newer with &man.devfs.5; enabled,
since the proper device nodes will be created automatically
under /dev.Is it possible to use a mouse in any way outside the X
Window system?If you are using the default console driver,
&man.syscons.4;, you can use a mouse pointer in text
consoles to cut & paste text. Run the mouse daemon,
&man.moused.8;, and turn on the mouse pointer in the
virtual console:&prompt.root; moused -p /dev/xxxx -t yyyy
&prompt.root; vidcontrol -m onWhere xxxx is the mouse
device name and yyyy is a
protocol type for the mouse. The mouse daemon can
automatically determine the protocol type of most
mice, except old serial mice. Specify the
auto protocol to invoke automatic
detection. If automatic detection does not work, see the
&man.moused.8; manual page for a list of supported
protocol types.If you have a PS/2 mouse, just add
moused_enable="YES" to
/etc/rc.conf to start the mouse
daemon at boot-time. Additionally, if you would like to
use the mouse daemon on all virtual terminals instead of
just the console, add allscreens_flags="-m
on" to /etc/rc.conf.When the mouse daemon is running, access to the mouse
must be coordinated between the mouse daemon and other
programs such as X Windows. Refer to the FAQ Why does my mouse not work with
X? for more details on this issue.How do I cut and paste text with a mouse in the text
console?Once you get the mouse daemon running (see the previous section), hold down the
button 1 (left button) and move the mouse to select a
region of text. Then, press the button 2 (middle button)
to paste it at the text cursor. Pressing button 3 (right
button) will extend the selected region of
text.If your mouse does not have a middle button, you may
wish to emulate one or remap buttons using mouse daemon
options. See the &man.moused.8; manual page for
details.My mouse has a fancy wheel and buttons. Can I use them in
FreeBSD?The answer is, unfortunately, It depends.
These mice with additional features require specialized driver
in most cases. Unless the mouse device driver or the user
program has specific support for the mouse, it will act just
like a standard two, or three button mouse.For the possible usage of wheels in the X Window
environment, refer to that
section.How do I use the mouse/trackball/touchpad on my laptop?Please refer to the answer to
the previous question.Networking and serial devicesWhich network cards does FreeBSD support?See the Hardware Notes supplied with each release of
FreeBSD for a more
complete list.Why is FreeBSD not finding my internal Plug & Play
modem?You will need to add the modem's PnP ID to the PnP ID
list in the serial driver. To enable Plug & Play support,
compile a new kernel with controller pnp0 in
the configuration file, then reboot the system. The kernel will
print the PnP IDs of all the devices it finds. Copy the PnP ID
from the modem to the table in
/sys/i386/isa/sio.c, at about line 2777.
Look for the string SUP1310 in the structure
siopnp_ids[] to find the table. Build the
kernel again, install, reboot, and your modem should be
found.You may have to manually configure the PnP devices using
the pnp command in the boot-time
configuration with a command likepnp 1 0 enable os irq0 3 drq0 0 port0 0x2f8to make the modem show.Does FreeBSD support software modems, such as Winmodems?FreeBSD supports many software modems via add-on
software. The comms/ltmdm port adds
support for modems based on the very popular Lucent LT
chipset. The comms/mwavem port
supports the modem in IBM Thinkpad 600 and 700
laptops.You cannot install FreeBSD via a software modem; this
software must be installed after the OS is
installed.Is there a native driver for the Broadcom 43xx cards?No, and there is not likely to be.Broadcom refuses to publically release programming
information for their wireless chipsets, most likely because
they use software controlled radios. In order to get FCC type
acceptance for their parts, they have to ensure that users
cannot arbitrarily set things like operating frequencies,
modulation parameters and power output. But without knowing
how to program the chipsets, it is nearly impossible to write
a driver.Which multi-port serial cards are supported by
FreeBSD?There is a list of these in the Miscellaneous
devices section of the handbook.Some unnamed clone cards have also been known to work,
especially those that claim to be AST compatible.Check the &man.sio.4; manual page to get more
information on configuring such cards.How do I get the boot: prompt to show on the serial
console?Build a kernel with
options COMCONSOLE.Create /boot.config and place
as the only text in the file.Unplug the keyboard from the system.See
/usr/src/sys/i386/boot/biosboot/README.serial
for information.Sound devicesWhich sound cards are supported by FreeBSD?&os; supports various sound cards including the &soundblaster;,
&soundblaster; Pro, &soundblaster; 16, Pro Audio Spectrum 16,
AdLib, and Gravis UltraSound sound cards (for more details,
see &os; Release Information
and the &man.snd.4; manual page).
There is also limited support for
MPU-401 and compatible MIDI cards. Cards conforming to the
µsoft; Sound System specification are also supported.This is only for sound! This driver does not support
CDROMs, SCSI or joysticks on these cards, except for the
&soundblaster;. The &soundblaster; SCSI interface and some
non-SCSI CDROMs are supported, but you cannot boot off this
device.Workarounds for no sound from my &man.pcm.4; sound
card?Some sound cards, such as the es1370, set their output
volume to 0 at every boot. Run the following command
every time the machine boots:&prompt.root; mixer pcm 100 vol 100 cd 100Other hardwareWhat other devices does FreeBSD support?See the Handbook
for the list of other devices supported.Does FreeBSD support power management on my
laptop?FreeBSD 4.X and later support APM
on certain machines. Further information can be found in
&man.apm.4;.FreeBSD 5.X and later support the
ACPI features found in most modern
hardware. Further information can be found in
&man.acpi.4;. If a system supports both
APM and ACPI, either
can be used. We suggest you try both and choose the one
that best fits your needs.How do I disable ACPI?Add following line hint.acpi.0.disabled="1"
into your /boot/device.hints file.Why does my Micron system hang at boot time?Certain Micron motherboards have a non-conforming PCI BIOS
implementation that causes grief when FreeBSD boots because PCI
devices do not get configured at their reported addresses.Disable the Plug and Play Operating System
flag in the BIOS to work around this problem.The boot floppy hangs on a system with an ASUS K7V
motherboard. How do I fix this?Go into the BIOS setup and disable the boot virus
protection.Why does my &tm.3com; PCI network card not work with my Micron
computer?Certain Micron motherboards have a non-conforming PCI BIOS
implementation that does not configure PCI devices at the
addresses reported. This causes grief when FreeBSD
boots.To work around this problem, disable the
Plug and Play Operating System flag in the
BIOS.My PCMCIA card does not work. I have a message:
cbb0: unsupported card type detected.
What can I do?You can try to use the original OLDCARD implementation. Edit
your kernel configuration file and remove the following lines:
device cbb
device pccard
device cardbus
Then add:
device pcic
device card 1
Rebuild and install the new kernel as described in
Configuring
the FreeBSD Kernel.TroubleshootingWhy is &os; finding the wrong amount of memory?The reason is the difference between physical memory addresses
and virtual addresses.The convention for most PC hardware is to use the memory area
between 3.5G and 4G for a special purpose (usually for PCI). This
address space is used to access PCI hardware. As a result real,
physical memory can not appear in that address space.What happens to the memory that should appear in that location
is dependent on your hardware. Unfortunately, some hardware does
nothing and the ability to use that last 500M of RAM is entirely
lost.Luckily, most hardware remaps the memory to a higher location
so that it can still be used. However, this can cause some
confusion if you watch the boot messages.On a 32 bit version of &os;, the memory appears lost, since it
will be remapped above 4G, which a 32 bit kernel is unable to
access. In this case, the solution is to build a PAE enabled
kernel. See this FAQ entry
for more information.On a 64 bit version of &os;, or when running a PAE-enabled
kernel, &os; will correctly detect and remap the memory so it is
usable. During boot, however, it may seem as if &os; is detecting
more memory than the system really has. This is normal and the
available memory will be corrected as the boot process
completes.What do I do when I have bad blocks on my hard drive?With SCSI drives, the drive should be capable of re-mapping
these automatically. However, many drives ship with
this feature disabled.To enable bad block remapping edit the first device page
mode, which can be done by giving the command
(as root)&prompt.root; camcontrol modepage sd0 -m 1 -e -P 3and changing the values of AWRE and ARRE from 0 to 1:-AWRE (Auto Write Reallocation Enbld): 1
ARRE (Auto Read Reallocation Enbld): 1Modern IDE drives also have bad block remapping
features in the controller, and they ship with this
feature turned on.If you see warnings about bad blocks (on either type
of drive), it is time to consider replacing the drive.
You might be able to use the drive manufacturer's
diagnostic program to lock out those bad blocks, but at
best this will buy you some time.Why does FreeBSD not detect my HP Netserver's SCSI
controller?This is basically a known problem. The EISA on-board SCSI
controller in the HP Netserver machines occupies EISA slot
number 11, so all the true EISA slots are in
front of it. Alas, the address space for EISA slots >= 10
collides with the address space assigned to PCI, and FreeBSD's
auto-configuration currently cannot handle this situation very
well.So now, the best you can do is to pretend there is no
address range clash :), by bumping the kernel option
EISA_SLOTS to a value of 12. Configure and
compile a kernel, as described in the Handbook entry on
configuring the kernel.Of course, this does present you with a chicken-and-egg
problem when installing on such a machine. In order to work
around this problem, a special hack is available inside
UserConfig. Do not use the
visual interface, but the plain command-line
interface there. Simply typeeisa 12
quitat the prompt, and install your system as usual. While
it is recommended you compile and install a custom kernel
anyway.Hopefully, future versions will have a proper fix for
this problem.You cannot use a
dangerously dedicated disk
with an HP Netserver. See this
note for more info.I keep seeing messages like
ed1: timeout. What do these messages
mean?This is usually caused by an interrupt conflict (e.g.,
two boards using the same IRQ). Boot with the
-c option and change the ed0/de0/... entry to match your
board.If you are using the BNC connector on your network card,
you may also see device timeouts because of bad termination. To
check this, attach a terminator directly to the NIC (with no
cable) and see if the error messages go away.Some NE2000 compatible cards will give this error if there
is no link on the UTP port or if the cable is disconnected.Why did my &tm.3com; 3C509 card stop working for no
apparent reason?This card has a bad habit of losing its configuration
information. Refresh your card's settings with the DOS
utility 3c5x9.exe.My parallel printer is ridiculously slow. What can I do?If the only problem is that the printer is terribly
slow, try changing your printer
port mode as discussed in the Printer
Setup section of the Handbook.Why do my programs occasionally die with
Signal 11 errors?Signal 11 errors are caused when your process has attempted
to access memory which the operating system has not granted it
access to. If something like this is happening at seemingly
random intervals then you need to start investigating things
very carefully.These problems can usually be attributed to either:If the problem is occurring only in a specific
application that you are developing yourself it is probably
a bug in your code.If it is a problem with part of the base FreeBSD system,
it may also be buggy code, but more often than not these
problems are found and fixed long before us general FAQ
readers get to use these bits of code (that is what -current
is for).In particular, a dead giveaway that this is
not a FreeBSD bug is if you see the
problem when you are compiling a program, but the activity
that the compiler is carrying out changes each
time.For example, suppose you are running make
buildworld, and the compile fails while trying to
compile ls.c into
ls.o. If you then run make
buildworld again, and the compile fails in the same
place then this is a broken build -- try updating your sources
and try again. If the compile fails elsewhere then this is
almost certainly hardware.What you should do:In the first case you can use a debugger e.g. gdb to find
the point in the program which is attempting to access a bogus
address and then fix it.In the second case you need to verify that it is not your
hardware at fault.Common causes of this include:Your hard disks might be overheating: Check the fans in
your case are still working, as your disk (and perhaps
other hardware might be overheating).The processor running is overheating: This might be
because the processor has been overclocked, or the fan on
the processor might have died. In either case you need to
ensure that you have hardware running at what it is
specified to run at, at least while trying to solve this
problem. i.e. Clock it back to the default settings.If you are overclocking then note that it is far cheaper
to have a slow system than a fried system that needs
replacing! Also the wider community is not often
sympathetic to problems on overclocked systems, whether you
believe it is safe or not.Dodgy memory: If you have multiple memory SIMMS/DIMMS
installed then pull them all out and try running the
machine with each SIMM or DIMM individually and narrow the
problem down to either the problematic DIMM/SIMM or perhaps
even a combination.Over-optimistic Motherboard settings: In your BIOS
settings, and some motherboard jumpers you have options to
set various timings, mostly the defaults will be
sufficient, but sometimes, setting the wait states on RAM
too low, or setting the RAM Speed: Turbo option, or
similar in the BIOS will cause strange behavior. A
possible idea is to set to BIOS defaults, but it might be
worth noting down your settings first!Unclean or insufficient power to the motherboard. If you
have any unused I/O boards, hard disks, or CDROMs in your
system, try temporarily removing them or disconnecting the
power cable from them, to see if your power supply can
manage a smaller load. Or try another power supply,
preferably one with a little more power (for instance, if
your current power supply is rated at 250 Watts try one
rated at 300 Watts).You should also read the SIG11 FAQ (listed below) which has
excellent explanations of all these problems, albeit from a
&linux; viewpoint. It also discusses how memory testing software
or hardware can still pass faulty memory.Finally, if none of this has helped it is possible that
you have just found a bug in FreeBSD, and you should follow the
instructions to send a problem report.There is an extensive FAQ on this at
the SIG11 problem FAQMy system crashes with either Fatal
trap 12: page fault in kernel mode, or
panic:, and spits out a
bunch of information. What should I do?The FreeBSD developers are very interested in these
errors, but need some more information than just the
error you see. Copy your full crash message. Then
consult the FAQ section on kernel panics,
build a debugging kernel, and get a backtrace. This
might sound difficult, but you do not need any
programming skills; you just have to follow the
instructions.Why does the screen go black and lose sync when I
boot?This is a known problem with the ATI Mach 64 video card.
The problem is that this card uses address
2e8, and the fourth serial port does too.
Due to a bug (feature?) in the &man.sio.4;
driver it will touch this port even if you do not have the
fourth serial port, and even if
you disable sio3 (the fourth port) which normally uses this
address.Until the bug has been fixed, you can use this
workaround:Enter at the boot prompt.
(This will put the kernel into configuration mode).Disable sio0,
sio1,
sio2 and
sio3 (all of them). This way
the sio driver does not get activated -> no
problems.Type exit to continue booting.If you want to be able to use your serial ports, you will
have to build a new kernel with the following modification: in
/usr/src/sys/i386/isa/sio.c find the one
occurrence of the string 0x2e8 and remove
that string and the preceding comma (keep the trailing comma).
Now follow the normal procedure of building a new
kernel.Even after applying these workarounds, you may still find
that the X Window System does not work properly. If this is the
case, make sure that the &xfree86; version you are using is at
least &xfree86; 3.3.3 or higher. This version and upwards has
built-in support for the Mach64 cards and even a dedicated X
server for those cards.Why does FreeBSD only use 64 MB of RAM when my system has
128 MB of RAM installed?Due to the manner in which FreeBSD gets the memory size
from the BIOS, it can only detect 16 bits worth of Kbytes in
size (65535 Kbytes = 64MB) (or less... some BIOSes peg the
memory size to 16M). If you have more than 64MB, FreeBSD will
attempt to detect it; however, the attempt may fail.To work around this problem, you need to use the kernel
option specified below. There is a way to get complete memory
information from the BIOS, but we do not have room in the
bootblocks to do it. Someday when lack of room in the
bootblocks is fixed, we will use the extended BIOS functions to
get the full memory information...but for now we are stuck with
the kernel option.options "MAXMEM=n"Where n is your memory in
Kilobytes. For a 128 MB machine, you would want to use
131072.My system has more than 1 GB of RAM, and I'm getting panics
with kmem_map too small messages. What is wrong?
Normally, FreeBSD determines a number of kernel parameters,
such as as the maximum number of files that can be open
concurrently, from the amount of memory installed in the
system. On systems with one gigabyte of RAM or more, this
auto sizing mechanism may choose values that are
too high: while starting up, the kernel allocates various tables
and other structures that fill up most of the available kernel
memory. Later on, while the system is running, the kernel has no
more space left for dynamic memory allocations, and
panics.Compile your own kernel, and add the
to your kernel configuration
file, increasing the maximum size to 400 MB
().
400 MB appears to be sufficient for machines with up to
6 GB of memory.My system does not have 1 GB of RAM, and FreeBSD still
panics with kmem_map too small!The panic indicates that the system ran out of virtual
memory for network buffers (specifically, mbuf clusters). You
can increase the amount of VM available for mbuf clusters by
following the instructions in the Network
Limits section of the Handbook.Why do I get the error /kernel: proc: table
is full?The FreeBSD kernel will only allow a certain number of
processes to exist at one time. The number is based on
the MAXUSERS option in the kernel
configuration. MAXUSERS also affects
various other in-kernel limits, such as network buffers
(see this
earlier question). If your machine is heavily loaded, you
probably want to increase MAXUSERS.
This will increase these other system limits in addition
to the maximum number of processes.To adjust your MAXUSERS value, see
the File/Process
Limits section of the Handbook. (While that
section refers to open files, the same limits apply to
processes.)If your machine is lightly loaded, and you are simply
running a very large number of processes, you can adjust
this with the kern.maxproc tunable. If
this tunable needs adjustion it needs to be defined in
in /boot/loader.conf. The tunable
will not get adjusted until the system is rebooted. For
more information about tuning tunables, you should see the
&man.loader.conf.5; and &man.sysctl.conf.5; manual pages.
If these processes are being run by a single user, you will
also need to adjust kern.maxprocperuid
to be one less than your new
kern.maxproc value. (It must be at
least one less because one system program, &man.init.8;,
must always be running.)To make a sysctl change permanent place the proper value
in /etc/sysctl.conf. More information
about system tuning with &man.sysctl.8; can be found at
the Tuning
with sysctl section of the Handbook.Why do I get an error reading CMAP
busy when rebooting with a new
kernel?The logic that attempts to detect an out of date
/var/db/kvm_*.db files sometimes fails
and using a mismatched file can sometimes lead to panics.If this happens, reboot single-user and do:&prompt.root; rm /var/db/kvm_*.dbWhat does the message ahc0: brkadrint,
Illegal Host Access at seqaddr 0x0
mean?This is a conflict with an Ultrastor SCSI Host Adapter.During the boot process enter the kernel configuration
menu and disable
uha0,
which is causing the problem.When I boot my system, I get the error
ahc0: illegal cable configuration.
My cabling is correct. What is going on?Your motherboard lacks the external logic to support
automatic termination. Switch your SCSI BIOS to specify
the correct termination for your configuration rather
than automatic termination. The AIC7XXX driver cannot
determine if the external logic for cable detection (and
thus auto-termination) is available. The driver simply
assumes that this support must exist if the configuration
contained in the serial EEPROM is set to "automatic
termination". Without the external cable detection logic
the driver will often configure termination incorrectly,
which can compromise the reliability of the SCSI
bus.Why does Sendmail give me an error reading
mail loops back to
myself?This is answered in the sendmail FAQ as follows:- * I'm getting "Local configuration error" messages, such as:
553 relay.domain.net config error: mail loops back to myself
554 <user@domain.net>... Local configuration error
How can I solve this problem?
You have asked mail to the domain (e.g., domain.net) to be
forwarded to a specific host (in this case, relay.domain.net)
by using an MX record, but the relay machine does not recognize
itself as domain.net. Add domain.net to /etc/mail/local-host-names
(if you are using FEATURE(use_cw_file)) or add "Cw domain.net"
to /etc/mail/sendmail.cf.
The current version of the sendmail
FAQ is no longer maintained with the sendmail release.
It is however regularly posted to comp.mail.sendmail,
comp.mail.misc, comp.mail.smail, comp.answers, and news.answers. You can also
receive a copy via email by sending a message to
mail-server@rtfm.mit.edu with the command
send usenet/news.answers/mail/sendmail-faq
as the body of the message.Why do full screen applications on remote machines
misbehave?The remote machine may be setting your terminal type
to something other than the cons25 terminal
type required by the FreeBSD console.There are a number of possible work-arounds for this
problem:After logging on to the remote machine, set your
TERM shell variable to ansi or
sco if the remote machine knows
about these terminal types.Use a VT100 emulator like
screen at the FreeBSD console.
screen offers you the ability
to run multiple concurrent sessions from one terminal,
and is a neat program in its own right. Each
screen window behaves like a
VT100 terminal, so the TERM variable at the remote end
should be set to vt100.Install the cons25 terminal
database entry on the remote machine. The way to do this
depends on the operating system on the remote machine.
The system administration manuals for the remote system
should be able to help you here.Fire up an X server at the FreeBSD end and login to
the remote machine using an X based terminal emulator
such as xterm or
rxvt. The TERM variable at the remote
host should be set to xterm or
vt100.Why does my machine print
calcru: negative time...?This can be caused by various hardware or software
ailments relating to interrupts. It may be due to bugs but can
also happen by nature of certain devices. Running TCP/IP over
the parallel port using a large MTU is one good way to provoke
this problem. Graphics accelerators can also get you here, in
which case you should check the interrupt setting of the card
first.A side effect of this problem are dying processes with the
message SIGXCPU exceeded cpu time limit.If the problem cannot be fixed otherwise the solution
is to set this sysctl variable:&prompt.root; sysctl -w kern.timecounter.method=1The option of &man.sysctl.8; is
deprecated and silently ignored in &os; 4.4-RELEASE and all
newer versions. You can safely ommit it when setting options
with sysctl as shown above.This means a performance impact, but considering the cause
of this problem, you probably will not notice. If the problem
persists, keep the sysctl set to one and set the
NTIMECOUNTER option in your kernel to
increasingly large values. If by the time you have reached
NTIMECOUNTER=20 the problem is not solved,
interrupts are too hosed on your machine for reliable
time keeping.Why is my PnP card no longer found (or found as
unknown) since upgrading to FreeBSD 4.X?FreeBSD 4.X is now much more PnP-centric
and this has had the side effect of some PnP devices (e.g. sound
cards and internal modems) not working even though they worked
under FreeBSD 3.X.The reasons for this behavior are explained by the following
e-mail, posted to the freebsd-questions mailing list by Peter
Wemm, in answer to a question about an internal modem that was
no longer found after an upgrade to FreeBSD 4.X (the comments
in [] have been added to clarify the
context.The contents of this quotation has been updated from
its original text.
The PNP bios preconfigured it [the modem] and left it
laying around in port space, so [in 3.X] the old-style ISA
probes found it there.Under 4.0, the ISA code is much more PnP-centric. It was
possible [in 3.X] for an ISA probe to find a
stray device and then for the PNP device id to
match and then fail due to resource conflicts. So, it
disables the programmable cards first so this double probing
cannot happen. It also means that it needs to know the PnP
ids for supported PnP hardware. Making this more user
tweakable is on the TODO list.
To get the device working again requires finding its PnP id
and adding it to the list that the ISA probes use to identify
PnP devices. This is obtained using &man.pnpinfo.8; to probe the
device, for example this is the output from &man.pnpinfo.8; for
an internal modem:&prompt.root; pnpinfo
Checking for Plug-n-Play devices...
Card assigned CSN #1
Vendor ID PMC2430 (0x3024a341), Serial Number 0xffffffff
PnP Version 1.0, Vendor Version 0
Device Description: Pace 56 Voice Internal Plug & Play Modem
Logical Device ID: PMC2430 0x3024a341 #0
Device supports I/O Range Check
TAG Start DF
I/O Range 0x3f8 .. 0x3f8, alignment 0x8, len 0x8
[16-bit addr]
IRQ: 4 - only one type (true/edge)[more TAG lines elided]TAG End DF
End Tag
Successfully got 31 resources, 1 logical fdevs
-- card select # 0x0001
CSN PMC2430 (0x3024a341), Serial Number 0xffffffff
Logical device #0
IO: 0x03e8 0x03e8 0x03e8 0x03e8 0x03e8 0x03e8 0x03e8 0x03e8
IRQ 5 0
DMA 4 0
IO range check 0x00 activate 0x01The information you require is in the
Vendor ID line at the start of the output. The
hexadecimal number in parentheses (0x3024a341 in this example)
is the PnP id and the string immediately before this (PMC2430)
is a unique ASCII id.Alternatively, if &man.pnpinfo.8; does not list the card in
question, &man.pciconf.8; can be used instead. This is part of
the output from pciconf -vl for an onboard
sound chip:&prompt.root; pciconf -vl
chip1@pci0:31:5: class=0x040100 card=0x00931028 chip=0x24158086 rev=0x02 hdr=0x00
vendor = 'Intel Corporation'
device = '82801AA 8xx Chipset AC'97 Audio Controller'
class = multimedia
subclass = audioHere, you would use the chip value,
0x24158086.This information (Vendor ID or chip value) needs adding
to the file
/usr/src/sys/isa/sio.c.You should first make a backup of sio.c
just in case things go wrong. You will also need it to make the
patch to submit with your PR (you are going to submit a PR,
are you not?) then edit sio.c and search
for the linestatic struct isa_pnp_id sio_ids[] = {then scroll down to find the correct place to add the entry
for your device. The entries look like this, and are sorted on
the ASCII Vendor ID string which should be included in the
comment to the right of the line of code along with all (if it
will fit) or part of the Device Description
from the output of &man.pnpinfo.8;:{0x0f804f3f, NULL}, /* OZO800f - Zoom 2812 (56k Modem) */
{0x39804f3f, NULL}, /* OZO8039 - Zoom 56k flex */
{0x3024a341, NULL}, /* PMC2430 - Pace 56 Voice Internal Modem */
{0x1000eb49, NULL}, /* ROK0010 - Rockwell ? */
{0x5002734a, NULL}, /* RSS0250 - 5614Jx3(G) Internal Modem */Add the hexadecimal Vendor ID for your device in the
correct place, save the file, rebuild your kernel, and reboot.
Your device should now be found as an sio
device as it was under FreeBSD 3.XWhy do I get the error nlist failed when
running, for example, top or
systat?The problem is that the application you are trying to run is
looking for a specific kernel symbol, but, for whatever reason,
cannot find it; this error stems from one of two problems:Your kernel and userland are not synchronized (i.e., you
built a new kernel but did not do an
installworld, or vice versa), and
thus the symbol table is different from what the user
application thinks it is. If this is the case, simply
complete the upgrade process (see
/usr/src/UPDATING for the correct
sequence).You are not using /boot/loader to load
your kernel, but doing it directly from boot2 (see
&man.boot.8;). While there is nothing wrong with bypassing
/boot/loader, it generally does a better
job of making the kernel symbols available to user
applications.Why does it take so long to connect to my computer via
ssh or telnet?The symptom: there is a long delay between the time the TCP
connection is established and the time when the client software
asks for a password (or, in &man.telnet.1;'s case, when a login
prompt appears).The problem: more likely than not, the delay is caused by
the server software trying to resolve the client's IP address
into a hostname. Many servers, including the Telnet and SSH
servers that come with FreeBSD, do this in order to, among
other things, store the hostname in a log file for future
reference by the administrator.The remedy: if the problem occurs whenever you connect from
your computer (the client) to any server, the problem is with
the client; likewise, if the problem only occurs when someone
connects to your computer (the server) the problem is with the
server.If the problem is with the client, the only remedy is to
fix the DNS so the server can resolve it. If this is on a
local network, consider it a server problem and keep reading;
conversely, if this is on the global Internet, you will most
likely need to contact your ISP and ask them to fix it for
you.If the problem is with the server, and this is on a local
network, you need to configure the server to be able to resolve
address-to-hostname queries for your local address range. See
the &man.hosts.5; and &man.named.8; manual pages for more
information. If this is on the global Internet, the problem
may be that your server's resolver is not functioning
correctly. To check, try to look up another host--say,
www.yahoo.com. If it does not work, that is
your problem.Following a fresh install of &os;, it is also possible
that domain and nameserver information is missing from
/etc/resolv.conf. This will often cause
a delay in SSH, as the option
UseDNS is set to yes by default
in the sshd_config file in
/etc/ssh. If this is causing the
problem, you will either need to fill in the missing information
in /etc/resolv.conf or set UseDNS
to no in sshd_config
as a temporary workaround.What does stray IRQ mean?Stray IRQs are indications of hardware IRQ glitches,
mostly from hardware that removes its interrupt request in
the middle of the interrupt request acknowledge
cycle.One has three options for dealing with this:Live with the warnings. All except the first 5
per irq are suppressed anyway.Break the warnings by changing 5 to 0 in
isa_strayintr() so that all the
warnings are suppressed.Break the warnings by installing parallel port
hardware that uses irq 7 and the PPP driver for it (this
happens on most systems), and install an ide drive or
other hardware that uses irq 15 and a suitable driver
for it.Why does file: table is full show up
repeatedly in dmesg?
This error message indicates you have exhausted the number
of available file descriptors on your system. Please see
the kern.maxfiles
section of the Tuning
Kernel Limits section of the Handbook for a
discussion and solution.Why does the clock on my laptop keep incorrect time?Your laptop has two or more clocks, and FreeBSD has chosen to
use the wrong one.Run &man.dmesg.8;, and check for lines that contain
Timecounter. The last line printed is the one
that FreeBSD chose, and will almost certainly be
TSC.&prompt.root; dmesg | grep Timecounter
Timecounter "i8254" frequency 1193182 Hz
Timecounter "TSC" frequency 595573479 HzYou can confirm this by checking the
kern.timecounter.hardware
&man.sysctl.3;.&prompt.root; sysctl kern.timecounter.hardware
kern.timecounter.hardware: TSCThe BIOS may modify the TSC clock—perhaps to change the
speed of the processor when running from batteries, or going into
a power saving mode, but FreeBSD is unaware of these adjustments,
and appears to gain or lose time.In this example, the i8254 clock is also
available, and can be selected by writing its name to the
kern.timecounter.hardware
&man.sysctl.3;.&prompt.root; sysctl -w kern.timecounter.hardware=i8254
kern.timecounter.hardware: TSC -> i8254Your laptop should now start keeping more accurate
time.To have this change automatically run at boot time, add the
following line to /etc/sysctl.conf.kern.timecounter.hardware=i8254Why did my laptop fail to correctly probe PC cards?This problem is common on laptops that boot more than
one operating system. Some non-BSD operating systems
leave PC card hardware in an inconsistent state.
pccardd will detect the card as
"(null)""(null)" instead of its
actual model.You must remove all power from the PC card slot to
fully reset the hardware. Completely power off the
laptop. (Do not suspend it, do not let it go into standby;
the power needs to be completely off.) Wait a few
moments, and reboot. Your PC card should work now.Some laptop hardware lies when it claims to be off.
If the above does not work shut down, remove the battery,
wait a moment, replace the battery, and reboot.Why does FreeBSD's boot loader display
Read error and stop after the BIOS
screen?FreeBSD's boot loader is incorrectly recognizing the hard
drive's geometry. This must be manually set within fdisk when
creating or modifying FreeBSD's slice.
The correct drive geometry values can be found within the
machine's BIOS. Look for the number of cylinders, heads and
sectors for the particular drive.
Within &man.sysinstall.8;'s fdisk, hit
G to set the drive geometry.A dialog will pop up requesting the number of
cylinders, heads and sectors. Type the numbers found from
the BIOS separated by forward slashes. For example, values
of 5000 cylinders, 250 heads, and 60 sectors would be entered as
5000/250/60.
Press enter to set the values, and hit
W to write the new partition table to the
drive.Another operating system destroyed my Boot Manager. How do I
get it back?Enter &man.sysinstall.8; and choose Configure,
then Fdisk. Select the disk the Boot Manager resided on
with the space key. Press
W to write changes to the drive. A prompt
will appear asking which boot loader to install. Select this,
and it will be restored.
What does the error swap_pager: indefinite
wait buffer: mean?This means that a process is trying to page memory to
disk, and the page attempt has hung trying to access the
disk for more than 20 seconds. It might be caused by bad
blocks on the disk drive, disk wiring, cables, or any
other disk I/O-related hardware. If the drive itself is
actually bad, you will also see disk errors in
/var/log/messages and in the output
of dmesg. Otherwise, check your cables
and connections.What are UDMA ICRC errors, and how do I
fix them?The &man.ata.4; driver reports UDMA ICRC
errors when a DMA transfer to or from a drive is corrupted.
The driver will retry the operation a few times. Should
the retries fail, it will switch from DMA to the slower PIO
mode of communication with the device.The problem can be caused by many factors, although
perhaps the most common cause is faulty or incorrect
cabling. Check that the ATA cables are undamaged and rated
for the Ultra DMA mode in use. If you are using removable
drive trays, they must also be compatible. Be sure that
all connections are making good contact. Problems have
also been noticed when an old drive is installed on the
same ATA channel as an Ultra DMA 66 (or faster) drive.
Lastly, these errors can indicate that the drive is
failing. Most drive vendors provide testing software for
their drives, so test your drive, and, if necessary, back
up your data and replace it.The &man.atacontrol.8; utility can be used to show and
select the DMA or PIO modes used for each ATA device. In
particular, atacontrol mode
channel will show the
modes in use on a particular ATA channel, where the primary
channel is numbered 0, and so on.What is a lock order reversal?&a.rwatson; answered this question very succinctly on
the freebsd-current list in a thread entitled lock
order reversals - what do they mean?
&a.rwatson; on freebsd-current, December 14,
2003These warnings are generated by Witness, a run-time lock
diagnostic system found in FreeBSD -CURRENT kernels (but
removed in releases). You can read more about Witness in the
&man.witness.4; man page, which talks about its capabilities. Among
other things, Witness performs run-time lock order verification
using a combination of hard coded lock orders, and run-time
detected lock orders, and generates console warnings when lock
orders are violated. The intent of this is to detect the
potential for deadlocks due to lock order violations; it is worth
observing that Witness is actually slightly conservative, and so
it is possible to get false positives. In the event that Witness
is accurately reporting a lock order problem, it is basically
saying "If you were unlucky, a deadlock would have happened
here". There are a couple of "well known" false positives,
which we need to do a better job of documenting to prevent
spurious reports. The non-well-known ones typically correspond
to bugs in newly added locking, as lock order reversals usually
get fixed pretty quickly because Witness is busy generating
warnings :-).
See Bjoern
Zeeb's lock order reversal page for the status of
known lock order reversals.What does Called ... with the following
non-sleepable locks held mean?This means that a function that may sleep was called while
a mutex (or other unsleepable) lock was held.The reason this is an error is because mutexes are not
intended to be held for long periods of time; they are
supposed to only be held to maintain short periods of
synchronization. This programming contract allows device
drivers to use mutexes to synchronize with the rest of the kernel
during interrupts. Interrupts (under FreeBSD) may not sleep.
Hence it is imperative that no subsystem in the kernel
block for an extended period while holding a mutex.To catch such errors, assertions may be added to the kernel
that interact with the witness subsystem to emit a warning
or fatal error (depending on the system configuration) when
a potentially blocking call is made while holding a mutex.In summary, such warnings are non-fatal, however with
unfortunate timing they could cause undesirable effects
ranging from a minor blip in the system's responsiveness
to a complete system lockup.Why does buildworld/installworld die with the message
touch: not found?This error does not mean that the &man.touch.1; utility is
missing. The error is instead probably due to the dates of the
files being set sometime in the future. If your CMOS-clock is
set to local time you need to run the command
adjkerntz -i to adjust the kernel clock
when booting into single user mode.Commercial ApplicationsThis section is still very sparse, though we are hoping, of
course, that companies will add to it! :) The FreeBSD group has
no financial interest in any of the companies listed here but
simply lists them as a public service (and feels that commercial
interest in FreeBSD can have very positive effects on FreeBSD's
long-term viability). We encourage commercial software vendors to
send their entries here for inclusion. See the
Vendors page for a longer list.Where can I get an Office Suite for FreeBSD?The open-source OpenOffice.org office
suite works natively on FreeBSD. The &linux; version of
StarOffice,
the value-added closed-source version of OpenOffice.org, also
works on FreeBSD.FreeBSD also includes a variety of text editors,
spreadsheets, and drawing programs in the Ports
Collection.Where can I get &motif; for FreeBSD?The Open Group has released the source code to &motif; 2.2.2.
You can install the open-motif package, or
compile it from ports. Refer to
the ports section of the
Handbook for more information on how to do this.
The Open &motif; distribution only allows redistribution
if it is running on an
open source operating system.In addition, there are commercial distributions of the &motif;
software available. These, however, are not for free, but their
license allows them to be used in closed-source software.
Contact Apps2go for the
least expensive ELF &motif; 2.1.20 distribution for FreeBSD
(either &i386; or Alpha).There are two distributions, the development
edition and the runtime edition (for
much less). These distributions includes:OSF/&motif; manager, xmbind, panner, wsm.Development kit with uil, mrm, xm, xmcxx, include
and Imake files.Static and dynamic ELF libraries.Demonstration applets.Be sure to specify that you want the FreeBSD version of
&motif; when ordering (do not forget to mention the architecture
you want too)! Versions for NetBSD and OpenBSD are also sold by
Apps2go. This is currently a FTP only
download.More info
Apps2go WWW pageorsales@apps2go.com or
support@apps2go.comorphone (817) 431 8775 or +1 817 431-8775Contact Xi Graphics for an
a.out &motif; 2.0 distribution for FreeBSD.This distribution includes:OSF/&motif; manager, xmbind, panner, wsm.Development kit with uil, mrm, xm, xmcxx, include
and Imake files.Static and dynamic libraries (for use with FreeBSD
2.2.8 and earlier).Demonstration applets.Preformatted manual pages.Be sure to specify that you want the FreeBSD version
of &motif; when ordering! Versions for BSDI and &linux; are also
sold by Xi Graphics. This is currently a 4
diskette set... in the future this will change to a unified CD
distribution like their CDE.Where can I get CDE for FreeBSD?Xi Graphics used to sell CDE
for FreeBSD, but no longer do.KDE is an open
source X11 desktop which is similar to CDE in many respects.
You might also like the look and feel of xfce. KDE and xfce are both
in the ports
system.Are there any commercial high-performance X servers?Yes, Xi Graphics
sells Accelerated-X products for FreeBSD and other Intel based
systems.The Xi Graphics offering is a high performance X Server
that offers easy configuration, support for multiple concurrent
video boards and is distributed in binary form only, in a
unified diskette distribution for FreeBSD and &linux;. Xi
Graphics also offers a high performance X Server tailored for
laptop support.There is a free compatibility demo of
version 5.0 available.Xi Graphics also sells &motif; and CDE for FreeBSD (see
above).More info
Xi Graphics WWW pageorsales@xig.com
or support@xig.comorphone (800) 946 7433 or +1 303 298-7478.Are there any Database systems for FreeBSD?Yes! See the
Commercial Vendors section of FreeBSD's Web site.Also see the
Databases section of the Ports collection.Can I run &oracle; on FreeBSD?Yes. The following pages tell you exactly how to set up
&linux;-&oracle; on FreeBSD:
http://www.scc.nl/~marcel/howto-oracle.html
http://www.lf.net/lf/pi/oracle/install-linux-oracle-on-freebsdAre there any commercial web browsers available for &os;?Yes. Opera is a multi-platform web browser and is available for &os;.
See www.opera.com for details.
A version of Opera, paid for by banner ads, is also available in ports.User ApplicationsSo, where are all the user applications?Please take a look at the ports page
for info on software packages ported to FreeBSD. The list
currently tops &os.numports; and is growing daily, so come
back to check often or subscribe to the
freebsd-announce mailing list for periodic updates
on new entries.Most ports should work on the 4.X, 5.X, and 6.X branches.
Each time a FreeBSD release is made, a snapshot of the
ports tree at the time of release in also included in the
ports/ directory.We also support the concept of a
package, essentially no more than a compressed
binary distribution with a little extra intelligence
embedded in it for doing whatever custom installation work
is required. A package can be installed and uninstalled
again easily without having to know the gory details of
which files it includes.Use the package installation menu in
/stand/sysinstall (under the
post-configuration menu item) or invoke the
&man.pkg.add.1; command on the specific package files you
are interested in installing. Package files can usually be
identified by their .tgz or .tbz suffix and
CDROM distribution people will have a
packages/All directory on their CD
which contains such files. They can also be downloaded
over the net for various versions of FreeBSD at the
following locations:for 4.X-RELEASE/4-STABLE
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-4-stable/for 5.X-RELEASE/5-STABLE
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-5-stablefor 6.X-RELEASE/6-STABLE
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-6-stablefor 7-CURRENT
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/i386/packages-7-currentor your nearest local mirror site.Note that all ports may not be available as packages since
new ones are constantly being added. It is always a good idea
to check back periodically to see which packages are available
at the ftp.FreeBSD.org
master site.How do I configure INN (Internet News) for my machine?After installing the news/inn package or port, an
excellent place to start is Dave
Barr's INN Page where you will find the INN
FAQ.Does FreeBSD support &java;?Yes. Please see
http://www.FreeBSD.org/java/.Why can I not build this port on my 4.X-STABLE machine?If you are running a FreeBSD version that lags
significantly behind -CURRENT or -STABLE, you may need to
update your ports collection; see the
Keeping Up section of the Porter's Handbook for further
information on how to do this.
If you are up to date,
then someone might have committed a change to the port which
works for -CURRENT but which broke the port for -STABLE. Please
submit a bug report on this with the
&man.send-pr.1; command, since the ports
collection is supposed to work for both the -CURRENT and
-STABLE branches.I just tried to build INDEX
using make index, and it failed.
Why?First, always make sure that you have a completely
up-to-date Ports Collection. Errors that affect building
INDEX from an up-to-date copy of the
Ports Collection are high-visibility and are thus almost
always fixed immediately.However, if you are up-to-date, perhaps you are seeing
another problem. make index has a
known bug in dealing with incomplete copies of the Ports
Collection. It assumes that you have a local copy of every
single port that every other port that you have a local copy
of depends on. To explain, if you have a copy of
foo/bar on your disk, and
foo/bar depends on
baz/quux, then you must also have
a copy of baz/quux on your disk, and
the ports baz/quux depends on, and
so on. Otherwise, make index has
insufficient information to create its dependency tree.This is particularly a problem for &os; users who
utilize &man.cvsup.1; to track the Ports Collection but
choose not to install certain categories by specifying
them in refuse. In theory, one
should be able to refuse categories, but in practice
there are too many ports that depend on ports in other
categories. Until someone comes up with a solution for
this problem, the general rule is is that if you want to
build INDEX, you must have a complete
copy of the Ports Collection.There are rare cases where INDEX
will not build due to odd cases involving
WITH_* or
WITHOUT_*
variables being set in make.conf. If
you suspect that this is the case, please try to make
INDEX with those Makevars turned off
before reporting it to &a.ports;.Why is CVSup not integrated in the main FreeBSD tree?
The FreeBSD base system is designed as self-hosting - it
should be possible to build the whole operating system starting
with a very limited set of tools. Thus, the actual build tools
needed to compile the FreeBSD sources are bundled with the
sources themselves. This includes a C compiler (&man.gcc.1;),
&man.make.1;, &man.awk.1;, and similar tools.Since CVSup is written in Modula-3, adding it to the FreeBSD
base system would also require adding and maintaining a Modula-3
compiler. This would lead to both an increase in the disk space
consumed by the FreeBSD sources and additional maintenance work.
Thus, it is much easier for both the developers and users to
keep CVSup as a separate port, which can be easily installed as
a package bundled on the FreeBSD installation CDs.I updated the sources, now how do I update my installed
ports?FreeBSD does not include a port upgrading tool, but it
does have some tools to make the upgrade process somewhat
easier. You can also install additional tools to simplify
port handling.The &man.pkg.version.1; command can generate a script
that will update installed ports to the latest version in
the ports tree.&prompt.root; pkg_version -c > /tmp/myscriptThe output script must be edited by
hand before you use it. Recent versions of
&man.pkg.version.1; force this by inserting an
&man.exit.1; at the beginning of the script.You should save the output of the script, as it will note
packages that depend on the one that has been updated. These
may or may not need to be updated as well. The usual case where
they need to be updated is that a shared library has changed
version numbers, so the ports that used that library need to be
rebuilt to use the new version.Beginning with FreeBSD 5.0 (and higher revisions),
&man.pkg.version.1; no longer supports the
option.If you have the disk space, you can use the
portupgrade tool to automate all of
this. portupgrade includes various
tools to simplify package handling. It is available under
- sysutils/portupgrade.
+ ports-mgmt/portupgrade.
Since it is written in Ruby,
portupgrade is an unlikely candidate for
integration with the main FreeBSD tree. That should not
stop anyone from using it, however.If your system is up full time, the &man.periodic.8; system
can be used to generate a weekly list of ports that might need
updating by setting
weekly_status_pkg_enable="YES" in
/etc/periodic.conf.Why is /bin/sh so minimal? Why does
FreeBSD not use bash or another shell?Because &posix; says that there shall be such a shell.The more complicated answer: many people need to write shell
scripts which will be portable across many systems. That is why
&posix; specifies the shell and utility commands in great detail.
Most scripts are written in Bourne shell, and because several
important programming interfaces (&man.make.1;, &man.system.3;,
&man.popen.3;, and analogues in higher-level scripting
languages like Perl and Tcl) are specified to use the Bourne
shell to interpret commands. Because the Bourne shell is so
often and widely used, it is important for it to be quick to
start, be deterministic in its behavior, and have a small
memory footprint.The existing implementation is our best effort at meeting as
many of these requirements simultaneously as we can. In order to
keep /bin/sh small, we have not provided many
of the convenience features that other shells have. That is why the
Ports Collection includes more featureful shells like bash, scsh,
tcsh, and zsh. (You can compare for yourself the memory
utilization of all these shells by looking at the
VSZ and RSS columns in a ps
-u listing.)Why do &netscape; and Opera take so long to
start?The usual answer is that DNS on your system is
misconfigured. Both &netscape; and Opera perform DNS checks
when starting up. The browser will not appear on your
desktop until the program either gets a response or
determines that the system has no network
connection.I updated parts of the Ports Collection using CVSup, and
now many ports fail to build with mysterious error messages!
What happened? Is the Ports Collection broken in some major
way?If you only update parts of the Ports Collection, using
one of its CVSup subcollections and not the
ports-all CVSup collection, you should
always update the
ports-base subcollection too! The reasons
are described in the
Handbook.How do I create audio CDs from my MIDI files?To create audio CDs from MIDI files, first
install audio/timidity++
from ports then install manually the GUS patches set by Eric
A. Welsh, available at .
After timidity++ has been installed properly, midi files may
be converted to wav files with the following command
line:&prompt.user; timidity -Ow -s 44100 -o /tmp/juke/01.wav 01.midThe wav files can then be converted to other formats
or burned onto audio CDs, as described in the FreeBSD
Handbook.Kernel ConfigurationI would like to customize my kernel. Is it difficult?Not at all! Check out the
kernel config section of the Handbook.We recommend that you make a dated snapshot of
your new /kernel called
/kernel.YYMMDD after you get it
working properly. Also back up your new
/modules directory to
/modules.YYMMDD. That way, if
you make a mistake the next time you play with your
configuration you can boot the backup kernel instead
of having to fall back to
kernel.GENERIC. This is
particularly important if you are now booting from a
controller that GENERIC does not support.My kernel compiles fail because
_hw_float is missing. How do I solve
this problem?You probably removed npx0
(see &man.npx.4;) from your kernel configuration file
because you do not have a math co-processor. The
npx0 device is
MANDATORY. Somewhere inside your
hardware lies a device that provides hardware
floating-point support, even if it is no longer a separate
device as used in the good old 386 days. You
must include the
npx0 device. Even if you manage
to build a kernel without npx0
support, it will not boot anyway. Why is my kernel so big (over 10MB)?Chances are, you compiled your kernel in
debug mode. Kernels built in debug
mode contain many symbols that are used for debugging,
thus greatly increasing the size of the kernel. Note that
there will be little or no performance decrease from
running a debug kernel, and it is useful to keep one
around in case of a system panic.However, if you are running low on disk space, or
you simply do not want to run a debug kernel, make sure
that both of the following are true:You do not have a line in your kernel
configuration file that reads:makeoptions DEBUG=-gYou are not running &man.config.8; with
the option.Either of the above settings will cause your kernel to
be built in debug mode. As long as you make sure you
follow the steps above, you can build your kernel
normally, and you should notice a fairly large size
decrease; most kernels tend to be around 1.5MB to
2MB.Why do I get interrupt conflicts with multi-port serial
code?When I compile a kernel
with multi-port serial code, it tells me that only the first
port is probed and the rest skipped due to interrupt conflicts.
How do I fix this?The problem here is that
FreeBSD has code built-in to keep the kernel from getting
trashed due to hardware or software conflicts. The way to fix
this is to leave out the IRQ settings on all but one port. Here
is an example:#
# Multiport high-speed serial line - 16550 UARTS
#
device sio2 at isa? port 0x2a0 tty irq 5 flags 0x501 vector siointr
device sio3 at isa? port 0x2a8 tty flags 0x501 vector siointr
device sio4 at isa? port 0x2b0 tty flags 0x501 vector siointr
device sio5 at isa? port 0x2b8 tty flags 0x501 vector siointrWhy does every kernel I try to build fail to compile, even
GENERIC?There are a number of possible causes for this problem.
They are, in no particular order:You are not using the new make
buildkernel and make
installkernel targets, and your source tree is
different from the one used to build the currently running
system (e.g., you are compiling 4.3-RELEASE on a 4.0-RELEASE
system). If you are attempting an upgrade, please read the
/usr/src/UPDATING file, paying
particular attention to the COMMON ITEMS
section at the end.You are using the new make
buildkernel and make
installkernel targets, but you failed to assert
the completion of the make buildworld
target. The make buildkernel target
relies on files generated by the make
buildworld target to complete its job
correctly.Even if you are trying to build FreeBSD-STABLE, it is possible that
you fetched the source tree at a time when it was either
being modified, or broken for other reasons; only releases
are absolutely guaranteed to be buildable, although FreeBSD-STABLE builds fine the
majority of the time. If you have not already done so, try
re-fetching the source tree and see if the problem goes
away. Try using a different server in case the one you are
using is having problems.How can I verify which scheduler is in use on a
running system?If you are running &os; version 5.2.1 or earlier, check for
the existence of the kern.quantum sysctl.
If you have it, you should see something like this:&prompt.user; sysctl kern.quantum
kern.sched.quantum: 99960If the kern.quantum sysctl exists, you are
using the 4BSD scheduler. If not, you will get an error printed
by &man.sysctl.8; (which you can safely ignore):&prompt.user; sysctl kern.sched.quantum
sysctl: unknown oid 'kern.sched.quantum'In &os; version 5.3-RELEASE and later, the name of the
scheduler currently being used is directly available as the value
of the kern.sched.name sysctl:&prompt.user; sysctl kern.sched.name
kern.sched.name: 4BSDWhat is kern.quantum?kern.quantum is the maximum number of
ticks a process can run without being preempted. It is
specific to the 4BSD scheduler, so you can use its
presence or absence to determine which scheduler is in
use. In &os; 5.X or later kern.quantum has
been renamed to kern.sched.quantum.What is kern.sched.quantum?See Disks, Filesystems, and Boot LoadersHow can I add my new hard disk to my FreeBSD system?See the Disk Formatting Tutorial at
www.FreeBSD.org.How do I move my system over to my huge new disk?The best way is to reinstall the OS on the new
disk, then move the user data over. This is highly
recommended if you have been tracking -STABLE for more
than one release, or have updated a release instead of
installing a new one. You can install booteasy on both
disks with &man.boot0cfg.8;, and dual boot them until
you are happy with the new configuration. Skip the
next paragraph to find out how to move the data after
doing this.Should you decide not to do a fresh install, you
need to partition and label the new disk with either
/stand/sysinstall, or &man.fdisk.8;
and &man.disklabel.8;. You should also install booteasy
on both disks with &man.boot0cfg.8;, so that you can
dual boot to the old or new system after the copying
is done. See the
formatting-media article for details on this
process.Now you have the new disk set up, and are ready
to move the data. Unfortunately, you cannot just blindly
copy the data. Things like device files (in
/dev), flags, and links tend to
screw that up. You need to use tools that understand
these things, which means &man.dump.8;.
Although it is suggested that you move the data in single user
mode, it is not required.You should never use anything but &man.dump.8; and
&man.restore.8; to move the root filesystem. The
&man.tar.1; command may work - then again, it may not.
You should also use &man.dump.8; and &man.restore.8;
if you are moving a single partition to another empty
partition. The sequence of steps to use dump to move
a partitions data to a new partition is:newfs the new partition.mount it on a temporary mount point.cd to that directory.dump the old partition, piping output to the
new one.For example, if you are going to move root to
/dev/ad1s1a, with
/mnt as the temporary mount point,
it is:&prompt.root; newfs /dev/ad1s1a
&prompt.root; mount /dev/ad1s1a /mnt
&prompt.root; cd /mnt
&prompt.root; dump 0af - / | restore xf -Rearranging your partitions with dump takes a bit more
work. To merge a partition like /var
into its parent, create the new partition large enough
for both, move the parent partition as described above,
then move the child partition into the empty directory
that the first move created:&prompt.root; newfs /dev/ad1s1a
&prompt.root; mount /dev/ad1s1a /mnt
&prompt.root; cd /mnt
&prompt.root; dump 0af - / | restore xf -
&prompt.root; cd var
&prompt.root; dump 0af - /var | restore xf -To split a directory from its parent, say putting
/var on its own partition when it was not
before, create both partitions, then mount the child partition
on the appropriate directory in the temporary mount point, then
move the old single partition:&prompt.root; newfs /dev/ad1s1a
&prompt.root; newfs /dev/ad1s1d
&prompt.root; mount /dev/ad1s1a /mnt
&prompt.root; mkdir /mnt/var
&prompt.root; mount /dev/ad1s1d /mnt/var
&prompt.root; cd /mnt
&prompt.root; dump 0af - / | restore xf -You might prefer &man.cpio.1;, &man.pax.1;,
&man.tar.1; to &man.dump.8; for user data. At the time of
this writing, these are known to lose file flag information,
so use them with caution.Will a dangerously dedicated disk endanger
my health?The installation procedure allows
you to chose two different methods in partitioning your
hard disk(s). The default way makes it compatible with other
operating systems on the same machine, by using fdisk table
entries (called slices in FreeBSD), with a
FreeBSD slice that employs partitions of its own. Optionally,
one can chose to install a boot-selector to switch between the
possible operating systems on the disk(s). The alternative uses
the entire disk for FreeBSD, and makes no attempt to be
compatible with other operating systems.So why it is called dangerous? A disk
in this mode does not contain what normal PC utilities
would consider a valid fdisk table. Depending on how well
they have been designed, they might complain at you once
they are getting in contact with such a disk, or even
worse, they might damage the BSD bootstrap without even
asking or notifying you. In addition, the
dangerously dedicated disk's layout is
known to confuse many BIOSes, including those from AWARD
(e.g. as found in HP Netserver and Micronics systems as
well as many others) and Symbios/NCR (for the popular
53C8xx range of SCSI controllers). This is not a complete
list, there are more. Symptoms of this confusion include
the read error message printed by
the FreeBSD bootstrap when it cannot find itself, as well
as system lockups when booting.Why have this mode at all then? It only saves a few kbytes
of disk space, and it can cause real problems for a new
installation. Dangerously dedicated mode's
origins lie in a desire to avoid one of the most common
problems plaguing new FreeBSD installers - matching the BIOS
geometry numbers for a disk to the disk
itself.Geometry is an outdated concept, but one
still at the heart of the PC's BIOS and its interaction with
disks. When the FreeBSD installer creates slices, it has to
record the location of these slices on the disk in a fashion
that corresponds with the way the BIOS expects to find them. If
it gets it wrong, you will not be able to boot.Dangerously dedicated mode tries to work
around this by making the problem simpler. In some cases, it
gets it right. But it is meant to be used as a last-ditch
alternative - there are better ways to solve the problem 99
times out of 100.So, how do you avoid the need for DD mode
when you are installing? Start by making a note of the geometry
that your BIOS claims to be using for your disks. You can
arrange to have the kernel print this as it boots by specifying
at the boot: prompt, or
using boot -v in the loader. Just before the
installer starts, the kernel will print a list of BIOS
geometries. Do not panic - wait for the installer to start and
then use scrollback to read the numbers. Typically the BIOS
disk units will be in the same order that FreeBSD lists your
disks, first IDE, then SCSI.When you are slicing up your disk, check that the disk
geometry displayed in the FDISK screen is correct (ie. it
matches the BIOS numbers); if it is wrong, use the
g key to fix it. You may have to do this if
there is absolutely nothing on the disk, or if the disk has been
moved from another system. Note that this is only an issue with
the disk that you are going to boot from; FreeBSD will sort
itself out just fine with any other disks you may have.Once you have got the BIOS and FreeBSD agreeing about the
geometry of the disk, your problems are almost guaranteed to be
over, and with no need for DD mode at all. If,
however, you are still greeted with the dreaded read
error message when you try to boot, it is time to cross
your fingers and go for it - there is nothing left to
lose.To return a dangerously dedicated disk
for normal PC use, there are basically two options. The first
is, you write enough NULL bytes over the MBR to make any
subsequent installation believe this to be a blank disk. You
can do this for example with&prompt.root; dd if=/dev/zero of=/dev/rda0 count=15Alternatively, the undocumented DOS
featureC:\>fdisk /mbrwill to install a new master boot record as well, thus
clobbering the BSD bootstrap.Which partitions can safely use Soft Updates? I have
heard that Soft Updates on / can cause
problems.Short answer: you can usually use Soft Updates safely
on all partitions.Long answer: There used to be some concern over using
Soft Updates on the root partition. Soft Updates has two
characteristics that caused this. First, a Soft Updates
partition has a small chance of losing data during a
system crash. (The partition will not be corrupted; the
data will simply be lost.) Also, Soft Updates can cause
temporary space shortages.When using Soft Updates, the kernel can take up to
thirty seconds to actually write changes to the physical
disk. If you delete a large file, the file still resides
on disk until the kernel actually performs the deletion.
This can cause a very simple race condition. Suppose you
delete one large file and immediately create another large
file. The first large file is not yet actually removed
from the physical disk, so the disk might not have enough
room for the second large file. You get an error that the
partition does not have enough space, although you know
perfectly well that you just released a large chunk of
space! When you try again mere seconds later, the file
creation works as you expect. This has left more than one
user scratching his head and doubting his sanity, the
FreeBSD filesystem, or both.If a system should crash after the kernel accepts a
chunk of data for writing to disk, but before that data is
actually written out, data could be lost or corrupted.
This risk is extremely small, but generally manageable.
Use of IDE write caching greatly increases this risk; it
is strongly recommended that you disable IDE write caching
when using Soft Updates.These issues affect all partitions using Soft Updates.
So, what does this mean for the root partition?Vital information on the root partition changes very
rarely. Files such as /kernel and
the contents of /etc only change
during system maintenance, or when users change their
passwords. If the system crashed during the
thirty-second window after such a change is made, it is
possible that data could be lost. This risk is negligible
for most applications, but you should be aware that it
exists. If your system cannot tolerate this much risk,
do not use Soft Updates on the root filesystem!/ is traditionally one of the
smallest partitions. By default, FreeBSD puts the
/tmp directory on
/. If you have a busy
/tmp, you might see intermittent
space problems. Symlinking /tmp to
/var/tmp will solve this
problem.What is inappropriate about my ccd?The symptom of this is:&prompt.root; ccdconfig -C
ccdconfig: ioctl (CCDIOCSET): /dev/ccd0c: Inappropriate file type or formatThis usually happens when you are trying to concatenate
the c partitions, which default to type
unused. The ccd driver requires the
underlying partition type to be FS_BSDFFS. Edit the disklabel
of the disks you are trying to concatenate and change the types
of partitions to 4.2BSD.Why can I not edit the disklabel on my ccd?The symptom of this is:&prompt.root; disklabel ccd0
(it prints something sensible here, so let us try to edit it)
&prompt.root; disklabel -e ccd0
(edit, save, quit)
disklabel: ioctl DIOCWDINFO: No disk label on disk;
use "disklabel -r" to install initial labelThis is because the disklabel returned by ccd is actually
a fake one that is not really on the disk.
You can solve this problem by writing it back explicitly,
as in:&prompt.root; disklabel ccd0 > /tmp/disklabel.tmp
&prompt.root; disklabel -Rr ccd0 /tmp/disklabel.tmp
&prompt.root; disklabel -e ccd0
(this will work now)Can I mount other foreign filesystems under FreeBSD?FreeBSD supports a variety of other
filesystems.Digital UNIXUFS CDROMs can be mounted directly on FreeBSD.
Mounting disk partitions from Digital UNIX and other
systems that support UFS may be more complex, depending
on the details of the disk partitioning for the operating
system in question.&linux;FreeBSD supports ext2fs
partitions. See &man.mount.ext2fs.8; for more
information.&windowsnt;FreeBSD includes a read-only NTFS driver. For
more information, see &man.mount.ntfs.8;.
FATFreeBSD includes a read-write FAT driver. For
more information, see &man.mount.msdosfs.8;.ReiserFSFreeBSD includes a read-only ReiserFS driver. For
more information, see &man.mount.reiserfs.8;.FreeBSD also supports network filesystems such as NFS
(see &man.mount.nfs.8;), NetWare (see &man.mount.nwfs.8;),
and Microsoft-style SMB filesystems (see
&man.mount.smbfs.8;).
How do I mount a secondary DOS partition?The secondary DOS partitions are found after ALL the
primary partitions. For example, if you have an
E partition as the second DOS partition on
the second SCSI drive, you need to create the special files
for slice 5 in /dev,
then mount /dev/da1s5:&prompt.root; cd /dev
&prompt.root; sh MAKEDEV da1s5
&prompt.root; mount -t msdos /dev/da1s5 /dos/eYou can omit this step if you are running FreeBSD
5.0-RELEASE or newer with &man.devfs.5;
enabled.Is there a cryptographic filesystem for &os;?Yes. FreeBSD 5.0 includes &man.gbde.8;, and FreeBSD 6.0
added &man.geli.8;. For earlier releases, see the security/cfs port.How can I use the &windowsnt; loader to boot FreeBSD?The general idea is that you copy the first sector of your
native root FreeBSD partition into a file in the DOS/&windowsnt;
partition. Assuming you name that file something like
c:\bootsect.bsd (inspired by
c:\bootsect.dos), you can then edit the
c:\boot.ini file to come up with something
like this:[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Windows NT"
C:\BOOTSECT.BSD="FreeBSD"
C:\="DOS"If FreeBSD is installed on the same disk as the &windowsnt; boot
partition simply copy /boot/boot1 to
C:\BOOTSECT.BSD. However, if FreeBSD is
installed on a different disk /boot/boot1
will not work, /boot/boot0 is needed./boot/boot0 needs to be installed
using sysinstall by selecting the FreeBSD boot manager on
the screen which asks if you wish to use a boot
manager. This is because /boot/boot0
has the partition table area filled with NULL characters
but sysinstall copies the partition table before copying
/boot/boot0 to the MBR.Do not simply copy /boot/boot0
instead of /boot/boot1; you will
overwrite your partition table and render your computer
un-bootable!When the FreeBSD boot manager runs it records the last
OS booted by setting the active flag on the partition table
entry for that OS and then writes the whole 512-bytes of itself
back to the MBR so if you just copy
/boot/boot0 to
C:\BOOTSECT.BSD then it writes an empty
partition table, with the active flag set on one entry, to the
MBR.How do I boot FreeBSD and &linux; from LILO?If you have FreeBSD and &linux; on the same disk, just follow
LILO's installation instructions for booting a non-&linux;
operating system. Very briefly, these are:Boot &linux;, and add the following lines to
/etc/lilo.conf:other=/dev/hda2
table=/dev/hda
label=FreeBSD(the above assumes that your FreeBSD slice is known to
&linux; as /dev/hda2; tailor to
suit your setup). Then, run lilo as
root and you should be done.If FreeBSD resides on another disk, you need to add
loader=/boot/chain.b to the LILO entry.
For example:other=/dev/dab4
table=/dev/dab
loader=/boot/chain.b
label=FreeBSDIn some cases you may need to specify the BIOS drive number
to the FreeBSD boot loader to successfully boot off the second
disk. For example, if your FreeBSD SCSI disk is probed by BIOS
as BIOS disk 1, at the FreeBSD boot loader prompt you need to
specify:Boot: 1:da(0,a)/kernelYou can configure
&man.boot.8;
to automatically do this for you at boot time.The
&linux;+FreeBSD mini-HOWTO is a good reference for
FreeBSD and &linux; interoperability issues.How do I boot &os; and &linux; using GRUBBooting &os; using GRUB is very simple. Just
add the following to your configuration file
/boot/grub/grub.conf.title FreeBSD 6.1
root (hd0,a)
kernel /boot/loader
Where hd0,a points to your root partition
on the first disk. If you need to specify which slice number
should be used, use something like this (hd0,2,a).
By default, if the slice number is omitted, GRUB searches the
first slice which has 'a' partition.How do I boot FreeBSD and &linux; using BootEasy?Install LILO at the start of your &linux; boot partition
instead of in the Master Boot Record. You can then boot LILO
from BootEasy.If you are running &windows; 95 and &linux; this is recommended
anyway, to make it simpler to get &linux; booting again if you
should need to reinstall &windows; 95 (which is a Jealous
Operating System, and will bear no other Operating Systems in
the Master Boot Record).How do I change the boot prompt from ??? to
something more meaningful?You can not do that with the standard boot manager without
rewriting it. There are a number of other boot managers
in the sysutils ports category that
provide this functionality.I have a new removable drive, how do I use it?Whether it is a removable drive like a &iomegazip; or an EZ drive
(or even a floppy, if you want to use it that way), or a new
hard disk, once it is installed and recognized by the system,
and you have your cartridge/floppy/whatever slotted in, things
are pretty much the same for all devices.(this section is based on
Mark Mayo's ZIP FAQ)If it is a ZIP drive or a floppy, you have already got a DOS
filesystem on it, you can use a command like this:&prompt.root; mount -t msdos /dev/fd0c /floppyif it is a floppy, or this:&prompt.root; mount -t msdos /dev/da2s4 /zipfor a ZIP disk with the factory configuration.For other disks, see how they are laid out using
&man.fdisk.8; or
&man.sysinstall.8;.The rest of the examples will be for a ZIP drive on da2,
the third SCSI disk.Unless it is a floppy, or a removable you plan on sharing
with other people, it is probably a better idea to stick a BSD
filesystem on it. You will get long filename support, at least a
2X improvement in performance, and a lot more stability. First,
you need to redo the DOS-level partitions/filesystems. You can
either use &man.fdisk.8; or
/stand/sysinstall, or for a small drive
that you do not want to bother with multiple operating system
support on, just blow away the whole FAT partition table
(slices) and just use the BSD partitioning:&prompt.root; dd if=/dev/zero of=/dev/rda2 count=2
&prompt.root; disklabel -Brw da2 autoYou can use disklabel or
/stand/sysinstall to create multiple BSD
partitions. You will certainly want to do this if you are adding
swap space on a fixed disk, but it is probably irrelevant on a
removable drive like a ZIP.Finally, create a new filesystem, this one is on our ZIP
drive using the whole disk:&prompt.root; newfs /dev/rda2cand mount it:&prompt.root; mount /dev/da2c /zipand it is probably a good idea to add a line like this
to /etc/fstab (see &man.fstab.5;) so
you can just type mount /zip in the
future:/dev/da2c /zip ffs rw,noauto 0 0Why do I get Incorrect super block when
mounting a CDROM?You have to tell &man.mount.8; the type of the device
that you want to mount. This is described in the Handbook section on
optical media, specifically the section Using Data
CDs.Why do I get Device not
configured when mounting a CDROM?This generally means that there is no CDROM in the
CDROM drive, or the drive is not visible on the
bus. Please see the Using Data
CDs section of the Handbook for a detailed
discussion of this issue.Why do all non-English characters in filenames show up as
? on my CDs when mounted in FreeBSD?Your CDROM probably uses the Joliet
extension for storing information about files and
directories. This is discussed in the Handbook chapter on
creating and
using CDROMs, specifically the section on Using Data
CDROMs.I burned a CD under FreeBSD and now I can not read it
under any other operating system. Why?You most likely burned a raw file to your CD, rather
than creating an ISO 9660 filesystem. Take a look at the
Handbook
chapter on creating CDROMs, particularly the
section on burning raw
data CDs.How can I create an image of a data CD?This is discussed in the Handbook section on duplicating
data CDs. For more on working with CDROMs, see the
Creating CDs
Section in the Storage chapter in the
Handbook.Why can I not mount an audio
CD?If you try to mount an audio CD, you will get an error
like cd9660: /dev/acd0c: Invalid
argument. This is because
mount only works on filesystems. Audio
CDs do not have filesystems; they just have data. You
need a program that reads audio CDs, such as the
audio/xmcd port.How do I mount a multi-session CD?By default, &man.mount.8; will attempt to mount the
last data track (session) of a CD. If you would like to
load an earlier session, you must use the
command line argument. Please see
&man.mount.cd9660.8; for specific examples.How do I let ordinary users mount floppies, CDROMs and
other removable media?Ordinary users can be permitted to mount devices. Here is
how:As root set the sysctl variable
vfs.usermount to
1.&prompt.root; sysctl -w vfs.usermount=1As root assign the appropriate
permissions to the block device associated with the
removable media.For example, to allow users to mount the first floppy
drive, use:&prompt.root; chmod 666 /dev/fd0To allow users in the group
operator to mount the CDROM drive,
use:&prompt.root; chgrp operator /dev/acd0c
&prompt.root; chmod 640 /dev/acd0cIf you are running &os; 5.X or later, you will need to alter
/etc/devfs.conf to make these changes
permanent across reboots.As root, add the necessary lines to
/etc/devfs.conf. For example, to allow
users to mount the first floppy drive add:# Allow all users to mount the floppy disk.
own /dev/fd0 root:operator
perm /dev/fd0 0666To allow users in the group operator
to mount the CD-ROM drive add:# Allow members of the group operator to mount CD-ROMs.
own /dev/acd0 root:operator
perm /dev/acd0 0660Finally, add the line
vfs.usermount=1
to the file /etc/sysctl.conf so
that it is reset at system boot time.All users can now mount the floppy
/dev/fd0 onto a directory that they
own:&prompt.user; mkdir ~/my-mount-point
&prompt.user; mount -t msdos /dev/fd0 ~/my-mount-pointUsers in group operator can now
mount the CDROM /dev/acd0c onto a
directory that they own:&prompt.user; mkdir ~/my-mount-point
&prompt.user; mount -t cd9660 /dev/acd0c ~/my-mount-pointUnmounting the device is simple:&prompt.user; umount ~/my-mount-pointEnabling vfs.usermount, however,
has negative security implications. A better way to
access &ms-dos; formatted media is to use the
emulators/mtools
package in the ports collection.The device name used in the previous examples must be
changed according to your configuration.The du and df
commands show different amounts of disk space available.
What is going on?You need to understand what du and
df really do. du
goes through the directory tree, measures how large each
file is, and presents the totals. df
just asks the filesystem how much space it has left. They
seem to be the same thing, but a file without a directory
entry will affect df but not
du.When a program is using a file, and you delete the
file, the file is not really removed from the filesystem
until the program stops using it. The file is immediately
deleted from the directory listing, however. You can see
this easily enough with a program such as
more. Assume you have a file large
enough that its presence affects the output of
du and df. (Since
disks can be so large today, this might be a
very large file!) If you delete this
file while using more on it,
more does not immediately choke and
complain that it cannot view the file. The entry is
simply removed from the directory so no other program or
user can access it. du shows that it
is gone — it has walked the directory tree and the file
is not listed. df shows that it is
still there, as the filesystem knows that
more is still using that space. Once
you end the more session,
du and df will
agree.Note that Soft Updates can delay the freeing of disk
space; you might need to wait up to 30 seconds for the
change to be visible!This situation is common on web servers. Many people
set up a FreeBSD web server and forget to rotate the log
files. The access log fills up /var.
The new administrator deletes the file, but the system
still complains that the partition is full. Stopping and
restarting the web server program would free the file,
allowing the system to release the disk space. To prevent
this from happening, set up &man.newsyslog.8;.How can I add more swap space?In the Configuration and
Tuning section of the Handbook, you will find a
section
describing how to do this.Why does &os; see my disk as smaller than the
manufacturer says it is?Disk manufacturers calculate gigabytes as a billion bytes
each, whereas &os; calculates them as 1,073,741,824 bytes
each. This explains why, for example, &os;'s boot messages
will report a disk that supposedly has 80GB as holding
76319MB.Also note that &os; will (by default)
reserve 8% of the disk
space.How is it possible for a partition to be more than 100%
full?A portion of each UFS partition (8%, by default) is
reserved for use by the operating system and the
root user.
&man.df.1; does not count that space when
calculating the Capacity column, so it can
exceed 100%. Also, you will notice that the
Blocks column is always greater than the
sum of the Used and
Avail columns, usually by a factor of
8%.For more details, look up the option
in &man.tunefs.8;.System AdministrationWhere are the system start-up configuration files?The primary configuration file is
/etc/defaults/rc.conf (see
&man.rc.conf.5;) System startup scripts such as
/etc/rc and
/etc/rc.d (see &man.rc.8;) just
include this file. Do not edit this
file! Instead, if there is any entry in
/etc/defaults/rc.conf that you want
to change, you should copy the line into
/etc/rc.conf and change it
there.For example, if you wish to start named, the included
DNS server, all you need to do is:&prompt.root; echo named_enable="YES" >> /etc/rc.confTo start up local services, place shell scripts in the
/usr/local/etc/rc.d directory. These
shell scripts should be set executable, and end with a
.sh.How do I add a user easily?Use the &man.adduser.8; command, or the &man.pw.8;
command for more complicated situations.To remove the user, use the &man.rmuser.8; command or,
if necessary, &man.pw.8;.Why do I keep getting messages like root: not
found after editing my crontab file?This is normally caused by editing the system crontab
(/etc/crontab) and then using
&man.crontab.1; to install it:&prompt.root; crontab /etc/crontabThis is not the correct way to do things. The system
crontab has a different format to the per-user crontabs
which &man.crontab.1; updates (the &man.crontab.5; manual
page explains the differences in more detail).If this is what you did, the extra crontab is simply a
copy of /etc/crontab in the wrong
format it. Delete it with the command:&prompt.root; crontab -rNext time, when you edit
/etc/crontab, you should not do
anything to inform &man.cron.8; of the changes, since it
will notice them automatically.If you want something to be run once per day, week, or
month, it is probably better to add shell scripts
/usr/local/etc/periodic, and let the
&man.periodic.8; command run from the system cron schedule
it with the other periodic system tasks.The actual reason for the error is that the system
crontab has an extra field, specifying which user to run the
command as. In the default system crontab provided with
FreeBSD, this is root for all entries.
When this crontab is used as the root
user's crontab (which is not the
same as the system crontab), &man.cron.8; assumes the string
root is the first word of the command to
execute, but no such command exists.Why do I get the error, you are not in the correct
group to su root when I try to su to
root?This is a security feature. In order to su to
root (or any other account with superuser
privileges), you must be in the wheel
group. If this feature were not there, anybody with an account
on a system who also found out root's
password would be able to gain superuser level access to the
system. With this feature, this is not strictly true;
&man.su.1; will prevent them from even trying to enter the
password if they are not in wheel.To allow someone to su to root, simply
put them in the wheel group.I made a mistake in rc.conf,
or another startup file, and
now I cannot edit it because the filesystem is read-only.
What should I do?When you get the prompt to enter the shell
pathname, simply press ENTER, and run
mount / to re-mount the root filesystem in
read/write mode. You may also need to run mount -a -t
ufs to mount the filesystem where your favorite
editor is defined. If your favorite editor is on a network
filesystem, you will need to either configure the network
manually before you can mount network filesystems, or use an
editor which resides on a local filesystem, such as
&man.ed.1;.If you intend to use a full screen editor such
as &man.vi.1; or &man.emacs.1;, you may also need to
run export TERM=cons25 so that these
editors can load the correct data from the &man.termcap.5;
database.Once you have performed these steps, you can edit
/etc/rc.conf as you usually would
to fix the syntax error. The error message displayed
immediately after the kernel boot messages should tell you
the number of the line in the file which is at fault.Why am I having trouble setting up my printer?Please have a look at the Handbook entry on printing. It
should cover most of your problem. See the
Handbook entry on printing.Some printers require a host-based driver to do any
kind of printing. These so-called
WinPrinters are not natively supported by
FreeBSD. If your printer does not work in DOS or &windowsnt;
4.0, it is probably a WinPrinter. Your only hope of
getting one of these to work is to check if the print/pnm2ppa port supports
it.How can I correct the keyboard mappings for my system?Please see the Handbook section on using
localization, specifically the section on console
setup.Why do I get messages like: unknown: <PNP0303>
can't assign resources on boot?The following is an excerpt from a post to the
freebsd-current mailing list.
&a.wollman;, 24 April 2001The can't assign resources messages
indicate that the devices are legacy ISA devices for which a
non-PnP-aware driver is compiled into the kernel. These
include devices such as keyboard controllers, the
programmable interrupt controller chip, and several other
bits of standard infrastructure. The resources cannot be
assigned because there is already a driver using those
addresses.
Why can I not get user quotas to work properly?It is possible that your kernel is not configured to use
quotas. If this is the case, you will need to add the following
line to your kernel configuration file and recompile:options QUOTAPlease read the Handbook
entry on quotas for full details.Do not turn on quotas on /.Put the quota file on the filesystem that the quotas
are to be enforced on, i.e.:FilesystemQuota file/usr/usr/admin/quotas/home/home/admin/quotas……Does FreeBSD support System V IPC primitives?Yes, FreeBSD supports System V-style IPC, including
shared memory, messages and semaphores, in the GENERIC
kernel. In a custom kernel, enable this support by adding
the following lines to your kernel config.options SYSVSHM # enable shared memory
options SYSVSEM # enable for semaphores
options SYSVMSG # enable for messagingRecompile and install your kernel.What other mail-server software can I use instead of
Sendmail?Sendmail is
the default mail-server software for FreeBSD, but you can
easily replace it with one of the other MTA (for instance,
an MTA installed from the ports).There are various alternative MTAs in the ports tree
already, with mail/exim, mail/postfix, mail/qmail, and mail/zmailer being some of the
most popular choices.Diversity is nice, and the fact that you have many
different mail-servers to chose from is considered a
good thing; therefore try to avoid
asking questions like Is Sendmail better than
Qmail? in the mailing lists. If you do feel like
asking, first check the mailing list archives. The
advantages and disadvantages of each and every one of the
available MTAs have already been discussed a few
times.I have forgotten the root password! What
do I do?Do not panic! Restart the system, type
boot -s at the Boot: prompt to
enter Single User mode. At the question about the shell to
use, hit ENTER. You will be dropped to a &prompt.root;
prompt. Enter mount -u / to remount
your root filesystem read/write, then run mount
-a to remount all the filesystems. Run
passwd root to change the
root password then run &man.exit.1;
to continue booting.How do I keep ControlAltDelete
from rebooting the system?If you are using syscons (the default console driver)
build and install a new kernel with the
lineoptions SC_DISABLE_REBOOTin the configuration file. If you use the PCVT console
driver, use the following kernel configuration line
instead.options PCVT_CTRL_ALT_DELHow do I reformat DOS text files to &unix; ones?Use this perl command:&prompt.user; perl -i.bak -npe 's/\r\n/\n/g' file ...file is the file(s) to process. The modification is done
in-place, with the original file stored with a .bak
extension.Alternatively you can use the
&man.tr.1;
command:&prompt.user; tr -d '\r' < dos-text-file > unix-filedos-text-file is the file
containing DOS text while unix-file
will contain the converted output. This can be quite a bit
faster than using perl.How do I kill processes by name?Use &man.killall.1;.Why is su bugging me about not being in
root's ACL?The error comes from the Kerberos distributed
authentication system. The problem is not fatal but annoying.
You can either run su with the -K option, or uninstall
Kerberos as described in the next question.How do I uninstall Kerberos?To remove Kerberos from the system, reinstall the bin
distribution for the release you are running. If you have
the CDROM, you can mount the cd (we will assume on /cdrom)
and run&prompt.root; cd /cdrom/bin
&prompt.root; ./install.shAlternately, you can remove all
MAKE_KERBEROS options from
/etc/make.conf and rebuild
world.What happened to
/dev/MAKEDEV?FreeBSD 5.X and beyond use the &man.devfs.8; device-on-demand
system. Device drivers automatically create new device
nodes as they are needed, obsoleting
/dev/MAKEDEV.If you are running FreeBSD 4.X or earlier and
/dev/MAKEDEV is missing, then you
really do have a problem. Grab a copy from the system
source code, probably in
/usr/src/etc/MAKEDEV.How do I add pseudoterminals to the system?If you have lots of telnet, ssh, X, or screen users,
you will probably run out of pseudoterminals. Here is how to
add more:Build and install a new kernel with the linepseudo-device pty 256in the configuration file.Run the commands&prompt.root; cd /dev
&prompt.root; sh MAKEDEV pty{1,2,3,4,5,6,7}to make 256 device nodes for the new terminals.Edit /etc/ttys and add lines
for each of the 256 terminals. They should match the form
of the existing entries, i.e. they look likettyqc none networkThe order of the letter designations is
tty[pqrsPQRS][0-9a-v], using a
regular expression. Reboot the system with the new kernel and you are
ready to go.Why can I not create the snd0 device?There is no snd device. The name
is used as a shorthand for the various devices that make up the
FreeBSD sound driver, such as mixer,
sequencer, and
dsp.To create these devices you should&prompt.root; cd /dev
&prompt.root; sh MAKEDEV snd0You can omit this step if you are running FreeBSD
5.0-RELEASE or newer with &man.devfs.5;
enabled.How do I re-read /etc/rc.conf and
re-start /etc/rc without a
reboot?Go into single user mode and then back to multi user
mode.On the console do:&prompt.root; shutdown now
(Note: without -r or -h)
&prompt.root; return
&prompt.root; exitI tried to update my system to the latest -STABLE, but
got -BETAx, -RC or -PRERELEASE! What is going on?Short answer: it is just a name. RC stands for
Release Candidate. It signifies that a
release is imminent. In FreeBSD, -PRERELEASE is typically
synonymous with the code freeze before a release. (For
some releases, the -BETA label was used in the same way as
-PRERELEASE.)Long answer: FreeBSD derives its releases from one of
two places. Major, dot-zero, releases, such as
4.0-RELEASE and 5.0-RELEASE, are branched from the head of
the development stream, commonly referred to as -CURRENT. Minor releases, such
as 4.1-RELEASE or 5.2-RELEASE, have been snapshots of the
active -STABLE branch.
Starting with 4.3-RELEASE, each release also now has its
own branch which can be tracked by people requiring an
extremely conservative rate of development (typically only
security advisories).When a release is about to be made, the branch from
which it will be derived from has to undergo a certain
process. Part of this process is a code freeze. When a
code freeze is initiated, the name of the branch is
changed to reflect that it is about to become a release.
For example, if the branch used to be called 4.5-STABLE,
its name will be changed to 4.6-PRERELEASE to signify the
code freeze and signify that extra pre-release testing
should be happening. Bug fixes can still be committed to
be part of the release. When the source code is in shape
for the release the name will be changed to 4.6-RC to
signify that a release is about to be made from it. Once
in the RC stage, only the most critical bugs found can be
fixed. Once the release (4.6-RELEASE in this example) and
release branch have been made, the branch will be renamed
to 4.6-STABLE.For more information on version numbers and the
various CVS branches, refer to the
Release
Engineering article.I tried to install a new kernel, and the chflags
failed. How do I get around this?Short answer: You are probably at security level
greater than 0. Reboot directly to single user mode to
install the kernel.Long answer: FreeBSD disallows changing system flags
at security levels greater than 0. You can check your
security level with the command:&prompt.root; sysctl kern.securelevelYou cannot lower the security level; you have to boot to
single mode to install the kernel, or change the security
level in /etc/rc.conf then reboot. See
the &man.init.8; manual page for details on securelevel, and see
/etc/defaults/rc.conf and the
&man.rc.conf.5; manual page for more information on
rc.conf.I cannot change the time on my system by more than one second!
How do I get around this?Short answer: You are probably at security level
greater than 1. Reboot directly to single user mode to
change the date.Long answer: FreeBSD disallows changing the time by
more that one second at security levels greater than 1. You
can check your security level with the command:&prompt.root; sysctl kern.securelevelYou cannot lower the security level; you have to boot
to single mode to change the date, or change the security
level in /etc/rc.conf then
reboot. See the &man.init.8; manual page for details on
securelevel, and see
/etc/defaults/rc.conf and the
&man.rc.conf.5; manual page for more information on
rc.conf.Why is rpc.statd using 256 megabytes of
memory?No, there is no memory leak, and it is not using 256 Mbytes
of memory. For convenience, rpc.statd maps an
obscene amount of memory into its address space.
There is nothing terribly wrong with this from a technical
standpoint; it just throws off things like &man.top.1; and
&man.ps.1;.&man.rpc.statd.8; maps its status file (resident on
/var) into its address space; to save
worrying about remapping it later when it needs to grow, it maps
it with a generous size. This is very evident from the source
code, where one can see that the length argument to &man.mmap.2;
is 0x10000000, or one sixteenth of the
address space on an IA32, or exactly 256MB.Why can I not unset the schg file
flag?You are running at an elevated (i.e., greater than 0)
securelevel. Lower the securelevel and try again. For more
information, see the FAQ entry on
securelevel and the &man.init.8; manual page.Why does SSH authentication through
.shosts not work by default in recent
versions of FreeBSD?The reason why .shosts
authentication does not work by default in more recent
versions of FreeBSD is because &man.ssh.1;
is not installed suid root by default. To
fix this, you can do one of the
following:As a permanent fix, set
ENABLE_SUID_SSH to true
in /etc/make.conf and rebuild ssh
(or run make world).As a temporary fix, change the mode on
/usr/bin/ssh to 4555
by running chmod 4555 /usr/bin/ssh as
root. Then add
ENABLE_SUID_SSH= true to
/etc/make.conf so the change takes
effect the next time make world is
run.What is vnlru?vnlru flushes and frees vnodes when
the system hits the kern.maxvnodes
limit. This kernel thread sits mostly idle, and only
activates if you have a huge amount of RAM and are
accessing tens of thousands of tiny files.What do the various memory states displayed by
top mean?Active: pages recently
statistically used.Inactive: pages
recently statistically unused.Cache: (most often)
pages that have percolated from inactive to a status
where they maintain their data, but can often be
immediately reused (either with their old association,
or reused with a new association.) There can be certain
immediate transitions from active to cache state if the
page is known to be clean (unmodified), but that
transition is a matter of policy, depending upon the
algorithm choice of the VM system
maintainer.Free: pages without
data content, and can be immediately used in certain
circumstances where cache pages might be ineligible.
Free pages can be reused at interrupt or process
state.Wired: pages that are
fixed into memory, usually for kernel purposes, but also
sometimes for special use in
processes.Pages are most often written to disk (sort of a VM
sync) when they are in the inactive state, but active
pages can also be synced (but requires the
availability of certain CPU features.) This depends upon
the CPU tracking of the modified bit being available,
and in certain situations there can be an advantage for a
block of VM pages to be synced, whether they are active or
inactive. In most common cases, it is best to think of
the inactive queue to be a queue of relatively unused
pages that might or might not be in the process of being
written to disk. Cached pages are already synced, not
mapped, but available for immediate process use with their
old association or with a new association. Free pages are
available at interrupt level, but cached or free pages can
be used at process state for reuse. Cache pages are not
adequately locked to be available at interrupt
level.There are some other flags (e.g., busy flag or busy
count) that might modify some of the rules that I
described.How much free memory is available?There are a couple of kinds of free
memory. One kind is the amount of memory
immediately available without paging anything else out.
That is approximately the size of cache queue + size of
free queue (with a derating factor, depending upon system
tuning.) Another kind of free memory is
the total amount of VM space. That can
be complex, but is dependent upon the amount of swap space
and memory. Other kinds of free memory
descriptions are also possible, but it is relatively
useless to define these, but rather it is important to
make sure that the paging rate is kept low, and to avoid
running out of swap space.What is /var/empty? I can not
delete it!/var/empty is a directory that the
&man.sshd.8; program uses when performing privilege separation.
The /var/empty directory is empty, owned by
root and has the schg
flag set.Although it is not recommended to delete this directory, to
do so you will need to unset the schg flag
first. See the &man.chflags.1; manual page for more information
(and bear in mind the answer to
the question on unsetting the schg flag).
The X Window System and Virtual ConsolesWhat is the X Window System?The X Window System is the most widely available windowing system
capable of running on &unix; or &unix; like systems, including
&os;. The X.Org
Foundation administers the X protocol
standards. The current release of the specification
is 11.6, so you will often see references shortened to
X11R6 or even just X11.
Many implementations are available for different
architectures and operating systems. An
implementation of the server-side code is properly known
as an X server.Which X implementations are available for &os;?Historically, the default implementation of X on
&os; has been
&xfree86; which is maintained by
The XFree86 Project,
Inc. This software was installed by default on
&os; versions up until 4.10 and 5.2. Although &xorg;
itself maintained an implementation during that time
period, it was basically only provided as a reference
platform, as it had suffered greatly from bitrot over
the years.However, early in 2004, some XFree86 developers left
that project
over issues including the pace of code changes, future
directions, and interpersonal conflicts, and are now contributing
code directly to &xorg; instead. At that time, &xorg; updated its
source tree to the last &xfree86; release before its subsequent
licensing change (XFree86 version 4.3.99.903), incorporated
many changes that had previously been maintained separately,
and has released that software as X11R6.7.0. A separate but
related project,
freedesktop.org (or fd.o for short),
is working on rearchitecting the original &xfree86; code to
offload more work onto the graphics cards (with the goal of
increased performance) and make it more modular
(with the goal of increased maintainability, and thus faster
releases as well as easier configuration). &xorg; intends to
incorporate the freedesktop.org changes in its future releases.As of July 2004, in &os.current;,
&xfree86; has been replaced with &xorg; as the default
implementation. The &xfree86; ports
(x11/XFree86-4 and
subports) remain in the ports collection and are still
the default for &os.stable;.The above describes the default X implementation installed.
It is still possible to install either implementation by
following the instructions in the entry for 20040723 in
/usr/ports/UPDATING.It is not currently
possible to mix-and-match pieces of each implementation;
one must choose one or the other.The following paragraphs refer to the
&xfree86; implementation, but most should also be applicable
to the &xorg; implementation as well. While the default
configuration filename for the &xorg; implementation is
xorg.conf, it will search for
XF86Config if it cannot find it.Will my existing applications run with the &xorg; suite?The &xorg; software is written to the same X11R6 specification
that &xfree86; is, so basic applications should work
unchanged. A few lesser-used protocols have been deprecated
(XIE, PEX, and
lbxproxy), but in the first two cases, the
&os; port of &xfree86; did not support them either.Why did the X projects split, anyway?The answer to this question is outside the scope of
this FAQ. Note that there are voluminous postings in various
mailing list archives on the Internet; please use your favorite
search engine to investigate the history instead of asking this
question on the &os; mailing lists. It may even be the case
that only the participants will ever know for certain.Why did &os; choose to go with the &xorg; ports by default?The &xorg; developers claim that their goal is to release
more often and incorporate new features more quickly. If they
are able to do so, this will be very attractive. Also, their
software still uses the traditional X license, while &xfree86;
is now using their modified one.This decision is still controversial. Only time will
tell which implementation proves technically superior. Each
&os; user should decide which they prefer.I want to run X, how do I go about it?The easiest way is to simply specify that you want to
run X during the installation process.If you would like to add X to an existing installation, you
should use the x11/xorg
meta-port, which will build and install all the necessary
components.Then read and follow the documentation on the
&man.xorgconfig.1; tool, which assists you in
configuring &xorg; for your particular graphics
card/mouse/etc. You may also wish to examine the
&man.xorgcfg.1; tool, which provides a graphical interface
to the X configuration process.For further information, read the X11 section of the
FreeBSD Handbook.You may also wish to investigate the Xaccel server.
See the section on Xi Graphics
for more details.I tried to run X, but I get an
KDENABIO failed (Operation not permitted)
error when I type startx. What do I do
now?Your system is probably running at a raised securelevel.
It is not possible to start X at a raised securelevel because
X requires write access to /dev/io.
For more information, see at the &man.init.8; manual
page.So the question is what else you should do instead,
and you basically have two choices: set your securelevel
back down to zero (usually from /etc/rc.conf),
or run &man.xdm.1; at boot time (before the securelevel is
raised).See for more information about
running &man.xdm.1; at boot time.Why does my mouse not work with X?If you are using syscons (the default console driver),
you can configure FreeBSD to support a mouse pointer on each
virtual screen. In order to avoid conflicting with X, syscons
supports a virtual device called
/dev/sysmouse. All mouse events received
from the real mouse device are written to the sysmouse device
via moused. If you wish to use your mouse on one or more
virtual consoles, and use X, see
and set up
moused.Then edit /etc/X11/XF86Config and make
sure you have the following lines:Section Pointer
Protocol "SysMouse"
Device "/dev/sysmouse"
.....The above example is for &xfree86; 3.3.2 or later, and
for &xorg; 6.7.0. For earlier versions, the
Protocol should be
MouseSystems.For &xorg;, /etc/X11/xorg.conf should
be edited. Although the pointer section format above is supported
for compatibility reasons, the preferred format is to use an
InputDevice section similar to the following example:Section "InputDevice"
Option "Protocol" "SysMouse"
Option "Device" "/dev/sysmouse"
.....Some people prefer to use
/dev/mouse under X. To make this
work, /dev/mouse should be linked
to /dev/sysmouse (see
&man.sysmouse.4;):&prompt.root; cd /dev
&prompt.root; rm -f mouse
&prompt.root; ln -s sysmouse mouseMy mouse has a fancy wheel. Can I use it in X?Yes.You need to tell X that you have a 5 button mouse.
To do this, simply add the lines
Buttons 5 and
ZAxisMapping 4 5 to the
InputDevice section of
/etc/XF86Config. For example, you
might have the following InputDevice section
in /etc/XF86Config.InputDevice Section for Wheeled Mouse
in &xfree86; and &xorg; configuration fileSection "InputDevice"
Identifier "Mouse1"
Driver "mouse"
Option "Protocol" "auto"
Option "Device" "/dev/sysmouse"
Option "Buttons" "5"
Option "ZAxisMapping" "4 5"
EndSection.emacs example for naive page
scrolling with Wheeled Mouse (optional);; wheel mouse
(global-set-key [mouse-4] 'scroll-down)
(global-set-key [mouse-5] 'scroll-up)How do I use remote X displays?For security reasons, the default setting is to not allow a
machine to remotely open a window.To enable this feature, simply start
X with the optional
argument:&prompt.user; startx
-listen_tcpWhy do X Window menus and dialog boxes not work
right?Try turning off the Num Lock key.If your Num Lock key is on by default
at boot-time, you may add the following line in the
Keyboard section of the
XF86Config file.# Let the server do the NumLock processing. This should only be
# required when using pre-R6 clients
ServerNumLockWhat is a virtual console and how do I make more?Virtual consoles, put simply, enable you to have several
simultaneous sessions on the same machine without doing anything
complicated like setting up a network or running X.When the system starts, it will display a login prompt on
the monitor after displaying all the boot messages. You can
then type in your login name and password and start working (or
playing!) on the first virtual console.At some point, you will probably wish to start another
session, perhaps to look at documentation for a program
you are running or to read your mail while waiting for an
FTP transfer to finish. Just do AltF2
(hold down the Alt key and press the
F2 key), and you will find a login prompt
waiting for you on the second virtual
console! When you want to go back to the original
session, do AltF1.The default FreeBSD installation has eight virtual
consoles enabled. AltF1,
AltF2,
AltF3,
and so on will switch between these virtual
consoles.To enable more of them, edit
/etc/ttys (see &man.ttys.5;)
and add entries for ttyv4
to ttyvc after the comment on
Virtual terminals:# Edit the existing entry for ttyv3 in /etc/ttys and change
# "off" to "on".
ttyv3 "/usr/libexec/getty Pc" cons25 on secure
ttyv4 "/usr/libexec/getty Pc" cons25 on secure
ttyv5 "/usr/libexec/getty Pc" cons25 on secure
ttyv6 "/usr/libexec/getty Pc" cons25 on secure
ttyv7 "/usr/libexec/getty Pc" cons25 on secure
ttyv8 "/usr/libexec/getty Pc" cons25 on secure
ttyv9 "/usr/libexec/getty Pc" cons25 on secure
ttyva "/usr/libexec/getty Pc" cons25 on secure
ttyvb "/usr/libexec/getty Pc" cons25 on secureUse as many or as few as you want. The more virtual
terminals you have, the more resources that are used; this
can be important if you have 8MB RAM or less. You may also
want to change the secure
to insecure.If you want to run an X server you
must leave at least one virtual
terminal unused (or turned off) for it to use. That is to
say that if you want to have a login prompt pop up for all
twelve of your Alt-function keys, you are out of luck - you
can only do this for eleven of them if you also want to run
an X server on the same machine.The easiest way to disable a console is by turning it off.
For example, if you had the full 12 terminal allocation
mentioned above and you wanted to run X, you would change
settings for virtual terminal 12 from:ttyvb "/usr/libexec/getty Pc" cons25 on secureto:ttyvb "/usr/libexec/getty Pc" cons25 off secureIf your keyboard has only ten function keys, you would
end up with:ttyv9 "/usr/libexec/getty Pc" cons25 off secure
ttyva "/usr/libexec/getty Pc" cons25 off secure
ttyvb "/usr/libexec/getty Pc" cons25 off secure(You could also just delete these lines.)Once you have edited /etc/ttys,
the next step is to make sure that you have enough virtual
terminal devices. The easiest way to do this is:&prompt.root; cd /dev
&prompt.root; sh MAKEDEV vty12On FreeBSD 5.X and beyond you do not have to create devices
manually if you are using DEVFS,
since the proper device nodes will be automatically
created under /dev.Next, the easiest (and cleanest) way to activate the
virtual consoles is to reboot. However, if you really do not
want to reboot, you can just shut down the X Window system
and execute (as root):&prompt.root; kill -HUP 1It is imperative that you completely shut down X Window if
it is running, before running this command. If you do not,
your system will probably appear to hang/lock up after
executing the kill command.How do I access the virtual consoles from X?Use CtrlAltFn to switch back to a virtual console.
CtrlAltF1 would return you to the first virtual console.Once you are back to a text console, you can then use
AltFn as normal to move between them.To return to the X session, you must switch to the
virtual console running X. If you invoked X from the
command line, (e.g., using startx) then
the X session will attach to the next unused virtual
console, not the text console from which it was invoked.
If you have eight active virtual terminals then X will be
running on the ninth, and you would use
AltF9 to return.How do I start XDM on boot?There are two schools of thought on how to start
&man.xdm.1;. One school starts xdm from
/etc/ttys (see &man.ttys.5;) using
the supplied example, while the other simply runs xdm from
rc.local (see &man.rc.8;) or from a
X.sh script in
/usr/local/etc/rc.d. Both are equally
valid, and one may work in situations where the other does
not. In both cases the result is the same: X will pop up
a graphical login: prompt.The ttys method has the advantage of documenting which
vty X will start on and passing the responsibility of
restarting the X server on logout to init. The rc.local
method makes it easy to kill xdm if there is a problem
starting the X server.If loaded from rc.local, xdm should
be started without any arguments (i.e., as a daemon). xdm must
start AFTER getty runs, or else getty and xdm will conflict,
locking out the console. The best way around this is to have
the script sleep 10 seconds or so then launch xdm.If you are to start xdm from
/etc/ttys, there still is a chance of
conflict between xdm and
&man.getty.8;. One way to avoid this is to add the
vt number in the
/usr/X11R6/lib/X11/xdm/Xservers
file.:0 local /usr/X11R6/bin/X vt4The above example will direct the X server to run in
/dev/ttyv3. Note the number is offset by
one. The X server counts the vty from one, whereas the FreeBSD
kernel numbers the vty from zero.Why do I get Couldn't open console
when I run xconsole?If you start X
with
startx, the permissions on
/dev/console will
not get changed, resulting in
things like
xterm -C and
xconsole not working.This is because of the way console permissions are set
by default. On a multi-user system, one does not necessarily
want just any user to be able to write on the system console.
For users who are logging directly onto a machine with a VTY,
the &man.fbtab.5;
file exists to solve such problems.In a nutshell, make sure an uncommented line of the
form/dev/ttyv0 0600 /dev/consoleis in /etc/fbtab (see
&man.fbtab.5;) and it will ensure that whomever logs in on
/dev/ttyv0 will own the
console.Before, I was able to run &xfree86; as a regular user. Why does
it now say that I must be root?All X servers need to be run as
root in order to get direct access to
your video hardware. Older versions of &xfree86; (<=
3.3.6) installed all bundled servers to be automatically
run as root (setuid to
root). This is obviously a security
hazard because X servers are large, complicated programs.
Newer versions of &xfree86; do not install the servers
setuid to root for just this
reason.Obviously, running an X server as the
root user is not acceptable, nor a
good idea security-wise. There are two ways to be able to
use X as a regular user. The first is to use
xdm or another display manager (e.g.,
kdm); the second is to use the
Xwrapper.xdm is a daemon that handles graphical
logins. It is usually started at boot time, and is responsible
for authenticating users and starting their sessions; it is
essentially the graphical counterpart of
&man.getty.8; and &man.login.1;. For
more information on xdm see
the &xfree86;
documentation, and the the FAQ
entry on it.Xwrapper is the X server wrapper; it is
a small utility to enable one to manually run an X server while
maintaining reasonable safety. It performs some sanity checks
on the command line arguments given, and if they pass, runs the
appropriate X server. If you do not want to run a display
manager for whatever reason, this is for you. If you have
installed the complete ports collection, you can find the port in
/usr/ports/x11/wrapper.Why does my PS/2 mouse misbehave under X?Your mouse and the mouse driver may have somewhat become
out of synchronization.
In rare cases the driver may erroneously report
synchronization problem and you may see the kernel
message:psmintr: out of sync (xxxx != yyyy)and notice that your mouse does not work properly.If this happens, disable the synchronization check code
by setting the driver flags for the PS/2 mouse driver to 0x100.
Enter UserConfig by giving the
option at the boot prompt:boot: -cThen, in the UserConfig command
line, type:UserConfig> flags psm0 0x100
UserConfig> quitWhy does my PS/2 mouse from MouseSystems not
work?There have been some reports that certain model of PS/2
mouse from MouseSystems works only if it is put into the
high resolution mode. Otherwise, the mouse
cursor may jump to the upper-left corner of the screen every
so often.Specify the flags 0x04 to the PS/2 mouse driver to put
the mouse into the high resolution mode. Enter
UserConfig by giving the
option at the boot prompt:boot: -cThen, in the UserConfig command line,
type:UserConfig> flags psm0 0x04
UserConfig> quitSee the previous section for another possible cause of mouse
problems.When building an X app, imake cannot
find Imake.tmpl. Where is it?Imake.tmpl is part of the Imake
package, a standard X application building tool.
Imake.tmpl, as well as several header
files that are required to build X apps, is contained in
the X prog distribution. You can install this from
sysinstall or manually from the X distribution
files.I want to install different X server.&os; versions prior 5.3 will use the default
&xfree86; 4.X,
while latter versions will default to
&xorg;.
If you want to run a different X11 implementation
than the default one, add the following line to
/etc/make.conf, (if you
do not have this file, create it):X_WINDOW_SYSTEM= xorgThis variable may be set to xorg,
xfree86-4, or
xfree86-3.How do I reverse the mouse buttons?Run the command
xmodmap -e "pointer = 3 2 1" from your
.xinitrc or .xsession.How do I install a splash screen and where do I find
them?&os; have a feature to allow the display of
splash screens during the boot
messages. The splash screens currently must be a 256 color
bitmap (*.BMP) or ZSoft PCX
(*.PCX) file. In addition, they must
have a resolution of 320x200 or less to work on standard
VGA adapters. If you compile VESA support into your
kernel, then you can use larger bitmaps up to 1024x768.
The actual VESA support can either be compiled directly
into the kernel with the VESA kernel
config option or by loading the VESA kld module during
bootup.To use a splash screen, you need to modify the startup
files that control the boot process for &os;.You need to create
a /boot/loader.rc file that contains
the following lines:include /boot/loader.4th
startand a /boot/loader.conf that
contains the following:splash_bmp_load="YES"
bitmap_load="YES"This assumes you are using
/boot/splash.bmp for your splash
screen. If you would rather use a PCX file, copy it to
/boot/splash.pcx, create a
/boot/loader.rc as instructed above,
and create a /boot/loader.conf that
contains:splash_pcx_load="YES"
bitmap_load="YES"
bitmap_name="/boot/splash.pcx"Now all you need is a splash screen. For that you can
surf on over to the gallery at
.Can I use the &windows;
keys on my keyboard in X?Yes. All you need to do is use &man.xmodmap.1; to define
what function you wish them to perform.Assuming all &windows; keyboards
are standard then the keycodes for the 3 keys are115 - &windows; key, between
the left-hand Ctrl and Alt keys116 - &windows; key, to the
right of the AltGr key117 - Menu key, to the left of
the right-hand Ctrl keyTo have the left &windows; key print a comma,
try this.&prompt.root; xmodmap -e "keycode 115 = comma"You will probably have to re-start your window manager
to see the result.To have the &windows;
key-mappings enabled automatically every time you start X either
put the xmodmap commands in your
~/.xinitrc file or, preferably, create a file
~/.xmodmaprc and include the
xmodmap options, one per line, then add the
linexmodmap $HOME/.xmodmaprcto your ~/.xinitrc.For example, you could map the 3 keys to be
F13, F14, and
F15, respectively. This would make it
easy to map them to useful functions within applications
or your window manager, as demonstrated further
down.To do this put the following in
~/.xmodmaprc.keycode 115 = F13
keycode 116 = F14
keycode 117 = F15If you use fvwm2, for example, you
could map the keys so that F13 iconifies
(or de-iconifies) the window the cursor is in,
F14 brings the window the cursor is in to
the front or, if it is already at the front, pushes it to
the back, and F15 pops up the main
Workplace (application) menu even if the cursor is not on
the desktop, which is useful if you do not have any part
of the desktop visible (and the logo on the key matches
its functionality).The following entries in
~/.fvwmrc implement the
aforementioned setup:Key F13 FTIWS A Iconify
Key F14 FTIWS A RaiseLower
Key F15 A A Menu Workplace NopHow can I get 3D hardware acceleration for
&opengl;?The availability of 3D acceleration depends on the
version of &xfree86; or &xorg; that you are using and the type of video chip
you have. If you have an NVIDIA chip, you can use the binary
drivers provided for FreeBSD on the
Drivers section of their website. For other cards
with &xfree86;-4 or &xorg;, including the Matrox G200/G400, ATI Rage
128/Radeon, and 3dfx Voodoo 3, 4, 5, and Banshee,
information on hardware acceleration is available on the
XFree86-4
Direct Rendering on FreeBSD page. Users of
&xfree86; version 3.3 can use the Utah-GLX port found in
graphics/utah-glx to
get limited accelerated &opengl; on the Matrox Gx00, ATI
Rage Pro, SiS 6326, i810, Savage, and older NVIDIA
chips.NetworkingWhere can I get information on
diskless booting?Diskless booting means that the FreeBSD
box is booted over a network, and reads the necessary files
from a server instead of its hard disk. For full details,
please read the
Handbook entry on diskless bootingCan a FreeBSD box be used as a dedicated network
router?Yes. Please see the Handbook entry on advanced
networking, specifically the section on routing
and gateways.Can I connect my &windows; box to the Internet via
FreeBSD?Typically, people who ask this question have two PCs
at home, one with FreeBSD and one with some version of
&windows; the idea is to use the FreeBSD box to connect to
the Internet and then be able to access the Internet from
the &windows; box through the FreeBSD box. This is really
just a special case of the previous question and works
perfectly well.If you are using dialup to connect to the Internet
user-mode &man.ppp.8; contains a
option. If you run &man.ppp.8; with the
option, set
gateway_enable to
YES in
/etc/rc.conf, and configure your
&windows; machine correctly, this should work fine. For more
information, please see the &man.ppp.8; manual page or the
Handbook entry on
user PPP.If you are using kernel-mode PPP or have an Ethernet
connection to the Internet, you need to use
&man.natd.8;. Please look at the natd section
of the Handbook for a tutorial.Does FreeBSD support SLIP and PPP?Yes. See the manual pages for &man.slattach.8;,
&man.sliplogin.8;, &man.ppp.8;, and &man.pppd.8;. &man.ppp.8;
and &man.pppd.8; provide support for both incoming and outgoing
connections, while &man.sliplogin.8; deals exclusively with
incoming connections, and &man.slattach.8; deals exclusively
with outgoing connections.For more information on how to use these, please see the
Handbook chapter on
PPP and SLIP.If you only have access to the Internet through a
shell account, you may want to have a look
at the net/slirp
package. It can provide you with (limited) access to
services such as ftp and http direct from your local
machine.Does FreeBSD support NAT or Masquerading?Yes. If you want to use NAT over a user PPP
connection, please see the Handbook entry on user
PPP. If you want to use NAT over some other sort
of network connection, please look at the natd section
of the Handbook.How do I connect two FreeBSD systems over a parallel line
using PLIP?Please see the PLIP
section of the Handbook.Why can I not create a /dev/ed0
device?Because they are not necessary. In the Berkeley
networking framework, network interfaces are only directly
accessible by kernel code. Please see the
/etc/rc.network file and the manual
pages for the various network programs mentioned there for
more information. If this leaves you totally confused,
then you should pick up a book describing network
administration on another BSD-related operating system;
with few significant exceptions, administering networking
on FreeBSD is basically the same as on &sunos; 4.0 or
Ultrix.How can I set up Ethernet aliases?If the alias is on the same subnet as an address
already configured on the interface, then add
netmask 0xffffffff to your
&man.ifconfig.8; command-line, as in the following:&prompt.root; ifconfig ed0 alias 192.0.2.2 netmask 0xffffffffOtherwise, just specify the network address and
netmask as usual:&prompt.root; ifconfig ed0 alias 172.16.141.5 netmask 0xffffff00How do I get my 3C503 to use the other network
port?If you want to use the other ports, you will have to specify
an additional parameter on the
&man.ifconfig.8; command line. The default port is
link0. To use the AUI port instead of the
BNC one, use link2. These flags should be
specified using the ifconfig_* variables in
/etc/rc.conf (see &man.rc.conf.5;).Why am I having trouble with NFS and FreeBSD?Certain PC network cards are better than others (to put
it mildly) and can sometimes cause problems with network
intensive applications like NFS.See
the Handbook entry on NFS for more information on
this topic.Why can I not NFS-mount from a &linux; box?Some versions of the &linux; NFS code only accept mount
requests from a privileged port; try&prompt.root; mount -o -P linuxbox:/blah /mntWhy can I not NFS-mount from a Sun box?&sun; workstations running &sunos; 4.X only accept mount
requests from a privileged port; try&prompt.root; mount -o -P sunbox:/blah /mntWhy does mountd keep telling me it
can't change attributes and that I have a
bad exports list on my FreeBSD NFS
server?The most frequent problem is not understanding the
correct format of /etc/exports.
Please review &man.exports.5; and the NFS entry in the
Handbook, especially the section on configuring
NFS.Why am I having problems talking PPP to NeXTStep
machines?Try disabling the TCP extensions in
/etc/rc.conf (see &man.rc.conf.5;) by
changing the following variable to NO:tcp_extensions=NOXylogic's Annex boxes are also broken in this regard
and you must use the above change to connect through
them.How do I enable IP multicast support?FreeBSD supports multicast host operations by
default. If you want your box to run as a multicast
router, you need to recompile your kernel with the
MROUTING option and run
&man.mrouted.8;. FreeBSD will start &man.mrouted.8; at
boot time if the flag mrouted_enable is
set to "YES" in
/etc/rc.conf.MBONE tools are available in their own ports category,
mbone.
If you are looking for the conference tools
vic and vat, look
there!Which network cards are based on the DEC PCI
chipset?Here is a list compiled by Glen Foster
gfoster@driver.nsta.org,
with some more modern additions:
Network cards based on the DEC PCI chipsetVendorModelASUSPCI-L101-TBAcctonENI1203CogentEM960PCICompexENET32-PCID-LinkDE-530DaynaDP1203, DP2100DECDE435, DE450DanpexEN-9400P3JCISCondor JC1260LinksysEtherPCIMylexLNP101SMCEtherPower 10/100 (Model 9332)SMCEtherPower (Model 8432)TopWareTE-3500PZnyx (2.2.x)ZX312, ZX314, ZX342, ZX345, ZX346, ZX348Znyx (3.x)ZX345Q, ZX346Q, ZX348Q, ZX412Q, ZX414, ZX442, ZX444,
ZX474, ZX478, ZX212, ZX214 (10mbps/hd)
Why do I have to use the FQDN for hosts on my
site?You will probably find that the host is actually in a
different domain; for example, if you are in foo.example.org and
you wish to reach a host called mumble in the
example.org domain, you will
have to refer to it by the fully-qualified domain name, mumble.example.org, instead of just
mumble.Traditionally, this was allowed by BSD BIND resolvers.
However the current version of
bind (see &man.named.8;)
that ships with FreeBSD no longer provides default
abbreviations for non-fully qualified domain names other than
the domain you are in. So an unqualified host
mumble must either be found as mumble.foo.example.org, or it will be searched
for in the root domain.This is different from the previous behavior, where the
search continued across
mumble.example.org, and
mumble.edu. Have a look at
RFC 1535 for why this was considered bad practice, or even a
security hole.As a good workaround, you can place the linesearch foo.example.org example.orginstead of the previousdomain foo.example.orginto your /etc/resolv.conf file
(see &man.resolv.conf.5;). However, make sure that the
search order does not go beyond the boundary
between local and public administration, as RFC
1535 calls it.Why do I get an error, Permission
denied, for all networking operations?If you have compiled your kernel with the
IPFIREWALL option, you need to be aware
that the default policy is to deny all packets that are
not explicitly allowed.If you had unintentionally misconfigured your system
for firewalling, you can restore network operability by
typing the following while logged in as
root:&prompt.root; ipfw add 65534 allow all from any to anyYou can also set
firewall_type="open" in
/etc/rc.conf.For further information on configuring a FreeBSD
firewall, see the
Handbook chapter.How much overhead does IPFW incur?Please see the Handbook's Firewalls
section, specifically the section on IPFW
Overhead & Optimization.Why is my ipfwfwd rule
to redirect a service to another machine not working?Possibly because you want to do network address translation
(NAT) and not just forward packets. A fwd rule
does exactly what it says; it forwards packets. It does not
actually change the data inside the packet. Say we have a rule
like:01000 fwd 10.0.0.1 from any to foo 21When a packet with a destination address of
foo arrives at the machine with this
rule, the packet is forwarded to
10.0.0.1, but it still has the
destination address of foo! The
destination address of the packet is not
changed to 10.0.0.1. Most machines
would probably drop a packet that they receive with a
destination address that is not their own. Therefore, using a
fwd rule does not often work the way the user
expects. This behavior is a feature and not a bug.See the FAQ about
redirecting services, the &man.natd.8; manual, or one of
the several port redirecting utilities in the ports collection for a correct way to do
this.How can I redirect service requests from one machine to
another?You can redirect FTP (and other service) request with
the socket package, available in the ports
tree in category sysutils. Simply replace the
service's command line to call socket instead, like so:ftp stream tcp nowait nobody /usr/local/bin/socket socket ftp.example.comftpwhere ftp.example.com and
ftp are the host and port to
redirect to, respectively.Where can I get a bandwidth management tool?There are three bandwidth management tools available
for FreeBSD. &man.dummynet.4; is integrated into FreeBSD
as part of &man.ipfw.4;. ALTQ
is available for free on FreeBSD 4.X and has been
integrated into FreeBSD 5.X as part of &man.pf.4;.
Bandwidth Manager from Emerging Technologies
is a commercial product.Why do I get /dev/bpf0: device not
configured?You are running a program that requires the Berkeley
Packet Filter (&man.bpf.4;), but it is not in your kernel.
Add this to your kernel config file and build a new
kernel:pseudo-device bpf # Berkeley Packet FilterOn FreeBSD 4.X and earlier, you must also create the
device node. After rebooting, go to the
/dev directory and run:&prompt.root; sh MAKEDEV bpf0Please see the Handbook entry
on device nodes for more information on managing
devices.How do I mount a disk from a &windows; machine that is on my
network, like smbmount in &linux;?Use the SMBFS toolset. It
includes a set of kernel modifications and a set of
userland programs. The programs and information are
available as net/smbfs
in the ports collection, or in the base system as of
4.5-RELEASE and later.What are these messages about icmp-response
bandwidth limit 300/200 pps in my log
files?This is the kernel telling you that some activity is
provoking it to send more ICMP or TCP reset (RST)
responses than it thinks it should. ICMP responses are
often generated as a result of attempted connections to
unused UDP ports. TCP resets are generated as a result of
attempted connections to unopened TCP ports. Among
others, these are the kinds of activities which may cause
these messages:Brute-force denial of service (DoS) attacks (as
opposed to single-packet attacks which exploit a
specific vulnerability).Port scans which attempt to connect to a large
number of ports (as opposed to only trying a few
well-known ports).The first number in the message tells you how many
packets the kernel would have sent if the limit was not in
place, and the second number tells you the limit. You can
control the limit using the
net.inet.icmp.icmplim sysctl variable
like this, where 300 is the limit in
packets per second:&prompt.root; sysctl -w net.inet.icmp.icmplim=300If you do not want to see messages about this in your
log files, but you still want the kernel to do response
limiting, you can use the
net.inet.icmp.icmplim_output sysctl
variable to disable the output like this:&prompt.root; sysctl -w net.inet.icmp.icmplim_output=0Finally, if you want to disable response limiting, you
can set the net.inet.icmp.icmplim
sysctl variable (see above for an example) to
0. Disabling response limiting is
discouraged for the reasons listed above.What are these arp: unknown hardware
address format error messages?This means that some device on your local Ethernet is
using a MAC address in a format that FreeBSD does not
recognize. This is probably caused by someone
experimenting with an Ethernet card somewhere else on the
network. You will see this most commonly on cable modem
networks. It is harmless, and should not affect the
performance of your FreeBSD machine.I have just installed CVSup but trying to execute it
produces errors. What is wrong?First, see if the error message you are receiving is
like the one shown below./usr/libexec/ld-elf.so.1: Shared object "libXaw.so.6" not foundErrors like these are caused by installing the
net/cvsup port on a
machine which does not have the
&xfree86; suite. If you want to
use the GUI included with
CVSup you will need to install
&xfree86; now. Alternatively if
you just wish to use CVSup from
a command line you should delete the package previously
installed. Then install the net/cvsup-without-gui port. This
is covered in more detail in the CVSup
section of the Handbook.SecurityWhat is a sandbox?Sandbox is a security term. It can
mean two things:A process which is placed inside a set of virtual
walls that are designed to prevent someone who breaks
into the process from being able to break into the wider
system.The process is said to be able to
play inside the walls. That is,
nothing the process does in regards to executing code is
supposed to be able to breech the walls so you do not
have to do a detailed audit of its code to be able to
say certain things about its security.The walls might be a userid, for example. This is
the definition used in the &man.security.7; and &man.named.8; man
pages.Take the ntalk service, for
example (see /etc/inetd.conf). This service used to run
as userid root. Now it runs as userid
tty. The tty user
is a sandbox designed to make it more difficult for
someone who has successfully hacked into the system via
ntalk from being able to hack beyond that user id.A process which is placed inside a simulation of the
machine. This is more hard-core. Basically it means that
someone who is able to break into the process may believe
that he can break into the wider machine but is, in fact,
only breaking into a simulation of that machine and not
modifying any real data.The most common way to accomplish this is to build a
simulated environment in a subdirectory and then run the
processes in that directory chroot'd (i.e.
/ for that process is this
directory, not the real / of the
system).Another common use is to mount an underlying
filesystem read-only and then create a filesystem layer
on top of it that gives a process a seemingly writeable
view into that filesystem. The process may believe it is
able to write to those files, but only the process sees
the effects - other processes in the system do not,
necessarily.An attempt is made to make this sort of sandbox so
transparent that the user (or hacker) does not realize
that he is sitting in it.&unix; implements two core sandboxes. One is at the
process level, and one is at the userid level.Every &unix; process is completely firewalled off from every
other &unix; process. One process cannot modify the address
space of another. This is unlike &windows; where a process
can easily overwrite the address space of any other, leading
to a crash.A &unix; process is owned by a particular userid. If
the userid is not the root user, it
serves to firewall the process off from processes owned by
other users. The userid is also used to firewall off
on-disk data.What is securelevel?The securelevel is a security mechanism implemented in the
kernel. Basically, when the securelevel is positive, the
kernel restricts certain tasks; not even the superuser (i.e.,
root) is allowed to do them. At the time
of this writing, the securelevel mechanism is capable of, among
other things, limiting the ability to,unset certain file flags, such as
schg (the system immutable flag),write to kernel memory via
/dev/mem and
/dev/kmem,load kernel modules, andalter firewall rules.To check the status of the securelevel on a running system,
simply execute the following command:&prompt.root; sysctl kern.securelevelThe output will contain the name of the &man.sysctl.8;
variable (in this case, kern.securelevel)
and a number. The latter is the current value of the
securelevel. If it is positive (i.e., greater than 0), at
least some of the securelevel's protections are enabled.You cannot lower the securelevel of a running system; being
able to do that would defeat its purpose. If you need to do a
task that requires that the securelevel be non-positive (e.g.,
an installworld or changing the date),
you will have to change the securelevel setting in
/etc/rc.conf (you want to look for the
kern_securelevel and
kern_securelevel_enable variables) and
reboot.For more information on securelevel and the specific things
all the levels do, please consult the &man.init.8; manual
page.Securelevel is not a silver bullet; it has many known
deficiencies. More often than not, it provides a false
sense of security.One of its biggest problems is that in order for it to
be at all effective, all files used in the boot process up
until the securelevel is set must be protected. If an
attacker can get the system to execute their code prior to
the securelevel being set (which happens quite late in the
boot process since some things the system must do at
start-up cannot be done at an elevated securelevel), its
protections are invalidated. While this task of protecting
all files used in the boot process is not technically
impossible, if it is achieved, system maintenance will
become a nightmare since one would have to take the system
down, at least to single-user mode, to modify a
configuration file.This point and others are often discussed on the
mailing lists, particularly the &a.security;. Please search
the archives here for an
extensive discussion. Some people are hopeful that
securelevel will soon go away in favor of a more
fine-grained mechanism, but things are still hazy in this
respect.Consider yourself warned.BIND (named) is listening on port 53 and
some other high-numbered port. What is going on?BIND uses a random high-numbered port for outgoing
queries. If you want to use port 53 for outgoing queries,
either to get past a firewall or to make yourself feel
better, you can try the following in
/etc/namedb/named.conf:options {
query-source address * port 53;
};You can replace the * with a single IP
address if you want to tighten things further.Congratulations, by the way. It is good practice to read
your &man.sockstat.1; output and notice odd
things!Sendmail is listening on port 587 as well as the
standard port 25! What is going on?Recent versions of Sendmail support a
mail submission feature that runs over port 587. This is
not yet widely supported, but is growing in
popularity.What is this UID 0 toor account? Have I
been compromised?Do not worry. toor is an
alternative superuser account (toor is root
spelt backwards). Previously it was created when the
&man.bash.1; shell was installed but now it is created by
default. It is intended to be used with a non-standard shell so
you do not have to change root's default
shell. This is important as shells which are not part of the
base distribution (for example a shell installed from ports or
packages) are likely to be installed in
/usr/local/bin which, by default, resides
on a different filesystem. If root's shell
is located in /usr/local/bin and
/usr (or whatever filesystem contains
/usr/local/bin) is not mounted for some
reason, root will not be able to log in to
fix a problem (although if you reboot into single user mode
you will be prompted for the path to a shell).Some people use toor for
day-to-day root tasks with a
non-standard shell, leaving root,
with a standard shell, for single user mode or
emergencies. By default you cannot log in using
toor as it does not have a password,
so log in as root and set a password
for toor if you want to use
it.Why is suidperl not working
properly?For security reasons, suidperl is
installed without the suid bit by default. The system
administrator can enable suid behavior with the following
command.&prompt.root; chmod u+s /usr/bin/suidperlIf you want suidperl to be built
suid during upgrades from source, edit
/etc/make.conf and add
ENABLE_SUIDPERL=true before you run
make buildworld.PPPI cannot make &man.ppp.8; work. What am I doing wrong?You should first read the &man.ppp.8; manual page and
the
PPP section of the handbook. Enable logging with
the commandset log Phase Chat Connect Carrier lcp ipcp ccp commandThis command may be typed at the &man.ppp.8; command
prompt or it may be entered in the
/etc/ppp/ppp.conf configuration file
(the start of the default section is
the best place to put it). Make sure that
/etc/syslog.conf (see
&man.syslog.conf.5;) contains the lines!ppp
*.* /var/log/ppp.logand that the file /var/log/ppp.log
exists. You can now find out a lot about what is going on
from the log file. Do not worry if it does not all make sense.
If you need to get help from someone, it may make sense to
them.Why does &man.ppp.8; hang when I run it?This is usually because your hostname will not resolve.
The best way to fix this is to make sure that
/etc/hosts is consulted by your
resolver first by editing /etc/host.conf
and putting the hosts line first. Then,
simply put an entry in /etc/hosts for
your local machine. If you have no local network, change your
localhost line:127.0.0.1 foo.example.com foo localhostOtherwise, simply add another entry for your host.
Consult the relevant manual pages for more details.You should be able to successfully ping -c1
`hostname` when you are done.Why will &man.ppp.8; not dial in -auto
mode?First, check that you have got a default route. By
running netstat -rn (see
&man.netstat.1;), you should see two entries like
this:Destination Gateway Flags Refs Use Netif Expire
default 10.0.0.2 UGSc 0 0 tun0
10.0.0.2 10.0.0.1 UH 0 0 tun0This is assuming that you have used the addresses from the
handbook, the manual page or from the ppp.conf.sample file.
If you do not have a default route, it may be because you are
running an old version of &man.ppp.8;
that does not understand the word HISADDR
in the ppp.conf file.Another reason for the default route line being
missing is that you have mistakenly set up a default
router in your /etc/rc.conf (see
&man.rc.conf.5;) file
and you have omitted the line sayingdelete ALLfrom ppp.conf. If this is the
case, go back to the Final
system configuration section of the
handbook.What does No route to host mean?This error is usually due to a missingMYADDR:
delete ALL
add 0 0 HISADDRsection in your /etc/ppp/ppp.linkup
file. This is only necessary if you have a dynamic IP address
or do not know the address of your gateway. If you are using
interactive mode, you can type the following after entering
packet mode (packet mode is
indicated by the capitalized PPP in the
prompt):delete ALL
add 0 0 HISADDRRefer to the
PPP and Dynamic IP addresses section of the handbook
for further details.Why does my connection drop after about 3 minutes?The default PPP timeout is 3 minutes. This can be
adjusted with the lineset timeout NNNwhere NNN is the number of
seconds of inactivity before the connection is closed. If
NNN is zero, the connection is never
closed due to a timeout. It is possible to put this command in
the ppp.conf file, or to type it at the
prompt in interactive mode. It is also possible to adjust it on
the fly while the line is active by connecting to
ppp's server socket using
&man.telnet.1; or &man.pppctl.8;.
Refer to the
&man.ppp.8; man
page for further details.Why does my connection drop under heavy load?If you have Link Quality Reporting (LQR) configured,
it is possible that too many LQR packets are lost between
your machine and the peer. Ppp deduces that the line must
therefore be bad, and disconnects. Prior to FreeBSD version
2.2.5, LQR was enabled by default. It is now disabled by
default. LQR can be disabled with the linedisable lqrWhy does my connection drop after a random amount of
time?Sometimes, on a noisy phone line or even on a line with
call waiting enabled, your modem may hang up because it
thinks (incorrectly) that it lost carrier.There is a setting on most modems for determining how
tolerant it should be to temporary losses of carrier. On a
USR &sportster; for example, this is measured by the S10
register in tenths of a second. To make your modem more
forgiving, you could add the following send-expect sequence
to your dial string:set dial "...... ATS10=10 OK ......"Refer to your modem manual for details.Why does my connection hang after a random amount of
time?Many people experience hung connections with no apparent
explanation. The first thing to establish is which side of
the link is hung.If you are using an external modem, you can simply try
using &man.ping.8; to see if the TD
light is flashing when you transmit data. If it flashes
(and the RD light does not), the
problem is with the remote end. If TD
does not flash, the problem is local. With an internal
modem, you will need to use the set
server command in your
ppp.conf file. When the hang occurs,
connect to &man.ppp.8; using &man.pppctl.8;. If your
network connection suddenly revives (PPP was revived due
to the activity on the diagnostic socket) or if you cannot
connect (assuming the set socket
command succeeded at startup time), the problem is
local. If you can connect and things are still hung,
enable local async logging with set log local
async and use &man.ping.8; from another window
or terminal to make use of the link. The async logging
will show you the data being transmitted and received on
the link. If data is going out and not coming back, the
problem is remote.Having established whether the problem is local or remote,
you now have two possibilities:If the problem is remote, read on entry .If the problem is local, read on entry .The remote end is not responding. What can I do?There is very little you can do about this. Most ISPs
will refuse to help if you are not running a Microsoft OS.
You can enable lqr in your
ppp.conf file, allowing &man.ppp.8; to detect
the remote failure and hang up, but this detection is
relatively slow and therefore not that useful. You may want to
avoid telling your ISP that you are running user-PPP...First, try disabling all local compression by adding the
following to your configuration:disable pred1 deflate deflate24 protocomp acfcomp shortseq vj
deny pred1 deflate deflate24 protocomp acfcomp shortseq vjThen reconnect to ensure that this makes no difference.
If things improve or if the problem is solved completely,
determine which setting makes the difference through trial
and error. This will provide good ammunition when you contact
your ISP (although it may make it apparent that you are not
running a Microsoft product).Before contacting your ISP, enable async logging
locally and wait until the connection hangs again. This
may use up quite a bit of disk space. The last data read
from the port may be of interest. It is usually ascii
data, and may even describe the problem (Memory
fault, core dumped?).If your ISP is helpful, they should be able to enable
logging on their end, then when the next link drop occurs,
they may be able to tell you why their side is having a
problem. Feel free to send the details to &a.brian;, or
even to ask your ISP to contact me directly.&man.ppp.8; has hung. What can I do?Your best bet here is to rebuild &man.ppp.8; by adding
CFLAGS+=-g and
STRIP= to the end of the Makefile, then
doing a make clean && make &&
make install. When &man.ppp.8; hangs, find the
&man.ppp.8; process id with ps ajxww | fgrep
ppp and run gdb ppp
PID. From the gdb
prompt, you can then use bt to get a
stack trace.Send the results to &a.brian;.Why does nothing happen after the Login OK!
message?Prior to FreeBSD version 2.2.5, once the link was
established, &man.ppp.8; would wait for the peer to
initiate the Line Control Protocol (LCP). Many ISPs will
not initiate negotiations and expect the client to do so.
To force &man.ppp.8; to initiate the LCP, use the
following line:set openmode activeIt usually does no harm if both sides initiate
negotiation, so openmode is now active by default.
However, the next section explains when it
does do some harm.I keep seeing errors about magic being the same. What does
it mean?Occasionally, just after connecting, you may see messages
in the log that say magic is the same.
Sometimes, these messages are harmless, and sometimes one side
or the other exits. Most PPP implementations cannot survive
this problem, and even if the link seems to come up, you will see
repeated configure requests and configure acknowledgments in
the log file until &man.ppp.8; eventually gives up and closes the
connection.This normally happens on server machines with slow
disks that are spawning a getty on the port, and executing
&man.ppp.8; from a login script or program after login. I
have also heard reports of it happening consistently when
using slirp. The reason is that in the time taken between
&man.getty.8; exiting and &man.ppp.8; starting, the
client-side &man.ppp.8; starts sending Line Control
Protocol (LCP) packets. Because ECHO is still switched on
for the port on the server, the client &man.ppp.8; sees
these packets reflect back.One part of the LCP negotiation is to establish a
magic number for each side of the link so that
reflections can be detected. The protocol
says that when the peer tries to negotiate the same magic
number, a NAK should be sent and a new magic number should
be chosen. During the period that the server port has
ECHO turned on, the client &man.ppp.8; sends LCP packets,
sees the same magic in the reflected packet and NAKs
it. It also sees the NAK reflect (which also means
&man.ppp.8; must change its magic). This produces a
potentially enormous number of magic number changes, all
of which are happily piling into the server's tty
buffer. As soon as &man.ppp.8; starts on the server, it is
flooded with magic number changes and almost immediately
decides it has tried enough to negotiate LCP and gives
up. Meanwhile, the client, who no longer sees the
reflections, becomes happy just in time to see a hangup
from the server.This can be avoided by allowing the peer to start
negotiating with the following line in your ppp.conf
file:set openmode passiveThis tells &man.ppp.8; to wait for the server to initiate LCP
negotiations. Some servers however may never initiate
negotiations. If this is the case, you can do something
like:set openmode active 3This tells &man.ppp.8; to be passive for 3 seconds, and then to
start sending LCP requests. If the peer starts sending
requests during this period, &man.ppp.8; will immediately respond
rather than waiting for the full 3 second period.LCP negotiations continue until the connection is
closed. What is wrong?There is currently an implementation mis-feature in
&man.ppp.8; where it does not associate
LCP, CCP & IPCP responses with their original requests. As
a result, if one PPP
implementation is more than 6 seconds slower than the other
side, the other side will send two additional LCP configuration
requests. This is fatal.Consider two implementations,
A and
B. A starts
sending LCP requests immediately after connecting and
B takes 7 seconds to start. When
B starts, A
has sent 3 LCP REQs. We are assuming the line has ECHO switched
off, otherwise we would see magic number problems as described in
the previous section. B sends a
REQ, then an ACK to the first of
A's REQs. This results in
A entering the OPENED
state and sending and ACK (the first) back to
B. In the meantime,
B sends back two more ACKs in response to
the two additional REQs sent by A
before B started up.
B then receives the first ACK from
A and enters the
OPENED state.
A receives the second ACK from
B and goes back to the
REQ-SENT state, sending another (forth) REQ
as per the RFC. It then receives the third ACK and enters the
OPENED state. In the meantime,
B receives the forth REQ from
A, resulting in it reverting to the
ACK-SENT state and sending
another (second) REQ and (forth) ACK as per the RFC.
A gets the REQ, goes into
REQ-SENT and sends another REQ. It
immediately receives the following ACK and enters
OPENED.This goes on until one side figures out that they are
getting nowhere and gives up.The best way to avoid this is to configure one side to be
passive - that is, make one side
wait for the other to start negotiating. This can be done
with theset openmode passivecommand. Care should be taken with this option. You
should also use theset stopped Ncommand to limit the amount of time that
&man.ppp.8; waits for the peer to begin
negotiations. Alternatively, theset openmode active Ncommand (where N is the
number of seconds to wait before starting negotiations) can be
used. Check the manual page for details.Why does &man.ppp.8; lock up when I shell out to test
it?When you execute the shell or
! command, &man.ppp.8; executes a
shell (or if you have passed any arguments,
&man.ppp.8; will execute those arguments). Ppp will
wait for the command to complete before continuing. If you
attempt to use the PPP link while running the command, the link
will appear to have frozen. This is because
&man.ppp.8; is waiting for the command to
complete.If you wish to execute commands like this, use the
!bg command instead. This will execute
the given command in the background, and &man.ppp.8; can
continue to service the link.Why does &man.ppp.8; over a null-modem cable never exit?There is no way for &man.ppp.8; to
automatically determine that a direct connection has been
dropped. This is due to the lines that are used in a
null-modem serial cable. When using this sort of connection,
LQR should always be enabled with the lineenable lqrLQR is accepted by default if negotiated by the peer.Why does &man.ppp.8; dial for no reason in -auto mode?If &man.ppp.8; is dialing unexpectedly, you must
determine the cause, and set up Dial filters (dfilters) to
prevent such dialing.To determine the cause, use the following line:set log +tcp/ipThis will log all traffic through the connection. The
next time the line comes up unexpectedly, you will see the
reason logged with a convenient timestamp next to
it.You can now disable dialing under these circumstances.
Usually, this sort of problem arises due to DNS lookups.
To prevent DNS lookups from establishing a connection
(this will not prevent &man.ppp.8;
from passing the packets through an established
connection), use the following:set dfilter 1 deny udp src eq 53
set dfilter 2 deny udp dst eq 53
set dfilter 3 permit 0/0 0/0This is not always suitable, as it will effectively
break your demand-dial capabilities - most programs will
need a DNS lookup before doing any other network related
things.In the DNS case, you should try to determine what is
actually trying to resolve a host name. A lot of the
time, &man.sendmail.8; is the culprit. You should make
sure that you tell sendmail not to do any DNS lookups in
its configuration file. See the section on using email with a
dialup connection in the FreeBSD Handbook for
details on how to create your own configuration file and
what should go into it. You may also want to add the
following line to your .mc
file:define(`confDELIVERY_MODE', `d')dnlThis will make sendmail queue everything until the
queue is run (usually, sendmail is invoked with
, telling it to run the queue
every 30 minutes) or until a sendmail
-q is done (perhaps from your ppp.linkup
file).What do these CCP errors mean?I keep seeing the following errors in my log file:CCP: CcpSendConfigReq
CCP: Received Terminate Ack (1) state = Req-Sent (6)This is because &man.ppp.8; is trying to negotiate Predictor1
compression, and the peer does not want to negotiate any
compression at all. The messages are harmless, but if you
wish to remove them, you can disable Predictor1 compression
locally too:disable pred1Why does &man.ppp.8; not log my connection speed?In order to log all lines of your modem
conversation, you must enable the
following:set log +connectThis will make &man.ppp.8; log
everything up until the last requested expect
string.If you wish to see your connect speed and are using PAP
or CHAP (and therefore do not have anything to
chat after the CONNECT in the dial script - no
set login script), you must make sure that
you instruct &man.ppp.8; to expect the whole CONNECT
line, something like this:set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 4 \
\"\" ATZ OK-ATZ-OK ATDT\\T TIMEOUT 60 CONNECT \\c \\n"Here, we get our CONNECT, send nothing, then expect a
line-feed, forcing &man.ppp.8; to read
the whole CONNECT response.Why does &man.ppp.8; ignore the \ character
in my chat script?Ppp parses each line in your config files so that it can
interpret strings such as
set phone "123 456 789" correctly and
realize that the number is actually only
one argument. In order to specify a
" character, you must escape it
using a backslash (\).When the chat interpreter parses each argument, it
re-interprets the argument in order to find any special
escape sequences such as \P or
\T (see the manual page). As a result of this
double-parsing, you must remember to use the correct number of
escapes.If you wish to actually send a \
character to (say) your modem, you would need something
like:set dial "\"\" ATZ OK-ATZ-OK AT\\\\X OK"resulting in the following sequence:ATZ
OK
AT\X
OKorset phone 1234567
set dial "\"\" ATZ OK ATDT\\T"resulting in the following sequence:ATZ
OK
ATDT1234567Why does &man.ppp.8; get a seg-fault, but I see no
ppp.core file?Ppp (or any other program for that matter) should
never dump core. Because &man.ppp.8; runs with an
effective user id of 0, the operating system will not
write &man.ppp.8;'s core image to disk before terminating
it. If, however &man.ppp.8; is actually terminating due
to a segmentation violation or some other signal that
normally causes core to be dumped,
and you are sure you are using the
latest version (see the start of this section), then you
should do the following:&prompt.user; tar xfz ppp-*.src.tar.gz
&prompt.user; cd ppp*/ppp
&prompt.user; echo STRIP= >>Makefile
&prompt.user; echo CFLAGS+=-g >>Makefile
&prompt.user; make clean all
&prompt.user; su
&prompt.root; make install
&prompt.root; chmod 555 /usr/sbin/pppYou will now have a debuggable version of &man.ppp.8;
installed. You will have to be root
to run &man.ppp.8; as all of its privileges have been
revoked. When you start &man.ppp.8;, take a careful note
of what your current directory was at the time.Now, if and when &man.ppp.8; receives the segmentation
violation, it will dump a core file called
ppp.core. You should then do the
following:&prompt.user; su
&prompt.root; gdb /usr/sbin/ppp ppp.core(gdb)bt
.....
(gdb)f 0
....
(gdb)i args
....
(gdb)l
.....All of this information should be given alongside your
question, making it possible to diagnose the problem.If you are familiar with gdb, you may wish to find out some
other bits and pieces such as what actually caused the dump and
the addresses & values of the relevant variables.Why does the process that forces a dial in auto mode never
connect?This was a known problem with
&man.ppp.8; set up to negotiate a
dynamic local IP number with the peer in auto mode. It is
fixed in the latest version - search the manual page for
iface.The problem was that when that initial program calls
&man.connect.2;, the IP number of the tun interface is assigned
to the socket endpoint. The kernel creates the first outgoing
packet and writes it to the tun device.
&man.ppp.8; then reads the packet and
establishes a connection. If, as a result of
&man.ppp.8;'s dynamic IP assignment, the
interface address is changed, the original socket endpoint will
be invalid. Any subsequent packets sent to the peer will
usually be dropped. Even if they are not, any responses will
not route back to the originating machine as the IP number is
no longer owned by that machine.There are several theoretical ways to approach this
problem. It would be nicest if the peer would re-assign the
same IP number if possible :-)
The current version of &man.ppp.8; does
this, but most other implementations do not.The easiest method from our side would be to never
change the tun interface IP number, but instead to change
all outgoing packets so that the source IP number is
changed from the interface IP to the negotiated IP on the
fly. This is essentially what the
iface-alias option in the latest
version of &man.ppp.8; is doing (with the help of
&man.libalias.3; and &man.ppp.8;'s
switch) - it is maintaining all previous interface
addresses and NATing them to the last negotiated
address.Another alternative (and probably the most reliable) would
be to implement a system call that changes all bound sockets
from one IP to another. &man.ppp.8; would
use this call to modify the sockets of all existing programs
when a new IP number is negotiated. The same system call could
be used by dhcp clients when they are forced to re-bind() their
sockets.Yet another possibility is to allow an interface to be
brought up without an IP number. Outgoing packets would be
given an IP number of 255.255.255.255 up until the first
SIOCAIFADDR ioctl is done. This would result in fully binding
the socket. It would be up to &man.ppp.8;
to change the source IP number, but only if it is set to
255.255.255.255, and only the IP number and IP checksum would
need to change. This, however is a bit of a hack as the kernel
would be sending bad packets to an improperly configured
interface, on the assumption that some other mechanism is
capable of fixing things retrospectively.Why do most games not work with the -nat switch?The reason games and the like do not work when libalias
is in use is that the machine on the outside will try to open a
connection or send (unsolicited) UDP packets to the machine on
the inside. The NAT software does not know that it should send
these packets to the interior machine.To make things work, make sure that the only thing
running is the software that you are having problems with, then
either run tcpdump on the tun interface of the gateway or
enable &man.ppp.8; tcp/ip logging (set log +tcp/ip)
on the gateway.When you start the offending software, you should see
packets passing through the gateway machine. When
something comes back from the outside, it will be dropped
(that is the problem). Note the port number of these
packets then shut down the offending software. Do this a
few times to see if the port numbers are consistent. If
they are, then the following line in the relevant section
of /etc/ppp/ppp.conf will make the
software functional:nat port protointernalmachine:portportwhere proto is either
tcp or udp,
internalmachine is the machine that
you want the packets to be sent to and
port is the destination port number
of the packets.You will not be able to use the software on other machines
without changing the above command, and running the software
on two internal machines at the same time is out of the question
- after all, the outside world is seeing your entire internal
network as being just a single machine.If the port numbers are not consistent, there are three
more options:Submit support in libalias. Examples of
special cases can be found in
/usr/src/lib/libalias/alias_*.c
(alias_ftp.c is a good
prototype). This usually involves reading certain
recognised outgoing packets, identifying the
instruction that tells the outside machine to initiate
a connection back to the internal machine on a
specific (random) port and setting up a
route in the alias table so that the
subsequent packets know where to go.This is the most difficult solution, but it is the
best and will make the software work with multiple
machines.Use a proxy. The application may support socks5
for example, or (as in the cvsup case)
may have a passive option that avoids
ever requesting that the peer open connections back to
the local machine.Redirect everything to the internal machine using
nat addr. This is the
sledge-hammer approach.Has anybody made a list of useful port numbers?Not yet, but this is intended to grow into such a list
(if any interest is shown). In each example,
internal should be replaced with
the IP number of the machine playing the game.Asheron's Callnat port udp
internal
:65000 65000Manually change the port number within the game to
65000. If you have got a number of machines that you wish
to play on assign a unique port number for each (i.e.
65001, 65002, etc) and add a nat port
line for each one.Half Lifenat port udp
internal:27005
27015PCAnywhere 8.0nat port udp
internal:5632
5632nat port tcp
internal:5631
5631Quakenat port udp
internal:6112
6112Quake 2nat port udp
internal:27901
27910nat port udp
internal:60021
60021nat port udp
internal:60040
60040Red Alertnat port udp
internal:8675
8675nat port udp
internal:5009
5009What are FCS errors?FCS stands for Frame
Check Sequence.
Each PPP packet has a checksum attached to ensure that the
data being received is the data being sent. If the FCS of
an incoming packet is incorrect, the packet is dropped and
the HDLC FCS count is increased. The HDLC error values
can be displayed using the show hdlc
command.If your link is bad (or if your serial driver is dropping
packets), you will see the occasional FCS error. This is not
usually worth worrying about although it does slow down the
compression protocols substantially. If you have an external
modem, make sure your cable is properly shielded from
interference - this may eradicate the problem.If your link freezes as soon as you have connected and you
see a large number of FCS errors, this may be because your link
is not 8 bit clean. Make sure your modem is not using software
flow control (XON/XOFF). If your datalink
must use software flow control, use the
command set accmap 0x000a0000 to tell
&man.ppp.8; to escape the ^Q and
^S characters.Another reason for seeing too many FCS errors may be
that the remote end has stopped talking
PPP. You may want to enable
async logging at this point to
determine if the incoming data is actually a login or
shell prompt. If you have a shell prompt at the remote
end, it is possible to terminate &man.ppp.8; without
dropping the line by using the close
lcp command (a following term
command will reconnect you to the shell on the remote
machine.If nothing in your log file indicates why the link might
have been terminated, you should ask the remote administrator
(your ISP?) why the session was terminated.Why do &macos; and &windows; 98 connections freeze when
running PPPoE on the gateway?Thanks to Michael Wozniak
mwozniak@netcom.ca for figuring this out and
Dan Flemming danflemming@mac.com for the Mac
solution:This is due to what is called a Black Hole
router. &macos; and &windows; 98 (and maybe other Microsoft OSs)
send TCP packets with a requested segment size too big to fit
into a PPPoE frame (MTU is 1500 by default for Ethernet)
and have the do not
fragment bit set (default of TCP) and the Telco router
is not sending ICMP must fragment back to the
www site you are trying to load. (Alternatively, the router is
sending the ICMP packet correctly, but the firewall at the www
site is dropping it.) When the www server is sending
you frames that do not fit into the PPPoE pipe the Telco router
drops them on the floor and your page does not load (some
pages/graphics do as they are smaller than a MSS.) This seems
to be the default of most Telco PPPoE configurations (if only
they knew how to program a router... sigh...)One fix is to use regedit on your 95/98 boxes to add the
following registry entry...HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\NetTrans\0000\MaxMTUIt should be a string with a value
1436, as some ADSL routers are reported to
be unable to deal with packets larger than this. This
registry key has been changed to
Tcpip\Parameters\Interfaces\ID for
adapter\MTU in &windows; 2000 and
becomes a DWORD.Refer to the Microsoft Knowledge Base documents Q158474
- Windows TCPIP Registry Entries and Q120642
- TCPIP & NBT Configuration Parameters for &windowsnt;
for more information on changing &windows; MTU to
work with a NAT router.Another regedit possibility under &windows; 2000 is to
set the
Tcpip\Parameters\Interfaces\ID for
adapter\EnablePMTUBHDetect DWORD
to 1 as mentioned in the Microsoft document 120642
mentioned above.Unfortunately, &macos; does not provide an interface for
changing TCP/IP settings. However, there is commercial software
available, such as OTAdvancedTuner (OT for OpenTransport, the
&macos; TCP/IP stack) by Sustainable Softworks,
that will allow users to customize TCP/IP settings. &macos; NAT
users should select ip_interface_MTU from
the drop-down menu, enter 1450 instead of
1500 in the box, click the box next to
Save as Auto Configure, and click
Make Active.The latest version of &man.ppp.8;
(2.3 or greater) has an enable tcpmssfixup
command that will automatically adjust the MSS to an appropriate
value. This facility is enabled by default. If you are stuck
with an older version of &man.ppp.8;, you
may want to look at the tcpmssd
port.None of this helps - I am desperate! What can I do?If all else fails, send as much information as you can,
including your config files, how you are starting
&man.ppp.8;, the relevant parts of your
log file and the output of the netstat -rn
command (before and after connecting) to the &a.questions; or
the
comp.unix.bsd.freebsd.misc news group, and someone
should point you in the right direction.Serial CommunicationsThis section answers common questions about serial
communications with FreeBSD. PPP and SLIP are covered in the
Networking section.How do I tell if FreeBSD found my serial ports?As the FreeBSD kernel boots, it will probe for the serial
ports in your system for which the kernel was configured.
You can either watch your system closely for the messages it
prints or run the command&prompt.user; dmesg | grep sioafter your system is up and running.Here is some example output from the above command:sio0 at 0x3f8-0x3ff irq 4 on isa
sio0: type 16550A
sio1 at 0x2f8-0x2ff irq 3 on isa
sio1: type 16550AThis shows two serial ports. The first is on irq 4, is
using port address 0x3f8, and has a
16550A-type UART chip. The second uses the same kind of chip
but is on irq 3 and is at port address 0x2f8.
Internal modem cards are treated just like serial ports---except
that they always have a modem attached to the
port.The GENERIC kernel includes support
for two serial ports using the same irq and port address
settings in the above example. If these settings are not
right for your system, or if you have added modem cards or have
more serial ports than your kernel is configured for, just
reconfigure your kernel. See section
about building a kernel for
more details.How do I tell if FreeBSD found my modem cards?Refer to the answer to the previous question.How do I access the serial ports on FreeBSD?The third serial port, sio2
(see &man.sio.4;, known as COM3 in DOS), is on
/dev/cuaa2 for dial-out devices,
and on /dev/ttyd2 for dial-in
devices. What is the difference between these two classes
of devices?You use
ttydX
for dial-ins. When opening
/dev/ttydX
in blocking mode, a process will wait for the
corresponding
cuaaX
device to become inactive, and then wait for the carrier
detect line to go active. When you open the
cuaaX
device, it makes sure the serial port is not already in
use by the
ttydX
device. If the port is available, it steals
it from the
ttydX
device. Also, the
cuaaX
device does not care about carrier detect. With this
scheme and an auto-answer modem, you can have remote users
log in and you can still dial out with the same modem and
the system will take care of all the conflicts.How do I enable support for a multiport serial
card?Again, the section on kernel configuration provides
information about configuring your kernel. For a multiport
serial card, place an &man.sio.4; line for each serial
port on the card in the kernel configuration file. But
place the irq and vector specifiers on only one of the
entries. All of the ports on the card should share one
irq. For consistency, use the last serial port to specify
the irq. Also, specify the
COM_MULTIPORT option.The following example is for an AST 4-port serial card on
irq 7:options "COM_MULTIPORT"
device sio4 at isa? port 0x2a0 tty flags 0x781
device sio5 at isa? port 0x2a8 tty flags 0x781
device sio6 at isa? port 0x2b0 tty flags 0x781
device sio7 at isa? port 0x2b8 tty flags 0x781 irq 7 vector siointrThe flags indicate that the master port has minor number 7
(0x700), diagnostics enabled during probe
(0x080), and all the ports share an irq
(0x001).Can FreeBSD handle multiport serial cards sharing
irqs?Not yet. You will have to use a different irq for each
card.Can I set the default serial parameters for a
port?The
ttydX
(or
cuaaX)
device is the regular device you will want to open for
your applications. When a process opens the device, it
will have a default set of terminal I/O settings. You can
see these settings with the command&prompt.root; stty -a -f /dev/ttyd1When you change the settings to this device, the settings
are in effect until the device is closed. When it is reopened,
it goes back to the default set. To make changes to the
default set, you can open and adjust the settings of the
initial state device. For example, to turn on
CLOCAL mode, 8 bits, and
XON/XOFF flow control by default for
ttyd5, do:&prompt.root; stty -f /dev/ttyid5 clocal cs8 ixon ixoffA good place to do this is in
/etc/rc.serial. Now, an application
will have these settings by default when it opens
ttyd5. It can still change these
settings to its liking, though.You can also prevent certain settings from being
changed by an application by making adjustments to the
lock state device. For example, to lock
the speed of ttyd5 to 57600 bps,
do&prompt.root; stty -f /dev/ttyld5 57600Now, an application that opens
ttyd5 and tries to change the
speed of the port will be stuck with 57600 bps.Naturally, you should make the initial state and lock
state devices writable only by
root. The &man.MAKEDEV.8; script does
NOT do this when it creates the
device entries.How can I enable dialup logins on my modem?So you want to become an Internet service provider, eh?
First, you will need one or more modems that can auto-answer.
Your modem will need to assert carrier-detect when it detects a
carrier and not assert it all the time. It will need to hang up
the phone and reset itself when the data terminal ready
(DTR) line goes from on to off. It should
probably use RTS/CTS flow control or no
local flow control at all. Finally, it must use a constant
speed between the computer and itself, but (to be nice to your
callers) it should negotiate a speed between itself and the
remote modem.For many Hayes command-set--compatible modems, this
command will make these settings and store them in
nonvolatile memory:AT &C1 &D3 &K3 &Q6 S0=1 &WSee the section on sending AT
commands below for information on how to make these
settings without resorting to an &ms-dos; terminal program.Next, make an entry in /etc/ttys
(see &man.ttys.5;) for the modem. This file lists all the
ports on which the operating system will await logins.
Add a line that looks something like this:ttyd1 "/usr/libexec/getty std.57600" dialup on insecureThis line indicates that the second serial port
(/dev/ttyd1) has a modem
connected running at 57600 bps and no parity
(std.57600, which comes from the file
/etc/gettytab, see &man.gettytab.5;).
The terminal type for this port is
dialup. The port is
on and is
insecure---meaning
root logins on the port are not
allowed. For dialin ports like this one, use the
ttydX
entry.It is common practice to use dialup
as the terminal type. Many users set up in their
.profile or
.login files a prompt for the actual
terminal type if the starting type is dialup. The example
shows the port as insecure. To become
root on this port, you have to login
as a regular user, then &man.su.1; to become
root. If you use
secure then root
can login in directly.After making modifications to
/etc/ttys, you need to send a hangup
or HUP signal to the &man.init.8;
process:&prompt.root; kill -HUP 1This forces the &man.init.8; process to reread
/etc/ttys. The init process will
then start getty processes on all on
ports. You can find out if logins are available for your
port by typing&prompt.user; ps -ax | grep '[t]tyd1'You should see something like:747 ?? I 0:00.04 /usr/libexec/getty std.57600 ttyd1How can I connect a dumb terminal to my FreeBSD
box?If you are using another computer as a terminal into your
FreeBSD system, get a null-modem cable to go between the two
serial ports. If you are using an actual terminal, see its
accompanying instructions.Then, modify /etc/ttys (see
&man.ttys.5;), like above. For example, if you are
hooking up a WYSE-50 terminal to the fifth serial port,
use an entry like this:ttyd4 "/usr/libexec/getty std.38400" wyse50 on secureThis example shows that the port on
/dev/ttyd4 has a wyse50 terminal
connected at 38400 bps with no parity
(std.38400 from
/etc/gettytab, see &man.gettytab.5;)
and root logins are allowed
(secure).Why can I not run tip or
cu?On your system, the programs &man.tip.1; and
&man.cu.1; are probably executable only by
uucp and group
dialer. You can use the group
dialer to control who has access to
your modem or remote systems. Just add yourself to group
dialer.Alternatively, you can let everyone on your system run
&man.tip.1; and &man.cu.1; by typing:&prompt.root; chmod 4511 /usr/bin/cu
&prompt.root; chmod 4511 /usr/bin/tipMy stock Hayes modem is not supported---what
can I do?Actually, the manual page for &man.tip.1; is out of
date. There is a generic Hayes dialer already built in.
Just use at=hayes in your
/etc/remote (see &man.remote.5;)
file.The Hayes driver is not smart enough to recognize some of
the advanced features of newer modems---messages like
BUSY, NO DIALTONE, or
CONNECT 115200 will just confuse it. You
should turn those messages off when you use &man.tip.1;
(using ATX0&W).Also, the dial timeout for &man.tip.1; is 60
seconds. Your modem should use something less, or else tip
will think there is a communication problem. Try
ATS7=45&W.Actually, as shipped &man.tip.1; does not yet
support it fully. The solution is to edit the file
tipconf.h in the directory
/usr/src/usr.bin/tip/tip. Obviously you
need the source distribution to do this.Edit the line #define HAYES 0
to #define HAYES 1. Then
make and make install.
Everything works nicely after that.How am I expected to enter these AT commands?Make what is called a direct entry in
your /etc/remote file (see
&man.remote.5;). For example, if your modem is hooked up
to the first serial port,
/dev/cuaa0, then put in the
following line:cuaa0:dv=/dev/cuaa0:br#19200:pa=noneUse the highest bps rate your modem supports in the br
capability. Then, type tip
cuaa0 (see &man.tip.1;)
and you will be connected to your modem.If there is no /dev/cuaa0 on your
system, do this:&prompt.root; cd /dev
&prompt.root; sh MAKEDEV cuaa0Or use cu as root with the
following command:&prompt.root; cu -lline -sspeedwith line being the serial
port (e.g. /dev/cuaa0) and
speed being the speed
(e.g.57600). When you are done
entering the AT commands hit ~. to
exit.Why does the <@> sign for the pn
capability not work?The <@> sign in the phone
number capability tells tip to look in
/etc/phones for a phone number. But
the <@> sign is also a special
character in capability files like
/etc/remote. Escape it with a
backslash:pn=\@How can I dial a phone number on the command
line?Put what is called a generic entry in
your /etc/remote file (see
&man.remote.5;). For example:tip115200|Dial any phone number at 115200 bps:\
:dv=/dev/cuaa0:br#115200:at=hayes:pa=none:du:
tip57600|Dial any phone number at 57600 bps:\
:dv=/dev/cuaa0:br#57600:at=hayes:pa=none:du:Then you can do something like tip -115200
5551234. If you prefer &man.cu.1; over
&man.tip.1;, use a generic cu entry:cu115200|Use cu to dial any number at 115200bps:\
:dv=/dev/cuaa1:br#57600:at=hayes:pa=none:du:and type cu 5551234 -s 115200.Do I have to type in the bps rate every time I do
that?Put in an entry for tip1200 or
cu1200, but go ahead and use whatever
bps rate is appropriate with the br capability.
&man.tip.1; thinks a good default is 1200 bps which is why
it looks for a tip1200 entry. You do
not have to use 1200 bps, though.How can I more easily access a number of hosts through a
terminal server?Rather than waiting until you are connected and typing
CONNECT host
each time, use tip's cm capability. For
example, these entries in
/etc/remote (see &man.remote.5;):pain|pain.deep13.com|Forrester's machine:\
:cm=CONNECT pain\n:tc=deep13:
muffin|muffin.deep13.com|Frank's machine:\
:cm=CONNECT muffin\n:tc=deep13:
deep13:Gizmonics Institute terminal server:\
:dv=/dev/cuaa2:br#38400:at=hayes:du:pa=none:pn=5551234:will let you type tip pain or
tip muffin to connect to the hosts
pain or muffin; and
tip deep13 to get to the terminal
server.Can tip try more than one line for each site?This is often a problem where a university has several
modem lines and several thousand students trying to use
them...Make an entry for your university in
/etc/remote (see &man.remote.5;) and
use <\@> for the
pn capability:big-university:\
:pn=\@:tc=dialout
dialout:\
:dv=/dev/cuaa3:br#9600:at=courier:du:pa=none:Then, list the phone numbers for the university in
/etc/phones (see &man.phones.5;):big-university 5551111
big-university 5551112
big-university 5551113
big-university 5551114&man.tip.1;
will try each one in the listed order, then give
up. If you want to keep retrying, run &man.tip.1;
in a while loop.Why do I have to hit CTRLP
twice to send CTRLP
once?CTRLP
is the default force character, used to
tell &man.tip.1; that the next character is literal data.
You can set the force character to any other character
with the ~s escape, which means
set a variable.Type ~sforce=single-char
followed by a newline.
single-char is any single
character. If you leave out
single-char, then the force
character is the nul character, which you can get by
typing CTRL2
or CTRLSPACE.
A pretty good value for
single-char is SHIFTCTRL6,
which I have seen only used on some terminal
servers.You can have the force character be whatever you want
by specifying the following in your
$HOME/.tiprc file:force=single-charWhy is everything I type suddenly in UPPER CASE?You must have pressed CTRLA,
&man.tip.1; raise character, specially
designed for people with broken Caps Lock
keys. Use ~s as above and set the
variable raisechar to something reasonable.
In fact, you can set it to the same as the force
character, if you never expect to use either of these
features.Here is a sample .tiprc file perfect for Emacs users
who need to type CTRL2
and CTRLA
a lot:force=^^
raisechar=^^The ^^ is SHIFTCTRL6.How can I do file transfers with
tip?If you are talking to another &unix; system, you can
send and receive files with ~p (put)
and ~t (take). These commands run
&man.cat.1; and &man.echo.1; on the remote system to
accept and send files. The syntax is:~p <local-file> [<remote-file>]
~t <remote-file> [<local-file>]There is no error checking, so you probably should use
another protocol, like zmodem.How can I run zmodem with
tip?First, install one of the zmodem programs from the
ports collection (such as one of the two from the comms
category, lrzsz or
rzsz.To receive files, start the sending program on the
remote end. Then, press enter and type ~C
rz (or ~C lrz if you
installed lrzsz) to begin
receiving them locally.To send files, start the receiving program on the
remote end. Then, press enter and type ~C sz
files (or ~C
lsz files) to send
them to the remote system.Miscellaneous QuestionsFreeBSD uses far more swap space than &linux;. Why?FreeBSD only appears to use more swap than &linux;. In
actual fact, it does not. The main difference between FreeBSD
and &linux; in this regard is that FreeBSD will proactively move
entirely idle, unused pages of main memory into swap in order
to make more main memory available for active use. &linux; tends
to only move pages to swap as a last resort. The perceived
heavier use of swap is balanced by the more efficient use of
main memory.Note that while FreeBSD is proactive in this regard, it
does not arbitrarily decide to swap pages when the system is
truly idle. Thus you will not find your system all paged
out when you get up in the morning after leaving it idle
overnight.Why does top show very little free
memory even when I have very few programs running?The simple answer is that free memory is wasted
memory. Any memory that your programs do not actively
allocate is used within the FreeBSD kernel as disk
cache. The values shown by &man.top.1; labeled as
Inact, Cache, and
Buf are all cached data at different
aging levels. This cached data means the system does
not have to access a slow disk again for data it has
accessed recently, thus increasing overall performance.
In general, a low value shown for Free
memory in &man.top.1; is good, provided it is not
very low.Why will chmod not change the
permissions on symlinks?Symlinks do not have permissions, and by default,
&man.chmod.1; will not follow symlinks to change the
permissions on the target file. So if you have a file,
foo, and a symlink to that file,
bar, then this command will always
succeed.&prompt.user; chmod g-w barHowever, the permissions on foo will
not have changed.You have to use either or
together with the
option to make this work. See the &man.chmod.1; and
&man.symlink.7; manual pages for more info.The option does a
RECURSIVE &man.chmod.1;. Be
careful about specifying directories or symlinks to
directories to &man.chmod.1;. If you want to change
the permissions of a directory referenced by a
symlink, use &man.chmod.1; without any options and
follow the symlink with a trailing slash
(/). For example, if
foo is a symlink to directory
bar, and you want to change the
permissions of foo (actually
bar), you would do something
like:&prompt.user; chmod 555 foo/With the trailing slash, &man.chmod.1; will follow
the symlink, foo, to change the
permissions of the directory,
bar.Can I run DOS binaries under FreeBSD?Yes, you can use emulators/doscmd, a DOS emulation
program, available in the &os; Ports Collection.The doscmd program used to be an
integrated part of &os;, but was removed before the release of
&os; 5.3.If doscmd will not suffice,
the add-on utility emulators/pcemu emulates an 8088 and
enough BIOS services to run many DOS text mode
applications. It requires the X Window System.What do I need to do to translate a FreeBSD document into
my native language?See the
Translation FAQ in the FreeBSD Documentation Project
Primer.Why does my email to any address at FreeBSD.org bounce?The FreeBSD.org mail system implements some of the
stricter Postfix checks on incoming mail and rejects mail that is
either misconfigured or is potential spam. Your mail
might bounce for one of the following reasons:The email is being sent from a known spam
domain or IP block.The FreeBSD mail servers reject email from known
spam sources. If you have service through a company
or domain who generates or relays spam, please switch
to a service provider who does not.The body of the email only contains HTML.Mail should be sent in plain text only. Please
configure your mail user agent to send plain
text.The mailer at FreeBSD.org cannot resolve the IP
address of the connecting host back to a symbolic
name.Working reverse DNS is a standard requirement for
accepting mail from a host. Set up reverse DNS for
your mail server's IP address. Many home services
(DSL, cable, dialup, etc.) will not give you this
option. In this case, relay your email through your
service provider's mail server.The hostname given in the EHLO/HELO part of the SMTP
exchange cannot be resolved to an IP address.A fully qualified, resolvable host name is necessary
in this part of the SMTP dialogue before mail will be
accepted. If you do not have a host name that is registered
in the DNS, then you should use your service provider's mail
server to relay your mail.Your message had a message ID ending with the string
localhost.Some mail user agents generate bad message IDs which will
not be accepted. You will need to persuade your mail user
agent to generate a valid message ID or else configure your
mail transfer agent to rewrite them.Where can I find a free FreeBSD account?While FreeBSD does not provide open access to any of their
servers, others do provide open access &unix; systems. The
charge varies and limited services may be available.Arbornet,
Inc, also known as M-Net, has been providing open
access to &unix; systems since 1983. Starting on an Altos
running System III, the site switched to BSD/OS in 1991. In
June of 2000, the site switched again to FreeBSD. M-Net can be
accessed via telnet and SSH and provides basic access to the
entire FreeBSD software suite. However, network access is
limited to members and patrons who donate to the system, which
is run as a non-profit organization. M-Net also provides an
bulletin board system and interactive chat.Grex provides a
site very similar to M-Net including the same bulletin board
and interactive chat software. However, the machine is a &sun;
4M and is running &sunos;.What is sup, and how do I use
it?
SUP stands for Software Update Protocol, and was
developed by CMU for keeping their development trees in sync.
We used it to keep remote sites in sync with our central
development sources.SUP is not bandwidth friendly, and has been retired.
The current recommended method to keep your sources up to
date is
CVSupWhat is the cute little red guy's name?He does not have one, and is just called the BSD
daemon. If you insist upon using a name, call him
beastie. Note that beastie
is pronounced BSD.You can learn more about the BSD daemon on his home
page.Can I use the BSD daemon image?Perhaps. The BSD daemon is copyrighted by Marshall
Kirk McKusick. You will want to check his Statement
on the Use of the BSD Daemon Figure for detailed
usage terms.In summary, you are free to use the image in a tasteful
manner, for personal use, so long as appropriate credit is
given. If you want to use him commercially, you must
contact Kirk McKusick. More details are available on the
BSD
Daemon's home page.Do you have any BSD daemon images I could use?You will find eps and Xfig drawings under
/usr/share/examples/BSD_daemon/.I have seen an acronym or other term on the mailing
lists and I do not understand what it means. Where should
I look?Please see the
&os Glossary.Why should I care what color the bikeshed is?The really, really short answer is that you should not.
The somewhat longer answer is that just because you are
capable of building a bikeshed does not mean you should stop
others from building one just because you do not like the
color they plan to paint it. This is a metaphor indicating
that you need not argue about every little feature just
because you know enough to do so. Some people have
commented that the amount of noise generated by a change is
inversely proportional to the complexity of the
change.The longer and more complete answer is that after a very
long argument about whether &man.sleep.1; should take
fractional second arguments, &a.phk; posted a long
message entitled A bike
shed (any color will do) on greener grass....
The appropriate portions of that message are quoted
below.
&a.phk; on freebsd-hackers, October
2, 1999What is it about this bike shed? Some
of you have asked me.It is a long story, or rather it is an old story, but
it is quite short actually. C. Northcote Parkinson wrote
a book in the early 1960s, called Parkinson's
Law, which contains a lot of insight into the
dynamics of management.[snip a bit of commentary on the book]In the specific example involving the bike shed, the
other vital component is an atomic power-plant, I guess
that illustrates the age of the book.Parkinson shows how you can go into the board of
directors and get approval for building a multi-million or
even billion dollar atomic power plant, but if you want to
build a bike shed you will be tangled up in endless
discussions.Parkinson explains that this is because an atomic
plant is so vast, so expensive and so complicated that
people cannot grasp it, and rather than try, they fall
back on the assumption that somebody else checked all the
details before it got this far. Richard P. Feynmann
gives a couple of interesting, and very much to the point,
examples relating to Los Alamos in his books.A bike shed on the other hand. Anyone can build one
of those over a weekend, and still have time to watch the
game on TV. So no matter how well prepared, no matter how
reasonable you are with your proposal, somebody will seize
the chance to show that he is doing his job, that he is
paying attention, that he is
here.In Denmark we call it setting your
fingerprint. It is about personal pride and
prestige, it is about being able to point somewhere and
say There! I did that.
It is a strong trait in politicians, but present in most
people given the chance. Just think about footsteps in
wet cement.
The FreeBSD FunniesHow cool is FreeBSD?Q. Has anyone done any temperature testing while
running FreeBSD? I know &linux; runs cooler than DOS, but have
never seen a mention of FreeBSD. It seems to run really
hot.A. No, but we have done numerous taste tests on
blindfolded volunteers who have also had 250 micrograms of
LSD-25 administered beforehand. 35% of the volunteers said that
FreeBSD tasted sort of orange, whereas &linux; tasted like purple
haze. Neither group mentioned any significant variances in
temperature. We eventually had to throw the
results of this survey out entirely anyway when we found that
too many volunteers were wandering out of the room during the
tests, thus skewing the results. We think most of the volunteers
are at Apple now, working on their new scratch and
sniff GUI. It is a funny old business we are in!Seriously, both FreeBSD and &linux; use the
HLT (halt) instruction when the system is
idle thus lowering its energy consumption and therefore the
heat it generates. Also if you have APM (advanced power
management) configured, then FreeBSD can also put the CPU into
a low power mode.Who is scratching in my memory banks??Q. Is there anything odd that FreeBSD
does when compiling the kernel which would cause the memory to
make a scratchy sound? When compiling (and for a brief moment
after recognizing the floppy drive upon startup, as well), a
strange scratchy sound emanates from what appears to be the
memory banks.A. Yes! You will see frequent references to
daemons in the BSD documentation, and what most
people do not know is that this refers to genuine, non-corporeal
entities that now possess your computer. The scratchy sound
coming from your memory is actually high-pitched whispering
exchanged among the daemons as they best decide how to deal
with various system administration tasks.If the noise gets to you, a good
fdisk /mbr from DOS will get rid of them,
but do not be surprised if they react adversely and try to stop
you. In fact, if at any point during the exercise you hear the
satanic voice of Bill Gates coming from the built-in speaker,
take off running and do not ever look back! Freed from the
counterbalancing influence of the BSD daemons, the twin demons
of DOS and &windows; are often able to re-assert total control
over your machine to the eternal damnation of your soul.
Now that you know, given a choice you would probably prefer to get
used to the scratchy noises, no?How many FreeBSD hackers does it take to change a
lightbulb?One thousand, one hundred and sixty-nine:Twenty-three to complain to -CURRENT about the lights
being out;Four to claim that it is a configuration problem, and
that such matters really belong on -questions;Three to submit PRs about it, one of which is misfiled
under doc and consists only of it's dark;One to commit an untested lightbulb which breaks
buildworld, then back it out five minutes later;Eight to flame the PR originators for not including
patches in their PRs;Five to complain about buildworld being broken;Thirty-one to answer that it works for them, and they
must have cvsupped at a bad time;One to post a patch for a new lightbulb to -hackers;One to complain that he had patches for this three years
ago, but when he sent them to -CURRENT they were just ignored,
and he has had bad experiences with the PR system; besides,
the proposed new lightbulb is non-reflexive;Thirty-seven to scream that lightbulbs do not belong in
the base system, that committers have no right to do things
like this without consulting the Community, and WHAT IS
-CORE DOING ABOUT IT!?Two hundred to complain about the color of the bicycle
shed;Three to point out that the patch breaks &man.style.9;;Seventeen to complain that the proposed new lightbulb is
under GPL;Five hundred and eighty-six to engage in a flame war
about the comparative advantages of the GPL, the BSD
license, the MIT license, the NPL, and the personal hygiene
of unnamed FSF founders;Seven to move various portions of the thread to -chat
and -advocacy;One to commit the suggested lightbulb, even though it
shines dimmer than the old one;Two to back it out with a furious flame of a commit
message, arguing that FreeBSD is better off in the dark than
with a dim lightbulb;Forty-six to argue vociferously about the backing out
of the dim lightbulb and demanding a statement from
-core;Eleven to request a smaller lightbulb so it will fit
their Tamagotchi if we ever decide to port FreeBSD to that
platform;Seventy-three to complain about the SNR on -hackers and
-chat and unsubscribe in protest;Thirteen to post unsubscribe,
How do I unsubscribe?, or Please
remove me from the list, followed by the usual
footer;One to commit a working lightbulb while everybody is too
busy flaming everybody else to notice;Thirty-one to point out that the new lightbulb would shine
0.364% brighter if compiled with TenDRA (although it will have
to be reshaped into a cube), and that FreeBSD should therefore
switch to TenDRA instead of GCC;One to complain that the new lightbulb lacks
fairings;Nine (including the PR originators) to ask
what is MFC?;Fifty-seven to complain about the lights being out two
weeks after the bulb has been changed.&a.nik; adds:I was laughing quite hard at
this.And then I thought, Hang on,
shouldn't there be '1 to document it.' in that list
somewhere?And then I was enlightened :-)Where does data written to /dev/null
go?It goes into a special data sink in the CPU where it
is converted to heat which is vented through the heatsink
/ fan assembly. This is why CPU cooling is increasingly
important; as people get used to faster processors, they
become careless with their data and more and more of it
ends up in /dev/null, overheating
their CPUs. If you delete /dev/null
(which effectively disables the CPU data sink) your CPU
may run cooler but your system will quickly become
constipated with all that excess data and start to behave
erratically. If you have a fast network connection you
can cool down your CPU by reading data out of
/dev/random and sending it off
somewhere; however you run the risk of overheating your
network connection and / or angering
your ISP, as most of the data will end up getting
converted to heat by their equipment, but they generally
have good cooling, so if you do not overdo it you should be
OK.Paul Robinson adds:There are other methods. As every good sysadmin knows,
it is part of standard practice to send data to the screen
of interesting variety to keep all the pixies that make up
your picture happy. Screen pixies (commonly mis-typed or
re-named as pixels are categorized by the type of hat
they wear (red, green or blue) and will hide or appear
(thereby showing the color of their hat) whenever they
receive a little piece of food. Video cards turn data into
pixie-food, and then send them to the pixies - the more
expensive the card, the better the food, so the better
behaved the pixies are. They also need constant stimulation
- this is why screen savers exist.To take your suggestions further, you could just throw
the random data to console, thereby letting the pixies
consume it. This causes no heat to be produced at all,
keeps the pixies happy and gets rid of your data quite
quickly, even if it does make things look a bit messy on
your screen.Incidentally, as an ex-admin of a large ISP who
experienced many problems attempting to maintain a stable
temperature in a server room, I would strongly discourage
people sending the data they do not want out to the
network. The fairies who do the packet switching and
routing get annoyed by it as well.Advanced TopicsHow can I learn more about FreeBSD's internals?At this time, there is only one book on FreeBSD-specific OS
internals, namely The Design and Implementation of the
FreeBSD Operating System by Marshall Kirk McKusick and
George V. Neville-Neil, ISBN 0-201-70245-2, which
focuses on version 5.X of FreeBSD.Additionally, much general &unix; knowledge is directly
applicable to FreeBSD.For a list of relevant books, please check the Handbook's Operating
System Internals Bibliography.How can I contribute to FreeBSD?Please see the article on Contributing
to FreeBSD for specific advice on how to do this.
Assistance is more than welcome!What are SNAPs and RELEASEs?There are currently three active/semi-active branches
in the FreeBSD CVS
Repository. (Earlier branches are only changed
very rarely, which is why there are only three active
branches of development):RELENG_5 AKA
5-STABLERELENG_6 AKA
6-STABLEHEAD AKA
-CURRENT AKA
7.X-CURRENTHEAD is not an actual branch tag,
like the other two; it is simply a symbolic constant for
the current, non-branched development
stream which we simply refer to as
-CURRENT.Right now, -CURRENT is the 7.X development
stream; the 5-STABLE branch,
RELENG_5, forked off from
-CURRENT in October 2004, and
the 6-STABLE branch,
RELENG_6, forked off from
-CURRENT in November 2005.How do I make my own custom release?Please see the
Release Engineering article.Why does make world clobber my existing
installed binaries?Yes, this is the general idea; as its name might suggest,
make world rebuilds every system binary from
scratch, so you can be certain of having a clean and consistent
environment at the end (which is why it takes so long).If the environment variable DESTDIR
is defined while running make world or
make install, the newly-created binaries
will be deposited in a directory tree identical to the
installed one, rooted at ${DESTDIR}.
Some random combination of shared libraries modifications and
program rebuilds can cause this to fail in make
world however.Why isn't cvsup.FreeBSD.org a round robin DNS entry to
share the load amongst the various CVSup servers?While CVSup mirrors update from the master CVSup
server hourly, this update might happen at any time during
the hour. This means that some servers have newer code
than others, even though all servers have code that is
less than an hour old. If cvsup.FreeBSD.org was a round
robin DNS entry that simply redirected users to a random
CVSup server, running CVSup twice in a row could download
code older than the code already on the system.Why does my system say (bus speed
defaulted) when it boots?The Adaptec 1542 SCSI host adapters allow the user to
configure their bus access speed in software. Previous versions
of the 1542 driver tried to determine the fastest usable speed
and set the adapter to that. We found that this breaks some
users' systems, so you now have to define the
TUNE_1542 kernel configuration option in order
to have this take place. Using it on those systems where it
works may make your disks run faster, but on those systems
where it does not, your data could be corrupted.Can I follow -CURRENT with limited Internet access?Yes, you can do this without
downloading the whole source tree by using the CTM facility.How did you split the distribution into 240k files?Newer BSD based systems have a
option to &man.split.1; that allows them to split files on arbitrary
byte boundaries.Here is an example from
/usr/src/Makefile.bin-tarball:
(cd ${DISTDIR}; \
tar cf - . \
gzip --no-name -9 -c | \
split -b 240640 - \
${RELEASEDIR}/tarballs/bindist/bin_tgz.)I have written a kernel extension, who do I send it
to?Please take a look at the article on Contributing
to FreeBSD to learn how to submit code.And thanks for the thought!How are Plug N Play ISA cards detected and
initialized?By: Frank Durda IV
uhclem@nemesis.lonestar.orgIn a nutshell, there a few I/O ports that all of the
PnP boards respond to when the host asks if anyone is out
there. So when the PnP probe routine starts, it asks if there
are any PnP boards present, and all the PnP boards respond with
their model # to a I/O read of the same port, so the probe
routine gets a wired-OR yes to that question. At
least one bit will be on in that reply. Then the probe code is
able to cause boards with board model IDs (assigned by
Microsoft/Intel) lower than X to go off-line. It
then looks to see if any boards are still responding to the
query. If the answer was 0, then there are
no boards with IDs above X. Now probe asks if there are any
boards below X. If so, probe knows there are
boards with a model numbers below X. Probe then asks for boards
greater than X-(limit/4) to go off-line. If repeats the query.
By repeating this semi-binary search of IDs-in-range enough
times, the probing code will eventually identify all PnP boards
present in a given machine with a number of iterations that is
much lower than what 2^64 would take.The IDs are two 32-bit fields (hence 2ˆ64) + 8 bit
checksum. The first 32 bits are a vendor identifier. They never
come out and say it, but it appears to be assumed that
different types of boards from the same vendor could have
different 32-bit vendor ids. The idea of needing 32 bits just
for unique manufacturers is a bit excessive.The lower 32 bits are a serial #, Ethernet address,
something that makes this one board unique. The vendor must
never produce a second board that has the same lower 32 bits
unless the upper 32 bits are also different. So you can have
multiple boards of the same type in the machine and the full 64
bits will still be unique.The 32 bit groups can never be all zero. This allows the
wired-OR to show non-zero bits during the initial binary
search.Once the system has identified all the board IDs present,
it will reactivate each board, one at a time (via the same I/O
ports), and find out what resources the given board needs, what
interrupt choices are available, etc. A scan is made over all
the boards to collect this information.This info is then combined with info from any ECU files
on the hard disk or wired into the MLB BIOS. The ECU and BIOS
PnP support for hardware on the MLB is usually synthetic, and
the peripherals do not really do genuine PnP. However by
examining the BIOS info plus the ECU info, the probe routines
can cause the devices that are PnP to avoid those devices the
probe code cannot relocate.Then the PnP devices are visited once more and given
their I/O, DMA, IRQ and Memory-map address assignments. The
devices will then appear at those locations and remain there
until the next reboot, although there is nothing that says you
cannot move them around whenever you want.There is a lot of oversimplification above, but you
should get the general idea.Microsoft took over some of the primary printer status
ports to do PnP, on the logic that no boards decoded those
addresses for the opposing I/O cycles. I found a genuine IBM
printer board that did decode writes of the status port during
the early PnP proposal review period, but MS said
tough. So they do a write to the printer status
port for setting addresses, plus that use that address +
0x800, and a third I/O port for reading that
can be located anywhere between 0x200 and
0x3ff.Can you assign a major number for a device driver I have
written?&os.current; after February 2003 has a facility for
dynamically and automatically allocating major numbers for
device drivers at runtime. This mechanism is highly
preferred to the older procedure of statically allocating
device numbers. Some comments on this subject can be
found in src/sys/conf/majors.If you are forced for some reason to use a static
major number, the procedure for obtaining one depends on
whether or not you plan on making the driver publicly
available. If you do, then please send us a copy of the
driver source code, plus the appropriate modifications to
files.i386, a sample configuration
file entry, and the appropriate &man.MAKEDEV.8; code to
create any special files your device uses. If you do not,
or are unable to because of licensing restrictions, then
character major number 32 and block major number 8 have
been reserved specifically for this purpose; please use
them. In any case, we would appreciate hearing about your
driver on the &a.hackers;.What about alternative layout policies for
directories?In answer to the question of alternative layout policies
for directories, the scheme that is currently in use is
unchanged from what I wrote in 1983. I wrote that policy for
the original fast filesystem, and never revisited it. It works
well at keeping cylinder groups from filling up. As several of
you have noted, it works poorly for find. Most filesystems are
created from archives that were created by a depth first search
(aka ftw). These directories end up being striped across the
cylinder groups thus creating a worst possible scenario for
future depth first searches. If one knew the total number of
directories to be created, the solution would be to create
(total / fs_ncg) per cylinder group before moving on.
Obviously, one would have to create some heuristic to guess at
this number. Even using a small fixed number like say 10 would
make an order of magnitude improvement. To differentiate
restores from normal operation (when the current algorithm is
probably more sensible), you could use the clustering of up to
10 if they were all done within a ten second window. Anyway, my
conclusion is that this is an area ripe for
experimentation.Kirk McKusick, September 1998How can I make the most of the data I see when my kernel
panics?[This section was extracted from a mail
written by &a.wpaul; on the freebsd-current
mailing list by &a.des;, who
fixed a few typos and added the bracketed comments]
From: Bill Paul <wpaul@skynet.ctr.columbia.edu>
Subject: Re: the fs fun never stops
To: Ben Rosengart
Date: Sun, 20 Sep 1998 15:22:50 -0400 (EDT)
Cc: current@FreeBSD.orgBen Rosengart posted the following
panic message]> Fatal trap 12: page fault while in kernel mode
> fault virtual address = 0x40
> fault code = supervisor read, page not present
> instruction pointer = 0x8:0xf014a7e5
^^^^^^^^^^
> stack pointer = 0x10:0xf4ed6f24
> frame pointer = 0x10:0xf4ed6f28
> code segment = base 0x0, limit 0xfffff, type 0x1b
> = DPL 0, pres 1, def32 1, gran 1
> processor eflags = interrupt enabled, resume, IOPL = 0
> current process = 80 (mount)
> interrupt mask =
> trap number = 12
> panic: page fault[When] you see a message like this, it is not enough to just
reproduce it and send it in. The instruction pointer value that
I highlighted up there is important; unfortunately, it is also
configuration dependent. In other words, the value varies
depending on the exact kernel image that you are using. If
you are using a GENERIC kernel image from one of the snapshots,
then it is possible for somebody else to track down the
offending function, but if you are running a custom kernel then
only you can tell us where the fault
occurred.What you should do is this:Write down the instruction pointer value. Note that
the 0x8: part at the beginning is not
significant in this case: it is the
0xf0xxxxxx part that we want.When the system reboots, do the following:
&prompt.user; nm -n /kernel.that.caused.the.panic | grep f0xxxxxx
where f0xxxxxx is the instruction
pointer value. The odds are you will not get an exact
match since the symbols in the kernel symbol table are
for the entry points of functions and the instruction
pointer address will be somewhere inside a function, not
at the start. If you do not get an exact match, omit the
last digit from the instruction pointer value and try
again, i.e.:
&prompt.user; nm -n /kernel.that.caused.the.panic | grep f0xxxxx
If that does not yield any results, chop off another
digit. Repeat until you get some sort of output. The
result will be a possible list of functions which caused
the panic. This is a less than exact mechanism for
tracking down the point of failure, but it is better than
nothing.I see people constantly show panic messages like this
but rarely do I see someone take the time to match up the
instruction pointer with a function in the kernel symbol
table.The best way to track down the cause of a panic is by
capturing a crash dump, then using &man.gdb.1; to generate
a stack trace on the crash dump.In any case, the method I normally use is this:Set up a kernel config file, optionally adding
options DDB if you think you need
the kernel debugger for something. (I use this mainly
for setting breakpoints if I suspect an infinite loop
condition of some kind.)Use config -g
KERNELCONFIG to set
up the build directory.cd /sys/compile/KERNELCONFIG; makeWait for kernel to finish compiling.make installrebootThe &man.make.1; process will have built two kernels.
kernel and
kernel.debug.
kernel was installed as
/kernel, while
kernel.debug can be used as the
source of debugging symbols for &man.gdb.1;.To make sure you capture a crash dump, you need edit
/etc/rc.conf and set
dumpdev to point to your swap
partition. This will cause the &man.rc.8; scripts to use
the &man.dumpon.8; command to enable crash dumps. You can
also run &man.dumpon.8; manually. After a panic, the
crash dump can be recovered using &man.savecore.8;; if
dumpdev is set in
/etc/rc.conf, the &man.rc.8; scripts
will run &man.savecore.8; automatically and put the crash
dump in /var/crash.FreeBSD crash dumps are usually the same size as the
physical RAM size of your machine. That is, if you have
64MB of RAM, you will get a 64MB crash dump. Therefore you
must make sure there is enough space in
/var/crash to hold the dump.
Alternatively, you run &man.savecore.8;
manually and have it recover the crash dump to another
directory where you have more room. It is possible to limit
the size of the crash dump by using options
MAXMEM=(foo) to set the amount of memory the
kernel will use to something a little more sensible. For
example, if you have 128MB of RAM, you can limit the
kernel's memory usage to 16MB so that your crash dump size
will be 16MB instead of 128MB.Once you have recovered the crash dump, you can get a
stack trace with &man.gdb.1; as follows:&prompt.user; gdb -k /sys/compile/KERNELCONFIG/kernel.debug /var/crash/vmcore.0(gdb)whereNote that there may be several screens worth of
information; ideally you should use
&man.script.1; to capture all of them. Using the
unstripped kernel image with all the debug symbols should show
the exact line of kernel source code where the panic occurred.
Usually you have to read the stack trace from the bottom up in
order to trace the exact sequence of events that lead to the
crash. You can also use &man.gdb.1; to print out
the contents of various variables or structures in order to
examine the system state at the time of the crash.Now, if you are really insane and have a second computer,
you can also configure &man.gdb.1; to do remote
debugging such that you can use &man.gdb.1; on
one system to debug the kernel on another system, including
setting breakpoints, single-stepping through the kernel code,
just like you can do with a normal user-mode program. I have not
played with this yet as I do not often have the chance to set up
two machines side by side for debugging purposes.[Bill adds: "I forgot to mention one thing: if
you have DDB enabled and the kernel drops into the debugger,
you can force a panic (and a crash dump) just by typing 'panic'
at the ddb prompt. It may stop in the debugger again during the
panic phase. If it does, type 'continue' and it will finish the
crash dump." -ed]Why has dlsym() stopped working for ELF executables?The ELF toolchain does not, by default, make the symbols
defined in an executable visible to the dynamic linker.
Consequently dlsym() searches on handles
obtained from calls to dlopen(NULL,
flags) will fail to find such symbols.If you want to search, using
dlsym(), for symbols present in the
main executable of a process, you need to link the
executable using the
option to the ELF linker (&man.ld.1;).How can I increase or reduce the kernel address space?By default, the kernel address space is 256 MB on
FreeBSD 3.X and 1 GB on FreeBSD 4.X. If you run a
network-intensive server (e.g. a large FTP or HTTP server),
you might find that 256 MB is not enough.So how do you increase the address space? There are two
aspects to this. First, you need to tell the kernel to reserve
a larger portion of the address space for itself. Second, since
the kernel is loaded at the top of the address space, you need
to lower the load address so it does not bump its head against
the ceiling.The first goal is achieved by increasing the value of
NKPDE in
src/sys/i386/include/pmap.h. Here is what
it looks like for a 1 GB address space:#ifndef NKPDE
#ifdef SMP
#define NKPDE 254 /* addressable number of page tables/pde's */
#else
#define NKPDE 255 /* addressable number of page tables/pde's */
#endif /* SMP */
#endifTo find the correct value of NKPDE,
divide the desired address space size (in megabytes) by four,
then subtract one for UP and two for SMP.To achieve the second goal, you need to compute the
correct load address: simply subtract the address space size
(in bytes) from 0x100100000; the result is 0xc0100000 for a 1
GB address space. Set LOAD_ADDRESS in
src/sys/i386/conf/Makefile.i386 to that
value; then set the location counter in the beginning of the
section listing in
src/sys/i386/conf/kernel.script to the
same value, as follows:OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(btext)
SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/obj/elf/home/src/tmp/usr/i386-unknown-freebsdelf/lib);
SECTIONS
{
/* Read-only sections, merged into text segment: */
. = 0xc0100000 + SIZEOF_HEADERS;
.interp : { *(.interp) }Then reconfig and rebuild your kernel. You will
probably have problems with &man.ps.1; &man.top.1; and the
like; make world should take care of it
(or a manual rebuild of libkvm,
&man.ps.1; and &man.top.1; after copying the patched
pmap.h to
/usr/include/vm/.NOTE: the size of the kernel address space must be a
multiple of four megabytes.[&a.dg; adds: I think the kernel address space
needs to be a power of two, but I am not certain about that. The
old(er) boot code used to monkey with the high order address bits
and I think expected at least 256MB
granularity.]AcknowledgmentsThis innocent little Frequently Asked Questions document has
been written, rewritten, edited, folded, spindled, mutilated,
eviscerated, contemplated, discombobulated, cogitated,
regurgitated, rebuilt, castigated, and reinvigorated over the
last decade, by a cast of hundreds if not thousands.
Repeatedly.We wish to thank every one of the people responsible, and we
encourage you to to join them
in making this FAQ even better.
&bibliography;
Index: head/en_US.ISO8859-1/books/fdp-primer/the-website/chapter.sgml
===================================================================
--- head/en_US.ISO8859-1/books/fdp-primer/the-website/chapter.sgml (revision 29515)
+++ head/en_US.ISO8859-1/books/fdp-primer/the-website/chapter.sgml (revision 29516)
@@ -1,207 +1,207 @@
The WebsitePreparationGet 200MB free disk space. You will need the disk space for the
SGML tools, a subset of the CVS tree, temporary build space and the
installed web pages. If you already have installed the SGML tools and
the CVS tree, you need only ~100MB free disk space.Make sure your documentation ports are up to date! When in
doubt, remove the old ports using &man.pkg.delete.1; command before
installing the port. For example, we currently depend on
jade-1.2 and if you have installed jade-1.1, please do:&prompt.root; pkg_delete jade-1.1Set up a CVS repository. You need the directories www, doc and
ports in the CVS tree (plus the CVSROOT of course). Please read the
CVSup introduction
on how to mirror a CVS tree or parts of a CVS tree.The essential cvsup collections are: www,
doc-all, cvs-base, and
ports-base.These collections require ~105MB free disk space.A full CVS tree - including src,
doc, www, and
ports - is currently 940MB.Build the web pages from scratchCreate and change directory into a build directory with at least 60MB of free
space.&prompt.root; mkdir /var/tmp/webbuild
&prompt.root; cd /var/tmp/webbuildCheckout the SGML files from the CVS tree.&prompt.root; cvs -R co www docChange into the www/en directory, and run
the &man.make.1; all target, to create
the web pages.
- &prompt.root; cd en
+ &prompt.root; cd www/en
&prompt.root; make allInstall the web pages into your web serverIf you have moved out of the en
directory, change back to it.&prompt.root; cd path/www/enRun the &man.make.1; install target,
setting the DESTDIR variable to the name of the
directory you want to install the files to.&prompt.root; make DESTDIR=/usr/local/www installIf you have previously installed the web pages into the same
directory the install process will not have deleted any old or
outdated pages. For example, if you build and install a new copy
of the site every day, this command will find and delete all
files that have not been updated in three days.&prompt.root; find /usr/local/www -ctime 3 -print0 | xargs -0 rmEnvironment variablesCVSROOTLocation of the CVS tree. Essential.&prompt.root; CVSROOT=/home/ncvs; export CVSROOTENGLISH_ONLYIf set and not empty, the makefiles will build and
install only the English documents. All translations will be
ignored. E.g.:&prompt.root; make ENGLISH_ONLY=YES all installIf you want to unset the variable
ENGLISH_ONLY and build all pages, including
translations, set the variable ENGLISH_ONLY
to an empty value:&prompt.root; make ENGLISH_ONLY="" all install cleanWEB_ONLYIf set and not empty, the makefiles will build and install
only the HTML pages from the www directory. All documents from
the doc directory (Handbook, FAQ, Tutorials) will be ignored.
E.g.:&prompt.root; make WEB_ONLY=YES all installNOPORTSCVSIf set, the makefiles will not checkout files from the ports
cvs repository. Instead, it will copy the files from
/usr/ports (or where the variable
PORTSBASE points to).CVSROOT is an environment variable. You must set it
on the command line or in your dot files (e.g., ~/.profile).WEB_ONLY, ENGLISH_ONLY and
NOPORTSCVS are makefile variables. You can set the
variables in /etc/make.conf,
Makefile.inc, as environment variables on the
command line, or in your dot files.
Index: head/en_US.ISO8859-1/books/handbook/mirrors/chapter.sgml
===================================================================
--- head/en_US.ISO8859-1/books/handbook/mirrors/chapter.sgml (revision 29515)
+++ head/en_US.ISO8859-1/books/handbook/mirrors/chapter.sgml (revision 29516)
@@ -1,3233 +1,3233 @@
Obtaining FreeBSDCDROM and DVD PublishersRetail Boxed ProductsFreeBSD is available as a boxed product (FreeBSD CDs,
additional software, and printed documentation) from several
retailers:CompUSA
WWW: Frys Electronics
WWW: CD and DVD SetsFreeBSD CD and DVD sets are available from many online
retailers:BSD Mall by Daemon NewsPO Box 161Nauvoo, IL62354USA
Phone: +1 866 273-6255
Fax: +1 217 453-9956
Email: sales@bsdmall.com
WWW: BSD-Systems
Email: info@bsd-systems.co.uk
WWW: FreeBSD Mall, Inc.3623 Sanford StreetConcord, CA94520-1405USA
Phone: +1 925 674-0783
Fax: +1 925 674-0821
Email: info@freebsdmall.com
WWW: Dr. Hinner EDVSt. Augustinus-Str. 10D-81825MünchenGermany
Phone: (089) 428 419
WWW: Ikarios22-24 rue Voltaire92000NanterreFrance
WWW: JMC SoftwareIreland
Phone: 353 1 6291282
WWW: Linux CD MallPrivate Bag MBE N348Auckland 1030New Zealand
Phone: +64 21 866529
WWW: The Linux EmporiumHilliard House, Lester WayWallingfordOX10 9TAUnited Kingdom
Phone: +44 1491 837010
Fax: +44 1491 837016
WWW: Linux+ DVD MagazineLewartowskiego 6Warsaw00-190Poland
Phone: +48 22 860 18 18
Email: editors@lpmagazine.org
WWW: Linux System Labs Australia21 Ray DriveBalwyn NorthVIC - 3104Australia
Phone: +61 3 9857 5918
Fax: +61 3 9857 8974
WWW: LinuxCenter.RuGalernaya Street, 55Saint-Petersburg190000Russia
Phone: +7-812-3125208
Email: info@linuxcenter.ru
WWW: DistributorsIf you are a reseller and want to carry FreeBSD CDROM products,
please contact a distributor:Cylogistics809B Cuesta Dr., #2149Mountain View, CA94040USA
Phone: +1 650 694-4949
Fax: +1 650 694-4953
Email: sales@cylogistics.com
WWW: Ingram Micro1600 E. St. Andrew PlaceSanta Ana, CA92705-4926USA
Phone: 1 (800) 456-8000
WWW: Kudzu, LLC7375 Washington Ave. S.Edina, MN55439USA
Phone: +1 952 947-0822
Fax: +1 952 947-0876
Email: sales@kudzuenterprises.comLinuxCenter.RuGalernaya Street, 55Saint-Petersburg190000Russia
Phone: +7-812-3125208
Email: info@linuxcenter.ru
WWW: Navarre Corp7400 49th Ave SouthNew Hope, MN55428USA
Phone: +1 763 535-8333
Fax: +1 763 535-0341
WWW: FTP SitesThe official sources for FreeBSD are available via anonymous FTP
from a worldwide set of mirror sites. The site
is well
connected and allows a large number of connections to it, but
you are probably better off finding a closer
mirror site (especially if you decide to set up some sort of
mirror site).The FreeBSD mirror
sites database is more accurate than the mirror listing in the
Handbook, as it gets its information from the DNS rather than relying on
static lists of hosts.Additionally, FreeBSD is available via anonymous FTP from the
following mirror sites. If you choose to obtain FreeBSD via anonymous
FTP, please try to use a site near you. The mirror sites listed as
Primary Mirror Sites typically have the entire FreeBSD archive (all
the currently available versions for each of the architectures) but
you will probably have faster download times from a site that is
in your country or region. The regional sites carry the most recent
versions for the most popular architecture(s) but might not carry
the entire FreeBSD archive. All sites provide access via anonymous
FTP but some sites also provide access via other methods. The access
methods available for each site are provided in parentheses
after the hostname.
&chap.mirrors.ftp.inc;
Anonymous CVSIntroductionCVSanonymousAnonymous CVS (or, as it is otherwise known,
anoncvs) is a feature provided by the CVS
utilities bundled with FreeBSD for synchronizing with a remote
CVS repository. Among other things, it allows users of FreeBSD
to perform, with no special privileges, read-only CVS operations
against one of the FreeBSD project's official anoncvs servers.
To use it, one simply sets the CVSROOT
environment variable to point at the appropriate anoncvs server,
provides the well-known password anoncvs with the
cvs login command, and then uses the
&man.cvs.1; command to access it like any local
repository.The cvs login command, stores the passwords
that are used for authenticating to the CVS server in a file
called .cvspass in your
HOME directory. If this file does not exist,
you might get an error when trying to use cvs
login for the first time. Just make an empty
.cvspass file, and retry to login.While it can also be said that the CVSup and anoncvs
services both perform essentially the same function, there are
various trade-offs which can influence the user's choice of
synchronization methods. In a nutshell,
CVSup is much more efficient in its
usage of network resources and is by far the most technically
sophisticated of the two, but at a price. To use
CVSup, a special client must first be
installed and configured before any bits can be grabbed, and
then only in the fairly large chunks which
CVSup calls
collections.Anoncvs, by contrast, can be used
to examine anything from an individual file to a specific
program (like ls or grep)
by referencing the CVS module name. Of course,
anoncvs is also only good for
read-only operations on the CVS repository, so if it is your
intention to support local development in one repository shared
with the FreeBSD project bits then
CVSup is really your only
option.Using Anonymous CVSConfiguring &man.cvs.1; to use an Anonymous CVS repository
is a simple matter of setting the CVSROOT
environment variable to point to one of the FreeBSD project's
anoncvs servers. At the time of this
writing, the following servers are available:Austria:
:pserver:anoncvs@anoncvs.at.FreeBSD.org:/home/ncvs
(Use cvs login and enter any
password when prompted.)France:
:pserver:anoncvs@anoncvs.fr.FreeBSD.org:/home/ncvs
(pserver (password anoncvs), ssh (no password))
Germany:
:pserver:anoncvs@anoncvs.de.FreeBSD.org:/home/ncvs
(Use cvs login and enter the password
anoncvs when prompted.)Germany:
:pserver:anoncvs@anoncvs2.de.FreeBSD.org:/home/ncvs
(rsh, pserver, ssh, ssh/2022)
Japan:
:pserver:anoncvs@anoncvs.jp.FreeBSD.org:/home/ncvs
(Use cvs login and enter the password
anoncvs when prompted.)USA:
freebsdanoncvs@anoncvs.FreeBSD.org:/home/ncvs
(ssh only - no password)SSH HostKey: 1024 a1:e7:46:de:fb:56:ef:05:bc:73:aa:91:09:da:f7:f4 root@sanmateo.ecn.purdue.edu
SSH2 HostKey: 1024 52:02:38:1a:2f:a8:71:d3:f5:83:93:8d:aa:00:6f:65 ssh_host_dsa_key.pubUSA:
anoncvs@anoncvs1.FreeBSD.org:/home/ncvs (ssh only - no
password)SSH HostKey: 1024 8b:c4:6f:9a:7e:65:8a:eb:50:50:29:7c:a1:47:03:bc root@ender.liquidneon.com
SSH2 HostKey: 2048 4d:59:19:7b:ea:9b:76:0b:ca:ee:da:26:e2:3a:83:b8 ssh_host_dsa_key.pubSince CVS allows one to check out virtually
any version of the FreeBSD sources that ever existed (or, in
some cases, will exist), you need to be
familiar with the revision () flag to
&man.cvs.1; and what some of the permissible values for it in
the FreeBSD Project repository are.There are two kinds of tags, revision tags and branch tags.
A revision tag refers to a specific revision. Its meaning stays
the same from day to day. A branch tag, on the other hand,
refers to the latest revision on a given line of development, at
any given time. Because a branch tag does not refer to a
specific revision, it may mean something different tomorrow than
it means today. contains revision tags that users
might be interested
in. Again, none of these are valid for the Ports Collection
since the Ports Collection does not have multiple
revisions.When you specify a branch tag, you normally receive the
latest versions of the files on that line of development. If
you wish to receive some past version, you can do so by
specifying a date with the flag.
See the &man.cvs.1; manual page for more details.ExamplesWhile it really is recommended that you read the manual page
for &man.cvs.1; thoroughly before doing anything, here are some
quick examples which essentially show how to use Anonymous
CVS:Checking Out Something from -CURRENT (&man.ls.1;):&prompt.user; setenv CVSROOT :pserver:anoncvs@anoncvs.jp.FreeBSD.org:/home/ncvs
&prompt.user; cvs loginAt the prompt, enter the passwordanoncvs.
&prompt.user; cvs co lsUsing SSH to check out the src/
tree:&prompt.user; cvs -d freebsdanoncvs@anoncvs.FreeBSD.org:/home/ncvs co src
The authenticity of host 'anoncvs.freebsd.org (128.46.156.46)' can't be established.
DSA key fingerprint is 52:02:38:1a:2f:a8:71:d3:f5:83:93:8d:aa:00:6f:65.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'anoncvs.freebsd.org' (DSA) to the list of known hosts.Checking Out the Version of &man.ls.1; in the 6-STABLE
Branch:&prompt.user; setenv CVSROOT :pserver:anoncvs@anoncvs.jp.FreeBSD.org:/home/ncvs
&prompt.user; cvs loginAt the prompt, enter the passwordanoncvs.
&prompt.user; cvs co -rRELENG_6 lsCreating a List of Changes (as Unified Diffs) to &man.ls.1;&prompt.user; setenv CVSROOT :pserver:anoncvs@anoncvs.jp.FreeBSD.org:/home/ncvs
&prompt.user; cvs loginAt the prompt, enter the passwordanoncvs.
&prompt.user; cvs rdiff -u -rRELENG_5_3_0_RELEASE -rRELENG_5_4_0_RELEASE lsFinding Out What Other Module Names Can Be Used:&prompt.user; setenv CVSROOT :pserver:anoncvs@anoncvs.jp.FreeBSD.org:/home/ncvs
&prompt.user; cvs loginAt the prompt, enter the passwordanoncvs.
&prompt.user; cvs co modules
&prompt.user; more modules/modulesOther ResourcesThe following additional resources may be helpful in learning
CVS:CVS Tutorial from Cal Poly.CVS Home,
the CVS development and support community.CVSweb is
the FreeBSD Project web interface for CVS.Using CTMCTMCTM is a method for keeping a
remote directory tree in sync with a central one. It has been
developed for usage with FreeBSD's source trees, though other
people may find it useful for other purposes as time goes by.
Little, if any, documentation currently exists at this time on the
process of creating deltas, so contact the &a.ctm-users.name; mailing list for more
information and if you wish to use CTM
for other things.Why Should I Use CTM?CTM will give you a local copy of
the FreeBSD source trees. There are a number of
flavors of the tree available. Whether you wish
to track the entire CVS tree or just one of the branches,
CTM can provide you the information.
If you are an active developer on FreeBSD, but have lousy or
non-existent TCP/IP connectivity, or simply wish to have the
changes automatically sent to you,
CTM was made for you. You will need
to obtain up to three deltas per day for the most active
branches. However, you should consider having them sent by
automatic email. The sizes of the updates are always kept as
small as possible. This is typically less than 5K, with an
occasional (one in ten) being 10-50K and every now and then a
large 100K+ or more coming around.You will also need to make yourself aware of the various
caveats related to working directly from the development sources
rather than a pre-packaged release. This is particularly true
if you choose the current sources. It is
recommended that you read Staying
current with FreeBSD.What Do I Need to Use
CTM?You will need two things: The CTM
program, and the initial deltas to feed it (to get up to
current levels).The CTM program has been part of
FreeBSD ever since version 2.0 was released, and lives in
/usr/src/usr.sbin/ctm if you have a copy
of the source available.The deltas you feed
CTM can be had two ways, FTP or
email. If you have general FTP access to the Internet then the
following FTP sites support access to
CTM:or see section mirrors.FTP the relevant directory and fetch the
README file, starting from there.If you wish to get your deltas via email:Subscribe to one of the
CTM distribution lists.
&a.ctm-cvs-cur.name; supports the entire CVS tree.
&a.ctm-src-cur.name; supports the head of the development
branch. &a.ctm-src-4.name; supports the 4.X release
branch, etc.. (If you do not know how to subscribe yourself
to a list, click on the list name above or go to
&a.mailman.lists.link; and click on the list that you
wish to subscribe to. The list page should contain all of
the necessary subscription instructions.)When you begin receiving your CTM
updates in the mail, you may use the
ctm_rmail program to unpack and apply them.
You can actually use the ctm_rmail program
directly from a entry in /etc/aliases if
you want to have the process run in a fully automated fashion.
Check the ctm_rmail manual page for more
details.No matter what method you use to get the
CTM deltas, you should subscribe to
the &a.ctm-announce.name; mailing list. In
the future, this will be the only place where announcements
concerning the operations of the
CTM system will be posted. Click
on the list name above and follow the instructions
to subscribe to the
list.Using CTM for the First
TimeBefore you can start using CTM
deltas, you will need to get to a starting point for the deltas
produced subsequently to it.First you should determine what you already have. Everyone
can start from an empty directory. You must use
an initial Empty delta to start off your
CTM supported tree. At some point it
is intended that one of these started deltas be
distributed on the CD for your convenience, however, this does
not currently happen.Since the trees are many tens of megabytes, you should
prefer to start from something already at hand. If you have a
-RELEASE CD, you can copy or extract an initial source from it.
This will save a significant transfer of data.You can recognize these starter deltas by the
X appended to the number
(src-cur.3210XEmpty.gz for instance). The
designation following the X corresponds to
the origin of your initial seed.
Empty is an empty directory. As a rule a
base transition from Empty is produced
every 100 deltas. By the way, they are large! 70 to 80
Megabytes of gzip'd data is common for the
XEmpty deltas.Once you have picked a base delta to start from, you will also
need all deltas with higher numbers following it.Using CTM in Your Daily
LifeTo apply the deltas, simply say:&prompt.root; cd /where/ever/you/want/the/stuff
&prompt.root; ctm -v -v /where/you/store/your/deltas/src-xxx.*CTM understands deltas which have
been put through gzip, so you do not need to
gunzip them first, this saves disk space.Unless it feels very secure about the entire process,
CTM will not touch your tree. To
verify a delta you can also use the flag and
CTM will not actually touch your
tree; it will merely verify the integrity of the delta and see
if it would apply cleanly to your current tree.There are other options to CTM
as well, see the manual pages or look in the sources for more
information.That is really all there is to it. Every time you get a new
delta, just run it through CTM to
keep your sources up to date.Do not remove the deltas if they are hard to download again.
You just might want to keep them around in case something bad
happens. Even if you only have floppy disks, consider using
fdwrite to make a copy.Keeping Your Local ChangesAs a developer one would like to experiment with and change
files in the source tree. CTM
supports local modifications in a limited way: before checking
for the presence of a file foo, it first
looks for foo.ctm. If this file exists,
CTM will operate on it instead of
foo.This behavior gives us a simple way to maintain local
changes: simply copy the files you plan to modify to the
corresponding file names with a .ctm
suffix. Then you can freely hack the code, while CTM keeps the
.ctm file up-to-date.Other Interesting CTM OptionsFinding Out Exactly What Would Be Touched by an
UpdateYou can determine the list of changes that
CTM will make on your source
repository using the option to
CTM.This is useful if you would like to keep logs of the
changes, pre- or post- process the modified files in any
manner, or just are feeling a tad paranoid.Making Backups Before UpdatingSometimes you may want to backup all the files that would
be changed by a CTM update.Specifying the option
causes CTM to backup all files that
would be touched by a given CTM
delta to backup-file.Restricting the Files Touched by an UpdateSometimes you would be interested in restricting the scope
of a given CTM update, or may be
interested in extracting just a few files from a sequence of
deltas.You can control the list of files that
CTM would operate on by specifying
filtering regular expressions using the
and options.For example, to extract an up-to-date copy of
lib/libc/Makefile from your collection of
saved CTM deltas, run the commands:&prompt.root; cd /where/ever/you/want/to/extract/it/
&prompt.root; ctm -e '^lib/libc/Makefile' ~ctm/src-xxx.*For every file specified in a
CTM delta, the
and options are applied in the order given
on the command line. The file is processed by
CTM only if it is marked as
eligible after all the and
options are applied to it.Future Plans for CTMTons of them:Use some kind of authentication into the CTM system, so
as to allow detection of spoofed CTM updates.Clean up the options to CTM,
they became confusing and counter intuitive.Miscellaneous StuffThere is a sequence of deltas for the
ports collection too, but interest has not
been all that high yet.CTM MirrorsCTM/FreeBSD is available via anonymous
FTP from the following mirror sites. If you choose to obtain CTM via
anonymous FTP, please try to use a site near you.In case of problems, please contact the &a.ctm-users.name;
mailing list.California, Bay Area, official sourceSouth Africa, backup server for old deltasTaiwan/R.O.C.If you did not find a mirror near to you or the mirror is
incomplete, try to use a search engine such as
alltheweb.Using CVSupIntroductionCVSup is a software package for
distributing and updating source trees from a master CVS
repository on a remote server host. The FreeBSD sources are
maintained in a CVS repository on a central development machine
in California. With CVSup, FreeBSD
users can easily keep their own source trees up to date.CVSup uses the so-called
pull model of updating. Under the pull
model, each client asks the server for updates, if and when they
are wanted. The server waits passively for update requests from
its clients. Thus all updates are instigated by the client.
The server never sends unsolicited updates. Users must either
run the CVSup client manually to get
an update, or they must set up a cron job to
run it automatically on a regular basis.The term CVSup, capitalized just
so, refers to the entire software package. Its main components
are the client cvsup which runs on each
user's machine, and the server cvsupd which
runs at each of the FreeBSD mirror sites.As you read the FreeBSD documentation and mailing lists, you
may see references to sup.
Sup was the predecessor of
CVSup, and it served a similar
purpose. CVSup is used much in the
same way as sup and, in fact, uses configuration files which are
backward-compatible with sup's.
Sup is no longer used in the FreeBSD
project, because CVSup is both faster
and more flexible.InstallationThe easiest way to install CVSup
is to use the precompiled net/cvsup package
from the FreeBSD packages collection.
If you prefer to build CVSup from
source, you can use the net/cvsup
port instead. But be forewarned: the
net/cvsup port depends on the Modula-3
system, which takes a substantial amount of time and
disk space to download and build.If you are going to be using
CVSup on a machine which will not have
&xfree86; or &xorg; installed, such as a server, be
sure to use the port which does not include the
CVSup GUI,
net/cvsup-without-gui.CVSup ConfigurationCVSup's operation is controlled
by a configuration file called the supfile.
There are some sample supfiles in the
directory /usr/share/examples/cvsup/.The information in a supfile answers
the following questions for CVSup:Which files do you
want to receive?Which versions of them
do you want?Where do you want to
get them from?Where do you want to
put them on your own machine?Where do you want to
put your status files?In the following sections, we will construct a typical
supfile by answering each of these
questions in turn. First, we describe the overall structure of
a supfile.A supfile is a text file. Comments
begin with # and extend to the end of the
line. Lines that are blank and lines that contain only
comments are ignored.Each remaining line describes a set of files that the user
wishes to receive. The line begins with the name of a
collection, a logical grouping of files defined by
the server. The name of the collection tells the server which
files you want. After the collection name come zero or more
fields, separated by white space. These fields answer the
questions listed above. There are two types of fields: flag
fields and value fields. A flag field consists of a keyword
standing alone, e.g., delete or
compress. A value field also begins with a
keyword, but the keyword is followed without intervening white
space by = and a second word. For example,
release=cvs is a value field.A supfile typically specifies more than
one collection to receive. One way to structure a
supfile is to specify all of the relevant
fields explicitly for each collection. However, that tends to
make the supfile lines quite long, and it
is inconvenient because most fields are the same for all of the
collections in a supfile.
CVSup provides a defaulting mechanism
to avoid these problems. Lines beginning with the special
pseudo-collection name *default can be used
to set flags and values which will be used as defaults for the
subsequent collections in the supfile. A
default value can be overridden for an individual collection, by
specifying a different value with the collection itself.
Defaults can also be changed or augmented in mid-supfile by
additional *default lines.With this background, we will now proceed to construct a
supfile for receiving and updating the main
source tree of FreeBSD-CURRENT.Which files do you want
to receive?The files available via CVSup
are organized into named groups called
collections. The collections that are
available are described in the following section. In this
example, we
wish to receive the entire main source tree for the FreeBSD
system. There is a single large collection
src-all which will give us all of that.
As a first step toward constructing our
supfile, we
simply list the collections, one per line (in this case,
only one line):src-allWhich version(s) of them
do you want?With CVSup, you can receive
virtually any version of the sources that ever existed.
That is possible because the
cvsupd server works directly from
the CVS repository, which contains all of the versions. You
specify which one of them you want using the
tag= and value
fields.Be very careful to specify any tag=
fields correctly. Some tags are valid only for certain
collections of files. If you specify an incorrect or
misspelled tag, CVSup
will delete files which you probably
do not want deleted. In particular, use only
tag=. for the
ports-* collections.The tag= field names a symbolic tag
in the repository. There are two kinds of tags, revision
tags and branch tags. A revision tag refers to a specific
revision. Its meaning stays the same from day to day. A
branch tag, on the other hand, refers to the latest revision
on a given line of development, at any given time. Because
a branch tag does not refer to a specific revision, it may
mean something different tomorrow than it means
today. contains branch tags that
users might be interested in. When specifying a tag in
CVSup's configuration file, it
must be preceded with tag=
(RELENG_4 will become
tag=RELENG_4).
Keep in mind that only the tag=. is
relevant for the Ports Collection.Be very careful to type the tag name exactly as shown.
CVSup cannot distinguish
between valid and invalid tags. If you misspell the tag,
CVSup will behave as though you
had specified a valid tag which happens to refer to no
files at all. It will delete your existing sources in
that case.When you specify a branch tag, you normally receive the
latest versions of the files on that line of development.
If you wish to receive some past version, you can do so by
specifying a date with the value
field. The &man.cvsup.1; manual page explains how to do
that.For our example, we wish to receive FreeBSD-CURRENT. We
add this line at the beginning of our
supfile:*default tag=.There is an important special case that comes into play
if you specify neither a tag= field nor a
date= field. In that case, you receive
the actual RCS files directly from the server's CVS
repository, rather than receiving a particular version.
Developers generally prefer this mode of operation. By
maintaining a copy of the repository itself on their
systems, they gain the ability to browse the revision
histories and examine past versions of files. This gain is
achieved at a large cost in terms of disk space,
however.Where do you want to get
them from?We use the host= field to tell
cvsup where to obtain its updates. Any
of the CVSup mirror
sites will do, though you should try to select one
that is close to you in cyberspace. In this example we will
use a fictional FreeBSD distribution site,
cvsup99.FreeBSD.org:*default host=cvsup99.FreeBSD.orgYou will need to change the host to one that actually
exists before running CVSup.
On any particular run of
cvsup, you can override the host setting
on the command line, with .Where do you want to put
them on your own machine?The prefix= field tells
cvsup where to put the files it receives.
In this example, we will put the source files directly into
our main source tree, /usr/src. The
src directory is already implicit in
the collections we have chosen to receive, so this is the
correct specification:*default prefix=/usrWhere should
cvsup maintain its status files?The CVSup client maintains
certain status files in what
is called the base directory. These files
help CVSup to work more
efficiently, by keeping track of which updates you have
already received. We will use the standard base directory,
/var/db:*default base=/var/dbIf your base directory does not already exist, now would
be a good time to create it. The cvsup
client will refuse to run if the base directory does not
exist.Miscellaneous supfile
settings:There is one more line of boiler plate that normally
needs to be present in the
supfile:*default release=cvs delete use-rel-suffix compressrelease=cvs indicates that the server
should get its information out of the main FreeBSD CVS
repository. This is virtually always the case, but there
are other possibilities which are beyond the scope of this
discussion.delete gives
CVSup permission to delete files.
You should always specify this, so that
CVSup can keep your source tree
fully up-to-date. CVSup is
careful to delete only those files for which it is
responsible. Any extra files you happen to have will be
left strictly alone.use-rel-suffix is ... arcane. If you
really want to know about it, see the &man.cvsup.1; manual
page. Otherwise, just specify it and do not worry about
it.compress enables the use of
gzip-style compression on the communication channel. If
your network link is T1 speed or faster, you probably should
not use compression. Otherwise, it helps
substantially.Putting it all together:Here is the entire supfile for our
example:*default tag=.
*default host=cvsup99.FreeBSD.org
*default prefix=/usr
*default base=/var/db
*default release=cvs delete use-rel-suffix compress
src-allThe refuse FileAs mentioned above, CVSup uses
a pull method. Basically, this means that
you connect to the CVSup server, and
it says, Here is what you can download from
me..., and your client responds OK, I will take
this, this, this, and this. In the default
configuration, the CVSup client will
take every file associated with the collection and tag you
chose in the configuration file. However, this is not always
what you want, especially if you are synching the doc, ports, or
www trees — most people cannot read four or five
languages, and therefore they do not need to download the
language-specific files. If you are
CVSuping the Ports Collection, you
can get around this by specifying each collection individually
(e.g., ports-astrology,
ports-biology, etc instead of simply
saying ports-all). However, since the doc
and www trees do not have language-specific collections, you
must use one of CVSup's many nifty
features: the refuse file.The refuse file essentially tells
CVSup that it should not take every
single file from a collection; in other words, it tells the
client to refuse certain files from the
server. The refuse file can be found (or, if you do not yet
have one, should be placed) in
base/sup/.
base is defined in your supfile;
our defined base is
/var/db,
which means that by default the refuse file is
/var/db/sup/refuse.The refuse file has a very simple format; it simply
contains the names of files or directories that you do not wish
to download. For example, if you cannot speak any languages other
than English and some German, and you do not feel the need to read
the German translation of documentation, you can put the following in your
refuse file:doc/bn_*
doc/da_*
doc/de_*
doc/el_*
doc/es_*
doc/fr_*
doc/it_*
doc/ja_*
doc/nl_*
doc/no_*
doc/pl_*
doc/pt_*
doc/ru_*
doc/sr_*
doc/tr_*
doc/zh_*and so forth for the other languages (you can find the
full list by browsing the FreeBSD
CVS repository).With this very useful feature, those users who are on
slow links or pay by the minute for their Internet connection
will be able to save valuable time as they will no longer need
to download files that they will never use. For more
information on refuse files and other neat
features of CVSup, please view its
manual page.Running CVSupYou are now ready to try an update. The command line for
doing this is quite simple:&prompt.root; cvsup supfilewhere supfile
is of course the name of the supfile you have just created.
Assuming you are running under X11, cvsup
will display a GUI window with some buttons to do the usual
things. Press the go button, and watch it
run.Since you are updating your actual
/usr/src tree in this example, you will
need to run the program as root so that
cvsup has the permissions it needs to update
your files. Having just created your configuration file, and
having never used this program before, that might
understandably make you nervous. There is an easy way to do a
trial run without touching your precious files. Just create an
empty directory somewhere convenient, and name it as an extra
argument on the command line:&prompt.root; mkdir /var/tmp/dest
&prompt.root; cvsup supfile /var/tmp/destThe directory you specify will be used as the destination
directory for all file updates.
CVSup will examine your usual files
in /usr/src, but it will not modify or
delete any of them. Any file updates will instead land in
/var/tmp/dest/usr/src.
CVSup will also leave its base
directory status files untouched when run this way. The new
versions of those files will be written into the specified
directory. As long as you have read access to
/usr/src, you do not even need to be
root to perform this kind of trial run.If you are not running X11 or if you just do not like GUIs,
you should add a couple of options to the command line when you
run cvsup:&prompt.root; cvsup -g -L 2 supfileThe tells
CVSup not to use its GUI. This is
automatic if you are not running X11, but otherwise you have to
specify it.The tells
CVSup to print out the
details of all the file updates it is doing. There are three
levels of verbosity, from to
. The default is 0, which means total
silence except for error messages.There are plenty of other options available. For a brief
list of them, type cvsup -H. For more
detailed descriptions, see the manual page.Once you are satisfied with the way updates are working, you
can arrange for regular runs of CVSup
using &man.cron.8;.
Obviously, you should not let CVSup
use its GUI when running it from &man.cron.8;.CVSup File CollectionsThe file collections available via
CVSup are organized hierarchically.
There are a few large collections, and they are divided into
smaller sub-collections. Receiving a large collection is
equivalent to receiving each of its sub-collections. The
hierarchical relationships among collections are reflected by
the use of indentation in the list below.The most commonly used collections are
src-all, and
ports-all. The other collections are used
only by small groups of people for specialized purposes, and
some mirror sites may not carry all of them.cvs-all release=cvsThe main FreeBSD CVS repository, including the
cryptography code.distrib release=cvsFiles related to the distribution and mirroring
of FreeBSD.doc-all release=cvsSources for the FreeBSD Handbook and other
documentation. This does not include files for
the FreeBSD web site.ports-all release=cvsThe FreeBSD Ports Collection.If you do not want to update the whole of
ports-all (the whole ports tree),
but use one of the subcollections listed below,
make sure that you always update
the ports-base subcollection!
Whenever something changes in the ports build
infrastructure represented by
ports-base, it is virtually certain
that those changes will be used by real
ports real soon. Thus, if you only update the
real ports and they use some of the new
features, there is a very high chance that their build
will fail with some mysterious error message. The
very first thing to do in this
case is to make sure that your
ports-base subcollection is up to
date.If you are going to be building your own local
copy of ports/INDEX, you
must accept
ports-all (the whole ports tree).
Building ports/INDEX with
a partial tree is not supported. See the
FAQ.ports-accessibility
release=cvsSoftware to help disabled users.ports-arabic
release=cvsArabic language support.ports-archivers
release=cvsArchiving tools.ports-astro
release=cvsAstronomical ports.ports-audio
release=cvsSound support.ports-base
release=cvsThe Ports Collection build infrastructure -
various files located in the
Mk/ and
Tools/ subdirectories of
/usr/ports.Please see the important
warning above: you should
always update this
subcollection, whenever you update any part of
the FreeBSD Ports Collection!ports-benchmarks
release=cvsBenchmarks.ports-biology
release=cvsBiology.ports-cad
release=cvsComputer aided design tools.ports-chinese
release=cvsChinese language support.ports-comms
release=cvsCommunication software.ports-converters
release=cvscharacter code converters.ports-databases
release=cvsDatabases.ports-deskutils
release=cvsThings that used to be on the desktop
before computers were invented.ports-devel
release=cvsDevelopment utilities.ports-dns
release=cvsDNS related software.ports-editors
release=cvsEditors.ports-emulators
release=cvsEmulators for other operating
systems.ports-finance
release=cvsMonetary, financial and related applications.ports-ftp
release=cvsFTP client and server utilities.ports-games
release=cvsGames.ports-german
release=cvsGerman language support.ports-graphics
release=cvsGraphics utilities.ports-hebrew
release=cvsHebrew language support.ports-hungarian
release=cvsHungarian language support.ports-irc
release=cvsInternet Relay Chat utilities.ports-japanese
release=cvsJapanese language support.ports-java
release=cvs&java; utilities.ports-korean
release=cvsKorean language support.ports-lang
release=cvsProgramming languages.ports-mail
release=cvsMail software.ports-math
release=cvsNumerical computation software.ports-mbone
release=cvsMBone applications.ports-misc
release=cvsMiscellaneous utilities.ports-multimedia
release=cvsMultimedia software.ports-net
release=cvsNetworking software.ports-net-im
release=cvsInstant messaging software.ports-net-mgmt
release=cvsNetwork management software.ports-net-p2p
release=cvsPeer to peer networking.ports-news
release=cvsUSENET news software.ports-palm
release=cvsSoftware support for Palm
series.ports-polish
release=cvsPolish language support.ports-ports-mgmt
release=cvsUtilities to manage ports and packages.ports-portuguese
release=cvsPortuguese language support.ports-print
release=cvsPrinting software.ports-russian
release=cvsRussian language support.ports-science
release=cvsScience.ports-security
release=cvsSecurity utilities.ports-shells
release=cvsCommand line shells.ports-sysutils
release=cvsSystem utilities.ports-textproc
release=cvstext processing utilities (does not
include desktop publishing).ports-ukrainian
release=cvsUkrainian language support.ports-vietnamese
release=cvsVietnamese language support.ports-www
release=cvsSoftware related to the World Wide
Web.ports-x11
release=cvsPorts to support the X window
system.ports-x11-clocks
release=cvsX11 clocks.ports-x11-fm
release=cvsX11 file managers.ports-x11-fonts
release=cvsX11 fonts and font utilities.ports-x11-toolkits
release=cvsX11 toolkits.ports-x11-servers
release=cvsX11 servers.ports-x11-themes
release=cvsX11 themes.ports-x11-wm
release=cvsX11 window managers.projects-all release=cvsSources for the FreeBSD projects repository.src-all release=cvsThe main FreeBSD sources, including the
cryptography code.src-base
release=cvsMiscellaneous files at the top of
/usr/src.src-bin
release=cvsUser utilities that may be needed in
single-user mode
(/usr/src/bin).src-contrib
release=cvsUtilities and libraries from outside the
FreeBSD project, used relatively unmodified
(/usr/src/contrib).src-crypto release=cvsCryptography utilities and libraries from
outside the FreeBSD project, used relatively
unmodified
(/usr/src/crypto).src-eBones release=cvsKerberos and DES
(/usr/src/eBones). Not
used in current releases of FreeBSD.src-etc
release=cvsSystem configuration files
(/usr/src/etc).src-games
release=cvsGames
(/usr/src/games).src-gnu
release=cvsUtilities covered by the GNU Public
License (/usr/src/gnu).src-include
release=cvsHeader files
(/usr/src/include).src-kerberos5
release=cvsKerberos5 security package
(/usr/src/kerberos5).src-kerberosIV
release=cvsKerberosIV security package
(/usr/src/kerberosIV).src-lib
release=cvsLibraries
(/usr/src/lib).src-libexec
release=cvsSystem programs normally executed by other
programs
(/usr/src/libexec).src-release
release=cvsFiles required to produce a FreeBSD
release
(/usr/src/release).src-sbin release=cvsSystem utilities for single-user mode
(/usr/src/sbin).src-secure
release=cvsCryptographic libraries and commands
(/usr/src/secure).src-share
release=cvsFiles that can be shared across multiple
systems
(/usr/src/share).src-sys
release=cvsThe kernel
(/usr/src/sys).src-sys-crypto
release=cvsKernel cryptography code
(/usr/src/sys/crypto).src-tools
release=cvsVarious tools for the maintenance of
FreeBSD
(/usr/src/tools).src-usrbin
release=cvsUser utilities
(/usr/src/usr.bin).src-usrsbin
release=cvsSystem utilities
(/usr/src/usr.sbin).www release=cvsThe sources for the FreeBSD WWW site.distrib release=selfThe CVSup server's own
configuration files. Used by CVSup
mirror sites.gnats release=currentThe GNATS bug-tracking database.mail-archive release=currentFreeBSD mailing list archive.www release=currentThe pre-processed FreeBSD WWW site files (not the
source files). Used by WWW mirror sites.For More InformationFor the CVSup FAQ and other
information about CVSup, see
The
CVSup Home Page.Most FreeBSD-related discussion of
CVSup takes place on the
&a.hackers;. New versions of the software are announced there,
as well as on the &a.announce;.Questions and bug reports should be addressed to the author
of the program at cvsup-bugs@polstra.com.CVSup SitesCVSup servers for FreeBSD are running
at the following sites:
&chap.mirrors.cvsup.inc;
Using PortsnapIntroductionPortsnap is a system for securely
distributing the &os; ports tree. Approximately once an hour,
a snapshot of the ports tree is generated,
repackaged, and cryptographically signed. The resulting files
are then distributed via HTTP.Like CVSup,
Portsnap uses a
pull model of updating: The packaged and
signed ports trees are placed on a web server which waits
passively for clients to request files. Users must either run
&man.portsnap.8; manually to download updates
or set up a &man.cron.8; job to download updates
automatically on a regular basis.For technical reasons, Portsnap
does not update the live ports tree in
/usr/ports/ directly; instead, it works
via a compressed copy of the ports tree stored in
/var/db/portsnap/ by default. This
compressed copy is then used to update the live ports tree.If Portsnap is installed from
the &os; Ports Collection, then the default location for its
compressed snapshot will be /usr/local/portsnap/
instead of /var/db/portsnap/.InstallationOn &os; 6.0 and more recent versions,
Portsnap is contained in the &os;
base system. On older versions of &os;, it can be installed
- using the sysutils/portsnap
+ using the ports-mgmt/portsnap
port.Portsnap ConfigurationPortsnap's operation is controlled
by the /etc/portsnap.conf configuration
file. For most users, the default configuration file will
suffice; for more details, consult the &man.portsnap.conf.5;
manual page.If Portsnap is installed from
the &os; Ports Collection, it will use the configuration file
/usr/local/etc/portsnap.conf instead of
/etc/portsnap.conf. This configuration
file is not created when the port is installed, but a sample
configuration file is distributed; to copy it into place, run
the following command:&prompt.root; cd /usr/local/etc && cp portsnap.conf.sample portsnap.confRunning Portsnap for the First
TimeThe first time &man.portsnap.8; is run,
it will need to download a compressed snapshot of the entire
ports tree into /var/db/portsnap/ (or
/usr/local/portsnap/ if
Portsnap was installed from the
Ports Collection). For the beginning of 2006 this is approximately a 41 MB
download.&prompt.root; portsnap fetchOnce the compressed snapshot has been downloaded, a
live copy of the ports tree can be extracted into
/usr/ports/. This is necessary even if a
ports tree has already been created in that directory (e.g., by
using CVSup), since it establishes a
baseline from which portsnap can
determine which parts of the ports tree need to be updated
later.&prompt.root; portsnap extractIn the default installation
/usr/ports is not
created. If you run &os; 6.0-RELEASE, it should be created before
portsnap is used. On more recent
versions of &os; or Portsnap,
this operation will be done automatically at first use
of the portsnap command.Updating the Ports TreeAfter an initial compressed snapshot of the ports tree has
been downloaded and extracted into /usr/ports/,
updating the ports tree consists of two steps:
fetching updates to the compressed
snapshot, and using them to update the
live ports tree. These two steps can be specified to
portsnap as a single command:&prompt.root; portsnap fetch updateSome older versions of portsnap
do not support this syntax; if it fails, try instead the
following:&prompt.root; portsnap fetch
&prompt.root; portsnap updateRunning Portsnap from cronIn order to avoid problems with flash crowds
accessing the Portsnap servers,
portsnap fetch will not run from
a &man.cron.8; job. Instead, a special
portsnap cron command exists, which
waits for a random duration up to 3600 seconds before fetching
updates.In addition, it is strongly recommended that
portsnap update not be run from a
cron job, since it is liable to cause
major problems if it happens to run at the same time as a port
is being built or installed. However, it is safe to update
the ports' INDEX files, and this can be done by passing the
flag to
portsnap. (Obviously, if
portsnap -I update is run from
cron, then it will be necessary to run
portsnap update without the
flag at a later time in order to update the rest of the tree.)Adding the following line to /etc/crontab
will cause portsnap to update its
compressed snapshot and the INDEX files in
/usr/ports/, and will send an email if any
installed ports are out of date:0 3 * * * root portsnap -I cron update && pkg_version -vIL=If the system clock is not set to the local time zone,
please replace 3 with a random
value between 0 and 23, in order to spread the load on the
Portsnap servers more evenly.Some older versions of portsnap
do not support listing multiple commands (e.g., cron update)
in the same invocation of portsnap. If
the line above fails, try replacing
portsnap -I cron update with
portsnap cron && portsnap -I update.CVS TagsWhen obtaining or updating sources using
cvs or
CVSup, a revision tag must be specified.
A revision tag refers to either a particular line of &os;
development, or a specific point in time. The first type are called
branch tags, and the second type are called
release tags.Branch TagsAll of these, with the exception of HEAD (which
is always a valid tag), only apply to the src/
tree. The ports/, doc/, and
www/ trees are not branched.HEADSymbolic name for the main line, or FreeBSD-CURRENT.
Also the default when no revision is specified.In CVSup, this tag is represented
by a . (not punctuation, but a literal
. character).In CVS, this is the default when no revision tag is
specified. It is usually not
a good idea to checkout or update to CURRENT sources
on a STABLE machine, unless that is your intent.RELENG_6The line of development for FreeBSD-6.X, also known
as FreeBSD 6-STABLERELENG_6_2The release branch for FreeBSD-6.2, used only for
security advisories and other critical fixes.RELENG_6_1The release branch for FreeBSD-6.1, used only for
security advisories and other critical fixes.RELENG_6_0The release branch for FreeBSD-6.0, used only for
security advisories and other critical fixes.RELENG_5The line of development for FreeBSD-5.X, also known
as FreeBSD 5-STABLE.RELENG_5_5The release branch for FreeBSD-5.5, used only
for security advisories and other critical fixes.RELENG_5_4The release branch for FreeBSD-5.4, used only
for security advisories and other critical fixes.RELENG_5_3The release branch for FreeBSD-5.3, used only
for security advisories and other critical fixes.RELENG_5_2The release branch for FreeBSD-5.2 and FreeBSD-5.2.1, used only
for security advisories and other critical fixes.RELENG_5_1The release branch for FreeBSD-5.1, used only
for security advisories and other critical fixes.RELENG_5_0The release branch for FreeBSD-5.0, used only
for security advisories and other critical fixes.RELENG_4The line of development for FreeBSD-4.X, also known
as FreeBSD 4-STABLE.RELENG_4_11The release branch for FreeBSD-4.11, used only
for security advisories and other critical fixes.RELENG_4_10The release branch for FreeBSD-4.10, used only
for security advisories and other critical fixes.RELENG_4_9The release branch for FreeBSD-4.9, used only
for security advisories and other critical fixes.RELENG_4_8The release branch for FreeBSD-4.8, used only
for security advisories and other critical fixes.RELENG_4_7The release branch for FreeBSD-4.7, used only
for security advisories and other critical fixes.RELENG_4_6The release branch for FreeBSD-4.6 and FreeBSD-4.6.2,
used only for security advisories and other
critical fixes.RELENG_4_5The release branch for FreeBSD-4.5, used only
for security advisories and other critical fixes.RELENG_4_4The release branch for FreeBSD-4.4, used only
for security advisories and other critical fixes.RELENG_4_3The release branch for FreeBSD-4.3, used only
for security advisories and other critical fixes.RELENG_3The line of development for FreeBSD-3.X, also known
as 3.X-STABLE.RELENG_2_2The line of development for FreeBSD-2.2.X, also known
as 2.2-STABLE. This branch is mostly obsolete.Release TagsThese tags refer to a specific point in time when a particular
version of &os; was released. The release engineering process is
documented in more detail by the
Release Engineering
Information and
Release
Process documents.
The src tree uses tag names that
start with RELENG_ tags.
The ports and
doc trees use tags whose names
begin with RELEASE tags.
Finally, the www tree is not
tagged with any special name for releases.RELENG_6_2_0_RELEASEFreeBSD 6.2RELENG_6_1_0_RELEASEFreeBSD 6.1RELENG_6_0_0_RELEASEFreeBSD 6.0RELENG_5_5_0_RELEASEFreeBSD 5.5RELENG_5_4_0_RELEASEFreeBSD 5.4RELENG_4_11_0_RELEASEFreeBSD 4.11RELENG_5_3_0_RELEASEFreeBSD 5.3RELENG_4_10_0_RELEASEFreeBSD 4.10RELENG_5_2_1_RELEASEFreeBSD 5.2.1RELENG_5_2_0_RELEASEFreeBSD 5.2RELENG_4_9_0_RELEASEFreeBSD 4.9RELENG_5_1_0_RELEASEFreeBSD 5.1RELENG_4_8_0_RELEASEFreeBSD 4.8RELENG_5_0_0_RELEASEFreeBSD 5.0RELENG_4_7_0_RELEASEFreeBSD 4.7RELENG_4_6_2_RELEASEFreeBSD 4.6.2RELENG_4_6_1_RELEASEFreeBSD 4.6.1RELENG_4_6_0_RELEASEFreeBSD 4.6RELENG_4_5_0_RELEASEFreeBSD 4.5RELENG_4_4_0_RELEASEFreeBSD 4.4RELENG_4_3_0_RELEASEFreeBSD 4.3RELENG_4_2_0_RELEASEFreeBSD 4.2RELENG_4_1_1_RELEASEFreeBSD 4.1.1RELENG_4_1_0_RELEASEFreeBSD 4.1RELENG_4_0_0_RELEASEFreeBSD 4.0RELENG_3_5_0_RELEASEFreeBSD-3.5RELENG_3_4_0_RELEASEFreeBSD-3.4RELENG_3_3_0_RELEASEFreeBSD-3.3RELENG_3_2_0_RELEASEFreeBSD-3.2RELENG_3_1_0_RELEASEFreeBSD-3.1RELENG_3_0_0_RELEASEFreeBSD-3.0RELENG_2_2_8_RELEASEFreeBSD-2.2.8RELENG_2_2_7_RELEASEFreeBSD-2.2.7RELENG_2_2_6_RELEASEFreeBSD-2.2.6RELENG_2_2_5_RELEASEFreeBSD-2.2.5RELENG_2_2_2_RELEASEFreeBSD-2.2.2RELENG_2_2_1_RELEASEFreeBSD-2.2.1RELENG_2_2_0_RELEASEFreeBSD-2.2.0AFS SitesAFS servers for FreeBSD are running at the following sites:SwedenThe path to the files are:
/afs/stacken.kth.se/ftp/pub/FreeBSD/stacken.kth.se # Stacken Computer Club, KTH, Sweden
130.237.234.43 #hot.stacken.kth.se
130.237.237.230 #fishburger.stacken.kth.se
130.237.234.3 #milko.stacken.kth.seMaintainer ftp@stacken.kth.sersync SitesThe following sites make FreeBSD available through the rsync
protocol. The rsync utility works in
much the same way as the &man.rcp.1; command,
but has more options and uses the rsync remote-update protocol
which transfers only the differences between two sets of files,
thus greatly speeding up the synchronization over the network.
This is most useful if you are a mirror site for the
FreeBSD FTP server, or the CVS repository. The
rsync suite is available for many
operating systems, on FreeBSD, see the
net/rsync
port or use the package.Czech Republicrsync://ftp.cz.FreeBSD.org/Available collections:ftp: A partial mirror of the FreeBSD FTP
server.FreeBSD: A full mirror of the FreeBSD FTP
server.Germanyrsync://grappa.unix-ag.uni-kl.de/Available collections:freebsd-cvs: The full FreeBSD CVS
repository.This machine also mirrors the CVS repositories of the
NetBSD and the OpenBSD projects, among others.Netherlandsrsync://ftp.nl.FreeBSD.org/Available collections:vol/4/freebsd-core: A full mirror of the
FreeBSD FTP server.United Kingdomrsync://rsync.mirror.ac.uk/Available collections:ftp.FreeBSD.org: A full mirror of the
FreeBSD FTP server.United States of Americarsync://ftp-master.FreeBSD.org/This server may only be used by FreeBSD primary mirror
sites.Available collections:FreeBSD: The master archive of the FreeBSD
FTP server.acl: The FreeBSD master ACL
list.rsync://ftp13.FreeBSD.org/Available collections:FreeBSD: A full mirror of the FreeBSD FTP
server.
Index: head/en_US.ISO8859-1/books/handbook/ports/chapter.sgml
===================================================================
--- head/en_US.ISO8859-1/books/handbook/ports/chapter.sgml (revision 29515)
+++ head/en_US.ISO8859-1/books/handbook/ports/chapter.sgml (revision 29516)
@@ -1,1432 +1,1432 @@
Installing Applications: Packages and PortsSynopsisportspackagesFreeBSD is bundled with a rich collection of system tools as
part of the base system. However, there is only so much one can
do before needing to install an additional third-party
application to get real work done. FreeBSD provides two
complementary technologies for installing third party software
on your system: the FreeBSD Ports Collection (for installing from
source), and packages (for installing from pre-built binaries).
Either method may be used to install the
newest version of your favorite applications from local media or
straight off the network.After reading this chapter, you will know:How to install third-party binary software packages.How to build third-party software from source by using the ports
collection.How to remove previously installed packages or ports.How to override the default values that the ports
collection uses.How to find the appropriate software package.How to upgrade your applications.Overview of Software InstallationIf you have used a &unix; system before you will know that
the typical procedure for installing third party software goes
something like this:Download the software, which might be distributed in
source code format, or as a binary.Unpack the software from its distribution format
(typically a tarball compressed with &man.compress.1;,
&man.gzip.1;, or &man.bzip2.1;).Locate the documentation (perhaps an
INSTALL or README
file, or some files in a doc/
subdirectory) and read up on how to install the
software.If the software was distributed in source format,
compile it. This may involve editing a
Makefile, or running a
configure script, and other work.Test and install the software.And that is only if everything goes well. If you are
installing a software package that was not deliberately ported
to FreeBSD you may even have to go in and edit the code to make
it work properly.Should you want to, you can continue to install software the
traditional way with FreeBSD. However, FreeBSD
provides two technologies which can save you a lot of effort:
packages and ports. At the time of writing, over &os.numports;
third party applications have been made available in this
way.For any given application, the FreeBSD package for that
application is a single file which you must download. The
package contains pre-compiled copies of all the commands for the
application, as well as any configuration files or
documentation. A downloaded package file can be manipulated
with FreeBSD package management commands, such as
&man.pkg.add.1;, &man.pkg.delete.1;, &man.pkg.info.1;, and so
on. Installing a new application can be carried out with a
single command.A FreeBSD port for an application is a collection of files
designed to automate the process of compiling an application
from source code.Remember that there are a number of steps you would normally
carry out if you compiled a program yourself (downloading,
unpacking, patching, compiling, installing). The files that
make up a port contain all the necessary information to allow
the system to do this for you. You run a handful of simple
commands and the source code for the application is
automatically downloaded, extracted, patched, compiled, and
installed for you.In fact, the ports system can also be used to generate packages
which can later be manipulated with pkg_add
and the other package management commands that will be introduced
shortly.Both packages and ports understand
dependencies. Suppose you want to install
an application that depends on a specific library being
installed. Both the application and the library have been made
available as FreeBSD ports and packages. If you use the
pkg_add command or the ports system to add
the application, both will notice that the library has not been
installed, and automatically install the library first.Given that the two technologies are quite similar, you might
be wondering why FreeBSD bothers with both. Packages and ports
both have their own strengths, and which one you use will depend
on your own preference.Package BenefitsA compressed package tarball is typically smaller than
the compressed tarball containing the source code for the
application.Packages do not require any additional compilation. For
large applications, such as
Mozilla,
KDE, or
GNOME this can be important,
particularly if you are on a slow system.Packages do not require any understanding of the process
involved in compiling software on FreeBSD.Ports BenefitsPackages are normally compiled with conservative options,
because they have to run on the maximum number of systems. By
installing from the port, you can tweak the compilation options to
(for example) generate code that is specific to a Pentium
IV or Athlon processor.Some applications have compile time options relating to
what they can and cannot do. For example,
Apache can be configured with a
wide variety of different built-in options. By building
from the port you do not have to accept the default options,
and can set them yourself.In some cases, multiple packages will exist for the same
application to specify certain settings. For example,
Ghostscript is available as a
ghostscript package and a
ghostscript-nox11 package, depending on
whether or not you have installed an X11 server. This sort
of rough tweaking is possible with packages, but rapidly
becomes impossible if an application has more than one or
two different compile time options.The licensing conditions of some software distributions forbid
binary distribution. They must be distributed as source
code.Some people do not trust binary distributions. At least
with source code, you can (in theory) read through it and
look for potential problems yourself.If you have local patches, you will need the source in order to
apply them.Some people like having code around, so they can read it
if they get bored, hack it, borrow from it (license
permitting, of course), and so on.To keep track of updated ports, subscribe to the
&a.ports; and the &a.ports-bugs;.Before installing any application, you should check for security issues
related to your application.You can also install security/portaudit which will
+ role="package">ports-mgmt/portaudit which will
automatically check all installed applications for known
vulnerabilities; a check will be also performed before any port
build. Meanwhile, you can use the command portaudit
-F -a after you have installed some
packages.The remainder of this chapter will explain how to use
packages and ports to install and manage third party software on
FreeBSD.Finding Your ApplicationBefore you can install any applications you need to know what you
want, and what the application is called.FreeBSD's list of available applications is growing all the
time. Fortunately, there are a number of ways to find what you
want:The FreeBSD web site maintains an up-to-date searchable
list of all the available applications, at http://www.FreeBSD.org/ports/.
The ports are divided into categories, and you may either
search for an application by name (if you know it), or see
all the applications available in a category.FreshPortsDan Langille maintains FreshPorts, at . FreshPorts
tracks changes to the applications in the ports tree as they
happen, allows you to watch one or more
ports, and can send you email when they are updated.FreshMeatIf you do not know the name of the application you want,
try using a site like FreshMeat () to find an
application, then check back at the FreeBSD site to see if
the application has been ported yet.If you know the exact name of the port, but just need to
find out which category it is in, you can use the
&man.whereis.1; command.
Simply type whereis
file, where
file is the program you want to
install. If it is found on your system, you will be told
where it is, as follows:&prompt.root; whereis lsof
lsof: /usr/ports/sysutils/lsofThis tells us that lsof (a system
utility) can be found in the
/usr/ports/sysutils/lsof
directory.Yet another way to find a particular port is by using the
Ports Collection's built-in search mechanism. To use the
search feature, you will need to be in the
/usr/ports directory. Once in that
directory, run make search
name=program-name where
program-name is the name of the
program you want to find. For example, if you were looking
for lsof:&prompt.root; cd /usr/ports
&prompt.root; make search name=lsof
Port: lsof-4.56.4
Path: /usr/ports/sysutils/lsof
Info: Lists information about open files (similar to fstat(1))
Maint: obrien@FreeBSD.org
Index: sysutils
B-deps:
R-deps: The part of the output you want to pay particular
attention to is the Path: line, since that
tells you where to find the port. The other information
provided is not needed in order to install the port, so it
will not be covered here.For more in-depth searching you can also use make
search key=string where
string is some text to search for.
This searches port names, comments, descriptions and
dependencies and can be used to find ports which relate to a
particular subject if you do not know the name of the program
you are looking for.In both of these cases, the search string is case-insensitive.
Searching for LSOF will yield the same results as
searching for lsof.ChernLeeContributed by Using the Packages SystemInstalling a Packagepackagesinstallingpkg_addYou can use the &man.pkg.add.1; utility to install a
FreeBSD software package from a local file or from a server on
the network.Downloading a Package Manually and Installing It Locally&prompt.root; ftp -a ftp2.FreeBSD.org
Connected to ftp2.FreeBSD.org.
220 ftp2.FreeBSD.org FTP server (Version 6.00LS) ready.
331 Guest login ok, send your email address as password.
230-
230- This machine is in Vienna, VA, USA, hosted by Verio.
230- Questions? E-mail freebsd@vienna.verio.net.
230-
230-
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>cd /pub/FreeBSD/ports/packages/sysutils/
250 CWD command successful.
ftp>get lsof-4.56.4.tgz
local: lsof-4.56.4.tgz remote: lsof-4.56.4.tgz
200 PORT command successful.
150 Opening BINARY mode data connection for 'lsof-4.56.4.tgz' (92375 bytes).
100% |**************************************************| 92375 00:00 ETA
226 Transfer complete.
92375 bytes received in 5.60 seconds (16.11 KB/s)
ftp>exit
&prompt.root; pkg_add lsof-4.56.4.tgzIf you do not have a source of local packages (such as a
FreeBSD CD-ROM set) then it will probably be easier to use the
option to &man.pkg.add.1;. This will
cause the utility to automatically determine the correct
object format and release and then fetch and install the
package from an FTP site.
pkg_add&prompt.root; pkg_add -r lsofThe example above would download the correct package and
add it without any further user intervention.
If you want to specify an alternative &os; Packages Mirror,
instead of the main distribution site, you have to set
PACKAGESITE accordingly, to
override the default settings. &man.pkg.add.1;
uses &man.fetch.3; to download the files, which honors various
environment variables, including
FTP_PASSIVE_MODE, FTP_PROXY, and
FTP_PASSWORD. You may need to set one or more
of these if you are behind a firewall, or need to use an
FTP/HTTP proxy. See &man.fetch.3; for the complete list.
Note that in the example above
lsof is used instead of
lsof-4.56.4. When the remote fetching
feature is used, the version number of the package must be
removed. &man.pkg.add.1; will automatically fetch the latest
version of the application.&man.pkg.add.1; will download the latest version of
your application if you are using &os.current; or
&os.stable;. If you run a -RELEASE version, it will grab
the version of the package that was built with your
release. It is possible to change this behavior by
overriding the PACKAGESITE environment
variable. For example, if you run a &os; 5.4-RELEASE
system, by default &man.pkg.add.1; will try to fetch
packages from
ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-5.4-release/Latest/.
If you want to force &man.pkg.add.1; to download
&os; 5-STABLE packages, set PACKAGESITE
to
ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-5-stable/Latest/.
Package files are distributed in .tgz
and .tbz formats. You can find them at ,
or on the FreeBSD CD-ROM distribution. Every CD on the
FreeBSD 4-CD set (and the PowerPak, etc.) contains packages
in the /packages directory. The layout
of the packages is similar to that of the
/usr/ports tree. Each category has its
own directory, and every package can be found within the
All directory.
The directory structure of the package system matches the
ports layout; they work with each other to form the entire
package/port system.
Managing Packagespackagesmanaging&man.pkg.info.1; is a utility that lists and describes
the various packages installed.
pkg_info&prompt.root; pkg_info
cvsup-16.1 A general network file distribution system optimized for CV
docbook-1.2 Meta-port for the different versions of the DocBook DTD
...&man.pkg.version.1; is a utility that summarizes the
versions of all installed packages. It compares the package
version to the current version found in the ports tree.
pkg_version&prompt.root; pkg_version
cvsup =
docbook =
...The symbols in the second column indicate the relative age
of the installed version and the version available in the
local ports tree.SymbolMeaning=The version of the
installed package matches the one found in the
local ports tree.<The installed version is older than the one available
in the ports tree.>The installed version is newer
than the one found in the local ports tree. (The local ports
tree is probably out of date.)?The installed package cannot be
found in the ports index. (This can happen, for instance, if an
installed port is removed from the Ports Collection or
renamed.)*There are multiple versions of the
package.Deleting a Packagepkg_deletepackagesdeletingTo remove a previously installed software package, use the
&man.pkg.delete.1; utility.
&prompt.root; pkg_delete xchat-1.7.1MiscellaneousAll package information is stored within the
/var/db/pkg directory. The installed
file list and descriptions of each package can be found within
files in this directory.
Using the Ports CollectionThe following sections provide basic instructions on using the
Ports Collection to install or remove programs from your
system. The detailed description of available make
targets and environment variables is available in &man.ports.7;.Obtaining the Ports CollectionBefore you can install ports, you must first obtain the
Ports Collection—which is essentially a set of
Makefiles, patches, and description files
placed in /usr/ports.
When installing your FreeBSD system,
sysinstall asked if you would like
to install the Ports Collection. If you chose no, you can
follow these instructions to obtain the ports
collection:CVSup MethodThis is a quick method for getting and keeping your copy of the
Ports Collection up to date using CVSup.
If you want to learn more about CVSup, see
Using CVSup.Make sure /usr/ports
is empty before you run CVSup for
the first time! If you already have the Ports Collection present,
obtained from another source, CVSup
will not prune removed patch files.Install the net/cvsup-without-gui package:&prompt.root; pkg_add -r cvsup-without-guiSee CVSup Installation () for more details.Run cvsup:&prompt.root; cvsup -L 2 -h cvsup.FreeBSD.org /usr/share/examples/cvsup/ports-supfileChange
cvsup.FreeBSD.org to a
CVSup server near you. See
CVSup Mirrors () for a complete listing of mirror
sites.One may want to use his own
ports-supfile, for example to avoid
the need of passing the CVSup
server on the command line.In this case, as root, copy
/usr/share/examples/cvsup/ports-supfile
to a new location, such as
/root or your home
directory.Edit ports-supfile.Change
CHANGE_THIS.FreeBSD.org
to a CVSup server near
you. See CVSup
Mirrors () for
a complete listing of mirror sites.And now to run cvsup, use the
following:&prompt.root; cvsup -L 2 /root/ports-supfileRunning the &man.cvsup.1; command later will download and apply all
the recent changes to your Ports Collection, except
actually rebuilding the ports for your own system.Portsnap MethodPortsnap is an alternative system for distributing the
Ports Collection. It was first included in &os; 6.0. On older
systems, you can install it from sysutils/portsnap package:
+ role="package">ports-mgmt/portsnap package:
&prompt.root; pkg_add -r portsnapPlease refer to Using Portsnap
for a detailed description of all Portsnap
features.Since &os; 6.1-RELEASE and with recent versions
of the Portsnap port or package, you
can safely skip this step. The /usr/ports will be created
automatically at first use of the &man.portsnap.8; command.
With previous versions of
Portsnap, you will have to
create an empty directory /usr/ports if it does not exists:&prompt.root; mkdir /usr/portsDownload a compressed snapshot of the Ports Collection into
/var/db/portsnap. You can
disconnect from the Internet after this step, if you wish.&prompt.root; portsnap fetchIf you are running Portsnap for the
first time, extract the snapshot into /usr/ports:
&prompt.root; portsnap extractIf you already have a populated /usr/ports and you are just updating,
run the following command instead:&prompt.root; portsnap updateSysinstall MethodThis method involves using sysinstall
to install the Ports Collection from the installation media. Note
that the old copy of Ports Collection from the date of the release
will be installed. If you have Internet access, you should always
use one of the methods mentioned above.As root, run
sysinstall
(/stand/sysinstall in &os;
versions older than 5.2) as shown below:&prompt.root; sysinstallScroll down and select Configure,
press Enter.Scroll down and select
Distributions, press
Enter.Scroll down to ports, press
Space.Scroll up to Exit, press
Enter.Select your desired installation media, such as CDROM,
FTP, and so on.Scroll up to Exit and press
Enter.Press X to exit
sysinstall.Installing PortsportsinstallingThe first thing that should be explained when it comes to
the Ports Collection is what is actually meant by a
skeleton. In a nutshell, a port skeleton is a
minimal set of files that tell your FreeBSD system how to
cleanly compile and install a program. Each port skeleton
includes:A Makefile. The
Makefile contains various statements
that specify how the application should be compiled and
where it should be installed on your system.A distinfo file. This file
contains information about the files that must be
downloaded to build the port and their checksums, to
verify that files have not been corrupted during the
download using &man.md5.1;.A files directory. This
directory contains patches to make the program compile and
install on your FreeBSD system. Patches are basically
small files that specify changes to particular files.
They are in plain text format, and basically say
Remove line 10 or Change line 26 to
this .... Patches are also known as
diffs because they are generated by the
&man.diff.1; program.This directory may also contain other files used to build
the port.A pkg-descr file. This is a more
detailed, often multiple-line, description of the program.A pkg-plist file. This is a list
of all the files that will be installed by the port. It
also tells the ports system what files to remove upon
deinstallation.Some ports have other files, such as
pkg-message. The ports system uses these
files to handle special situations. If you want more details
on these files, and on ports in general, check out the FreeBSD Porter's
Handbook.The port includes instructions on how to build source
code, but does not include the actual source code. You can
get the source code from a CD-ROM or from the Internet.
Source code is distributed in whatever manner the software
author desires. Frequently this is a tarred and gzipped file,
but it might be compressed with some other tool or even
uncompressed. The program source code, whatever form it comes
in, is called a distfile. The two methods for
installing a &os; port are described below.You must be logged in as root to
install ports.Before installing any port, you should be sure to have
an up-to-date Ports Collection and you should check for security issues
related to your port.A security vulnerabilities check can be automatically
done by portaudit before any new
application installation. This tool can be found in the
Ports Collection (security/portaudit). Consider
+ role="package">ports-mgmt/portaudit). Consider
running portaudit -F before installing a
new port, to fetch the current vulnerabilities database. A
security audit and an update of the database will be
performed during the daily security system check. For more
information read the &man.portaudit.1; and &man.periodic.8;
manual pages.The Ports Collection makes an assumption that you have a working
Internet connection. If you do not, you will need to put a copy of the
distfile into /usr/ports/distfiles
manually.To begin, change to the directory for the port you want to
install:&prompt.root; cd /usr/ports/sysutils/lsofOnce inside the lsof directory, you
will see the port skeleton. The next step is to compile, or
build, the port. This is done by simply
typing make at the prompt. Once you have
done so, you should see something like this:&prompt.root; make
>> lsof_4.57D.freebsd.tar.gz doesn't seem to exist in /usr/ports/distfiles/.
>> Attempting to fetch from ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/.
===> Extracting for lsof-4.57
...
[extraction output snipped]
...
>> Checksum OK for lsof_4.57D.freebsd.tar.gz.
===> Patching for lsof-4.57
===> Applying FreeBSD patches for lsof-4.57
===> Configuring for lsof-4.57
...
[configure output snipped]
...
===> Building for lsof-4.57
...
[compilation output snipped]
...
&prompt.root;Notice that once the compile is complete you are
returned to your prompt. The next step is to install the
port. In order to install it, you simply need to tack one word
onto the make command, and that word is
install:&prompt.root; make install
===> Installing for lsof-4.57
...
[installation output snipped]
...
===> Generating temporary packing list
===> Compressing manual pages for lsof-4.57
===> Registering installation for lsof-4.57
===> SECURITY NOTE:
This port has installed the following binaries which execute with
increased privileges.
&prompt.root;Once you are returned to your prompt, you should be able to
run the application you just installed. Since
lsof is a
program that runs with increased privileges, a security
warning is shown. During the building and installation of
ports, you should take heed of any other warnings that
may appear.It is a good idea to delete the working subdirectory,
which contains all the temporary files used during compilation.
Not only does it consume valuable disk space, but it would also
cause problems later when upgrading to the newer version of the
port.&prompt.root; make clean
===> Cleaning for lsof-4.57
&prompt.root;You can save two extra steps by just running make
install clean instead of make,
make install and make clean
as three separate steps.Some shells keep a cache of the commands that are
available in the directories listed in the
PATH environment variable, to speed up
lookup operations for the executable file of these
commands. If you are using one of these shells, you might
have to use the rehash command after
installing a port, before the newly installed commands can
be used. This command will work for shells like
tcsh. Use the hash -r
command for shells like sh. Look at the
documentation for your shell for more information.Some third party DVD-ROM products such as the FreeBSD Toolkit
from the FreeBSD
Mall contain distfiles. They can be used with the Ports
Collection. Mount the DVD-ROM on /cdrom. If
you use a different mount point, set CD_MOUNTPTS
make variable. The needed distfiles will be automatically used
if they are present on the disk.Please be aware that the licenses of a few ports do
not allow for inclusion on the CD-ROM. This could be
because a registration form needs to be filled out before
downloading or redistribution is not allowed, or for
another reason. If you wish to install a port not
included on the CD-ROM, you will need to be online in
order to do so.The ports system uses &man.fetch.1; to download the
files, which honors various environment variables, including
FTP_PASSIVE_MODE, FTP_PROXY,
and FTP_PASSWORD. You may need to set one or
more of these if you are behind a firewall, or need to use
an FTP/HTTP proxy. See &man.fetch.3; for the complete
list.For users which cannot be connected all the time, the
make fetch option is
provided. Just run this command at the top level directory
(/usr/ports) and the required files
will be downloaded for you. This command will also work in
the lower level categories, for example:
/usr/ports/net.
Note that if a port depends on libraries or other ports this will
not fetch the distfiles of those ports too.
Replace fetch with
fetch-recursive
if you want to fetch all the dependencies of a port too.You can build all the ports in a category or as a
whole by running make in the top level
directory, just like the aforementioned make
fetch method. This is
dangerous, however, as some ports cannot co-exist. In other
cases, some ports can install two different files with the
same filename.In some rare cases, users may need to acquire the
tarballs from a site other than the
MASTER_SITES (the location where files
are downloaded from). You can override the
MASTER_SITES option with the following
command:&prompt.root; cd /usr/ports/directory
&prompt.root; make MASTER_SITE_OVERRIDE= \
ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/ fetchIn this example we change the
MASTER_SITES option to ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/.Some ports allow (or even require) you to provide
build options which can enable/disable parts of the
application which are unneeded, certain security options,
and other customizations. A few which come to mind are
www/mozilla, security/gpgme, and mail/sylpheed-claws. A message
will be displayed when options such as these are
available.Overriding the Default Ports DirectoriesSometimes it is useful (or mandatory) to use a different
working and target directory. The
WRKDIRPREFIX and PREFIX
variables can override the default directories. For
example:&prompt.root; make WRKDIRPREFIX=/usr/home/example/ports installwill compile the port in
/usr/home/example/ports and install
everything under /usr/local.&prompt.root; make PREFIX=/usr/home/example/local installwill compile it in /usr/ports and
install it in
/usr/home/example/local.And of course,&prompt.root; make WRKDIRPREFIX=../ports PREFIX=../local installwill combine the two (it is too long to completely write
on this page, but it should give you the general
idea).Alternatively, these variables can also be set as part
of your environment. Read the manual page for your shell
for instructions on doing so.Dealing with imakeSome ports that use imake (a part of
the X Window System) do not work well with
PREFIX, and will insist on installing
under /usr/X11R6. Similarly, some Perl
ports ignore PREFIX and install in the
Perl tree. Making these ports respect
PREFIX is a difficult or impossible
job.Removing Installed PortsportsremovingNow that you know how to install ports, you are probably
wondering how to remove them, just in case you install one and
later on decide that you installed the wrong port.
We will remove our previous example (which was
lsof for
those of you not paying attention). Ports are being removed exactly
the same as the packages (discussed in the Packages section), using the
&man.pkg.delete.1; command:&prompt.root; pkg_delete lsof-4.57Upgrading PortsportsupgradingFirst, list outdated ports that have a newer version available in
the Ports Collection with the &man.pkg.version.1; command:&prompt.root; pkg_version -v/usr/ports/UPDATINGOnce you have updated your Ports Collection, before
attempting a port upgrade, you should check
/usr/ports/UPDATING. This file
describes various issues and additional steps users may
encounter and need to perform when updating a port, including
such things as file format changes, changes in locations of
configuration files, or other such incompatibilities with
previous versions.If UPDATING contradicts something you
read here, UPDATING takes precedence.Upgrading Ports using PortupgradeportupgradeThe portupgrade utility is designed
to easily upgrade installed ports. It is available from the sysutils/portupgrade port. Install it like
+ role="package">ports-mgmt/portupgrade port. Install it like
any other port, using the make install
clean command:
- &prompt.root; cd /usr/ports/sysutils/portupgrade
+ &prompt.root; cd /usr/ports/ports-mgmt/portupgrade
&prompt.root; make install cleanScan the list of installed ports with the pkgdb
-F command and fix all the inconsistencies it reports. It is
a good idea to do this regularly, before every upgrade.When you run portupgrade -a,
portupgrade will begin to upgrade all the
outdated ports installed on your system. Use the
flag if you want to be asked for confirmation of every individual
upgrade.&prompt.root; portupgrade -aiIf you want to upgrade only a
certain application, not all available ports, use portupgrade
pkgname. Include the
flag if portupgrade
should first upgrade all the ports required by the given
application.&prompt.root; portupgrade -R firefoxTo use packages instead of ports for installation, provide
flag. With this option
portupgrade searches
the local directories listed in PKG_PATH, or
fetches packages from remote site if it is not found locally.
If packages can not be found locally or fetched remotely,
portupgrade will use ports.
To avoid using ports, specify .&prompt.root; portupgrade -PR gnome2To just fetch distfiles (or packages, if
is specified) without building or
installing anything, use .
For further information see &man.portupgrade.1;.Upgrading Ports using PortmanagerportmanagerPortmanager is another utility for
easy upgrading of installed ports. It is available from the
- sysutils/portmanager port:
+ ports-mgmt/portmanager port:
- &prompt.root; cd /usr/ports/sysutils/portmanager
+ &prompt.root; cd /usr/ports/ports-mgmt/portmanager
&prompt.root; make install cleanAll the installed ports can be upgraded using this simple
command:&prompt.root; portmanager -uYou can add the flag to get asked for
confirmation of every step Portmanager
will perform. Portmanager can also be
used to install new ports on the system. Unlike the usual
make install clean command, it will upgrade all
the dependencies prior to building and installing the
selected port.&prompt.root; portmanager x11/gnome2If there are any problems regarding the dependencies for the
selected port, you can use Portmanager to
rebuild all of them in the correct order. Once finished, the
problematic port will be rebuilt too.&prompt.root; portmanager graphics/gimp -fFor more information see
Portmanager's manual page.Ports and Disk Spaceportsdisk-spaceUsing the Ports Collection will use up disk
space over time. After building and installing software from the
ports, you should always remember to clean up
the temporary work directories using the make
clean command. You can sweep the whole
Ports Collection with the following command:&prompt.root; portsclean -CYou will accumulate a lot of old source distribution files in the
distfiles directory over time.
You can remove them by hand, or you can use the following command to
delete all the distfiles that are no longer referenced by any
ports:&prompt.root; portsclean -DOr to remove all distfiles not referenced by any port
currently installed on your system:&prompt.root; portsclean -DDThe portsclean utility is part of the
portupgrade suite.Do not forget to remove the installed ports once you no longer need
them. A nice tool to help automate this task is available from the
- sysutils/pkg_cutleaves port.
+ ports-mgmt/pkg_cutleaves port.
Post-installation ActivitiesAfter installing a new application you will normally want to
read any documentation it may have included, edit any
configuration files that are required, ensure that the
application starts at boot time (if it is a daemon), and so
on.The exact steps you need to take to configure each
application will obviously be different. However, if you have
just installed a new application and are wondering What
now? these tips might help:Use &man.pkg.info.1; to find out which files were installed,
and where. For example, if you have just
installed FooPackage version 1.0.0, then this command&prompt.root; pkg_info -L foopackage-1.0.0 | lesswill show all the files installed by the package. Pay
special attention to files in man/
directories, which will be manual pages,
etc/ directories, which will be
configuration files, and doc/, which
will be more comprehensive documentation.If you are not sure which version of the application was
just installed, a command like this&prompt.root; pkg_info | grep -i foopackagewill find all the installed packages that have
foopackage in the package name.
Replace foopackage in your
command line as necessary.Once you have identified where the application's manual
pages have been installed, review them using &man.man.1;.
Similarly, look over the sample configuration files, and any
additional documentation that may have been provided.If the application has a web site, check it for
additional documentation, frequently asked questions, and so
forth. If you are not sure of the web site address it may
be listed in the output from&prompt.root; pkg_info foopackage-1.0.0A WWW: line, if present, should provide a URL
for the application's web site.Ports that should start at boot (such as Internet
servers) will usually install a sample script in
/usr/local/etc/rc.d. You should
review this script for correctness and edit or rename it if
needed. See Starting
Services for more information.Dealing with Broken PortsIf you come across a port that does not work for you,
there are a few things you can do, including:Find out if there is a fix pending for the port in
the Problem Report
database. If so, you may be able to use the
proposed fix.Ask the maintainer of the port for help. Type
make maintainer or read the
Makefile to find the maintainer's
email address. Remember to include the name and version
of the port (send the $FreeBSD:
line from the Makefile) and the
output leading up to the error when you email the
maintainer.Some ports are not maintained by an individual but
instead by a mailing
list. Many, but not all, of these addresses look like
freebsd-listname@FreeBSD.org. Please
take this into account when phrasing your questions.In particular, ports shown as maintained by
freebsd-ports@FreeBSD.org are
actually not maintained by anyone. Fixes and support, if
any, come from the general community who subscribe to that
mailing list. More volunteers are always needed!If you do not get a response,
you can use &man.send-pr.1; to submit a bug
report (see Writing
FreeBSD Problem Reports).Fix it! The Porter's
Handbook includes detailed information on the
Ports infrastructure so that you can fix the occasional
broken port or even submit your own!Grab the package from an FTP site near you. The
master package collection is on ftp.FreeBSD.org in the packages
directory, but be sure to check your local mirrorfirst! These are more likely to work
than trying to compile from source and are a lot faster as
well. Use the &man.pkg.add.1; program to install the
package on your system.
Index: head/en_US.ISO8859-1/books/handbook/security/chapter.sgml
===================================================================
--- head/en_US.ISO8859-1/books/handbook/security/chapter.sgml (revision 29515)
+++ head/en_US.ISO8859-1/books/handbook/security/chapter.sgml (revision 29516)
@@ -1,4981 +1,4981 @@
MatthewDillonMuch of this chapter has been taken from the
security(7) manual page by SecuritysecuritySynopsisThis chapter will provide a basic introduction to system security
concepts, some general good rules of thumb, and some advanced topics
under &os;. A lot of the topics covered here can be applied
to system and Internet security in general as well. The Internet
is no longer a friendly place in which everyone
wants to be your kind neighbor. Securing your system is imperative
to protect your data, intellectual property, time, and much more
from the hands of hackers and the like.&os; provides an array of utilities and mechanisms to ensure
the integrity and security of your system and network.After reading this chapter, you will know:Basic system security concepts, in respect to &os;.About the various crypt mechanisms available in &os;,
such as DES and MD5.How to set up one-time password authentication.How to configure TCP Wrappers for use
with inetd.How to set up KerberosIV on &os;
releases prior to 5.0.How to set up Kerberos5 on
&os;.How to configure IPsec and create a VPN between
&os;/&windows; machines.How to configure and use OpenSSH, &os;'s SSH
implementation.What file system ACLs are and how to use them.How to use the Portaudit
utility to audit third party software packages installed
from the Ports Collection.How to utilize the &os; security advisories
publications.Have an idea of what Process Accounting is and how to
enable it on &os;.Before reading this chapter, you should:Understand basic &os; and Internet concepts.Additional security topics are covered throughout this book.
For example, Mandatory Access Control is discussed in and Internet Firewalls are discussed in .IntroductionSecurity is a function that begins and ends with the system
administrator. While all BSD &unix; multi-user systems have some
inherent security, the job of building and maintaining additional
security mechanisms to keep those users honest is
probably one of the single largest undertakings of the sysadmin.
Machines are only as secure as you make them, and security concerns
are ever competing with the human necessity for convenience. &unix;
systems, in general, are capable of running a huge number of
simultaneous processes and many of these processes operate as
servers — meaning that external entities can connect and talk
to them. As yesterday's mini-computers and mainframes become
today's desktops, and as computers become networked and
inter-networked, security becomes an even bigger issue.System security also pertains to dealing with various forms of
attack, including attacks that attempt to crash, or otherwise make a
system unusable, but do not attempt to compromise the
root account (break root).
Security concerns
can be split up into several categories:Denial of service attacks.User account compromises.Root compromise through accessible servers.Root compromise via user accounts.Backdoor creation.DoS attacksDenial of Service (DoS)securityDoS attacksDenial of Service (DoS)Denial of Service (DoS)A denial of service attack is an action that deprives the
machine of needed resources. Typically, DoS attacks are
brute-force mechanisms that attempt to crash or otherwise make a
machine unusable by overwhelming its servers or network stack. Some
DoS attacks try to take advantage of bugs in the networking
stack to crash a machine with a single packet. The latter can only
be fixed by applying a bug fix to the kernel. Attacks on servers
can often be fixed by properly specifying options to limit the load
the servers incur on the system under adverse conditions.
Brute-force network attacks are harder to deal with. A
spoofed-packet attack, for example, is nearly impossible to stop,
short of cutting your system off from the Internet. It may not be
able to take your machine down, but it can saturate your
Internet connection.securityaccount compromisesA user account compromise is even more common than a DoS
attack. Many sysadmins still run standard
telnetd, rlogind,
rshd,
and ftpd servers on their machines.
These servers, by default, do
not operate over encrypted connections. The result is that if you
have any moderate-sized user base, one or more of your users logging
into your system from a remote location (which is the most common
and convenient way to login to a system) will have his or her
password sniffed. The attentive system admin will analyze his
remote access logs looking for suspicious source addresses even for
successful logins.One must always assume that once an attacker has access to a
user account, the attacker can break root.
However, the reality is that in a well secured and maintained system,
access to a user account does not necessarily give the attacker
access to root. The distinction is important
because without access to root the attacker
cannot generally hide his tracks and may, at best, be able to do
nothing more than mess with the user's files, or crash the machine.
User account compromises are very common because users tend not to
take the precautions that sysadmins take.securitybackdoorsSystem administrators must keep in mind that there are
potentially many ways to break root on a machine.
The attacker may know the root password,
the attacker may find a bug in a root-run server and be able
to break root over a network
connection to that server, or the attacker may know of a bug in
a suid-root program that allows the attacker to break
root once he has broken into a user's account.
If an attacker has found a way to break root
on a machine, the attacker may not have a need
to install a backdoor. Many of the root holes
found and closed to date involve a considerable amount of work
by the attacker to cleanup after himself, so most attackers install
backdoors. A backdoor provides the attacker with a way to easily
regain root access to the system, but it
also gives the smart system administrator a convenient way
to detect the intrusion.
Making it impossible for an attacker to install a backdoor may
actually be detrimental to your security, because it will not
close off the hole the attacker found to break in the first
place.Security remedies should always be implemented with a
multi-layered onion peel approach and can be
categorized as follows:Securing root and staff accounts.Securing root–run servers
and suid/sgid binaries.Securing user accounts.Securing the password file.Securing the kernel core, raw devices, and
file systems.Quick detection of inappropriate changes made to the
system.Paranoia.The next section of this chapter will cover the above bullet
items in greater depth.Securing &os;securitysecuring &os;Command vs. ProtocolThroughout this document, we will use
bold text to refer to an
application, and a monospaced font to refer
to specific commands. Protocols will use a normal font. This
typographical distinction is useful for instances such as ssh,
since it is
a protocol as well as command.The sections that follow will cover the methods of securing your
&os; system that were mentioned in the last section of this chapter.Securing the root Account and
Staff AccountssuFirst off, do not bother securing staff accounts if you have
not secured the root account.
Most systems have a password assigned to the root
account. The first thing you do is assume
that the password is always compromised.
This does not mean that you should remove the password. The
password is almost always necessary for console access to the
machine. What it does mean is that you should not make it
possible to use the password outside of the console or possibly
even with the &man.su.1; command. For example, make sure that
your ptys are specified as being insecure in the
/etc/ttys file so that direct
root logins
via telnet or rlogin are
disallowed. If using other login services such as
sshd, make sure that direct
root logins are disabled there as well.
You can do this by editing
your /etc/ssh/sshd_config file, and making
sure that PermitRootLogin is set to
NO. Consider every access method —
services such as FTP often fall through the cracks.
Direct root logins should only be allowed
via the system console.wheelOf course, as a sysadmin you have to be able to get to
root, so we open up a few holes.
But we make sure these holes require additional password
verification to operate. One way to make root
accessible is to add appropriate staff accounts to the
wheel group (in
/etc/group). The staff members placed in the
wheel group are allowed to
su to root.
You should never give staff
members native wheel access by putting them in the
wheel group in their password entry. Staff
accounts should be placed in a staff group, and
then added to the wheel group via the
/etc/group file. Only those staff members
who actually need to have root access
should be placed in the
wheel group. It is also possible, when using
an authentication method such as Kerberos, to use Kerberos'
.k5login file in the root
account to allow a &man.ksu.1; to root
without having to place anyone at all in the
wheel group. This may be the better solution
since the wheel mechanism still allows an
intruder to break root if the intruder
has gotten hold of your
password file and can break into a staff account. While having
the wheel mechanism is better than having
nothing at all, it is not necessarily the safest option.An indirect way to secure staff accounts, and ultimately
root access is to use an alternative
login access method and
do what is known as starring out the encrypted
password for the staff accounts. Using the &man.vipw.8;
command, one can replace each instance of an encrypted password
with a single * character.
This command will update the /etc/master.passwd
file and user/password database to disable password-authenticated
logins.A staff account entry such as:foobar:R9DT/Fa1/LV9U:1000:1000::0:0:Foo Bar:/home/foobar:/usr/local/bin/tcshShould be changed to this:foobar:*:1000:1000::0:0:Foo Bar:/home/foobar:/usr/local/bin/tcshThis change will prevent normal logins from occurring,
since the encrypted password will never match
*. With this done,
staff members must use
another mechanism to authenticate themselves such as
&man.kerberos.1; or &man.ssh.1; using a public/private key
pair. When using something like Kerberos, one generally must
secure the machines which run the Kerberos servers and your
desktop workstation. When using a public/private key pair
with ssh, one must generally secure
the machine used to login from (typically
one's workstation). An additional layer of protection can be
added to the key pair by password protecting the key pair when
creating it with &man.ssh-keygen.1;. Being able to
star out the passwords for staff accounts also
guarantees that staff members can only login through secure
access methods that you have set up. This forces all staff
members to use secure, encrypted connections for all of their
sessions, which closes an important hole used by many
intruders: sniffing the network from an unrelated,
less secure machine.The more indirect security mechanisms also assume that you are
logging in from a more restrictive server to a less restrictive
server. For example, if your main box is running all sorts of
servers, your workstation should not be running any. In order for
your workstation to be reasonably secure you should run as few
servers as possible, up to and including no servers at all, and
you should run a password-protected screen blanker. Of course,
given physical access to a workstation an attacker can break any
sort of security you put on it. This is definitely a problem that
you should consider, but you should also consider the fact that the
vast majority of break-ins occur remotely, over a network, from
people who do not have physical access to your workstation or
servers.KerberosIVUsing something like Kerberos also gives you the ability to
disable or change the password for a staff account in one place,
and have it immediately affect all the machines on which the staff
member may have an account. If a staff member's account gets
compromised, the ability to instantly change his password on all
machines should not be underrated. With discrete passwords,
changing a password on N machines can be a mess. You can also
impose re-passwording restrictions with Kerberos: not only can a
Kerberos ticket be made to timeout after a while, but the Kerberos
system can require that the user choose a new password after a
certain period of time (say, once a month).Securing Root-run Servers and SUID/SGID BinariesntalkcomsatfingersandboxessshdtelnetdrshdrlogindThe prudent sysadmin only runs the servers he needs to, no
more, no less. Be aware that third party servers are often the
most bug-prone. For example, running an old version of
imapd or
popper is like giving a universal
root ticket out to the entire world.
Never run a server that you have not checked out carefully.
Many servers do not need to be run as root.
For example, the ntalk,
comsat, and
finger daemons can be run in special
user sandboxes. A sandbox is not perfect,
unless you go through a large amount of trouble, but the onion
approach to security still stands: If someone is able to break
in through a server running in a sandbox, they still have to
break out of the sandbox. The more layers the attacker must
break through, the lower the likelihood of his success. Root
holes have historically been found in virtually every server
ever run as root, including basic system servers.
If you are running a machine through which people only login via
sshd and never login via
telnetd or
rshd or
rlogind, then turn off those
services!&os; now defaults to running
ntalkd,
comsat, and
finger in a sandbox. Another program
which may be a candidate for running in a sandbox is &man.named.8;.
/etc/defaults/rc.conf includes the arguments
necessary to run named in a sandbox in a
commented-out form. Depending on whether you are installing a new
system or upgrading an existing system, the special user accounts
used by these sandboxes may not be installed. The prudent
sysadmin would research and implement sandboxes for servers
whenever possible.sendmailThere are a number of other servers that typically do not run
in sandboxes: sendmail,
popper,
imapd, ftpd,
and others. There are alternatives to some of these, but
installing them may require more work than you are willing to
perform (the convenience factor strikes again). You may have to
run these servers as root and rely on other
mechanisms to detect break-ins that might occur through them.The other big potential root holes in a
system are the
suid-root and sgid binaries installed on the system. Most of
these binaries, such as rlogin, reside
in /bin, /sbin,
/usr/bin, or /usr/sbin.
While nothing is 100% safe, the system-default suid and sgid
binaries can be considered reasonably safe. Still,
root holes are occasionally found in these
binaries. A root hole was found in
Xlib in 1998 that made
xterm (which is typically suid)
vulnerable. It is better to be safe than sorry and the prudent
sysadmin will restrict suid binaries, that only staff should run,
to a special group that only staff can access, and get rid of
(chmod 000) any suid binaries that nobody uses.
A server with no display generally does not need an
xterm binary. Sgid binaries can be
almost as dangerous. If an intruder can break an sgid-kmem binary,
the intruder might be able to read /dev/kmem
and thus read the encrypted password file, potentially compromising
any passworded account. Alternatively an intruder who breaks
group kmem can monitor keystrokes sent through
ptys, including ptys used by users who login through secure
methods. An intruder that breaks the tty
group can write to
almost any user's tty. If a user is running a terminal program or
emulator with a keyboard-simulation feature, the intruder can
potentially generate a data stream that causes the user's terminal
to echo a command, which is then run as that user.Securing User AccountsUser accounts are usually the most difficult to secure. While
you can impose draconian access restrictions on your staff and
star out their passwords, you may not be able to
do so with any general user accounts you might have. If you do
have sufficient control, then you may win out and be able to secure
the user accounts properly. If not, you simply have to be more
vigilant in your monitoring of those accounts. Use of
ssh and Kerberos for user accounts is
more problematic, due to the extra administration and technical
support required, but still a very good solution compared to a
encrypted password file.Securing the Password FileThe only sure fire way is to star out as many
passwords as you can and use ssh or
Kerberos for access to those accounts. Even though the encrypted
password file (/etc/spwd.db) can only be read
by root, it may be possible for an intruder
to obtain read access to that file even if the attacker cannot
obtain root-write access.Your security scripts should always check for and report
changes to the password file (see the Checking file integrity section
below).Securing the Kernel Core, Raw Devices, and
File systemsIf an attacker breaks root he can do
just about anything, but
there are certain conveniences. For example, most modern kernels
have a packet sniffing device driver built in. Under &os; it
is called the bpf device. An intruder
will commonly attempt to run a packet sniffer on a compromised
machine. You do not need to give the intruder the capability and
most systems do not have the need for the
bpf device compiled in.sysctlBut even if you turn off the bpf
device, you still have
/dev/mem and
/dev/kmem
to worry about. For that matter, the intruder can still write to
raw disk devices. Also, there is another kernel feature called
the module loader, &man.kldload.8;. An enterprising intruder can
use a KLD module to install his own bpf
device, or other sniffing
device, on a running kernel. To avoid these problems you have to
run the kernel at a higher secure level, at least securelevel 1.
The securelevel can be set with a sysctl on
the kern.securelevel variable. Once you have
set the securelevel to 1, write access to raw devices will be
denied and special chflags flags,
such as schg,
will be enforced. You must also ensure that the
schg flag is set on critical startup binaries,
directories, and script files — everything that gets run up
to the point where the securelevel is set. This might be overdoing
it, and upgrading the system is much more difficult when you
operate at a higher secure level. You may compromise and run the
system at a higher secure level but not set the
schg flag for every system file and directory
under the sun. Another possibility is to simply mount
/ and /usr read-only.
It should be noted that being too draconian in what you attempt to
protect may prevent the all-important detection of an
intrusion.Checking File Integrity: Binaries, Configuration Files,
Etc.When it comes right down to it, you can only protect your core
system configuration and control files so much before the
convenience factor rears its ugly head. For example, using
chflags to set the schg bit
on most of the files in / and
/usr is probably counterproductive, because
while it may protect the files, it also closes a detection window.
The last layer of your security onion is perhaps the most
important — detection. The rest of your security is pretty
much useless (or, worse, presents you with a false sense of
security) if you cannot detect potential intrusions. Half the job
of the onion is to slow down the attacker, rather than stop him, in
order to be able to catch him in the act.The best way to detect an intrusion is to look for modified,
missing, or unexpected files. The best way to look for modified
files is from another (often centralized) limited-access system.
Writing your security scripts on the extra-secure limited-access
system makes them mostly invisible to potential attackers, and this
is important. In order to take maximum advantage you generally
have to give the limited-access box significant access to the
other machines in the business, usually either by doing a
read-only NFS export of the other machines to the limited-access
box, or by setting up ssh key-pairs to
allow the limited-access box to ssh to
the other machines. Except for its network traffic, NFS is the
least visible method — allowing you to monitor the
file systems on each client box virtually undetected. If your
limited-access server is connected to the client boxes through a
switch, the NFS method is often the better choice. If your
limited-access server is connected to the client boxes through a
hub, or through several layers of routing, the NFS method may be
too insecure (network-wise) and using
ssh may be the better choice even with
the audit-trail tracks that ssh
lays.Once you have given a limited-access box at least read access to the
client systems it is supposed to monitor, you must write scripts
to do the actual monitoring. Given an NFS mount, you can write
scripts out of simple system utilities such as &man.find.1; and
&man.md5.1;. It is best to physically md5 the client-box files
at least once a day, and to test control files such as those
found in /etc and
/usr/local/etc even more often. When
mismatches are found, relative to the base md5 information the
limited-access machine knows is valid, it should scream at a
sysadmin to go check it out. A good security script will also
check for inappropriate suid binaries and for new or deleted files
on system partitions such as / and
/usr.When using ssh rather than NFS,
writing the security script is much more difficult. You
essentially have to scp the scripts to the client
box in order to
run them, making them visible, and for safety you also need to
scp the binaries (such as find) that those
scripts use. The ssh client on the
client box may already be compromised. All in all, using
ssh may be necessary when running over
insecure links, but it is also a lot harder to deal with.A good security script will also check for changes to user and
staff members access configuration files:
.rhosts, .shosts,
.ssh/authorized_keys and so forth,
files that might fall outside the purview of the
MD5 check.If you have a huge amount of user disk space, it may take too
long to run through every file on those partitions. In this case,
setting mount flags to disallow suid binaries and devices on those
partitions is a good idea. The nodev and
nosuid options (see &man.mount.8;) are what you
want to look into. You should probably scan them anyway, at least
once a week, since the object of this layer is to detect a break-in
attempt, whether or not the attempt succeeds.Process accounting (see &man.accton.8;) is a relatively
low-overhead feature of the operating system which might help
as a post-break-in evaluation mechanism. It is especially
useful in tracking down how an intruder has actually broken into
a system, assuming the file is still intact after the break-in has
occured.Finally, security scripts should process the log files, and the
logs themselves should be generated in as secure a manner as
possible — remote syslog can be very useful. An intruder
will try to cover his tracks, and log files are critical to the
sysadmin trying to track down the time and method of the initial
break-in. One way to keep a permanent record of the log files is
to run the system console to a serial port and collect the
information to a secure machine monitoring the consoles.ParanoiaA little paranoia never hurts. As a rule, a sysadmin can add
any number of security features, as long as they do not affect
convenience, and can add security features that
do affect convenience with some added thought.
Even more importantly, a security administrator should mix it up a
bit — if you use recommendations such as those given by this
document verbatim, you give away your methodologies to the
prospective attacker who also has access to this document.Denial of Service AttacksDenial of Service (DoS)This section covers Denial of Service attacks. A DoS attack
is typically a packet attack. While there is not much you can do
about modern spoofed packet attacks that saturate your network,
you can generally limit the damage by ensuring that the attacks
cannot take down your servers by:Limiting server forks.Limiting springboard attacks (ICMP response attacks, ping
broadcast, etc.).Overloading the Kernel Route Cache.A common DoS attack scenario is attacking a forking server and
making it spawning so many child processes that the host system
eventually runs out of memory, file descriptors, etc. and then
grinds to a halt. inetd
(see &man.inetd.8;) has several
options to limit this sort of attack. It should be noted that
while it is possible to prevent a machine from going down, it is
not generally possible to prevent a service from being disrupted
by the attack. Read the inetd manual
page carefully and pay
specific attention to the , ,
and options. Note that spoofed-IP attacks
will circumvent the option to
inetd, so
typically a combination of options must be used. Some standalone
servers have self-fork-limitation parameters.Sendmail has its
option, which tends to work
much better than trying to use Sendmail's load limiting options
due to the load lag. You should specify a
MaxDaemonChildren parameter, when you start
sendmail; high enough to handle your
expected load, but not so high that the computer cannot handle that
number of Sendmail instances without falling on
its face. It is also prudent to run Sendmail in queued mode
() and to run the daemon
(sendmail -bd) separate from the queue-runs
(sendmail -q15m). If you still want real-time
delivery you can run the queue at a much lower interval, such as
, but be sure to specify a reasonable
MaxDaemonChildren option for
thatSendmail to prevent cascade failures.Syslogd can be attacked directly
and it is strongly recommended that you use the
option whenever possible, and the option
otherwise.You should also be fairly careful with connect-back services
such as TCP Wrapper's reverse-identd,
which can be attacked directly. You generally do not want to use
the reverse-ident feature of
TCP Wrapper for this reason.It is a very good idea to protect internal services from
external access by firewalling them off at your border routers.
The idea here is to prevent saturation attacks from outside your
LAN, not so much to protect internal services from network-based
root compromise.
Always configure an exclusive firewall, i.e.,
firewall everything except ports A, B,
C, D, and M-Z. This way you can firewall off all of your
low ports except for certain specific services such as
named (if you are primary for a zone),
ntalkd,
sendmail, and other Internet-accessible
services. If you try to configure the firewall the other way
— as an inclusive or permissive firewall, there is a good
chance that you will forget to close a couple of
services, or that you will add a new internal service and forget
to update the firewall. You can still open up the high-numbered
port range on the firewall, to allow permissive-like operation,
without compromising your low ports. Also take note that &os;
allows you to control the range of port numbers used for dynamic
binding, via the various net.inet.ip.portrangesysctl's (sysctl -a | fgrep
portrange), which can also ease the complexity of your
firewall's configuration. For example, you might use a normal
first/last range of 4000 to 5000, and a hiport range of 49152 to
65535, then block off everything under 4000 in your firewall
(except for certain specific Internet-accessible ports, of
course).Another common DoS attack is called a springboard attack
— to attack a server in a manner that causes the server to
generate responses which overloads the server, the local
network, or some other machine. The most common attack of this
nature is the ICMP ping broadcast attack.
The attacker spoofs ping packets sent to your LAN's broadcast
address with the source IP address set to the actual machine they
wish to attack. If your border routers are not configured to
stomp on ping packets to broadcast addresses, your LAN winds up
generating sufficient responses to the spoofed source address to
saturate the victim, especially when the attacker uses the same
trick on several dozen broadcast addresses over several dozen
different networks at once. Broadcast attacks of over a hundred
and twenty megabits have been measured. A second common
springboard attack is against the ICMP error reporting system.
By constructing packets that generate ICMP error responses, an
attacker can saturate a server's incoming network and cause the
server to saturate its outgoing network with ICMP responses. This
type of attack can also crash the server by running it out of
memory, especially if the server cannot drain the ICMP responses
it generates fast enough.
Use the sysctl
variable net.inet.icmp.icmplim to limit these attacks.
The last major class of springboard
attacks is related to certain internal
inetd services such as the
udp echo service. An attacker simply spoofs a UDP packet with the
source address being server A's echo port, and the destination
address being server B's echo port, where server A and B are both
on your LAN. The two servers then bounce this one packet back and
forth between each other. The attacker can overload both servers
and their LANs simply by injecting a few packets in this manner.
Similar problems exist with the internal
chargen port. A
competent sysadmin will turn off all of these inetd-internal test
services.Spoofed packet attacks may also be used to overload the kernel
route cache. Refer to the net.inet.ip.rtexpire,
rtminexpire, and rtmaxcachesysctl parameters. A spoofed packet attack
that uses a random source IP will cause the kernel to generate a
temporary cached route in the route table, viewable with
netstat -rna | fgrep W3. These routes
typically timeout in 1600 seconds or so. If the kernel detects
that the cached route table has gotten too big it will dynamically
reduce the rtexpire but will never decrease it
to less than rtminexpire. There are two
problems:The kernel does not react quickly enough when a lightly
loaded server is suddenly attacked.The rtminexpire is not low enough for
the kernel to survive a sustained attack.If your servers are connected to the Internet via a T3 or
better, it may be prudent to manually override both
rtexpire and rtminexpire
via &man.sysctl.8;. Never set either parameter to zero (unless
you want to crash the machine). Setting both
parameters to 2 seconds should be sufficient to protect the route
table from attack.Access Issues with Kerberos and SSHsshKerberosIVThere are a few issues with both Kerberos and
ssh that need to be addressed if
you intend to use them. Kerberos 5 is an excellent
authentication protocol, but there are bugs in the kerberized
telnet and
rlogin applications that make them
unsuitable for dealing with binary streams. Also, by default
Kerberos does not encrypt a session unless you use the
option. ssh
encrypts everything by default.Ssh works quite well in every
respect except that it forwards encryption keys by default. What
this means is that if you have a secure workstation holding keys
that give you access to the rest of the system, and you
ssh to an insecure machine, your keys
are usable. The actual keys themselves are not exposed, but
ssh installs a forwarding port for the
duration of your login, and if an attacker has broken
root on the
insecure machine he can utilize that port to use your keys to gain
access to any other machine that your keys unlock.We recommend that you use ssh in
combination with Kerberos whenever possible for staff logins.
Ssh can be compiled with Kerberos
support. This reduces your reliance on potentially exposed
ssh keys while at the same time
protecting passwords via Kerberos. Ssh
keys should only be used for automated tasks from secure machines
(something that Kerberos is unsuited to do). We also recommend that
you either turn off key-forwarding in the
ssh configuration, or that you make use
of the from=IP/DOMAIN option that
ssh allows in its
authorized_keys file to make the key only
usable to entities logging in from specific machines.BillSwingleParts rewritten and updated by DES, MD5, and CryptsecuritycryptcryptDESMD5Every user on a &unix; system has a password associated with
their account. It seems obvious that these passwords need to be
known only to the user and the actual operating system. In
order to keep these passwords secret, they are encrypted with
what is known as a one-way hash, that is, they can
only be easily encrypted but not decrypted. In other words, what
we told you a moment ago was obvious is not even true: the
operating system itself does not really know
the password. It only knows the encrypted
form of the password. The only way to get the
plain-text password is by a brute force search of the
space of possible passwords.Unfortunately the only secure way to encrypt passwords when
&unix; came into being was based on DES, the Data Encryption
Standard. This was not such a problem for users resident in
the US, but since the source code for DES could not be exported
outside the US, &os; had to find a way to both comply with
US law and retain compatibility with all the other &unix;
variants that still used DES.The solution was to divide up the encryption libraries
so that US users could install the DES libraries and use
DES but international users still had an encryption method
that could be exported abroad. This is how &os; came to
use MD5 as its default encryption method. MD5 is believed to
be more secure than DES, so installing DES is offered primarily
for compatibility reasons.Recognizing Your Crypt MechanismCurrently the library supports DES, MD5 and Blowfish hash
functions. By default &os; uses MD5 to encrypt
passwords.It is pretty easy to identify which encryption method
&os; is set up to use. Examining the encrypted passwords in
the /etc/master.passwd file is one way.
Passwords encrypted with the MD5 hash are longer than those
encrypted with the DES hash and also begin with the characters
$1$. Passwords starting with
$2a$ are encrypted with the
Blowfish hash function. DES password strings do not
have any particular identifying characteristics, but they are
shorter than MD5 passwords, and are coded in a 64-character
alphabet which does not include the $
character, so a relatively short string which does not begin with
a dollar sign is very likely a DES password.The password format used for new passwords is controlled
by the passwd_format login capability in
/etc/login.conf, which takes values of
des, md5 or
blf. See the &man.login.conf.5; manual page
for more information about login capabilities.One-time Passwordsone-time passwordssecurityone-time passwordsBy default, &os; includes support for OPIE (One-time Passwords
In Everything), which uses the MD5 hash by default.There are three different sorts of passwords which we will discuss
below. The first is your usual &unix; style or
Kerberos password; we will call this a &unix; password.
The second sort is the one-time password which is generated by the OPIE
&man.opiekey.1; program and accepted by the
&man.opiepasswd.1; program
and the login prompt; we will
call this a one-time password. The final sort of
password is the secret password which you give to the
opiekey program (and
sometimes the
opiepasswd programs)
which it uses to generate
one-time passwords; we will call it a secret password
or just unqualified password.The secret password does not have anything to do with your &unix;
password; they can be the same but this is not recommended.
OPIE secret passwords are not limited to 8 characters like old
&unix; passwordsUnder &os; the standard login
password may be up to 128 characters in length.,
they can be as long as you like. Passwords of six or
seven word long phrases are fairly common. For the most part, the
OPIE system operates completely independently of the &unix;
password system.Besides the password, there are two other pieces of data that
are important to OPIE. One is what is known as the
seed or key, consisting of two letters
and five digits. The other is what is called the iteration
count, a number between 1 and 100. OPIE creates the
one-time password by concatenating the seed and the secret password,
then applying the MD5 hash as many times as specified by the
iteration count and turning the result into six short English words.
These six English words are your one-time password. The
authentication system (primarily PAM) keeps
track of the last one-time password used, and the user is
authenticated if the hash of the user-provided password is equal to
the previous password. Because a one-way hash is used it is
impossible to generate future one-time passwords if a successfully
used password is captured; the iteration count is decremented after
each successful login to keep the user and the login program in
sync. When the iteration count gets down to 1, OPIE must be
reinitialized.There are a few programs involved in each system
which we will discuss below. The
opiekey program accepts an iteration
count, a seed, and a secret password, and generates a one-time
password or a consecutive list of one-time passwords. The
opiepasswd
program is used to initialize OPIE,
and to change passwords, iteration counts, or seeds; it
takes either a secret passphrase, or an iteration count,
seed, and a one-time password. The
opieinfo program will examine the
relevant credentials files
(/etc/opiekeys) and print out the invoking user's
current iteration count and seed.There are four different sorts of operations we will cover. The
first is using
opiepasswd over a secure connection to set up
one-time-passwords for the first time, or to change your password
or seed. The second operation is using
opiepasswd over an insecure connection, in
conjunction with opiekey
over a secure connection, to do the same. The third is using
opiekey to log in over
an insecure connection. The fourth is using
opiekey to generate a number of keys which
can be written down or printed out to carry with you when going to
some location without secure connections to anywhere.Secure Connection InitializationTo initialize OPIE for the first time, execute the
opiepasswd command:&prompt.user; opiepasswd -c
[grimreaper] ~ $ opiepasswd -f -c
Adding unfurl:
Only use this method from the console; NEVER from remote. If you are using
telnet, xterm, or a dial-in, type ^C now or exit with no password.
Then run opiepasswd without the -c parameter.
Using MD5 to compute responses.
Enter new secret pass phrase:
Again new secret pass phrase:
ID unfurl OTP key is 499 to4268
MOS MALL GOAT ARM AVID COED
At the Enter new secret pass phrase: or
Enter secret password: prompts, you
should enter a password or phrase. Remember, this is not the
password that you will use to login with, this is used to generate
your one-time login keys. The ID line gives the
parameters of your particular instance: your login name, the
iteration count, and seed. When logging in the system
will remember these parameters and present them back to you so you
do not have to remember them. The last line gives the particular
one-time password which corresponds to those parameters and your
secret password; if you were to re-login immediately, this
one-time password is the one you would use.Insecure Connection InitializationTo initialize or change your secret password over an
insecure connection, you will need to already have a secure
connection to some place where you can run
opiekey; this might be in the form of a shell
prompt on a machine you
trust. You will also need to make up an iteration count (100 is
probably a good value), and you may make up your own seed or use a
randomly-generated one. Over on the insecure connection (to the
machine you are initializing), use opiepasswd:&prompt.user; opiepasswd
Updating unfurl:
You need the response from an OTP generator.
Old secret pass phrase:
otp-md5 498 to4268 ext
Response: GAME GAG WELT OUT DOWN CHAT
New secret pass phrase:
otp-md5 499 to4269
Response: LINE PAP MILK NELL BUOY TROY
ID mark OTP key is 499 gr4269
LINE PAP MILK NELL BUOY TROY
To accept the default seed press Return.
Then before entering an
access password, move over to your secure connection and give it
the same parameters:&prompt.user; opiekey 498 to4268
Using the MD5 algorithm to compute response.
Reminder: Don't use opiekey from telnet or dial-in sessions.
Enter secret pass phrase:
GAME GAG WELT OUT DOWN CHAT
Now switch back over to the insecure connection, and copy the
one-time password generated over to the relevant program.Generating a Single One-time PasswordOnce you have initialized OPIE and login, you will be
presented with a prompt like this:&prompt.user; telnet example.com
Trying 10.0.0.1...
Connected to example.com
Escape character is '^]'.
FreeBSD/i386 (example.com) (ttypa)
login: <username>
otp-md5 498 gr4269 ext
Password: As a side note, the OPIE prompts have a useful feature
(not shown here): if you press Return
at the password prompt, the
prompter will turn echo on, so you can see what you are
typing. This can be extremely useful if you are attempting to
type in a password by hand, such as from a printout.MS-DOSWindowsMacOSAt this point you need to generate your one-time password to
answer this login prompt. This must be done on a trusted system
that you can run
opiekey on. (There are versions of these for DOS,
&windows; and &macos; as well.) They need the iteration count and
the seed as command line options. You can cut-and-paste these
right from the login prompt on the machine that you are logging
in to.On the trusted system:&prompt.user; opiekey 498 to4268
Using the MD5 algorithm to compute response.
Reminder: Don't use opiekey from telnet or dial-in sessions.
Enter secret pass phrase:
GAME GAG WELT OUT DOWN CHATNow that you have your one-time password you can continue
logging in.Generating Multiple One-time PasswordsSometimes you have to go places where you do not have
access to a trusted machine or secure connection. In this case,
it is possible to use the
opiekey command to
generate a number of one-time passwords beforehand to be printed
out and taken with you. For example:&prompt.user; opiekey -n 5 30 zz99999
Using the MD5 algorithm to compute response.
Reminder: Don't use opiekey from telnet or dial-in sessions.
Enter secret pass phrase: <secret password>
26: JOAN BORE FOSS DES NAY QUIT
27: LATE BIAS SLAY FOLK MUCH TRIG
28: SALT TIN ANTI LOON NEAL USE
29: RIO ODIN GO BYE FURY TIC
30: GREW JIVE SAN GIRD BOIL PHIThe requests five keys in sequence, the
specifies what the last iteration number
should be. Note that these are printed out in
reverse order of eventual use. If you are
really paranoid, you might want to write the results down by hand;
otherwise you can cut-and-paste into lpr. Note
that each line shows both the iteration count and the one-time
password; you may still find it handy to scratch off passwords as
you use them.Restricting Use of &unix; PasswordsOPIE can restrict the use of &unix; passwords based on the IP
address of a login session. The relevant file
is /etc/opieaccess, which is present by default.
Please check &man.opieaccess.5;
for more information on this file and which security considerations
you should be aware of when using it.Here is a sample opieaccess file:permit 192.168.0.0 255.255.0.0This line allows users whose IP source address (which is
vulnerable to spoofing) matches the specified value and mask,
to use &unix; passwords at any time.If no rules in opieaccess are matched,
the default is to deny non-OPIE logins.TomRhodesWritten by: TCP WrappersTCP WrappersAnyone familiar with &man.inetd.8; has probably heard
of TCP Wrappers at some point. But few
individuals seem to fully comprehend its usefulness in a
network environment. It seems that everyone wants to
install a firewall to handle network connections. While a
firewall has a wide variety of uses, there are some things
that a firewall not handle such as sending text back to the
connection originator. The TCP software
does this and much more. In the next few sections many of
the TCP Wrappers features will be discussed,
and, when applicable, example configuration lines will be
provided.The TCP Wrappers software extends the
abilities of inetd to provide support for
every server daemon under its control. Using this method it
is possible to provide logging support, return messages to
connections, permit a daemon to only accept internal connections,
etc. While some of these features can be provided by implementing
a firewall, this will add not only an extra layer of protection
but go beyond the amount of control a firewall can
provide.The added functionality of TCP Wrappers
should not be considered a replacement for a good firewall.
TCP Wrappers can be used in conjunction
with a firewall or other security enhancements though and
it can serve nicely as an extra layer of protection
for the system.Since this is an extension to the configuration of
inetd, the reader is expected have
read the inetd configuration
section.While programs run by &man.inetd.8; are not exactly
daemons, they have traditionally been called
daemons. This is the term we will use in this section too.Initial ConfigurationThe only requirement of using TCP
Wrappers in &os; is to ensure the inetd
server is started from rc.conf with the
option; this is the default setting. Of
course, proper configuration of
/etc/hosts.allow is also expected, but
&man.syslogd.8; will throw messages in the system logs in
these cases.Unlike other implementations of TCP
Wrappers, the use of hosts.deny has
been deprecated. All configuration options should be placed
in /etc/hosts.allow.In the simplest configuration, daemon connection policies
are set to either be permitted or blocked depending on the
options in /etc/hosts.allow. The default
configuration in &os; is to allow a connection to every daemon
started with inetd. Changing this will be
discussed only after the basic configuration is covered.Basic configuration usually takes the form of
daemon : address : action. Where
daemon is the daemon name which
inetd started. The
address can be a valid hostname, an
IP address or an IPv6 address enclosed in
brackets ([ ]). The action field can be either allow
or deny to grant or deny access appropriately. Keep in mind
that configuration works off a first rule match semantic,
meaning that the configuration file is scanned in ascending
order for a matching rule. When a match is found the rule
is applied and the search process will halt.Several other options exist but they will be explained
in a later section. A simple configuration line may easily be
constructed from that information alone. For example, to
allow POP3 connections via the
mail/qpopper daemon,
the following lines should be appended to
hosts.allow:# This line is required for POP3 connections:
qpopper : ALL : allowAfter adding this line, inetd will need
restarted. This can be accomplished by use of the &man.kill.1;
command, or with the restart parameter
with /etc/rc.d/inetd.Advanced ConfigurationTCP Wrappers has advanced
options too; they will allow for more control over the
way connections are handled. In some cases it may be
a good idea to return a comment to certain hosts or
daemon connections. In other cases, perhaps a log file
should be recorded or an email sent to the administrator.
Other situations may require the use of a service for local
connections only. This is all possible through the use of
configuration options known as wildcards,
expansion characters and external command execution. The
next two sections are written to cover these situations.External CommandsSuppose that a situation occurs where a connection
should be denied yet a reason should be sent to the
individual who attempted to establish that connection. How
could it be done? That action can be made possible by
using the option. When a connection
attempt is made, will be called to
execute a shell command or script. An example already exists
in the hosts.allow file:# The rest of the daemons are protected.
ALL : ALL \
: severity auth.info \
: twist /bin/echo "You are not welcome to use %d from %h."This example shows that the message,
You are not allowed to use daemon
from hostname. will be returned
for any daemon not previously configured in the access file.
This is extremely useful for sending a reply back to the
connection initiator right after the established connection
is dropped. Note that any message returned
must be wrapped in quote
" characters; there are no exceptions to
this rule.It may be possible to launch a denial of service attack
on the server if an attacker, or group of attackers could
flood these daemons with connection requests.Another possibility is to use the
option in these cases. Like , the
implicitly denies the connection and
may be used to run external shell commands or scripts.
Unlike , will
not send a reply back to the individual who established the
connection. For an example, consider the following
configuration line:# We do not allow connections from example.com:
ALL : .example.com \
: spawn (/bin/echo %a from %h attempted to access %d >> \
/var/log/connections.log) \
: denyThis will deny all connection attempts from the
*.example.com domain;
simultaneously logging the hostname, IP
address and the daemon which they attempted to access in the
/var/log/connections.log file.Aside from the already explained substitution characters
above, e.g. %a, a few others exist. See the
&man.hosts.access.5; manual page for the complete list.Wildcard OptionsThus far the ALL example has been used
continuously throughout the examples. Other options exist
which could extend the functionality a bit further. For
instance, ALL may be used to match every
instance of either a daemon, domain or an
IP address. Another wildcard available is
PARANOID which may be used to match any
host which provides an IP address that may
be forged. In other words, paranoid may
be used to define an action to be taken whenever a connection
is made from an IP address that differs
from its hostname. The following example may shed some more
light on this discussion:# Block possibly spoofed requests to sendmail:
sendmail : PARANOID : denyIn that example all connection requests to
sendmail which have an
IP address that varies from its hostname
will be denied.Using the PARANOID may severely
cripple servers if the client or server has a broken
DNS setup. Administrator discretion
is advised.To learn more about wildcards and their associated
functionality, see the &man.hosts.access.5; manual
page.Before any of the specific configuration lines above will
work, the first configuration line should be commented out
in hosts.allow. This was noted at the
beginning of this section.MarkMurrayContributed by MarkDapozBased on a contribution by KerberosIVKerberos is a network add-on system/protocol that allows users to
authenticate themselves through the services of a secure server.
Services such as remote login, remote copy, secure inter-system file
copying and other high-risk tasks are made considerably safer and more
controllable.The following instructions can be used as a guide on how to set up
Kerberos as distributed for &os;. However, you should refer to the
relevant manual pages for a complete description.Installing KerberosIVMITKerberosIVinstallingKerberos is an optional component of &os;. The easiest
way to install this software is by selecting the krb4 or
krb5 distribution in sysinstall
during the initial installation of &os;. This will install
the eBones (KerberosIV) or Heimdal (Kerberos5)
implementation of Kerberos. These implementations are
included because they are developed outside the USA/Canada and
were thus available to system owners outside those countries
during the era of restrictive export controls on cryptographic
code from the USA.Alternatively, the MIT implementation of Kerberos is
available from the Ports Collection as
security/krb5.Creating the Initial DatabaseThis is done on the Kerberos server only. First make sure that
you do not have any old Kerberos databases around. You should change
to the directory /etc/kerberosIV and check that
only the following files are present:&prompt.root; cd /etc/kerberosIV
&prompt.root; ls
README krb.conf krb.realmsIf any additional files (such as principal.*
or master_key) exist, then use the
kdb_destroy command to destroy the old Kerberos
database, or if Kerberos is not running, simply delete the extra
files.You should now edit the krb.conf and
krb.realms files to define your Kerberos realm.
In this case the realm will be EXAMPLE.COM and the
server is grunt.example.com. We edit
or create the krb.conf file:&prompt.root; cat krb.conf
EXAMPLE.COM
EXAMPLE.COM grunt.example.com admin server
CS.BERKELEY.EDU okeeffe.berkeley.edu
ATHENA.MIT.EDU kerberos.mit.edu
ATHENA.MIT.EDU kerberos-1.mit.edu
ATHENA.MIT.EDU kerberos-2.mit.edu
ATHENA.MIT.EDU kerberos-3.mit.edu
LCS.MIT.EDU kerberos.lcs.mit.edu
TELECOM.MIT.EDU bitsy.mit.edu
ARC.NASA.GOV trident.arc.nasa.govIn this case, the other realms do not need to be there. They are
here as an example of how a machine may be made aware of multiple
realms. You may wish to not include them for simplicity.The first line names the realm in which this system works. The
other lines contain realm/host entries. The first item on a line is a
realm, and the second is a host in that realm that is acting as a
key distribution center. The words admin
server following a host's name means that host also
provides an administrative database server. For further explanation
of these terms, please consult the Kerberos manual pages.Now we have to add grunt.example.com
to the EXAMPLE.COM realm and also add an entry to
put all hosts in the .example.com
domain in the EXAMPLE.COM realm. The
krb.realms file would be updated as
follows:&prompt.root; cat krb.realms
grunt.example.com EXAMPLE.COM
.example.com EXAMPLE.COM
.berkeley.edu CS.BERKELEY.EDU
.MIT.EDU ATHENA.MIT.EDU
.mit.edu ATHENA.MIT.EDUAgain, the other realms do not need to be there. They are here as
an example of how a machine may be made aware of multiple realms. You
may wish to remove them to simplify things.The first line puts the specific system into
the named realm. The rest of the lines show how to default systems of
a particular subdomain to a named realm.Now we are ready to create the database. This only needs to run
on the Kerberos server (or Key Distribution Center). Issue the
kdb_init command to do this:&prompt.root; kdb_initRealm name [default ATHENA.MIT.EDU ]:EXAMPLE.COM
You will be prompted for the database Master Password.
It is important that you NOT FORGET this password.
Enter Kerberos master key:Now we have to save the key so that servers on the local machine
can pick it up. Use the kstash command to do
this:&prompt.root; kstashEnter Kerberos master key:
Current Kerberos master key version is 1.
Master key entered. BEWARE!This saves the encrypted master password in
/etc/kerberosIV/master_key.Making It All RunKerberosIVinitial startupTwo principals need to be added to the database for
each system that will be secured with Kerberos.
Their names are kpasswd and rcmd.
These two principals are made for each system, with the instance being
the name of the individual system.These daemons, kpasswd and
rcmd allow other systems to change Kerberos
passwords and run commands like &man.rcp.1;,
&man.rlogin.1; and &man.rsh.1;.Now let us add these entries:&prompt.root; kdb_edit
Opening database...
Enter Kerberos master key:
Current Kerberos master key version is 1.
Master key entered. BEWARE!
Previous or default values are in [brackets] ,
enter return to leave the same, or new value.
Principal name:passwdInstance:grunt
<Not found>, Create [y] ?y
Principal: passwd, Instance: grunt, kdc_key_ver: 1
New Password: <---- enter RANDOM here
Verifying password
New Password: <---- enter RANDOM here
Random password [y] ?y
Principal's new key version = 1
Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?Max ticket lifetime (*5 minutes) [ 255 ] ?Attributes [ 0 ] ?
Edit O.K.
Principal name:rcmdInstance:grunt
<Not found>, Create [y] ?
Principal: rcmd, Instance: grunt, kdc_key_ver: 1
New Password: <---- enter RANDOM here
Verifying password
New Password: <---- enter RANDOM here
Random password [y] ?
Principal's new key version = 1
Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?Max ticket lifetime (*5 minutes) [ 255 ] ?Attributes [ 0 ] ?
Edit O.K.
Principal name: <---- null entry here will cause an exitCreating the Server FileWe now have to extract all the instances which define the
services on each machine. For this we use the
ext_srvtab command. This will create a file
which must be copied or moved by secure
means to each Kerberos client's
/etc directory. This file must
be present on each server and client, and is crucial to the
operation of Kerberos.&prompt.root; ext_srvtab gruntEnter Kerberos master key:
Current Kerberos master key version is 1.
Master key entered. BEWARE!
Generating 'grunt-new-srvtab'....Now, this command only generates a temporary file which must be
renamed to srvtab so that all the servers can pick
it up. Use the &man.mv.1; command to move it into place on
the original system:&prompt.root; mv grunt-new-srvtab srvtabIf the file is for a client system, and the network is not deemed
safe, then copy the
client-new-srvtab to
removable media and transport it by secure physical means. Be sure to
rename it to srvtab in the client's
/etc directory, and make sure it is
mode 600:&prompt.root; mv grumble-new-srvtab srvtab
&prompt.root; chmod 600 srvtabPopulating the DatabaseWe now have to add some user entries into the database. First
let us create an entry for the user jane. Use the
kdb_edit command to do this:&prompt.root; kdb_edit
Opening database...
Enter Kerberos master key:
Current Kerberos master key version is 1.
Master key entered. BEWARE!
Previous or default values are in [brackets] ,
enter return to leave the same, or new value.
Principal name:janeInstance:
<Not found>, Create [y] ?y
Principal: jane, Instance: , kdc_key_ver: 1
New Password: <---- enter a secure password here
Verifying password
New Password: <---- re-enter the password here
Principal's new key version = 1
Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?Max ticket lifetime (*5 minutes) [ 255 ] ?Attributes [ 0 ] ?
Edit O.K.
Principal name: <---- null entry here will cause an exitTesting It All OutFirst we have to start the Kerberos daemons. Note that if you
have correctly edited your /etc/rc.conf then this
will happen automatically when you reboot. This is only necessary on
the Kerberos server. Kerberos clients will automatically get what
they need from the /etc/kerberosIV
directory.&prompt.root; kerberos &
Kerberos server starting
Sleep forever on error
Log file is /var/log/kerberos.log
Current Kerberos master key version is 1.
Master key entered. BEWARE!
Current Kerberos master key version is 1
Local realm: EXAMPLE.COM
&prompt.root; kadmind -n &
KADM Server KADM0.0A initializing
Please do not use 'kill -9' to kill this job, use a
regular kill instead
Current Kerberos master key version is 1.
Master key entered. BEWARE!Now we can try using the kinit command to get a
ticket for the ID jane that we created
above:&prompt.user; kinit jane
MIT Project Athena (grunt.example.com)
Kerberos Initialization for "jane"
Password:Try listing the tokens using klist to see if we
really have them:&prompt.user; klist
Ticket file: /tmp/tkt245
Principal: jane@EXAMPLE.COM
Issued Expires Principal
Apr 30 11:23:22 Apr 30 19:23:22 krbtgt.EXAMPLE.COM@EXAMPLE.COMNow try changing the password using &man.passwd.1; to
check if the kpasswd daemon can get
authorization to the Kerberos database:&prompt.user; passwd
realm EXAMPLE.COM
Old password for jane:New Password for jane:
Verifying password
New Password for jane:
Password changed.Adding su PrivilegesKerberos allows us to give each user
who needs root privileges their own
separate &man.su.1; password.
We could now add an ID which is authorized to
&man.su.1; to root. This is
controlled by having an instance of root
associated with a principal. Using kdb_edit
we can create the entry jane.root in the
Kerberos database:&prompt.root; kdb_edit
Opening database...
Enter Kerberos master key:
Current Kerberos master key version is 1.
Master key entered. BEWARE!
Previous or default values are in [brackets] ,
enter return to leave the same, or new value.
Principal name:janeInstance:root
<Not found>, Create [y] ? y
Principal: jane, Instance: root, kdc_key_ver: 1
New Password: <---- enter a SECURE password here
Verifying password
New Password: <---- re-enter the password here
Principal's new key version = 1
Expiration date (enter yyyy-mm-dd) [ 2000-01-01 ] ?Max ticket lifetime (*5 minutes) [ 255 ] ?12 <--- Keep this short!
Attributes [ 0 ] ?
Edit O.K.
Principal name: <---- null entry here will cause an exitNow try getting tokens for it to make sure it works:&prompt.root; kinit jane.root
MIT Project Athena (grunt.example.com)
Kerberos Initialization for "jane.root"
Password:Now we need to add the user to root's
.klogin file:&prompt.root; cat /root/.klogin
jane.root@EXAMPLE.COMNow try doing the &man.su.1;:&prompt.user; suPassword:and take a look at what tokens we have:&prompt.root; klist
Ticket file: /tmp/tkt_root_245
Principal: jane.root@EXAMPLE.COM
Issued Expires Principal
May 2 20:43:12 May 3 04:43:12 krbtgt.EXAMPLE.COM@EXAMPLE.COMUsing Other CommandsIn an earlier example, we created a principal called
jane with an instance root.
This was based on a user with the same name as the principal, and this
is a Kerberos default; that a
<principal>.<instance> of the form
<username>.root will allow
that <username> to &man.su.1; to
root if the necessary entries are in the
.klogin file in root's
home directory:&prompt.root; cat /root/.klogin
jane.root@EXAMPLE.COMLikewise, if a user has in their own home directory lines of the
form:&prompt.user; cat ~/.klogin
jane@EXAMPLE.COM
jack@EXAMPLE.COMThis allows anyone in the EXAMPLE.COM realm
who has authenticated themselves as jane or
jack (via kinit, see above)
to access to jane's
account or files on this system (grunt) via
&man.rlogin.1;, &man.rsh.1; or
&man.rcp.1;.For example, jane now logs into another system using
Kerberos:&prompt.user; kinit
MIT Project Athena (grunt.example.com)
Password:
&prompt.user; rlogin grunt
Last login: Mon May 1 21:14:47 from grumble
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995Or jack logs into jane's account on the same machine
(jane having
set up the .klogin file as above, and the person
in charge of Kerberos having set up principal
jack with a null instance):&prompt.user; kinit
&prompt.user; rlogin grunt -l jane
MIT Project Athena (grunt.example.com)
Password:
Last login: Mon May 1 21:16:55 from grumble
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD BUILT-19950429 (GR386) #0: Sat Apr 29 17:50:09 SAT 1995TillmanHodgsonContributed by MarkMurrayBased on a contribution by Kerberos5Every &os; release beyond &os;-5.1 includes support
only for Kerberos5. Hence
Kerberos5 is the only version
included, and its configuration is similar in many aspects
to that of KerberosIV. The following
information only applies to
Kerberos5 in post &os;-5.0
releases. Users who wish to use the
KerberosIV package may install the
security/krb4 port.Kerberos is a network add-on
system/protocol that allows users to authenticate themselves
through the services of a secure server. Services such as remote
login, remote copy, secure inter-system file copying and other
high-risk tasks are made considerably safer and more
controllable.Kerberos can be described as an
identity-verifying proxy system. It can also be described as a
trusted third-party authentication system.
Kerberos provides only one
function — the secure authentication of users on the network.
It does not provide authorization functions (what users are
allowed to do) or auditing functions (what those users did).
After a client and server have used
Kerberos to prove their identity, they
can also encrypt all of their communications to assure privacy
and data integrity as they go about their business.Therefore it is highly recommended that
Kerberos be used with other security
methods which provide authorization and audit services.The following instructions can be used as a guide on how to set
up Kerberos as distributed for &os;.
However, you should refer to the relevant manual pages for a complete
description.For purposes of demonstrating a Kerberos
installation, the various name spaces will be handled as follows:The DNS domain (zone)
will be example.org.The Kerberos realm will be
EXAMPLE.ORG.Please use real domain names when setting up
Kerberos even if you intend to run
it internally. This avoids DNS problems
and assures inter-operation with other
Kerberos realms.HistoryKerberos5historyKerberos was created by
MIT as a solution to network security problems.
The Kerberos protocol uses strong
cryptography so that a client can prove its identity to a server
(and vice versa) across an insecure network connection.Kerberos is both the name of a
network authentication protocol and an adjective to describe
programs that implement the program
(Kerberos telnet, for example). The
current version of the protocol is version 5, described in
RFC 1510.Several free implementations of this protocol are available,
covering a wide range of operating systems. The Massachusetts
Institute of Technology (MIT), where
Kerberos was originally developed,
continues to develop their Kerberos
package. It is commonly used in the US
as a cryptography product, as such it
has historically been affected by US export
regulations. The MIT
Kerberos is available as a port
(security/krb5). Heimdal
Kerberos is another version 5
implementation, and was explicitly developed outside of the
US to avoid export
regulations (and is thus often included in non-commercial &unix;
variants). The Heimdal Kerberos
distribution is available as a port
(security/heimdal), and a
minimal installation of it is included in the base &os;
install.In order to reach the widest audience, these instructions assume
the use of the Heimdal distribution included in &os;.Setting up a Heimdal KDCKerberos5Key Distribution CenterThe Key Distribution Center (KDC) is the
centralized authentication service that
Kerberos provides — it is the
computer that issues Kerberos tickets.
The KDC is considered trusted by
all other computers in the Kerberos
realm, and thus has heightened security concerns.Note that while running the Kerberos
server requires very few computing resources, a dedicated machine
acting only as a KDC is recommended for security
reasons.To begin setting up a KDC, ensure that your
/etc/rc.conf file contains the correct
settings to act as a KDC (you may need to adjust
paths to reflect your own system):kerberos5_server_enable="YES"
kadmind5_server_enable="YES"Next we will set up your Kerberos
config file, /etc/krb5.conf:[libdefaults]
default_realm = EXAMPLE.ORG
[realms]
EXAMPLE.ORG = {
kdc = kerberos.example.org
admin_server = kerberos.example.org
}
[domain_realm]
.example.org = EXAMPLE.ORGNote that this /etc/krb5.conf file implies
that your KDC will have the fully-qualified
hostname of kerberos.example.org.
You will need to add a CNAME (alias) entry to your zone file to
accomplish this if your KDC has a different
hostname.For large networks with a properly configured
BIND DNS server, the
above example could be trimmed to:[libdefaults]
default_realm = EXAMPLE.ORGWith the following lines being appended to the
example.org zonefile:_kerberos._udp IN SRV 01 00 88 kerberos.example.org.
_kerberos._tcp IN SRV 01 00 88 kerberos.example.org.
_kpasswd._udp IN SRV 01 00 464 kerberos.example.org.
_kerberos-adm._tcp IN SRV 01 00 749 kerberos.example.org.
_kerberos IN TXT EXAMPLE.ORGFor clients to be able to find the
Kerberos services, you
must have either a fully configured
/etc/krb5.conf or a minimally configured
/etc/krb5.confand a
properly configured DNS server.Next we will create the Kerberos
database. This database contains the keys of all principals encrypted
with a master password. You are not
required to remember this password, it will be stored in a file
(/var/heimdal/m-key). To create the master
key, run kstash and enter a password.Once the master key has been created, you can initialize the
database using the kadmin program with the
-l option (standing for local).
This option instructs kadmin to modify the
database files directly rather than going through the
kadmind network service. This handles the
chicken-and-egg problem of trying to connect to the database
before it is created. Once you have the kadmin
prompt, use the init command to create your
realms initial database.Lastly, while still in kadmin, create your
first principal using the add command. Stick
to the defaults options for the principal for now, you can always
change them later with the modify command.
Note that you can use the ? command at any
prompt to see the available options.A sample database creation session is shown below:&prompt.root; kstash
Master key: xxxxxxxx
Verifying password - Master key: xxxxxxxx
&prompt.root; kadmin -l
kadmin> init EXAMPLE.ORG
Realm max ticket life [unlimited]:
kadmin> add tillman
Max ticket life [unlimited]:
Max renewable life [unlimited]:
Attributes []:
Password: xxxxxxxx
Verifying password - Password: xxxxxxxxNow it is time to start up the KDC services.
Run /etc/rc.d/kerberos start and
/etc/rc.d/kadmind start to bring up the
services. Note that you will not have any kerberized daemons running
at this point but you should be able to confirm the that the
KDC is functioning by obtaining and listing a
ticket for the principal (user) that you just created from the
command-line of the KDC itself:&prompt.user; kinit tillman
tillman@EXAMPLE.ORG's Password:
&prompt.user; klist
Credentials cache: FILE:/tmp/krb5cc_500
Principal: tillman@EXAMPLE.ORG
Issued Expires Principal
Aug 27 15:37:58 Aug 28 01:37:58 krbtgt/EXAMPLE.ORG@EXAMPLE.ORGThe ticket can then be revoked when you have
finished:&prompt.user; k5destroyKerberos enabling a server with
Heimdal servicesKerberos5enabling servicesFirst, we need a copy of the Kerberos
configuration file, /etc/krb5.conf. To do
so, simply copy it over to the client computer from the
KDC in a secure fashion (using network utilities,
such as &man.scp.1;, or physically via a
floppy disk).Next you need a /etc/krb5.keytab file.
This is the major difference between a server providing
Kerberos enabled daemons and a
workstation — the server must have a
keytab file. This file
contains the server's host key, which allows it and the
KDC to verify each others identity. It
must be transmitted to the server in a secure fashion, as the
security of the server can be broken if the key is made public.
This explicitly means that transferring it via a clear text
channel, such as FTP, is a very bad idea.Typically, you transfer to the keytab
to the server using the kadmin program.
This is handy because you also need to create the host principal
(the KDC end of the
krb5.keytab) using
kadmin.Note that you must have already obtained a ticket and that this
ticket must be allowed to use the kadmin
interface in the kadmind.acl. See the section
titled Remote administration in the Heimdal info
pages (info heimdal) for details on designing
access control lists. If you do not want to enable remote
kadmin access, you can simply securely connect
to the KDC (via local console,
&man.ssh.1; or Kerberos
&man.telnet.1;) and perform administration locally
using kadmin -l.After installing the /etc/krb5.conf file,
you can use kadmin from the
Kerberos server. The
add --random-key command will let you add the
server's host principal, and the ext command
will allow you to extract the server's host principal to its own
keytab. For example:&prompt.root; kadmin
kadmin> add --random-key host/myserver.example.org
Max ticket life [unlimited]:
Max renewable life [unlimited]:
Attributes []:
kadmin> ext host/myserver.example.org
kadmin> exitNote that the ext command (short for
extract) stores the extracted key in
/etc/krb5.keytab by default.If you do not have kadmind running on the
KDC (possibly for security reasons) and thus
do not have access to kadmin remotely, you
can add the host principal
(host/myserver.EXAMPLE.ORG) directly on the
KDC and then extract it to a temporary file
(to avoid over-writing the /etc/krb5.keytab
on the KDC) using something like this:&prompt.root; kadmin
kadmin> ext --keytab=/tmp/example.keytab host/myserver.example.org
kadmin> exitYou can then securely copy the keytab to the server
computer (using scp or a floppy, for
example). Be sure to specify a non-default keytab name
to avoid over-writing the keytab on the
KDC.At this point your server can communicate with the
KDC (due to its krb5.conf
file) and it can prove its own identity (due to the
krb5.keytab file). It is now ready for
you to enable some Kerberos services.
For this example we will enable the telnet
service by putting a line like this into your
/etc/inetd.conf and then restarting the
&man.inetd.8; service with
/etc/rc.d/inetd restart:telnet stream tcp nowait root /usr/libexec/telnetd telnetd -a userThe critical bit is that the -a
(for authentication) type is set to user. Consult the
&man.telnetd.8; manual page for more details.Kerberos enabling a client with HeimdalKerberos5configure clientsSetting up a client computer is almost trivially easy. As
far as Kerberos configuration goes,
you only need the Kerberos
configuration file, located at /etc/krb5.conf.
Simply securely copy it over to the client computer from the
KDC.Test your client computer by attempting to use
kinit, klist, and
kdestroy from the client to obtain, show, and
then delete a ticket for the principal you created above. You
should also be able to use Kerberos
applications to connect to Kerberos
enabled servers, though if that does not work and obtaining a
ticket does the problem is likely with the server and not with
the client or the KDC.When testing an application like telnet,
try using a packet sniffer (such as &man.tcpdump.1;)
to confirm that your password is not sent in the clear. Try
using telnet with the -x
option, which encrypts the entire data stream (similar to
ssh).Various non-core Kerberos client
applications are also installed by default. This is where the
minimal nature of the base Heimdal installation is
felt: telnet is the only
Kerberos enabled service.The Heimdal port adds some of the missing client applications:
Kerberos enabled versions of
ftp, rsh,
rcp, rlogin, and a few
other less common programs. The MIT port also
contains a full suite of Kerberos
client applications.User configuration files: .k5login and .k5users.k5login.k5usersUsers within a realm typically have their
Kerberos principal (such as
tillman@EXAMPLE.ORG) mapped to a local
user account (such as a local account named
tillman). Client applications such as
telnet usually do not require a user name
or a principal.Occasionally, however, you want to grant access to a local
user account to someone who does not have a matching
Kerberos principal. For example,
tillman@EXAMPLE.ORG may need access to the
local user account webdevelopers. Other
principals may also need access to that local account.The .k5login and
.k5users files, placed in a users home
directory, can be used similar to a powerful combination of
.hosts and .rhosts,
solving this problem. For example, if a
.k5login with the following
contents:tillman@example.org
jdoe@example.orgWere to be placed into the home directory of the local user
webdevelopers then both principals listed
would have access to that account without requiring a shared
password.Reading the manual pages for these commands is recommended.
Note that the ksu manual page covers
.k5users.Kerberos Tips, Tricks, and TroubleshootingKerberos5troubleshootingWhen using either the Heimdal or MIT
Kerberos ports ensure that your
PATH environment variable lists the
Kerberos versions of the client
applications before the system versions.Do all the computers in your realm have synchronized
time settings? If not, authentication may fail.
describes how to synchronize
clocks using NTP.MIT and Heimdal inter-operate nicely.
Except for kadmin, the protocol for
which is not standardized.If you change your hostname, you also need to change your
host/ principal and update your keytab.
This also applies to special keytab entries like the
www/ principal used for Apache's
www/mod_auth_kerb.All hosts in your realm must be resolvable (both forwards
and reverse) in DNS (or
/etc/hosts as a minimum). CNAMEs
will work, but the A and PTR records must be correct and in
place. The error message is not very intuitive:
Kerberos5 refuses authentication because Read req
failed: Key table entry not found.Some operating systems that may being acting as clients
to your KDC do not set the permissions
for ksu to be setuid
root. This means that
ksu does not work, which is a good
security idea but annoying. This is not a
KDC error.With MIT
Kerberos, if you want to allow a
principal to have a ticket life longer than the default ten
hours, you must use modify_principal in
kadmin to change the maxlife of both the
principal in question and the krbtgt
principal. Then the principal can use the
-l option with kinit
to request a ticket with a longer lifetime.If you run a packet sniffer on your
KDC to add in troubleshooting and then
run kinit from a workstation, you will
notice that your TGT is sent
immediately upon running kinit —
even before you type your password! The explanation is
that the Kerberos server freely
transmits a TGT (Ticket Granting
Ticket) to any unauthorized request; however, every
TGT is encrypted in a key derived from
the user's password. Therefore, when a user types their
password it is not being sent to the KDC,
it is being used to decrypt the TGT that
kinit already obtained. If the decryption
process results in a valid ticket with a valid time stamp,
the user has valid Kerberos
credentials. These credentials include a session key for
establishing secure communications with the
Kerberos server in the future, as
well as the actual ticket-granting ticket, which is actually
encrypted with the Kerberos
server's own key. This second layer of encryption is
unknown to the user, but it is what allows the
Kerberos server to verify
the authenticity of each TGT.If you want to use long ticket lifetimes (a week, for
example) and you are using OpenSSH
to connect to the machine where your ticket is stored, make
sure that Kerberos
is set to no
in your sshd_config or else your tickets
will be deleted when you log out.Remember that host principals can have a longer ticket
lifetime as well. If your user principal has a lifetime of a
week but the host you are connecting to has a lifetime of nine
hours, you will have an expired host principal in your cache
and the ticket cache will not work as expected.When setting up a krb5.dict file to
prevent specific bad passwords from being used (the manual page
for kadmind covers this briefly), remember
that it only applies to principals that have a password policy
assigned to them. The krb5.dict files
format is simple: one string per line. Creating a symbolic
link to /usr/share/dict/words might be
useful.Differences with the MIT portThe major difference between the MIT
and Heimdal installs relates to the kadmin
program which has a different (but equivalent) set of commands
and uses a different protocol. This has a large implications
if your KDC is MIT as you
will not be able to use the Heimdal kadmin
program to administer your KDC remotely
(or vice versa, for that matter).The client applications may also take slightly different
command line options to accomplish the same tasks. Following
the instructions on the MIT
Kerberos web site
()
is recommended. Be careful of path issues: the
MIT port installs into
/usr/local/ by default, and the
normal system applications may be run instead
of MIT if your PATH
environment variable lists the system directories first.With the MIT
security/krb5 port
that is provided by &os;, be sure to read the
/usr/local/share/doc/krb5/README.FreeBSD
file installed by the port if you want to understand why logins
via telnetd and klogind
behave somewhat oddly. Most importantly, correcting the
incorrect permissions on cache file behavior
requires that the login.krb5 binary be used
for authentication so that it can properly change ownership for
the forwarded credentials.The rc.conf must also be modified
to contain the following configuration:kerberos5_server="/usr/local/sbin/krb5kdc"
kadmind5_server="/usr/local/sbin/kadmind"
kerberos5_server_enable="YES"
kadmind5_server_enable="YES"This is done because the applications for
MIT kerberos installs binaries in the
/usr/local
hierarchy.Mitigating limitations found in KerberosKerberos5limitations and shortcomingsKerberos is an all-or-nothing approachEvery service enabled on the network must be modified to
work with Kerberos (or be otherwise
secured against network attacks) or else the users credentials
could be stolen and re-used. An example of this would be
Kerberos enabling all remote shells
(via rsh and telnet, for
example) but not converting the POP3 mail
server which sends passwords in plain text.Kerberos is intended for single-user workstationsIn a multi-user environment,
Kerberos is less secure.
This is because it stores the tickets in the
/tmp directory, which is readable by all
users. If a user is sharing a computer with several other
people simultaneously (i.e. multi-user), it is possible that
the user's tickets can be stolen (copied) by another
user.This can be overcome with the -c
filename command-line option or (preferably) the
KRB5CCNAME environment variable, but this
is rarely done. In principal, storing the ticket in the users
home directory and using simple file permissions can mitigate
this problem.The KDC is a single point of failureBy design, the KDC must be as secure as
the master password database is contained on it. The
KDC should have absolutely no other
services running on it and should be physically secured. The
danger is high because Kerberos
stores all passwords encrypted with the same key (the
master key), which in turn is stored as a file
on the KDC.As a side note, a compromised master key is not quite as
bad as one might normally fear. The master key is only used
to encrypt the Kerberos database
and as a seed for the random number generator. As long as
access to your KDC is secure, an attacker
cannot do much with the master key.Additionally, if the KDC is unavailable
(perhaps due to a denial of service attack or network problems)
the network services are unusable as authentication can not be
performed, a recipe for a denial-of-service attack. This can
alleviated with multiple KDCs (a single
master and one or more slaves) and with careful implementation
of secondary or fall-back authentication
(PAM is excellent for this).Kerberos ShortcomingsKerberos allows users, hosts
and services to authenticate between themselves. It does not
have a mechanism to authenticate the KDC
to the users, hosts or services. This means that a trojanned
kinit (for example) could record all user
names and passwords. Something like
security/tripwire or
other file system integrity checking tools can alleviate
this.Resources and further informationKerberos5external resources
The Kerberos FAQDesigning
an Authentication System: a Dialog in Four ScenesRFC 1510,
The Kerberos Network Authentication Service
(V5)MIT
Kerberos home pageHeimdal
Kerberos home pageTomRhodesWritten by: OpenSSLsecurityOpenSSLOne feature that many users overlook is the
OpenSSL toolkit included
in &os;. OpenSSL provides an
encryption transport layer on top of the normal communications
layer; thus allowing it to be intertwined with many network
applications and services.Some uses of OpenSSL may include
encrypted authentication of mail clients, web based transactions
such as credit card payments and more. Many ports such as
www/apache13-ssl, and
mail/sylpheed-claws
will offer compilation support for building with
OpenSSL.In most cases the Ports Collection will attempt to build
the security/openssl port
unless the WITH_OPENSSL_BASE make variable
is explicitly set to yes.The version of OpenSSL included
in &os; supports Secure Sockets Layer v2/v3 (SSLv2/SSLv3),
Transport Layer Security v1 (TLSv1) network security protocols
and can be used as a general cryptographic library.While OpenSSL supports the
IDEA algorithm, it is disabled by default
due to United States patents. To use it, the license should
be reviewed and, if the restrictions are acceptable, the
MAKE_IDEA variable must be set in
make.conf.One of the most common uses of
OpenSSL is to provide certificates for
use with software applications. These certificates ensure
that the credentials of the company or individual are valid
and not fraudulent. If the certificate in question has
not been verified by one of the several Certificate Authorities,
or CAs, a warning is usually produced. A
Certificate Authority is a company, such as VeriSign, which will
sign certificates in order to validate credentials of individuals
or companies. This process has a cost associated with it and
is definitely not a requirement for using certificates; however,
it can put some of the more paranoid users at ease.Generating CertificatesOpenSSLcertificate generationTo generate a certificate, the following command is
available:&prompt.root; openssl req -new -nodes -out req.pem -keyout cert.pem
Generating a 1024 bit RSA private key
................++++++
.......................................++++++
writing new private key to 'cert.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:PA
Locality Name (eg, city) []:Pittsburgh
Organization Name (eg, company) [Internet Widgits Pty Ltd]:My Company
Organizational Unit Name (eg, section) []:Systems Administrator
Common Name (eg, YOUR name) []:localhost.example.org
Email Address []:trhodes@FreeBSD.org
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:SOME PASSWORD
An optional company name []:Another NameNotice the response directly after the
Common Name prompt shows a domain name.
This prompt requires a server name to be entered for
verification purposes; placing anything but a domain name
would yield a useless certificate. Other options, for
instance expire time, alternate encryption algorithms, etc.
are available. A complete list may be obtained by viewing
the &man.openssl.1; manual page.Two files should now exist in
the directory in which the aforementioned command was issued.
The certificate request, req.pem, may be
sent to a certificate authority who will validate the credentials
that you entered, sign the request and return the certificate to
you. The second file created will be named cert.pem
and is the private key for the certificate and should be
protected at all costs; if this falls in the hands of others it
can be used to impersonate you (or your server).In cases where a signature from a CA is
not required, a self signed certificate can be created. First,
generate the RSA key:&prompt.root; openssl dsaparam -rand -genkey -out myRSA.key 1024Next, generate the CA key:&prompt.root; openssl gendsa -des3 -out myca.keymyRSA.keyUse this key to create the certificate:&prompt.root; openssl req -new -x509 -days 365 -key myca.key -out new.crtTwo new files should appear in the directory: a certificate
authority signature file, myca.key and the
certificate itself, new.crt. These should
be placed in a directory, preferably under
/etc, which is readable
only by root. Permissions of 0700 should be fine for this and
they can be set with the chmod
utility.Using Certificates, an ExampleSo what can these files do? A good use would be to
encrypt connections to the Sendmail
MTA. This would dissolve the use of clear
text authentication for users who send mail via the local
MTA.This is not the best use in the world as some
MUAs will present the user with an
error if they have not installed the certificate locally.
Refer to the documentation included with the software for
more information on certificate installation.The following lines should be placed inside the
local .mc file:dnl SSL Options
define(`confCACERT_PATH',`/etc/certs')dnl
define(`confCACERT',`/etc/certs/new.crt')dnl
define(`confSERVER_CERT',`/etc/certs/new.crt')dnl
define(`confSERVER_KEY',`/etc/certs/myca.key')dnl
define(`confTLS_SRV_OPTIONS', `V')dnlWhere /etc/certs/
is the directory to be used for storing the certificate
and key files locally. The last few requirements are a rebuild
of the local .cf file. This is easily
achieved by typing makeinstall within the
/etc/mail
directory. Follow that up with makerestart which should start the
Sendmail daemon.If all went well there will be no error messages in the
/var/log/maillog file and
Sendmail will show up in the process
list.For a simple test, simply connect to the mail server
using the &man.telnet.1; utility:&prompt.root; telnet example.com 25
Trying 192.0.34.166...
Connected to example.com.
Escape character is '^]'.
220 example.com ESMTP Sendmail 8.12.10/8.12.10; Tue, 31 Aug 2004 03:41:22 -0400 (EDT)
ehlo example.com
250-example.com Hello example.com [192.0.34.166], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH LOGIN PLAIN
250-STARTTLS
250-DELIVERBY
250 HELP
quit
221 2.0.0 example.com closing connection
Connection closed by foreign host.If the STARTTLS line appears in the output
then everything is working correctly.NikClaytonnik@FreeBSD.orgWritten by IPsecVPN over IPsecCreating a VPN between two networks, separated by the
Internet, using FreeBSD gateways.Hiten M.Pandyahmp@FreeBSD.orgWritten by Understanding IPsecThis section will guide you through the process of setting
up IPsec, and to use it in an environment which consists of
FreeBSD and µsoft.windows; 2000/XP
machines, to make them communicate securely. In order to set up
IPsec, it is necessary that you are familiar with the concepts
of building a custom kernel (see
).IPsec is a protocol which sits on top
of the Internet Protocol (IP) layer. It allows two or more
hosts to communicate in a secure manner (hence the name). The
FreeBSD IPsec network stack is based on the
KAME implementation,
which has support for both protocol families, IPv4 and
IPv6.FreeBSD contains a hardware
accelerated IPsec stack, known as Fast
IPsec, that was obtained from OpenBSD. It employs
cryptographic hardware (whenever possible) via the
&man.crypto.4; subsystem to optimize the performance of IPsec.
This subsystem is new, and does not support all the features
that are available in the KAME version of IPsec. However, in
order to enable hardware-accelerated IPsec, the following
kernel option has to be added to your kernel configuration
file:kernel optionsFAST_IPSEC
options FAST_IPSEC # new IPsec (cannot define w/ IPSEC)
Note, that it is not currently possible to use the
Fast IPsec subsystem in lieu of the KAME
implementation of IPsec. Consult the &man.fast.ipsec.4;
manual page for more information.To let firewalls properly track state for &man.gif.4;
tunnels too, you have to enable the
in your kernel
configuration:
options IPSEC_FILTERGIF #filter ipsec packets from a tunnel
IPsecESPIPsecAHIPsec consists of two sub-protocols:Encapsulated Security Payload
(ESP), protects the IP packet data from third
party interference, by encrypting the contents using
symmetric cryptography algorithms (like Blowfish,
3DES).Authentication Header (AH),
protects the IP packet header from third party interference
and spoofing, by computing a cryptographic checksum and
hashing the IP packet header fields with a secure hashing
function. This is then followed by an additional header
that contains the hash, to allow the information in the
packet to be authenticated.ESP and AH can
either be used together or separately, depending on the
environment.VPNvirtual private networkVPNIPsec can either be used to directly encrypt the traffic
between two hosts (known as Transport
Mode); or to build virtual tunnels
between two subnets, which could be used for secure
communication between two corporate networks (known as
Tunnel Mode). The latter is more commonly
known as a Virtual Private Network (VPN).
The &man.ipsec.4; manual page should be consulted for detailed
information on the IPsec subsystem in FreeBSD.To add IPsec support to your kernel, add the following
options to your kernel configuration file:kernel optionsIPSECkernel optionsIPSEC_ESP
options IPSEC #IP security
options IPSEC_ESP #IP security (crypto; define w/ IPSEC)
kernel optionsIPSEC_DEBUGIf IPsec debugging support is desired, the following
kernel option should also be added:
options IPSEC_DEBUG #debug for IP security
The ProblemThere is no standard for what constitutes a VPN. VPNs can
be implemented using a number of different technologies, each of
which have their own strengths and weaknesses. This section
presents a scenario, and the strategies used for implementing a
VPN for this scenario.The Scenario: Two networks, connected to the Internet, to
behave as oneVPNcreatingThe premise is as follows:You have at least two sitesBoth sites are using IP internallyBoth sites are connected to the Internet, through a
gateway that is running FreeBSD.The gateway on each network has at least one public IP
address.The internal addresses of the two networks can be
public or private IP addresses, it does not matter. You can
be running NAT on the gateway machine if necessary.The internal IP addresses of the two networks
do not collide. While I expect it is
theoretically possible to use a combination of VPN
technology and NAT to get this to work, I expect it to be a
configuration nightmare.If you find that you are trying to connect two networks,
both of which, internally, use the same private IP address range
(e.g. both of them use 192.168.1.x), then one of the networks will
have to be renumbered.The network topology might look something like this:Network #1 [ Internal Hosts ] Private Net, 192.168.1.2-254
[ Win9x/NT/2K ]
[ UNIX ]
|
|
.---[fxp1]---. Private IP, 192.168.1.1
| FreeBSD |
`---[fxp0]---' Public IP, A.B.C.D
|
|
-=-=- Internet -=-=-
|
|
.---[fxp0]---. Public IP, W.X.Y.Z
| FreeBSD |
`---[fxp1]---' Private IP, 192.168.2.1
|
|
Network #2 [ Internal Hosts ]
[ Win9x/NT/2K ] Private Net, 192.168.2.2-254
[ UNIX ]Notice the two public IP addresses. I will use the letters to
refer to them in the rest of this article. Anywhere you see those
letters in this article, replace them with your own public IP
addresses. Note also that internally, the two gateway
machines have .1 IP addresses, and that the two networks have
different private IP addresses (192.168.1.x and 192.168.2.x respectively). All the
machines on the private networks have been configured to use the
.1 machine as their default
gateway.The intention is that, from a network point of view, each
network should view the machines on the other network as though
they were directly attached the same router -- albeit a slightly
slow router with an occasional tendency to drop packets.This means that (for example), machine 192.168.1.20 should be able to runping 192.168.2.34and have it work, transparently. &windows; machines should
be able to see the machines on the other network, browse file
shares, and so on, in exactly the same way that they can browse
machines on the local network.And the whole thing has to be secure. This means that
traffic between the two networks has to be encrypted.Creating a VPN between these two networks is a multi-step
process. The stages are as follows:Create a virtual network link between the two
networks, across the Internet. Test it, using tools like
&man.ping.8;, to make sure it works.Apply security policies to ensure that traffic between
the two networks is transparently encrypted and decrypted as
necessary. Test this, using tools like &man.tcpdump.1;, to
ensure that traffic is encrypted.Configure additional software on the FreeBSD gateways,
to allow &windows; machines to see one another across the
VPN.Step 1: Creating and testing a virtual
network linkSuppose that you were logged in to the gateway machine on
network #1 (with public IP address A.B.C.D, private IP address 192.168.1.1), and you ran ping
192.168.2.1, which is the private address of the machine
with IP address W.X.Y.Z. What
needs to happen in order for this to work?The gateway machine needs to know how to reach 192.168.2.1. In other words, it needs
to have a route to 192.168.2.1.Private IP addresses, such as those in the 192.168.x range are not supposed to
appear on the Internet at large. Instead, each packet you
send to 192.168.2.1 will need
to be wrapped up inside another packet. This packet will need
to appear to be from A.B.C.D,
and it will have to be sent to W.X.Y.Z. This process is called
encapsulation.Once this packet arrives at W.X.Y.Z it will need to
unencapsulated, and delivered to 192.168.2.1.You can think of this as requiring a tunnel
between the two networks. The two tunnel mouths are the IP
addresses A.B.C.D and W.X.Y.Z, and the tunnel must be told the
addresses of the private IP addresses that will be allowed to pass
through it. The tunnel is used to transfer traffic with private
IP addresses across the public Internet.This tunnel is created by using the generic interface, or
gif devices on FreeBSD. As you can
imagine, the gif interface on each
gateway host must be configured with four IP addresses; two for
the public IP addresses, and two for the private IP
addresses.Support for the gif device must be compiled in to the
&os; kernel on both machines. You can do this by adding the
line:device gifto the kernel configuration files on both machines, and
then compile, install, and reboot as normal.Configuring the tunnel is a two step process. First the
tunnel must be told what the outside (or public) IP addresses
are, using &man.ifconfig.8;. Then the private IP addresses must be
configured using &man.ifconfig.8;.On the gateway machine on network #1 you would run the
following commands to configure the tunnel.&prompt.root; ifconfig gif0 create
&prompt.root; ifconfig gif0 tunnel A.B.C.DW.X.Y.Z
&prompt.root; ifconfig gif0 inet 192.168.1.1192.168.2.1 netmask 0xffffffffOn the other gateway machine you run the same commands,
but with the order of the IP addresses reversed.&prompt.root; ifconfig gif0 create
&prompt.root; ifconfig gif0 tunnel W.X.Y.ZA.B.C.D
&prompt.root; ifconfig gif0 inet 192.168.2.1192.168.1.1 netmask 0xffffffffYou can then run:ifconfig gif0to see the configuration. For example, on the network #1
gateway, you would see this:&prompt.root; ifconfig gif0
gif0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1280
tunnel inet A.B.C.D --> W.X.Y.Z
inet 192.168.1.1 --> 192.168.2.1 netmask 0xffffffff
As you can see, a tunnel has been created between the
physical addresses A.B.C.D and
W.X.Y.Z, and the traffic allowed
through the tunnel is that between 192.168.1.1 and 192.168.2.1.This will also have added an entry to the routing table
on both machines, which you can examine with the command netstat -rn.
This output is from the gateway host on network #1.&prompt.root; netstat -rn
Routing tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
...
192.168.2.1 192.168.1.1 UH 0 0 gif0
...
As the Flags value indicates, this is a
host route, which means that each gateway knows how to reach the
other gateway, but they do not know how to reach the rest of
their respective networks. That problem will be fixed
shortly.It is likely that you are running a firewall on both
machines. This will need to be circumvented for your VPN
traffic. You might want to allow all traffic between both
networks, or you might want to include firewall rules that
protect both ends of the VPN from one another.It greatly simplifies testing if you configure the
firewall to allow all traffic through the VPN. You can always
tighten things up later. If you are using &man.ipfw.8; on the
gateway machines then a command likeipfw add 1 allow ip from any to any via gif0will allow all traffic between the two end points of the
VPN, without affecting your other firewall rules. Obviously
you will need to run this command on both gateway hosts.This is sufficient to allow each gateway machine to ping
the other. On 192.168.1.1, you
should be able to runping 192.168.2.1and get a response, and you should be able to do the same
thing on the other gateway machine.However, you will not be able to reach internal machines
on either network yet. This is because of the routing --
although the gateway machines know how to reach one another,
they do not know how to reach the network behind each one.To solve this problem you must add a static route on each
gateway machine. The command to do this on the first gateway
would be:route add 192.168.2.0 192.168.2.1 netmask 0xffffff00
This says In order to reach the hosts on the
network 192.168.2.0, send the
packets to the host 192.168.2.1. You will need to
run a similar command on the other gateway, but with the
192.168.1.x addresses
instead.IP traffic from hosts on one network will now be able to
reach hosts on the other network.That has now created two thirds of a VPN between the two
networks, in as much as it is virtual and it is a
network. It is not private yet. You can test
this using &man.ping.8; and &man.tcpdump.1;. Log in to the
gateway host and runtcpdump dst host 192.168.2.1In another log in session on the same host runping 192.168.2.1You will see output that looks something like this:
16:10:24.018080 192.168.1.1 > 192.168.2.1: icmp: echo request
16:10:24.018109 192.168.1.1 > 192.168.2.1: icmp: echo reply
16:10:25.018814 192.168.1.1 > 192.168.2.1: icmp: echo request
16:10:25.018847 192.168.1.1 > 192.168.2.1: icmp: echo reply
16:10:26.028896 192.168.1.1 > 192.168.2.1: icmp: echo request
16:10:26.029112 192.168.1.1 > 192.168.2.1: icmp: echo reply
As you can see, the ICMP messages are going back and forth
unencrypted. If you had used the parameter to
&man.tcpdump.1; to grab more bytes of data from the packets you
would see more information.Obviously this is unacceptable. The next section will
discuss securing the link between the two networks so that
all traffic is automatically encrypted.Summary:Configure both kernels with device gif.Edit /etc/rc.conf on gateway host
#1 and add the following lines (replacing IP addresses as
necessary).gif_interfaces="gif0"
gifconfig_gif0="A.B.C.D W.X.Y.Z"
ifconfig_gif0="inet 192.168.1.1 192.168.2.1 netmask 0xffffffff"
static_routes="vpn"
route_vpn="192.168.2.0 192.168.2.1 netmask 0xffffff00"
Edit your firewall script
(/etc/rc.firewall, or similar) on both
hosts, and addipfw add 1 allow ip from any to any via gif0Make similar changes to
/etc/rc.conf on gateway host #2,
reversing the order of IP addresses.Step 2: Securing the linkTo secure the link we will be using IPsec. IPsec provides
a mechanism for two hosts to agree on an encryption key, and to
then use this key in order to encrypt data between the two
hosts.The are two areas of configuration to be considered here.There must be a mechanism for two hosts to agree on the
encryption mechanism to use. Once two hosts have agreed on
this mechanism there is said to be a security association
between them.There must be a mechanism for specifying which traffic
should be encrypted. Obviously, you do not want to encrypt
all your outgoing traffic -- you only want to encrypt the
traffic that is part of the VPN. The rules that you put in
place to determine what traffic will be encrypted are called
security policies.Security associations and security policies are both
maintained by the kernel, and can be modified by userland
programs. However, before you can do this you must configure the
kernel to support IPsec and the Encapsulated Security Payload
(ESP) protocol. This is done by configuring a kernel with:kernel optionsIPSECoptions IPSEC
options IPSEC_ESP
and recompiling, reinstalling, and rebooting. As before
you will need to do this to the kernels on both of the gateway
hosts.IKEYou have two choices when it comes to setting up security
associations. You can configure them by hand between two hosts,
which entails choosing the encryption algorithm, encryption keys,
and so forth, or you can use daemons that implement the Internet
Key Exchange protocol (IKE) to do this for you.I recommend the latter. Apart from anything else, it is
easier to set up.IPsecsecurity policiessetkeyEditing and displaying security policies is carried out
using &man.setkey.8;. By analogy, setkey is
to the kernel's security policy tables as &man.route.8; is to
the kernel's routing tables. setkey can
also display the current security associations, and to continue
the analogy further, is akin to netstat -r
in that respect.There are a number of choices for daemons to manage
security associations with FreeBSD. This article will describe
how to use one of these, racoon — which is available from
security/ipsec-tools in the &os; Ports
collection.racoonThe racoon software must be run on both gateway hosts. On each host it
is configured with the IP address of the other end of the VPN,
and a secret key (which you choose, and must be the same on both
gateways).The two daemons then contact one another, confirm that they
are who they say they are (by using the secret key that you
configured). The daemons then generate a new secret key, and use
this to encrypt the traffic over the VPN. They periodically
change this secret, so that even if an attacker were to crack one
of the keys (which is as theoretically close to unfeasible as it
gets) it will not do them much good -- by the time they have cracked
the key the two daemons have chosen another one.The configuration file for racoon is stored in
${PREFIX}/etc/racoon. You should find a
configuration file there, which should not need to be changed
too much. The other component of racoon's configuration,
which you will need to change, is the pre-shared
key.The default racoon configuration expects to find this in
the file ${PREFIX}/etc/racoon/psk.txt. It is important to note
that the pre-shared key is not the key that will be used to
encrypt your traffic across the VPN link, it is simply a token
that allows the key management daemons to trust one another.psk.txt contains a line for each
remote site you are dealing with. In this example, where there
are two sites, each psk.txt file will contain one line (because
each end of the VPN is only dealing with one other end).On gateway host #1 this line should look like this:W.X.Y.Z secretThat is, the public IP address of the remote end,
whitespace, and a text string that provides the secret.
Obviously, you should not use secret as your key -- the normal
rules for choosing a password apply.On gateway host #2 the line would look like thisA.B.C.D secretThat is, the public IP address of the remote end, and the
same secret key. psk.txt must be mode
0600 (i.e., only read/write to
root) before racoon will run.You must run racoon on both gateway machines. You will
also need to add some firewall rules to allow the IKE traffic,
which is carried over UDP to the ISAKMP (Internet Security Association
Key Management Protocol) port. Again, this should be fairly early in
your firewall ruleset.ipfw add 1 allow udp from A.B.C.D to W.X.Y.Z isakmp
ipfw add 1 allow udp from W.X.Y.Z to A.B.C.D isakmp
Once racoon is running you can try pinging one gateway host
from the other. The connection is still not encrypted, but
racoon will then set up the security associations between the two
hosts -- this might take a moment, and you may see this as a
short delay before the ping commands start responding.Once the security association has been set up you can
view it using &man.setkey.8;. Runsetkey -Don either host to view the security association information.That's one half of the problem. The other half is setting
your security policies.To create a sensible security policy, let's review what's
been set up so far. This discussions hold for both ends of the
link.Each IP packet that you send out has a header that contains
data about the packet. The header includes the IP addresses of
both the source and destination. As we already know, private IP
addresses, such as the 192.168.x.y
range are not supposed to appear on the public Internet.
Instead, they must first be encapsulated inside another packet.
This packet must have the public source and destination IP
addresses substituted for the private addresses.So if your outgoing packet started looking like this:
.----------------------.
| Src: 192.168.1.1 |
| Dst: 192.168.2.1 |
| <other header info> |
+----------------------+
| <packet data> |
`----------------------'Then it will be encapsulated inside another packet, looking
something like this:
.--------------------------.
| Src: A.B.C.D |
| Dst: W.X.Y.Z |
| <other header info> |
+--------------------------+
| .----------------------. |
| | Src: 192.168.1.1 | |
| | Dst: 192.168.2.1 | |
| | <other header info> | |
| +----------------------+ |
| | <packet data> | |
| `----------------------' |
`--------------------------'This encapsulation is carried out by the
gif device. As
you can see, the packet now has real IP addresses on the outside,
and our original packet has been wrapped up as data inside the
packet that will be put out on the Internet.Obviously, we want all traffic between the VPNs to be
encrypted. You might try putting this in to words, as:If a packet leaves from A.B.C.D, and it is destined for W.X.Y.Z, then encrypt it, using the
necessary security associations.If a packet arrives from W.X.Y.Z, and it is destined for A.B.C.D, then decrypt it, using the
necessary security associations.That's close, but not quite right. If you did this, all
traffic to and from W.X.Y.Z, even
traffic that was not part of the VPN, would be encrypted. That's
not quite what you want. The correct policy is as followsIf a packet leaves from A.B.C.D, and that packet is encapsulating
another packet, and it is destined for W.X.Y.Z, then encrypt it, using the
necessary security associations.If a packet arrives from W.X.Y.Z, and that packet is encapsulating
another packet, and it is destined for A.B.C.D, then decrypt it, using the
necessary security associations.A subtle change, but a necessary one.Security policies are also set using &man.setkey.8;.
&man.setkey.8; features a configuration language for defining the
policy. You can either enter configuration instructions via
stdin, or you can use the option to specify a
filename that contains configuration instructions.The configuration on gateway host #1 (which has the public
IP address A.B.C.D) to force all
outbound traffic to W.X.Y.Z to be
encrypted is:
spdadd A.B.C.D/32 W.X.Y.Z/32 ipencap -P out ipsec esp/tunnel/A.B.C.D-W.X.Y.Z/require;
Put these commands in a file (e.g.
/etc/ipsec.conf) and then run&prompt.root; setkey -f /etc/ipsec.conf tells &man.setkey.8; that we want
to add a rule to the secure policy database. The rest of this
line specifies which packets will match this policy. A.B.C.D/32 and W.X.Y.Z/32 are the IP addresses and
netmasks that identify the network or hosts that this policy will
apply to. In this case, we want it to apply to traffic between
these two hosts. tells the kernel that
this policy should only apply to packets that encapsulate other
packets. says that this policy applies
to outgoing packets, and says that the
packet will be secured.The second line specifies how this packet will be
encrypted. is the protocol that will be
used, while indicates that the packet
will be further encapsulated in an IPsec packet. The repeated
use of A.B.C.D and W.X.Y.Z is used to select the security
association to use, and the final
mandates that packets must be encrypted if they match this
rule.This rule only matches outgoing packets. You will need a
similar rule to match incoming packets.spdadd W.X.Y.Z/32 A.B.C.D/32 ipencap -P in ipsec esp/tunnel/W.X.Y.Z-A.B.C.D/require;Note the instead of
in this case, and the necessary reversal of
the IP addresses.The other gateway host (which has the public IP address
W.X.Y.Z) will need similar rules.spdadd W.X.Y.Z/32 A.B.C.D/32 ipencap -P out ipsec esp/tunnel/W.X.Y.Z-A.B.C.D/require;
spdadd A.B.C.D/32 W.X.Y.Z/32 ipencap -P in ipsec esp/tunnel/A.B.C.D-W.X.Y.Z/require;Finally, you need to add firewall rules to allow ESP and
IPENCAP packets back and forth. These rules will need to be
added to both hosts.ipfw add 1 allow esp from A.B.C.D to W.X.Y.Z
ipfw add 1 allow esp from W.X.Y.Z to A.B.C.D
ipfw add 1 allow ipencap from A.B.C.D to W.X.Y.Z
ipfw add 1 allow ipencap from W.X.Y.Z to A.B.C.D
Because the rules are symmetric you can use the same rules
on each gateway host.Outgoing packets will now look something like this:
.------------------------------. --------------------------.
| Src: A.B.C.D | |
| Dst: W.X.Y.Z | |
| <other header info> | | Encrypted
+------------------------------+ | packet.
| .--------------------------. | -------------. | contents
| | Src: A.B.C.D | | | | are
| | Dst: W.X.Y.Z | | | | completely
| | <other header info> | | | |- secure
| +--------------------------+ | | Encap'd | from third
| | .----------------------. | | -. | packet | party
| | | Src: 192.168.1.1 | | | | Original |- with real | snooping
| | | Dst: 192.168.2.1 | | | | packet, | IP addr |
| | | <other header info> | | | |- private | |
| | +----------------------+ | | | IP addr | |
| | | <packet data> | | | | | |
| | `----------------------' | | -' | |
| `--------------------------' | -------------' |
`------------------------------' --------------------------'
When they are received by the far end of the VPN they will
first be decrypted (using the security associations that have
been negotiated by racoon). Then they will enter the
gif interface, which will unwrap
the second layer, until you are left with the innermost
packet, which can then travel in to the inner network.You can check the security using the same &man.ping.8; test from
earlier. First, log in to the
A.B.C.D gateway machine, and
run:tcpdump dst host 192.168.2.1In another log in session on the same host runping 192.168.2.1This time you should see output like the following:XXX tcpdump outputNow, as you can see, &man.tcpdump.1; shows the ESP packets. If
you try to examine them with the option you will see
(apparently) gibberish, because of the encryption.Congratulations. You have just set up a VPN between two
remote sites.SummaryConfigure both kernels with:options IPSEC
options IPSEC_ESP
Install security/ipsec-tools. Edit
${PREFIX}/etc/racoon/psk.txt on both
gateway hosts, adding an entry for the remote host's IP
address and a secret key that they both know. Make sure
this file is mode 0600.Add the following lines to
/etc/rc.conf on each host:ipsec_enable="YES"
ipsec_file="/etc/ipsec.conf"
Create an /etc/ipsec.conf on each
host that contains the necessary spdadd lines. On gateway
host #1 this would be:
spdadd A.B.C.D/32 W.X.Y.Z/32 ipencap -P out ipsec
esp/tunnel/A.B.C.D-W.X.Y.Z/require;
spdadd W.X.Y.Z/32 A.B.C.D/32 ipencap -P in ipsec
esp/tunnel/W.X.Y.Z-A.B.C.D/require;
On gateway host #2 this would be:
spdadd W.X.Y.Z/32 A.B.C.D/32 ipencap -P out ipsec
esp/tunnel/W.X.Y.Z-A.B.C.D/require;
spdadd A.B.C.D/32 W.X.Y.Z/32 ipencap -P in ipsec
esp/tunnel/A.B.C.D-W.X.Y.Z/require;
Add firewall rules to allow IKE, ESP, and IPENCAP
traffic to both hosts:
ipfw add 1 allow udp from A.B.C.D to W.X.Y.Z isakmp
ipfw add 1 allow udp from W.X.Y.Z to A.B.C.D isakmp
ipfw add 1 allow esp from A.B.C.D to W.X.Y.Z
ipfw add 1 allow esp from W.X.Y.Z to A.B.C.D
ipfw add 1 allow ipencap from A.B.C.D to W.X.Y.Z
ipfw add 1 allow ipencap from W.X.Y.Z to A.B.C.D
The previous two steps should suffice to get the VPN up and
running. Machines on each network will be able to refer to one
another using IP addresses, and all traffic across the link will
be automatically and securely encrypted.ChernLeeContributed by OpenSSHOpenSSHsecurityOpenSSHOpenSSH is a set of network connectivity tools used to
access remote machines securely. It can be used as a direct
replacement for rlogin,
rsh, rcp, and
telnet. Additionally, TCP/IP
connections can be tunneled/forwarded securely through SSH.
OpenSSH encrypts all traffic to effectively eliminate eavesdropping,
connection hijacking, and other network-level attacks.OpenSSH is maintained by the OpenBSD project, and is based
upon SSH v1.2.12 with all the recent bug fixes and updates. It
is compatible with both SSH protocols 1 and 2.Advantages of Using OpenSSHNormally, when using &man.telnet.1; or &man.rlogin.1;,
data is sent over the network in an clear, un-encrypted form.
Network sniffers anywhere in between the client and server can
steal your user/password information or data transferred in
your session. OpenSSH offers a variety of authentication and
encryption methods to prevent this from happening.Enabling sshdOpenSSHenablingThe
sshd is an option presented during
a Standard install of &os;. To see if
sshd is enabled, check the
rc.conf file for:sshd_enable="YES"This will load &man.sshd.8;, the daemon program for OpenSSH,
the next time your system initializes. Alternatively, it is
possible to use /etc/rc.d/sshd &man.rc.8;
script to start OpenSSH:/etc/rc.d/sshd startSSH ClientOpenSSHclientThe &man.ssh.1; utility works similarly to
&man.rlogin.1;.&prompt.root; ssh user@example.com
Host key not found from the list of known hosts.
Are you sure you want to continue connecting (yes/no)? yes
Host 'example.com' added to the list of known hosts.
user@example.com's password: *******The login will continue just as it would have if a session was
created using rlogin or
telnet. SSH utilizes a key fingerprint
system for verifying the authenticity of the server when the
client connects. The user is prompted to enter
yes only when
connecting for the first time. Future attempts to login are all
verified against the saved fingerprint key. The SSH client
will alert you if the saved fingerprint differs from the
received fingerprint on future login attempts. The fingerprints
are saved in ~/.ssh/known_hosts, or
~/.ssh/known_hosts2 for SSH v2
fingerprints.By default, recent versions of the
OpenSSH servers only accept SSH v2
connections. The client will use version 2 if possible and
will fall back to version 1. The client can also be forced to
use one or the other by passing it the or
for version 1 or version 2, respectively.
The version 1 compatibility is maintained in the client for
backwards compatibility with older versions.Secure CopyOpenSSHsecure copyscpThe &man.scp.1; command works similarly to
&man.rcp.1;; it copies a file to or from a remote machine,
except in a secure fashion.&prompt.root; scp user@example.com:/COPYRIGHT COPYRIGHT
user@example.com's password: *******
COPYRIGHT 100% |*****************************| 4735
00:00
&prompt.root;Since the fingerprint was already saved for this host in the
previous example, it is verified when using &man.scp.1;
here.The arguments passed to &man.scp.1; are similar
to &man.cp.1;, with the file or files in the first
argument, and the destination in the second. Since the file is
fetched over the network, through SSH, one or more of the file
arguments takes on the form
.ConfigurationOpenSSHconfigurationThe system-wide configuration files for both the
OpenSSH daemon and client reside
within the /etc/ssh directory.ssh_config configures the client
settings, while sshd_config configures the
daemon.Additionally, the
(/usr/sbin/sshd by default), and
rc.conf
options can provide more levels of configuration.ssh-keygenInstead of using passwords, &man.ssh-keygen.1; can
be used to generate DSA or RSA keys to authenticate a user:&prompt.user; ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa):
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/id_dsa.
Your public key has been saved in /home/user/.ssh/id_dsa.pub.
The key fingerprint is:
bb:48:db:f2:93:57:80:b6:aa:bc:f5:d5:ba:8f:79:17 user@host.example.com
&man.ssh-keygen.1; will create a public and private
key pair for use in authentication. The private key is stored in
~/.ssh/id_dsa or
~/.ssh/id_rsa, whereas the public key is
stored in ~/.ssh/id_dsa.pub or
~/.ssh/id_rsa.pub, respectively for DSA and
RSA key types. The public key must be placed in
~/.ssh/authorized_keys of the remote
machine in order for the setup to work. Similarly, RSA version
1 public keys should be placed in
~/.ssh/authorized_keys.This will allow connection to the remote machine based upon
SSH keys instead of passwords.If a passphrase is used in &man.ssh-keygen.1;, the user
will be prompted for a password each time in order to use the
private key. &man.ssh-agent.1; can alleviate the strain of
repeatedly entering long passphrases, and is explored in the
section below.The various options and files can be different
according to the OpenSSH version
you have on your system; to avoid problems you should consult
the &man.ssh-keygen.1; manual page.ssh-agent and ssh-addThe &man.ssh-agent.1; and &man.ssh-add.1; utilities provide
methods for SSH keys to be loaded
into memory for use, without needing to type the passphrase
each time.The &man.ssh-agent.1; utility will handle the authentication
using the private key(s) that are loaded into it.
&man.ssh-agent.1; should be used to launch another application.
At the most basic level, it could spawn a shell or at a more
advanced level, a window manager.To use &man.ssh-agent.1; in a shell, first it will need to
be spawned with a shell as an argument. Secondly, the
identity needs to be added by running &man.ssh-add.1; and
providing it the passphrase for the private key. Once these
steps have been completed the user will be able to &man.ssh.1;
to any host that has the corresponding public key installed.
For example:&prompt.user; ssh-agent csh
&prompt.user; ssh-add
Enter passphrase for /home/user/.ssh/id_dsa:
Identity added: /home/user/.ssh/id_dsa (/home/user/.ssh/id_dsa)
&prompt.user;To use &man.ssh-agent.1; in X11, a call to
&man.ssh-agent.1; will need to be placed in
~/.xinitrc. This will provide the
&man.ssh-agent.1; services to all programs launched in X11.
An example ~/.xinitrc file might look
like this:exec ssh-agent startxfce4This would launch &man.ssh-agent.1;, which would in turn
launch XFCE, every time X11 starts.
Then once that is done and X11 has been restarted so that the
changes can take effect, simply run &man.ssh-add.1; to load
all of your SSH keys.SSH TunnelingOpenSSHtunnelingOpenSSH has the ability to create a tunnel to encapsulate
another protocol in an encrypted session.The following command tells &man.ssh.1; to create a tunnel
for telnet:&prompt.user; ssh -2 -N -f -L 5023:localhost:23 user@foo.example.com
&prompt.user;The ssh command is used with the
following options:Forces ssh to use version 2 of
the protocol. (Do not use if you are working with older
SSH servers)Indicates no command, or tunnel only. If omitted,
ssh would initiate a normal
session.Forces ssh to run in the
background.Indicates a local tunnel in
localport:remotehost:remoteport
fashion.The remote SSH server.An SSH tunnel works by creating a listen socket on
localhost on the specified port.
It then forwards any connection received
on the local host/port via the SSH connection to the specified
remote host and port.In the example, port 5023 on
localhost is being forwarded to port
23 on localhost
of the remote machine. Since 23 is telnet,
this would create a secure telnet session through an SSH tunnel.This can be used to wrap any number of insecure TCP
protocols such as SMTP, POP3, FTP, etc.Using SSH to Create a Secure Tunnel for SMTP&prompt.user; ssh -2 -N -f -L 5025:localhost:25 user@mailserver.example.com
user@mailserver.example.com's password: *****
&prompt.user; telnet localhost 5025
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 mailserver.example.com ESMTPThis can be used in conjunction with an
&man.ssh-keygen.1; and additional user accounts to create a
more seamless/hassle-free SSH tunneling environment. Keys
can be used in place of typing a password, and the tunnels
can be run as a separate user.Practical SSH Tunneling ExamplesSecure Access of a POP3 ServerAt work, there is an SSH server that accepts
connections from the outside. On the same office network
resides a mail server running a POP3 server. The network,
or network path between your home and office may or may not
be completely trustable. Because of this, you need to check
your e-mail in a secure manner. The solution is to create
an SSH connection to your office's SSH server, and tunnel
through to the mail server.&prompt.user; ssh -2 -N -f -L 2110:mail.example.com:110 user@ssh-server.example.com
user@ssh-server.example.com's password: ******When the tunnel is up and running, you can point your
mail client to send POP3 requests to localhost
port 2110. A connection here will be forwarded securely across
the tunnel to mail.example.com.Bypassing a Draconian FirewallSome network administrators impose extremely draconian
firewall rules, filtering not only incoming connections,
but outgoing connections. You may be only given access
to contact remote machines on ports 22 and 80 for SSH
and web surfing.You may wish to access another (perhaps non-work
related) service, such as an Ogg Vorbis server to stream
music. If this Ogg Vorbis server is streaming on some other
port than 22 or 80, you will not be able to access it.The solution is to create an SSH connection to a machine
outside of your network's firewall, and use it to tunnel to
the Ogg Vorbis server.&prompt.user; ssh -2 -N -f -L 8888:music.example.com:8000 user@unfirewalled-system.example.org
user@unfirewalled-system.example.org's password: *******Your streaming client can now be pointed to
localhost port 8888, which will be
forwarded over to music.example.com port
8000, successfully evading the firewall.The AllowUsers Users OptionIt is often a good idea to limit which users can log in and
from where. The AllowUsers option is a good
way to accomplish this. For example, to only allow the
root user to log in from
192.168.1.32, something like this
would be appropriate in the
/etc/ssh/sshd_config file:AllowUsers root@192.168.1.32To allow the user admin to log in from
anywhere, just list the username by itself:AllowUsers adminMultiple users should be listed on the same line, like so:AllowUsers root@192.168.1.32 adminIt is important that you list each user that needs to
log in to this machine; otherwise they will be locked out.After making changes to
/etc/ssh/sshd_config you must tell
&man.sshd.8; to reload its config files, by running:&prompt.root; /etc/rc.d/sshd reloadFurther ReadingOpenSSH&man.ssh.1; &man.scp.1; &man.ssh-keygen.1;
&man.ssh-agent.1; &man.ssh-add.1; &man.ssh.config.5;&man.sshd.8; &man.sftp-server.8; &man.sshd.config.5;TomRhodesContributed by ACLFile System Access Control ListsIn conjunction with file system enhancements like snapshots, FreeBSD 5.0
and later offers the security of File System Access Control Lists
(ACLs).Access Control Lists extend the standard &unix;
permission model in a highly compatible (&posix;.1e) way. This feature
permits an administrator to make use of and take advantage of a
more sophisticated security model.To enable ACL support for UFS
file systems, the following:options UFS_ACLmust be compiled into the kernel. If this option has
not been compiled in, a warning message will be displayed
when attempting to mount a file system supporting ACLs.
This option is included in the GENERIC kernel.
ACLs rely on extended attributes being enabled on
the file system. Extended attributes are natively supported in the next generation
&unix; file system, UFS2.A higher level of administrative overhead is required to
configure extended attributes on UFS1 than on
UFS2. The performance of extended attributes
on UFS2 is also substantially higher. As a
result, UFS2 is generally recommended in preference
to UFS1 for use with access control lists.ACLs are enabled by the mount-time administrative
flag, , which may be added to /etc/fstab.
The mount-time flag can also be automatically set in a persistent manner using
&man.tunefs.8; to modify a superblock ACLs flag in the
file system header. In general, it is preferred to use the superblock flag
for several reasons:The mount-time ACLs flag cannot be changed by a
remount (&man.mount.8; ), only by means of a complete
&man.umount.8; and fresh &man.mount.8;. This means that
ACLs cannot be enabled on the root file system after boot.
It also means that you cannot change the disposition of a file system once
it is in use.Setting the superblock flag will cause the file system to always be
mounted with ACLs enabled even if there is not an
fstab entry or if the devices re-order. This prevents
accidental mounting of the file system without ACLs
enabled, which can result in ACLs being improperly enforced,
and hence security problems.We may change the ACLs behavior to allow the flag to
be enabled without a complete fresh &man.mount.8;, but we consider it desirable to
discourage accidental mounting without ACLs enabled, because you
can shoot your feet quite nastily if you enable ACLs, then disable
them, then re-enable them without flushing the extended attributes. In general, once
you have enabled ACLs on a file system, they should not be disabled,
as the resulting file protections may not be compatible with those intended by the
users of the system, and re-enabling ACLs may re-attach the previous
ACLs to files that have since had their permissions changed,
resulting in other unpredictable behavior.File systems with ACLs enabled will show a +
(plus) sign in their permission settings when viewed. For example:drwx------ 2 robert robert 512 Dec 27 11:54 private
drwxrwx---+ 2 robert robert 512 Dec 23 10:57 directory1
drwxrwx---+ 2 robert robert 512 Dec 22 10:20 directory2
drwxrwx---+ 2 robert robert 512 Dec 27 11:57 directory3
drwxr-xr-x 2 robert robert 512 Nov 10 11:54 public_htmlHere we see that the directory1,
directory2, and directory3
directories are all taking advantage of ACLs. The
public_html directory is not.Making Use of ACLsThe file system ACLs can be viewed by the
&man.getfacl.1; utility. For instance, to view the
ACL settings on the test
file, one would use the command:&prompt.user; getfacl test
#file:test
#owner:1001
#group:1001
user::rw-
group::r--
other::r--To change the ACL settings on this file,
invoke the &man.setfacl.1; utility. Observe:&prompt.user; setfacl -k testThe flag will remove all of the
currently defined ACLs from a file or file
system. The more preferable method would be to use
as it leaves the basic fields required for
ACLs to work.&prompt.user; setfacl -m u:trhodes:rwx,group:web:r--,o::--- testIn the aforementioned command, the
option was used to modify the default ACL
entries. Since there were no pre-defined entries, as they were
removed by the previous command, this will restore the default
options and assign the options listed. Take care to notice that
if you add a user or group which does not exist on the system,
an Invalid argument error will be printed
to stdout.TomRhodesContributed by PortauditMonitoring Third Party Security IssuesIn recent years, the security world has made many improvements
to how vulnerability assessment is handled. The threat of system
intrusion increases as third party utilities are installed and
configured for virtually any operating system available
today.Vulnerability assessment is a key factor in security, and
while &os; releases advisories for the base system, doing so
for every third party utility is beyond the &os; Project's
capability. There is a way to mitigate third party
vulnerabilities and warn administrators of known security
issues. A &os; add on utility known as
Portaudit exists solely for this
purpose.
- The security/portaudit port
+ The ports-mgmt/portaudit port
polls a database, updated and maintained by the &os; Security
Team and ports developers, for known security issues.To begin using Portaudit, one
must install it from the Ports Collection:
- &prompt.root; cd /usr/ports/security/portaudit && make install clean
+ &prompt.root; cd /usr/ports/ports-mgmt/portaudit && make install cleanDuring the install process, the configuration files for
&man.periodic.8; will be updated, permitting
Portaudit output in the daily security
runs. Ensure the daily security run emails, which are sent to
root's email account, are being read. No
more configuration will be required here.After installation, an administrator can update the database
and view known vulnerabilities in installed packages by invoking
the following command:&prompt.root; portaudit -FdaThe database will automatically be updated during the
&man.periodic.8; run; thus, the previous command is completely
optional. It is only required for the following
examples.To audit the third party utilities installed as part of
the Ports Collection at anytime, an administrator need only run
the following command:&prompt.root; portaudit -aPortaudit will produce something
like this for vulnerable packages:Affected package: cups-base-1.1.22.0_1
Type of problem: cups-base -- HPGL buffer overflow vulnerability.
Reference: <http://www.FreeBSD.org/ports/portaudit/40a3bca2-6809-11d9-a9e7-0001020eed82.html>
1 problem(s) in your installed packages found.
You are advised to update or deinstall the affected package(s) immediately.By pointing a web browser to the URL shown,
an administrator may obtain more information about the
vulnerability in question. This will include versions affected,
by &os; Port version, along with other web sites which may contain
security advisories.In short, Portaudit is a powerful
utility and extremely useful when coupled with the
Portupgrade port.TomRhodesContributed by FreeBSD Security Advisories&os; Security AdvisoriesLike many production quality operating systems, &os; publishes
Security Advisories. These advisories are usually
mailed to the security lists and noted in the Errata only
after the appropriate releases have been patched. This section
will work to explain what an advisory is, how to understand it,
and what measures to take in order to patch a system.What does an advisory look like?The &os; security advisories look similar to the one below,
taken from the &a.security-notifications.name; mailing list.=============================================================================
&os;-SA-XX:XX.UTIL Security Advisory
The &os; Project
Topic: denial of service due to some problem
Category: core
Module: sys
Announced: 2003-09-23
Credits: Person@EMAIL-ADDRESS
Affects: All releases of &os;
&os; 4-STABLE prior to the correction date
Corrected: 2003-09-23 16:42:59 UTC (RELENG_4, 4.9-PRERELEASE)
2003-09-23 20:08:42 UTC (RELENG_5_1, 5.1-RELEASE-p6)
2003-09-23 20:07:06 UTC (RELENG_5_0, 5.0-RELEASE-p15)
2003-09-23 16:44:58 UTC (RELENG_4_8, 4.8-RELEASE-p8)
2003-09-23 16:47:34 UTC (RELENG_4_7, 4.7-RELEASE-p18)
2003-09-23 16:49:46 UTC (RELENG_4_6, 4.6-RELEASE-p21)
2003-09-23 16:51:24 UTC (RELENG_4_5, 4.5-RELEASE-p33)
2003-09-23 16:52:45 UTC (RELENG_4_4, 4.4-RELEASE-p43)
2003-09-23 16:54:39 UTC (RELENG_4_3, 4.3-RELEASE-p39)
CVE Name: CVE-XXXX-XXXX
For general information regarding FreeBSD Security Advisories,
including descriptions of the fields above, security branches, and the
following sections, please visit
http://www.FreeBSD.org/security/.
I. Background
II. Problem Description
III. Impact
IV. Workaround
V. Solution
VI. Correction details
VII. ReferencesThe Topic field indicates exactly what the problem is.
It is basically an introduction to the current security
advisory and notes the utility with the
vulnerability.The Category refers to the affected part of the system
which may be one of core, contrib, or ports. The core
category means that the vulnerability affects a core
component of the &os; operating system. The contrib
category means that the vulnerability affects software
contributed to the &os; Project, such as
sendmail. Finally the ports
category indicates that the vulnerability affects add on
software available as part of the Ports Collection.The Module field refers to the component location, for
instance sys. In this example, we see that the module,
sys, is affected; therefore, this vulnerability
affects a component used within the kernel.The Announced field reflects the date said security
advisory was published, or announced to the world. This
means that the security team has verified that the problem
does exist and that a patch has been committed to the &os;
source code repository.The Credits field gives credit to the individual or
organization who noticed the vulnerability and reported
it.The Affects field explains which releases of &os; are
affected by this vulnerability. For the kernel, a quick
look over the output from ident on the
affected files will help in determining the revision.
For ports, the version number is listed after the port name
in /var/db/pkg. If the system does not
sync with the &os; CVS repository and rebuild
daily, chances are that it is affected.The Corrected field indicates the date, time, time
offset, and release that was corrected.Reserved for the identification information used to look up
vulnerabilities in the Common Vulnerabilities Database system.The Background field gives information on exactly what
the affected utility is. Most of the time this is why
the utility exists in &os;, what it is used for, and a bit
of information on how the utility came to be.The Problem Description field explains the security hole
in depth. This can include information on flawed code, or
even how the utility could be maliciously used to open
a security hole.The Impact field describes what type of impact the
problem could have on a system. For example, this could
be anything from a denial of service attack, to extra
privileges available to users, or even giving the attacker
superuser access.The Workaround field offers a feasible workaround to
system administrators who may be incapable of upgrading
the system. This may be due to time constraints, network
availability, or a slew of other reasons. Regardless,
security should not be taken lightly, and an affected system
should either be patched or the security hole workaround
should be implemented.The Solution field offers instructions on patching the
affected system. This is a step by step tested and verified
method for getting a system patched and working
securely.The Correction Details field displays the
CVS branch or release name with the
periods changed to underscore characters. It also shows
the revision number of the affected files within each
branch.The References field usually offers sources of other
information. This can include web URLs,
books, mailing lists, and newsgroups.TomRhodesContributed by Process AccountingProcess AccountingProcess accounting is a security method in which an
administrator may keep track of system resources used,
their allocation among users, provide for system monitoring,
and minimally track a user's commands.This indeed has its own positive and negative points. One of
the positives is that an intrusion may be narrowed down
to the point of entry. A negative is the amount of logs
generated by process accounting, and the disk space they may
require. This section will walk an administrator through
the basics of process accounting.Enable and Utilizing Process AccountingBefore making use of process accounting, it
must be enabled. To do this, execute the following
commands:&prompt.root; touch /var/account/acct
&prompt.root; accton /var/account/acct
&prompt.root; echo 'accounting_enable="YES"' >> /etc/rc.confOnce enabled, accounting will begin to track
CPU stats, commands, etc. All accounting
logs are in a non-human readable format and may be viewed
using the &man.sa.8; utility. If issued without any options,
sa will print information relating to the
number of per user calls, the total elapsed time in minutes,
total CPU and user time in minutes, average
number of I/O operations, etc.To view information about commands being issued, one
would use the &man.lastcomm.1; utility. The
lastcomm may be used to print out commands
issued by users on specific &man.ttys.5;, for example:&prompt.root; lastcomm ls
trhodes ttyp1Would print out all known usage of the ls
by trhodes on the ttyp1 terminal.Many other useful options exist and are explained in the
&man.lastcomm.1;, &man.acct.5; and &man.sa.8; manual
pages.
Index: head/en_US.ISO8859-1/books/porters-handbook/book.sgml
===================================================================
--- head/en_US.ISO8859-1/books/porters-handbook/book.sgml (revision 29515)
+++ head/en_US.ISO8859-1/books/porters-handbook/book.sgml (revision 29516)
@@ -1,11824 +1,11824 @@
%books.ent;
]>
FreeBSD Porter's HandbookThe FreeBSD Documentation ProjectApril 200020002001200220032004200520062007The FreeBSD Documentation
Project
&bookinfo.trademarks;
&bookinfo.legalnotice;
IntroductionThe FreeBSD ports collection is the way almost everyone
installs applications ("ports") on FreeBSD. Like everything
else about FreeBSD, it is primarily a volunteer effort.
It is important to keep this in mind when reading this
document.In FreeBSD, anyone may submit a new port, or volunteer
to maintain an existing port if it is unmaintained—you
do not need any special commit privileges to do so.Making a port yourselfSo, you are interested in making your own port or
upgrading an existing one? Great!What follows are some guidelines for creating a new port for
FreeBSD. If you want to upgrade an existing port, you should
read this and then read .When this document is not sufficiently detailed, you should
refer to /usr/ports/Mk/bsd.port.mk, which
all port Makefiles include. Even if you do not hack Makefiles
daily, it is well commented, and you will still gain much
knowledge from it. Additionally, you may send specific questions
to the &a.ports;.Only a fraction of the variables
(VAR) that can be
overridden are mentioned in this document. Most (if not all)
are documented at the start of /usr/ports/Mk/bsd.port.mk;
the others probably ought to be.
Note that this file uses a non-standard tab setting:
Emacs and
Vim should recognize the setting on
loading the file. Both &man.vi.1; and
&man.ex.1; can be set to use the correct value by
typing :set tabstop=4 once the file has been
loaded.Quick PortingThis section tells you how to do a quick port. In many cases, it
is not sufficient, so you will have to read further on into
the document.First, get the original tarball and put it into
DISTDIR, which defaults to
/usr/ports/distfiles.The following assumes that the software compiled out-of-the-box,
i.e., there was absolutely no change required for the port to work
on your FreeBSD box. If you needed to change something, you will
have to refer to the next section too.Writing the MakefileThe minimal Makefile would look something
like this:# New ports collection makefile for: oneko
# Date created: 5 December 1994
# Whom: asami
#
# $FreeBSD$
#
PORTNAME= oneko
PORTVERSION= 1.1b
CATEGORIES= games
MASTER_SITES= ftp://ftp.cs.columbia.edu/archives/X11R5/contrib/
MAINTAINER= asami@FreeBSD.org
COMMENT= A cat chasing a mouse all over the screen
MAN1= oneko.1
MANCOMPRESSED= yes
USE_IMAKE= yes
.include <bsd.port.mk>See if you can figure it out. Do not worry about the contents
of the $FreeBSD$ line, it will be
filled in automatically by CVS when the port is imported to our main
ports tree. You can find a more detailed example in the sample Makefile section.Writing the description filesThere are two description files that are required for
any port, whether they actually package or not. They are
pkg-descr and
pkg-plist. Their
pkg- prefix distinguishes them from
other files.pkg-descrThis is a longer description of the port. One to a few
paragraphs concisely explaining what the port does is
sufficient.This is not a manual or an in-depth
description on how to use or compile the port! Please
be careful if you are copying from the
README or manpage; too often
they are not a concise description of the port or are in an
awkward format (e.g., manpages have justified spacing). If the
ported software has an official WWW homepage, you should list it
here. Prefix one of the websites with
WWW: so that automated tools will work
correctly.The following example shows how your
pkg-descr should look:This is a port of oneko, in which a cat chases a poor mouse all over
the screen.
:
(etc.)
WWW: http://www.oneko.org/pkg-plistThis file lists all the files installed by the port. It is
also called the packing list because the package is
generated by packing the files listed here. The pathnames are
relative to the installation prefix (usually
/usr/local or
/usr/X11R6). If you are using the
MANn variables (as
you should be), do not list any manpages here. If the port creates
directories during installation, make sure to add
@dirrm lines to remove them when the package is
deleted.Here is a small example:bin/oneko
lib/X11/app-defaults/Oneko
lib/X11/oneko/cat1.xpm
lib/X11/oneko/cat2.xpm
lib/X11/oneko/mouse.xpm
@dirrm lib/X11/onekoRefer to the &man.pkg.create.1; manual page for details on the
packing list.It is recommended that you keep all the filenames in this
file sorted alphabetically. It will make verifying the changes
when you upgrade the port much easier.Creating a packing list manually can be a very tedious
task. If the port installs a large numbers of files, creating the packing list
automatically might save time.There is only one case when pkg-plist
can be omitted from a port. If the port installs just a handful
of files, and perhaps directories, the files and directories may
be listed in the variables PLIST_FILES and
PLIST_DIRS, respectively, within the port's
Makefile. For instance, we could get along
without pkg-plist in the above
oneko port by adding the
following lines to the Makefile:PLIST_FILES= bin/oneko \
lib/X11/app-defaults/Oneko \
lib/X11/oneko/cat1.xpm \
lib/X11/oneko/cat2.xpm \
lib/X11/oneko/mouse.xpm
PLIST_DIRS= lib/X11/onekoOf course, PLIST_DIRS should be left
unset if a port installs no directories of its own.The price for this way of listing port's files and
directories is that you cannot use command sequences
described in &man.pkg.create.1;. Therefore, it is suitable
only for simple ports and makes them even simpler. At the
same time, it has the advantage of reducing the number of files
in the ports collection. Please consider using this technique
before you resort to pkg-plist.Later we will see how pkg-plist
and PLIST_FILES can be used to fulfil
more sophisticated
tasks.Creating the checksum fileJust type make makesum. The ports make rules
will automatically generate the file
distinfo.If a file fetched has its checksum changed regularly and you are
certain the source is trusted (i.e. it comes from manufacturer CDs
or documentation generated daily), you should specify these files in
the IGNOREFILES variable.
Then the checksum is not calculated for that file when you run
make makesum, but set to
IGNORE.Testing the portYou should make sure that the port rules do exactly what you
want them to do, including packaging up the port. These are the
important points you need to verify.pkg-plist does not contain anything not
installed by your portpkg-plist contains everything that is
installed by your portYour port can be installed multiple times using the
reinstall targetYour port cleans up
after itself upon deinstallRecommended test orderingmake installmake packagemake deinstallpkg_add package-namemake deinstallmake reinstallmake packageMake sure that there are not any warnings issued in any of the
package and
deinstall stages. After step 3, check to
see if all the new directories are correctly deleted. Also, try
using the software after step 4, to ensure that it works correctly
when installed from a package.Checking your port with portlintPlease use portlint to see if your port
- conforms to our guidelines. The devel/portlint
+ conforms to our guidelines. The ports-mgmt/portlint
program is part of the ports collection.
In particular, you may want to check if the
Makefile is in the right
shape and the package is named
appropriately.Submitting the portFirst, make sure you have read the DOs and DON'Ts section.Now that you are happy with your port, the only thing remaining
is to put it in the main FreeBSD ports tree and make everybody else
happy about it too. We do not need your work
directory or the pkgname.tgz package, so delete
them now. Next, simply include the output of shar `find
port_dir` in a bug report and send it with the
&man.send-pr.1; program (see Bug
Reports and General Commentary for more information about
&man.send-pr.1;). Be sure to classify the bug report as category
ports and class
change-request (Do not mark the report
confidential!).
Also add a short description of the program you ported
to the Description field of the PR and
the shar to the Fix field.You can make our work a lot easier, if you use a good
description in the synopsis of the problem report.
We prefer something like
New port: <category>/<portname>
<short description of the port> for new ports and
Update port: <category>/<portname>
<short description of the update> for port updates.
If you stick to this scheme, the chance that someone will take a
look at your PR soon is much better.One more time, do not include the original source
distfile, the work directory, or the package
you built with make package.After you have submitted your port, please be patient.
Sometimes it can take a few months before a port is included
in FreeBSD, although it might only take a few days. You can
view the list of ports
waiting to be committed to FreeBSD.Once we have looked at your port, we will get back to you if necessary, and put
it in the tree. Your name will also appear in the list of
Additional FreeBSD Contributors
and other files. Isn't that great?!? :-)Slow PortingOk, so it was not that simple, and the port required some
modifications to get it to work. In this section, we will explain,
step by step, how to modify it to get it to work with the ports
paradigm.How things workFirst, this is the sequence of events which occurs when the user
first types make in your port's directory.
You may find that having bsd.port.mk in another
window while you read this really helps to understand it.But do not worry if you do not really understand what
bsd.port.mk is doing, not many people do...
:->The fetch target is run. The
fetch target is responsible for making
sure that the tarball exists locally in
DISTDIR. If fetch
cannot find the required files in DISTDIR it
will look up the URL MASTER_SITES, which is
set in the Makefile, as well as our main FTP site at ,
where we put sanctioned distfiles as backup. It will then
attempt to fetch the named distribution file with
FETCH, assuming that the requesting site has
direct access to the Internet. If that succeeds, it will save
the file in DISTDIR for future use and
proceed.The extract target is run. It
looks for your port's distribution file (typically a gzip'd
tarball) in DISTDIR and unpacks it into a
temporary subdirectory specified by WRKDIR
(defaults to work).The patch target is run. First,
any patches defined in PATCHFILES are
applied. Second, if any patch files named
patch-* are found in
PATCHDIR (defaults to the
files subdirectory), they are applied at
this time in alphabetical order.The configure target is run. This
can do any one of many different things.If it exists, scripts/configure is
run.If HAS_CONFIGURE or
GNU_CONFIGURE is set,
WRKSRC/configure is
run.If USE_IMAKE is set,
XMKMF (default: xmkmf
-a) is run.The build target is run. This is
responsible for descending into the port's private working
directory (WRKSRC) and building it. If
USE_GMAKE is set, GNU make
will be used, otherwise the system make will
be used.The above are the default actions. In addition, you can define
targets
pre-something or
post-something,
or put scripts with those names, in the scripts
subdirectory, and they will be run before or after the default
actions are done.For example, if you have a post-extract
target defined in your Makefile, and a file
pre-build in the scripts
subdirectory, the post-extract target will
be called after the regular extraction actions, and the
pre-build script will be executed before the
default build rules are done. It is recommended that you use
Makefile targets if the actions are simple
enough, because it will be easier for someone to figure out what
kind of non-default action the port requires.The default actions are done by the
bsd.port.mk targets
do-something.
For example, the commands to extract a port are in the target
do-extract. If you are not happy with the
default target, you can fix it by redefining the
do-something
target in your Makefile.The main targets (e.g.,
extract,
configure, etc.) do nothing more than
make sure all the stages up to that one are completed and call
the real targets or scripts, and they are not intended to be
changed. If you want to fix the extraction, fix
do-extract, but never ever change
the way extract operates!Now that you understand what goes on when the user types
make, let us go through the recommended steps to
create the perfect port.Getting the original sourcesGet the original sources (normally) as a compressed tarball
(foo.tar.gz or
foo.tar.Z) and copy
it into DISTDIR. Always use
mainstream sources when and where you
can.You will need to set the variable MASTER_SITES
to reflect where the original tarball resides. You will find
convenient shorthand definitions for most mainstream sites
in bsd.sites.mk. Please use these
sites—and the associated definitions—if
at all possible, to help avoid the problem of having the same
information repeated over again many times in the source base.
As these sites tend to change over time, this becomes a
maintenance nightmare for everyone involved.If you cannot find a FTP/HTTP site that is well-connected to the
net, or can only find sites that have irritatingly non-standard
formats, you might want to put a copy on a reliable FTP or HTTP
server that you control (e.g., your home page).If you cannot find somewhere convenient and reliable to put the
distfile
we can house it ourselves
on ftp.FreeBSD.org; however, this is the
least-preferred solution.
The distfile must be placed into
~/public_distfiles/ of someone's
freefall account.
Ask the person who commits your port to do this.
This person will also set MASTER_SITES to
MASTER_SITE_LOCAL and
MASTER_SITE_SUBDIR to their
freefall username.If your port's distfile changes all the time without any
kind of version update by the author,
consider putting the distfile on your home page and listing it as
the first MASTER_SITES. If you can, try
to talk the port author out of doing this; it
really does help to establish some kind of source code control.
Hosting your own version will prevent users
from getting checksum mismatch errors, and
also reduce the workload of maintainers of our FTP site. Also, if
there is only one master site for the port, it is recommended that
you house a backup at your site and list it as the second
MASTER_SITES.If your port requires some additional `patches' that are
available on the Internet, fetch them too and put them in
DISTDIR. Do not worry if they come from a site
other than where you got the main source tarball, we have a way to
handle these situations (see the description of PATCHFILES below).Modifying the portUnpack a copy of the tarball in a private directory and make
whatever changes are necessary to get the port to compile properly
under the current version of FreeBSD. Keep careful
track of everything you do, as you will be automating
the process shortly. Everything, including the deletion, addition,
or modification of files should be doable using an automated script
or patch file when your port is finished.If your port requires significant user interaction/customization
to compile or install, you should take a look at one of Larry Wall's
classic Configure scripts and perhaps do
something similar yourself. The goal of the new ports collection is
to make each port as plug-and-play as possible for the
end-user while using a minimum of disk space.Unless explicitly stated, patch files, scripts, and other
files you have created and contributed to the FreeBSD ports
collection are assumed to be covered by the standard BSD copyright
conditions.PatchingIn the preparation of the port, files that have been added or
changed can be picked up with a &man.diff.1;
for later feeding to &man.patch.1;. Each patch you
wish to apply should be saved into a file named
patch-* where
* indicates
the pathname of the file that is patched,
such as patch-Imakefile or
patch-src-config.h. These files should
be stored in PATCHDIR
(usually files/, from where they will be
automatically applied. All patches must be relative to
WRKSRC (generally the directory your port's
tarball unpacks itself into, that being where the build is done).
To make fixes and upgrades easier, you should avoid having more than
one patch fix the same file (e.g., patch-file and
patch-file2 both changing
WRKSRC/foobar.c).Please only use characters [-+._a-zA-Z0-9] for
naming your patches. Do not use any other characters besides them.
Do not name your patches like patch-aa or
patch-ab etc, always mention path and file name
in patch names.Do not put RCS strings in patches. CVS will mangle them when we
put the files into the ports tree, and when we check them out again,
they will come out different and the patch will fail. RCS strings
are surrounded by dollar ($) signs, and
typically start with $Id or
$RCS.Using the recurse () option to
&man.diff.1; to generate patches is fine, but please take
a look at the resulting patches to make sure you do not have any
unnecessary junk in there. In particular, diffs between two backup
files, Makefiles when the port uses
Imake or GNU configure, etc.,
are unnecessary and should be deleted. If you had to edit
configure.in and run
autoconf to regenerate
configure, do not take the diffs of
configure (it often grows to a few thousand
lines!); define USE_AUTOTOOLS=autoconf:253 and take the
diffs of configure.in.If you had to delete a file, then you can do it in the
post-extract target rather than as part of
the patch.Simple replacements can be performed directly from the port
Makefile using the in-place mode of
&man.sed.1;. This is very useful when you need to patch in
a variable value. Example:post-patch:
@${REINPLACE_CMD} -e 's|for Linux|for FreeBSD|g' ${WRKSRC}/README
@${REINPLACE_CMD} -e 's|-pthread|${PTHREAD_LIBS}|' ${WRKSRC}/configureQuite often, there is a situation when the software being
ported, especially if it is primarily developed on &windows;, uses
the CR/LF convention for most of its source files. This may cause
problems with further patching, compiler warnings, scripts
execution (/bin/sh^M not found), etc. To
quickly convert all files from CR/LF to just LF, add
USE_DOS2UNIX=yes to the port
Makefile. A list of files to convert can
be specified:USE_DOS2UNIX= util.c util.hIf you want to convert a group of files across subdirectories,
DOS2UNIX_REGEX can be used. It's argument is
a find compatible regular expression. More on
the format is in &man.re.format.7;. This option is useful for
converting all files of a given extension, for example all source
code files leaving binary files intact:USE_DOS2UNIX= yes
DOS2UNIX_REGEX= .*\.(c|cpp|h)ConfiguringInclude any additional customization commands in your
configure script and save it in the
scripts subdirectory. As mentioned above, you
can also do this with Makefile targets and/or
scripts with the name pre-configure or
post-configure.Handling user inputIf your port requires user input to build, configure, or install,
you must set IS_INTERACTIVE in your Makefile. This
will allow overnight builds to skip your port if the
user sets the variable BATCH in his environment (and
if the user sets the variable INTERACTIVE, then
only those ports requiring interaction are
built). This will save a lot of wasted time on the set of
machines that continually build ports (see below).It is also recommended that if there are reasonable default
answers to the questions, you check the
PACKAGE_BUILDING variable and turn off the
interactive script when it is set. This will allow us to build the
packages for CDROMs and FTP.Configuring the MakefileConfiguring the Makefile is pretty simple, and again we suggest
that you look at existing examples before starting. Also, there is a
sample Makefile in this
handbook, so take a look and please follow the ordering of variables
and sections in that template to make your port easier for others to
read.Now, consider the following problems in sequence as you design
your new Makefile:The original sourceDoes it live in DISTDIR as a standard
gzip'd tarball named something like
foozolix-1.2.tar.gz? If so, you can go on
to the next step. If not, you should look at overriding any of
the DISTVERSION, DISTNAME,
EXTRACT_CMD,
EXTRACT_BEFORE_ARGS,
EXTRACT_AFTER_ARGS,
EXTRACT_SUFX, or DISTFILES
variables, depending on how alien a format your port's
distribution file is. (The most common case is
EXTRACT_SUFX=.tar.Z, when the tarball is
condensed by regular compress, not
gzip.)In the worst case, you can simply create your own
do-extract target to override the
default, though this should be rarely, if ever,
necessary.NamingThe first part of the port's Makefile names
the port, describes its version number, and lists it in the correct
category.PORTNAME and PORTVERSIONYou should set PORTNAME to the
base name of your port, and PORTVERSION
to the version number of the port.PORTREVISION and
PORTEPOCHPORTREVISIONThe PORTREVISION variable is a
monotonically increasing value which is reset to 0 with
every increase of PORTVERSION (i.e.
every time a new official vendor release is made), and
appended to the package name if non-zero.
Changes to PORTREVISION are
used by automated tools (e.g. &man.pkg.version.1;)
to highlight the fact that a new package is
available.PORTREVISION should be increased
each time a change is made to the port which significantly
affects the content or structure of the derived
package.Examples of when PORTREVISION
should be bumped:Addition of patches to correct security
vulnerabilities, bugs, or to add new functionality to
the port.Changes to the port Makefile to enable or disable
compile-time options in the package.Changes in the packing list or the install-time
behavior of the package (e.g. change to a script
which generates initial data for the package, like ssh
host keys).Version bump of a port's shared library dependency
(in this case, someone trying to install the old
package after installing a newer version of the
dependency will fail since it will look for the old
libfoo.x instead of libfoo.(x+1)).Silent changes to the port distfile which have
significant functional differences, i.e. changes to
the distfile requiring a correction to
distinfo with no corresponding change to
PORTVERSION, where a diff
-ru of the old and new versions shows
non-trivial changes to the code.Examples of changes which do not require a
PORTREVISION bump:Style changes to the port skeleton with no
functional change to what appears in the resulting
package.Changes to MASTER_SITES or
other functional changes to the port which do not
affect the resulting package.Trivial patches to the distfile such as correction
of typos, which are not important enough that users of
the package should go to the trouble of
upgrading.Build fixes which cause a package to become
compilable where it was previously failing (as long as
the changes do not introduce any functional change on
any other platforms on which the port did previously
build). Since PORTREVISION reflects
the content of the package, if the package was not
previously buildable then there is no need to increase
PORTREVISION to mark a
change.A rule of thumb is to ask yourself whether a change
committed to a port is something which everyone
would benefit from having (either because of an
enhancement, fix, or by virtue that the new package will
actually work at all), and weigh that against that fact
that it will cause everyone who regularly updates their
ports tree to be compelled to update. If yes, the
PORTREVISION should be bumped.PORTEPOCHFrom time to time a software vendor or FreeBSD porter
will do something silly and release a version of their
software which is actually numerically less than the
previous version. An example of this is a port which goes
from foo-20000801 to foo-1.0 (the former will be
incorrectly treated as a newer version since 20000801 is a
numerically greater value than 1).In situations such as this, the
PORTEPOCH version should be increased.
If PORTEPOCH is nonzero it is appended
to the package name as described in section 0 above.
PORTEPOCH must never be decreased or reset
to zero, because that would cause comparison to a package
from an earlier epoch to fail (i.e. the package would not
be detected as out of date): the new version number (e.g.
1.0,1 in the above example) is still
numerically less than the previous version (20000801), but
the ,1 suffix is treated specially by
automated tools and found to be greater than the implied
suffix ,0 on the earlier package.Dropping or resetting PORTEPOCH
incorrectly leads
to no end of grief; if you do not understand the above discussion,
please keep after it until you do, or ask questions on
the mailing lists.It is expected that PORTEPOCH will
not be used for the majority of ports, and that sensible
use of PORTVERSION can often pre-empt
it becoming necessary if a future release of the software
should change the version structure. However, care is
needed by FreeBSD porters when a vendor release is made
without an official version number — such as a code
snapshot release. The temptation is to label the
release with the release date, which will cause problems
as in the example above when a new official release is
made.For example, if a snapshot release is made on the date
20000917, and the previous version of the software was
version 1.2, the snapshot release should be given a
PORTVERSION of 1.2.20000917 or similar,
not 20000917, so that the succeeding release, say 1.3, is
still a numerically greater value.Example of PORTREVISION and
PORTEPOCH usageThe gtkmumble port, version
0.10, is committed to the ports
collection:PORTNAME= gtkmumble
PORTVERSION= 0.10PKGNAME becomes
gtkmumble-0.10.A security hole is discovered which requires a local
FreeBSD patch. PORTREVISION is bumped
accordingly.PORTNAME= gtkmumble
PORTVERSION= 0.10
PORTREVISION= 1PKGNAME becomes
gtkmumble-0.10_1A new version is released by the vendor, numbered 0.2
(it turns out the author actually intended
0.10 to actually mean
0.1.0, not what comes after
0.9 - oops, too late now). Since the new minor
version 2 is numerically less than the
previous version 10, the
PORTEPOCH must be bumped to manually
force the new package to be detected as newer. Since it
is a new vendor release of the code,
PORTREVISION is reset to 0 (or removed
from the Makefile).PORTNAME= gtkmumble
PORTVERSION= 0.2
PORTEPOCH= 1PKGNAME becomes
gtkmumble-0.2,1The next release is 0.3. Since
PORTEPOCH never decreases, the version
variables are now:PORTNAME= gtkmumble
PORTVERSION= 0.3
PORTEPOCH= 1PKGNAME becomes
gtkmumble-0.3,1If PORTEPOCH were reset
to 0 with this upgrade, someone who had
installed the gtkmumble-0.10_1 package would not detect
the gtkmumble-0.3 package as newer, since
3 is still numerically less than
10. Remember, this is the whole point of
PORTEPOCH in the first place.PKGNAMEPREFIX and PKGNAMESUFFIXTwo optional variables, PKGNAMEPREFIX and
PKGNAMESUFFIX, are combined with
PORTNAME and
PORTVERSION to
form PKGNAME as
${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}-${PORTVERSION}.
Make sure this conforms to our guidelines for a good package
name. In particular, you are not allowed to use a
hyphen (-) in
PORTVERSION. Also, if the package name
has the language- or the
-compiled.specifics part (see below), use
PKGNAMEPREFIX and
PKGNAMESUFFIX, respectively. Do not make
them part of PORTNAME.Package Naming ConventionsThe following are the conventions you should follow in naming your
packages. This is to have our package directory easy to scan, as
there are already thousands of packages and users are going to
turn away if they hurt their eyes!The package name should look like
language_region-name-compiled.specifics-version.numbers.The package name is defined as
${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}-${PORTVERSION}.
Make sure to set the variables to conform to that format.FreeBSD strives to support the native language of its users.
The language- part should be a two
letter abbreviation of the natural language defined by ISO-639 if
the port is specific to a certain language. Examples are
ja for Japanese, ru for
Russian, vi for Vietnamese,
zh for Chinese, ko for
Korean and de for German.If the port is specific to a certain region within the
language area, add the two letter country code as well.
Examples are en_US for US English and
fr_CH for Swiss French.The language- part should
be set in the PKGNAMEPREFIX variable.The first letter of name part
should be lowercase. (The rest of the name can contain
capital letters, so use your own discretion when you are
converting a software name that has some capital letters in it.)
There is a tradition of naming perl 5 modules by
prepending p5- and converting the double-colon
separator to a hyphen; for example, the
Data::Dumper module becomes
p5-Data-Dumper. If the software in question
has numbers, hyphens, or underscores in its name, you may include
them as well (like kinput2).If the port can be built with different hardcoded defaults (usually
part of the directory name in a family of ports), the
-compiled.specifics part should state
the compiled-in defaults (the hyphen is optional). Examples are
papersize and font units.The -compiled.specifics part
should be set in the PKGNAMESUFFIX
variable.The version string should follow a dash
(-) and be a period-separated list of
integers and single lowercase alphabetics. In particular,
it is not permissible to have another dash inside the
version string. The only exception is the string
pl (meaning patchlevel), which can be
used only when there are no major and
minor version numbers in the software. If the software
version has strings like alpha, beta, rc, or pre, take
the first letter and put it immediately after a period.
If the version string continues after those names, the
numbers should follow the single alphabet without an extra
period between them.The idea is to make it easier to sort ports by looking
at the version string. In particular, make sure version
number components are always delimited by a period, and
if the date is part of the string, use the
yyyy.mm.dd
format, not
dd.mm.yyyy
or the non-Y2K compliant
yy.mm.dd
format.Here are some (real) examples on how to convert the name
as called by the software authors to a suitable package
name:Distribution NamePKGNAMEPREFIXPORTNAMEPKGNAMESUFFIXPORTVERSIONReasonmule-2.2.2(empty)mule(empty)2.2.2No changes requiredXFree86-3.3.6(empty)XFree86(empty)3.3.6No changes requiredEmiClock-1.0.2(empty)emiclock(empty)1.0.2No uppercase names for single programsrdist-1.3alpha(empty)rdist(empty)1.3.aNo strings like alpha
allowedes-0.9-beta1(empty)es(empty)0.9.b1No strings like beta
allowedmailman-2.0rc3(empty)mailman(empty)2.0.r3No strings like rc
allowedv3.3beta021.src(empty)tiff(empty)3.3What the heck was that anyway?tvtwm(empty)tvtwm(empty)pl11Version string always requiredpiewm(empty)piewm(empty)1.0Version string always requiredxvgr-2.10pl1(empty)xvgr(empty)2.10.1pl allowed only when no
major/minor version numbersgawk-2.15.6ja-gawk(empty)2.15.6Japanese language versionpsutils-1.13(empty)psutils-letter1.13Papersize hardcoded at package build timepkfonts(empty)pkfonts3001.0Package for 300dpi fontsIf there is absolutely no trace of version information in the
original source and it is unlikely that the original author will ever
release another version, just set the version string to
1.0 (like the piewm example above). Otherwise, ask
the original author or use the date string
(yyyy.mm.dd)
as the version.CategorizationCATEGORIESWhen a package is created, it is put under
/usr/ports/packages/All and links are made from
one or more subdirectories of
/usr/ports/packages. The names of these
subdirectories are specified by the variable
CATEGORIES. It is intended to make life easier
for the user when he is wading through the pile of packages on the
FTP site or the CDROM. Please take a look at the current list of categories and pick the ones
that are suitable for your port.This list also determines where in the ports tree the port is
imported. If you put more than one category here, it is assumed
that the port files will be put in the subdirectory with the name in
the first category. See below for more
discussion about how to pick the right categories.Current list of categoriesHere is the current list of port categories. Those
marked with an asterisk (*) are
virtual categories—those that do not have
a corresponding subdirectory in the ports tree. They are only
used as secondary categories, and only for search purposes.For non-virtual categories, you will find a one-line
description in the COMMENT in that
subdirectory's Makefile.CategoryDescriptionNotesaccessibilityPorts to help disabled users.afterstep*Ports to support the
AfterStep
window manager.arabicArabic language support.archiversArchiving tools.astroAstronomical ports.audioSound support.benchmarksBenchmarking utilities.biologyBiology-related software.cadComputer aided design tools.chineseChinese language support.commsCommunication software.Mostly software to talk to your serial port.convertersCharacter code converters.databasesDatabases.deskutilsThings that used to be on the desktop before
computers were invented.develDevelopment utilities.Do not put libraries here just because they are
libraries—unless they truly do not belong anywhere
else, they should not be in this category.dnsDNS-related software.editorsGeneral editors.Specialized editors go in the section for those
tools (e.g., a mathematical-formula editor will go
in math).elisp*Emacs-lisp ports.emulatorsEmulators for other operating systems.Terminal emulators do not belong
here—X-based ones should go to
x11 and text-based ones to either
comms or misc,
depending on the exact functionality.financeMonetary, financial and related applications.frenchFrench language support.ftpFTP client and server utilities.If your port speaks both FTP and HTTP, put it in
ftp with a secondary
category of www.gamesGames.geography*Geography-related software.germanGerman language support.gnome*Ports from the GNOME
Project.graphicsGraphics utilities.gnustep*Software related to the GNUstep desktop environment.hamradio*Software for amateur radio.haskell*Software related to the Haskell language.hebrewHebrew language support.hungarianHungarian language support.ipv6*IPv6 related software.ircInternet Relay Chat utilities.japaneseJapanese language support.javaSoftware related to the Java language.The java category shall not be
the only one for a port. Save for ports directly related to
the Java language, porters are also encouraged not to
use java as the main category of a
port.kde*Ports from the K Desktop Environment (KDE)
Project.koreanKorean language support.langProgramming languages.linux*Linux applications and support utilities.lisp*Software related to the Lisp language.mailMail software.mathNumerical computation software and other utilities
for mathematics.mboneMBone applications.miscMiscellaneous utilitiesBasically things that
do not belong anywhere else.
If at all possible, try to
find a better category for your port than
misc, as ports tend to get overlooked
in here.multimediaMultimedia software.netMiscellaneous networking software.net-imInstant messaging software.net-mgmtNetworking management software.net-p2pPeer to peer network applications.newsUSENET news software.palmSoftware support for the Palm™ series.parallel*Applications dealing with parallelism in computing.pear*Ports related to the Pear PHP framework.perl5*Ports that require Perl version 5 to run.plan9*Various programs from Plan9.polishPolish language support.ports-mgmtPorts for managing, installing and developing FreeBSD ports and packages.portuguesePortuguese language support.printPrinting software.Desktop publishing tools
(previewers, etc.) belong here too.python*Software related to the Python language.ruby*Software related to the Ruby language.rubygems*Ports of RubyGems packages.russianRussian language support.scheme*Software related to the Scheme language.scienceScientific ports that do not fit into other
categories such as astro,
biology and
math.securitySecurity utilities.shellsCommand line shells.spanish*Spanish language support.sysutilsSystem utilities.tcl80*Ports that use Tcl version 8.0 to run.tcl81*Ports that use Tcl version 8.1 to run.tcl82*Ports that use Tcl version 8.2 to run.tcl83*Ports that use Tcl version 8.3 to run.tcl84*Ports that use Tcl version 8.4 to run.textprocText processing utilities.It does not include
desktop publishing tools, which go to print.tk80*Ports that use Tk version 8.0 to run.tk82*Ports that use Tk version 8.2 to run.tk83*Ports that use Tk version 8.3 to run.tk84*Ports that use Tk version 8.4 to run.tkstep80*Ports that use TkSTEP version 8.0 to run.ukrainianUkrainian language support.vietnameseVietnamese language support.windowmaker*Ports to support the WindowMaker window
manager.wwwSoftware related to the World Wide Web.HTML language
support belongs here too.x11The X Window System and friends.This category is only
for software that directly supports the window system. Do not
put regular X applications here; most of them should go
into other x11-* categories (see below).
If your port is an X
application, define USE_XLIB (implied by
USE_IMAKE) and put it in the appropriate
category.x11-clocksX11 clocks.x11-fmX11 file managers.x11-fontsX11 fonts and font utilities.x11-serversX11 servers.x11-themesX11 themes.x11-toolkitsX11 toolkits.x11-wmX11 window managers.xfce*Ports related to the
Xfce desktop
environment.zope*Zope support.Choosing the right categoryAs many of the categories overlap, you often have to choose
which of the categories should be the primary category of your port.
There are several rules that govern this issue. Here is the list of
priorities, in decreasing order of precedence:The first category must be a physical category (see
above). This is
necessary to make the packaging work. Virtual categories and
physical categories may be intermixed after that.Language specific categories always come first. For
example, if your port installs Japanese X11 fonts, then your
CATEGORIES line would read japanese
x11-fonts.Specific categories are listed before less-specific ones. For
instance, an HTML editor should be listed as www
editors, not the other way around. Also, you should not
list net when the port belongs to
any of irc, mail,
mbone, news,
security, or www, as
net is included implicitly.x11 is used as a secondary category only
when the primary category is a natural language. In particular,
you should not put x11 in the category line
for X applications.Emacs modes should be
placed in the same ports category as the application
supported by the mode, not in
editors. For example, an
Emacs mode to edit source
files of some programming language should go into
lang.
misc
should not appear with any other non-virtual category.
If you have misc with something else in
your CATEGORIES line, that means you can
safely delete misc and just put the port
in that other subdirectory!If your port truly does not belong anywhere else, put it in
misc.If you are not sure about the category, please put a comment to
that effect in your &man.send-pr.1; submission so we can
discuss it before we import it. If you are a committer, send a note
to the &a.ports; so we can discuss it first. Too often, new ports are
imported to the wrong category only to be moved right away.
This causes unnecessary and undesirable bloat in the master
source repository.Proposing a new categoryAs the Ports Collection has grown over time, various new
categories have been introduced. New categories can either
be virtual categories—those that do
not have a corresponding subdirectory in the ports tree—
or physical categories—those that
do. The following text discusses the issues involved in creating
a new physical category so that you can understand them before
you propose one.Our existing practice has been to avoid creating a new
physical category unless either a large number of ports would
logically belong to it, or the ports that would belong to it
are a logically distinct group that is of limited general
interest (for instance, categories related to spoken human
languages), or preferably both.The rationale for this is that such a change creates a
fair amount of work for both the committers and also
for all users who track changes to the Ports Collection. In
addition, proposed category changes just naturally seem to
attract controversy. (Perhaps this is because there is no
clear consensus on when a category is too big,
nor whether categories should lend themselves to browsing (and
thus what number of categories would be an ideal number), and
so forth.)Here is the procedure:Propose the new category on &a.ports;. You should
include a detailed rationale for the new category,
including why you feel the existing categories are not
sufficient, and the list of existing ports proposed to move.
(If there are new ports pending in
GNATS that would fit this
category, list them too.) If you are the maintainer and/or
submitter, respectively, mention that as it may help you
to make your case.Participate in the discussion.If it seems that there is support for your idea,
file a PR which includes both the rationale and the list
of existing ports that need to be moved. Ideally, this
PR should also include patches for the following:Makefiles for the
new ports once they are repocopiedMakefile for the
new categoryMakefile for the
old ports' categoriesMakefiles for ports
that depend on the old ports(for extra credit, you can include the other
files that have to change, as per the procedure
in the Committer's Guide.)Since it affects the ports infrastructure and involves
not only performing repo-copies but also possibly running
regression tests on the build cluster, the PR should be
assigned to the &a.portmgr;.If that PR is approved, a committer will need to follow
the rest of the procedure that is
outlined in the Committer's Guide.Proposing a new virtual category should be similar to
the above but much less involved, since no ports will
actually have to move. In this case, the only patches to
include in the PR would be those to add the new category to the
CATEGORIESs of the affected ports.Proposing reorganizing all the categoriesOccasionally someone proposes reorganizing the categories
with either a 2-level structure, or some other kind of keyword
structure. To date, nothing has come of any of these proposals
because, while they are very easy to make, the effort involved to
retrofit the entire existing ports collection with any kind of
reorganization is daunting to say the very least. Please read
the history of these proposals in the mailing list archives before
you post this idea; furthermore, you should be prepared to be
challenged to offer a working prototype.The distribution filesThe second part of the Makefile describes the
files that must be downloaded in order to build the port, and where
they can be downloaded from.DISTVERSION/DISTNAMEDISTNAME is the name of the port as
called by the authors of the software.
DISTNAME defaults to
${PORTNAME}-${PORTVERSION}, so override it only if necessary.
DISTNAME is only used in two places.
First, the distribution file list
(DISTFILES) defaults to
${DISTNAME}${EXTRACT_SUFX}.
Second, the distribution file is expected to extract into a
subdirectory named WRKSRC, which defaults
to work/${DISTNAME}.Some vendor's distribution names which do not fit into the
${PORTNAME}-${PORTVERSION}-scheme can be handled
automatically by setting DISTVERSION.
PORTVERSION and DISTNAME will be
derived automatically, but can of course be overridden. The following
table lists some examples:DISTVERSIONPORTVERSION0.7.1d0.7.1.d10Alpha310.a33Beta7-pre23.b7.p28:f_178f.17PKGNAMEPREFIX and
PKGNAMESUFFIX do not affect
DISTNAME. Also note that if
WRKSRC is equal to
work/${PORTNAME}-${PORTVERSION}
while the original source archive is named something other than
${PORTNAME}-${PORTVERSION}${EXTRACT_SUFX},
you should probably leave DISTNAME
alone— you are better off defining
DISTFILES than having to set both
DISTNAME and WRKSRC
(and possibly EXTRACT_SUFX).MASTER_SITESRecord the directory part of the FTP/HTTP-URL pointing at the
original tarball in MASTER_SITES. Do not forget
the trailing slash (/)!The make macros will try to use this
specification for grabbing the distribution file with
FETCH if they cannot find it already on the
system.It is recommended that you put multiple sites on this list,
preferably from different continents. This will safeguard against
wide-area network problems. We are even planning to add support
for automatically determining the closest master site and fetching
from there; having multiple sites will go a long way towards
helping this effort.If the original tarball is part of one of the popular
archives such as X-contrib, GNU, or Perl CPAN, you may be able
refer to those sites in an easy compact form using
MASTER_SITE_*
(e.g., MASTER_SITE_XCONTRIB,
MASTER_SITE_GNU and
MASTER_SITE_PERL_CPAN). Simply set
MASTER_SITES to one of these variables and
MASTER_SITE_SUBDIR to the path within the
archive. Here is an example:MASTER_SITES= ${MASTER_SITE_XCONTRIB}
MASTER_SITE_SUBDIR= applicationsThese variables are defined in
/usr/ports/Mk/bsd.sites.mk. There are
new entries added all the time, so make sure to check the
latest version of this file before submitting a port.The user can also set the MASTER_SITE_*
variables in /etc/make.conf to override our
choices, and use their favorite mirrors of these popular archives
instead.EXTRACT_SUFXIf you have one distribution file, and it uses an odd suffix to
indicate the compression mechanism, set
EXTRACT_SUFX.For example, if the distribution file was named
foo.tgz instead of the more normal
foo.tar.gz, you would write:DISTNAME= foo
EXTRACT_SUFX= .tgzThe USE_BZIP2 and USE_ZIP
variables automatically set EXTRACT_SUFX to
.tar.bz2 or .zip as necessary. If
neither of these are set then EXTRACT_SUFX
defaults to .tar.gz.You never need to set both EXTRACT_SUFX and
DISTFILES.DISTFILESSometimes the names of the files to be downloaded have no
resemblance to the name of the port. For example, it might be
called source.tar.gz or similar. In other
cases the application's source code might be in several different
archives, all of which must be downloaded.If this is the case, set DISTFILES to be a
space separated list of all the files that must be
downloaded.DISTFILES= source1.tar.gz source2.tar.gzIf not explicitly set, DISTFILES defaults to
${DISTNAME}${EXTRACT_SUFX}.EXTRACT_ONLYIf only some of the DISTFILES must be
extracted—for example, one of them is the source code, while
another is an uncompressed document—list the filenames that
must be extracted in EXTRACT_ONLY.DISTFILES= source.tar.gz manual.html
EXTRACT_ONLY= source.tar.gzIf none of the DISTFILES
should be uncompressed then set EXTRACT_ONLY to
the empty string.EXTRACT_ONLY=PATCHFILESIf your port requires some additional patches that are available
by FTP or HTTP, set PATCHFILES to the names of
the files and PATCH_SITES to the URL of the
directory that contains them (the format is the same as
MASTER_SITES).If the patch is not relative to the top of the source tree
(i.e., WRKSRC) because it contains some extra
pathnames, set PATCH_DIST_STRIP accordingly. For
instance, if all the pathnames in the patch have an extra
foozolix-1.0/ in front of the filenames, then set
PATCH_DIST_STRIP=-p1.Do not worry if the patches are compressed; they will be
decompressed automatically if the filenames end with
.gz or .Z.If the patch is distributed with some other files, such as
documentation, in a gzip'd tarball, you cannot just use
PATCHFILES. If that is the case, add the name
and the location of the patch tarball to
DISTFILES and MASTER_SITES.
Then, use the EXTRA_PATCHES variable to
point to those files and bsd.port.mk
will automatically apply them for you. In particular, do
not copy patch files into the
PATCHDIR directory—that directory may
not be writable.The tarball will have been extracted alongside the
regular source by then, so there is no need to explicitly extract
it if it is a regular gzip'd or compress'd tarball. If you do the
latter, take extra care not to overwrite something that already
exists in that directory. Also, do not forget to add a command to
remove the copied patch in the pre-clean
target.Multiple distribution files or patches from different
sites and subdirectories
(MASTER_SITES:n)(Consider this to be a somewhat advanced topic;
those new to this document may wish to skip this section at first).
This section has information on the fetching mechanism
known as both MASTER_SITES:n and
MASTER_SITES_NN. We will refer to this
mechanism as MASTER_SITES:n
hereon.A little background first. OpenBSD has a neat feature
inside both DISTFILES and
PATCHFILES variables, both files and
patches can be postfixed with :n
identifiers where n both can be
[0-9] and denote a group designation.
For example:DISTFILES= alpha:0 beta:1In OpenBSD, distribution file alpha
will be associated with variable
MASTER_SITES0 instead of our common
MASTER_SITES and
beta with
MASTER_SITES1.This is a very interesting feature which can decrease
that endless search for the correct download site.Just picture 2 files in DISTFILES and
20 sites in MASTER_SITES, the sites slow
as hell where beta is carried by all
sites in MASTER_SITES, and
alpha can only be found in the 20th
site. It would be such a waste to check all of them if
maintainer knew this beforehand, would it not? Not a good
start for that lovely weekend!Now that you have the idea, just imagine more
DISTFILES and more
MASTER_SITES. Surely our
distfiles survey meister would appreciate the
relief to network strain that this would bring.In the next sections, information will follow on the
FreeBSD implementation of this idea. We improved a bit on
OpenBSD's concept.Simplified informationThis section tells you how to quickly prepare fine
grained fetching of multiple distribution files and
patches from different sites and subdirectories. We
describe here a case of simplified
MASTER_SITES:n usage. This will be
sufficient for most scenarios. However, if you need
further information, you will have to refer to the next
section.Some applications consist of multiple distribution
files that must be downloaded from a number of different
sites. For example,
Ghostscript consists of the
core of the program, and then a large number of driver
files that are used depending on the user's printer. Some
of these driver files are supplied with the core, but many
others must be downloaded from a variety of different
sites.To support this, each entry in
DISTFILES may be followed by a colon
and a tag name. Each site listed in
MASTER_SITES is then followed by a
colon, and the tag that indicates which distribution files
should be downloaded from this site.For example, consider an application with the source
split in two parts, source1.tar.gz
and source2.tar.gz, which must be
downloaded from two different sites. The port's
Makefile would include lines like
.Simplified use of MASTER_SITES:n
with 1 file per siteMASTER_SITES= ftp://ftp.example1.com/:source1 \
ftp://ftp.example2.com/:source2
DISTFILES= source1.tar.gz:source1 \
source2.tar.gz:source2Multiple distribution files can have the same tag.
Continuing the previous example, suppose that there was a
third distfile, source3.tar.gz, that
should be downloaded from
ftp.example2.com. The
Makefile would then be written like
.Simplified use of MASTER_SITES:n
with more than 1 file per siteMASTER_SITES= ftp://ftp.example1.com/:source1 \
ftp://ftp.example2.com/:source2
DISTFILES= source1.tar.gz:source1 \
source2.tar.gz:source2 \
source3.tar.gz:source2Detailed informationOkay, so the previous section example did not reflect
your needs? In this section we will explain in detail how
the fine grained fetching mechanism
MASTER_SITES:n works and how you can
modify your ports to use it.Elements can be postfixed with
:n where
n is
[^:,]+, i.e.,
n could conceptually be any
alphanumeric string but we will limit it to
[a-zA-Z_][0-9a-zA-Z_]+ for
now.Moreover, string matching is case sensitive;
i.e., n is different from
N.However, the following words cannot be used for
postfixing purposes since they yield special meaning:
default, all and
ALL (they are used internally in
item ).
Furthermore, DEFAULT is a special
purpose word (check item ).Elements postfixed with :n
belong to the group n,
:m belong to group
m and so forth.Elements without a postfix are groupless, i.e.,
they all belong to the special group
DEFAULT. If you postfix any
elements with DEFAULT, you are just
being redundant unless you want to have an element
belonging to both DEFAULT and other
groups at the same time (check item ).The following examples are equivalent but the
first one is preferred:MASTER_SITES= alpha
MASTER_SITES= alpha:DEFAULTGroups are not exclusive, an element may belong to
several different groups at the same time and a group
can either have either several different elements or
none at all. Repeated elements within the same group
will be simply that, repeated elements.When you want an element to belong to several
groups at the same time, you can use the comma
operator (,).Instead of repeating it several times, each time
with a different postfix, we can list several groups
at once in a single postfix. For instance,
:m,n,o marks an element that
belongs to group m,
n and o.All the following examples are equivalent but the
last one is preferred:MASTER_SITES= alpha alpha:SOME_SITE
MASTER_SITES= alpha:DEFAULT alpha:SOME_SITE
MASTER_SITES= alpha:SOME_SITE,DEFAULT
MASTER_SITES= alpha:DEFAULT,SOME_SITEAll sites within a given group are sorted
according to MASTER_SORT_AWK. All
groups within MASTER_SITES and
PATCH_SITES are sorted as
well.Group semantics can be used in any of the
following variables MASTER_SITES,
PATCH_SITES,
MASTER_SITE_SUBDIR,
PATCH_SITE_SUBDIR,
DISTFILES, and
PATCHFILES according to the
following syntax:All MASTER_SITES,
PATCH_SITES,
MASTER_SITE_SUBDIR and
PATCH_SITE_SUBDIR elements must
be terminated with the forward slash
/ character. If any elements
belong to any groups, the group postfix
:n
must come right after the terminator
/. The
MASTER_SITES:n mechanism relies
on the existence of the terminator
/ to avoid confusing elements
where a :n is a valid part of
the element with occurrences where
:n denotes group
n. For compatibility purposes,
since the / terminator was not
required before in both
MASTER_SITE_SUBDIR and
PATCH_SITE_SUBDIR elements, if
the postfix immediate preceding character is not
a / then :n
will be considered a valid part of the element
instead of a group postfix even if an element is
postfixed with :n. See both
and .Detailed use of
MASTER_SITES:n in
MASTER_SITE_SUBDIRMASTER_SITE_SUBDIR= old:n new/:NEWDirectories within group
DEFAULT -> old:nDirectories within group
NEW -> newDetailed use of
MASTER_SITES:n with comma
operator, multiple files, multiple sites and
multiple subdirectoriesMASTER_SITES= http://site1/%SUBDIR%/ http://site2/:DEFAULT \
http://site3/:group3 http://site4/:group4 \
http://site5/:group5 http://site6/:group6 \
http://site7/:DEFAULT,group6 \
http://site8/%SUBDIR%/:group6,group7 \
http://site9/:group8
DISTFILES= file1 file2:DEFAULT file3:group3 \
file4:group4,group5,group6 file5:grouping \
file6:group7
MASTER_SITE_SUBDIR= directory-trial:1 directory-n/:groupn \
directory-one/:group6,DEFAULT \
directoryThe previous example results in the
following fine grained fetching. Sites are
listed in the exact order they will be
used.file1 will be
fetched fromMASTER_SITE_OVERRIDEhttp://site1/directory-trial:1/http://site1/directory-one/http://site1/directory/http://site2/http://site7/MASTER_SITE_BACKUPfile2 will be
fetched exactly as
file1 since they
both belong to the same groupMASTER_SITE_OVERRIDEhttp://site1/directory-trial:1/http://site1/directory-one/http://site1/directory/http://site2/http://site7/MASTER_SITE_BACKUPfile3 will be
fetched fromMASTER_SITE_OVERRIDEhttp://site3/MASTER_SITE_BACKUPfile4 will be
fetched fromMASTER_SITE_OVERRIDEhttp://site4/http://site5/http://site6/http://site7/http://site8/directory-one/MASTER_SITE_BACKUPfile5 will be
fetched fromMASTER_SITE_OVERRIDEMASTER_SITE_BACKUPfile6 will be
fetched fromMASTER_SITE_OVERRIDEhttp://site8/MASTER_SITE_BACKUPHow do I group one of the special variables from
bsd.sites.mk, e.g.,
MASTER_SITE_SOURCEFORGE?See .Detailed use of
MASTER_SITES:n with
MASTER_SITE_SOURCEFORGEMASTER_SITES= http://site1/ ${MASTER_SITE_SOURCEFORGE:S/$/:sourceforge,TEST/}
DISTFILES= something.tar.gz:sourceforgesomething.tar.gz will be
fetched from all sites within
MASTER_SITE_SOURCEFORGE.How do I use this with PATCH*
variables?All examples were done with
MASTER* variables but they work
exactly the same for PATCH* ones as
can be seen in .Simplified use of
MASTER_SITES:n with
PATCH_SITES.PATCH_SITES= http://site1/ http://site2/:test
PATCHFILES= patch1:testWhat does change for ports? What does not?All current ports remain the same. The
MASTER_SITES:n feature code is only
activated if there are elements postfixed with
:n like
elements according to the aforementioned syntax rules,
especially as shown in item .The port targets remain the same:
checksum,
makesum,
patch,
configure,
build, etc. With the obvious
exceptions of do-fetch,
fetch-list,
master-sites and
patch-sites.do-fetch: deploys the
new grouping postfixed
DISTFILES and
PATCHFILES with their matching
group elements within both
MASTER_SITES and
PATCH_SITES which use matching
group elements within both
MASTER_SITE_SUBDIR and
PATCH_SITE_SUBDIR. Check .fetch-list: works
like old fetch-list with
the exception that it groups just like
do-fetch.master-sites and
patch-sites:
(incompatible with older versions) only return the
elements of group DEFAULT; in
fact, they execute targets
master-sites-default and
patch-sites-default
respectively.Furthermore, using target either
master-sites-all or
patch-sites-all is
preferred to directly checking either
MASTER_SITES or
PATCH_SITES. Also,
directly checking is not guaranteed to work in any
future versions. Check item
for more information on these new port
targets.New port targetsThere are
master-sites-n
and
patch-sites-n
targets which will list the elements of the
respective group n
within MASTER_SITES and
PATCH_SITES respectively. For
instance, both
master-sites-DEFAULT and
patch-sites-DEFAULT will
return the elements of group
DEFAULT,
master-sites-test and
patch-sites-test of group
test, and thereon.There are new targets
master-sites-all and
patch-sites-all which do
the work of the old
master-sites and
patch-sites ones. They
return the elements of all groups as if they all
belonged to the same group with the caveat that it
lists as many
MASTER_SITE_BACKUP and
MASTER_SITE_OVERRIDE as there
are groups defined within either
DISTFILES or
PATCHFILES; respectively for
master-sites-all and
patch-sites-all.DIST_SUBDIRDo not let your port clutter
/usr/ports/distfiles. If your port requires a
lot of files to be fetched, or contains a file that has a name that
might conflict with other ports (e.g.,
Makefile), set DIST_SUBDIR
to the name of the port (${PORTNAME} or
${PKGNAMEPREFIX}${PORTNAME}
should work fine). This will change
DISTDIR from the default
/usr/ports/distfiles to
/usr/ports/distfiles/DIST_SUBDIR,
and in effect puts everything that is required for your port into
that subdirectory.It will also look at the subdirectory with the same name on the
backup master site at ftp.FreeBSD.org.
(Setting DISTDIR explicitly in your
Makefile will not accomplish this, so please use
DIST_SUBDIR.)This does not affect the MASTER_SITES you
define in your Makefile.ALWAYS_KEEP_DISTFILESIf your port uses binary distfiles and has a license that
requires that the source code is provided with packages distributed
in binary form, e.g. GPL, ALWAYS_KEEP_DISTFILES
will instruct the &os; build cluster to keep a copy of the files
specified in DISTFILES. Users of these ports
will generally not need these files, so it is a good idea to only
add the source distfiles to DISTFILES when
PACKAGE_BUILDING is defined.
Use of ALWAYS_KEEP_DISTFILES..if defined(PACKAGE_BUILDING)
DISTFILES+= foo.tar.gz
ALWAYS_KEEP_DISTFILES= yes
.endifWhen adding extra files to DISTFILES,
make sure you also add them to distinfo.
Also, the additional files will normally be extracted into
WRKDIR as well, which for some ports may
lead to undesirable sideeffects and require special handling.MAINTAINERSet your mail-address here. Please. :-)Note that only a single address without the comment part is
allowed as a MAINTAINER value.
The format used should be user@hostname.domain.
Please do not include any descriptive text such as your real
name in this entry—that merely confuses
bsd.port.mk.The maintainer is responsible for keeping the port up to
date, and ensuring the port works correctly.
For a detailed description of the responsibilities of a port
maintainer, refer to the The
challenge for port maintainers section.Changes to the port will be sent to the maintainer of
a port for a review and an approval before being committed.
If the maintainer does not respond to an update
request after two weeks (excluding major public
holidays), then that is considered a maintainer timeout, and the
update may be made without explicit maintainer approval. If the
maintainer does not respond within three months, then that
maintainer is considered absent without leave, and can be
replaced as the maintainer of the particular port in question.
Exceptions to this are anything maintained by the &a.portmgr;, or
the &a.security-officer;. No unauthorized commits may ever be
made to ports maintained by those groups.We reserve the right to modify the maintainer's submission
to better match existing policies and style of the Ports
Collection without explicit blessing from the submitter.
Also, large infrastructural changes can result in
a port being modified without maintainer's consent.
This kind of changes will never affect the port's
functionality.The &a.portmgr; reserves the right to revoke or override
anyone's maintainership for any reason, and the &a.security-officer;
reserves the right to revoke or override maintainership for security
reasons.COMMENTThis is a one-line description of the port.
Please do not include the package name (or
version number of the software) in the comment. The comment
should begin with a capital and end without a period. Here
is an example:COMMENT= A cat chasing a mouse all over the screenThe COMMENT variable should immediately follow the MAINTAINER
variable in the Makefile.Please try to keep the COMMENT line less than 70
characters, as it is displayed to users as a one-line
summary of the port.DependenciesMany ports depend on other ports. There are seven variables that
you can use to ensure that all the required bits will be on the
user's machine. There are also some pre-supported dependency
variables for common cases, plus a few more to control the behavior
of dependencies.LIB_DEPENDSThis variable specifies the shared libraries this port depends
on. It is a list of
lib:dir:target
tuples where lib is the name of the
shared library, dir is the
directory in which to find it in case it is not available, and
target is the target to call in that
directory. For example,
LIB_DEPENDS= jpeg.9:${PORTSDIR}/graphics/jpeg
will check for a shared jpeg library with major version 9, and
descend into the graphics/jpeg subdirectory
of your ports tree to build and install it if it is not found.
The target part can be omitted if it is
equal to DEPENDS_TARGET (which defaults to
install).The lib part is a regular
expression which is being looked up in the
ldconfig -r output. Values such as
intl.[5-7] and intl are
allowed. The first pattern,
intl.[5-7], will match any of:
intl.5, intl.6 or
intl.7. The second pattern,
intl, will match any version of the
intl library.The dependency is checked twice, once from within the
extract target and then from within the
install target. Also, the name of the
dependency is put into the package so that
&man.pkg.add.1; will automatically install it if it is
not on the user's system.RUN_DEPENDSThis variable specifies executables or files this port depends
on during run-time. It is a list of
path:dir:target
tuples where path is the name of the
executable or file, dir is the
directory in which to find it in case it is not available, and
target is the target to call in that
directory. If path starts with a slash
(/), it is treated as a file and its existence
is tested with test -e; otherwise, it is
assumed to be an executable, and which -s is
used to determine if the program exists in the search path.For example,RUN_DEPENDS= ${LOCALBASE}/etc/innd:${PORTSDIR}/news/inn \
wish8.0:${PORTSDIR}/x11-toolkits/tk80will check if the file or directory
/usr/local/etc/innd exists, and build and
install it from the news/inn subdirectory of
the ports tree if it is not found. It will also see if an
executable called wish8.0 is in the search
path, and descend into the x11-toolkits/tk80
subdirectory of your ports tree to build and install it if it is
not found.In this case, innd is actually an
executable; if an executable is in a place that is not expected
to be in the search path, you should use the full
pathname.The official search PATH used on the ports
build cluster is/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/binThe dependency is checked from within the
install target. Also, the name of the
dependency is put into the package so that
&man.pkg.add.1; will automatically install it if it is
not on the user's system. The target
part can be omitted if it is the same as
DEPENDS_TARGET.BUILD_DEPENDSThis variable specifies executables or files this port
requires to build. Like RUN_DEPENDS, it is a
list of
path:dir:target
tuples. For example, BUILD_DEPENDS=
unzip:${PORTSDIR}/archivers/unzip will check
for an executable called unzip, and descend
into the archivers/unzip subdirectory of your
ports tree to build and install it if it is not found.build here means everything from extraction to
compilation. The dependency is checked from within the
extract target. The
target part can be omitted if it is
the same as DEPENDS_TARGETFETCH_DEPENDSThis variable specifies executables or files this port
requires to fetch. Like the previous two, it is a list of
path:dir:target
tuples. For example, FETCH_DEPENDS=
ncftp2:${PORTSDIR}/net/ncftp2 will check for an
executable called ncftp2, and descend into the
net/ncftp2 subdirectory of your ports tree to
build and install it if it is not found.The dependency is checked from within the
fetch target. The
target part can be omitted if it is the
same as DEPENDS_TARGET.EXTRACT_DEPENDSThis variable specifies executables or files this port
requires for extraction. Like the previous, it is a list of
path:dir:target
tuples. For example, EXTRACT_DEPENDS=
unzip:${PORTSDIR}/archivers/unzip will check
for an executable called unzip, and descend
into the archivers/unzip subdirectory of
your ports tree to build and install it if it is not found.The dependency is checked from within the
extract target. The
target part can be omitted if it is the
same as DEPENDS_TARGET.Use this variable only if the extraction does not already
work (the default assumes gzip) and cannot
be made to work using USE_ZIP or
USE_BZIP2 described in .PATCH_DEPENDSThis variable specifies executables or files this port
requires to patch. Like the previous, it is a list of
path:dir:target
tuples. For example, PATCH_DEPENDS=
${NONEXISTENT}:${PORTSDIR}/java/jfc:extract
will descend into the
java/jfc subdirectory of your ports tree to
extract it.The dependency is checked from within the
patch target. The
target part can be omitted if it is the
same as DEPENDS_TARGET.USE_*A number of variables exist in order to encapsulate common
dependencies that many ports have. Although their use is
optional, they can help to reduce the verbosity of the port
Makefiles. Each of them is styled
as USE_*. The
usage of these variables is restricted to the port
Makefiles and
ports/Mk/bsd.*.mk and is not designed
to encapsulate user-settable options — use
WITH_* and
WITHOUT_*
for that purpose.It is always incorrect to set
any USE_*
in /etc/make.conf. For instance,
setting USE_GCC=3.2
would adds a dependency on gcc32 for every port,
including gcc32 itself!
The USE_*
variablesVariableMeansUSE_BZIP2The port's tarballs are compressed with
bzip2.USE_ZIPThe port's tarballs are compressed with
zip.USE_BISONThe port uses bison for
building.USE_CDRTOOLSThe port requires cdrecord
either from sysutils/cdrtools or sysutils/cdrtools-cjk, according to
the user's preference.USE_GCCThe port requires a specific version of
gcc to build. The exact version can be
specified with value such as 3.2.
The minimal required version can be specified as
3.2+. The gcc from
the base system is used when it satisfies the requested
version, otherwise an appropriate gcc is
compiled from ports and the CC and
CXX variables are adjusted.
Variables related to gmake and
the configure script are described in
, while
autoconf,
automake and
libtool are described in
. Perl
related variables are described in .
X11 variables are listed in . deals with GNOME and with KDE related variables. documents Java variables, while contains information on
Apache, PHP
and PEAR modules. Python is discussed
in , while
Ruby in .
Finally, provides variables used for
SDL applications.Minimal version of a dependencyA minimal version of a dependency can be specified in any
*_DEPENDS variable using the following
syntax:p5-Spiffy>=0.26:${PORTSDIR}/devel/p5-SpiffyThe first field contains a dependent package name,
which must match the entry in the package database,
a comparison sign, and a package version. The dependency
is satisfied if p5-Spiffy-0.26 or newer is installed on
the machine.Notes on dependenciesAs mentioned above, the default target to call when a
dependency is required is DEPENDS_TARGET.
It defaults to install. This is a user
variable; it is never defined in a port's
Makefile. If your port needs a special way
to handle a dependency, use the :target part of
the *_DEPENDS variables instead of redefining
DEPENDS_TARGET.When you type make clean, its dependencies
are automatically cleaned too. If you do not wish this to happen,
define the variable NOCLEANDEPENDS in your
environment. This may be particularly desirable if the port
has something that takes a long time to rebuild in its
dependency list, such as KDE, GNOME or Mozilla.To depend on another port unconditionally, use the
variable ${NONEXISTENT} as the first field
of BUILD_DEPENDS or
RUN_DEPENDS. Use this only when you need to
get the source of the other port. You can often save
compilation time by specifying the target too. For
instance
BUILD_DEPENDS= ${NONEXISTENT}:${PORTSDIR}/graphics/jpeg:extract
will always descend to the jpeg port and extract it.Circular dependencies are fatalDo not introduce any circular dependencies into the
ports tree!The ports building technology does not tolerate
circular dependencies. If you introduce one, you will have
someone, somewhere in the world, whose FreeBSD installation will
break almost immediately, with many others quickly to follow.
These can really be hard to detect; if in doubt, before
you make that change, make sure you have done the following:
cd /usr/ports; make index. That process
can be quite slow on older machines, but you may be able to
save a large number of people—including yourself—
a lot of grief in the process.MASTERDIRIf your port needs to build slightly different versions of
packages by having a variable (for instance, resolution, or paper
size) take different values, create one subdirectory per package to
make it easier for users to see what to do, but try to share as many
files as possible between ports. Typically you only need a very short
Makefile in all but one of the directories if you
use variables cleverly. In the sole Makefile,
you can use MASTERDIR to specify the directory
where the rest of the files are. Also, use a variable as part of
PKGNAMESUFFIX so
the packages will have different names.This will be best demonstrated by an example. This is part of
japanese/xdvi300/Makefile;PORTNAME= xdvi
PORTVERSION= 17
PKGNAMEPREFIX= ja-
PKGNAMESUFFIX= ${RESOLUTION}
:
# default
RESOLUTION?= 300
.if ${RESOLUTION} != 118 && ${RESOLUTION} != 240 && \
${RESOLUTION} != 300 && ${RESOLUTION} != 400
@${ECHO_MSG} "Error: invalid value for RESOLUTION: \"${RESOLUTION}\""
@${ECHO_MSG} "Possible values are: 118, 240, 300 (default) and 400."
@${FALSE}
.endifjapanese/xdvi300 also has all the regular
patches, package files, etc. If you type make
there, it will take the default value for the resolution (300) and
build the port normally.As for other resolutions, this is the entirexdvi118/Makefile:RESOLUTION= 118
MASTERDIR= ${.CURDIR}/../xdvi300
.include "${MASTERDIR}/Makefile"(xdvi240/Makefile and
xdvi400/Makefile are similar). The
MASTERDIR definition tells
bsd.port.mk that the regular set of
subdirectories like FILESDIR and
SCRIPTDIR are to be found under
xdvi300. The RESOLUTION=118
line will override the RESOLUTION=300 line in
xdvi300/Makefile and the port will be built with
resolution set to 118.ManpagesThe MAN[1-9LN] variables will automatically add
any manpages to pkg-plist (this means you must
not list manpages in the
pkg-plist—see generating PLIST for more). It also
makes the install stage automatically compress or uncompress manpages
depending on the setting of NOMANCOMPRESS in
/etc/make.conf.If your port tries to install multiple names for manpages using
symlinks or hardlinks, you must use the MLINKS
variable to identify these. The link installed by your port will
be destroyed and recreated by bsd.port.mk
to make sure it points to the correct file. Any manpages
listed in MLINKS must not be listed in the
pkg-plist.To specify whether the manpages are compressed upon installation,
use the MANCOMPRESSED variable. This variable can
take three values, yes, no and
maybe. yes means manpages are
already installed compressed, no means they are
not, and maybe means the software already respects
the value of NOMANCOMPRESS so
bsd.port.mk does not have to do anything
special.MANCOMPRESSED is automatically set to
yes if USE_IMAKE is set and
NO_INSTALL_MANPAGES is not set, and to
no otherwise. You do not have to explicitly define
it unless the default is not suitable for your port.If your port anchors its man tree somewhere other than
PREFIX, you can use the
MANPREFIX to set it. Also, if only manpages in
certain sections go in a non-standard place, such as some perl modules
ports, you can set individual man paths using
MANsectPREFIX (where
sect is one of 1-9,
L or N).If your manpages go to language-specific subdirectories, set the
name of the languages to MANLANG. The value of
this variable defaults to "" (i.e., English
only).Here is an example that puts it all together.MAN1= foo.1
MAN3= bar.3
MAN4= baz.4
MLINKS= foo.1 alt-name.8
MANLANG= "" ja
MAN3PREFIX= ${PREFIX}/share/foobar
MANCOMPRESSED= yesThis states that six files are installed by this port;${PREFIX}/man/man1/foo.1.gz
${PREFIX}/man/ja/man1/foo.1.gz
${PREFIX}/share/foobar/man/man3/bar.3.gz
${PREFIX}/share/foobar/man/ja/man3/bar.3.gz
${PREFIX}/man/man4/baz.4.gz
${PREFIX}/man/ja/man4/baz.4.gzAdditionally ${PREFIX}/man/man8/alt-name.8.gz
may or may not be installed by your port. Regardless, a
symlink will be made to join the foo(1) manpage and
alt-name(8) manpage.If only some manpages are translated, you can use several variables
dynamically created from MANLANG content:MANLANG= "" de ja
MAN1= foo.1
MAN1_EN= bar.1
MAN3_DE= baz.3This translates into this list of files:${PREFIX}/man/man1/foo.1.gz
${PREFIX}/man/de/man1/foo.1.gz
${PREFIX}/man/ja/man1/foo.1.gz
${PREFIX}/man/man1/bar.1.gz
${PREFIX}/man/de/man3/baz.3.gzInfo filesIf your package needs to install GNU info files, they should be
listed in the INFO variable (without the trailing
.info), and appropriate installation/de-installation
code will be automatically added to the temporary
pkg-plist before package registration.Makefile OptionsSome large applications can be built in a number of
configurations, adding functionality if one of a number of
libraries or applications is available. Examples include
choice of natural (human) language, GUI versus command-line,
or type of database to support. Since not all users
want those libraries or applications, the ports system
provides hooks that the port author can use to control which
configuration should be built. Supporting these properly will
make users happy, and effectively provide 2 or more ports for the
price of one.KNOBSWITH_* and
WITHOUT_*These variables are designed to be set by the system
administrator. There are many that are standardized in
ports/Mk/bsd.*.mk; others are not,
which can be confusing. If you need to add such a
configuration variable, please consider using one of the
ones from the following list.You should not assume that a
WITH_*
necessarily has a corresponding
WITHOUT_*
variable and vice versa. In general, the default is
simply assumed.Unless otherwise specified, these variables are only
tested for being set or not set, rather than being set to
some kind of variable such as YES or
NO.
The WITH_*
and WITHOUT_*
variablesVariableMeansWITH_APACHE2If set, use
www/apache20
instead of the default of
www/apache13.WITH_BERKELEY_DBDefine this variable to specify the ability to
use a variant of the Berkeley database package such as
databases/db41.
An associated variable,
WITH_BDB_VER, may be
set to values such as 2, 3, 4, 41 or 42.WITH_MYSQLDefine this variable to specify the ability to
use a variant of the MySQL database package such as
databases/mysql40-server.
An associated variable,
WANT_MYSQL_VER, may be
set to values such as 323, 40, 41, or 50.WITHOUT_NLSIf set, says that internationalization is not
needed, which can save compile time. By default,
internationalization is used.WITH_OPENSSL_BASEUse the version of OpenSSL in the base system.WITH_OPENSSL_PORTUse the version of OpenSSL from
security/openssl,
overwriting the version that was originally installed
in the base system.WITH_POSTGRESQLDefine this variable to specify the ability to
use a variant of the PostGreSQL database package such as
databases/postgresql72.
WITHOUT_X11If the port can be built both with and without
X support, then it should normally be built with
X support. If this variable is defined, then
the version that does not have X support should
be built instead.
Knob namingIt is recommended that porters use like-named knobs, for the
benefit of end-users and to help keep the number of knob names down.
A list of popular knob names can be found in the
KNOBS
file.Knob names should reflect what the knob is and does.
When a port has a lib-prefix in the PORTNAME
the lib-prefix should be dropped in knob naming.OPTIONSBackgroundThe OPTIONS variable gives the user who
installs the port a dialog with the available options and saves
them to /var/db/ports/portname/options.
Next time when the port has to be rebuild, the options are reused.
Never again you will have to remember all the twenty
WITH_* and
WITHOUT_* options you
used to build this port!When the user runs make config (or runs
make build for the first time), the framework will
check for
/var/db/ports/portname/options.
If that file does not exist, it will use the values of
OPTIONS to create a dialogbox where the options
can be enabled or disabled. Then the
options file is saved and the selected
variables will be used when building the port.Use make showconfig to see the saved
configuration. Use make rmconfig to remove the
saved configuration.SyntaxThe syntax for the OPTIONS variable is:
OPTIONS= OPTION "descriptive text" default ...
The value for default is either ON or
OFF. Multiple repetitions of these three fields
are allowed.OPTIONS definition must appear before
the inclusion of bsd.port.pre.mk.
The WITH_* and WITHOUT_*
variables can only be tested after the inclusion of
bsd.port.pre.mk.
Due to a deficiency in the infrastructure, you can only test
WITH_* variables for options which are
OFF by default, and
WITHOUT_* variables for options which
default to ON. The reasoning behind this:
when packages are built with PACKAGE_BUILDING or
BATCH defined, the config
target is not run, and therefore no OPTIONS
are selected. This would cause make depends and
make describe to break for ports not following
the aforementioned rule.ExampleSimple use of OPTIONSOPTIONS= FOO "Enable option foo" On \
BAR "Support feature bar" Off
.include <bsd.port.pre.mk>
.if defined(WITHOUT_FOO)
CONFIGURE_ARGS+= --without-foo
.else
CONFIGURE_ARGS+= --with-foo
.endif
.if defined(WITH_BAR)
RUN_DEPENDS+= bar:${PORTSDIR}/bar/bar
.endif
.include <bsd.port.post.mk>Feature auto-activationWhen using a GNU configure script, keep an eye on which optional
features are activated by auto-detection. Explicitly disable
optional features you do not wish to be used by passing respective
--without-xxx or --disable-xxx
in CONFIGURE_ARGS.Wrong handling of an option.if defined(WITH_FOO)
LIB_DEPENDS+= foo.0:${PORTSDIR}/devel/foo
CONFIGURE_ARGS+= --enable-foo
.endifIn the example above, imagine a library libfoo is installed on
the system. User does not want this application to use libfoo, so he
toggled the option off in the make config dialog.
But the application's configure script detects the library present in
the system and includes its support in the resulting executable. Now
when user decides to remove libfoo from the system, the ports system
does not protest (no dependency on libfoo was recorded) but the
application breaks.Correct handling of an option.if defined(WITH_FOO)
LIB_DEPENDS+= foo.0:${PORTSDIR}/devel/foo
CONFIGURE_ARGS+= --enable-foo
.else
CONFIGURE_ARGS+= --disable-foo
.endifIn the second example, the library libfoo is explicitly disabled.
The configure script does not enable related features in the
application, despite library's presence in the system.Specifying the working directoryEach port is extracted in to a working directory, which must be
writable. The ports system defaults to having the
DISTFILES unpack in to a directory called
${DISTNAME}. In other words, if you have
set:PORTNAME= foo
PORTVERSION= 1.0then the port's distribution files contain a top-level directory,
foo-1.0, and the rest of the files are located
under that directory.There are a number of variables you can override if that is not the
case.WRKSRCThe variable lists the name of the directory that is created when
the application's distfiles are extracted. If our previous example
extracted into a directory called foo (and not
foo-1.0) you would write:WRKSRC= ${WRKDIR}/fooor possiblyWRKSRC= ${WRKDIR}/${PORTNAME}NO_WRKSUBDIRIf the port does not extract in to a subdirectory at all then
you should set NO_WRKSUBDIR to indicate
that.NO_WRKSUBDIR= yesCONFLICTSIf your package cannot coexist with other packages
(because of file conflicts, runtime incompatibility, etc.),
list the other package names in the CONFLICTS
variable. You can use shell globs like * and
? here. Packages names should be
enumerated the same way they appear in
/var/db/pkg. Please make sure that
CONFLICTS does not match this port's
package itself, or else forcing its installation with
FORCE_PKG_REGISTER will no longer work.
CONFLICTS automatically sets
IGNORE, which is more fully documented
in .Special considerationsThere are some more things you have to take into account when you
create a port. This section explains the most common of those.Shared LibrariesIf your port installs one or more shared libraries, define a
USE_LDCONFIG make variable, which will instruct
a bsd.port.mk to run
${LDCONFIG} -m on the directory where the
new library is installed (usually
PREFIX/lib) during
post-install target to register it into the
shared library cache. This variable, when defined, will also
facilitate addition of an appropriate
@exec /sbin/ldconfig -m and
@unexec /sbin/ldconfig -R pair into your
pkg-plist file, so that a user who installed
the package can start using the shared library immediately and
de-installation will not cause the system to still believe the
library is there.USE_LDCONFIG= yesIf you need, you can override the default directory
by setting the USE_LDCONFIG
value to a list of directories into which
shared libraries are to be installed. For example if your port
installs shared libraries into
PREFIX/lib/foo and
PREFIX/lib/bar directories
you could use the following in your
Makefile:USE_LDCONFIG= ${PREFIX}/lib/foo ${PREFIX}/lib/barPlease
double-check, often this is not necessary at all or can be avoided
through -rpath or setting LD_RUN_PATH
during linking (see lang/moscow_ml
for an example), or through a shell-wrapper which sets
LD_LIBRARY_PATH before invoking the binary, like
www/mozilla does.When installing 32-bit libraries on 64-bit system, use
USE_LDCONFIG32 instead.Try to keep shared library version numbers in the
libfoo.so.0 format. Our runtime linker only
cares for the major (first) number.When the major library version number increments in the update
to the new port version, all other ports that link to the affected
library should have their PORTREVISION incremented,
to force recompilation with the new library version.If the port installs shared libraries with long version numbers,
e.g. libfoo.so.0.2.9, the ports infrastructure
will try to rename the files. Define
NO_FILTER_SHLIBS to disable this
functionality.Ports with distribution restrictionsLicenses vary, and some of them place restrictions on how the
application can be packaged, whether it can be sold for profit, and so
on.It is your responsibility as a porter to read the licensing
terms of the software and make sure that the FreeBSD project will
not be held accountable for violating them by redistributing the
source or compiled binaries either via FTP/HTTP or CD-ROM. If in doubt,
please contact the &a.ports;.In situations like this, the variables described in the following
sections can be set.NO_PACKAGEThis variable indicates that we may not generate a binary
package of the application. For instance, the license may
disallow binary redistribution, or it may prohibit distribution
of packages created from patched sources.However, the port's DISTFILES may be
freely mirrored on FTP/HTTP. They may also be distributed on
a CD-ROM (or similar media) unless NO_CDROM
is set as well.NO_PACKAGE should also be used if the binary
package is not generally useful, and the application should always
be compiled from the source code. For example, if the application
has configuration information that is site specific hard coded in to
it at compile time, set NO_PACKAGE.NO_PACKAGE should be set to a string
describing the reason why the package should not be
generated.NO_CDROMThis variable alone indicates that, although we are allowed
to generate binary packages, we may put neither those packages
nor the port's DISTFILES onto a CD-ROM (or
similar media) for resale. However, the binary packages and
the port's DISTFILES will still be available
via FTP/HTTP. If this variable is set along with
NO_PACKAGE, then only the port's
DISTFILES will be available, and only via
FTP/HTTP.NO_CDROM should be set to a string
describing the reason why the port cannot be redistributed
on CD-ROM. For instance, this should be used if the port's license
is for non-commercial use only.NOFETCHFILESFiles defined in the NOFETCHFILES
variable are not fetchable from any of the
MASTER_SITES. An example of such a
file is when the file is supplied on CD-ROM by the
vendor.Tools which check for the availability of these files
on the MASTER_SITES should ignore these
files and not report about them.RESTRICTEDSet this variable alone if the application's license permits
neither mirroring the application's DISTFILES
nor distributing the binary package in any way.NO_CDROM or NO_PACKAGE
should not be set along with RESTRICTED
since the latter variable implies the former ones.RESTRICTED should be set to a string
describing the reason why the port cannot be redistributed.
Typically, this indicates that the port contains proprietary
software and that the user will need to manually download the
DISTFILES, possibly after registering for the
software or agreeing to accept the terms of an
EULA.RESTRICTED_FILESWhen RESTRICTED or NO_CDROM
is set, this variable defaults to ${DISTFILES}
${PATCHFILES}, otherwise it is empty. If only some of the
distribution files are restricted, then set this variable to list
them.Note that the port committer should add an entry to
/usr/ports/LEGAL for every listed distribution
file, describing exactly what the restriction entails.Building mechanismsmake, gmake, and
imakeIf your port uses GNU make, set
USE_GMAKE=yes.
Variables for ports related to gmakeVariableMeansUSE_GMAKEThe port requires gmake to
build.GMAKEThe full path for gmake if it is not
in the PATH.
If your port is an X application that creates
Makefile files from
Imakefile files using
imake, then set
USE_IMAKE=yes. This will cause the
configure stage to automatically do an xmkmf -a.
If the flag is a problem for your port, set
XMKMF=xmkmf. If the port uses
imake but does not understand the
install.man target,
NO_INSTALL_MANPAGES=yes should be set.If your port's source Makefile has
something else than all as the main build
target, set ALL_TARGET accordingly. Same goes
for install and
INSTALL_TARGET.configure scriptIf your port uses the configure script to
generate Makefile files from
Makefile.in files, set
GNU_CONFIGURE=yes. If you want to give extra
arguments to the configure script (the default
argument is --prefix=${PREFIX}
${CONFIGURE_TARGET}), set those
extra arguments in CONFIGURE_ARGS. Extra
environment variables can be passed using
CONFIGURE_ENV variable.If your package uses GNU configure, and
the resulting executable file has a strange name
like
i386-portbld-freebsd4.7-appname,
you will need to additionally override the
CONFIGURE_TARGET variable to specify the
target in the way required by scripts generated by recent
versions of autoconf. Add the following line
immediately after the GNU_CONFIGURE=yes line
in your Makefile:CONFIGURE_TARGET=--build=${MACHINE_ARCH}-portbld-freebsd${OSREL}
Variables for ports that use configureVariableMeansGNU_CONFIGUREThe port uses configure script to
prepare build.HAS_CONFIGURESame as GNU_CONFIGURE, except
default configure target is not added to
CONFIGURE_ARGS.CONFIGURE_ARGSAdditional arguments passed to
configure script.CONFIGURE_ENVAdditional environment variables to be set
for configure script run.CONFIGURE_TARGETOverride default configure target. Default value is
${MACHINE_ARCH}-portbld-freebsd${OSREL}.
Using sconsIf your port uses SCons, define
USE_SCONS=yes.
Variables for ports that use sconsVariableMeansSCONS_ARGSPort specific SCons flags passed to the SCons
environment.SCONS_BUILDENVVariables to be set in system environment.SCONS_ENVVariables to be set in SCons environment.SCONS_TARGETLast argument passed to SCons, similar to
MAKE_TARGET.
Using GNU autotoolsIntroductionThe various GNU autotools provide an abstraction mechanism for
building a piece of software over a wide variety of operating
systems and machine architectures. Within the Ports Collection,
an individual port can make use of these tools via a simple
construct:USE_AUTOTOOLS= tool:version[:operation] ...At the time of writing, tool can be
one of libtool, libltdl,
autoconf, autoheader,
automake or aclocal.version specifies the particular
tool revision to be used (see
devel/{automake,autoconf,libtool}[0-9]+ for
valid versions).operation is an optional extension
to modify how the tool is used.Multiple tools can be specified at once, either by including
them all on a single line, or using the +=
Makefile construct.Before proceeding any further, it cannot be stressed highly
enough that the constructs discussed here are for use ONLY in
building other ports. For cross-development work, the
devel/gnu-{automake,autoconf,libtool} ports
should be used, such as within an IDE. devel/anjuta and devel/kdevelop (GNOME and KDE
respectively) are good examples of how to achieve this.libtoolShared libraries using the GNU building framework usually use
libtool to adjust the compilation and
installation of shared libraries to match the specifics of the
underlying operating system. The usual practice is to use copy of
libtool bundled with the application. In case
you need to use external libtool, you can use
the version provided by The Ports Collection:USE_AUTOTOOLS= libtool:version[:env]With no additional operations,
libtool:version tells
the building framework to patch the configure script with the
system-installed copy of libtool.
The GNU_CONFIGURE is implied.
Further, a number of make and shell
variables will be assigned for onward use by the port. See
bsd.autotools.mk for details.With the :env operation, only the
environment will be set up.PreviouslyUSE_AUTOTOOLS constructUSE_LIBTOOL_VER=15libtool:15USE_INC_LIBTOOL_VER=15not in use anymoreWANT_LIBTOOL_VER=15libtool:15:envFinally, LIBTOOLFLAGS and
LIBTOOLFILES can be optionally set to override
the most likely arguments to, and files patched by,
libtool. Most ports are unlikely to need this.
See bsd.autotools.mk for further
details.libltdlSome ports make use of the libltdl library
package, which is part of the libtool suite.
Use of this library does not automatically necessitate the use of
libtool itself, so a separate construct is
provided.USE_AUTOTOOLS= libltdl:versionCurrently, all this does is to bring in a
LIB_DEPENDS on the appropriate
libltdl port, and is provided as a convenience
function to help eliminate any dependencies on the autotools ports
outside of the USE_AUTOTOOLS framework. There
are no optional operations for this tool.PreviouslyUSE_AUTOTOOLS constructUSE_LIBLTDL=YESlibltdl:15autoconf and
autoheaderSome ports do not contain a configure script, but do contain an
autoconf template in the configure.ac file.
You can use the following assignments to let
autoconf create the configure script, and also
have autoheader create template headers for use
by the configure script.USE_AUTOTOOLS= autoconf:version[:env]andUSE_AUTOTOOLS= autoheader:versionwhich also implies the use of
autoconf:version.Similarly to libtool, the inclusion of the
optional :env operation simply sets up the
environment for further use. Without it, patching and
reconfiguration of the port is carried out.PreviouslyUSE_AUTOTOOLS constructUSE_AUTOCONF_VER=213autoconf:213WANT_AUTOCONF_VER=259autoconf:259:envUSE_AUTOHEADER_VER=253autoheader:253 (implies
autoconf:253)The additional optional variables
AUTOCONF_ARGS and
AUTOHEADER_ARGS can be overridden by the port
Makefile if specifically requested. As with
the libtool equivalents, most ports are unlikely
to need this.automake and
aclocalSome packages only contain Makefile.am
files. These have to be converted into
Makefile.in files using
automake, and the further processed by
configure to generate an actual
Makefile.Similarly, packages occasionally do not ship with included
aclocal.m4 files, again required to build the
software. This can be achieved with aclocal,
which scans configure.ac or
configure.in.aclocal has a similar relationship to
automake as autoheader does
to autoconf, described in the previous section.
aclocal implies the use of
automake, thus we have:USE_AUTOTOOLS= automake:version[:env]andUSE_AUTOTOOLS= aclocal:versionwhich also implies the use of
automake:version.Similarly to libtool and
autoconf, the inclusion of the optional
:env operation simply sets up the environment
for further use. Without it, reconfiguration of the port is
carried out.PreviouslyUSE_AUTOTOOLS constructUSE_AUTOMAKE_VER=14automake:14WANT_AUTOMAKE_VER=15automake:15:envUSE_ACLOCAL_VER=19aclocal:19 (implies
automake:19)As with
autoconf and autoheader, both
automake and aclocal have
optional argument variables, AUTOMAKE_ARGS and
ACLOCAL_ARGS respectively, which may be
overriden by the port Makefile if
required.Using GNU gettextBasic usageIf your port requires gettext,
just set USE_GETTEXT to yes,
and your port will grow the dependency on devel/gettext. The value of
USE_GETTEXT can also specify the required
version of the libintl library, the basic
part of gettext, but using this
feature is strongly discouraged:
Your port should work with just the current version of
devel/gettext.A rather common case is a port using
gettext and configure.
Generally, GNU configure should be
able to locate gettext automatically.
If it ever fails to, hints at the location of
gettext can be passed in
CPPFLAGS and LDFLAGS as
follows:USE_GETTEXT= yes
CPPFLAGS+= -I${LOCALBASE}/include
LDFLAGS+= -L${LOCALBASE}/lib
GNU_CONFIGURE= yes
CONFIGURE_ENV= CPPFLAGS="${CPPFLAGS}" \
LDFLAGS="${LDFLAGS}"Of course, the code can be more compact if there are no
more flags to pass to configure:USE_GETTEXT= yes
GNU_CONFIGURE= yes
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
LDFLAGS="-L${LOCALBASE}/lib"Optional usageSome software products allow for disabling NLS,
e.g., through passing to
configure. In that case, your port
should use gettext conditionally,
depending on the status of WITHOUT_NLS.
For ports of low to medium complexity, you can rely on the
following idiom:GNU_CONFIGURE= yes
.if !defined(WITHOUT_NLS)
USE_GETTEXT= yes
PLIST_SUB+= NLS=""
.else
CONFIGURE_ARGS+= --disable-nls
PLIST_SUB+= NLS="@comment "
.endifThe next item on your to-do list is to arrange so that
the message catalog files are included in the packing list
conditionally. The Makefile part of
this task is already provided by the idiom. It is explained
in the section on advanced
pkg-plist practices. In a
nutshell, each occurrence of %%NLS%% in
pkg-plist will be replaced by
@comment if NLS is
disabled, or by a null string if NLS is enabled. Consequently,
the lines prefixed by %%NLS%% will become
mere comments in the final packing list if NLS is off;
otherwise the prefix will be just left out. All you need
to do now is insert %%NLS%% before each
path to a message catalog file in pkg-plist.
For example:%%NLS%%share/locale/fr/LC_MESSAGES/foobar.mo
%%NLS%%share/locale/no/LC_MESSAGES/foobar.moIn high complexity cases, you may need to use more advanced
techniques than the recipe given here, such as dynamic packing list generation.Handling message catalog directoriesThere is a point to note about installing message catalog
files. The target directories for them, which reside under
LOCALBASE/share/locale,
should rarely be created and removed by your port. The
most popular languages have their respective directories
listed in /etc/mtree/BSD.local.dist;
that is, they are a part of the base system. The directories
for many other languages are governed by the devel/gettext port. You may want
to consult its pkg-plist and see whether
your port is going to install a message catalog file for a
unique language.Using perlIf MASTER_SITES is set to
MASTER_SITE_PERL_CPAN, then preferred value of
MASTER_SITE_SUBDIR is top-level hierarchy name.
For example, the recommend value for p5-Module-Name
is Module. The top-level hierarchy can be examined
at cpan.org.
This keeps the port working when the author of the module
changes.The exception to this rule is when the relevant directory does not
exist or the distfile does not exist in the directory. In such case, using author's id as
MASTER_SITE_SUBDIR is allowed.
Variables for ports that use perlVariableMeansUSE_PERL5Says that the port uses perl 5 to build and run.USE_PERL5_BUILDSays that the port uses perl 5 to build.USE_PERL5_RUNSays that the port uses perl 5 to run.PERLThe full path of perl 5, either in the
system or installed from a port, but without the version
number. Use this if you need to replace
#!lines in scripts.PERL_CONFIGUREConfigure using Perl's MakeMaker. It implies
USE_PERL5.PERL_MODBUILDConfigure, build and install using Module::Build. It
implies PERL_CONFIGURE.Read only variablesPERL_VERSIONThe full version of perl installed (e.g.,
5.00503).PERL_VERThe short version of perl installed (e.g.,
5.005).PERL_LEVELThe installed perl version as an integer of the form MNNNPP
(e.g., 500503).PERL_ARCHWhere perl stores architecture dependent libraries.
Defaults to ${ARCH}-freebsd.PERL_PORTName of the perl port that is
installed (e.g., perl5).SITE_PERLDirectory name where site specific
perl packages go.
This value is added to PLIST_SUB.
Ports of Perl modules, which do not have an official website,
should link cpan.org in the WWW line of a
pkg-descr file. The preferred URL form is
http://search.cpan.org/dist/Module-Name/
(including the trailing slash).Using X11Variable definitions
Variables for ports that use XUSE_X_PREFIXThe port installs in X11BASE_REL, not
PREFIX.USE_XLIBThe port uses the X libraries.USE_MOTIFThe port uses the Motif toolkit.USE_IMAKEThe port uses imake. Implies
USE_X_PREFIX.XMKMFSet to the path of xmkmf if not in the
PATH. Defaults to xmkmf
-a.
Variables for depending on individual parts of X11X_IMAKE_PORTPort providing imake and several
other utilities used to build X11.X_LIBRARIES_PORTPort providing X11 libraries.X_CLIENTS_PORTPort providing X clients.X_SERVER_PORTPort providing X server.X_FONTSERVER_PORTPort providing font server.X_PRINTSERVER_PORTPort providing print server.X_VFBSERVER_PORTPort providing virtual framebuffer server.X_NESTSERVER_PORTPort providing a nested X server.X_FONTS_ENCODINGS_PORTPort providing encodings for fonts.X_FONTS_MISC_PORTPort providing miscellaneous bitmap fonts.X_FONTS_100DPI_PORTPort providing 100dpi bitmap fonts.X_FONTS_75DPI_PORTPort providing 75dpi bitmap fonts.X_FONTS_CYRILLIC_PORTPort providing cyrillic bitmap fonts.X_FONTS_TTF_PORTPort providing &truetype; fonts.X_FONTS_TYPE1_PORTPort providing Type1 fonts.X_MANUALS_PORTPort providing developer oriented manual pages
Using X11 related variables in port# Use X11 libraries and depend on
# font server as well as cyrillic fonts.
RUN_DEPENDS= ${X11BASE}/bin/xfs:${X_FONTSERVER_PORT} \
${X11BASE}/lib/X11/fonts/cyrillic/crox1c.pcf.gz:${X_FONTS_CYRILLIC_PORT}
USE_XLIB= yesPorts that require MotifIf your port requires a Motif library, define
USE_MOTIF in the Makefile.
Default Motif implementation is
x11-toolkits/open-motif.
Users can choose
x11-toolkits/lesstif instead
by setting WANT_LESSTIF variable.The MOTIFLIB variable will be set by
bsd.port.mk to reference the appropriate
Motif library. Please patch the source of your port to
use ${MOTIFLIB} wherever the Motif library is referenced in the original
Makefile or
Imakefile.There are two common cases:If the port refers to the Motif library as
-lXm in its Makefile or
Imakefile, simply substitute
${MOTIFLIB} for it.If the port uses XmClientLibs in its
Imakefile, change it to
${MOTIFLIB} ${XTOOLLIB}
${XLIB}.Note that MOTIFLIB (usually) expands to
-L/usr/X11R6/lib -lXm or
/usr/X11R6/lib/libXm.a, so there is no need to
add -L or -l in front.X11 fontsIf your port installs fonts for the X Window System, put them in
X11BASE/lib/X11/fonts/local.Getting fake DISPLAY using XvfbSome applications require a working X11 display for compilation to
succeed. This pose a problem for the FreeBSD package building
cluster, which operates headless. When the following canonical hack
is used, the package cluster will start the virtual framebuffer
X server. The working DISPLAY is then passed
to the build..if defined(PACKAGE_BUILDING)
BUILD_DEPENDS+= Xvfb:${X_VFBSERVER_PORT} \
${X11BASE}/lib/X11/fonts/misc/8x13O.pcf.gz:${X_FONTS_MISC_PORT}
.endifDesktop entriesDesktop Entries (Freedesktop
standard) can be easily created in your port using
DESKTOP_ENTRIES variable. These entries do
show up in application menus of compliant desktop environments
like GNOME or KDE. The .desktop file will
be created, installed, and added to the
pkg-plist automatically. Syntax is:DESKTOP_ENTRIES= "NAME" "COMMENT" "ICON" "COMMAND" "CATEGORY" StartupNotifyThe list of possible categories is available on the Freedesktop
website. The StartupNotify
indicates, if the application will clear the status in startup
notification aware environment.Example:DESKTOP_ENTRIES= "ToME" "Roguelike game based on JRR Tolkien's work" \
"${DATADIR}/xtra/graf/tome-128.png" \
"tome -v -g" "Application;Game;RolePlaying" \
falseUsing GNOMEThe FreeBSD/GNOME project uses its own set of variables
to define which GNOME components a
particular port uses. A
comprehensive
list of these variables exists within the FreeBSD/GNOME
project's homepage.Using KDE
Variables for ports that use KDEUSE_QT_VERThe port uses the Qt toolkit. Possible values are
1 and
3; each specify the major version
of Qt to use. Sets both MOC and
QTCPPFLAGSto default appropriate
values.USE_KDELIBS_VERThe port uses KDE libraries. Possible values are
3; each specify the major version
of KDE to use. Implies USE_QT_VER
of the appropriate version.USE_KDEBASE_VERThe port uses KDE base. Possible values are
3; each specify the major version
of KDE to use. Implies USE_KDELIBS_VER
of the appropriate version.MOCSet to the path of moc.
Default set according to USE_QT_VER
value.QTCPPFLAGSSet the CPPFLAGS to use when
processing Qt code. Default set according to
USE_QT_VER value.
Using JavaVariable definitionsIf your port needs a Java™ Development Kit (JDK) to
either build, run or even extract the distfile, then it should
define USE_JAVA.There are several JDKs in the ports collection, from various
vendors, and in several versions. If your port must use one of
these versions, you can define which one. The most current
version is java/jdk15.
Variables that may be set by ports that use JavaVariableMeansUSE_JAVAShould be defined for the remaining variables to have any
effect.JAVA_VERSIONList of space-separated suitable Java versions for
the port. An optional "+" allows you to
specify a range of versions (allowed values:
1.1[+] 1.2[+] 1.3[+] 1.4[+]).JAVA_OSList of space-separated suitable JDK port operating
systems for the port (allowed values: native
linux).JAVA_VENDORList of space-separated suitable JDK port vendors for
the port (allowed values: freebsd bsdjava sun ibm
blackdown).JAVA_BUILDWhen set, it means that the selected JDK port should
be added to the build dependencies of the port.JAVA_RUNWhen set, it means that the selected JDK port should
be added to the run dependencies of the port.JAVA_EXTRACTWhen set, it means that the selected JDK port should
be added to the extract dependencies of the port.USE_JIKESWhether the port should or should not use the
jikes bytecode compiler to build. When
no value is set for this variable, the port will use
jikes to build if available. You may
also explicitly forbid or enforce the use of
jikes (by setting 'no'
or 'yes'). In the later case, devel/jikes will be added to build
dependencies of the port. In any case that jikes
is actually used in place of javac, then the
HAVE_JIKES variable is defined by
bsd.java.mk.
Below is the list of all settings a port will receive after
setting USE_JAVA:
Variables provided to ports that use JavaVariableValueJAVA_PORTThe name of the JDK port (e.g.
'java/jdk14').JAVA_PORT_VERSIONThe full version of the JDK port (e.g.
'1.4.2'). If you only need the first
two digits of this version number, use
${JAVA_PORT_VERSION:C/^([0-9])\.([0-9])(.*)$/\1.\2/}.JAVA_PORT_OSThe operating system used by the JDK port (e.g.
'linux').JAVA_PORT_VENDORThe vendor of the JDK port (e.g.
'sun').JAVA_PORT_OS_DESCRIPTIONDescription of the operating system used by the JDK port
(e.g. 'Linux').JAVA_PORT_VENDOR_DESCRIPTIONDescription of the vendor of the JDK port (e.g.
'FreeBSD Foundation').JAVA_HOMEPath to the installation directory of the JDK (e.g.
'/usr/local/jdk1.3.1').JAVACPath to the Java compiler to use (e.g.
'/usr/local/jdk1.1.8/bin/javac' or
'/usr/local/bin/jikes').JARPath to the jar tool to use (e.g.
'/usr/local/jdk1.2.2/bin/jar' or
'/usr/local/bin/fastjar').APPLETVIEWERPath to the appletviewer utility (e.g.
'/usr/local/linux-jdk1.2.2/bin/appletviewer').JAVAPath to the java executable. Use
this for executing Java programs (e.g.
'/usr/local/jdk1.3.1/bin/java').JAVADOCPath to the javadoc utility
program.JAVAHPath to the javah program.JAVAPPath to the javap program.JAVA_KEYTOOLPath to the keytool utility program.
This variable is available only if the JDK is Java 1.2 or
higher.JAVA_N2APath to the native2ascii tool.JAVA_POLICYTOOLPath to the policytool program.
This variable is available only if the JDK is Java 1.2 or
higher.JAVA_SERIALVERPath to the serialver utility
program.RMICPath to the RMI stub/skeleton generator,
rmic.RMIREGISTRYPath to the RMI registry program,
rmiregistry.RMIDPath to the RMI daemon program rmid.
This variable is only available if the JDK is Java 1.2
or higher.JAVA_CLASSESPath to the archive that contains the JDK class
files. On JDK 1.2 or later, this is
${JAVA_HOME}/jre/lib/rt.jar. Earlier
JDKs used
${JAVA_HOME}/lib/classes.zip.HAVE_JIKESDefined whenever jikes is used by
the port (see USE_JIKES above).
You may use the java-debug make target
to get information for debugging your port. It will display the
value of many of the forecited variables.Additionally, the following constants are defined so all
Java ports may be installed in a consistent way:
Constants defined for ports that use JavaConstantValueJAVASHAREDIRThe base directory for everything related to Java.
Default: ${PREFIX}/share/java.
JAVAJARDIRThe directory where JAR files should be installed.
Default:
${JAVASHAREDIR}/classes.JAVALIBDIRThe directory where JAR files installed by other
ports are located. Default:
${LOCALBASE}/share/java/classes.
The related entries are defined in both
PLIST_SUB (documented in
) and
SUB_LIST.Building with AntWhen the port is to be built using Apache Ant, it has to
define USE_ANT. Ant is thus considered to be
the sub-make command. When no do-build target
is defined by the port, a default one will be set that simply
runs Ant according to MAKE_ENV,
MAKE_ARGS and ALL_TARGETS.
This is similar to the USE_GMAKE mechanism,
which is documented in .If jikes is used in place of
javac (see USE_JIKES in
), then Ant will automatically
use it to build the port.Best practicesWhen porting a Java library, your port should install the
JAR file(s) in ${JAVAJARDIR}, and everything
else under ${JAVASHAREDIR}/${PORTNAME}
(except for the documentation, see below). In order to reduce
the packing file size, you may reference the JAR file(s) directly
in the Makefile. Just use the following
statement (where myport.jar is the name
of the JAR file installed as part of the port):PLIST_FILES+= %%JAVAJARDIR%%/myport.jarWhen porting a Java application, the port usually installs
everything under a single directory (including its JAR
dependencies). The use of
${JAVASHAREDIR}/${PORTNAME} is strongly
encouraged in this regard. It is up the porter to decide
whether the port should install the additional JAR dependencies
under this directory or directly use the already installed ones
(from ${JAVAJARDIR}).Regardless of the type of your port (library or application),
the additional documentation should be installed in the
same location as for
any other port. The JavaDoc tool is known to produce a
different set of files depending on the version of the JDK that
is used. For ports that do not enforce the use of a particular
JDK, it is therefore a complex task to specify the packing list
(pkg-plist). This is one reason why
porters are strongly encouraged to use the
PORTDOCS macro. Moreover, even if you can
predict the set of files that will be generated by
javadoc, the size of the resulting
pkg-plist advocates for the use of
PORTDOCS.The default value for DATADIR is
${PREFIX}/share/${PORTNAME}. It is a good
idea to override DATADIR to
${JAVASHAREDIR}/${PORTNAME} for Java ports.
Indeed, DATADIR is automatically added to
PLIST_SUB (documented in ) so you may use
%%DATADIR%% directly in
pkg-plist.As for the choice of building Java ports from source or
directly installing them from a binary distribution, there is
no defined policy at the time of writing. However, people from
the &os; Java Project
encourage porters to have their ports built from source whenever
it is a trivial task.All the features that have been presented in this section
are implemented in bsd.java.mk. If you
ever think that your port needs more sophisticated Java support,
please first have a look at the
bsd.java.mk CVS log as it usually takes some time to
document the latest features. Then, if you think the support
you are lacking would be beneficial to many other Java ports,
feel free to discuss it on the &a.java;.Although there is a java category for
PRs, it refers to the JDK porting effort from the &os; Java
project. Therefore, you should submit your Java port in the
ports category as for any other port, unless
the issue you are trying to resolve is related to either a JDK
implementation or bsd.java.mk.Similarly, there is a defined policy regarding the
CATEGORIES of a Java port, which is detailed
in .Using Apache and PHPApache
Variables for ports that use ApacheUSE_APACHEThe port requires Apache. Possible values:
yes (gets any version),
1.3, 2.0,
2.2, 2.0+,
etc. Default dependency is on version
1.3.WITH_APACHE2The port requires Apache 2.0. Without this variable,
the port will depend on Apache 1.3. This variable is
deprecated and should not be used anymore.APXSFull path to the apxs binary.
Can be overriden in your port.HTTPDFull path to the httpd binary.
Can be overriden in your port.APACHE_VERSIONThe version of present Apache installation (read-only
variable). This variable is only available after inclusion
of bsd.port.pre.mk. Possible values:
13, 20,
22.APACHEMODDIRDirectory for Apache modules. This variable is
automatically expanded in pkg-plist.APACHEINCLUDEDIRDirectory for Apache headers. This variable is
automatically expanded in pkg-plist.APACHEETCDIRDirectory for Apache configuration files. This
variable is automatically expanded in pkg-plist.
Useful variables for porting Apache modulesMODULENAMEName of the module. Default value is
PORTNAME. Example:
mod_helloSHORTMODNAMEShort name of the module. Automatically derived
from MODULENAME, but can be overriden.
Example: helloAP_FAST_BUILDUse apxs to compile and install
the module.AP_GENPLISTAlso automatically creates
a pkg-plist.AP_INCAdds a directory to a header search path during
compilation.AP_LIBAdds a directory to a library search path during
compilation.AP_EXTRASAdditional flags to pass to
apxs.
Web applications should be installed into
PREFIX/www/appname
and should not assume Apache is present, unless they depend
on Apache explicitly. User may wish to run them on different
web server than Apache.PHP
Variables for ports that use PHPUSE_PHPThe port requires PHP. The value yes
adds a dependency on PHP. The list of required PHP extensions
can be specified instead. Example: pcre xml
gettextDEFAULT_PHP_VERSelects which major version of PHP will be installed as
a dependency when no PHP is installed yet. Default is
4. Possible values: 4,
5IGNORE_WITH_PHPThe port does not work with PHP of the given version.
Possible values: 4,
5USE_PHPIZEThe port will be built as a PHP extension.USE_PHPEXTThe port will be treated as a PHP extension, including
installation and registration in the extension registry.USE_PHP_BUILDSet PHP as a build dependency.WANT_PHP_CLIWant the CLI (command line) version of PHP.WANT_PHP_CGIWant the CGI version of PHP.WANT_PHP_MODWant the Apache module version of PHP.WANT_PHP_SCRWant the CLI or the CGI version of PHP.WANT_PHP_WEBWant the Apache module or the CGI version of PHP.
PEAR modulesPorting PEAR modules is a very simple process.Use the variables FILES,
TESTS, DATA,
SQLS, SCRIPTFILES,
DOCS and EXAMPLES to list the
files you want to install. All listed files will be automatically
installed into the appropriate locations and added to
pkg-plist.Include
${PORTSDIR}/devel/pear/bsd.pear.mk
on the last line of the Makefile.Example Makefile for PEAR classPORTNAME= Date
PORTVERSION= 1.4.3
CATEGORIES= devel www pear
MAINTAINER= example@domain.com
COMMENT= PEAR Date and Time Zone Classes
BUILD_DEPENDS= ${PEARDIR}/PEAR.php:${PORTSDIR}/devel/pear-PEAR
RUN_DEPENDS= ${BUILD_DEPENDS}
FILES= Date.php Date/Calc.php Date/Human.php Date/Span.php \
Date/TimeZone.php
TESTS= test_calc.php test_date_methods_span.php testunit.php \
testunit_date.php testunit_date_span.php wknotest.txt \
bug674.php bug727_1.php bug727_2.php bug727_3.php \
bug727_4.php bug967.php weeksinmonth_4_monday.txt \
weeksinmonth_4_sunday.txt weeksinmonth_rdm_monday.txt \
weeksinmonth_rdm_sunday.txt
DOCS= TODO
_DOCSDIR= .
.include <bsd.port.pre.mk>
.include "${PORTSDIR}/devel/pear/bsd.pear.mk"
.include <bsd.port.post.mk>Using PythonThe Ports Collection supports parallel installation of multiple
Python versions. Ports should make sure to use a correct
python interpreter, according to the user-settable
PYTHON_VERSION variable. Most prominently, this
means replacing the path to python executable in
scripts with the value of PYTHON_CMD
variable.Ports that install files under PYTHON_SITELIBDIR
should use the pyXY- package name prefix, so their
package name embeds the version of Python they are installed
into.PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
Most useful variables for ports that use PythonUSE_PYTHONThe port needs Python. Minimal required version can be
specified with values such as 2.3+.
Version ranges can also be specified, by separating two version
numbers with a dash, e.g.: 2.1-2.3USE_PYDISTUTILSUse Python distutils for configuring, compiling and
installing. This is required when the port comes with
setup.py. This overrides the
do-build and
do-install targets
and may also override do-configure if
GNU_CONFIGURE is not defined.PYTHON_PKGNAMEPREFIXUsed as a PKGNAMEPREFIX to distinguish
packages for different Python versions.
Example: py24-PYTHON_SITELIBDIRLocation of the site-packages tree, that contains
installation path of Python (usually LOCALBASE).
The PYTHON_SITELIBDIR variable can be very
useful when installing Python modules.PYTHONPREFIX_SITELIBDIRThe PREFIX-clean variant of PYTHON_SITELIBDIR.
Always use
%%PYTHON_SITELIBDIR%% in
pkg-plist when possible. The default value of
%%PYTHON_SITELIBDIR%% is
lib/python%%PYTHON_VERSION%%/site-packagesPYTHON_CMDPython interpreter command line, including version
number.PYNUMERICDependency line for numeric extension.PYNUMPYDependency line for the new numeric extension, numpy.
(PYNUMERIC is deprecated by upstream vendor).PYXMLDependency line for XML extension (not needed for
Python 2.0 and higher as it is also in base distribution).USE_TWISTEDAdd dependency on twistedCore. The list of required
components can be specified as a value of this
variable. Example: web lore pair
flowUSE_ZOPEAdd dependency on Zope, a web application platform.
Change Python dependency to Python 2.3. Set
ZOPEBASEDIR containing a directory with
Zope installation.
A complete list of available variables can be found in
/usr/ports/Mk/bsd.python.mk.Using EmacsThis section is yet to be written.Using Ruby
Useful variables for ports that use RubyVariableDescriptionUSE_RUBYThe port requires Ruby.USE_RUBY_EXTCONFThe port uses extconf.rb to
configure.USE_RUBY_SETUPThe port uses setup.rb to
configure.RUBY_SETUPSet to the alternative name of
setup.rb. Common value is
install.rb.
The following table shows the selected variables available to port
authors via the ports infrastructure. These variables should be used
to install files into their proper locations. Use them in
pkg-plist as much as possible. These variables
should not be redefined in the port.
Selected read-only variables for ports that use RubyVariableDescriptionExample valueRUBY_PKGNAMEPREFIXUsed as a PKGNAMEPREFIX to distinguish
packages for different Ruby versions.ruby18-RUBY_VERSIONFull version of Ruby in the form of
x.y.z.1.8.2RUBY_SITELIBDIRArchitecture independent libraries installation
path./usr/local/lib/ruby/site_ruby/1.8RUBY_SITEARCHLIBDIRArchitecture dependent libraries installation
path./usr/local/lib/ruby/site_ruby/1.8/amd64-freebsd6RUBY_MODDOCDIRModule documentation installation path./usr/local/share/doc/ruby18/patsyRUBY_MODEXAMPLESDIRModule examples installation path./usr/local/share/examples/ruby18/patsy
A complete list of available variables can be found in
/usr/ports/Mk/bsd.ruby.mk.Using SDLThe USE_SDL variable is used to autoconfigure
the dependencies for ports which use an SDL based library like
devel/sdl12 and
x11-toolkits/sdl_gui.The following SDL libraries are recognized at the moment:sdl: devel/sdl12gfx: graphics/sdl_gfxgui: x11-toolkits/sdl_guiimage: graphics/sdl_imageldbad: devel/sdl_ldbadmixer: audio/sdl_mixermm: devel/sdlmmnet: net/sdl_netsound: audio/sdl_soundttf: graphics/sdl_ttfTherefore, if a port has a dependency on
net/sdl_net and
audio/sdl_mixer,
the syntax will be:USE_SDL= net mixerThe dependency devel/sdl12,
which is required by net/sdl_net and
audio/sdl_mixer, is automatically
added as well.If you use USE_SDL, it will automatically:Add a dependency on sdl12-config to
BUILD_DEPENDSAdd the variable SDL_CONFIG to
CONFIGURE_ENVAdd the dependencies of the selected libraries to the
LIB_DEPENDSTo check whether an SDL library is available, you can do it
with the WANT_SDL variable:WANT_SDL=yes
.include <bsd.port.pre.mk>
.if ${HAVE_SDL:Mmixer}!=""
USE_SDL+= mixer
.endif
.include <bsd.port.post.mk>Using wxWidgetsThis section describes the status of the
wxWidgets libraries in the ports tree and
its integration with the ports system.IntroductionThere are many versions of the
wxWidgets libraries which conflict
between them (install files under the same name). In the ports tree
this problem has been solved by installing each version under a
different name using version number suffixes.The obvious disadvantage of this is that each application has to
be modified to find the expected version. Fortunately, most of the
applications call the wx-config script to
determine the necessary compiler and linker flags. The script is
named differently for every available version. Majority of
applications respect an environment variable, or accept a configure
argument, to specify which wx-config script to
call. Otherwise they have to be patched.Version selectionTo make your port use a specific version of
wxWidgets there are two variables
available for defining (if only one is defined the other will be set
to a default value):
Variables to select wxWidgets
versionsVariableDescriptionDefault valueUSE_WXList of versions the port can useAll available versionsUSE_WX_NOTList of versions the port can not useNone
The following is a list of available
wxWidgets versions and the corresponding
ports in the tree:
Available wxWidgets
versionsVersionPort2.4x11-toolkits/wxgtk242.6x11-toolkits/wxgtk262.8x11-toolkits/wxgtk28
The versions starting from 2.5 also come in
Unicode version and are installed by a slave port named like the
normal one plus a -unicode suffix, but this can
be handled with variables (see ).The variables in can be set
to one or more of the following combinations separated by
spaces:
wxWidgets version
specificationsDescriptionExampleSingle version2.4Ascending range2.4+Descending range2.6-Full range (must be ascending)2.4-2.6
There are also some variables to select the preferred versions
from the available ones. They can be set to a list of versions, the
first ones will have higher priority.
Variables to select preferred
wxWidgets versionsNameDesigned forWANT_WX_VERthe portWITH_WX_VERthe user
Component selectionThere are other applications that, while not being
wxWidgets libraries, are related to them.
These applications can be specified in the
WX_COMPS variable. The following components are
available:
Available wxWidgets
componentsNameDescriptionVersion restrictionwxmain librarynonecontribcontributed librariesnonepythonwxPython
(Python bindings)2.4-2.6mozillawxMozilla2.4svgwxSVG2.6
The dependency type can be selected for each component by adding
a suffix separated by a semicolon. If not present then a default
type will be used (see ). The
following types are available:
Available wxWidgets dependency
typesNameDescriptionbuildComponent is required for building, equivalent to
BUILD_DEPENDSrunComponent is required for running, equivalent to
RUN_DEPENDSlibComponent is required for building and running,
equivalent to LIB_DEPENDS
The default values for the components are detailed in the
following table:
Selecting wxWidgets
componentsThe following fragment corresponds to a port which uses
wxWidgets version
2.4 and its contributed libraries.USE_WX= 2.4
WX_COMPS= wx contribUnicodeThe wxWidgets library supports
Unicode since version 2.5. In the ports tree
both versions are available and can be selected with the following
variables:
Variables to select Unicode in
wxWidgets
versionsVariableDescriptionDesigned forWX_UNICODEThe port works only with the
Unicode versionthe portWANT_UNICODEThe port works with both versions but prefers the
Unicode onethe portWITH_UNICODEThe port will use the Unicode versionthe userWITHOUT_UNICODEThe port will use the normal version if
supported (when WX_UNICODE is not
defined)the user
Do not use WX_UNICODE for ports that can
use both Unicode and normal versions. If you want the port to use
Unicode by default define WANT_UNICODE
instead.Detecting installed versionsTo detect an installed version you have to define
WANT_WX. If you do not set it to a specific
version then the components will have a version suffix. The
HAVE_WX variable will be filled after
detection.Detecting installed wxWidgets
versions and componentsThe following fragment can be used in a port that uses
wxWidgets if it is installed, or an
option is selected.WANT_WX= yes
.include <bsd.port.pre.mk>
.if defined(WITH_WX) || ${HAVE_WX:Mwx-2.4} != ""
USE_WX= 2.4
CONFIGURE_ARGS+=--enable-wx
.endifThe following fragment can be used in a port that enables
wxPython support if it is installed or
if an option is selected, in addition to
wxWidgets, both version
2.6.USE_WX= 2.6
WX_COMPS= wx
WANT_WX= 2.6
.include <bsd.port.pre.mk>
.if defined(WITH_WXPYTHON) || ${HAVE_WX:Mpython} != ""
WX_COMPS+= python
CONFIGURE_ARGS+=--enable-wxpython
.endifDefined variablesThe following variables are available in the port (after
defining one from ).
Variables defined for ports that use
wxWidgetsNameDescriptionWX_CONFIGThe path to the wxWidgetswx-config script (with different
name)WXRC_CMDThe path to the wxWidgetswxrc program (with different
name)WX_VERSIONThe wxWidgets version that
is going to be used (e.g., 2.6)WX_UNICODEIf not defined but Unicode is going to be used then it
will be defined
Processing in bsd.port.pre.mkIf you need to use the variables for running commands right
after including bsd.port.pre.mk you need to
define WX_PREMK.If you define WX_PREMK, then the version,
dependencies, components and defined variables will not change if
you modify the wxWidgets port variables
after including
bsd.port.pre.mk.Using wxWidgets variables in
commandsThe following fragment illustrates the use of
WX_PREMK by running the
wx-config script to obtain the full version
string, assign it to a variable and pass it to the program.USE_WX= 2.4
WX_PREMK= yes
.include <bsd.port.pre.mk>
.if exists(${WX_CONFIG})
VER_STR!= ${WX_CONFIG} --release
PLIST_SUB+= VERSION="${VER_STR}"
.endifThe wxWidgets variables can be
safely used in commands when they are inside targets without the
need of WX_PREMK.Additional configure argumentsSome GNU configure scripts can not find
wxWidgets with just the
WX_CONFIG environment variable set, requiring
additional arguments. The WX_CONF_ARGS variable
can be used for provide them.
Legal values for WX_CONF_ARGSPossible valueResulting argumentabsolute--with-wx-config=${WX_CONFIG}relative--with-wx=${X11BASE}
--with-wx-config=${WX_CONFIG:T}
Using LuaThis section describes the status of the
Lua libraries in the ports tree and its
integration with the ports system.IntroductionThere are many versions of the Lua
libraries and corresponding interpreters, which conflict between
them (install files under the same name). In the ports tree this
problem has been solved by installing each version under a different
name using version number suffixes.The obvious disadvantage of this is that each application has to
be modified to find the expected version. But it can be solved by
adding some additional flags to the compiler and linker.Version selectionTo make your port use a specific version of
Lua there are two variables available
for defining (if only one is defined the other will be set to a
default value):
Variables to select Lua
versionsVariableDescriptionDefault valueUSE_LUAList of versions the port can useAll available versionsUSE_LUA_NOTList of versions the port can not useNone
The following is a list of available
Lua versions and the corresponding ports
in the tree:
Available Lua versionsVersionPort4.0lang/lua45.0lang/lua505.1lang/lua
The variables in can be set
to one or more of the following combinations separated by
spaces:
Lua version specificationsDescriptionExampleSingle version4.0Ascending range5.0+Descending range5.0-Full range (must be ascending)5.0-5.1
There are also some variables to select the preferred versions
from the available ones. They can be set to a list of versions, the
first ones will have higher priority.
Variables to select preferred Lua
versionsNameDesigned forWANT_LUA_VERthe portWITH_LUA_VERthe user
Selecting the Lua versionThe following fragment is from a port which can use
Lua version 5.0 or
5.1, and uses 5.0 by
default. It can be overriden by the user using
WITH_LUA_VER.USE_LUA= 5.0-5.1
WANT_LUA_VER= 5.0Component selectionThere are other applications that, while not being
Lua libraries, are related to them.
These applications can be specified in the
LUA_COMPS variable. The following components are
available:
Available Lua componentsNameDescriptionVersion restrictionluamain librarynonetoluaLibrary for accesing C/C++ code4.0-5.0rubyRuby bindings4.0-5.0
There are more components but they are modules for the
interpreter, not used by applications (only by other
modules).The dependency type can be selected for each component by adding
a suffix separated by a semicolon. If not present then a default
type will be used (see ). The
following types are available:
Available Lua dependency
typesNameDescriptionbuildComponent is required for building, equivalent to
BUILD_DEPENDSrunComponent is required for running, equivalent to
RUN_DEPENDSlibComponent is required for building and running,
equivalent to LIB_DEPENDS
The default values for the components are detailed in the
following table:
Default Lua dependency
typesComponentDependency typelualib for 4.0-5.0
(shared) and build for
5.1 (static)toluabuild (static)rubylib (shared)
Selecting Lua componentsThe following fragment corresponds to a port which uses
Lua version 4.0 and
its Ruby bindings.USE_LUA= 4.0
LUA_COMPS= lua rubyDetecting installed versionsTo detect an installed version you have to define
WANT_LUA. If you do not set it to a specific
version then the components will have a version suffix. The
HAVE_LUA variable will be filled after
detection.Detecting installed Lua versions
and componentsThe following fragment can be used in a port that uses
Lua if it is installed, or an option is
selected.WANT_LUA= yes
.include <bsd.port.pre.mk>
.if defined(WITH_LUA5) || ${HAVE_LUA:Mlua-5.[01]} != ""
USE_LUA= 5.0-5.1
CONFIGURE_ARGS+=--enable-lua5
.endifThe following fragment can be used in a port that enables
tolua support if it is installed or if
an option is selected, in addition to
Lua, both version
4.0.USE_LUA= 4.0
LUA_COMPS= lua
WANT_LUA= 4.0
.include <bsd.port.pre.mk>
.if defined(WITH_TOLUA) || ${HAVE_LUA:Mtolua} != ""
LUA_COMPS+= tolua
CONFIGURE_ARGS+=--enable-tolua
.endifDefined variablesThe following variables are available in the port (after
defining one from ).
Variables defined for ports that use
LuaNameDescriptionLUA_VERThe Lua version that is
going to be used (e.g., 5.1)LUA_VER_SHThe Lua shared library major
version (e.g., 1)LUA_VER_STRThe Lua version without the
dots (e.g., 51)LUA_PREFIXThe prefix where Lua (and
components) is installedLUA_SUBDIRThe directory under ${PREFIX}/bin,
${PREFIX}/share and
${PREFIX}/lib where
Lua is installedLUA_INCDIRThe directory where Lua and
tolua header files are
installedLUA_LIBDIRThe directory where Lua and
tolua libraries are
installedLUA_MODLIBDIRThe directory where Lua
module libraries (.so) are
installedLUA_MODSHAREDIRThe directory where Lua
modules (.lua) are installedLUA_PKGNAMEPREFIXThe package name prefix used by
Lua modulesLUA_CMDThe path to the Lua
interpreterLUAC_CMDThe path to the Lua
compilerTOLUA_CMDThe path to the tolua
program
Telling the port where to find
LuaThe following fragment shows how to tell a port that uses a
configure script where the Lua header
files and libraries are.
USE_LUA= 4.0
GNU_CONFIGURE= yes
CONFIGURE_ENV= CPPFLAGS="-I${LUA_INCDIR}" LDFLAGS="-L${LUA_LIBDIR}"Processing in bsd.port.pre.mkIf you need to use the variables for running commands right
after including bsd.port.pre.mk you need to
define LUA_PREMK.If you define LUA_PREMK, then the version,
dependencies, components and defined variables will not change if
you modify the Lua port variables
after including
bsd.port.pre.mk.Using Lua variables in
commandsThe following fragment illustrates the use of
LUA_PREMK by running the
Lua interpreter to obtain the full
version string, assign it to a variable and pass it to the
program.USE_LUA= 5.0
LUA_PREMK= yes
.include <bsd.port.pre.mk>
.if exists(${LUA_CMD})
VER_STR!= ${LUA_CMD} -v
CFLAGS+= -DLUA_VERSION_STRING="${VER_STR}"
.endifThe Lua variables can be safely
used in commands when they are inside targets without the need of
LUA_PREMK.Starting and stopping services (rc scripts)rc.d scripts are used to start services on system
startup, and to give administrators a standard way of stopping,
starting and restarting the service. Ports integrate into
the system rc.d framework. Details on its usage
can be found in
the rc.d Handbook
chapter. Detailed explanation of available commands is
provided in
&man.rc.8; and &man.rc.subr.8;. Finally, there is
an article
on practical aspects of rc.d scripting.One or more rc scripts can be installed:USE_RC_SUBR= doormandScripts must be placed in the files
subdirectory and a .in suffix must be added to their
filename. The only difference from a base system rc.d script is that the
. /etc/rc.subr line must be replaced with the
. %%RC_SUBR%%, because older versions of &os;
do not have an /etc/rc.subr file. Standard
SUB_LIST expansions are used too.
Use of the %%PREFIX%%,
%%LOCALBASE%%, and
%%X11BASE%% expansions is strongly encouraged as well.
More on
SUB_LIST in the relevant section.Prior to &os; 6.1-RELEASE, integration with &man.rcorder.8; is available by using
USE_RCORDER instead of
USE_RC_SUBR.
However, use of this method is deprecated.As of &os; 6.1-RELEASE, local rc.d
scripts (including those installed by ports) are included in
the overall &man.rcorder.8; of the base system.Example simple rc.d script:#!/bin/sh
# PROVIDE: doormand
# REQUIRE: LOGIN
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# doormand_enable (bool): Set to NO by default.
# Set it to YES to enable doormand.
# doormand_config (path): Set to %%PREFIX%%/etc/doormand/doormand.cf
# by default.
#
. %%RC_SUBR%%
name="doormand"
rcvar=${name}_enable
command=%%PREFIX%%/sbin/${name}
pidfile=/var/run/${name}.pid
load_rc_config $name
: ${doormand_enable="NO"}
: ${doormand_config="%%PREFIX%%/etc/doormand/doormand.cf"}
command_args="-p $pidfile -f $doormand_config"
run_rc_command "$1"The "=" style of default variable assignment
is preferable to the ":=" style here, since the
former sets a default value only if the variable is unset,
and the latter sets one if the variable is unset
or null.
A user might very well include something like
doormand_flags="" in their
rc.conf.local file, and a variable
substitution using ":=" would inappropriately
override the user's intention.The suffix of the rc script is provided in
RC_SUBR_SUFFIX for further use in the port's
Makefile. Current versions of &os; does not add
any suffix to the script name, but older versions has used to add
.sh suffix.Stopping services at deinstallIt is possible to have a service stopped automatically as part of
the deinstall routine. We advise using this feature only when it's
absolutely necessary to stop a service before it's files go
away. Usually, it's up to the administrator's discretion to decide,
whether to stop the service on deinstall or not. Also note this
affects upgrades, too.Line like this goes to the pkg-plist:@stopdaemon doormandThe argument must match the content of
USE_RC_SUBR variable.Advanced pkg-plist practicesChanging pkg-plist based on make
variablesSome ports, particularly the p5- ports,
need to change their pkg-plist depending on
what options they are configured with (or version of
perl, in the case of p5-
ports). To make this easy, any instances in the
pkg-plist of %%OSREL%%,
%%PERL_VER%%, and
%%PERL_VERSION%% will be substituted for
appropriately. The value of %%OSREL%% is the
numeric revision of the operating system (e.g.,
4.9). %%PERL_VERSION%% is
the full version number of perl (e.g.,
5.00502) and %%PERL_VER%%
is the perl version number minus
the patchlevel (e.g., 5.005). Several other
%%VARS%% related to
port's documentation files are described in the relevant section.If you need to make other substitutions, you can set the
PLIST_SUB variable with a list of
VAR=VALUE
pairs and instances of
%%VAR%% will be
substituted with VALUE in the
pkg-plist.For instance, if you have a port that installs many files in a
version-specific subdirectory, you can put something likeOCTAVE_VERSION= 2.0.13
PLIST_SUB= OCTAVE_VERSION=${OCTAVE_VERSION}in the Makefile and use
%%OCTAVE_VERSION%% wherever the version shows up
in pkg-plist. That way, when you upgrade the port,
you will not have to change dozens (or in some cases, hundreds) of
lines in the pkg-plist.This substitution (as well as addition of any manual pages) will be done between
the pre-install and
do-install targets, by reading from
PLIST and writing to
TMPPLIST
(default:
WRKDIR/.PLIST.mktmp). So if
your port builds PLIST
on the fly, do so in or
before pre-install. Also, if your port
needs to edit the resulting file, do so in
post-install to a file named
TMPPLIST.Another possibility to modify port's packing list is based
on setting the variables PLIST_FILES and
PLIST_DIRS. The value of each variable
is regarded as a list of pathnames to
write to TMPPLIST
along with PLIST
contents. Names listed in PLIST_FILES
and PLIST_DIRS are subject to
%%VAR%%
substitution, as described above.
Except for that, names from PLIST_FILES
will appear in the final packing list unchanged,
while @dirrm will be
prepended to names from PLIST_DIRS.
To take effect, PLIST_FILES and
PLIST_DIRS must be set before
TMPPLIST is written,
i.e. in pre-install or earlier.Empty directoriesCleaning up empty directoriesDo make your ports remove empty directories when they are
de-installed. This is usually accomplished by adding
@dirrm lines for all directories that are
specifically created by the port. You need to delete subdirectories
before you can delete parent directories. :
lib/X11/oneko/pixmaps/cat.xpm
lib/X11/oneko/sounds/cat.au
:
@dirrm lib/X11/oneko/pixmaps
@dirrm lib/X11/oneko/sounds
@dirrm lib/X11/onekoHowever, sometimes @dirrm will give you
errors because other ports share the same directory. You
can use @dirrmtry to
remove only empty directories without warning.@dirrmtry share/doc/gimpThis will neither print any error messages nor cause
&man.pkg.delete.1; to exit abnormally even if
${PREFIX}/share/doc/gimp is not
empty due to other ports installing some files in there.Creating empty directoriesEmpty directories created during port installation need special
attention. They will not get created when installing the package,
because packages only store the files, and &man.pkg.add.1; creates
directories for them as needed. To make sure the empty directory
is created when installing the package, add this line to
pkg-plist above the corresponding
@dirrm line:@exec mkdir -p %D/share/foo/templatesConfiguration filesIf your port requires some configuration files in
PREFIX/etc, do
not just install them and list them in
pkg-plist. That will cause
&man.pkg.delete.1; to delete files carefully edited by
the user and a new installation to wipe them out.Instead, install sample files with a suffix
(filename.sample
will work well). Copy the sample file as the real configuration
file, if it does not exist. On deinstall, delete the configuration
file, but only if it was not modified by the user. You need to
handle this both in the port Makefile, and in
the pkg-plist (for installation from
the package).Example of the Makefile part:post-install:
@if [ ! -f ${PREFIX}/etc/orbit.conf ]; then \
${CP} -p ${PREFIX}/etc/orbit.conf.sample ${PREFIX}/etc/orbit.conf ; \
fiExample of the pkg-plist part:@unexec if cmp -s %D/etc/orbit.conf.sample %D/etc/orbit.conf; then rm -f %D/etc/orbit.conf; fi
etc/orbit.conf.sample
@exec if [ ! -f %D/etc/orbit.conf ] ; then cp -p %D/%F %B/orbit.conf; fiAlternatively, print out a message pointing out that the
user has to copy and edit the file before the software can be made
to work.Dynamic vs. static package listA static package list is a package list
which is available in the Ports Collection either as a
pkg-plist file (with or without variable
substitution), or embedded into the Makefile
via PLIST_FILES and PLIST_DIRS.
Even if the contents are auto-generated by a tool or a target
in the Makefile before the inclusion into the
Ports Collection by a committer, this is still considered a
static list, since it is possible to examine it without having
to download or compile the distfile.A dynamic package list is a package list
which is generated at the time the port is compiled based upon the
files and directories which are installed. It is not possible to
examine it before the source code of the ported application
is downloaded and compiled, or after running a make
clean.While the use of dynamic package lists is not forbidden,
maintainers should use static package lists wherever possible, as it
enables users to &man.grep.1; through available ports to discover,
for example, which port installs a certain file. Dynamic lists
should be primarily used for
complex ports where the package list changes drastically based upon
optional features of the port (and thus maintaining a static package
list is infeasible), or ports which change the
package list based upon the version of dependent software used (e.g.
ports which generate docs with
Javadoc).Maintainers who prefer dynamic package lists are encouraged to
add a new target to their port which generates the
pkg-plist file so that users may examine
the contents.Automated package list creationFirst, make sure your port is almost complete, with only
pkg-plist missing.Next, create a temporary directory tree into which your port can be
installed, and install any dependencies.&prompt.root; mkdir /var/tmp/$(make -V PORTNAME)
&prompt.root; mtree -U -f $(make -V MTREE_FILE) -d -e -p /var/tmp/$(make -V PORTNAME)
&prompt.root; make depends PREFIX=/var/tmp/$(make -V PORTNAME)Store the directory structure in a new file.&prompt.root; (cd /var/tmp/$(make -V PORTNAME) && find -d * -type d) | sort > OLD-DIRSCreate an empty pkg-plist file:&prompt.root; :>pkg-plistIf your port honors PREFIX (which it should)
you can then install the port and create the package list.&prompt.root; make install PREFIX=/var/tmp/$(make -V PORTNAME)
&prompt.root; (cd /var/tmp/$(make -V PORTNAME) && find -d * \! -type d) | sort > pkg-plistYou must also add any newly created directories to the packing
list.&prompt.root; (cd /var/tmp/$(make -V PORTNAME) && find -d * -type d) | sort | comm -13 OLD-DIRS - | sort -r | sed -e 's#^#@dirrm #' >> pkg-plistFinally, you need to tidy up the packing list by hand; it is not
all automated. Manual pages should be listed in
the port's Makefile under
MANn, and not in the
package list. User configuration files should be removed, or
installed as
filename.sample.
The info/dir file should not be listed
and appropriate install-info lines should
be added as noted in the info
files section. Any
libraries installed by the port should be listed as specified in the
shared libraries section.Alternatively, use the plist script in
/usr/ports/Tools/scripts/ to build the
package list automatically. The first step is the same as
above: take the first three lines, that is,
mkdir, mtree and
make depends. Then build and install the
port:&prompt.root; make install PREFIX=/var/tmp/$(make -V PORTNAME)And let plist create the
pkg-plist file:&prompt.root; /usr/ports/Tools/scripts/plist -Md -m $(make -V MTREE_FILE) /var/tmp/$(make -V PORTNAME) > pkg-plistThe packing list still has to be tidied up by hand as
stated above.The pkg-* filesThere are some tricks we have not mentioned yet about the
pkg-* files
that come in handy sometimes.pkg-messageIf you need to display a message to the installer, you may place
the message in pkg-message. This capability is
often useful to display additional installation steps to be taken
after a &man.pkg.add.1; or to display licensing
information.When some lines about the build-time knobs or warnings
have to be displayed, use ECHO_MSG. The
pkg-message file is only for
post-installation steps. Likewise, the distinction between
ECHO_MSG and ECHO_CMD
should be kept in mind. The former is for printing
informational text to the screen, while the latter is for
command pipelining.A good example for both can be found in
shells/bash2/Makefile:update-etc-shells:
@${ECHO_MSG} "updating /etc/shells"
@${CP} /etc/shells /etc/shells.bak
@( ${GREP} -v ${PREFIX}/bin/bash /etc/shells.bak; \
${ECHO_CMD} ${PREFIX}/bin/bash) >/etc/shells
@${RM} /etc/shells.bakThe pkg-message file does not need to be
added to pkg-plist. Also, it will not get
automatically printed if the user is using the port, not the
package, so you should probably display it from the
post-install target yourself.pkg-installIf your port needs to execute commands when the binary package
is installed with &man.pkg.add.1; you can do this via the
pkg-install script. This script will
automatically be added to the package, and will be run twice by
&man.pkg.add.1;: the first time as
${SH} pkg-install ${PKGNAME}
PRE-INSTALL and the second time as
${SH} pkg-install ${PKGNAME} POST-INSTALL.
$2 can be tested to determine which mode
the script is being run in. The PKG_PREFIX
environmental variable will be set to the package installation
directory. See &man.pkg.add.1; for
additional information.This script is not run automatically if you install the port
with make install. If you are depending on it
being run, you will have to explicitly call it from your port's
Makefile, with a line like
PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL}
${PKGNAME} PRE-INSTALL.pkg-deinstallThis script executes when a package is removed.
This script will be run twice by &man.pkg.delete.1;.
The first time as ${SH} pkg-deinstall ${PKGNAME}
DEINSTALL and the second time as
${SH} pkg-deinstall ${PKGNAME} POST-DEINSTALL.
pkg-reqIf your port needs to determine if it should install or not, you
can create a pkg-reqrequirements
script. It will be invoked automatically at
installation/de-installation time to determine whether or not
installation/de-installation should proceed.The script will be run at installation time by
&man.pkg.add.1; as
pkg-req ${PKGNAME} INSTALL.
At de-installation time it will be run by
&man.pkg.delete.1; as
pkg-req ${PKGNAME} DEINSTALL.Changing the names of
pkg-* filesAll the names of pkg-* files
are defined using variables so you can change them in your
Makefile if need be. This is especially useful
when you are sharing the same pkg-* files
among several ports or have to write to one of the above files (see
writing to places other than
WRKDIR for why it is a bad idea to write
directly into the pkg-* subdirectory).Here is a list of variable names and their default
values. (PKGDIR defaults to
${MASTERDIR}.)VariableDefault valueDESCR${PKGDIR}/pkg-descrPLIST${PKGDIR}/pkg-plistPKGINSTALL${PKGDIR}/pkg-installPKGDEINSTALL${PKGDIR}/pkg-deinstallPKGREQ${PKGDIR}/pkg-reqPKGMESSAGE${PKGDIR}/pkg-messagePlease change these variables rather than overriding
PKG_ARGS. If you change
PKG_ARGS, those files will not correctly be
installed in /var/db/pkg upon install from a
port.Making use of SUB_FILES and
SUB_LISTThe SUB_FILES and SUB_LIST
variables are useful for dynamic values in port files, such as the
installation PREFIX in
pkg-message.The SUB_FILES variable specifies a list
of files to be automatically modified. Each
file in the
SUB_FILES list must have a corresponding
file.in present
in FILESDIR. A modified version will
be created in WRKDIR. Files defined as a
value of USE_RC_SUBR (or the deprecated
USE_RCORDER)
are automatically added to the
SUB_FILES. For the files
pkg-message,
pkg-install, pkg-deinstall
and pkg-reg, the corresponding Makefile variable
is automatically set to point to the processed version.The SUB_LIST variable is a list of
VAR=VALUE pairs. For each pair
%%VAR%% will get replaced
with VALUE in each file listed in
SUB_FILES. Several common pairs are
automatically defined: PREFIX,
LOCALBASE, X11BASE,
DATADIR, DOCSDIR,
EXAMPLESDIR. Any line beginning with
@comment will be deleted from resulting files
after a variable substitution.The following example will replace %%ARCH%%
with the system architecture
in a pkg-message:SUB_FILES= pkg-message
SUB_LIST= ARCH=${ARCH}Note that for this example, the
pkg-message.in file must exist in
FILESDIR.Example of a good pkg-message.in:Now it is time to configure this package.
Copy %%PREFIX%%/share/examples/putsy/%%ARCH%%.conf into your home directory
as .putsy.conf and edit it.Testing your portRunning make describeSeveral of the &os; port maintenance tools, such as
&man.portupgrade.1;, rely on a database called
/usr/ports/INDEX which keeps track of such
items as port dependencies. INDEX is created
by the top-level ports/Makefile via
make index, which descends into each
port subdirectory and executes make describe
there. Thus, if make describe fails in any
port, no one can generate INDEX, and many
people will quickly become unhappy.It is important to be able to generate this file no
matter what options are present in make.conf,
so please avoid doing things such as using .error
statements when (for instance) a dependency is not satisfied.
(See .)If make describe produces a string
rather than an error message, you are probably safe. See
bsd.port.mk for the meaning of the
string produced.Also note that running a recent version of
portlint (as specified in the next section)
will cause make describe to be run
automatically.PortlintDo check your work with portlint
before you submit or commit it. portlint
warns you about many common errors, both functional and
stylistic. For a new (or repocopied) port,
portlint -A is the most thorough; for an
existing port, portlint -C is sufficient.Since portlint uses heuristics to
try to figure out errors, it can produce false positive
warnings. In addition, occasionally something that is
flagged as a problem really cannot be done in any other
way due to limitations in the ports framework. When in
doubt, the best thing to do is ask on &a.ports;.PREFIX and DESTDIRPREFIX determines the location where
the port will install. It is usually /usr/local,
or /opt. User can set PREFIX
to anything he wants. Your port must respect this variable.DESTDIR, if set by user, determines the
complete alternative environment, usually a jail, or an installed
system mounted elsewhere than /.
A port will actually install into
DESTDIR/PREFIX, and register
with the package database in DESTDIR/var/db/pkg.
It is very important to write ports that respect
DESTDIR.The value of PREFIX will be set
to LOCALBASE_REL (default
/usr/local). If
USE_X_PREFIX or USE_IMAKE is
set, PREFIX will be X11BASE_REL (default
/usr/X11R6). If
USE_LINUX_PREFIX is set, PREFIX
will be LINUXBASE_REL (default
/compat/linux).Avoiding the hard-coding of /usr/local or
/usr/X11R6 anywhere in the source will make the
port much more flexible and able to cater to the needs of other
sites. For X ports that use imake, this is
automatic; otherwise, this can often be done by simply replacing the
occurrences of /usr/local (or
/usr/X11R6 for X ports that do not use imake)
in the various Makefiles in the port to read
${PREFIX}, as this variable is automatically passed
down to every stage of the build and install processes.Make sure your application is not installing things in
/usr/local instead of PREFIX.
A quick test for this is to do this is:&prompt.root; make clean; make package PREFIX=/var/tmp/$(make -V PORTNAME)If anything is installed outside of PREFIX,
the package creation process will complain that it
cannot find the files.This does not test for the existence of internal references,
or correct use of LOCALBASE for references to
files from other ports. Testing the installation in
/var/tmp/$(make -V PORTNAME)
to do that while you have it installed would do that.Do not set USE_X_PREFIX unless your port
truly requires it (i.e., it needs to
reference files in X11BASE).The variable PREFIX can be reassigned in your
Makefile or in the user's environment.
However, it is strongly discouraged for individual ports to set this
variable explicitly in the Makefiles.Also, refer to programs/files from other ports with the
variables mentioned above, not explicit pathnames. For instance, if
your port requires a macro PAGER to be the full
pathname of less, use the compiler flag:
-DPAGER=\"${LOCALBASE}/bin/less\"
instead of
-DPAGER=\"/usr/local/bin/less\". This way it will
have a better chance of working if the system administrator has
moved the whole /usr/local tree somewhere else.Note that LOCALBASE,
LINUXBASE, X11BASE,
DOCSDIR, EXAMPLESDIR,
DATADIR, DESKTOPDIR variables
already contain DESTDIR. Using
DESTDIRLOCALBASE is
wrong. Use LOCALBASE_REL,
LINUXBASE_REL, X11BASE_REL
if you need a variable relative to DESTDIR.
To keep things terse, TARGETDIR can be used to
replace DESTDIRPREFIX.Example of correct usage:post-install:
${INSTALL_PROGRAM} ${WRKSRC}/helper ${TARGETDIR}/bin/helper
${INSTALL_DATA} ${WRKSRC}/guide.txt ${DOCSDIR}When referencing dependencies in the port, the
LOCALBASE is used, as we are working with
dependencies inside the target environment. For hardcoding file
paths in the software, LOCALBASE_REL must
be used, because the software will run inside the target
environment.Example of correct usage:RUN_DEPENDS= ${LOCALBASE}/share/gonzo/launch.dat:${PORTSDIR}/games/gonzo
post-patch:
@${REINPLACE_CMD} -e 's|/usr/gonzo/launch.dat|${LOCALBASE_REL}/share/gonzo/launch.dat}' ${WRKSRC}/main.c
@${REINPLACE_CMD} -e 's|/etc/game.conf|${PREFIX}/etc/game.conf|' ${WRKSRC}/loader.c
post-install:
@${INSTALL_DATA} ${WRKSRC}/example/conf ${TARGETDIR}/etc/game.confIn packing lists and in pkg-* scripts,
%%LOCALBASE%%, %%LINUXBASE%%
and %%X11BASE%% expansions will contain paths
stripped of DESTDIR, as all these files are
processed of a context of target environment.TinderboxIf you're an avid ports contributor, you might want to take a
look at Tinderbox. It is a powerful
system for building and testing ports based on the scripts used on
Pointyhat. You can install
Tinderbox using
- misc/tinderbox port. Be sure
+ ports-mgmt/tinderbox port. Be sure
to read supplied documentation since the configuration is not
trivial.Visit the Tinderbox website
for more details.UpgradingWhen you notice that a port is out of date compared to the latest
version from the original authors, you should first ensure that you
have the latest
port. You can find them in the
ports/ports-current directory of the &os; FTP mirror
sites. However, if you are working with more than a few
ports, you will probably find it easier to use
CVSup to keep your whole ports collection
up-to-date, as described in the
Handbook.
This will have the added benefit of tracking all the ports'
dependencies.The next step is to see if there is an update already pending.
To do this, you have two options. There is a searchable interface
to the
FreeBSD Problem Report (PR) database (also known as
GNATS). Select ports in the
dropdown, and enter the name of the port.However, sometimes people forget to put the name of the port
into the Synopsis field in an unambiguous fashion. In that case,
you can try the
FreeBSD Ports Monitoring System (also known as
portsmon). This system attempts to classify
port PRs by portname. To search for PRs about a particular port,
use the
Overview of One Port.If there is no pending PR, the next step is to send an email
to the port's maintainer, as shown by
make maintainer. That person may
already be working on an upgrade, or have a reason to not upgrade the
port right now (because of, for example, stability problems of the new
version); you would not want to duplicate their work. Note that
unmaintained ports are listed with a maintainer of
ports@FreeBSD.org, which is just the general
ports mailing list, so sending mail there
probably will not help in this case.If the maintainer asks you to do the upgrade or there is
no maintainer, then you have a chance to help out &os; by
preparing the update yourself! Please make the changes and save
the result of the
recursive diff output
of the new and old
ports directories (e.g., if your modified port directory is
called superedit and the original is in our tree
as superedit.bak, then save the result of
diff -ruN superedit.bak superedit). Either
unified or context diff is fine, but port committers generally
prefer unified diffs. Note the use of the -N
option—this is the accepted way to force diff to properly
deal with the case of new files being added or old files being
deleted. Before sending us the diff, please examine the
output to make sure all the changes make sense. To
simplify common operations with patch files, you can use
/usr/ports/Tools/scripts/patchtool.py.
Before using it, please read
/usr/ports/Tools/scripts/README.patchtool.If the port is unmaintained, and you are actively using
it yourself, please consider volunteering to become its
maintainer. &os; has over 2000 ports without maintainers,
and this is an area where more volunteers are always needed.
(For a detailed description of the responsibilities of maintainers,
refer to the
MAINTAINER on Makefiles section.) The best way to
send us the diff is by including it via &man.send-pr.1; (category
ports). If you are maintaining the port,
be sure to put [maintainer update] at the beginning
of your synopsis line and set the Class of your PR
to maintainer-update. Otherwise, the
Class of your PR should be
change-request. Please mention any added or
deleted files in the message, as they have to be explicitly specified
to &man.cvs.1; when doing a commit. If the diff is more than about 20KB,
please compress and uuencode it; otherwise, just include it in the PR
as is.Before you &man.send-pr.1;, you should review the
Writing the problem report section in the Problem
Reports article; it contains far more information about how to write
useful problem reports.If your upgrade is motivated by security concerns or a
serious fault in the currently committed port, please notify
the &a.portmgr; to request immediate rebuilding and
redistribution of your port's package. Unsuspecting users
of &man.pkg.add.1; will otherwise continue to install the
old version via pkg_add -r for several
weeks.Once again, please use &man.diff.1; and not &man.shar.1; to send
updates to existing ports!Now that you have done all that, you will want to read about
how to keep up-to-date in .Ports securityWhy security is so importantBugs are occasionally introduced to the software.
Arguably, the most dangerous of them are those opening
security vulnerabilities. From the technical viewpoint,
such vulnerabilities are to be closed by exterminating
the bugs that caused them. However, the policies for
handling mere bugs and security vulnerabilities are
very different.A typical small bug affects only those users who have
enabled some combination of options triggering the bug.
The developer will eventually release a patch followed
by a new version of the software, free of the bug, but
the majority of users will not take the trouble of upgrading
immediately because the bug has never vexed them. A
critical bug that may cause data loss represents a graver
issue. Nevertheless, prudent users know that a lot of
possible accidents, besides software bugs, are likely to
lead to data loss, and so they make backups of important
data; in addition, a critical bug will be discovered
really soon.A security vulnerability is all different. First,
it may remain unnoticed for years because often it does
not cause software malfunction. Second, a malicious party
can use it to gain unauthorized access to a vulnerable
system, to destroy or alter sensitive data; and in the
worst case the user will not even notice the harm caused.
Third, exposing a vulnerable system often assists attackers
to break into other systems that could not be compromised
otherwise. Therefore closing a vulnerability alone is
not enough: the audience should be notified of it in most
clear and comprehensive manner, which will allow to
evaluate the danger and take appropriate actions.Fixing security vulnerabilitiesWhile on the subject of ports and packages, a security
vulnerability may initially appear in the original
distribution or in the port files. In the former case,
the original software developer is likely to release a
patch or a new version instantly, and you will
only need to update the port promptly with respect to
the author's fix. If the fix is delayed for some reason,
you should either mark the port as
FORBIDDEN
or introduce a patch file of your own to the port. In
the case of a vulnerable port, just fix the port as soon as
possible. In either case, the
standard procedure for submitting your change should
be followed unless you have rights to commit it directly
to the ports tree.Being a ports committer is not enough to commit to
an arbitrary port. Remember that ports usually have
maintainers, whom you should respect.Please make sure that the port's revision is bumped
as soon as the vulnerability has been closed.
That is how the users who upgrade installed packages
on a regular basis will see they need to run an update.
Besides, a new package will be built and distributed
over FTP and WWW mirrors, replacing the vulnerable one.
PORTREVISION should be bumped unless
PORTVERSION has changed in the course
of correcting the vulnerability. That is you should
bump PORTREVISION if you have added a
patch file to the port, but you should not if you have updated
the port to the latest software version and thus already
touched PORTVERSION. Please refer to the
corresponding section
for more information.Keeping the community informedThe VuXML databaseA very important and urgent step to take as early as
a security vulnerability is discovered is to notify the
community of port users about the jeopardy. Such
notification serves two purposes. First, should the danger
be really severe, it will be wise to apply an instant workaround,
e.g., stop the affected network service or even deinstall
the port completely, until the vulnerability is closed.
Second, a lot of users tend to upgrade installed packages
just occasionally. They will know from the notification
that they must update the package
without delay as soon as a corrected version is available.Given the huge number of ports in the tree,
a security advisory cannot be issued on each incident
without creating a flood and losing the attention of
the audience by the time it comes to really serious
matters. Therefore security vulnerabilities found in
ports are recorded in the FreeBSD VuXML
database. The Security Officer Team members
are monitoring it for issues requiring their
intervention.If you have committer rights, you can update the VuXML
database by yourself. So you will both help the Security
Officer Team and deliver the crucial information to the
community earlier. However, if you are not a committer,
or you believe you have found an exceptionally severe
vulnerability, or whatever, please do not hesitate to
contact the Security Officer Team directly as described
on the FreeBSD
Security Information page.All right, you elected the hard way. As it may be obvious
from its title, the VuXML database is essentially an
XML document. Its source file vuln.xml
is kept right inside the port security/vuxml. Therefore
the file's full pathname will be
PORTSDIR/security/vuxml/vuln.xml.
Each time you discover a security vulnerability in a
port, please add an entry for it to that file.
Until you are familiar with VuXML, the best thing you can
do is to find an existing entry fitting your case, then copy
it and use as a template.A short introduction to VuXMLThe full-blown XML is complex and far beyond the scope of
this book. However, to gain basic insight on the structure
of a VuXML entry, you need only the notion of tags. XML
tag names are enclosed in angle brackets. Each opening
<tag> must have a matching closing </tag>.
Tags may be nested. If nesting, the inner tags must be
closed before the outer ones. There is a hierarchy of
tags, i.e. more complex rules of nesting them. Sounds
very similar to HTML, doesn't it? The major difference
is that XML is eXtensible, i.e. based
on defining custom tags. Due to its intrinsic structure,
XML puts otherwise amorphous data into shape. VuXML is
particularly tailored to mark up descriptions of security
vulnerabilities.Now let's consider a realistic VuXML entry:<vuln vid="f4bc80f4-da62-11d8-90ea-0004ac98a7b9">
<topic>Several vulnerabilities found in Foo</topic>
<affects>
<package>
<name>foo</name>
<name>foo-devel</name>
<name>ja-foo</name>
<range><ge>1.6</ge><lt>1.9</lt></range>
<range><ge>2.*</ge><lt>2.4_1</lt></range>
<range><eq>3.0b1</eq></range>
</package>
<package>
<name>openfoo</name>
<range><lt>1.10_7</lt></range>
<range><ge>1.2,1</ge><lt>1.3_1,1</lt></range>
</package>
</affects>
<description>
<body xmlns="http://www.w3.org/1999/xhtml">
<p>J. Random Hacker reports:</p>
<blockquote
cite="http://j.r.hacker.com/advisories/1">
<p>Several issues in the Foo software may be exploited
via carefully crafted QUUX requests. These requests will
permit the injection of Bar code, mumble theft, and the
readability of the Foo administrator account.</p>
</blockquote>
</body>
</description>
<references>
<freebsdsa>SA-10:75.foo</freebsdsa>
<freebsdpr>ports/987654</freebsdpr>
<cvename>CAN-2010-0201</cvename>
<cvename>CAN-2010-0466</cvename>
<bid>96298</bid>
<certsa>CA-2010-99</certsa>
<certvu>740169</certvu>
<uscertsa>SA10-99A</uscertsa>
<uscertta>SA10-99A</uscertta>
<mlist msgid="201075606@hacker.com">http://marc.theaimsgroup.com/?l=bugtraq&m=203886607825605</mlist>
<url>http://j.r.hacker.com/advisories/1</url>
</references>
<dates>
<discovery>2010-05-25</discovery>
<entry>2010-07-13</entry>
<modified>2010-09-17</entry>
</dates>
</vuln>The tag names are supposed to be self-descriptive,
so we shall take a closer look only at fields you will need
to fill in by yourself:This is the top-level tag of a VuXML entry. It has
a mandatory attribute, vid,
specifying a universally unique identifier (UUID) for
this entry (in quotes). You should generate a UUID
for each new VuXML entry (and do not forget to substitute
it for the template UUID unless you are writing the
entry from scratch). You can use &man.uuidgen.1; to
generate a VuXML UUID; alternatively, if you are using
FreeBSD 4.x, you may install the port devel/p5-Data-UUID and issue
the following command:perl -MData::UUID -le 'print lc new Data::UUID->create_str'This is a one-line description of the issue found.The names of packages affected are listed there.
Multiple names can be given since several packages may be
based on a single master port or software product. This
may include stable and development branches, localized
versions, and slave ports featuring different choices of
important build-time configuration options.It is your responsibility to find all such related
packages when writing a VuXML entry. Keep in mind that
make search name=foo is your friend.
The primary points to look for are as follows:the foo-devel variant
for a foo port;other variants with a suffix like
-a4 (for print-related packages),
-without-gui (for packages with X
support disabled), or similar;jp-, ru-,
zh-, and other possible localized
variants in the corresponding national categories of
the ports collection.Affected versions of the package(s) are specified
there as one or more ranges using a combination of
<lt>, <le>,
<eq>, <ge>,
and <gt> elements. The
version ranges given should not overlap.In a range specification, * (asterisk)
denotes the smallest version number. In particular,
2.* is less than 2.a.
Therefore an asterisk may be used for a range to match all
possible alpha, beta,
and RC versions. For instance,
<ge>2.*</ge><lt>3.*</lt>
will selectively match every 2.x version while
<ge>2.0</ge><lt>3.0</lt>
will obviously not since the latter misses
2.r3 and matches
3.b.The above example
specifies that affected are versions from 1.6
to 1.9 inclusive, versions
2.x before 2.4_1,
and version 3.0b1.Several related package groups (essentially, ports)
can be listed in the <affected>
section. This can be used if several software products
(say FooBar, FreeBar and OpenBar) grow from the same code base
and still share its bugs and vulnerabilities. Note the
difference from listing multiple names within a single
<package> section.The version ranges should allow for
PORTEPOCH and
PORTREVISION if applicable.
Please remember that according to the collation rules,
a version with a non-zero PORTEPOCH is
greater than any version without
PORTEPOCH, e.g., 3.0,1
is greater than 3.1 or even than
8.9.This is a summary of the issue.
XHTML is used in this field. At least enclosing
<p> and </p>
should appear. More complex mark-up may be used, but only for
the sake of accuracy and clarity: No eye candy please.This section contains references to relevant documents.
As many references as apply are encouraged.This is a
FreeBSD
security advisory.This is a
FreeBSD
problem report.This is a Mitre
CVE identifier.This is a
SecurityFocus
Bug ID.This is a
US-CERT
security advisory.This is a
US-CERT
vulnerability note.This is a
US-CERT
Cyber Security Alert.This is a
US-CERT
Technical Cyber Security Alert.This is a URL to an archived posting in a mailing list.
The attribute msgid is optional and
may specify the message ID of the posting.This is a generic URL. It should be used only if none of
the other reference categories apply.This is the date when the issue was disclosed
(YYYY-MM-DD).This is the date when the entry was added
(YYYY-MM-DD).This is the date when any information in the entry
was last modified (YYYY-MM-DD).
New entries must not include this field. It should be added
upon editing an existing entry.Testing your changes to the VuXML databaseAssume you just wrote or filled in an entry for a
vulnerability in the package clamav
that has been fixed in version 0.65_7.As a prerequisite, you need to install fresh versions of the
- ports security/portaudit and
- security/portaudit-db.
+ ports ports-mgmt/portaudit and
+ ports-mgmt/portaudit-db.
First, check whether there already is an entry for this
vulnerability. If there were such entry, it would match the
previous version of the package,
0.65_6:&prompt.user; packaudit
&prompt.user; portaudit clamav-0.65_6To run packaudit, you must have
permission to write to its
DATABASEDIR,
typically /var/db/portaudit.If there is none found, you get the green light to add
a new entry for this vulnerability. Now you can generate
a brand-new UUID (assume it's
74a9541d-5d6c-11d8-80e3-0020ed76ef5a) and
add your new entry to the VuXML database. Please verify
its syntax after that as follows:&prompt.user; cd ${PORTSDIR}/security/vuxml && make validateYou will need at least one of the following packages
installed: textproc/libxml2,
textproc/jade.Now rebuild the portaudit database
from the VuXML file:&prompt.user; packauditTo verify that the <affected>
section of your entry will match correct package(s), issue
the following command:&prompt.user; portaudit -f /usr/ports/INDEX -r 74a9541d-5d6c-11d8-80e3-0020ed76ef5aPlease refer to &man.portaudit.1; for better understanding
of the command syntax.Make sure that your entry produces no spurious matches
in the output.Now check whether the right package versions are matched
by your entry:&prompt.user; portaudit clamav-0.65_6 clamav-0.65_7
Affected package: clamav-0.65_6 (matched by clamav<0.65_7)
Type of problem: clamav remote denial-of-service.
Reference: <http://www.freebsd.org/ports/portaudit/74a9541d-5d6c-11d8-80e3-0020ed76ef5a.html>
1 problem(s) found.Obviously, the former version should match while the
latter one should not.Finally, verify whether the web page generated from the
VuXML database looks like expected:&prompt.user; mkdir -p ~/public_html/portaudit
&prompt.user; packaudit
&prompt.user; lynx ~/public_html/portaudit/74a9541d-5d6c-11d8-80e3-0020ed76ef5a.htmlDos and Don'tsIntroductionHere is a list of common dos and don'ts that you encounter during
the porting process. You should check your own port against this list,
but you can also check ports in the PR database that others have
submitted. Submit any comments on ports you check as described in
Bug Reports and General
Commentary. Checking ports in the PR database will both make
it faster for us to commit them, and prove that you know what you are
doing.Stripping BinariesDo not strip binaries manually unless you have to. All binaries
should be stripped, but the INSTALL_PROGRAM
macro will install and strip a binary at the same time (see the next
section).If you need to strip a file, but do not wish to use the
INSTALL_PROGRAM macro,
${STRIP_CMD} will strip your program. This is
typically done within the post-install
target. For example:post-install:
${STRIP_CMD} ${PREFIX}/bin/xdlUse the &man.file.1; command on the installed executable to
check whether the binary is stripped or not. If it does not say
not stripped, it is stripped. Additionally,
&man.strip.1; will not strip a previously stripped program; it
will instead exit cleanly.INSTALL_* macrosDo use the macros provided in bsd.port.mk
to ensure correct modes and ownership of files in your own
*-install targets.INSTALL_PROGRAM is a command to install
binary executables.INSTALL_SCRIPT is a command to install
executable scripts.INSTALL_DATA is a command to install
sharable data.INSTALL_MAN is a command to install
manpages and other documentation (it does not compress
anything).These are basically the install command with
all the appropriate flags. See below for an example on how to use
them.WRKDIRDo not write anything to files outside
WRKDIR. WRKDIR is the only
place that is guaranteed to be writable during the port build (see
installing ports from a CDROM for an
example of building ports from a read-only tree). If you need to
modify one of the pkg-*
files, do so by redefining a variable, not by
writing over it.WRKDIRPREFIXMake sure your port honors WRKDIRPREFIX.
Most ports do not have to worry about this. In particular, if you
are referring to a WRKDIR of another port, note
that the correct location is
WRKDIRPREFIXPORTSDIR/subdir/name/work not PORTSDIR/subdir/name/work or .CURDIR/../../subdir/name/work or some such.Also, if you are defining WRKDIR yourself,
make sure you prepend
${WRKDIRPREFIX}${.CURDIR} in the
front.Differentiating operating systems and OS versionsYou may come across code that needs modifications or conditional
compilation based upon what version of Unix it is running under. If
you need to make such changes to the code for conditional
compilation, make sure you make the changes as general as possible
so that we can back-port code to older FreeBSD systems and cross-port
to other BSD systems such as 4.4BSD from CSRG, BSD/386, 386BSD,
NetBSD, and OpenBSD.The preferred way to tell 4.3BSD/Reno (1990) and newer versions
of the BSD code apart is by using the BSD macro
defined in
sys/param.h.
Hopefully that
file is already included; if not, add the code:#if (defined(__unix__) || defined(unix)) && !defined(USG)
#include <sys/param.h>
#endifto the proper place in the .c file. We
believe that every system that defines these two symbols has
sys/param.h. If you find a system that
does not, we would like to know. Please send mail to the
&a.ports;.Another way is to use the GNU Autoconf style of doing
this:#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
#endifDo not forget to add -DHAVE_SYS_PARAM_H to the
CFLAGS in the Makefile for
this method.Once you have sys/param.h included, you may
use:#if (defined(BSD) && (BSD >= 199103))to detect if the code is being compiled on a 4.3 Net2 code base
or newer (e.g. FreeBSD 1.x, 4.3/Reno, NetBSD 0.9, 386BSD, BSD/386
1.1 and below).Use:#if (defined(BSD) && (BSD >= 199306))to detect if the code is being compiled on a 4.4 code base or
newer (e.g. FreeBSD 2.x, 4.4, NetBSD 1.0, BSD/386 2.0 or
above).The value of the BSD macro is
199506 for the 4.4BSD-Lite2 code base. This is
stated for informational purposes only. It should not be used to
distinguish between versions of FreeBSD based only on 4.4-Lite vs.
versions that have merged in changes from 4.4-Lite2. The
__FreeBSD__ macro should be used instead.Use sparingly:__FreeBSD__ is defined in all versions of
FreeBSD. Use it if the change you are making
only affects FreeBSD. Porting gotchas like
the use of sys_errlist[] vs
strerror() are Berkeley-isms, not FreeBSD
changes.In FreeBSD 2.x, __FreeBSD__ is defined to
be 2. In earlier versions, it is
1. Later versions always bump it to match
their major version number.If you need to tell the difference between a FreeBSD 1.x
system and a FreeBSD 2.x or above system, usually the right answer
is to use the BSD macros described above. If
there actually is a FreeBSD specific change (such as special
shared library options when using ld) then it
is OK to use __FreeBSD__ and #if
__FreeBSD__ > 1 to detect a FreeBSD 2.x and later
system. If you need more granularity in detecting FreeBSD
systems since 2.0-RELEASE you can use the following:#if __FreeBSD__ >= 2
#include <osreldate.h>
# if __FreeBSD_version >= 199504
/* 2.0.5+ release specific code here */
# endif
#endifIn the hundreds of ports that have been done, there have only
been one or two cases where __FreeBSD__ should
have been used. Just because an earlier port screwed up and used it
in the wrong place does not mean you should do so too.__FreeBSD_version valuesHere is a convenient list of
__FreeBSD_version values as defined in
sys/param.h:
__FreeBSD_version valuesRelease__FreeBSD_version2.0-RELEASE1194112.1-CURRENT199501, 1995032.0.5-RELEASE1995042.2-CURRENT before 2.11995082.1.0-RELEASE1995112.2-CURRENT before 2.1.51995122.1.5-RELEASE1996072.2-CURRENT before 2.1.61996082.1.6-RELEASE1996122.1.7-RELEASE1996122.2-RELEASE2200002.2.1-RELEASE220000 (no change)2.2-STABLE after 2.2.1-RELEASE220000 (no change)2.2-STABLE after texinfo-3.92210012.2-STABLE after top2210022.2.2-RELEASE2220002.2-STABLE after 2.2.2-RELEASE2220012.2.5-RELEASE2250002.2-STABLE after 2.2.5-RELEASE2250012.2-STABLE after ldconfig -R merge2250022.2.6-RELEASE2260002.2.7-RELEASE2270002.2-STABLE after 2.2.7-RELEASE2270012.2-STABLE after &man.semctl.2; change2270022.2.8-RELEASE2280002.2-STABLE after 2.2.8-RELEASE2280013.0-CURRENT before &man.mount.2; change3000003.0-CURRENT after &man.mount.2; change3000013.0-CURRENT after &man.semctl.2; change3000023.0-CURRENT after ioctl arg changes3000033.0-CURRENT after ELF conversion3000043.0-RELEASE3000053.0-CURRENT after 3.0-RELEASE3000063.0-STABLE after 3/4 branch3000073.1-RELEASE3100003.1-STABLE after 3.1-RELEASE3100013.1-STABLE after C++ constructor/destructor order
change3100023.2-RELEASE3200003.2-STABLE3200013.2-STABLE after binary-incompatible IPFW and
socket changes3200023.3-RELEASE3300003.3-STABLE3300013.3-STABLE after adding &man.mkstemp.3;
to libc3300023.4-RELEASE3400003.4-STABLE3400013.5-RELEASE3500003.5-STABLE3500014.0-CURRENT after 3.4 branch4000004.0-CURRENT after change in dynamic linker
handling4000014.0-CURRENT after C++ constructor/destructor
order change4000024.0-CURRENT after functioning &man.dladdr.3;4000034.0-CURRENT after __deregister_frame_info dynamic
linker bug fix (also 4.0-CURRENT after EGCS 1.1.2
integration)
4000044.0-CURRENT after &man.suser.9; API change
(also 4.0-CURRENT after newbus)4000054.0-CURRENT after cdevsw registration change4000064.0-CURRENT after the addition of so_cred for
socket level credentials4000074.0-CURRENT after the addition of a poll syscall
wrapper to libc_r4000084.0-CURRENT after the change of the kernel's
dev_t type to struct
specinfo pointer4000094.0-CURRENT after fixing a hole
in &man.jail.2;4000104.0-CURRENT after the sigset_t
datatype change4000114.0-CURRENT after the cutover to the GCC 2.95.2
compiler4000124.0-CURRENT after adding pluggable linux-mode
ioctl handlers4000134.0-CURRENT after importing OpenSSL4000144.0-CURRENT after the C++ ABI change in GCC 2.95.2
from -fvtable-thunks to -fno-vtable-thunks by
default4000154.0-CURRENT after importing OpenSSH4000164.0-RELEASE4000174.0-STABLE after 4.0-RELEASE4000184.0-STABLE after the introduction of delayed
checksums.4000194.0-STABLE after merging libxpg4 code into
libc.4000204.0-STABLE after upgrading Binutils to 2.10.0, ELF
branding changes, and tcsh in the base system.4000214.1-RELEASE4100004.1-STABLE after 4.1-RELEASE4100014.1-STABLE after &man.setproctitle.3; moved from
libutil to libc.4100024.1.1-RELEASE4110004.1.1-STABLE after 4.1.1-RELEASE4110014.2-RELEASE4200004.2-STABLE after combining libgcc.a and
libgcc_r.a, and associated GCC linkage changes.4200014.3-RELEASE4300004.3-STABLE after wint_t introduction.4300014.3-STABLE after PCI powerstate API merge.4300024.4-RELEASE4400004.4-STABLE after d_thread_t introduction.4400014.4-STABLE after mount structure changes (affects
filesystem klds).4400024.4-STABLE after the userland components of smbfs
were imported.4400034.5-RELEASE4500004.5-STABLE after the usb structure element rename.4500014.5-STABLE after the
sendmail_enable &man.rc.conf.5;
variable was made to take the value
NONE.4500044.5-STABLE after moving to XFree86 4 by default
for package builds.4500054.5-STABLE after accept filtering was fixed so
that is no longer susceptible to an easy DoS.4500064.6-RELEASE4600004.6-STABLE &man.sendfile.2; fixed to comply with
documentation, not to count any headers sent against
the amount of data to be sent from the file.4600014.6.2-RELEASE4600024.6-STABLE4601004.6-STABLE after MFC of `sed -i'.4601014.6-STABLE after MFC of many new pkg_install
features from the HEAD.4601024.7-RELEASE4700004.7-STABLE470100Start generated __std{in,out,err}p references rather
than __sF. This changes std{in,out,err} from a
compile time expression to a runtime one.4701014.7-STABLE after MFC of mbuf changes to replace
m_aux mbufs by m_tag's4701024.7-STABLE gets OpenSSL 0.9.74701034.8-RELEASE4800004.8-STABLE4801004.8-STABLE after &man.realpath.3; has been made
thread-safe4801014.8-STABLE 3ware API changes to twe.4801024.9-RELEASE4900004.9-STABLE4901004.9-STABLE after e_sid was added to struct
kinfo_eproc.4901014.9-STABLE after MFC of libmap functionality
for rtld.4901024.10-RELEASE4910004.10-STABLE4911004.10-STABLE after MFC of revision 20040629 of
the package tools4911014.10-STABLE after VM fix dealing with unwiring
of fictitious pages4911024.11-RELEASE4920004.11-STABLE4921004.11-STABLE after adding libdata/ldconfig directories
to mtree files.4921015.0-CURRENT5000005.0-CURRENT after adding addition ELF header fields,
and changing our ELF binary branding method.5000015.0-CURRENT after kld metadata changes.5000025.0-CURRENT after buf/bio changes.5000035.0-CURRENT after binutils upgrade.5000045.0-CURRENT after merging libxpg4 code into
libc and after TASKQ interface introduction.5000055.0-CURRENT after the addition of AGP
interfaces.5000065.0-CURRENT after Perl upgrade to 5.6.05000075.0-CURRENT after the update of KAME code to
2000/07 sources.5000085.0-CURRENT after ether_ifattach() and
ether_ifdetach() changes.5000095.0-CURRENT after changing mtree defaults
back to original variant, adding -L to follow
symlinks.5000105.0-CURRENT after kqueue API changed.5000115.0-CURRENT after &man.setproctitle.3; moved from
libutil to libc.5000125.0-CURRENT after the first SMPng commit.5000135.0-CURRENT after <sys/select.h> moved to
<sys/selinfo.h>.5000145.0-CURRENT after combining libgcc.a and
libgcc_r.a, and associated GCC linkage changes.5000155.0-CURRENT after change allowing libc and libc_r
to be linked together, deprecating -pthread
option.5000165.0-CURRENT after switch from struct ucred to
struct xucred to stabilize kernel-exported API for
mountd et al.5000175.0-CURRENT after addition of CPUTYPE make variable
for controlling CPU-specific optimizations.5000185.0-CURRENT after moving machine/ioctl_fd.h to
sys/fdcio.h5000195.0-CURRENT after locale names renaming.5000205.0-CURRENT after Bzip2 import.
Also signifies removal of S/Key.5000215.0-CURRENT after SSE support.5000225.0-CURRENT after KSE Milestone 2.5000235.0-CURRENT after d_thread_t,
and moving UUCP to ports.5000245.0-CURRENT after ABI change for descriptor
and creds passing on 64 bit platforms.5000255.0-CURRENT after moving to XFree86 4 by default for
package builds, and after the new libc strnstr() function
was added.5000265.0-CURRENT after the new libc strcasestr() function
was added.5000275.0-CURRENT after the userland components of smbfs
were imported.5000285.0-CURRENT after the new C99 specific-width
integer types were added.(Not incremented.)5.0-CURRENT after a change was made in the return
value of &man.sendfile.2;.5000295.0-CURRENT after the introduction of the
type fflags_t, which is the
appropriate size for file flags.5000305.0-CURRENT after the usb structure element rename.5000315.0-CURRENT after the introduction of
Perl 5.6.1.5000325.0-CURRENT after the
sendmail_enable &man.rc.conf.5;
variable was made to take the value
NONE.5000335.0-CURRENT after mtx_init() grew a third argument.5000345.0-CURRENT with Gcc 3.1.5000355.0-CURRENT without Perl in /usr/src5000365.0-CURRENT after the addition of &man.dlfunc.3;5000375.0-CURRENT after the types of some struct
sockbuf members were changed and the structure was
reordered.5000385.0-CURRENT after GCC 3.2.1 import.
Also after headers stopped using
_BSD_FOO_T_ and started using _FOO_T_DECLARED.
This value can also be used as a conservative
estimate of the start of &man.bzip2.1; package
support.5000395.0-CURRENT after various changes to disk functions
were made in the name of removing dependency on disklabel
structure internals.5000405.0-CURRENT after the addition of &man.getopt.long.3;
to libc.5000415.0-CURRENT after Binutils 2.13 upgrade, which
included new FreeBSD emulation, vec, and output format.
5000425.0-CURRENT after adding weak pthread_XXX stubs
to libc, obsoleting libXThrStub.so. 5.0-RELEASE.5000435.0-CURRENT after branching for RELENG_5_0500100<sys/dkstat.h> is empty and should
not be included.5001015.0-CURRENT after the d_mmap_t interface
change.5001025.0-CURRENT after taskqueue_swi changed to run
without Giant, and taskqueue_swi_giant added to run
with Giant.500103cdevsw_add() and cdevsw_remove() no
longer exists.
Appearance of MAJOR_AUTO allocation facility.5001045.0-CURRENT after new cdevsw initialization method.500105devstat_add_entry() has been replaced by
devstat_new_entry()500106Devstat interface change; see sys/sys/param.h 1.149500107Token-Ring interface changes.500108Addition of vm_paddr_t.5001095.0-CURRENT after &man.realpath.3; has been made
thread-safe5001105.0-CURRENT after &man.usbhid.3; has been synced with
NetBSD5001115.0-CURRENT after new NSS implementation
and addition of POSIX.1 getpw*_r, getgr*_r
functions5001125.0-CURRENT after removal of the old rc system.5001135.1-RELEASE.5010005.1-CURRENT after branching for RELENG_5_1.5011005.1-CURRENT after correcting the semantics of
sigtimedwait(2) and sigwaitinfo(2).5011015.1-CURRENT after adding the lockfunc and lockfuncarg
fields to &man.bus.dma.tag.create.9;.5011025.1-CURRENT after GCC 3.3.1-pre 20030711 snapshot
integration.5011035.1-CURRENT 3ware API changes to twe.5011045.1-CURRENT dynamically-linked /bin and /sbin
support and movement of libraries to /lib.5011055.1-CURRENT after adding kernel support for
Coda 6.x.5011065.1-CURRENT after 16550 UART constants moved from
<dev/sio/sioreg.h> to
<dev/ic/ns16550.h>.
Also when libmap functionality was unconditionally
supported by rtld.5011075.1-CURRENT after PFIL_HOOKS API update5011085.1-CURRENT after adding kiconv(3)5011095.1-CURRENT after changing default operations
for open and close in cdevsw5011105.1-CURRENT after changed layout of cdevsw501111 5.1-CURRENT after adding kobj multiple inheritance
501112 5.1-CURRENT after the if_xname change in
struct ifnet501113 5.1-CURRENT after changing /bin and /sbin to
be dynamically linked5011145.2-RELEASE5020005.2.1-RELEASE5020105.2-CURRENT after branching for RELENG_5_25021005.2-CURRENT after __cxa_atexit/__cxa_finalize
functions were added to libc.5021015.2-CURRENT after change of default thread library
from libc_r to libpthread.5021025.2-CURRENT after device driver API megapatch.
5021035.2-CURRENT after getopt_long_only() addition.
5021045.2-CURRENT after NULL is made into ((void *)0)
for C, creating more warnings.
5021055.2-CURRENT after pf is linked to the build and
install.
5021065.2-CURRENT after time_t is changed to a
64-bit value on sparc64.
5021075.2-CURRENT after Intel C/C++ compiler support in some headers and execve(2) changes to be more strictly conforming to POSIX.
5021085.2-CURRENT after the introduction of the
bus_alloc_resource_any API
5021095.2-CURRENT after the addition of UTF-8 locales
5021105.2-CURRENT after the removal of the getvfsent(3)
API
5021115.2-CURRENT after the addition of the .warning
directive for make.5021125.2-CURRENT after ttyioctl() was made mandatory
for serial drivers.5021135.2-CURRENT after import of the ALTQ framework.
5021145.2-CURRENT after changing sema_timedwait(9) to
return 0 on success and a non-zero error code on
failure.
5021155.2-CURRENT after changing kernel dev_t to
be pointer to struct cdev *.
5021165.2-CURRENT after changing kernel udev_t to dev_t.
5021175.2-CURRENT after adding support for CLOCK_VIRTUAL
and CLOCK_PROF to clock_gettime(2) and clock_getres(2).
5021185.2-CURRENT after changing network interface
cloning overhaul.
5021195.2-CURRENT after the update of the package tools
to revision 20040629.
5021205.2-CURRENT after marking Bluetooth code as
non-i386 specific.
5021215.2-CURRENT after the introduction of the KDB
debugger framework, the conversion of DDB into a
backend and the introduction of the GDB backend.
5021225.2-CURRENT after change to make
VFS_ROOT take a struct
thread argument as does vflush. Struct kinfo_proc
now has a user data pointer.
The switch of the default X implementation to
xorg was also made at this time.
5021235.2-CURRENT after the change to separate the way
ports rc.d and legacy scripts are started.
5021245.2-CURRENT after the backout of the
previous change.
5021255.2-CURRENT after the removal of
kmem_alloc_pageable() and the import of gcc 3.4.2.
5021265.2-CURRENT after changing the UMA kernel
API to allow ctors/inits to fail.
5021275.2-CURRENT after the change of the
vfs_mount signature as well as global replacement of
PRISON_ROOT with SUSER_ALLOWJAIL for the suser(9)
API.
5021285.3-BETA/RC before the pfil API change5030005.3-RELEASE5030015.3-STABLE after branching for RELENG_5_35031005.3-STABLE after addition of glibc style
&man.strftime.3; padding options.5031015.3-STABLE after OpenBSD's nc(1) import MFC.5031025.4-PRERELEASE after the MFC of the fixes in
<src/include/stdbool.h> and
<src/sys/i386/include/_types.h>
for using the GCC-compatibility of the Intel C/C++ compiler.5031035.4-PRERELEASE after the MFC of the change of
ifi_epoch from wall clock time to uptime.5031045.4-PRERELEASE after the MFC of the fix of EOVERFLOW check in vswprintf(3).5031055.4-RELEASE.5040005.4-STABLE after branching for RELENG_5_45041005.4-STABLE after increasing the default
thread stacksizes5041015.4-STABLE after the addition of sha2565041025.4-STABLE after the MFC of if_bridge5041035.4-STABLE after the MFC of bsdiff and portsnap5041045.4-STABLE after MFC of ldconfig_local_dirs
change.5041055.5-RELEASE.5050005.5-STABLE after branching for RELENG_5_55051006.0-CURRENT6000006.0-CURRENT after permanently enabling PFIL_HOOKS
in the kernel.
6000016.0-CURRENT after initial addition of
ifi_epoch to struct if_data. Backed out after a
few days. Do not use this value.
6000026.0-CURRENT after the re-addition of the
ifi_epoch member of struct if_data.
6000036.0-CURRENT after addition of the struct inpcb
argument to the pfil API.
6000046.0-CURRENT after addition of the "-d
DESTDIR" argument to newsyslog.
6000056.0-CURRENT after addition of glibc style
&man.strftime.3; padding options.
6000066.0-CURRENT after addition of 802.11 framework
updates.
6000076.0-CURRENT after changes to VOP_*VOBJECT() functions
and introduction of MNTK_MPSAFE flag for Giantfree filesystems.
6000086.0-CURRENT after addition of the cpufreq framework
and drivers.
6000096.0-CURRENT after importing OpenBSD's nc(1).6000106.0-CURRENT after removing semblance of SVID2
matherr() support.6000116.0-CURRENT after increase of default thread stacks'
size.6000126.0-CURRENT after fixes in
<src/include/stdbool.h> and
<src/sys/i386/include/_types.h>
for using the GCC-compatibility of the Intel C/C++ compiler.6000136.0-CURRENT after EOVERFLOW checks in vswprintf(3) fixed.6000146.0-CURRENT after changing the struct if_data
member, ifi_epoch, from wall clock time to uptime.6000156.0-CURRENT after LC_CTYPE disk format changed.6000166.0-CURRENT after NLS catalogs disk format changed.6000176.0-CURRENT after LC_COLLATE disk format changed.600018Installation of acpica includes into /usr/include.600019Addition of MSG_NOSIGNAL flag to send(2) API.600020Addition of fields to cdevsw600021Removed gtar from base system.600022LOCAL_CREDS, LOCAL_CONNWAIT socket options added to unix(4).600023&man.hwpmc.4; and related tools added to 6.0-CURRENT.600024struct icmphdr added to 6.0-CURRENT.600025pf updated to 3.7.600026Kernel libalias and ng_nat introduced.600027POSIX ttyname_r(3) made available through unistd.h and libc.6000286.0-CURRENT after libpcap updated to v0.9.1 alpha 096.6000296.0-CURRENT after importing NetBSD's if_bridge(4).6000306.0-CURRENT after struct ifnet was broken out
of the driver softcs.6000316.0-CURRENT after the import of libpcap v0.9.1.6000326.0-STABLE after bump of all shared library
versions that had not been changed since
RELENG_5.6000336.0-STABLE after credential argument is added to
dev_clone event handler. 6.0-RELEASE.6000346.0-STABLE after 6.0-RELEASE6001006.0-STABLE after incorporating scripts from the
local_startup directories into the base &man.rcorder.8;.6001016.0-STABLE after updating the ELF types and
constants.6001026.0-STABLE after MFC of pidfile(3) API.6001036.0-STABLE after MFC of ldconfig_local_dirs
change.6001046.0-STABLE after NLS catalog support of
csh(1).6001056.1-RELEASE6010006.1-STABLE after 6.1-RELEASE.6011006.1-STABLE after the import of csup.6011016.1-STABLE after the iwi(4) update.6011026.1-STABLE after the resolver update to
BIND9, and exposure of reentrant version of
netdb functions.6011036.1-STABLE after DSO (dynamic shared
objects) support has been enabled in
OpenSSL.6011046.2-RELEASE6020006.2-STABLE after 6.2-RELEASE.6021006.2-STABLE after the addition of Wi-Spy
quirk.6021016.2-STABLE after pci_find_extcap() addition.6021026.2-STABLE after MFC of dlsym change to look
for a requested symbol both
in specified dso and its implicit dependencies.6021036.2-STABLE after MFC of ng_deflate(4) and
ng_pred1(4) netgraph nodes and new compression and
encryption modes for ng_ppp(4) node.6021047.0-CURRENT.7000007.0-CURRENT after bump of all shared library
versions that had not been changed since
RELENG_5.7000017.0-CURRENT after credential argument is added to
dev_clone vent handler.7000027.0-CURRENT after memmem(3) is added to libc.7000037.0-CURRENT after solisten(9) kernel arguments
are modified to accept a backlog parameter.7000047.0-CURRENT after IFP2ENADDR() was changed to return
a pointer to IF_LLADDR().7000057.0-CURRENT after addition of if_addr
member to struct ifnet and IFP2ENADDR()
removal.7000067.0-CURRENT after incorporating scripts from the
local_startup directories into the base &man.rcorder.8;.7000077.0-CURRENT after removal of MNT_NODEV mount
option.7000087.0-CURRENT after ELF-64 type changes and symbol
versioning.7000097.0-CURRENT after addition of hostb and vgapci
drivers, addition of pci_find_extcap(), and changing
the AGP drivers to no longer map the aperture.7000107.0-CURRENT after tv_sec was made time_t on
all platforms but Alpha.7000117.0-CURRENT after ldconfig_local_dirs change.7000127.0-CURRENT after changes to
/etc/rc.d/abi to support
/compat/linux/etc/ld.so.cache
being a symlink in a readonly filesystem.7000137.0-CURRENT after pts import.7000147.0-CURRENT after the introduction of version 2
of &man.hwpmc.4;'s ABI.7000157.0-CURRENT after addition of &man.fcloseall.3;
to libc.7000167.0-CURRENT after removal of ip6fw.7000177.0-CURRENT after import of snd_emu10kx.7000187.0-CURRENT after import of OpenSSL 0.9.8b.7000197.0-CURRENT after addition of bus_dma_get_tag
function7000207.0-CURRENT after libpcap 0.9.4 and
tcpdump 3.9.4 import.7000217.0-CURRENT after dlsym change to look
for a requested symbol both
in specified dso and its implicit dependencies.7000227.0-CURRENT after adding new sound IOCTLs.7000237.0-CURRENT after import of OpenSSL 0.9.8d.7000247.0-CURRENT after the addition of libelf.7000257.0-CURRENT after major changes on sound
sysctls.7000267.0-CURRENT after the addition of Wi-Spy
quirk.7000277.0-CURRENT after the addition of sctp calls to libc
7000287.0-CURRENT after the GNU &man.gzip.1; implementation was
replaced with a BSD licensed version ported from NetBSD.700029
Note that 2.2-STABLE sometimes identifies itself as
2.2.5-STABLE after the 2.2.5-RELEASE. The pattern
used to be year followed by the month, but we decided to change it
to a more straightforward major/minor system starting from 2.2.
This is because the parallel development on several branches made
it infeasible to classify the releases simply by their real
release dates. If you are making a port now, you do not have to
worry about old -CURRENTs; they are listed here just for your
reference.Writing something after
bsd.port.mkDo not write anything after the .include
<bsd.port.mk> line. It usually can be avoided by
including bsd.port.pre.mk somewhere in the
middle of your Makefile and
bsd.port.post.mk at the end.You need to include either the
bsd.port.pre.mk/bsd.port.post.mk pair or
bsd.port.mk only; do not mix these two usages.bsd.port.pre.mk only defines a few
variables, which can be used in tests in the
Makefile, bsd.port.post.mk
defines the rest.Here are some important variables defined in
bsd.port.pre.mk (this is not the complete list,
please read bsd.port.mk for the complete
list).VariableDescriptionARCHThe architecture as returned by uname
-m (e.g., i386)OPSYSThe operating system type, as returned by
uname -s (e.g.,
FreeBSD)OSRELThe release version of the operating system (e.g.,
2.1.5 or
2.2.7)OSVERSIONThe numeric version of the operating system; the same as
__FreeBSD_version.PORTOBJFORMATThe object format of the system
(elf or aout;
note that for modern versions of FreeBSD,
aout is deprecated.)LOCALBASEThe base of the local tree (e.g.,
/usr/local/)X11BASEThe base of the X11 tree (e.g.,
/usr/X11R6)PREFIXWhere the port installs itself (see more on
PREFIX).If you have to define the variables
USE_IMAKE, USE_X_PREFIX, or
MASTERDIR, do so before including
bsd.port.pre.mk.Here are some examples of things you can write after
bsd.port.pre.mk:# no need to compile lang/perl5 if perl5 is already in system
.if ${OSVERSION} > 300003
BROKEN= perl is in system
.endif
# only one shlib version number for ELF
.if ${PORTOBJFORMAT} == "elf"
TCL_LIB_FILE= ${TCL_LIB}.${SHLIB_MAJOR}
.else
TCL_LIB_FILE= ${TCL_LIB}.${SHLIB_MAJOR}.${SHLIB_MINOR}
.endif
# software already makes link for ELF, but not for a.out
post-install:
.if ${PORTOBJFORMAT} == "aout"
${LN} -sf liblinpack.so.1.0 ${PREFIX}/lib/liblinpack.so
.endifYou did remember to use tab instead of spaces after
BROKEN= and
TCL_LIB_FILE=, did you not?
:-).Install additional documentationIf your software has some documentation other than the standard
man and info pages that you think is useful for the user, install it
under PREFIX/share/doc.
This can be done, like the previous item, in the
post-install target.Create a new directory for your port. The directory name should
reflect what the port is. This usually means
PORTNAME. However, if you
think the user might want different versions of the port to be
installed at the same time, you can use the whole
PKGNAME.Make the installation dependent on the variable
NOPORTDOCS so that users can disable it in
/etc/make.conf, like this:post-install:
.if !defined(NOPORTDOCS)
${MKDIR} ${DOCSDIR}
${INSTALL_MAN} ${WRKSRC}/docs/xvdocs.ps ${DOCSDIR}
.endifHere are some handy variables and how they are expanded
by default when used
in the Makefile:DATADIR gets expanded to
PREFIX/share/PORTNAME.DOCSDIR gets expanded to
PREFIX/share/doc/PORTNAME.EXAMPLESDIR gets expanded to
PREFIX/share/examples/PORTNAME.These variables are exported to PLIST_SUB.
Their values will appear there as pathnames relative to
PREFIX if possible.
That is, share/doc/PORTNAME
will be substituted for %%DOCSDIR%%
in the packing list by default, and so on.
(See more on pkg-plist substitution
here.)All documentation files and directories installed should
be included in pkg-plist with the
%%PORTDOCS%% prefix, for example:%%PORTDOCS%%%%DOCSDIR%%/AUTHORS
%%PORTDOCS%%%%DOCSDIR%%/CONTACT
%%PORTDOCS%%@dirrm %%DOCSDIR%%As an alternative to enumerating the documentation files
in pkg-plist, a port can set the variable
PORTDOCS to a list of file names and shell
glob patterns to add to the final packing list.
The names will be relative to DOCSDIR.
Therefore, a port that utilizes PORTDOCS and
uses a non-default location for its documentation should set
DOCSDIR accordingly.
If a directory is listed in PORTDOCS
or matched by a glob pattern from this variable,
the entire subtree of contained files and directories will be
registered in the final packing list. If NOPORTDOCS
is defined then files and directories listed in
PORTDOCS would not be installed and neither
would be added to port packing list.
Installing the documentation at PORTDOCS
as shown above remains up to the port itself.
A typical example of utilizing PORTDOCS
looks as follows:PORTDOCS= README.* ChangeLog docs/*You can also use the pkg-message file to
display messages upon installation. See the section on using
pkg-message for details.
The pkg-message file does not need to be
added to pkg-plist.SubdirectoriesTry to let the port put things in the right subdirectories of
PREFIX. Some ports lump everything and put it in
the subdirectory with the port's name, which is incorrect. Also,
many ports put everything except binaries, header files and manual
pages in a subdirectory of lib, which does
not work well with the BSD paradigm. Many of the files should be
moved to one of the following: etc
(setup/configuration files), libexec
(executables started internally), sbin
(executables for superusers/managers), info
(documentation for info browser) or share
(architecture independent files). See &man.hier.7; for details;
the rules governing
/usr pretty much apply to
/usr/local too. The exception are ports
dealing with USENET news. They may use
PREFIX/news as a destination
for their files.Use the exec statement in wrapper scriptsIf the port installs a shell script whose purpose is to launch
another program, and if launching that program is the last action
performed by the script, make sure to launch the program using
the exec statement, for instance:#!/bin/sh
exec %%LOCALBASE%%/bin/java -jar %%DATADIR%%/foo.jar "$@"The exec statement replaces the shell
process with the specified program. If exec
is omitted, the shell process remains in memory while the
program is executing, and needlessly consumes system
resources.UIDs and GIDsThe current list of reserved UIDs and GIDs can be found
in ports/UIDs and
ports/GIDs.If your port requires a certain user to be on the installed
system, let the pkg-install script call
pw to create it automatically. Look at
net/cvsup-mirror for an example.
Please note that this is strongly discouraged, please register
user/group ID numbers as stated below.If your port must use the same user/group ID number when it is
installed as a binary package as when it was compiled, then you must
choose a free UID from 50 to 999 and register it either in
ports/UIDs (for users) or in
ports/GIDs (for groups). Look at
japanese/Wnn6 for an example.Make sure you do not use a UID already used by the system or
other ports.Please include a patch against these two files when you
require a new user or group to be created for your
port.Do things rationallyThe Makefile should do things simply and
reasonably. If you can make it a couple of lines shorter or more
readable, then do so. Examples include using a make
.if construct instead of a shell
if construct, not redefining
do-extract if you can redefine
EXTRACT* instead, and using
GNU_CONFIGURE instead of CONFIGURE_ARGS
+= --prefix=${PREFIX}.If you find yourself having to write a lot
of new code to try to do something, please go back and review
bsd.port.mk to see if it contains an
existing implementation of what you are trying to do. While
hard to read, there are a great many seemingly-hard problems for
which bsd.port.mk already provides a
shorthand solution.Respect both CC and
CXXThe port should respect both CC
and CXX variables. What we mean by this
is that the port should not set the values of these variables
absolutely, overriding existing values; instead, it should append
whatever values it needs to the existing values. This is so that
build options that affect all ports can be set globally.If the port does not respect these variables,
please add NO_PACKAGE=ignores either cc or
cxx to the Makefile.An example of a Makefile respecting
both CC and CXX
variables follows. Note the ?=:CC?= gccCXX?= g++Here is an example which respects neither
CC nor CXX
variables:CC= gccCXX= g++Both CC and CXX
variables can be defined on FreeBSD systems in
/etc/make.conf. The first example
defines a value if it was not previously set in
/etc/make.conf, preserving any
system-wide definitions. The second example clobbers
anything previously defined.Respect CFLAGSThe port should respect the CFLAGS variable.
What we mean by this is that the port should not set the value of
this variable absolutely, overriding the existing value; instead,
it should append whatever values it needs to the existing value.
This is so that build options that affect all ports can be set
globally.If it does not, please add NO_PACKAGE=ignores
cflags to the Makefile.An example of a Makefile respecting
the CFLAGS variable follows. Note the
+=:CFLAGS+= -Wall -WerrorHere is an example which does not respect the
CFLAGS variable:CFLAGS= -Wall -WerrorThe CFLAGS variable is defined on
FreeBSD systems in /etc/make.conf. The
first example appends additional flags to the
CFLAGS variable, preserving any system-wide
definitions. The second example clobbers anything previously
defined.You should remove optimization flags from the third party
Makefiles. System CFLAGS
contains system-wide optimization flags. An example from
an unmodified Makefile:CFLAGS= -O3 -funroll-loops -DHAVE_SOUNDUsing system optimization flags, the
Makefile would look similar to the
following example:CFLAGS+= -DHAVE_SOUNDThreading librariesThe threading library must be linked to the binaries
using a special linker flag -pthread on
&os;. If a port insists on linking
-lpthread or -lc_r
directly, patch it to use PTHREAD_LIBS
variable provided by the ports framework. This variable
usually has the value of -pthread, but
on certain architectures and &os; versions it can have
different values, so do not just hardcode
-pthread into patches and always use
PTHREAD_LIBS.If building the port errors out with unrecognized
option '-pthread' when setting
PTHREAD_LIBS, it may be desirable to use
gcc as linker by setting
CONFIGURE_ENV to LD=${CC}.
The -pthread option is not supported by
ld directly.FeedbackDo send applicable changes/patches to the original
author/maintainer for inclusion in next release of the code. This
will only make your job that much easier for the next
release.README.htmlDo not include the README.html file. This
file is not part of the cvs collection but is generated using the
make readme command.
Marking a port not installable with BROKEN,
FORBIDDEN, or IGNOREIn certain cases users should be prevented from installing
a port. To tell a user that
a port should not be installed, there are several
make variables that can be used in a port's
Makefile. The value of the following
make variables will be the reason that is
given back to users for why the port refuses to install itself.
Please use the correct make variable as
each make variable conveys radically different meanings to
both users, and to automated systems that depend on the
Makefiles, such as
the ports build cluster,
FreshPorts, and
portsmon.VariablesBROKEN is reserved for ports that
currently do not compile, install, or deinstall correctly.
It should be used for ports where the problem is
believed to be temporary.If instructed, the build cluster will still attempt to
try to build
them to see if the underlying problem has been
resolved. (However, in general, the cluster is run without
this.)For instance, use
BROKEN when a port:does not compilefails its configuration or installation processinstalls files outside of
${LOCALBASE} and
${X11BASE}does not remove all its files cleanly upon
deinstall (however, it may be acceptable, and desirable,
for the port to leave user-modified files behind)FORBIDDEN is used for ports that
do contain a security vulnerability or induce grave
concern regarding the security of a FreeBSD system with
a given port installed (ex: a reputably insecure program
or a program that provides easily exploitable services).
Ports should be marked as FORBIDDEN
as soon as a particular piece of software has a
vulnerability and there is no released upgrade. Ideally
ports should be upgraded as soon as possible when a
security vulnerability is discovered so as to reduce the
number of vulnerable FreeBSD hosts (we like being known
for being secure), however sometimes there is a
noticeable time gap between disclosure of a
vulnerability and an updated release of the
vulnerable software. Do not mark a port
FORBIDDEN for any reason other than
security.IGNORE is reserved for ports that
should not be built for some other reason.
It should be used for ports where the problem is
believed to be structural.
The build
cluster will not, under any
circumstances, build ports marked as
IGNORE. For instance, use
IGNORE when a port:compiles but does not run properlydoes not work on the installed version of &os;requires &os; kernel sources to build, but the
user does not have them installedhas a distfile which may not be automatically
fetched due to licensing restrictionsdoes not work with some other currently installed
port (for instance, the port depends on
www/apache21 but
www/apache13
is installed)If a port would conflict with a currently installed
port (for example, if they install a file in the same
place that perfoms a different function),
use
CONFLICTS instead.
CONFLICTS will set
IGNORE by itself.If a port should be marked IGNORE
only on certain architectures, there are two other
convenience variables that will automatically set
IGNORE for you:
ONLY_FOR_ARCHS and
NOT_FOR_ARCHS. Examples:ONLY_FOR_ARCHS= i386 amd64NOT_FOR_ARCHS= alpha ia64 sparc64A custom IGNORE message can be set
using ONLY_FOR_ARCHS_REASON and
NOT_FOR_ARCHS_REASON. Per architecture
entries are possible with
ONLY_FOR_ARCHS_REASON_ARCH
and
NOT_FOR_ARCHS_REASON_ARCH.
If a port fetches i386 binaries and installs them,
IA32_BINARY_PORT should be set. If this
variable is set, it will be checked whether the
/usr/lib32 directory is available for
IA32 versions of libraries and whether the kernel
has IA32 compatibility compiled in. If one of these two
dependencies is not satisfied, IGNORE will
be set automatically.Implementation NotesThe strings should not be quoted.
Also, the wording of the string should be somewhat
different due to the way the information is shown to the
user. Examples:BROKEN= this port is unsupported on FreeBSD 5.xIGNORE= is unsupported on FreeBSD 5.xresulting in the following output from
make describe:===> foobar-0.1 is marked as broken: this port is unsupported on FreeBSD 5.x.===> foobar-0.1 is unsupported on FreeBSD 5.x.Marking a port for removal with DEPRECATED
or EXPIRATION_DATEDo remember that BROKEN and
FORBIDDEN are to be used as a
temporary resort if a port is not working. Permanently
broken ports should be removed from the tree
entirely.When it makes sense to do so, users can be warned about
a pending port removal with DEPRECATED
and EXPIRATION_DATE. The former is
simply a string stating why the port is scheduled for removal;
the latter is a string in ISO 8601 format (YYYY-MM-DD). Both
will be shown to the user.It is possible to set DEPRECATED
without an EXPIRATION_DATE (for
instance, recommending a newer version of the port), but
the converse does not make any sense.There is no set policy on how much notice to give.
Current practice seems to be one month for security-related
issues and two months for build issues. This also gives any
interested committers a little time to fix the problems.Avoid use of the .error constructThe correct way for a Makefile to
signal that the port can not be installed due to some external
factor (for instance, the user has specified an illegal
combination of build options) is to set a nonblank value to
IGNORE. This value will be formatted and
shown to the user by make install.It is a common mistake to use .error
for this purpose. The problem with this is that many
automated tools that work with the ports tree will fail in
this situation. The most common occurrence of this is seen
when trying to build /usr/ports/INDEX
(see ). However, even more
trivial commands such as make -V maintainer
also fail in this scenario. This is not acceptable.How to avoid using .errorAssume that someone has the line
USE_POINTYHAT=yes
in make.conf. The first of
the next two Makefile snippets will
cause make index to fail, while the
second one will not:.if USE_POINTYHAT
.error "POINTYHAT is not supported"
.endif.if USE_POINTYHAT
IGNORE=POINTYHAT is not supported
.endifUsage of sysctlThe usage of sysctl is discouraged
except in targets. This is because the evaluation of any
makevars, such as used during
make index, then has to run the command,
further slowing down that process.Usage of &man.sysctl.8; should always be done
with the SYSCTL variable, as it contains the
fully qualified path and can be overridden, if one has such a
special need.Rerolling distfilesSometimes the authors of software change the content of
released distfiles without changing the file's name. You have
to verify that the changes are official and have been performed
by the author. It has happened in the past that the distfile
was silently altered on the download servers with the intent
to cause harm or compromise end user security.Put the old distfile aside, download the new one, unpack
them and compare the content with &man.diff.1;. If you see
nothing suspicious, you can update distinfo.
Be sure to summarize the differences in your PR or commit log,
so that other people know that you have taken care to ensure
that nothing bad has happened.You might also want to contact the authors of the software
and confirm the changes with them.Necessary workaroundsSometimes it is necessary to work around bugs in
software included with older versions of &os;.Some versions of &man.make.1; were broken
on at least 4.8 and 5.0 with respect to handling
comparisons based on OSVERSION.
This would often lead to failures during
make describe (and thus, the overall
ports make index). The workaround is
to enclose the conditional comparison in spaces, e.g.:
if ( ${OSVERSION} > 500023 )
Be aware that test-installing a port on 4.9 or 5.2
will not detect this problem.MiscellaneaThe files
pkg-descr and pkg-plist
should each be double-checked. If you are reviewing a port and feel
they can be worded better, do so.Do not copy more copies of the GNU General Public License into
our system, please.Please be careful to note any legal issues! Do not let us
illegally distribute software!A Sample MakefileHere is a sample Makefile that you can use to
create a new port. Make sure you remove all the extra comments (ones
between brackets)!It is recommended that you follow this format (ordering of
variables, empty lines between sections, etc.). This format is
designed so that the most important information is easy to locate. We
recommend that you use portlint to check the
Makefile.[the header...just to make it easier for us to identify the ports.]
# New ports collection makefile for: xdvi
[the "version required" line is only needed when the PORTVERSION
variable is not specific enough to describe the port.]
# Date created: 26 May 1995
[this is the person who did the original port to FreeBSD, in particular, the
person who wrote the first version of this Makefile. Remember, this should
not be changed when upgrading the port later.]
# Whom: Satoshi Asami <asami@FreeBSD.org>
#
# $FreeBSD$
[ ^^^^^^^^^ This will be automatically replaced with RCS ID string by CVS
when it is committed to our repository. If upgrading a port, do not alter
this line back to "$FreeBSD$". CVS deals with it automatically.]
#
[section to describe the port itself and the master site - PORTNAME
and PORTVERSION are always first, followed by CATEGORIES,
and then MASTER_SITES, which can be followed by MASTER_SITE_SUBDIR.
PKGNAMEPREFIX and PKGNAMESUFFIX, if needed, will be after that.
Then comes DISTNAME, EXTRACT_SUFX and/or DISTFILES, and then
EXTRACT_ONLY, as necessary.]
PORTNAME= xdvi
PORTVERSION= 18.2
CATEGORIES= print
[do not forget the trailing slash ("/")!
if you are not using MASTER_SITE_* macros]
MASTER_SITES= ${MASTER_SITE_XCONTRIB}
MASTER_SITE_SUBDIR= applications
PKGNAMEPREFIX= ja-
DISTNAME= xdvi-pl18
[set this if the source is not in the standard ".tar.gz" form]
EXTRACT_SUFX= .tar.Z
[section for distributed patches -- can be empty]
PATCH_SITES= ftp://ftp.sra.co.jp/pub/X11/japanese/
PATCHFILES= xdvi-18.patch1.gz xdvi-18.patch2.gz
[maintainer; *mandatory*! This is the person who is volunteering to
handle port updates, build breakages, and to whom a users can direct
questions and bug reports. To keep the quality of the Ports Collection
as high as possible, we no longer accept new ports that are assigned to
"ports@FreeBSD.org".]
MAINTAINER= asami@FreeBSD.org
COMMENT= A DVI Previewer for the X Window System
[dependencies -- can be empty]
RUN_DEPENDS= gs:${PORTSDIR}/print/ghostscript
LIB_DEPENDS= Xpm.5:${PORTSDIR}/graphics/xpm
[this section is for other standard bsd.port.mk variables that do not
belong to any of the above]
[If it asks questions during configure, build, install...]
IS_INTERACTIVE= yes
[If it extracts to a directory other than ${DISTNAME}...]
WRKSRC= ${WRKDIR}/xdvi-new
[If the distributed patches were not made relative to ${WRKSRC}, you
may need to tweak this]
PATCH_DIST_STRIP= -p1
[If it requires a "configure" script generated by GNU autoconf to be run]
GNU_CONFIGURE= yes
[If it requires GNU make, not /usr/bin/make, to build...]
USE_GMAKE= yes
[If it is an X application and requires "xmkmf -a" to be run...]
USE_IMAKE= yes
[et cetera.]
[non-standard variables to be used in the rules below]
MY_FAVORITE_RESPONSE= "yeah, right"
[then the special rules, in the order they are called]
pre-fetch:
i go fetch something, yeah
post-patch:
i need to do something after patch, great
pre-install:
and then some more stuff before installing, wow
[and then the epilogue]
.include <bsd.port.mk>Keeping UpThe &os; Ports Collection is constantly changing. Here is
some information on how to keep up.FreshPortsOne of the easiest ways to learn about updates that have
already been committed is by subscribing to
FreshPorts.
You can select multiple ports to monitor. Maintainers are
strongly encouraged to subscribe, because they will receive
notification of not only their own changes, but also any
changes that any other &os; committer has made. (These are
often necessary to keep up with changes in the underlying
ports framework—although it would be most polite to
receive an advance heads-up from those committing such changes,
sometimes this is overlooked or just simply impractical.
Also, in some cases, the changes are very minor in nature.
We expect everyone to use their best judgement in these
cases.)If you wish to use FreshPorts, all you need is an
account. If your registered email address is
@FreeBSD.org, you will see the opt-in link on the
right hand side of the webpages.
For those of you who already have a FreshPorts account, but are not
using your @FreeBSD.org email address,
just change your email to @FreeBSD.org, subscribe,
then change it back again.FreshPorts also has
a sanity test feature which automatically tests each commit to the
FreeBSD ports tree. If subscribed to this service, you will be
notified of any errors which FreshPorts detects during sanity
testing of your commits.The Web Interface to the Source RepositoryIt is possible to browse the files in the source repository by
using a web interface. Changes that affect the entire port system
are now documented in the
CHANGES file. Changes that affect individual ports
are now documented in the
UPDATING file. However, the definitive answer to any
question is undoubtedly to read the source code of
bsd.port.mk, and associated files.The &os; Ports Mailing ListIf you maintain ports, you should consider following the
&a.ports;. Important changes to the way ports work will be announced
there, and then committed to CHANGES.The &os; Port Building Cluster on
pointyhat.FreeBSD.orgOne of the least-publicized strengths of &os; is that
an entire cluster of machines is dedicated to continually
building the Ports Collection, for each of the major OS
releases and for each Tier-1 architecture. You can find
the results of these builds at
package building logs
and errors.Individual ports are built unless they are specifically
marked with IGNORE. Ports that are
marked with BROKEN will still be attempted,
to see if the underlying problem has been resolved. (This
is done by passing TRYBROKEN to the
port's Makefile.)The &os; Port Distfile SurveyThe build cluster is dedicated to building the latest
release of each port with distfiles that have already been
fetched. However, as the Internet continually changes,
distfiles can quickly go missing. The FreeBSD
Ports distfiles survey attempts to query every
download site for every port to find out if each distfile
is still currently available. Maintainers are asked to
check this report periodically, not only to speed up the
building process for users, but to help avoid wasting
bandwidth of the sites that volunteer to host all these
distfiles.The &os; Ports Monitoring SystemAnother handy resource is the
FreeBSD Ports Monitoring System (also known as
portsmon). This system comprises a
database that processes information from several sources
and allows its to be browsed via a web interface. Currently,
the ports Problem Reports (PRs), the error logs from
the build cluster, and individual files from the ports
collection are used. In the future, this will be expanded
to include the distfile survey, as well as other sources.To get started, you can view all information about a
particular port by using the
Overview of One Port.As of this writing, this is the only resource available
that maps GNATS PR entries to portnames. (PR submitters
do not always include the portname in their Synopsis, although
we would prefer that they did.) So, portsmon
is a good place to start if you want to find out whether an
existing port has any PRs filed against it and/or any build
errors; or, to find out if a new port that you may be thinking
about creating has already been submitted.