Exemplo n.º 1
0
/* <dict> .setsystemparams - */
static int
zsetsystemparams(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    int code;
    dict_param_list list;
    gs_param_list *const plist = (gs_param_list *)&list;
    password pass;

    check_type(*op, t_dictionary);
    code = dict_param_list_read(&list, op, NULL, false, iimemory);
    if (code < 0)
        return code;
    code = dict_read_password(&pass, systemdict, "SystemParamsPassword");
    if (code < 0)
        return code;
    code = param_check_password(plist, &pass);
    if (code != 0) {
        if (code > 0)
            code = gs_note_error(gs_error_invalidaccess);
        goto out;
    }
    code = param_read_password(plist, "StartJobPassword", &pass);
    switch (code) {
        default:		/* invalid */
            goto out;
        case 1:		/* missing */
            break;
        case 0:
            code = dict_write_password(&pass, systemdict,
                                       "StartJobPassword",
                                       ! i_ctx_p->LockFilePermissions);
            if (code < 0)
                goto out;
    }
    code = param_read_password(plist, "SystemParamsPassword", &pass);
    switch (code) {
        default:		/* invalid */
            goto out;
        case 1:		/* missing */
            break;
        case 0:
            code = dict_write_password(&pass, systemdict,
                                       "SystemParamsPassword",
                                       ! i_ctx_p->LockFilePermissions);
            if (code < 0)
                goto out;
    }

    code = setparams(i_ctx_p, plist, &system_param_set);
  out:
    iparam_list_release(&list);
    if (code < 0)
        return code;
    pop(1);
    return 0;
}
Exemplo n.º 2
0
/* Return 0 if OK, 1 if not OK, or an error code. */
int
param_check_password(gs_param_list * plist, const password * ppass)
{
    if (ppass->size != 0) {
	password pass;
	int code = param_read_password(plist, "Password", &pass);

	if (code)
	    return code;
	if (pass.size != ppass->size ||
	    bytes_compare(&pass.data[0], pass.size,
			  &ppass->data[0],
			  ppass->size) != 0
	    )
	    return 1;
    }
    return 0;
}