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 43The 44.Fn getlocalbase 45function returns the path to the local software base directory. 46Normally this is the 47.Pa /usr/local 48directory. 49First the 50.Ev LOCALBASE 51environment variable is checked. 52If that does not exist then the 53.Va user.localbase 54sysctl is checked. 55If that also does not exist then the value of the 56.Dv _PATH_LOCALBASE 57compile-time variable is used. 58If that is undefined then the default of 59.Pa /usr/local 60is used. 61.Pp 62The value returned by the 63.Fn getlocalbase 64function shall not be modified. 65.Sh IMPLEMENTATION NOTES 66Calls to 67.Fn getlocalbase 68will perform a setugid check on the running binary before checking the 69environment. 70.Sh RETURN VALUES 71The 72.Fn getlocalbase 73function always succeeds and returns a pointer to a string, whose length 74may exceed MAXPATHLEN if it has been derived from the environment variable 75LOCALBASE. 76No length checks are performed on the result. 77.Sh ENVIRONMENT 78The 79.Fn getlocalbase 80library function retrieves the 81.Ev LOCALBASE 82environment variable. 83.Sh ERRORS 84The 85.Fn getlocalbase 86function always succeeds. 87.Sh SEE ALSO 88.Xr env 1 , 89.Xr src.conf 5 , 90.Xr sysctl 8 91.Sh HISTORY 92The 93.Nm 94library function first appeared in 95.Fx 13.0 . 96.Sh AUTHORS 97This 98manual page was written by 99.An Scott Long Aq Mt scottl@FreeBSD.org and Stefan Eßer Aq Mt se@FreeBSD.org . 100