Commit eb54a41c authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

config: if read-only, refuse to save the configuration

This restores the pre-1.0.0 behaviour. With the atomic vlcrc update,
VLC managed to work-around a read-only vlcrc. Indeed, Linux (POSIX?)
allows renaming a file onto an existing read-only file, which is
then replaced (both content and meta-data). In principle, you should
put the containing directory in read-only mode to avoid this, but this
is inconvenient as .config/vlc contains other files.
parent 75dda08f
......@@ -430,12 +430,18 @@ static int SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name,
file = config_OpenConfigFile( p_this );
if( file != NULL )
{
/* look for file size */
fseek( file, 0L, SEEK_END );
i_sizebuf = ftell( file );
fseek( file, 0L, SEEK_SET );
if( i_sizebuf >= LONG_MAX )
i_sizebuf = 0;
struct stat st;
/* Some users make vlcrc read-only to prevent changes.
* The atomic replacement scheme breaks this "feature",
* so we check for read-only by hand. */
if (fstat (fileno (file), &st)
|| !(st.st_mode & S_IWUSR))
{
msg_Err (p_this, "configuration file is read-only");
goto error;
}
i_sizebuf = ( st.st_size < LONG_MAX ) ? st.st_size : 0;
}
p_bigbuffer = p_index = malloc( i_sizebuf+1 );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment