mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 08:43:19 -04:00
libbe: don't hardcode /tmp
Respect $TMPDIR if it's set, fallback to _PATH_TMP (not hardcoded /tmp)
if it's not.
Bump .Dd after recent commits.
Reviewed by: rcm
(cherry picked from commit 2f11393fee)
This commit is contained in:
parent
0635fe2922
commit
8dc42b80fd
2 changed files with 17 additions and 3 deletions
|
|
@ -33,7 +33,7 @@
|
|||
#include "be.h"
|
||||
#include "be_impl.h"
|
||||
|
||||
#define LIBBE_MOUNT_PREFIX "be_mount." /* XXX */
|
||||
#define LIBBE_MOUNT_PREFIX "be_mount."
|
||||
|
||||
struct be_mountcheck_info {
|
||||
const char *path;
|
||||
|
|
@ -261,7 +261,17 @@ be_mount(libbe_handle_t *lbh, const char *bootenv, const char *mountpoint,
|
|||
|
||||
/* Create mountpoint if it is not specified */
|
||||
if (mountpoint == NULL) {
|
||||
strlcpy(mnt_temp, "/tmp/be_mount.XXXX", sizeof(mnt_temp));
|
||||
const char *tmpdir;
|
||||
|
||||
tmpdir = getenv("TMPDIR");
|
||||
if (tmpdir == NULL)
|
||||
tmpdir = _PATH_TMP;
|
||||
|
||||
if (snprintf(mnt_temp, sizeof(mnt_temp), "%s%s%sXXXX", tmpdir,
|
||||
tmpdir[strlen(tmpdir) - 1] == '/' ? "" : "/",
|
||||
LIBBE_MOUNT_PREFIX) >= (int)sizeof(mnt_temp))
|
||||
return (set_error(lbh, BE_ERR_PATHLEN));
|
||||
|
||||
if (mkdtemp(mnt_temp) == NULL)
|
||||
return (set_error(lbh, BE_ERR_IO));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.Dd March 18, 2024
|
||||
.Dd April 25, 2025
|
||||
.Dt LIBBE 3
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
|
@ -358,6 +358,10 @@ If
|
|||
is
|
||||
.Dv NULL ,
|
||||
a mount point will be generated in
|
||||
.Ev TMPDIR
|
||||
or, if
|
||||
.Ev TMPDIR
|
||||
is not set,
|
||||
.Pa /tmp
|
||||
using
|
||||
.Xr mkdtemp 3 .
|
||||
|
|
|
|||
Loading…
Reference in a new issue