static bool swap_sid_in_acl( struct security_descriptor *sd, struct dom_sid *s1, struct dom_sid *s2 ) { struct security_acl *theacl; int i; bool update = False; verbose_output(" Owner SID: %s\n", sid_string_tos(sd->owner_sid)); if ( dom_sid_equal( sd->owner_sid, s1 ) ) { sid_copy( sd->owner_sid, s2 ); update = True; verbose_output(" New Owner SID: %s\n", sid_string_tos(sd->owner_sid)); } verbose_output(" Group SID: %s\n", sid_string_tos(sd->group_sid)); if ( dom_sid_equal( sd->group_sid, s1 ) ) { sid_copy( sd->group_sid, s2 ); update = True; verbose_output(" New Group SID: %s\n", sid_string_tos(sd->group_sid)); } theacl = sd->dacl; verbose_output(" DACL: %d entries:\n", theacl->num_aces); for ( i=0; i<theacl->num_aces; i++ ) { verbose_output(" Trustee SID: %s\n", sid_string_tos(&theacl->aces[i].trustee)); if ( dom_sid_equal( &theacl->aces[i].trustee, s1 ) ) { sid_copy( &theacl->aces[i].trustee, s2 ); update = True; verbose_output(" New Trustee SID: %s\n", sid_string_tos(&theacl->aces[i].trustee)); } } #if 0 theacl = sd->sacl; verbose_output(" SACL: %d entries: \n", theacl->num_aces); for ( i=0; i<theacl->num_aces; i++ ) { verbose_output(" Trustee SID: %s\n", sid_string_tos(&theacl->aces[i].trustee)); if ( dom_sid_equal( &theacl->aces[i].trustee, s1 ) ) { sid_copy( &theacl->aces[i].trustee, s2 ); update = True; verbose_output(" New Trustee SID: %s\n", sid_string_tos(&theacl->aces[i].trustee)); } } #endif return update; }
int main(int argc, char *argv[]) { int opt_verbose = 0; int opt_html = 1; char *out_name = NULL; char *out_dir = NULL; int out_type; char *html_dir = NULL; char *conf_name = NULL; report_config_t *rc; unsigned char md5sum[MD5_SIGNATURE_LENGTH]; int ret = 0; char *p; int i; /* Retrieve command arguments */ for (i = 1; i < argc; i++) { char *str = argv[i]; if ( str[0] == '-' ) { if ( (strcmp(str, "-v") == 0) || (strcmp(str, "--verbose") == 0) ) { opt_verbose = 1; } else if ( (strcmp(str, "-n") == 0) || (strcmp(str, "--no-html") == 0) ) { opt_html = 0; } else if ( strcmp(str, "-o") == 0 ) { i++; if ( i < argc ) { html_dir = argv[i]; } else { usage(); } } else if ( strncmp(str, "--output=", 9) == 0 ) { html_dir = &(argv[i][9]); } else if ( strcmp(str, "-c") == 0 ) { i++; if ( i < argc ) { conf_name = argv[i]; } else { usage(); } } else if ( strncmp(str, "--config=", 9) == 0 ) { conf_name = &(argv[i][9]); } else { usage(); } } else { if ( out_name == NULL ) { out_name = str; } else { usage(); } } } if ( out_name == NULL ) usage(); /* Construct Test Output file name */ if ( access(out_name, R_OK) != 0 ) { fprintf(stderr, NAME ": %s: Cannot read Test Output file\n", out_name); exit(1); } /* Check Test Output file format */ out_type = output_file_type(out_name); if ( out_type != OUTPUT_FILE_XML ) { fprintf(stderr, NAME ": %s: Cannot recognize format of Test Output file\n", out_name); exit(1); } /* Compute Test Output MD5 checksum */ md5_sign(out_name, md5sum); /* Load report configuration file */ rc = report_config_alloc(); p = report_config_load(rc, conf_name); if ( p != NULL ) fprintf(stderr, "Report Configuration file: %s\n", p); else if ( conf_name != NULL ) fprintf(stderr, "Warning: Report Configuration '%s' not found: using standard layout\n", conf_name); /* Get output file directory */ out_dir = g_path_get_dirname(out_name); /* Create target directory (if required) */ if ( opt_html ) { if ( html_dir == NULL ) html_dir = out_dir; ret = mkdir(html_dir, 0755); if ( ret && (errno != EEXIST) ) { fprintf(stderr, "Cannot create target directory %s: %s\n", html_dir, strerror(errno)); exit(1); } } /* Show files name */ if ( opt_verbose ) { printf(TITLE "\n"); printf("Test Report options:\n"); verbose_options(rc); printf("Test Output file: %s\n", out_name); if ( md5sum[0] != '\0' ) printf(" MD5 Checksum: %s\n", md5sum); if ( verbose_output(out_name) ) { fprintf(stderr, NAME ": %s: Error opening Test Output file\n", out_name); exit(1); } } if ( opt_html ) { char signature[strlen((char *) md5sum)+40]; struct stat st; /* Build Test Report signature */ p = signature; p += sprintf(p, "%s", md5sum); if ( stat(out_name, &st) == 0 ) p += sprintf(p, " %ld", st.st_mtime); /* Generate HTML Test Log files */ if ( rc->conf & REPORT_CONFIG_LOG ) { /* Log may be appended to the .out file or in a separate .log file */ if ( report_log_build(out_name, signature, 1, html_dir) != 0 ) { char *log_name; int size; size = strlen(out_dir) + 16; log_name = (char *) malloc(size); snprintf(log_name, size, "%s" G_DIR_SEPARATOR_S "global.log", out_dir); if ( report_log_build(log_name, signature, 0, html_dir) != 0 ) rc->conf &= ~REPORT_CONFIG_LOG; free(log_name); } } /* Genarate HTML Test Report file */ if ( opt_verbose ) printf("HTML Test Report target directory: %s\n", html_dir); ret = report_xslt(out_name, signature, rc, html_dir); if ( ret < 0 ) ret = 99; } /* Free string buffers */ if ( out_dir != NULL ) free(out_dir); report_config_destroy(rc); exit(ret); return 0; }
static bool copy_registry_tree( REGF_FILE *infile, REGF_NK_REC *nk, REGF_NK_REC *parent, REGF_FILE *outfile, const char *parentpath ) { REGF_NK_REC *key, *subkey; struct security_descriptor *new_sd; struct regval_ctr *values; struct regsubkey_ctr *subkeys; int i; char *path; WERROR werr; /* swap out the SIDs in the security descriptor */ if ( !(new_sd = dup_sec_desc( outfile->mem_ctx, nk->sec_desc->sec_desc )) ) { fprintf( stderr, "Failed to copy security descriptor!\n" ); return False; } verbose_output("ACL for %s%s%s\n", parentpath, parent ? "\\" : "", nk->keyname); swap_sid_in_acl( new_sd, &old_sid, &new_sid ); werr = regsubkey_ctr_init(NULL, &subkeys); if (!W_ERROR_IS_OK(werr)) { DEBUG(0,("copy_registry_tree: talloc() failure!\n")); return False; } werr = regval_ctr_init(subkeys, &values); if (!W_ERROR_IS_OK(werr)) { TALLOC_FREE( subkeys ); DEBUG(0,("copy_registry_tree: talloc() failure!\n")); return False; } /* copy values into the struct regval_ctr */ for ( i=0; i<nk->num_values; i++ ) { regval_ctr_addvalue( values, nk->values[i].valuename, nk->values[i].type, nk->values[i].data, (nk->values[i].data_size & ~VK_DATA_IN_OFFSET) ); } /* copy subkeys into the struct regsubkey_ctr */ while ( (subkey = regfio_fetch_subkey( infile, nk )) ) { regsubkey_ctr_addkey( subkeys, subkey->keyname ); } key = regfio_write_key( outfile, nk->keyname, values, subkeys, new_sd, parent ); /* write each one of the subkeys out */ path = talloc_asprintf(subkeys, "%s%s%s", parentpath, parent ? "\\" : "",nk->keyname); if (!path) { TALLOC_FREE( subkeys ); return false; } nk->subkey_index = 0; while ((subkey = regfio_fetch_subkey(infile, nk))) { if (!copy_registry_tree( infile, subkey, key, outfile, path)) { TALLOC_FREE(subkeys); return false; } } verbose_output("[%s]\n", path); /* values is a talloc()'d child of subkeys here so just throw it all away */ TALLOC_FREE(subkeys); return True; }
int main(int argc, char **argv) { REAL8TimeSeries *hplus = NULL; REAL8TimeSeries *hcross = NULL; struct params p; int status = 0; gsl_rng *rng = NULL; XLALSetErrorHandler(XLALAbortErrorHandler); p = parseargs(argc, argv); if ((int)(p.waveform) < 0 || (int)(p.waveform) >= NumWaveforms) { fprintf(stderr, "error: must specify valid waveform\n"); exit(1); } if (p.waveform == BLTWNB) { /* set up gsl random number generator */ gsl_rng_env_setup(); rng = gsl_rng_alloc(gsl_rng_default); } if (IS_INVALID_DOUBLE(p.srate) || p.srate <= 0.0) { fprintf(stderr, "error: must specify valid sample rate\n"); status = 1; } verbose_output("Input parameters:\n"); verbose_output("%-31s `%s' - %s\n", "waveform:", waveform_names[p.waveform], waveform_long_names[p.waveform]); verbose_output("%-31s %g (Hz)\n", "sample rate:", p.srate); switch (p.waveform) { case BLTWNB: /* sanity check relevant parameters */ if (IS_INVALID_DOUBLE(p.duration) || p.duration < 0.0) { fprintf(stderr, "error: must specify valid duration for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } if (IS_INVALID_DOUBLE(p.frequency) || p.frequency < 0.0) { fprintf(stderr, "error: must specify valid frequency for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } if (IS_INVALID_DOUBLE(p.bandwidth) || p.bandwidth < 0.0) { fprintf(stderr, "error: must specify valid bandwidth for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } if (IS_INVALID_DOUBLE(p.eccentricity) || p.eccentricity < 0.0 || p.eccentricity > 1.0) { fprintf(stderr, "error: must specify valid eccentricity in domain [0,1] for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } if (IS_INVALID_DOUBLE(p.fluence) || p.fluence < 0.0) { fprintf(stderr, "error: must specify valid fluence for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } /* detect set but ignored parameters */ if (!IS_INVALID_DOUBLE(p.q)) fprintf(stderr, "warning: quality-factor parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (p.phase != DEFAULT_PHASE) fprintf(stderr, "warning: phase parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.amplitude)) fprintf(stderr, "warning: amplitude parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.hrss)) fprintf(stderr, "warning: hrss parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!status) { double int_hdot_squared_dt; int_hdot_squared_dt = p.fluence * LAL_GMSUN_SI * 4 / LAL_C_SI / LAL_PC_SI / LAL_PC_SI; verbose_output("%-31s %g (s)\n", "duration:", p.duration); verbose_output("%-31s %g (Hz)\n", "frequency:", p.frequency); verbose_output("%-31s %g (Hz)\n", "bandwidth:", p.bandwidth); verbose_output("%-31s %g\n", "eccentricity:", p.eccentricity); verbose_output("%-31s %g (Msun c^2 pc^-2)\n", "fluence:", p.fluence); verbose_output("%-31s %g (s^-1)\n", "integral (dh/dt)^2 dt:", int_hdot_squared_dt); verbose_output("%-31s GSL_RNG_TYPE=%s\n", "GSL random number generator:", gsl_rng_name(rng)); verbose_output("%-31s GSL_RNG_SEED=%lu\n", "GSL random number seed:", gsl_rng_default_seed); status = XLALGenerateBandAndTimeLimitedWhiteNoiseBurst(&hplus, &hcross, p.duration, p.frequency, p.bandwidth, p.eccentricity, int_hdot_squared_dt, 1.0/p.srate, rng); } break; case StringCusp: /* sanity check relevant parameters */ if (IS_INVALID_DOUBLE(p.amplitude) || p.amplitude < 0.0) { fprintf(stderr, "error: must specify valid amplitude for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } if (IS_INVALID_DOUBLE(p.frequency) || p.frequency < 0.0) { fprintf(stderr, "error: must specify valid frequency for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } /* detect set but ignored parameters */ if (!IS_INVALID_DOUBLE(p.duration)) fprintf(stderr, "warning: duration parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.bandwidth)) fprintf(stderr, "warning: bandwidth parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.q)) fprintf(stderr, "warning: quality-factor parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (p.eccentricity != DEFAULT_ECCENTRICITY) fprintf(stderr, "warning: eccentricity parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (p.phase != DEFAULT_PHASE) fprintf(stderr, "warning: phase parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.hrss)) fprintf(stderr, "warning: hrss parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.fluence)) fprintf(stderr, "warning: fluence parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!status) { verbose_output("%-31s %g (s^-1/3)\n", "amplitude:", p.amplitude); verbose_output("%-31s %g (Hz)\n", "frequency:", p.frequency); status = XLALGenerateStringCusp(&hplus, &hcross, p.amplitude, p.frequency, 1.0/p.srate); } break; case SineGaussian: /* sanity check relevant parameters */ if (IS_INVALID_DOUBLE(p.q) || p.q < 0.0) { fprintf(stderr, "error: must specify valid quality factor for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } if (IS_INVALID_DOUBLE(p.frequency) || p.frequency < 0.0) { fprintf(stderr, "error: must specify valid frequency for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } if (IS_INVALID_DOUBLE(p.hrss) || p.hrss < 0.0) { fprintf(stderr, "error: must specify valid hrss for waveform `%s\n", waveform_names[p.waveform]); status = 1; } if (IS_INVALID_DOUBLE(p.eccentricity) || p.eccentricity < 0.0 || p.eccentricity > 1.0) { fprintf(stderr, "error: must specify valid eccentricity in domain [0,1] for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } if (IS_INVALID_DOUBLE(p.phase)) { fprintf(stderr, "error: must specify valid phase for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } /* detect set but ignored parameters */ if (!IS_INVALID_DOUBLE(p.duration)) fprintf(stderr, "warning: duration parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.bandwidth)) fprintf(stderr, "warning: bandwidth parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.amplitude)) fprintf(stderr, "warning: amplitude parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.fluence)) fprintf(stderr, "warning: fluence parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!status) { verbose_output("%-31s %g\n", "quality-factor:", p.q); verbose_output("%-31s %g (Hz)\n", "frequency:", p.frequency); verbose_output("%-31s %g (Hz^-1/2)\n", "root-sum-squared strain:", p.hrss); verbose_output("%-31s %g\n", "eccentricity:", p.eccentricity); verbose_output("%-31s %g (degrees)\n", "phase:", p.phase / LAL_PI_180); status = XLALSimBurstSineGaussian(&hplus, &hcross, p.q, p.frequency, p.hrss, p.eccentricity, p.phase, 1.0/p.srate); } break; case Gaussian: /* sanity check relevant parameters */ if (IS_INVALID_DOUBLE(p.duration) || p.duration < 0.0) { fprintf(stderr, "error: must specify valid duration for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } if (IS_INVALID_DOUBLE(p.hrss) || p.hrss < 0.0) { fprintf(stderr, "error: must specify valid hrss for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } /* detect set but ignored parameters */ if (!IS_INVALID_DOUBLE(p.frequency)) fprintf(stderr, "warning: frequency parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.bandwidth)) fprintf(stderr, "warning: bandwidth parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.q)) fprintf(stderr, "warning: quality-factor parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (p.eccentricity != DEFAULT_ECCENTRICITY) fprintf(stderr, "warning: eccentricity parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (p.phase != DEFAULT_PHASE) fprintf(stderr, "warning: phase parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.amplitude)) fprintf(stderr, "warning: amplitude parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.fluence)) fprintf(stderr, "warning: fluence parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!status) { verbose_output("%-31s %g (s)\n", "duration:", p.duration); verbose_output("%-31s %g (Hz^-1/2)\n", "root-sum-squared strain:", p.hrss); status = XLALSimBurstGaussian(&hplus, &hcross, p.duration, p.hrss, 1.0/p.srate); } break; case Impulse: /* sanity check relevant parameters */ if (IS_INVALID_DOUBLE(p.amplitude) || p.amplitude < 0.0) { fprintf(stderr, "error: must specify valid amplitude for waveform `%s'\n", waveform_names[p.waveform]); status = 1; } /* detect set but ignored parameters */ if (!IS_INVALID_DOUBLE(p.duration)) fprintf(stderr, "warning: duration parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.frequency)) fprintf(stderr, "warning: frequency parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.bandwidth)) fprintf(stderr, "warning: bandwidth parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.q)) fprintf(stderr, "warning: quality-factor parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (p.eccentricity != DEFAULT_ECCENTRICITY) fprintf(stderr, "warning: eccentricity parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (p.phase != DEFAULT_PHASE) fprintf(stderr, "warning: phase parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.hrss)) fprintf(stderr, "warning: hrss parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!IS_INVALID_DOUBLE(p.fluence)) fprintf(stderr, "warning: fluence parameter is set but ignored for waveform `%s'\n", waveform_names[p.waveform]); if (!status) { verbose_output("%-31s %g (dimensionless)\n", "amplitude:", p.amplitude); status = XLALGenerateImpulseBurst(&hplus, &hcross, p.amplitude, 1.0/p.srate); } break; default: fprintf(stderr, "error: unrecognized waveform\n"); exit(1); }; if (status) exit(1); if (verbose) { char peak_time[32]; // GPS time string - 31 characters is enough LIGOTimeGPS tpeak; COMPLEX16 hpeak; double hrss; double fluence; unsigned ipeak; hpeak = XLALMeasureHPeak(hplus, hcross, &ipeak); tpeak = hplus->epoch; XLALGPSAdd(&tpeak, ipeak * hplus->deltaT); XLALGPSToStr(peak_time, &tpeak); hrss = XLALMeasureHrss(hplus, hcross); fluence = XLALMeasureEoverRsquared(hplus, hcross); verbose_output("Measured parameters:\n"); verbose_output("%-31s %s (s)\n", "peak time:", peak_time); verbose_output("%-31s (h+, hx) = (%g, %g)\n", "peak strain amplitude:", creal(hpeak), cimag(hpeak)); verbose_output("%-31s abs(h+, hx) = %g\n", "peak strain amplitude:", cabs(hpeak)); verbose_output("%-31s arg(h+, hx) = %g (rad)\n", "peak strain amplitude:", carg(hpeak)); verbose_output("%-31s %g (Hz^-1/2)\n", "root-sum-squared strain:", hrss); verbose_output("%-31s %g (J m^-2)\n", "isotropic energy fluence:", fluence); verbose_output("%-31s %g (Msun c^2 pc^-2)\n", "isotropic energy fluence:", fluence * LAL_PC_SI * LAL_PC_SI / LAL_MSUN_SI / LAL_C_SI / LAL_C_SI); } output(hplus, hcross); XLALDestroyREAL8TimeSeries(hcross); XLALDestroyREAL8TimeSeries(hplus); LALCheckMemoryLeaks(); return 0; }