summaryrefslogtreecommitdiff
path: root/trust
diff options
context:
space:
mode:
Diffstat (limited to 'trust')
-rw-r--r--trust/save.c22
-rw-r--r--trust/token.c10
2 files changed, 19 insertions, 13 deletions
diff --git a/trust/save.c b/trust/save.c
index acef483..0f047fc 100644
--- a/trust/save.c
+++ b/trust/save.c
@@ -282,20 +282,18 @@ p11_save_finish_file (p11_save_file *file,
if (!path)
ret = false;
- } else {
- if ((file->flags & P11_SAVE_OVERWRITE) &&
+ } else if ((file->flags & P11_SAVE_OVERWRITE) &&
unlink (path) < 0 && errno != ENOENT) {
- p11_message ("couldn't remove original file: %s: %s",
- path, strerror (errno));
- ret = false;
- }
+ p11_message ("couldn't remove original file: %s: %s",
+ path, strerror (errno));
+ ret = false;
+ }
- if (ret == true &&
- rename (file->temp, file->path) < 0) {
- p11_message ("couldn't complete writing file: %s: %s",
- file->path, strerror (errno));
- ret = false;
- }
+ if (ret == true &&
+ rename (file->temp, path) < 0) {
+ p11_message ("couldn't complete writing file: %s: %s",
+ path, strerror (errno));
+ ret = false;
}
unlink (file->temp);
diff --git a/trust/token.c b/trust/token.c
index c91acd2..12e9e4c 100644
--- a/trust/token.c
+++ b/trust/token.c
@@ -572,11 +572,15 @@ writer_put_object (p11_save_file *file,
static bool
mkdir_with_parents (const char *path)
{
- int mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
char *parent;
bool ret;
+#ifdef OS_UNIX
+ int mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
if (mkdir (path, mode) == 0)
+#else
+ if (mkdir (path) == 0)
+#endif
return true;
switch (errno) {
@@ -586,7 +590,11 @@ mkdir_with_parents (const char *path)
ret = mkdir_with_parents (parent);
free (parent);
if (ret == true) {
+#ifdef OS_UNIX
if (mkdir (path, mode) == 0)
+#else
+ if (mkdir (path) == 0)
+#endif
return true;
}
}