check_security_file_permission(
    FILE *verbose)
{
    struct stat stat_buf;
    char *quoted = quote_string(SECURITY_FILE);

    if (!stat(SECURITY_FILE, &stat_buf)) {
        if (stat_buf.st_uid != 0 ) {
            if (verbose)
		g_fprintf(verbose, "ERROR [%s is not owned by root]\n", quoted);
	    g_debug("ERROR [%s is not owned by root]", quoted);
            amfree(quoted);
            return FALSE;
        }
        if (stat_buf.st_mode & S_IWOTH) {
            if (verbose)
		g_fprintf(verbose, "ERROR [%s is writable by everyone]\n", quoted);
	    g_debug("ERROR [%s is writable by everyone]", quoted);
            amfree(quoted);
            return FALSE;
        }
        if (stat_buf.st_mode & S_IWGRP) {
            if (verbose)
		g_fprintf(verbose, "ERROR [%s is writable by the group]\n", quoted);
	    g_debug("ERROR [%s is writable by the group]", quoted);
            amfree(quoted);
            return FALSE;
        }
	if (EUIDACCESS(SECURITY_FILE, R_OK) == -1) {
	    char  ruid_str[NUM_STR_SIZE];
	    char  euid_str[NUM_STR_SIZE];

	    g_snprintf(ruid_str, sizeof(ruid_str), "%d", (int)getuid());
	    g_snprintf(euid_str, sizeof(euid_str), "%d", (int)geteuid());

	    if (verbose)
		g_fprintf(verbose, "ERROR [can not access '%s': %s (ruid:%s euid:%s)]\n", quoted, strerror(errno), ruid_str, euid_str);
	    g_debug("ERROR [can not access '%s': %s (ruid:%s euid:%s)]", quoted, strerror(errno), ruid_str, euid_str);
	    amfree(quoted);
	    return FALSE;
	}
    }
    else {
        if (verbose)
	    g_fprintf(verbose, "ERROR [can not stat %s: %s]\n", quoted, strerror(errno));
	g_debug("ERROR [can not stat %s: %s]", quoted, strerror(errno));
        amfree(quoted);
        return FALSE;
    }
    amfree(quoted);
    return TRUE;
}
check_security_file_permission(
    FILE *verbose)
{
    struct stat stat_buf;
    char *quoted = quote_string(SECURITY_FILE);

    if (!stat(SECURITY_FILE, &stat_buf)) {
        if (stat_buf.st_uid != 0 ) {
            if (verbose)
		g_fprintf(verbose, "ERROR [%s is not owned by root]\n", quoted);
	    g_debug("ERROR [%s is not owned by root]", quoted);
            amfree(quoted);
            return FALSE;
        }
        if (stat_buf.st_mode & S_IWOTH) {
            if (verbose)
		g_fprintf(verbose, "ERROR [%s is writable by everyone]\n", quoted);
	    g_debug("ERROR [%s is writable by everyone]", quoted);
            amfree(quoted);
            return FALSE;
        }
        if (stat_buf.st_mode & S_IWGRP) {
            if (verbose)
		g_fprintf(verbose, "ERROR [%s is writable by the group]\n", quoted);
	    g_debug("ERROR [%s is writable by the group]", quoted);
            amfree(quoted);
            return FALSE;
        }
	if (EUIDACCESS(SECURITY_FILE, R_OK) == -1) {
	    char  ruid_str[NUM_STR_SIZE];
	    char  euid_str[NUM_STR_SIZE];

	    g_snprintf(ruid_str, sizeof(ruid_str), "%d", (int)getuid());
	    g_snprintf(euid_str, sizeof(euid_str), "%d", (int)geteuid());

	    if (verbose)
		g_fprintf(verbose, "ERROR [can not access '%s': %s (ruid:%s euid:%s)]\n", quoted, strerror(errno), ruid_str, euid_str);
	    g_debug("ERROR [can not access '%s': %s (ruid:%s euid:%s)]", quoted, strerror(errno), ruid_str, euid_str);
	    amfree(quoted);
	    return FALSE;
	}
    }
    else {
        if (verbose)
	    g_fprintf(verbose, "ERROR [can not stat %s: %s]\n", quoted, strerror(errno));
	g_debug("ERROR [can not stat %s: %s]", quoted, strerror(errno));
        amfree(quoted);
        return FALSE;
    }
    amfree(quoted);
    return TRUE;
}