Question

I am running into a problem with the ./configure script for ffmpeg. My linux environment uses busybox, which only allows for limited set of linux commands. One command which is used in the ffmpeg ./configure script is mktemp -u, the problem here is the busybox for linux does not recognize the -u switch as valid, so it complains about it and breaks the configure process.

This is the relevant code in ./configure which uses the mktemp -u command:

if ! check_cmd type mktemp; then
    # simple replacement for missing mktemp
    # NOT SAFE FOR GENERAL USE
    mktemp(){
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
    }
fi

tmpfile(){
    tmp=$(mktemp -u "${TMPDIR}/ffconf.XXXXXXXX")$2 &&
        (set -C; exec > $tmp) 2>/dev/null ||
        die "Unable to create temporary file in $TMPDIR."
    append TMPFILES $tmp
    eval $1=$tmp
}

I am not good with bash scripting at all, so I was wondering if anyone one had an idea on how I can force this configure script to not use mktemp -u and use the 'replacement' alternative option that is available in as per the snippet above. Thanks.

btw... simply removing the -u switch does not work. Nor does replacing it with -t, or -p. I believe the mktemp has to be bypassed completely.

Was it helpful?

Solution

Change this:

if ! check_cmd type mktemp; then
    # simple replacement for missing mktemp
    # NOT SAFE FOR GENERAL USE
    mktemp(){
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
    }
fi

To this:

#if ! check_cmd type mktemp; then
if true; then # Force the use of mktemp()
    # simple replacement for missing mktemp
    # NOT SAFE FOR GENERAL USE
    mktemp(){
        echo "${2%XXX*}.${HOSTNAME}.${UID}.$$"
    }
fi

You could alternatively remove the entire if fi constructs so that what's left is just the mktemp() definition but I'd rather leave them in as a way to remember what needed to be done and in case you need to go back.

OTHER TIPS

I would just change the configure script to drop the -u option to mktemp and remove the set -C; (which sets no-clobber mode, and requires the file to be absent; removing the -u means you need to remove the set -C too).

The MacOS X manual pages for mktemp(1) say:

-u Operate in ``unsafe'' mode. The temp file will be unlinked before mktemp exits. This is slightly better than mktemp(3) but still introduces a race condition. Use of this option is not encouraged.

The generated file name is unlinked by mktemp, and then immediately re-created by the configure script, which is a trifle silly. Dropping the -u means that the file name will already exist, having been created securely.

If the software is something you are going to use often, then report the issue to the developer or maintainer of the software.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top