static void authDigestParse(authScheme * scheme, int n_configured, char *param_str) { if (scheme->scheme_data == NULL) { assert(digestConfig == NULL); /* this is the first param to be found */ scheme->scheme_data = xmalloc(sizeof(auth_digest_config)); memset(scheme->scheme_data, 0, sizeof(auth_digest_config)); digestConfig = scheme->scheme_data; digestConfig->authenticateChildren = 5; digestConfig->digestAuthRealm = xstrdup("Squid proxy-caching web server"); /* 5 minutes */ digestConfig->nonceGCInterval = 5 * 60; /* 30 minutes */ digestConfig->noncemaxduration = 30 * 60; /* 50 requests */ digestConfig->noncemaxuses = 50; /* Not strict nonce count behaviour */ digestConfig->NonceStrictness = 0; /* Verify nonce count */ digestConfig->CheckNonceCount = 1; digestConfig->PostWorkaround = 0; } digestConfig = scheme->scheme_data; if (strcasecmp(param_str, "program") == 0) { if (digestConfig->authenticate) wordlistDestroy(&digestConfig->authenticate); parse_wordlist(&digestConfig->authenticate); requirePathnameExists("authparam digest program", digestConfig->authenticate->key); } else if (strcasecmp(param_str, "children") == 0) { parse_int(&digestConfig->authenticateChildren); } else if (strcasecmp(param_str, "realm") == 0) { parse_eol(&digestConfig->digestAuthRealm); } else if (strcasecmp(param_str, "nonce_garbage_interval") == 0) { parse_time_t(&digestConfig->nonceGCInterval); } else if (strcasecmp(param_str, "nonce_max_duration") == 0) { parse_time_t(&digestConfig->noncemaxduration); } else if (strcasecmp(param_str, "nonce_max_count") == 0) { parse_int(&digestConfig->noncemaxuses); } else if (strcasecmp(param_str, "nonce_strictness") == 0) { parse_onoff(&digestConfig->NonceStrictness); } else if (strcasecmp(param_str, "check_nonce_count") == 0) { parse_onoff(&digestConfig->CheckNonceCount); } else if (strcasecmp(param_str, "post_workaround") == 0) { parse_onoff(&digestConfig->PostWorkaround); } else { debug(28, 0) ("unrecognised digest auth scheme parameter '%s'\n", param_str); } }
static void authBasicParse(authScheme * scheme, int n_configured, char *param_str) { if (scheme->scheme_data == NULL) { assert(basicConfig == NULL); /* this is the first param to be found */ scheme->scheme_data = xmalloc(sizeof(auth_basic_config)); memset(scheme->scheme_data, 0, sizeof(auth_basic_config)); basicConfig = scheme->scheme_data; basicConfig->basicAuthRealm = xstrdup("Squid proxy-caching web server"); basicConfig->authenticateChildren = 5; basicConfig->credentialsTTL = 2 * 60 * 60; /* two hours */ } basicConfig = scheme->scheme_data; if (strcasecmp(param_str, "program") == 0) { if (basicConfig->authenticate) wordlistDestroy(&basicConfig->authenticate); parse_wordlist(&basicConfig->authenticate); } else if (strcasecmp(param_str, "children") == 0) { parse_int(&basicConfig->authenticateChildren); } else if (strcasecmp(param_str, "concurrency") == 0) { parse_int(&basicConfig->authenticateConcurrency); } else if (strcasecmp(param_str, "realm") == 0) { parse_eol(&basicConfig->basicAuthRealm); } else if (strcasecmp(param_str, "credentialsttl") == 0) { parse_time_t(&basicConfig->credentialsTTL); } else if (strcasecmp(param_str, "casesensitive") == 0) { parse_onoff(&basicConfig->casesensitive); } else if (strcasecmp(param_str, "blankpassword") == 0) { parse_onoff(&basicConfig->blankpassword); } else { debug(29, 0) ("unrecognised basic auth scheme parameter '%s'\n", param_str); } }
static guestfs_int_isoinfo * parse_isoinfo (char **lines) { guestfs_int_isoinfo *ret; size_t i; ret = calloc (1, sizeof *ret); if (ret == NULL) { reply_with_perror ("calloc"); return NULL; } /* Default each int field in the struct to -1. */ ret->iso_volume_space_size = (uint32_t) -1; ret->iso_volume_set_size = (uint32_t) -1; ret->iso_volume_sequence_number = (uint32_t) -1; ret->iso_logical_block_size = (uint32_t) -1; ret->iso_volume_creation_t = -1; ret->iso_volume_modification_t = -1; ret->iso_volume_expiration_t = -1; ret->iso_volume_effective_t = -1; for (i = 0; lines[i] != NULL; ++i) { if (STRPREFIX (lines[i], "System id: ")) { ret->iso_system_id = strdup (&lines[i][11]); if (ret->iso_system_id == NULL) goto error; } else if (STRPREFIX (lines[i], "Volume id: ")) { ret->iso_volume_id = strdup (&lines[i][11]); if (ret->iso_volume_id == NULL) goto error; } else if (STRPREFIX (lines[i], "Volume set id: ")) { ret->iso_volume_set_id = strdup (&lines[i][15]); if (ret->iso_volume_set_id == NULL) goto error; } else if (STRPREFIX (lines[i], "Publisher id: ")) { ret->iso_publisher_id = strdup (&lines[i][14]); if (ret->iso_publisher_id == NULL) goto error; } else if (STRPREFIX (lines[i], "Data preparer id: ")) { ret->iso_data_preparer_id = strdup (&lines[i][18]); if (ret->iso_data_preparer_id == NULL) goto error; } else if (STRPREFIX (lines[i], "Application id: ")) { ret->iso_application_id = strdup (&lines[i][16]); if (ret->iso_application_id == NULL) goto error; } else if (STRPREFIX (lines[i], "Copyright File id: ")) { ret->iso_copyright_file_id = strdup (&lines[i][19]); if (ret->iso_copyright_file_id == NULL) goto error; } else if (STRPREFIX (lines[i], "Abstract File id: ")) { ret->iso_abstract_file_id = strdup (&lines[i][18]); if (ret->iso_abstract_file_id == NULL) goto error; } else if (STRPREFIX (lines[i], "Bibliographic File id: ")) { ret->iso_bibliographic_file_id = strdup (&lines[i][23]); if (ret->iso_bibliographic_file_id == NULL) goto error; } else if (STRPREFIX (lines[i], "Volume size is: ")) { if (parse_uint32 (&ret->iso_volume_space_size, &lines[i][16]) == -1) goto error; } else if (STRPREFIX (lines[i], "Volume set size is: ")) { if (parse_uint32 (&ret->iso_volume_set_size, &lines[i][20]) == -1) goto error; } else if (STRPREFIX (lines[i], "Volume set sequence number is: ")) { if (parse_uint32 (&ret->iso_volume_sequence_number, &lines[i][31]) == -1) goto error; } else if (STRPREFIX (lines[i], "Logical block size is: ")) { if (parse_uint32 (&ret->iso_logical_block_size, &lines[i][23]) == -1) goto error; } else if (STRPREFIX (lines[i], "Creation Date: ")) { if (parse_time_t (&ret->iso_volume_creation_t, &lines[i][19]) == -1) goto error; } else if (STRPREFIX (lines[i], "Modification Date: ")) { if (parse_time_t (&ret->iso_volume_modification_t, &lines[i][19]) == -1) goto error; } else if (STRPREFIX (lines[i], "Expiration Date: ")) { if (parse_time_t (&ret->iso_volume_expiration_t, &lines[i][19]) == -1) goto error; } else if (STRPREFIX (lines[i], "Effective Date: ")) { if (parse_time_t (&ret->iso_volume_effective_t, &lines[i][19]) == -1) goto error; } } /* Any string fields which were not set above will be NULL. However * we cannot return NULL fields in structs, so we convert these to * empty strings here. */ if (ret->iso_system_id == NULL) { ret->iso_system_id = strdup (""); if (ret->iso_system_id == NULL) goto error; } if (ret->iso_volume_id == NULL) { ret->iso_volume_id = strdup (""); if (ret->iso_volume_id == NULL) goto error; } if (ret->iso_volume_set_id == NULL) { ret->iso_volume_set_id = strdup (""); if (ret->iso_volume_set_id == NULL) goto error; } if (ret->iso_publisher_id == NULL) { ret->iso_publisher_id = strdup (""); if (ret->iso_publisher_id == NULL) goto error; } if (ret->iso_data_preparer_id == NULL) { ret->iso_data_preparer_id = strdup (""); if (ret->iso_data_preparer_id == NULL) goto error; } if (ret->iso_application_id == NULL) { ret->iso_application_id = strdup (""); if (ret->iso_application_id == NULL) goto error; } if (ret->iso_copyright_file_id == NULL) { ret->iso_copyright_file_id = strdup (""); if (ret->iso_copyright_file_id == NULL) goto error; } if (ret->iso_abstract_file_id == NULL) { ret->iso_abstract_file_id = strdup (""); if (ret->iso_abstract_file_id == NULL) goto error; } if (ret->iso_bibliographic_file_id == NULL) { ret->iso_bibliographic_file_id = strdup (""); if (ret->iso_bibliographic_file_id == NULL) goto error; } return ret; error: free (ret->iso_system_id); free (ret->iso_volume_id); free (ret->iso_volume_set_id); free (ret->iso_publisher_id); free (ret->iso_data_preparer_id); free (ret->iso_application_id); free (ret->iso_copyright_file_id); free (ret->iso_abstract_file_id); free (ret->iso_bibliographic_file_id); free (ret); return NULL; }