Changeset f277225 for storage_xml.c


Ignore:
Timestamp:
2010-06-06T21:58:46Z (14 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
04a927c
Parents:
3dc6d86
Message:

Use mkstemp() instead of just a tilde-file when writing new configs to a
temporary file. This solves hard-to-debug issues where for example the
user hand-edited his configs as root and left a root-owned user.xml~ file
behind.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • storage_xml.c

    r3dc6d86 rf277225  
    404404                return STORAGE_ALREADY_EXISTS;
    405405       
    406         strcat( path, "~" );
    407         if( ( fd = open( path, O_WRONLY | O_CREAT | O_TRUNC, 0600 ) ) < 0 )
     406        strcat( path, ".XXXXXX" );
     407        if( ( fd = mkstemp( path ) ) < 0 )
    408408        {
    409409                irc_usermsg( irc, "Error while opening configuration file." );
     
    499499        close( fd );
    500500       
    501         path2 = g_strndup( path, strlen( path ) - 1 );
     501        path2 = g_strndup( path, strlen( path ) - 7 );
    502502        if( rename( path, path2 ) != 0 )
    503503        {
Note: See TracChangeset for help on using the changeset viewer.