mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Remove 'umask' calls from 'mkdir'.
Fixes <http://bugs.gnu.org/24659>. * libguile/filesys.c (SCM_DEFINE): Remove calls to 'umask' when MODE is unbound; instead, use 0777 as the mode. Update docstring to clarify this. * doc/ref/posix.texi (File System): Adjust accordingly. * NEWS: Mention it.
This commit is contained in:
parent
25652ff84c
commit
844b2cf758
3 changed files with 27 additions and 19 deletions
14
NEWS
14
NEWS
|
@ -996,9 +996,21 @@ Changes in 2.0.13 (since 2.0.12):
|
||||||
See "File System" in the manual, for more.
|
See "File System" in the manual, for more.
|
||||||
|
|
||||||
* Bug fixes
|
* Bug fixes
|
||||||
|
|
||||||
|
** 'mkdir' procedure no longer calls umask(2) (<http://bugs.gnu.org/24659>)
|
||||||
|
|
||||||
|
When the second argument to the 'mkdir' procedure was omitted, it would
|
||||||
|
call umask(0) followed by umask(previous_umask) and apply the umask to
|
||||||
|
mode #o777.
|
||||||
|
|
||||||
|
This was unnecessary and a security issue for multi-threaded
|
||||||
|
applications: during a small window the process' umask was set to zero,
|
||||||
|
so other threads calling mkdir(2) or open(2) could end up creating
|
||||||
|
world-readable/writable/executable directories or files.
|
||||||
|
|
||||||
** Fix optimizer bug when compiling fixpoint operator
|
** Fix optimizer bug when compiling fixpoint operator
|
||||||
** Fix build error on MinGW
|
** Fix build error on MinGW
|
||||||
** Update `uname' implementation on MinGW
|
** Update 'uname' implementation on MinGW
|
||||||
|
|
||||||
|
|
||||||
Changes in 2.0.12 (since 2.0.11):
|
Changes in 2.0.12 (since 2.0.11):
|
||||||
|
|
|
@ -870,9 +870,10 @@ Create a symbolic link named @var{newpath} with the value (i.e., pointing to)
|
||||||
@deffn {Scheme Procedure} mkdir path [mode]
|
@deffn {Scheme Procedure} mkdir path [mode]
|
||||||
@deffnx {C Function} scm_mkdir (path, mode)
|
@deffnx {C Function} scm_mkdir (path, mode)
|
||||||
Create a new directory named by @var{path}. If @var{mode} is omitted
|
Create a new directory named by @var{path}. If @var{mode} is omitted
|
||||||
then the permissions of the directory file are set using the current
|
then the permissions of the directory are set to @code{#o777}
|
||||||
umask (@pxref{Processes}). Otherwise they are set to the decimal
|
masked with the current umask (@pxref{Processes, @code{umask}}).
|
||||||
value specified with @var{mode}. The return value is unspecified.
|
Otherwise they are set to the value specified with @var{mode}.
|
||||||
|
The return value is unspecified.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Scheme Procedure} rmdir path
|
@deffn {Scheme Procedure} rmdir path
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006,
|
/* Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004, 2006,
|
||||||
* 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
|
* 2009, 2010, 2011, 2012, 2013, 2014, 2016 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -1258,26 +1258,21 @@ SCM_DEFINE (scm_getcwd, "getcwd", 0, 0, 0,
|
||||||
SCM_DEFINE (scm_mkdir, "mkdir", 1, 1, 0,
|
SCM_DEFINE (scm_mkdir, "mkdir", 1, 1, 0,
|
||||||
(SCM path, SCM mode),
|
(SCM path, SCM mode),
|
||||||
"Create a new directory named by @var{path}. If @var{mode} is omitted\n"
|
"Create a new directory named by @var{path}. If @var{mode} is omitted\n"
|
||||||
"then the permissions of the directory file are set using the current\n"
|
"then the permissions of the directory are set to @code{#o777}\n"
|
||||||
"umask. Otherwise they are set to the decimal value specified with\n"
|
"masked with the current umask (@pxref{Processes, @code{umask}}).\n"
|
||||||
"@var{mode}. The return value is unspecified.")
|
"Otherwise they are set to the value specified with @var{mode}.\n"
|
||||||
|
"The return value is unspecified.")
|
||||||
#define FUNC_NAME s_scm_mkdir
|
#define FUNC_NAME s_scm_mkdir
|
||||||
{
|
{
|
||||||
int rv;
|
int rv;
|
||||||
mode_t mask;
|
mode_t c_mode;
|
||||||
|
|
||||||
if (SCM_UNBNDP (mode))
|
c_mode = SCM_UNBNDP (mode) ? 0777 : scm_to_uint (mode);
|
||||||
{
|
|
||||||
mask = umask (0);
|
STRING_SYSCALL (path, c_path, rv = mkdir (c_path, c_mode));
|
||||||
umask (mask);
|
|
||||||
STRING_SYSCALL (path, c_path, rv = mkdir (c_path, 0777 ^ mask));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
STRING_SYSCALL (path, c_path, rv = mkdir (c_path, scm_to_uint (mode)));
|
|
||||||
}
|
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
SCM_SYSERROR;
|
SCM_SYSERROR;
|
||||||
|
|
||||||
return SCM_UNSPECIFIED;
|
return SCM_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue