GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
GETLOCALBASE(3) FreeBSD Library Functions Manual GETLOCALBASE(3)

getlocalbase
return the path to the local software directory

System Utilities Library (libutil, -lutil)

#include <libutil.h>

const char*
getlocalbase(void);

The getlocalbase() function returns the path to the local software base directory. Normally this is the /usr/local directory. First the LOCALBASE environment variable is checked. If that does not exist then the user.localbase sysctl is checked. If that also does not exist then the value of the _PATH_LOCALBASE compile-time variable is used. If that is undefined then the default of /usr/local is used.

The contents of the string returned by the getlocalbase() function shall not be modified.

Calls to getlocalbase() will perform a setugid check on the running binary before checking the environment.

The address returned by getlocalbase() will point into the executing processes environment if it is the result of getenv(LOCALBASE), to a static buffer if it is the result of sysctl(user.localbase), and to a constant string if the compiled in default value is returned.

The same value will be returned on successive calls during the run-time of the program, ignoring any changes to the environment variable or the sysctl value that might have been made.

The getlocalbase() function can be compiled with a non-default value of LOCALBASE_CTL_LEN. A value of 0 will disable fetching of the sysctl value, a value less than MAXPATHLEN will put a limit on the maximum string length supported for this sysctl value. If built with a non-default value of LOCALBASE_CTL_LEN, a value of the user.localbase sysctl variable longer than this value will make getlocalbase() return a valid string that is not a valid path prefix in any filesystem.

The getlocalbase() function returns a pointer to a string, whose length may exceed MAXPATHLEN, if it has been obtained from the environment.

The getlocalbase() library function retrieves the LOCALBASE environment variable.

The getlocalbase() function always succeeds and returns a valid pointer to a string.

env(1), src.conf(5), sysctl(8)

The getlocalbase library function first appeared in FreeBSD 13.0.

This manual page was written by Scott Longscottl@FreeBSD.org and Stefan Eßer <se@FreeBSD.org>⟩.
November 25, 2020 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.