Commit Graph

25 Commits

Author SHA1 Message Date
Stefan Eßer
c454c57163 whereis: fix fetching of user.cs_path sysctl variable
The current implementation of sysctlbyname() does not support the user
sub-tree. This function exits with a return value of 0, but sets the
passed string buffer to an empty string.

As a result, the whereis program did not use the value of the sysctl
variable "user.cs_path", but only the value of the environment
variable "PATH".

This update makes whereis use the sysctl function with a fixed OID,
which already supports the user sub-tree.

MFC after:	3 days
2022-02-04 23:44:34 +01:00
Stefan Eßer
f5ce14028c Silence Clang Scan warnings regarding the use of strcp().
While these warnings are false positives, the use of strdup() instead of
malloc() and strcpy() simplifies and clarifies the code.

While checking the remaining uses of strcpy and strcat I noticed an
assignment of a strlen() to a variable "s", whose value needs to be
preserved for use in later output routines (where it is used to allocate
a buffer). I do not think that the value of "s" will come out lower than
its correct value and thus there is no risk of a buffer overflow, in the
general case, but a specially crafter argument might lead to an overflow.

The bogus assignment to "s" is removed since this value was only used a
single time in the following malloc() call, which has been removed.

MFC after:	2 weeks
2019-01-24 18:39:45 +00:00
Pedro F. Giffuni
1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Pedro F. Giffuni
af7ca7c85d usr.bin: minor spelling fixes on comments.
No functional change.
2016-05-01 16:13:05 +00:00
Baptiste Daroussin
c1eac826c2 Fix bad checking of the return of realloc(3)
Reported by:	Coverity
CID:		1007335
MFC after:	3 days
2016-04-20 20:56:06 +00:00
Marcelo Araujo
d919e0d513 Use NULL instead of 0 for pointers.
realloc will return NULL if it cannot allocate memory.

MFC after:	2 weeks.
2016-04-18 06:12:00 +00:00
Colin Percival
11d9aa6707 Step 1 of eliminating the "games" distribution: Move binaries to /usr/bin;
update paths; and include everything in the "base" distribution.

The "games" distribution being optional made sense when there were more
games and we had small disks; but the "games-like" games were moved into
the ports tree a dozen years ago and the remaining "utility-like" games
occupy less than 0.001% of my laptop's small hard drive.  Meanwhile every
new user is confronted by the question "do you want games installed" when
they they try to install FreeBSD.

The next steps will be:

2. Removing punch card (bcd, ppt), phase-of-moon (pom), clock (grdc), and
caesar cipher (caesar, rot13) utilities.  I intend to keep fortune, factor,
morse, number, primes, and random, since there is evidence that those are
still being used.

3. Merging src/games into src/usr.bin.

This change will not be MFCed.

Reviewed by:	jmg
Discussed at:	EuroBSDCon
Approved by:	gjb (release-affecting changes)
2015-02-12 05:35:00 +00:00
Ulrich Spörlein
fb2ad9d3a4 Reencode files from latin1 to UTF-8.
This makes a tiny percentage of entries in calendars ugly for latin1
users, but fixes them for UTF-8 users.

This badly needs a solution involving locale-dependent re-encoding.
2011-12-30 10:59:15 +00:00
Ed Schouten
558b00f5a1 Mark global functions and/or variables in whereis(1) static where possible.
This allows compilers and static analyzers to more thorough analysis.
2011-11-06 18:50:19 +00:00
Joerg Wunsch
2b7b4962ab Make the search for sources in PATH_PORTS more accurate. I only
noticed that a "whereis -qs qemu" matched the distfiles subdir of qemu
rather than /usr/ports/emulators/qemu.

It now ignores all dot entries in /usr/ports, plus all entries
starting with a capital letter (maintenance stuff like Templates, but
also includes subdir CVS), plus /usr/ports/distfiles which is simply a
magic name in that respect.
2008-06-20 08:39:42 +00:00
Stefan Farfeleder
6c97c3d1d3 Remove unused variables. 2005-04-09 14:31:41 +00:00
Ruslan Ermilov
48baa77217 Fixed usage(). 2005-02-10 16:07:23 +00:00
Tim J. Robbins
4ff2396545 Respect locale settings from the environment. 2004-07-15 08:13:56 +00:00
Johan Karlsson
1f05bc6c92 Add the -a option to report all matches instead of only the
first of each requested type.

Approved by: joerg, sheldonh (mentor)
2002-08-22 01:50:51 +00:00
Johan Karlsson
ad23c58318 Correctly handle empty path arguments, e.g., whereis -S -f biff.
Approved by:	joerg, sheldonh (mentor)
2002-08-18 18:21:18 +00:00
Johan Karlsson
103d66460c Define all paths in pathnames.h
Approved by:	joerg, sheldonh (mentor)
2002-07-25 23:04:31 +00:00
Johan Karlsson
8e4c33e9e7 Teach whereis(1) about games.
Approved by:	joerg, sheldonh (mentor)
2002-07-24 14:35:29 +00:00
Joerg Wunsch
e97f67f532 Complete rewrite, once again.
This is basically a ``C compilation'' of the former whereis.pl file,
employing the same algorithms, and aiming at being mostly
UI-compatible to the old (legally tainted) 4.3BSD whereis(1).  In
comparision, the 4.4BSD-Lite version is just another variant of
which(1) only, where in particular the option to search for source
directories is sorely missing.

While i was at it, i added two more options which i contemplated doing
long since.  -x will suppress the run of locate(1) to find sources
that could not be found otherwise, potentially saving a lot of time
(but obviously, risking to not find some sources that are well hidden
in the tree).  -q will omit the leading name of the query, so in
particular, you can now do something like:

	cd `whereis -qs ls`

I'd explicitly like to thank johan for his review which was quite a
bit more than an average review, including sending me a lot of diffs.

Reviewed by:	johan
2002-07-11 21:20:54 +00:00
Johan Karlsson
b68725e33f Restore copyright and RCSID.
Remove duplicate $FreeBSD$, $NetBSD$.

Submitted by:   mike
Approved by:    sheldonh (mentor)
2002-07-04 12:29:39 +00:00
Johan Karlsson
8d430958db compact synopsis
s/program [program ...]/program .../
        s/program [...]/program .../

Approved by:    sheldonh (mentor)
2002-07-03 19:20:59 +00:00
Johan Karlsson
058e185122 Remove -p flag.
OpenBSD's implementation lacks -p, and we don't want to
support the option now, only to lose it if/when we later
switch to OpenBSD's implementation.
This functionality is provided by which(1).

Approved by:    sheldonh (mentor)
2002-07-03 19:19:54 +00:00
Johan Karlsson
9d1b456e66 Add __FBSDID.
Remove __COPYRIGHT, __RCSID which caused an assembler warning.

Approved by:    sheldonh (mentor)
2002-07-03 19:17:59 +00:00
Johan Karlsson
b78dcb87c0 Change to NetBSDs version of whereis.
Approved by:    sheldonh (mentor)
Obtained from:  NetBSD
2002-07-03 19:16:31 +00:00
Joerg Wunsch
1ace9012ad A totally revamped whereis(1), bringing back all the functionality of
the 4.3BSD command.  Rewritten from scratch after the old man page,
taking account for the different situation with man pages and source
tree hierarchy (re: /usr/src/gnu) of the FreeBSD project.

Reviewed by:	wosch (actually loooong time ago)
1996-06-15 12:29:48 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00