JDK-1263792 : java.io: Not relying on umask in open/create/mkdir
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.1.4,1.1.5,1.1.6,1.2.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,solaris_2.5,solaris_2.5.1
  • CPU: generic,sparc
  • Submitted: 1996-08-15
  • Updated: 1999-11-23
  • Resolved: 1998-04-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.2.0 1.2beta4Fixed
Related Reports
Duplicate :  
Duplicate :  
Description
The canonical implementation of creation in POSIX systems is to open with
maximal permission (usually 777 or 666) and let umask clear what the user
wants to clear.  You should not assume that  people want their files and/or
directories protected or not protected from "other".   Turn on all the bits
and let umask sort 'em out.

java_io_File_mkdir0 uses 771
java_io_FileOutputStream_open uses 664
java_io_FileOutputStream_openAppend uses 664
java_io_RandomAccessFile_open users 664
in src/share/sun/jio/jio.c, jio_open uses 644
in src/solaris/doc/java/native/file.c, demo_OutputFile_open uses 644
in src/solaris/java/javai/javai.c, OpenCode uses 644 twice
in src/solaris/java/javap/javap.c, OpenCode uses 644
in src/win32/bin/hotjava.c, main uses 644



ken.arnold@East 1998-01-07

This is still a problem, and is causing problems in our development environment where javac creates directories with the wrong mode.  This is just not the right
mapping for UNIX -- UNIX custom is to create with all reasonable permissions on and let umask sort it out.  This is a simple thing to fix -- surely we can get it into 1.2?

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.2beta4 FIXED IN: 1.2beta4 INTEGRATED IN: 1.2beta4
14-06-2004

PUBLIC COMMENTS The canonical implementation of creation in POSIX systems is to open with maximal permission (usually 777 or 666) and let umask clear what the user wants to clear. You should not assume that people want their files and/or directories protected or not protected from "other". Turn on all the bits and let umask sort 'em out. java_io_File_mkdir0 uses 771 java_io_FileOutputStream_open uses 664 java_io_FileOutputStream_openAppend uses 664 java_io_RandomAccessFile_open users 664 in src/share/sun/jio/jio.c, jio_open uses 644 in src/solaris/doc/java/native/file.c, demo_OutputFile_open uses 644 in src/solaris/java/javai/javai.c, OpenCode uses 644 twice in src/solaris/java/javap/javap.c, OpenCode uses 644 in src/win32/bin/hotjava.c, main uses 644
10-06-2004

SUGGESTED FIX Proposed fix for 1.1.8: Proposed fix for 1.1.8 Note: src/win32/bin/hotjava.c is not in 1.1.8 source tree sccs diffs -bitwc /home/carolyn/bld/517713/JDK118/src/share/java/lang/filesystem.c ------- filesystem.c ------- *** /tmp/dGFxDG_ Fri Dec 11 10:40:20 1998 --- /home/carolyn/bld/517713/JDK118/src/share/java/lang/filesystem.c Wed Dec 9 17:39:51 1998 *************** *** 194,200 **** path = makePlatformCString(thisptr->path); ! return sysMkdir(path, 0771) != -1; } long --- 194,200 ---- path = makePlatformCString(thisptr->path); ! return sysMkdir(path, 0777) != -1; } long sccs diffs -bitwc /home/carolyn/bld/517713/JDK118/src/share/java/lang/io.c ------- io.c ------- *** /tmp/d0qrmcU Fri Dec 11 10:40:21 1998 --- /home/carolyn/bld/517713/JDK118/src/share/java/lang/io.c Wed Dec 9 17:41:24 1998 *************** *** 254,260 **** buf = makePlatformCString(name); flags = O_WRONLY|O_CREAT|O_TRUNC; ! if ((fd = sysOpenFD(fdptr, buf, flags, 0664)) == -1) { char utfPath[128]; javaString2UTF(name, utfPath, sizeof(utfPath)); SignalError(0, IO_EXCEPTION, utfPath); --- 254,260 ---- buf = makePlatformCString(name); flags = O_WRONLY|O_CREAT|O_TRUNC; ! if ((fd = sysOpenFD(fdptr, buf, flags, 0666)) == -1) { char utfPath[128]; javaString2UTF(name, utfPath, sizeof(utfPath)); SignalError(0, IO_EXCEPTION, utfPath); *************** *** 283,289 **** buf = makePlatformCString(name); flags = O_WRONLY|O_CREAT|O_APPEND; ! if ((fd = sysOpenFD(fdptr, buf, flags, 0664)) == -1) { char utfPath[128]; javaString2UTF(name, utfPath, sizeof(utfPath)); SignalError(0, IO_EXCEPTION, utfPath); --- 283,289 ---- buf = makePlatformCString(name); flags = O_WRONLY|O_CREAT|O_APPEND; ! if ((fd = sysOpenFD(fdptr, buf, flags, 0666)) == -1) { char utfPath[128]; javaString2UTF(name, utfPath, sizeof(utfPath)); SignalError(0, IO_EXCEPTION, utfPath); *************** *** 396,402 **** buf = makePlatformCString(name); if (writeable) { ! if ((fd = sysOpenFD(fdptr, buf, O_RDWR|O_CREAT, 0664)) == -1) { char utfPath[128]; javaString2UTF(name, utfPath, sizeof(utfPath)); SignalError(0, IO_EXCEPTION, utfPath); --- 396,402 ---- buf = makePlatformCString(name); if (writeable) { ! if ((fd = sysOpenFD(fdptr, buf, O_RDWR|O_CREAT, 0666)) == -1) { char utfPath[128]; javaString2UTF(name, utfPath, sizeof(utfPath)); SignalError(0, IO_EXCEPTION, utfPath); sccs diffs -bitwc /home/carolyn/bld/517713/JDK118/src/share/sun/jio/jio.c ------- jio.c ------- *** /tmp/dNSc_j_ Fri Dec 11 10:40:21 1998 --- /home/carolyn/bld/517713/JDK118/src/share/sun/jio/jio.c Wed Dec 9 17:43:34 1998 *************** *** 188,194 **** default: return (JIOFILE *)0; } ! return jio_fdopen(open(name, open_flags, 0644), mode); } EXPORT JIOFILE * --- 188,194 ---- default: return (JIOFILE *)0; } ! return jio_fdopen(open(name, open_flags, 0666), mode); } EXPORT JIOFILE * sccs diffs -bitwc /home/carolyn/bld/517713/JDK118/src/solaris/doc/java/native/file.c ------- file.c ------- *** /tmp/d0x2SOx Fri Dec 11 10:40:21 1998 --- /home/carolyn/bld/517713/JDK118/src/solaris/doc/java/native/file.c Thu Dec 10 09:01:13 1998 *************** *** 204,210 **** javaString2CString(unhand(this)->path, buf, sizeof(buf)); convertPath(buf); ! fd = open(buf, O_RDWR|O_CREAT|O_TRUNC, 0644); if (fd < 0) return(FALSE); unhand(this)->fd = fd; --- 204,210 ---- javaString2CString(unhand(this)->path, buf, sizeof(buf)); convertPath(buf); ! fd = open(buf, O_RDWR|O_CREAT|O_TRUNC, 0666); if (fd < 0) return(FALSE); unhand(this)->fd = fd; sccs diffs -bitwc /home/carolyn/bld/517713/JDK118/src/solaris/java/javai/javai.c ------- javai.c ------- *** /tmp/d0UfHn9 Fri Dec 11 10:40:22 1998 --- /home/carolyn/bld/517713/JDK118/src/solaris/java/javai/javai.c Wed Dec 9 17:44:58 1998 *************** *** 615,621 **** char *src, *dst; int i; ! if (st != 0 && fn != 0 && (fd = open(fn, 0, 0644)) >= 0 && fstat(fd, st) < 0) { close(fd); fd = -1; --- 615,621 ---- char *src, *dst; int i; ! if (st != 0 && fn != 0 && (fd = open(fn, 0, 0666)) >= 0 && fstat(fd, st) < 0) { close(fd); fd = -1; *************** *** 683,689 **** Execute(com, alt); } if (fn) { ! fd = open(fn, 0, 0644); if (fd >= 0 && st) if (fstat(fd, st) < 0) { close(fd); --- 683,689 ---- Execute(com, alt); } if (fn) { ! fd = open(fn, 0, 0666); if (fd >= 0 && st) if (fstat(fd, st) < 0) { close(fd); sccs diffs -bitwc /home/carolyn/bld/517713/JDK118/src/solaris/java/javap/javap.c ------- javap.c ------- *** /tmp/d2G7AO_ Fri Dec 11 10:40:22 1998 --- /home/carolyn/bld/517713/JDK118/src/solaris/java/javap/javap.c Wed Dec 9 17:46:07 1998 *************** *** 157,163 **** OpenCode(char *fn, char *sfn, char *dir, struct stat * st) { long codefd; ! if (fn == 0 || (codefd = open(fn, 0, 0644)) < 0 || fstat(codefd, st) < 0) return -2; return codefd; --- 157,163 ---- OpenCode(char *fn, char *sfn, char *dir, struct stat * st) { long codefd; ! if (fn == 0 || (codefd = open(fn, 0, 0666)) < 0 || fstat(codefd, st) < 0) return -2; return codefd; carolyn.lowenthal@Eng 1998-12-11
11-12-1998

EVALUATION I'm going to fix this in 1.2beta4. tom.rodriguez@Eng 1998-03-16
16-03-1998