mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:07:45 +00:00
Userland: Fix broken permissions for files created by /bin/cp.
When passing O_CREAT to open(), it will grab a third "mode" argument from the stack. Let's not forget to actually pass this! Also use the process umask for the created files.
This commit is contained in:
parent
ca52de8e5c
commit
28a6ba498a
1 changed files with 5 additions and 3 deletions
|
@ -34,7 +34,7 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int dst_fd = open(dst_path.characters(), O_WRONLY | O_CREAT);
|
int dst_fd = open(dst_path.characters(), O_WRONLY | O_CREAT, 0666);
|
||||||
if (dst_fd < 0) {
|
if (dst_fd < 0) {
|
||||||
if (errno != EISDIR) {
|
if (errno != EISDIR) {
|
||||||
perror("open dst");
|
perror("open dst");
|
||||||
|
@ -45,7 +45,7 @@ int main(int argc, char** argv)
|
||||||
builder.append('/');
|
builder.append('/');
|
||||||
builder.append(FileSystemPath(src_path).basename());
|
builder.append(FileSystemPath(src_path).basename());
|
||||||
dst_path = builder.to_string();
|
dst_path = builder.to_string();
|
||||||
dst_fd = open(dst_path.characters(), O_WRONLY | O_CREAT);
|
dst_fd = open(dst_path.characters(), O_WRONLY | O_CREAT, 0666);
|
||||||
if (dst_fd < 0) {
|
if (dst_fd < 0) {
|
||||||
perror("open dst");
|
perror("open dst");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -75,7 +75,9 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = fchmod(dst_fd, src_stat.st_mode);
|
auto my_umask = umask(0);
|
||||||
|
umask(my_umask);
|
||||||
|
rc = fchmod(dst_fd, src_stat.st_mode & ~my_umask);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
perror("fchmod dst");
|
perror("fchmod dst");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue