]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libutil/getlocalbase.3
Add function getlocalbase() to libutil.
[FreeBSD/FreeBSD.git] / lib / libutil / getlocalbase.3
1 .\"
2 .\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 .\"
4 .\" Copyright 2020 Scott Long
5 .\" Copyright 2020 Stefan Eßer
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\" $FreeBSD$
29 .\"
30 .Dd November 18, 2020
31 .Dt GETLOCALBASE 3
32 .Os
33 .Sh NAME
34 .Nm getlocalbase
35 .Nd "return the path to the local software directory"
36 .Sh LIBRARY
37 .Lb libutil
38 .Sh SYNOPSIS
39 .In libutil.h
40 .Ft const char*
41 .Fn getlocalbase "void"
42 .Sh DESCRIPTION
43 The
44 .Fn getlocalbase
45 function returns the path to the local software base directory.
46 Normally this is the
47 .Pa /usr/local
48 directory.
49 First the
50 .Ev LOCALBASE
51 environment variable is checked.
52 If that does not exist then the
53 .Va user.localbase
54 sysctl is checked.
55 If that also does not exist then the value of the
56 .Dv _PATH_LOCALBASE
57 compile-time variable is used.
58 If that is undefined then the default of
59 .Pa /usr/local
60 is used.
61 .Pp
62 The value returned by the
63 .Fn getlocalbase
64 function shall not be modified.
65 .Sh IMPLEMENTATION NOTES
66 Calls to
67 .Fn getlocalbase
68 will perform a setugid check on the running binary before checking the
69 environment.
70 .Sh RETURN VALUES
71 The
72 .Fn getlocalbase
73 function always succeeds and returns a pointer to a string, whose length
74 may exceed MAXPATHLEN if it has been derived from the environment variable
75 LOCALBASE.
76 No length checks are performed on the result.
77 .Sh ENVIRONMENT
78 The
79 .Fn getlocalbase
80 library function retrieves the
81 .Ev LOCALBASE
82 environment variable.
83 .Sh ERRORS
84 The
85 .Fn getlocalbase
86 function always succeeds.
87 .Sh SEE ALSO
88 .Xr env 1 ,
89 .Xr src.conf 5 ,
90 .Xr sysctl 8
91 .Sh HISTORY
92 The
93 .Nm
94 library function first appeared in
95 .Fx 13.0 .
96 .Sh AUTHORS
97 This
98 manual page was written by
99 .An Scott Long Aq Mt scottl@FreeBSD.org and Stefan Eßer Aq Mt se@FreeBSD.org .