-/* Make a directory (internal function).
- * If the directory already exists then we pretend we created it.
- *
- * The uid and gid are used only if we are running as root.
- */
-static int
-mk1dir(
- const char *dir, /* directory to create */
- mode_t mode, /* mode for new directory */
- uid_t G_GNUC_UNUSED uid, /* uid for new directory */
- gid_t G_GNUC_UNUSED gid) /* gid for new directory */
-{
- int rc; /* return code */
-
- rc = mkdir(dir, mode);
- if(rc != 0) { /* maybe someone beat us to it */
- int serrno;
-
- serrno = errno;
- if(access(dir, F_OK) != 0)
- rc = -1;
- errno = serrno; /* pass back the real error */
- }
-
- /* mkdir is affected by umask, so set the mode bits manually */
- if (rc == 0) {
- rc = chmod(dir, mode);
- }
-
- if (rc == 0 && geteuid() == 0) {
- rc = chown(dir, uid, gid);
- }
-
- return rc;
-}
-
-