r10003: in the rush for 10k, I forgot to run add the rest of Chris' libmsrpc files
[vlendec/samba-autobuild/.git] / source3 / libmsrpc / libmsrpc_internal.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  MS-RPC client internal functions
4  *  Copyright (C) Chris Nicholls              2005.
5  *  
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21
22 #include "libmsrpc.h"
23 #include "libmsrpc_internal.h"
24
25 /*takes a string like HKEY_LOCAL_MACHINE\HARDWARE\ACPI and returns the reg_type code and then a pointer to the start of the path (HARDWARE)*/
26 int cac_ParseRegPath(char *path, uint32 *reg_type, char **key_name) {
27
28    if(!path)
29       return CAC_FAILURE;
30
31    if(strncmp(path, "HKLM", 4) == 0) {
32       *reg_type = HKEY_LOCAL_MACHINE;
33       *key_name = (path[4] == '\\') ? path + 5 : NULL;
34    }
35    else if(strncmp(path, "HKEY_LOCAL_MACHINE", 18) == 0) {
36       *reg_type = HKEY_LOCAL_MACHINE;
37       *key_name = (path[18] == '\\') ? path + 19 : NULL;
38    }
39    else if(strncmp(path, "HKCR", 4) == 0) {
40       *reg_type = HKEY_CLASSES_ROOT;
41       *key_name = (path[4] == '\\') ? path + 5 : NULL;
42    }
43    else if(strncmp(path, "HKEY_CLASSES_ROOT", 17) == 0) {
44       *reg_type = HKEY_CLASSES_ROOT;
45       *key_name = (path[17] == '\\') ? path + 18 : NULL;
46    }
47    else if(strncmp(path, "HKU", 3) == 0) {
48       *reg_type = HKEY_USERS;
49       *key_name = (path[3] == '\\') ? path + 4 : NULL;
50    }
51    else if(strncmp(path, "HKEY_USERS", 10) == 0) {
52       *reg_type = HKEY_USERS;
53       *key_name = (path[10] == '\\') ? path + 11 : NULL;
54    }
55    else if(strncmp(path, "HKPD", 4) == 0) {
56       *reg_type = HKEY_PERFORMANCE_DATA;
57       *key_name = (path[4] == '\\') ? path + 5 : NULL;
58    }
59    else if(strncmp(path, "HKEY_PERFORMANCE_DATA", 21) == 0) {
60       *reg_type = HKEY_PERFORMANCE_DATA;
61       *key_name = (path[21] == '\\') ? path + 22 : NULL;
62    }
63    else {
64       return CAC_FAILURE;
65    }
66
67    return CAC_SUCCESS;
68 }
69
70
71
72 RPC_DATA_BLOB *cac_MakeRpcDataBlob(TALLOC_CTX *mem_ctx, uint32 data_type, REG_VALUE_DATA data) {
73    RPC_DATA_BLOB *blob = NULL;
74    int i;
75    uint32 size = 0;
76    uint32 len  = 0;
77    uint8 *multi = NULL;
78    uint32 multi_idx = 0;
79
80    blob = talloc(mem_ctx, RPC_DATA_BLOB);
81
82    if(!blob) {
83       errno = ENOMEM;
84       return NULL;
85    }
86
87    switch(data_type) {
88       case REG_SZ:
89          init_rpc_blob_str(blob, data.reg_sz, strlen(data.reg_sz ) + 1);
90          break;
91
92       case REG_EXPAND_SZ:
93          init_rpc_blob_str(blob, data.reg_expand_sz, strlen(data.reg_sz) + 1);
94          break;
95
96       case REG_BINARY:
97          init_rpc_blob_bytes(blob, data.reg_binary.data, data.reg_binary.data_length);
98          break;
99
100       case REG_DWORD:
101          init_rpc_blob_uint32(blob, data.reg_dword);
102          break;
103          
104       case REG_DWORD_BE:
105          init_rpc_blob_uint32(blob, data.reg_dword_be);
106          break;
107          
108       case REG_MULTI_SZ:
109          /*need to find the size*/
110          for(i = 0; i < data.reg_multi_sz.num_strings; i++) {
111             size += strlen(data.reg_multi_sz.strings[i]) + 1;
112          }
113
114          /**need a whole bunch of unicode strings in a row (seperated by null characters), with an extra null-character on the end*/
115
116          multi = TALLOC_ZERO_ARRAY(mem_ctx, uint8, (size + 1)*2); /*size +1 for the extra null character*/
117          if(!multi) {
118             errno = ENOMEM;
119             break;
120          }
121          
122          /*do it using rpcstr_push()*/
123          multi_idx = 0;
124          for(i = 0; i < data.reg_multi_sz.num_strings; i++) {
125             len = strlen(data.reg_multi_sz.strings[i]) + 1;
126
127             rpcstr_push((multi + multi_idx), data.reg_multi_sz.strings[i], len * 2, STR_TERMINATE);
128
129             /* x2 becuase it is a uint8 buffer*/
130             multi_idx += len * 2;
131          }
132             
133          /*now initialize the buffer as binary data*/
134          init_rpc_blob_bytes(blob, multi, (size + 1)*2);
135
136          break;
137
138       default:
139          talloc_free(blob);
140          blob = NULL;
141    }
142
143    if(!(blob->buffer)) {
144       talloc_free(blob);
145       return NULL;
146    }
147
148    return blob;
149 }
150
151 /*turns a string in a uint16 array to a char array*/
152 char *cac_unistr_to_str(TALLOC_CTX *mem_ctx, uint16 *src, int num_bytes) {
153    char *buf;
154    
155    int i = 0;
156
157    uint32 str_len = 0;
158    
159    /*don't allocate more space than we need*/
160    while( (str_len) < num_bytes/2 && src[str_len] != 0x0000)
161       str_len++;
162
163    /*need room for a '\0'*/
164    str_len++;
165
166    buf = talloc_array(mem_ctx, char, str_len);
167    if(!buf) {
168       return NULL;
169    }
170
171    for(i = 0; i < num_bytes/2; i++) {
172       buf[i] = ((char *)src)[2*i];
173    }
174
175    buf[str_len - 1] = '\0';
176
177    return buf;
178 }
179
180 REG_VALUE_DATA *cac_MakeRegValueData(TALLOC_CTX *mem_ctx, uint32 data_type, REGVAL_BUFFER buf) {
181    REG_VALUE_DATA *data;
182
183    uint32 i;
184
185    /*all of the following used for MULTI_SZ data*/
186    uint32 size       = 0;
187    uint32 len        = 0;
188    uint32 multi_idx  = 0;
189    uint32 num_strings= 0;
190    char **strings    = NULL;
191
192    data = talloc(mem_ctx, REG_VALUE_DATA);
193    if(!data) {
194       errno = ENOMEM;
195       return NULL;
196    }
197
198    switch (data_type) {
199       case REG_SZ:
200          data->reg_sz = cac_unistr_to_str(mem_ctx, buf.buffer, buf.buf_len);
201          if(!data->reg_sz) {
202             talloc_free(data);
203             errno = ENOMEM;
204             data = NULL;
205          }
206             
207          break;
208
209       case REG_EXPAND_SZ:
210          data->reg_expand_sz = cac_unistr_to_str(mem_ctx, buf.buffer, buf.buf_len);
211
212          if(!data->reg_expand_sz) {
213             talloc_free(data);
214             errno = ENOMEM;
215             data = NULL;
216          }
217             
218          break;
219
220       case REG_BINARY:
221          size = buf.buf_len;
222
223          data->reg_binary.data_length = size;
224
225          data->reg_binary.data = talloc_memdup(mem_ctx, buf.buffer, size);
226          if(!data->reg_binary.data) {
227             talloc_free(data);
228             errno = ENOMEM;
229             data = NULL;
230          }
231          break;
232
233       case REG_DWORD:
234          data->reg_dword = *((uint32 *)buf.buffer);
235          break;
236
237       case REG_DWORD_BE:
238          data->reg_dword_be = *((uint32 *)buf.buffer);
239          break;
240
241       case REG_MULTI_SZ:
242          size = buf.buf_len;
243
244          /*find out how many strings there are. size is # of bytes and we want to work uint16*/
245          for(i = 0; i < (size/2 - 1); i++) {
246             if(buf.buffer[i] == 0x0000)
247                num_strings++;
248
249             /*buffer is suppsed to be terminated with \0\0, but it might not be*/
250             if(buf.buffer[i] == 0x0000 && buf.buffer[i + 1] == 0x0000)
251                break;
252          }
253          
254          strings = talloc_array(mem_ctx, char *, num_strings);
255          if(!strings) {
256             errno = ENOMEM;
257             talloc_free(data);
258             break;
259          }
260
261          if(num_strings == 0) /*then our work here is done*/
262             break;
263
264          for(i = 0; i < num_strings; i++) {
265             /*find out how many characters are in this string*/
266             len = 0;
267             /*make sure we don't go past the end of the buffer and keep looping until we have a uni \0*/
268             while( multi_idx + len < size/2 && buf.buffer[multi_idx + len] != 0x0000)
269                len++;
270
271             /*stay aware of the \0\0*/
272             len++;
273
274             strings[i] = TALLOC_ZERO_ARRAY(mem_ctx, char, len);
275
276             /*pull out the unicode string*/
277             rpcstr_pull(strings[i], (buf.buffer + multi_idx) , len, -1, STR_TERMINATE);
278
279             /*keep track of where we are in the bigger array*/
280             multi_idx += len;
281          }
282
283          data->reg_multi_sz.num_strings = num_strings;
284          data->reg_multi_sz.strings     = strings;
285
286          break;
287
288       default:
289          talloc_free(data);
290          data = NULL;
291    }
292
293    return data;
294 }
295
296 SAM_USERINFO_CTR *cac_MakeUserInfoCtr(TALLOC_CTX *mem_ctx, CacUserInfo *info) {
297    SAM_USERINFO_CTR *ctr = NULL;
298
299    /*the flags we are 'setting'- include/passdb.h*/
300    uint32 flags = ACCT_USERNAME | ACCT_FULL_NAME | ACCT_PRIMARY_GID | ACCT_ADMIN_DESC | ACCT_DESCRIPTION |
301                      ACCT_HOME_DIR | ACCT_HOME_DRIVE | ACCT_LOGON_SCRIPT | ACCT_PROFILE | ACCT_WORKSTATIONS |
302                       ACCT_FLAGS;
303
304    NTTIME logon_time;
305    NTTIME logoff_time;
306    NTTIME kickoff_time;
307    NTTIME pass_last_set_time;
308    NTTIME pass_can_change_time;
309    NTTIME pass_must_change_time;
310
311    UNISTR2 user_name;
312    UNISTR2 full_name;
313    UNISTR2 home_dir;
314    UNISTR2 dir_drive;
315    UNISTR2 log_scr;
316    UNISTR2 prof_path;
317    UNISTR2 desc;
318    UNISTR2 wkstas;
319    UNISTR2 mung_dial;
320    UNISTR2 unk;
321
322    ctr = talloc(mem_ctx, SAM_USERINFO_CTR);
323    if(!ctr)
324       return NULL;
325
326    ZERO_STRUCTP(ctr->info.id23);
327
328    ctr->info.id21 = talloc(mem_ctx, SAM_USER_INFO_21);
329    if(!ctr->info.id21)
330       return NULL;
331
332    ctr->switch_value = 21;
333
334    ZERO_STRUCTP(ctr->info.id21);
335
336    unix_to_nt_time(&logon_time, info->logon_time);
337    unix_to_nt_time(&logoff_time, info->logoff_time);
338    unix_to_nt_time(&kickoff_time, info->kickoff_time);
339    unix_to_nt_time(&pass_last_set_time, info->pass_last_set_time);
340    unix_to_nt_time(&pass_can_change_time, info->pass_can_change_time);
341    unix_to_nt_time(&pass_must_change_time, info->pass_must_change_time);
342
343    /*initialize the strings*/
344    init_unistr2(&user_name, info->username, STR_TERMINATE);
345    init_unistr2(&full_name, info->full_name, STR_TERMINATE);
346    init_unistr2(&home_dir, info->home_dir, STR_TERMINATE);
347    init_unistr2(&dir_drive, info->home_drive, STR_TERMINATE);
348    init_unistr2(&log_scr, info->logon_script, STR_TERMINATE);
349    init_unistr2(&prof_path, info->profile_path, STR_TERMINATE);
350    init_unistr2(&desc, info->description, STR_TERMINATE);
351    init_unistr2(&wkstas, info->workstations, STR_TERMINATE);
352    init_unistr2(&unk, "\0", STR_TERMINATE);
353    init_unistr2(&mung_dial, info->dial, STR_TERMINATE);
354
355    /*manually set passmustchange*/
356    ctr->info.id21->passmustchange = (info->pass_must_change) ? 0x01 : 0x00;
357
358    init_sam_user_info21W(ctr->info.id21,
359                          &logon_time,
360                          &logoff_time,
361                          &kickoff_time,
362                          &pass_last_set_time,
363                          &pass_can_change_time,
364                          &pass_must_change_time,
365                          &user_name,
366                          &full_name,
367                          &home_dir,
368                          &dir_drive,
369                          &log_scr,
370                          &prof_path,
371                          &desc,
372                          &wkstas,
373                          &unk,
374                          &mung_dial,
375                          info->lm_password,
376                          info->nt_password,
377                          info->rid,
378                          info->group_rid,
379                          info->acb_mask,
380                          flags,
381                          168, /*logon divs*/
382                          info->logon_hours,
383                          info->bad_passwd_count,
384                          info->logon_count);
385
386    return ctr;
387    
388 }
389
390 char *talloc_unistr2_to_ascii(TALLOC_CTX *mem_ctx, UNISTR2 str) {
391    char *buf = NULL;
392
393    if(!mem_ctx)
394       return NULL;
395
396    buf = talloc_array(mem_ctx, char, (str.uni_str_len + 1));
397    if(!buf)
398       return NULL;
399
400    unistr2_to_ascii(buf, &str, str.uni_str_len + 1);
401
402    return buf;
403 }
404
405 CacUserInfo *cac_MakeUserInfo(TALLOC_CTX *mem_ctx, SAM_USERINFO_CTR *ctr) {
406    CacUserInfo *info = NULL;
407    SAM_USER_INFO_21 *id21 = NULL;
408
409    if(!ctr || ctr->switch_value != 21)
410       return NULL;
411
412    info = talloc(mem_ctx, CacUserInfo);
413    if(!info)
414       return NULL;
415
416    id21 = ctr->info.id21;
417
418    ZERO_STRUCTP(info);
419
420    info->logon_time = nt_time_to_unix(&id21->logon_time);
421    info->logoff_time = nt_time_to_unix(&id21->logoff_time);
422    info->kickoff_time = nt_time_to_unix(&id21->kickoff_time);
423    info->pass_last_set_time = nt_time_to_unix(&id21->pass_last_set_time);
424    info->pass_can_change_time = nt_time_to_unix(&id21->pass_can_change_time);
425    info->pass_must_change_time = nt_time_to_unix(&id21->pass_must_change_time);
426
427    info->username = talloc_unistr2_to_ascii(mem_ctx, id21->uni_user_name);
428    if(!info->username)
429       return NULL;
430
431    info->full_name = talloc_unistr2_to_ascii(mem_ctx, id21->uni_full_name);
432    if(!info->full_name)
433       return NULL;
434    
435    info->home_dir = talloc_unistr2_to_ascii(mem_ctx, id21->uni_home_dir);
436    if(!info->home_dir)
437       return NULL;
438    
439    info->home_drive = talloc_unistr2_to_ascii(mem_ctx, id21->uni_dir_drive);
440    if(!info->home_drive)
441       return NULL;
442
443    info->logon_script = talloc_unistr2_to_ascii(mem_ctx, id21->uni_logon_script);
444    if(!info->logon_script)
445       return NULL;
446
447    info->profile_path = talloc_unistr2_to_ascii(mem_ctx, id21->uni_profile_path);
448    if(!info->profile_path)
449       return NULL;
450    
451    info->description = talloc_unistr2_to_ascii(mem_ctx, id21->uni_acct_desc);
452    if(!info->description)
453       return NULL;
454    
455    info->workstations = talloc_unistr2_to_ascii(mem_ctx, id21->uni_workstations);
456    if(!info->workstations)
457       return NULL;
458
459    info->dial = talloc_unistr2_to_ascii(mem_ctx, id21->uni_munged_dial);
460    if(!info->dial)
461       return NULL;
462
463    info->rid = id21->user_rid;
464    info->group_rid = id21->group_rid;
465    info->acb_mask = id21->acb_info;
466    info->bad_passwd_count = id21->bad_password_count;
467    info->logon_count = id21->logon_count;
468
469    memcpy(info->nt_password, id21->nt_pwd, 8);
470    memcpy(info->lm_password, id21->lm_pwd, 8);
471    
472    info->logon_hours = talloc_memdup(mem_ctx, &(id21->logon_hrs), sizeof(LOGON_HRS));
473    if(!info->logon_hours)
474       return NULL;
475
476    info->pass_must_change = (id21->passmustchange) ? True : False;
477
478    return info;
479 }
480
481 CacGroupInfo *cac_MakeGroupInfo(TALLOC_CTX *mem_ctx, GROUP_INFO_CTR *ctr) {
482    CacGroupInfo *info = NULL;
483
484    if(!mem_ctx || !ctr || ctr->switch_value1 != 1)
485       return NULL;
486
487    info = talloc(mem_ctx, CacGroupInfo);
488    if(!info)
489       return NULL;
490
491    info->name = talloc_unistr2_to_ascii(mem_ctx, ctr->group.info1.uni_acct_name);
492    if(!info->name)
493       return NULL;
494
495    info->description = talloc_unistr2_to_ascii(mem_ctx, ctr->group.info1.uni_acct_desc);
496    if(!info->description)
497       return NULL;
498
499    info->num_members = ctr->group.info1.num_members;
500
501    return info;
502 }
503
504 GROUP_INFO_CTR *cac_MakeGroupInfoCtr(TALLOC_CTX *mem_ctx, CacGroupInfo *info) {
505    GROUP_INFO_CTR *ctr = NULL;
506
507    if(!mem_ctx || !info)
508       return NULL;
509
510    ctr = talloc(mem_ctx, GROUP_INFO_CTR);
511    if(!ctr)
512       return NULL;
513
514    ctr->switch_value1 = 1;
515
516    init_samr_group_info1(&(ctr->group.info1), info->name, info->description, info->num_members);
517
518    return ctr;
519 }
520
521 CacAliasInfo *cac_MakeAliasInfo(TALLOC_CTX *mem_ctx, ALIAS_INFO_CTR ctr) {
522    CacGroupInfo *info = NULL;
523
524    if(!mem_ctx || ctr.level != 1)
525       return NULL;
526
527    info = talloc(mem_ctx, CacAliasInfo);
528    if(!info)
529       return NULL;
530
531    info->name = talloc_unistr2_to_ascii(mem_ctx, *(ctr.alias.info1.name.string));
532    if(!info->name)
533       return NULL;
534
535    info->description = talloc_unistr2_to_ascii(mem_ctx, *(ctr.alias.info1.description.string));
536    if(!info->name)
537       return NULL;
538
539    info->num_members = ctr.alias.info1.num_member;
540
541    return info;
542 }
543
544 ALIAS_INFO_CTR *cac_MakeAliasInfoCtr(TALLOC_CTX *mem_ctx, CacAliasInfo *info) {
545    ALIAS_INFO_CTR *ctr = NULL;
546
547    if(!mem_ctx || !info)
548       return NULL;
549
550    ctr = talloc(mem_ctx, ALIAS_INFO_CTR);
551    if(!ctr)
552       return NULL;
553
554    ctr->level = 1;
555
556    init_samr_alias_info1(&(ctr->alias.info1), info->name, info->num_members, info->description);
557
558    return ctr;
559 }
560
561 CacDomainInfo *cac_MakeDomainInfo(TALLOC_CTX *mem_ctx, SAM_UNK_INFO_1 *info1, SAM_UNK_INFO_2 *info2, SAM_UNK_INFO_12 *info12) {
562    CacDomainInfo *info = NULL;
563
564    if(!mem_ctx || !info1 || !info2 || !info12)
565       return NULL;
566
567    info = talloc(mem_ctx, CacDomainInfo);
568    if(!info)
569       return NULL;
570
571    info->min_pass_length = info1->min_length_password;
572    info->pass_history    = info1->password_history;
573
574    cac_InitCacTime(&(info->expire), info1->expire);
575    cac_InitCacTime(&(info->min_pass_age), info1->min_passwordage);
576
577    info->server_role       = info2->server_role;
578    info->num_users         = info2->num_domain_usrs;
579    info->num_domain_groups = info2->num_domain_grps;
580    info->num_local_groups  = info2->num_local_grps;
581
582    /*if these have been ZERO'd out we need to know. uni_str_len will be 0*/
583    if(info2->uni_comment.uni_str_len == 0) {
584       info->comment = talloc_strdup(mem_ctx, "\0");
585    }
586    else {
587       info->comment = talloc_unistr2_to_ascii(mem_ctx, info2->uni_comment);
588    }
589
590    if(info2->uni_domain.uni_str_len == 0) {
591       info->domain_name = talloc_strdup(mem_ctx, "\0");
592    }
593    else {
594       info->domain_name = talloc_unistr2_to_ascii(mem_ctx, info2->uni_domain);
595    }
596
597    if(info2->uni_server.uni_str_len == 0) {
598       info->server_name = talloc_strdup(mem_ctx, "\0");
599    }
600    else {
601       info->server_name = talloc_unistr2_to_ascii(mem_ctx, info2->uni_server);
602    }
603
604
605    cac_InitCacTime(&(info->lockout_duration), info12->duration);
606    cac_InitCacTime(&(info->lockout_reset), info12->reset_count);
607    info->num_bad_attempts = info12->bad_attempt_lockout;
608
609    return info;
610 }
611
612 char *cac_unistr_ascii(TALLOC_CTX *mem_ctx, UNISTR src) {
613    char *buf;
614    uint32 len;
615
616    if(!mem_ctx || !src.buffer)
617       return NULL;
618
619    len = unistrlen(src.buffer) + 1;
620
621    buf = TALLOC_ZERO_ARRAY(mem_ctx, char, len);
622    if(!buf)
623       return NULL;
624
625    rpcstr_pull(buf, src.buffer, len, -1, STR_TERMINATE);
626
627    return buf;
628 }
629
630 CacService *cac_MakeServiceArray(TALLOC_CTX *mem_ctx, ENUM_SERVICES_STATUS *svc, uint32 num_services) {
631    int i;
632    CacService *services = NULL;
633
634    if(!mem_ctx || !svc)
635       return NULL;
636
637    services = TALLOC_ZERO_ARRAY(mem_ctx, CacService, num_services);
638    if(!services)
639       return NULL;
640
641    for(i = 0; i < num_services; i++) {
642       services[i].service_name = cac_unistr_ascii(mem_ctx, svc[i].servicename);
643       services[i].display_name = cac_unistr_ascii(mem_ctx, svc[i].displayname);
644
645       if(!services[i].service_name || !services[i].display_name)
646          return NULL;
647
648       services[i].status = svc[i].status;
649    }
650
651    return services;
652 }
653
654 int cac_InitCacServiceConfig(TALLOC_CTX *mem_ctx, SERVICE_CONFIG *src, CacServiceConfig *dest) {
655    if(!src || !dest)
656       return CAC_FAILURE;
657
658    dest->exe_path = talloc_unistr2_to_ascii(mem_ctx, *src->executablepath);
659    if(!dest->exe_path)
660       return CAC_FAILURE;
661
662    dest->load_order_group = talloc_unistr2_to_ascii(mem_ctx, *src->loadordergroup);
663    if(!dest->load_order_group)
664       return CAC_FAILURE;
665
666    dest->dependencies = talloc_unistr2_to_ascii(mem_ctx, *src->dependencies);
667    if(!dest->dependencies)
668       return CAC_FAILURE;
669
670    dest->start_name = talloc_unistr2_to_ascii(mem_ctx, *src->startname);
671    if(!dest->start_name)
672       return CAC_FAILURE;
673
674    dest->display_name = talloc_unistr2_to_ascii(mem_ctx, *src->displayname);
675    if(!dest->display_name)
676       return CAC_FAILURE;
677
678    dest->type = src->service_type;
679    dest->start_type = src->start_type;
680    dest->error_control = src->error_control;
681    dest->tag_id = src->tag_id;
682
683    return CAC_SUCCESS;
684 }