OpenDNSSEC-enforcer  1.4.6
ksm_import.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2009 Nominet UK. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
17  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
19  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
21  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
23  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  */
26 
27 /*
28  * ksm_import.c - Import/update configuration data in kasp database
29  */
30 
31 #include <assert.h>
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 #include <time.h>
36 
37 #include "ksm/database.h"
38 #include "ksm/database_statement.h"
39 #include "ksm/datetime.h"
40 #include "ksm/db_fields.h"
41 #include "ksm/debug.h"
42 #include "ksm/ksmdef.h"
43 #include "ksm/ksm.h"
44 #include "ksm/ksm_internal.h"
45 #include "ksm/message.h"
46 #include "ksm/string_util.h"
47 #include "ksm/string_util2.h"
48 
49 /*+
50  * KsmImportRepository - Insert or update a repository
51  *
52  *
53  * Arguments:
54  *
55  * const char* repo_name
56  * Name of the repository
57  *
58  * const char* repo_capacity
59  * Capacity for that repository
60  *
61  * int require_backup
62  * flag to indicate if keys in this repo need to be backed up before they can be used
63  *
64  * Returns:
65  * int
66  * Status return. 0 on success.
67  * -1 if an unexpected count value was returned
68 -*/
69 
70 int KsmImportRepository(const char* repo_name, const char* repo_capacity, int require_backup)
71 {
72  char* sql = NULL; /* SQL query */
73  int status = 0; /* Status return */
74  int count = 0; /* Do we already have a repository with this name? */
75 
76  /* check the main argument (capacity may be NULL) */
77  if (repo_name == NULL) {
78  return MsgLog(KSM_INVARG, "NULL repository name");
79  }
80 
81  /*
82  * First see if this repository exists
83  */
85  DqsConditionString(&sql, "NAME", DQS_COMPARE_EQ, repo_name, 0);
86  DqsEnd(&sql);
87 
88  /* Execute query and free up the query string */
89  status = DbIntQuery(DbHandle(), &count, sql);
90  DqsFree(sql);
91 
92  if (status != 0)
93  {
94  status = MsgLog(KSM_SQLFAIL, DbErrmsg(DbHandle()));
95  return status;
96  }
97 
98  /* If the count was 0 then we do an insert, otherwise we do an update */
99  if (count == 0)
100  {
101  sql = DisSpecifyInit(DB_SECURITY_MODULE_TABLE, "name, capacity, requirebackup");
102  DisAppendString(&sql, repo_name);
103  DisAppendString(&sql, repo_capacity);
104  DisAppendInt(&sql, require_backup);
105  DisEnd(&sql);
106 
107  status = DbExecuteSqlNoResult(DbHandle(), sql);
108  DisFree(sql);
109  }
110  else if (count == 1)
111  {
113  DusSetString(&sql, "capacity", repo_capacity, 0);
114  DusSetInt(&sql, "requirebackup", require_backup, 1);
115  DusConditionString(&sql, "name", DQS_COMPARE_EQ, repo_name, 0);
116  DusEnd(&sql);
117 
118  status = DbExecuteSqlNoResult(DbHandle(), sql);
119  DusFree(sql);
120  }
121  else
122  {
123  return -1;
124  }
125 
126  return status;
127 }
128 
129 /*+
130  * KsmImportPolicy - Insert a policy (will not be called if policy exists, unlike above
131  *
132  *
133  * Arguments:
134  *
135  * const char* policy_name
136  * Name of the policy
137  *
138  * const char* policy_description
139  * Description for that policy
140  *
141  * Returns:
142  * int
143  * Status return. 0 on success.
144  * -1 if an unexpected count value was returned
145 -*/
146 
147 int KsmImportPolicy(const char* policy_name, const char* policy_description)
148 {
149  char* sql = NULL; /* SQL query */
150  int status = 0; /* Status return */
151 
152  char quoted_desc[KSM_POLICY_DESC_LENGTH]; /* with bad chars quoted */
153 
154  /* check the main argument (description may be NULL) */
155  if (policy_name == NULL) {
156  return MsgLog(KSM_INVARG, "NULL policy name");
157  }
158 
159  /* Quote description */
160  status = DbQuoteString(DbHandle(), policy_description, quoted_desc, KSM_POLICY_DESC_LENGTH);
161 
162  if (status != 0) {
163  return status;
164  }
165 
166  /* Insert policy */
167  sql = DisSpecifyInit("policies", "name, description");
168  DisAppendString(&sql, policy_name);
169  DisAppendString(&sql, quoted_desc);
170  DisEnd(&sql);
171 
172  status = DbExecuteSqlNoResult(DbHandle(), sql);
173  DisFree(sql);
174 
175  return status;
176 }
177 
178 /*+
179  * KsmImportZone - Insert or update a zone
180  *
181  *
182  * Arguments:
183  *
184  * const char* zone_name
185  * Name of the repository
186  *
187  * int policy_id
188  * Policy for the zone
189  *
190  * int fail_if_exists
191  * Set to 1 if you don't want to update existing zones
192  *
193  * int *new_zone
194  * (returned) indicate if the zone was new to the database
195  *
196  * const char* signconf
197  * Where is the signconf saved
198  *
199  * const char* input
200  * Where is the input
201  *
202  * const char* output
203  * Where is the output
204  *
205  * const char* input_type
206  * What adapter type is the input
207  *
208  * const char* output_type
209  * What adapter type is the output
210  *
211  * Returns:
212  * int
213  * Status return. 0 on success.
214  * -1 if an unexpected count value was returned
215  * -2 if the zone exists and fail_if_exists == 1
216  * -3 if the zone exists with and without a trailing dot
217 -*/
218 int KsmImportZone(const char* zone_name, int policy_id, int fail_if_exists, int *new_zone, const char* signconf, const char* input, const char* output, const char* input_type, const char* output_type)
219 {
220  char* sql = NULL; /* SQL query */
221  int status = 0; /* Status return */
222  int count = 0; /* Do we already have a zone with this name? */
223  char* zone_name_td = NULL; /* zone name with td swapped */
224  char in_clause[KSM_SQL_SIZE]; /* in part of where clause */
225 
226  /* check the arguments */
227  if (zone_name == NULL || policy_id == 0) {
228  return MsgLog(KSM_INVARG, "NULL zone name or policy");
229  }
230 
231  /* make copy of zone_name with opposite td to original (unless original is
232  "."; in which case the copy is identical */
233  zone_name_td = StrStrdup(zone_name);
234  if (strlen(zone_name_td) > 1 && zone_name_td[strlen(zone_name_td)-1] == '.') {
235  zone_name_td[strlen(zone_name_td)-1] = '\0';
236  }
237  else if (strlen(zone_name_td) > 1) {
238  StrAppend(&zone_name_td, ".");
239  }
240 
241  snprintf(in_clause, KSM_SQL_SIZE, "(\"%s\",\"%s\")", zone_name, zone_name_td);
242 
243  /*
244  * First see if this zone exists
245  */
247  DqsConditionKeyword(&sql, "NAME", DQS_COMPARE_IN, in_clause, 0);
248  DqsEnd(&sql);
249 
250  /* Execute query and free up the query string */
251  status = DbIntQuery(DbHandle(), &count, sql);
252  DqsFree(sql);
253 
254  if (status != 0)
255  {
256  status = MsgLog(KSM_SQLFAIL, DbErrmsg(DbHandle()));
257  return status;
258  }
259 
260  /* If the count was 0 then we do an insert, otherwise we do an update */
261  if (count == 0)
262  {
263  sql = DisSpecifyInit(DB_ZONE_TABLE, "name, policy_id, signconf, input, output, in_type, out_type");
264  DisAppendString(&sql, zone_name);
265  DisAppendInt(&sql, policy_id);
266  DisAppendString(&sql, signconf);
267  DisAppendString(&sql, input);
268  DisAppendString(&sql, output);
269  DisAppendString(&sql, input_type);
270  DisAppendString(&sql, output_type);
271  DisEnd(&sql);
272 
273  status = DbExecuteSqlNoResult(DbHandle(), sql);
274  DisFree(sql);
275 
276  *new_zone = 1;
277  }
278  else if (count == 1)
279  {
280  if (fail_if_exists == 1) {
281  return -2;
282  }
283  sql = DusInit(DB_ZONE_TABLE);
284  DusSetInt(&sql, "policy_id", policy_id, 0);
285  DusSetString(&sql, "signconf", signconf, 1);
286  DusSetString(&sql, "input", input, 2);
287  DusSetString(&sql, "output", output, 3);
288  DusSetString(&sql, "in_type", input_type, 4);
289  DusSetString(&sql, "out_type", output_type, 5);
290  DusConditionString(&sql, "name", DQS_COMPARE_EQ, zone_name, 0);
291  DusEnd(&sql);
292 
293  status = DbExecuteSqlNoResult(DbHandle(), sql);
294  DusFree(sql);
295 
296  *new_zone = 0;
297  }
298  else if (count == 2)
299  {
300  return -3;
301  }
302  else
303  {
304  return -1;
305  }
306 
307  StrFree(zone_name_td);
308 
309  return status;
310 }
311 
312 /*+
313  * KsmImportKeyPair - Create Entry in the KeyPairs table for an existing key
314  *
315  * Description:
316  * Creates a key in the database. If the retire time is set then it is marked as
317  * fixed (I.e. it will not be changed to fit the policy timings.)
318  *
319  * Arguments:
320  * policy_id
321  * policy that the key is created for
322  * HSMKeyID
323  * ID the key is refered to in the HSM
324  * smID
325  * security module ID
326  * size
327  * size of key
328  * alg
329  * algorithm used
330  * state
331  * state to set key to
332  * time
333  * timestamp of entry into state given
334  * fixDate
335  * set to 1 if the retire date should be fixed
336  *
337  * DB_ID* id (returned)
338  * ID of the created entry. This will be undefined on error.
339  *
340  * Returns:
341  * int
342  * Status return. 0=> Success, non-zero => error.
343 -*/
344 int KsmImportKeyPair(int policy_id, const char* HSMKeyID, int smID, int size, int alg, int state, const char* time, int fixDate, DB_ID* id)
345 {
346  unsigned long rowid; /* ID of last inserted row */
347  int status = 0; /* Status return */
348  char* sql = NULL; /* SQL Statement */
349  char* columns = NULL; /* what columns are we setting */
350 
351  /* Check arguments */
352  if (id == NULL) {
353  return MsgLog(KSM_INVARG, "NULL id");
354  }
355 
356  StrAppend(&columns, "policy_id, HSMkey_id, securitymodule_id, size, algorithm");
357  if (state == KSM_STATE_GENERATE) {
358  StrAppend(&columns, ", ");
359  StrAppend(&columns, KsmKeywordStateValueToName(state));
360  }
361  if (state == KSM_STATE_ACTIVE && fixDate == 1) {
362  StrAppend(&columns, ", fixedDate");
363  }
364 
365  sql = DisSpecifyInit("keypairs", columns);
366  DisAppendInt(&sql, policy_id);
367  DisAppendString(&sql, HSMKeyID);
368  DisAppendInt(&sql, smID);
369  DisAppendInt(&sql, size);
370  DisAppendInt(&sql, alg);
371  if (state == KSM_STATE_GENERATE) {
372  DisAppendString(&sql, time);
373  }
374  if (state == KSM_STATE_ACTIVE && fixDate == 1) {
375  DisAppendInt(&sql, fixDate);
376  }
377  DisEnd(&sql);
378 
379  /* Execute the statement */
380 
381  status = DbExecuteSqlNoResult(DbHandle(), sql);
382  DisFree(sql);
383  StrFree(columns);
384 
385  if (status == 0) {
386 
387  /* Succcess, get the ID of the inserted record */
388 
389  status = DbLastRowId(DbHandle(), &rowid);
390  if (status == 0) {
391  *id = (DB_ID) rowid;
392  }
393  }
394 
395  return status;
396 }
397 
398 int KsmSmIdFromName(const char* name, int *id)
399 {
400  char* sql = NULL; /* SQL query */
401  int status = 0; /* Status return */
402 
403  /* check the argument */
404  if (name == NULL) {
405  return MsgLog(KSM_INVARG, "NULL name");
406  }
407 
408  /* Construct the query */
409 
411  DqsConditionString(&sql, "name", DQS_COMPARE_EQ, name, 0);
412  DqsEnd(&sql);
413 
414  /* Execute query and free up the query string */
415  status = DbIntQuery(DbHandle(), id, sql);
416  DqsFree(sql);
417 
418  if (status != 0)
419  {
420  status = MsgLog(KSM_SQLFAIL, DbErrmsg(DbHandle()));
421  return status;
422  }
423 
424  return status;
425 }
426 
427 int KsmSerialIdFromName(const char* name, int *id)
428 {
429  char* sql = NULL; /* SQL query */
430  int status = 0; /* Status return */
431 
432  /* check the argument */
433  if (name == NULL) {
434  return MsgLog(KSM_INVARG, "NULL name");
435  }
436 
437  /* Construct the query */
438 
439  sql = DqsSpecifyInit("serialmodes","id");
440  DqsConditionString(&sql, "name", DQS_COMPARE_EQ, name, 0);
441  DqsEnd(&sql);
442 
443  /* Execute query and free up the query string */
444  status = DbIntQuery(DbHandle(), id, sql);
445  DqsFree(sql);
446 
447  if (status != 0)
448  {
449  status = MsgLog(KSM_SQLFAIL, DbErrmsg(DbHandle()));
450  return status;
451  }
452 
453  return status;
454 }
455 
456 /*+
457  * KsmPolicyIdFromName - Given a policy name return the id
458  *
459  *
460  * Arguments:
461  *
462  * Name of the policy.
463  *
464  *
465  * Returns:
466  * int
467  * 0 Success, value found
468  * Other Error
469 -*/
470 int KsmPolicyIdFromName(const char* name, int *id)
471 {
472  char* sql = NULL; /* SQL query */
473  int status = 0; /* Status return */
474 
475  /* check the argument */
476  if (name == NULL) {
477  return MsgLog(KSM_INVARG, "NULL name");
478  }
479 
480  /* Construct the query */
481 
482  sql = DqsSpecifyInit("policies","id");
483  DqsConditionString(&sql, "name", DQS_COMPARE_EQ, name, 0);
484  DqsEnd(&sql);
485 
486  /* Execute query and free up the query string */
487  status = DbIntQuery(DbHandle(), id, sql);
488  DqsFree(sql);
489 
490  if (status != 0)
491  {
492  status = MsgLog(KSM_SQLFAIL, DbErrmsg(DbHandle()));
493  return status;
494  }
495 
496  return status;
497 }
498 
499 /*+
500  * KsmMarkPreBackup - Mark a backup as having been prepared
501  *
502  *
503  * Arguments:
504  *
505  * int repo_id
506  * ID of the repository (-1 for all)
507  *
508  * const char* datetime
509  * When the pre backup was done
510  *
511  * Returns:
512  * int
513  * Status return. 0 on success.
514  * other on fail
515  */
516 
517 int KsmMarkPreBackup(int repo_id, const char* datetime)
518 {
519  char* sql = NULL; /* SQL query */
520  int status = 0; /* Status return */
521  int count = -1; /* How many keys get marked */
522 
523  /* Count how many we will mark */
524  sql = DqsCountInit("keypairs");
525  if (repo_id != -1) {
526  DqsConditionInt(&sql, "securitymodule_id", DQS_COMPARE_EQ, repo_id, 0);
527  StrAppend(&sql, " and pre_backup is null");
528  } else {
529  StrAppend(&sql, " where pre_backup is null");
530  }
531  DqsEnd(&sql);
532 
533  /* Execute query and free up the query string */
534  status = DbIntQuery(DbHandle(), &count, sql);
535  DqsFree(sql);
536 
537  if (status != 0)
538  {
539  status = MsgLog(KSM_SQLFAIL, DbErrmsg(DbHandle()));
540  return status;
541  }
542 
543  if (count == 0) {
544  /* No work to do */
545  return -1;
546  }
547 
548  /* Update rows */
549  sql = DusInit("keypairs");
550  DusSetString(&sql, "PRE_BACKUP", datetime, 0);
551  if (repo_id != -1) {
552  DusConditionInt(&sql, "securitymodule_id", DQS_COMPARE_EQ, repo_id, 0);
553  StrAppend(&sql, " and pre_backup is null");
554  } else {
555  StrAppend(&sql, " where pre_backup is null");
556  }
557  DusEnd(&sql);
558 
559  status = DbExecuteSqlNoResult(DbHandle(), sql);
560  DusFree(sql);
561 
562  return status;
563 }
564 
565 /*+
566  * KsmRollbackPreBackup - Rollback a backup prepare step
567  *
568  *
569  * Arguments:
570  *
571  * int repo_id
572  * ID of the repository (-1 for all)
573  *
574  * Returns:
575  * int
576  * Status return. 0 on success.
577  * other on fail
578  */
579 
580 int KsmRollbackMarkPreBackup(int repo_id)
581 {
582  char* sql = NULL; /* SQL query */
583  int status = 0; /* Status return */
584  int count = -1; /* How many keys get marked */
585 
586  /* Count how many we will mark */
587  sql = DqsCountInit("keypairs");
588  if (repo_id != -1) {
589  DqsConditionInt(&sql, "securitymodule_id", DQS_COMPARE_EQ, repo_id, 0);
590  StrAppend(&sql, " and pre_backup is not null");
591  StrAppend(&sql, " and backup is null");
592  } else {
593  StrAppend(&sql, " where pre_backup is not null");
594  StrAppend(&sql, " and backup is null");
595  }
596  DqsEnd(&sql);
597 
598  /* Execute query and free up the query string */
599  status = DbIntQuery(DbHandle(), &count, sql);
600  DqsFree(sql);
601 
602  if (status != 0)
603  {
604  status = MsgLog(KSM_SQLFAIL, DbErrmsg(DbHandle()));
605  return status;
606  }
607 
608  if (count == 0) {
609  /* No work to do */
610  return -1;
611  }
612 
613  /* Update rows */
614  sql = DusInit("keypairs");
615  DusSetString(&sql, "PRE_BACKUP", NULL, 0);
616  if (repo_id != -1) {
617  DusConditionInt(&sql, "securitymodule_id", DQS_COMPARE_EQ, repo_id, 0);
618  StrAppend(&sql, " and pre_backup is not null");
619  StrAppend(&sql, " and backup is null");
620  } else {
621  StrAppend(&sql, " where pre_backup is null");
622  StrAppend(&sql, " and backup is null");
623  }
624  DusEnd(&sql);
625 
626  status = DbExecuteSqlNoResult(DbHandle(), sql);
627  DusFree(sql);
628 
629  return status;
630 }
631 
632 /*+
633  * KsmMarkBackup - Mark a backup as having been done
634  *
635  *
636  * Arguments:
637  *
638  * int repo_id
639  * ID of the repository (-1 for all)
640  *
641  * const char* datetime
642  * When the backup was done
643  *
644  * Returns:
645  * int
646  * Status return. 0 on success.
647  * other on fail
648  */
649 
650 int KsmMarkBackup(int repo_id, const char* datetime)
651 {
652  char* sql = NULL; /* SQL query */
653  int status = 0; /* Status return */
654  int count = -1; /* How many keys get marked */
655 
656  /* Count how many we will mark */
657  sql = DqsCountInit("keypairs");
658  if (repo_id != -1) {
659  DqsConditionInt(&sql, "securitymodule_id", DQS_COMPARE_EQ, repo_id, 0);
660  StrAppend(&sql, " and pre_backup is not null");
661  StrAppend(&sql, " and backup is null");
662  } else {
663  StrAppend(&sql, " where pre_backup is not null");
664  StrAppend(&sql, " and backup is null");
665  }
666  DqsEnd(&sql);
667 
668  /* Execute query and free up the query string */
669  status = DbIntQuery(DbHandle(), &count, sql);
670  DqsFree(sql);
671 
672  if (status != 0)
673  {
674  status = MsgLog(KSM_SQLFAIL, DbErrmsg(DbHandle()));
675  return status;
676  }
677 
678  if (count == 0) {
679  /* No work to do */
680  return -1;
681  }
682 
683  /* Update rows */
684  sql = DusInit("keypairs");
685  DusSetString(&sql, "BACKUP", datetime, 0);
686  if (repo_id != -1) {
687  DusConditionInt(&sql, "securitymodule_id", DQS_COMPARE_EQ, repo_id, 0);
688  StrAppend(&sql, " and backup is null");
689  StrAppend(&sql, " and pre_backup is not null");
690  } else {
691  StrAppend(&sql, " where backup is null");
692  StrAppend(&sql, " and pre_backup is not null");
693  }
694  DusEnd(&sql);
695 
696  status = DbExecuteSqlNoResult(DbHandle(), sql);
697  DusFree(sql);
698 
699  return status;
700 }
701 
702 /*+
703  * KsmCheckHSMkeyID - Checks if the cka_id exists in the hsm specified
704  *
705  *
706  * Arguments:
707  *
708  * int repo_id
709  * ID of the repository (-1 for all)
710  *
711  * const char* cka_id
712  * ID to look for
713  *
714  * int *exists
715  * Flag to say if the ID exists
716  *
717  * Returns:
718  * int
719  * Status return. 0 on success.
720  * -1 if an unexpected count value was returned
721 -*/
722 
723 int KsmCheckHSMkeyID(int repo_id, const char* cka_id, int *exists)
724 {
725  char* sql = NULL; /* SQL query */
726  int status = 0; /* Status return */
727  int count = 0; /* Do we already have a key with this ID? */
728 
729  /* check the arguments */
730  if (cka_id == NULL) {
731  return MsgLog(KSM_INVARG, "NULL cka_id");
732  }
733 
734  /*
735  * Set up the count
736  */
737  sql = DqsCountInit("keypairs");
738  DqsConditionString(&sql, "HSMkey_id", DQS_COMPARE_EQ, cka_id, 0);
739  if (repo_id != -1) {
740  DqsConditionInt(&sql, "securitymodule_id", DQS_COMPARE_EQ, repo_id, 1);
741  }
742  DqsEnd(&sql);
743 
744  /* Execute query and free up the query string */
745  status = DbIntQuery(DbHandle(), &count, sql);
746  DqsFree(sql);
747 
748  if (status != 0)
749  {
750  status = MsgLog(KSM_SQLFAIL, DbErrmsg(DbHandle()));
751  return status;
752  }
753 
754  if (count > 0) {
755  *exists = 1;
756  }
757  else {
758  *exists = 0;
759  }
760 
761  return 0;
762 }
763 
#define StrFree(x)
Definition: string_util.h:66
#define KSM_INVARG
Definition: ksmdef.h:66
#define KSM_SQLFAIL
Definition: ksmdef.h:67
char * DqsSpecifyInit(const char *table, const char *fields)
Definition: dq_string.c:117
#define KSM_STATE_ACTIVE
Definition: ksm.h:366
#define DB_SECURITY_MODULE_TABLE
Definition: db_fields.h:90
int KsmMarkBackup(int repo_id, const char *datetime)
Definition: ksm_import.c:650
void DusFree(char *sql)
Definition: du_string.c:223
void DusConditionString(char **query, const char *field, DQS_COMPARISON compare, const char *value, int clause)
Definition: du_string.c:176
void DqsConditionKeyword(char **query, const char *field, DQS_COMPARISON compare, const char *value, int index)
Definition: dq_string.c:251
char * DisSpecifyInit(const char *table, const char *cols)
Definition: di_string.c:99
int MsgLog(int status,...)
Definition: message.c:335
void DusSetInt(char **sql, const char *field, int data, int clause)
Definition: du_string.c:97
void DqsFree(char *query)
Definition: dq_string.c:320
void DusConditionInt(char **query, const char *field, DQS_COMPARISON compare, int value, int clause)
Definition: du_string.c:170
const char * KsmKeywordStateValueToName(int value)
Definition: ksm_keyword.c:242
char * DqsCountInit(const char *table)
Definition: dq_string.c:90
DB_HANDLE DbHandle(void)
char * StrStrdup(const char *string)
Definition: string_util.c:124
void DqsConditionInt(char **query, const char *field, DQS_COMPARISON compare, int value, int index)
Definition: dq_string.c:224
int KsmMarkPreBackup(int repo_id, const char *datetime)
Definition: ksm_import.c:517
int KsmImportZone(const char *zone_name, int policy_id, int fail_if_exists, int *new_zone, const char *signconf, const char *input, const char *output, const char *input_type, const char *output_type)
Definition: ksm_import.c:218
int DbQuoteString(DB_HANDLE handle, const char *in, char *buffer, size_t buflen)
int KsmSerialIdFromName(const char *name, int *id)
Definition: ksm_import.c:427
int DbLastRowId(DB_HANDLE handle, DB_ID *id)
unsigned long DB_ID
Definition: database.h:78
const char * DbErrmsg(DB_HANDLE handle)
void DisAppendString(char **sql, const char *what)
Definition: di_string.c:142
void DisEnd(char **sql)
Definition: di_string.c:170
#define KSM_SQL_SIZE
Definition: ksm.h:63
#define KSM_POLICY_DESC_LENGTH
Definition: ksm.h:60
void StrAppend(char **str1, const char *str2)
Definition: string_util2.c:76
int KsmSmIdFromName(const char *name, int *id)
Definition: ksm_import.c:398
void DusEnd(char **sql)
Definition: du_string.c:202
int DbIntQuery(DB_HANDLE handle, int *value, const char *query)
char * DusInit(const char *table)
Definition: du_string.c:60
int KsmCheckHSMkeyID(int repo_id, const char *cka_id, int *exists)
Definition: ksm_import.c:723
int KsmImportKeyPair(int policy_id, const char *HSMKeyID, int smID, int size, int alg, int state, const char *time, int fixDate, DB_ID *id)
Definition: ksm_import.c:344
void DisFree(char *sql)
Definition: di_string.c:191
#define DB_ZONE_TABLE
Definition: db_fields.h:97
int KsmPolicyIdFromName(const char *name, int *id)
Definition: ksm_import.c:470
int KsmImportPolicy(const char *policy_name, const char *policy_description)
Definition: ksm_import.c:147
void DisAppendInt(char **sql, int what)
Definition: di_string.c:131
#define KSM_STATE_GENERATE
Definition: ksm.h:360
void DusSetString(char **sql, const char *field, const char *data, int clause)
Definition: du_string.c:113
void DqsEnd(char **query)
Definition: dq_string.c:299
int DbExecuteSqlNoResult(DB_HANDLE handle, const char *stmt_str)
void DqsConditionString(char **query, const char *field, DQS_COMPARISON compare, const char *value, int index)
Definition: dq_string.c:238
int KsmRollbackMarkPreBackup(int repo_id)
Definition: ksm_import.c:580
int KsmImportRepository(const char *repo_name, const char *repo_capacity, int require_backup)
Definition: ksm_import.c:70