aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/rdsquashfs/restore_fstree.c17
-rw-r--r--lib/sqfs/unix/io_file.c2
2 files changed, 13 insertions, 6 deletions
diff --git a/bin/rdsquashfs/restore_fstree.c b/bin/rdsquashfs/restore_fstree.c
index 8f99439..e79f333 100644
--- a/bin/rdsquashfs/restore_fstree.c
+++ b/bin/rdsquashfs/restore_fstree.c
@@ -7,10 +7,11 @@
#include "rdsquashfs.h"
#ifdef _WIN32
-static int create_node(const sqfs_tree_node_t *n, const char *name)
+static int create_node(const sqfs_tree_node_t *n, const char *name, int flags)
{
WCHAR *wpath;
HANDLE fh;
+ (void)flags;
wpath = path_to_windows(name);
if (wpath == NULL)
@@ -43,10 +44,10 @@ fail:
return -1;
}
#else
-static int create_node(const sqfs_tree_node_t *n, const char *name)
+static int create_node(const sqfs_tree_node_t *n, const char *name, int flags)
{
sqfs_u32 devno;
- int fd;
+ int fd, mode;
switch (n->inode->base.mode & S_IFMT) {
case S_IFDIR:
@@ -88,7 +89,13 @@ static int create_node(const sqfs_tree_node_t *n, const char *name)
}
break;
case S_IFREG:
- fd = open(name, O_WRONLY | O_CREAT | O_EXCL, 0600);
+ if (flags & UNPACK_CHMOD) {
+ mode = (n->inode->base.mode & ~S_IFMT) | 0200;
+ } else {
+ mode = 0644;
+ }
+
+ fd = open(name, O_WRONLY | O_CREAT | O_EXCL, mode);
if (fd < 0) {
fprintf(stderr, "creating %s: %s\n",
@@ -131,7 +138,7 @@ static int create_node_dfs(const sqfs_tree_node_t *n, int flags)
if (!(flags & UNPACK_QUIET))
printf("creating %s\n", name);
- ret = create_node(n, name);
+ ret = create_node(n, name, flags);
free(name);
if (ret)
return -1;
diff --git a/lib/sqfs/unix/io_file.c b/lib/sqfs/unix/io_file.c
index 52fc94b..d4c1232 100644
--- a/lib/sqfs/unix/io_file.c
+++ b/lib/sqfs/unix/io_file.c
@@ -168,7 +168,7 @@ sqfs_file_t *sqfs_open_file(const char *filename, sqfs_u32 flags)
}
}
- file->fd = open(filename, open_mode, 0600);
+ file->fd = open(filename, open_mode, 0644);
if (file->fd < 0) {
temp = errno;
free(file);