[klibc] [PATCH] dd O_CREAT permission
Olaf Hering
olh at suse.de
Sun Nov 23 18:11:41 PST 2003
O_CREAT requires a mode argument for open()
This patch passes the current umask of the dd process.
--- usr/klibc/klibc-0.81.orig/utils/dd.c 2002-09-03 00:49:08.000000000 +0200
+++ usr/klibc/klibc-0.81/utils/dd.c 2003-11-23 18:04:11.000000000 +0100
@@ -8,6 +8,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
@@ -483,7 +485,7 @@ int main(int argc, char *argv[])
* Open the output file, if specified.
*/
if (OPT_OF->str) {
- wr_fd = open(OPT_OF->str, O_RDWR|O_CREAT);
+ wr_fd = open(OPT_OF->str, O_RDWR|O_CREAT,~umask(0) & (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH));
if (wr_fd == -1) {
perror("open output file");
return 1;
--
USB is for mice, FireWire is for men!
sUse lINUX ag, nÜRNBERG
More information about the klibc
mailing list