Ignore:
Timestamp:
Jun 26, 2020, 7:16:26 PM (5 years ago)
Author:
bird
Message:

kmk: Avoid setting umask just to get it, store the current value in a global variable (g_fUMask). The umask(0777) call in cp.c raced other code (kmk_append) that created files and directories, leaving us with read-only files sometimes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/kmkbuiltin.c

    r3352 r3389  
    402402                {
    403403                    /*
    404                      * Call the worker function, making sure to preserve umask.
     404                     * Call the worker function.
    405405                     */
    406406#ifdef CONFIG_WITH_KMK_BUILTIN_STATS
     
    408408#endif
    409409                    KMKBUILTINCTX Ctx;
    410                     int const iUmask = umask(0);        /* save umask */
    411                     umask(iUmask);
     410                    assert(g_fUMask == umask(g_fUMask));
    412411
    413412                    Ctx.pszProgName = pEntry->uName.s.sz;
     
    448447                        rc = 99;
    449448
    450                     umask(iUmask);                      /* restore it */
     449                    assert(g_fUMask == umask(g_fUMask)); /* builtin command must preserve umask! */
    451450
    452451#ifdef CONFIG_WITH_KMK_BUILTIN_STATS
Note: See TracChangeset for help on using the changeset viewer.