23 if ((rc =
Stat(dpath, &st)) < 0) {
34 rc =
Mkdir(dpath, 0755);
60 for (source = str, dest = s, i = 0; i < length; i++, source++, dest++) {
62 if (*dest == sep) fields++;
67 list =
xmalloc(
sizeof(*list) * (fields + 1));
91 list[0] =
_free(list[0]);
110 if (!overwrite &&
getenv(name))
return 0;
113 a =
xmalloc(strlen(name) + strlen(value) +
sizeof(
"="));
120 const char * tpmacro =
"%{?_tmppath:%{_tmppath}}%{!?_tmppath:/var/tmp}";
121 const char * tempfn = NULL;
122 const char * tfn = NULL;
123 static int _initialized = 0;
129 if (!prefix) prefix =
"";
137 if (
rpmioMkpath(tempfn, 0755, (uid_t) -1, (gid_t) -1))
144 ran = rand() % 100000;
151 sprintf(tfnbuf,
"rpm-tmp.%d", ran++);
152 tempfn =
_free(tempfn);
155 strcpy(tfnbuf,
"rpm-tmp.XXXXXX");
156 tempfn =
_free(tempfn);
157 tempfn =
rpmGenPath(prefix, tpmacro, mktemp(tfnbuf));
160 temput =
urlPath(tempfn, &tfn);
161 if (*tfn ==
'\0')
goto errxit;
175 fd =
Fopen(tempfn,
"w+x");
177 }
while ((fd == NULL ||
Ferror(fd)) &&
errno == EEXIST);
179 if (fd == NULL ||
Ferror(fd)) {
187 {
struct stat sb, sb2;
188 if (!stat(tfn, &sb) &&
S_ISLNK(sb.st_mode)) {
193 if (sb.st_nlink != 1) {
198 if (fstat(
Fileno(fd), &sb2) == 0) {
199 if (sb2.st_ino != sb.st_ino || sb2.st_dev != sb.st_dev) {
213 tempfn =
_free(tempfn);
220 tempfn =
_free(tempfn);
224 if (fd != NULL) (void)
Fclose(fd);
232 char * currDir = NULL;
236 currDir =
xrealloc(currDir, currDirLen);
237 memset(currDir, 0, currDirLen);
238 }
while (getcwd(currDir, currDirLen) == NULL &&
errno == ERANGE);