return S_ISDIR (buf.st_mode);
}
+
+char *
+do_mkdtemp (char *template)
+{
+ char *r;
+
+ NEED_ROOT (NULL);
+ ABS_PATH (template, NULL);
+
+ CHROOT_IN;
+ r = mkdtemp (template);
+ CHROOT_OUT;
+
+ if (r == NULL) {
+ reply_with_perror ("mkdtemp: %s", template);
+ return NULL;
+ }
+
+ /* The caller will free template AND try to free the return value,
+ * so we must make a copy here.
+ */
+ if (r == template) {
+ r = strdup (template);
+ if (r == NULL) {
+ reply_with_perror ("strdup");
+ return NULL;
+ }
+ }
+ return r;
+}
It is an interface to the L<scrub(1)> program. See that
manual page for more details.");
+ ("mkdtemp", (RString "dir", [String "template"]), 117, [],
+ [InitBasicFS, Always, TestRun (
+ [["mkdir"; "/tmp"];
+ ["mkdtemp"; "/tmp/tmpXXXXXX"]])],
+ "create a temporary directory",
+ "\
+This command creates a temporary directory. The
+C<template> parameter should be a full pathname for the
+temporary directory with the six characters being
+\"XXXXXX\".
+
+For example: \"/tmp/tmpXXXXXX\" or \"/Temp/tmpXXXXXX\",
+the second one being suitable for Windows.
+
+The name of the temporary directory that was created
+is returned.
+
+The caller is responsible for deleting the temporary
+directory and its contents after use.
+
+See also: L<mkdtemp(3)>");
+
]
let all_functions = non_daemon_functions @ daemon_functions