-/* 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 uid, /* uid for new directory */
- gid_t gid) /* gid for new directory */
-{
- int rc; /* return code */
-
- rc = mkdir(dir, mode);
- if(rc != 0) {
- int serrno;
-
- serrno = errno;
- if(access(dir, F_OK) == 0)
- rc = 0; /* someone just beat us to it, so it's OK */
- errno = serrno;
- }
-
- /* 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;
-}
-
-