hfaxd/FileSystem.c++
/*
 * Force the specified file to have the GID setup as
 * the effective GID of the process.  On System-V-style
 * filesystems this happens automatically and there is
 * nothing to do.  On BSD-style filesystems however the
 * file's GID is set from the GID of the containing
 * directory so we must explicitly set the value.  Note
 * that we must auto-detect the appropriate semantics
 * because some systems support both styles and the
 * specific scheme is selectable on a per-filesystem
 * basis (e.g. IRIX).
 */
Force the specified file to have the GID setup as
the effective GID of the process.  On System-V-style
filesystems this happens automatically and there is
nothing to do.  On BSD-style filesystems however the
file's GID is set from the GID of the containing
directory so we must explicitly set the value.  Note
that we must auto-detect the appropriate semantics
because some systems support both styles and the
specific scheme is selectable on a per-filesystem
basis .
Force the specified file to have the GID setup as the effective GID of the process . On System - V - style filesystems this happens automatically and there is nothing to do . On BSD - style filesystems however the file ' s GID is set from the GID of the containing directory so we must explicitly set the value . Note that we must auto - detect the appropriate semantics because some systems support both styles and the specific scheme is selectable on a per - filesystem basis .
void
HylaFAXServer::setFileOwner(const char* file)
{
    if (IS(CHECKGID)) {				
        struct stat sb;
        if (!FileCache::lookup(file, sb)) {
            fatal("setFileOwner called for non-existent file (check)");
        }
        if (sb.st_gid != (gid_t) uid) {
            state |= S_SETGID;			
        } else {
            state &= ~S_SETGID;			
        }
        if (TRACE(SERVER)) {
            logDebug("Filesystem has %s-style file creation semantics.",
                IS(SETGID) ? "BSD" : "SysV");
        }
        state &= ~S_CHECKGID;
    }
    if (IS(SETGID)) {
        struct stat sb;
        if (!FileCache::lookup(file, sb)) {
            fatal("setFileOwner called for non-existent file (set)");
        }
        if (!FileCache::chown(file, sb.st_uid, (gid_t) uid)) {
            logError("%s: chown: %s", file, strerror(errno));
        }
    }
}
void HylaFAXServer :: setFileOwner ( const char * file ) { if ( IS ( CHECKGID ) ) { struct stat sb ; if ( ! FileCache :: lookup ( file , sb ) ) { fatal ( " " ) ; } if ( sb . st_gid != ( gid_t ) uid ) { state |= S_SETGID ; } else { state &= ~ S_SETGID ; } if ( TRACE ( SERVER ) ) { logDebug ( " " , IS ( SETGID ) ? " " : " " ) ; } state &= ~ S_CHECKGID ; } if ( IS ( SETGID ) ) { struct stat sb ; if ( ! FileCache :: lookup ( file , sb ) ) { fatal ( " " ) ; } if ( ! FileCache :: chown ( file , sb . st_uid , ( gid_t ) uid ) ) { logError ( " " , file , strerror ( errno ) ) ; } } }
Force the specified file to have the GID setup as
 the effective GID of the process.
Force the specified file to have the GID setup as the effective GID of the process .
// auto-detect how GID handled // not set, must force it // set by OS, no work to do