s3:services_db: rewrite svcctl_init_keys() to use reg_api calls instead of legacy
[kai/samba.git] / source3 / services / services_db.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  Service Control API Implementation
4  * 
5  *  Copyright (C) Marcin Krzysztof Porwit         2005.
6  *  Largely Rewritten by:
7  *  Copyright (C) Gerald (Jerry) Carter           2005.
8  *  
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 3 of the License, or
12  *  (at your option) any later version.
13  *  
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *  
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #include "includes.h"
24 #include "services/services.h"
25 #include "registry.h"
26 #include "registry/reg_util_legacy.h"
27 #include "registry/reg_dispatcher.h"
28 #include "registry/reg_objects.h"
29 #include "registry/reg_api_util.h"
30
31 struct rcinit_file_information {
32         char *description;
33 };
34
35 struct service_display_info {
36         const char *servicename;
37         const char *daemon;
38         const char *dispname;
39         const char *description;
40 };
41
42 struct service_display_info builtin_svcs[] = {
43   { "Spooler",        "smbd",   "Print Spooler", "Internal service for spooling files to print devices" },
44   { "NETLOGON",       "smbd",   "Net Logon", "File service providing access to policy and profile data (not remotely manageable)" },
45   { "RemoteRegistry", "smbd",   "Remote Registry Service", "Internal service providing remote access to "
46                                 "the Samba registry" },
47   { "WINS",           "nmbd",   "Windows Internet Name Service (WINS)", "Internal service providing a "
48                                 "NetBIOS point-to-point name server (not remotely manageable)" },
49   { NULL, NULL, NULL, NULL }
50 };
51
52 struct service_display_info common_unix_svcs[] = {
53   { "cups",          NULL, "Common Unix Printing System","Provides unified printing support for all operating systems" },
54   { "postfix",       NULL, "Internet Mail Service",     "Provides support for sending and receiving electonic mail" },
55   { "sendmail",      NULL, "Internet Mail Service",     "Provides support for sending and receiving electonic mail" },
56   { "portmap",       NULL, "TCP Port to RPC PortMapper",NULL },
57   { "xinetd",        NULL, "Internet Meta-Daemon",      NULL },
58   { "inet",          NULL, "Internet Meta-Daemon",      NULL },
59   { "xntpd",         NULL, "Network Time Service",      NULL },
60   { "ntpd",          NULL, "Network Time Service",      NULL },
61   { "lpd",           NULL, "BSD Print Spooler",         NULL },
62   { "nfsserver",     NULL, "Network File Service",      NULL },
63   { "cron",          NULL, "Scheduling Service",        NULL },
64   { "at",            NULL, "Scheduling Service",        NULL },
65   { "nscd",          NULL, "Name Service Cache Daemon", NULL },
66   { "slapd",         NULL, "LDAP Directory Service",    NULL },
67   { "ldap",          NULL, "LDAP DIrectory Service",    NULL },
68   { "ypbind",        NULL, "NIS Directory Service",     NULL },
69   { "courier-imap",  NULL, "IMAP4 Mail Service",        NULL },
70   { "courier-pop3",  NULL, "POP3 Mail Service",         NULL },
71   { "named",         NULL, "Domain Name Service",       NULL },
72   { "bind",          NULL, "Domain Name Service",       NULL },
73   { "httpd",         NULL, "HTTP Server",               NULL },
74   { "apache",        NULL, "HTTP Server",               "Provides s highly scalable and flexible web server "
75                                                         "capable of implementing various protocols incluing "
76                                                         "but not limited to HTTP" },
77   { "autofs",        NULL, "Automounter",               NULL },
78   { "squid",         NULL, "Web Cache Proxy ",          NULL },
79   { "perfcountd",    NULL, "Performance Monitoring Daemon", NULL },
80   { "pgsql",         NULL, "PgSQL Database Server",     "Provides service for SQL database from Postgresql.org" },
81   { "arpwatch",      NULL, "ARP Tables watcher",        "Provides service for monitoring ARP tables for changes" },
82   { "dhcpd",         NULL, "DHCP Server",               "Provides service for dynamic host configuration and IP assignment" },
83   { "nwserv",        NULL, "NetWare Server Emulator",   "Provides service for emulating Novell NetWare 3.12 server" },
84   { "proftpd",       NULL, "Professional FTP Server",   "Provides high configurable service for FTP connection and "
85                                                         "file transferring" },
86   { "ssh2",          NULL, "SSH Secure Shell",          "Provides service for secure connection for remote administration" },
87   { "sshd",          NULL, "SSH Secure Shell",          "Provides service for secure connection for remote administration" },
88   { NULL, NULL, NULL, NULL }
89 };
90
91 static WERROR svcctl_set_secdesc_internal(struct registry_key *key,
92                                           struct security_descriptor *sec_desc);
93
94 /********************************************************************
95 ********************************************************************/
96
97 static struct security_descriptor* construct_service_sd( TALLOC_CTX *ctx )
98 {
99         struct security_ace ace[4];
100         size_t i = 0;
101         struct security_descriptor *sd = NULL;
102         struct security_acl *theacl = NULL;
103         size_t sd_size;
104
105         /* basic access for Everyone */
106
107         init_sec_ace(&ace[i++], &global_sid_World,
108                 SEC_ACE_TYPE_ACCESS_ALLOWED, SERVICE_READ_ACCESS, 0);
109
110         init_sec_ace(&ace[i++], &global_sid_Builtin_Power_Users,
111                         SEC_ACE_TYPE_ACCESS_ALLOWED, SERVICE_EXECUTE_ACCESS, 0);
112
113         init_sec_ace(&ace[i++], &global_sid_Builtin_Server_Operators,
114                 SEC_ACE_TYPE_ACCESS_ALLOWED, SERVICE_ALL_ACCESS, 0);
115         init_sec_ace(&ace[i++], &global_sid_Builtin_Administrators,
116                 SEC_ACE_TYPE_ACCESS_ALLOWED, SERVICE_ALL_ACCESS, 0);
117
118         /* create the security descriptor */
119
120         theacl = make_sec_acl(ctx, NT4_ACL_REVISION, i, ace);
121         if (theacl == NULL) {
122                 return NULL;
123         }
124
125         sd = make_sec_desc(ctx, SECURITY_DESCRIPTOR_REVISION_1,
126                            SEC_DESC_SELF_RELATIVE, NULL, NULL, NULL,
127                            theacl, &sd_size);
128         if (sd == NULL) {
129                 return NULL;
130         }
131
132         return sd;
133 }
134
135 /********************************************************************
136  This is where we do the dirty work of filling in things like the
137  Display name, Description, etc...
138 ********************************************************************/
139
140 static char *get_common_service_dispname( const char *servicename )
141 {
142         int i;
143
144         for ( i=0; common_unix_svcs[i].servicename; i++ ) {
145                 if (strequal(servicename, common_unix_svcs[i].servicename)) {
146                         char *dispname;
147                         if (asprintf(&dispname,
148                                 "%s (%s)",
149                                 common_unix_svcs[i].dispname,
150                                 common_unix_svcs[i].servicename) < 0) {
151                                 return NULL;
152                         }
153                         return dispname;
154                 }
155         }
156
157         return SMB_STRDUP(servicename );
158 }
159
160 /********************************************************************
161 ********************************************************************/
162
163 static char *cleanup_string( const char *string )
164 {
165         char *clean = NULL;
166         char *begin, *end;
167         TALLOC_CTX *ctx = talloc_tos();
168
169         clean = talloc_strdup(ctx, string);
170         if (!clean) {
171                 return NULL;
172         }
173         begin = clean;
174
175         /* trim any beginning whilespace */
176
177         while (isspace(*begin)) {
178                 begin++;
179         }
180
181         if (*begin == '\0') {
182                 return NULL;
183         }
184
185         /* trim any trailing whitespace or carriage returns.
186            Start at the end and move backwards */
187
188         end = begin + strlen(begin) - 1;
189
190         while ( isspace(*end) || *end=='\n' || *end=='\r' ) {
191                 *end = '\0';
192                 end--;
193         }
194
195         return begin;
196 }
197
198 /********************************************************************
199 ********************************************************************/
200
201 static bool read_init_file( const char *servicename, struct rcinit_file_information **service_info )
202 {
203         struct rcinit_file_information *info = NULL;
204         char *filepath = NULL;
205         char str[1024];
206         XFILE *f = NULL;
207         char *p = NULL;
208
209         info = TALLOC_ZERO_P( NULL, struct rcinit_file_information );
210         if (info == NULL) {
211                 return False;
212         }
213
214         /* attempt the file open */
215
216         filepath = talloc_asprintf(info, "%s/%s/%s", get_dyn_MODULESDIR(),
217                                 SVCCTL_SCRIPT_DIR, servicename);
218         if (!filepath) {
219                 TALLOC_FREE(info);
220                 return false;
221         }
222         f = x_fopen( filepath, O_RDONLY, 0 );
223         if (f == NULL) {
224                 DEBUG(0,("read_init_file: failed to open [%s]\n", filepath));
225                 TALLOC_FREE(info);
226                 return false;
227         }
228
229         while ( (x_fgets( str, sizeof(str)-1, f )) != NULL ) {
230                 /* ignore everything that is not a full line
231                    comment starting with a '#' */
232
233                 if ( str[0] != '#' )
234                         continue;
235
236                 /* Look for a line like '^#.*Description:' */
237
238                 p = strstr( str, "Description:" );
239                 if (p != NULL) {
240                         char *desc;
241
242                         p += strlen( "Description:" ) + 1;
243                         if ( !p )
244                                 break;
245
246                         desc = cleanup_string(p);
247                         if (desc != NULL)
248                                 info->description = talloc_strdup( info, desc );
249                 }
250         }
251
252         x_fclose( f );
253
254         if ( !info->description )
255                 info->description = talloc_strdup( info, "External Unix Service" );
256
257         *service_info = info;
258         TALLOC_FREE(filepath);
259
260         return True;
261 }
262
263 /********************************************************************
264  This is where we do the dirty work of filling in things like the
265  Display name, Description, etc...
266 ********************************************************************/
267
268 static WERROR svcctl_setvalue(struct registry_key *key,
269                               const char *name,
270                               struct registry_value *value)
271 {
272         WERROR wresult;
273
274         wresult = reg_setvalue(key, name, value);
275         if (!W_ERROR_IS_OK(wresult)) {
276                 DEBUG(0, ("reg_setvalue failed for %s in key %s: %s\n",
277                           name, key->key->name, win_errstr(wresult)));
278         }
279
280         return wresult;
281 }
282
283 static WERROR svcctl_setvalue_dword(struct registry_key *key,
284                                     const char *name,
285                                     uint32_t dword)
286 {
287         struct registry_value value;
288
289         value.type = REG_DWORD;
290         value.data.length = sizeof(uint32_t);
291         value.data.data = (uint8_t *)&dword;
292
293         return svcctl_setvalue(key, name, &value);
294 }
295
296 static WERROR svcctl_setvalue_sz(struct registry_key *key,
297                                  const char *name,
298                                  const char *sz)
299 {
300         struct registry_value value;
301         WERROR wresult;
302         TALLOC_CTX *mem_ctx = talloc_stackframe();
303
304         if (!push_reg_sz(mem_ctx, &value.data, sz)) {
305                 DEBUG(0, ("push_reg_sz failed\n"));
306                 wresult = WERR_NOMEM;
307                 goto done;
308         }
309         value.type = REG_SZ;
310
311         wresult = svcctl_setvalue(key, name, &value);
312 done:
313         talloc_free(mem_ctx);
314         return wresult;
315 }
316
317 static void fill_service_values(struct registry_key *key)
318 {
319         char *dname, *ipath, *description;
320         int i;
321         WERROR wresult;
322         TALLOC_CTX *mem_ctx = talloc_stackframe();
323         char *name = NULL;
324
325         name = strrchr(key->key->name, '\\');
326         if (name == NULL) {
327                 name = key->key->name;
328         } else {
329                 name++;
330         }
331
332         /* These values are hardcoded in all QueryServiceConfig() replies.
333            I'm just storing them here for cosmetic purposes */
334
335         wresult = svcctl_setvalue_dword(key, "Start", SVCCTL_AUTO_START);
336         if (!W_ERROR_IS_OK(wresult)) {
337                 goto done;
338         }
339
340         wresult = svcctl_setvalue_dword(key, "Type", SERVICE_TYPE_WIN32_OWN_PROCESS);
341         if (!W_ERROR_IS_OK(wresult)) {
342                 goto done;
343         }
344
345         wresult = svcctl_setvalue_dword(key, "ErrorControl", SVCCTL_SVC_ERROR_NORMAL);
346         if (!W_ERROR_IS_OK(wresult)) {
347                 goto done;
348         }
349
350         /* everything runs as LocalSystem */
351
352         wresult = svcctl_setvalue_sz(key, "ObjectName", "LocalSystem");
353         if (!W_ERROR_IS_OK(wresult)) {
354                 goto done;
355         }
356
357         /* special considerations for internal services and the DisplayName value */
358
359         for ( i=0; builtin_svcs[i].servicename; i++ ) {
360                 if ( strequal( name, builtin_svcs[i].servicename ) ) {
361                         ipath = talloc_asprintf(mem_ctx, "%s/%s/%s",
362                                                 get_dyn_MODULESDIR(),
363                                                 SVCCTL_SCRIPT_DIR,
364                                                 builtin_svcs[i].daemon);
365                         description = talloc_strdup(mem_ctx, builtin_svcs[i].description);
366                         dname = talloc_strdup(mem_ctx, builtin_svcs[i].dispname);
367                         break;
368                 }
369         }
370
371         /* default to an external service if we haven't found a match */
372
373         if ( builtin_svcs[i].servicename == NULL ) {
374                 char *dispname = NULL;
375                 struct rcinit_file_information *init_info = NULL;
376
377                 ipath = talloc_asprintf(mem_ctx, "%s/%s/%s",
378                                         get_dyn_MODULESDIR(), SVCCTL_SCRIPT_DIR,
379                                         name);
380
381                 /* lookup common unix display names */
382                 dispname = get_common_service_dispname(name);
383                 dname = talloc_strdup(mem_ctx, dispname ? dispname : "");
384                 SAFE_FREE(dispname);
385
386                 /* get info from init file itself */
387                 if ( read_init_file( name, &init_info ) ) {
388                         description = talloc_strdup(mem_ctx, init_info->description);
389                         TALLOC_FREE( init_info );
390                 }
391                 else {
392                         description = talloc_strdup(mem_ctx, "External Unix Service");
393                 }
394         }
395
396         /* add the new values */
397
398         wresult = svcctl_setvalue_sz(key, "DisplayName", dname);
399         if (!W_ERROR_IS_OK(wresult)) {
400                 goto done;
401         }
402
403         wresult = svcctl_setvalue_sz(key, "ImagePath", ipath);
404         if (!W_ERROR_IS_OK(wresult)) {
405                 goto done;
406         }
407
408         wresult = svcctl_setvalue_sz(key, "Description", description);
409
410 done:
411         talloc_free(mem_ctx);
412         return;
413 }
414
415 /********************************************************************
416 ********************************************************************/
417
418 static void add_new_svc_name(struct registry_key *key_parent,
419                              const char *name)
420 {
421         struct registry_key *key_service = NULL, *key_secdesc = NULL;
422         WERROR wresult;
423         struct security_descriptor *sd = NULL;
424         TALLOC_CTX *mem_ctx = talloc_stackframe();
425         enum winreg_CreateAction action = REG_ACTION_NONE;
426
427         wresult = reg_createkey(mem_ctx, key_parent, name, REG_KEY_ALL,
428                                 &key_service, &action);
429
430         if (!W_ERROR_IS_OK(wresult)) {
431                 DEBUG(0, ("add_new_svc_name: reg_createkey failed for %s\\%s: "
432                           "%s\n", key_parent->key->name, name,
433                           win_errstr(wresult)));
434                 goto done;
435         }
436
437         /* now for the service values */
438
439         fill_service_values(key_service);
440
441         /* now add the security descriptor */
442
443         sd = construct_service_sd(key_secdesc);
444         if (sd == NULL) {
445                 DEBUG(0, ("add_new_svc_name: Failed to create default "
446                           "sec_desc!\n"));
447                 goto done;
448         }
449
450         wresult = svcctl_set_secdesc_internal(key_service, sd);
451
452 done:
453         talloc_free(mem_ctx);
454         return;
455 }
456
457 /********************************************************************
458 ********************************************************************/
459
460 void svcctl_init_keys( void )
461 {
462         const char **service_list = lp_svcctl_list();
463         int i;
464         struct registry_key *key = NULL;
465         struct registry_key *subkey = NULL;
466         WERROR wresult;
467         TALLOC_CTX *mem_ctx = talloc_stackframe();
468
469         /* bad mojo here if the lookup failed.  Should not happen */
470
471         wresult = reg_open_path(mem_ctx, KEY_SERVICES, REG_KEY_ALL, get_root_nt_token(), &key);
472
473         if ( !W_ERROR_IS_OK(wresult) ) {
474                 DEBUG(0,("svcctl_init_keys: key lookup failed! (%s)\n",
475                         win_errstr(wresult)));
476                 goto done;
477         }
478
479         /* the builtin services exist */
480
481         for ( i=0; builtin_svcs[i].servicename; i++ )
482                 add_new_svc_name(key, builtin_svcs[i].servicename);
483
484         for ( i=0; service_list && service_list[i]; i++ ) {
485
486                 /* only add new services */
487
488                 wresult = reg_openkey(mem_ctx, key, service_list[i], REG_KEY_ALL, &subkey);
489                 if (W_ERROR_IS_OK(wresult)) {
490                         continue;
491                 }
492
493                 /* Add the new service key and initialize the appropriate values */
494
495                 add_new_svc_name(key, service_list[i]);
496         }
497
498         /* initialize the control hooks */
499
500         init_service_op_table();
501
502 done:
503         talloc_free(mem_ctx);
504         return;
505 }
506
507 /********************************************************************
508  This is where we do the dirty work of filling in things like the
509  Display name, Description, etc...Always return a default secdesc
510  in case of any failure.
511 ********************************************************************/
512
513 struct security_descriptor *svcctl_get_secdesc( TALLOC_CTX *ctx, const char *name, struct security_token *token )
514 {
515         struct registry_key *key = NULL;
516         struct registry_value *value;
517         struct security_descriptor *ret_sd = NULL;
518         char *path= NULL;
519         WERROR wresult;
520         NTSTATUS status;
521         TALLOC_CTX *mem_ctx = talloc_stackframe();
522
523         path = talloc_asprintf(mem_ctx, "%s\\%s\\%s", KEY_SERVICES, name,
524                                "Security");
525         if (path == NULL) {
526                 goto done;
527         }
528
529         wresult = reg_open_path(mem_ctx, path, REG_KEY_ALL, token, &key);
530         if ( !W_ERROR_IS_OK(wresult) ) {
531                 DEBUG(0,("svcctl_get_secdesc: key lookup failed! [%s] (%s)\n",
532                         path, win_errstr(wresult)));
533                 goto done;
534         }
535
536         wresult = reg_queryvalue(mem_ctx, key, "Security", &value);
537         if (W_ERROR_EQUAL(wresult, WERR_BADFILE)) {
538                 goto fallback_to_default_sd;
539         } else if (!W_ERROR_IS_OK(wresult)) {
540                 DEBUG(0, ("svcctl_get_secdesc: error getting value 'Security': "
541                           "%s\n", win_errstr(wresult)));
542                 goto done;
543         }
544
545         status = unmarshall_sec_desc(ctx, value->data.data,
546                                      value->data.length, &ret_sd);
547
548         if (NT_STATUS_IS_OK(status)) {
549                 goto done;
550         }
551
552 fallback_to_default_sd:
553         DEBUG(6, ("svcctl_get_secdesc: constructing default secdesc for "
554                   "service [%s]\n", name));
555         ret_sd = construct_service_sd(ctx);
556
557 done:
558         talloc_free(mem_ctx);
559         return ret_sd;
560 }
561
562 /********************************************************************
563  Wrapper to make storing a Service sd easier
564 ********************************************************************/
565
566 static WERROR svcctl_set_secdesc_internal(struct registry_key *key,
567                                           struct security_descriptor *sec_desc)
568 {
569         struct registry_key *key_security = NULL;
570         WERROR wresult;
571         struct registry_value value;
572         NTSTATUS status;
573         enum winreg_CreateAction action = REG_ACTION_NONE;
574         TALLOC_CTX *mem_ctx = talloc_stackframe();
575
576         wresult = reg_createkey(mem_ctx, key, "Security", REG_KEY_ALL, &key_security, &action);
577         if (!W_ERROR_IS_OK(wresult)) {
578                 DEBUG(0, ("svcctl_set_secdesc: reg_createkey failed: "
579                           "[%s\\Security] (%s)\n", key->key->name,
580                           win_errstr(wresult)));
581                 goto done;
582         }
583
584         status = marshall_sec_desc(mem_ctx, sec_desc, &value.data.data,
585                                    &value.data.length);
586         if (!NT_STATUS_IS_OK(status)) {
587                 DEBUG(0, ("svcctl_set_secdesc: marshall_sec_desc() failed: %s\n",
588                           nt_errstr(status)));
589                 wresult = ntstatus_to_werror(status);
590                 goto done;
591         }
592
593         value.type = REG_BINARY;
594
595         wresult = reg_setvalue(key_security, "Security", &value);
596         if (!W_ERROR_IS_OK(wresult)) {
597                 DEBUG(0, ("svcctl_set_secdesc: reg_setvalue failed: %s\n",
598                           win_errstr(wresult)));
599         }
600
601 done:
602         talloc_free(mem_ctx);
603         return wresult;
604 }
605
606 bool svcctl_set_secdesc(const char *name, struct security_descriptor *sec_desc,
607                         struct security_token *token)
608 {
609         struct registry_key *key = NULL;
610         WERROR wresult;
611         char *path = NULL;
612         bool ret = false;
613         TALLOC_CTX *mem_ctx = talloc_stackframe();
614
615         path = talloc_asprintf(mem_ctx, "%s\\%s", KEY_SERVICES, name);
616         if (path == NULL) {
617                 goto done;
618         }
619
620         wresult = reg_open_path(mem_ctx, path, REG_KEY_ALL, token, &key);
621         if ( !W_ERROR_IS_OK(wresult) ) {
622                 DEBUG(0, ("svcctl_set_secdesc: key lookup failed! [%s] (%s)\n",
623                           path, win_errstr(wresult)));
624                 goto done;
625         }
626
627         wresult = svcctl_set_secdesc_internal(key, sec_desc);
628
629         ret = W_ERROR_IS_OK(wresult);
630
631 done:
632         talloc_free(mem_ctx);
633         return ret;
634 }
635
636 const char *svcctl_get_string_value(TALLOC_CTX *ctx, const char *key_name,
637                                     const char *value_name,
638                                     struct security_token *token)
639 {
640         const char *result = NULL;
641         struct registry_key *key = NULL;
642         struct registry_value *value = NULL;
643         char *path = NULL;
644         WERROR wresult;
645         TALLOC_CTX *mem_ctx = talloc_stackframe();
646
647         path = talloc_asprintf(mem_ctx, "%s\\%s", KEY_SERVICES, key_name);
648         if (path == NULL) {
649                 goto done;
650         }
651
652         wresult = reg_open_path(mem_ctx, path, REG_KEY_READ, token, &key);
653         if (!W_ERROR_IS_OK(wresult)) {
654                 DEBUG(0, ("svcctl_get_string_value: key lookup failed! "
655                           "[%s] (%s)\n", path, win_errstr(wresult)));
656                 goto done;
657         }
658
659         wresult = reg_queryvalue(mem_ctx, key, value_name, &value);
660         if (!W_ERROR_IS_OK(wresult)) {
661                 DEBUG(0, ("svcctl_get_string_value: error getting value "
662                           "'%s': %s\n", value_name, win_errstr(wresult)));
663                 goto done;
664         }
665
666         if (value->type != REG_SZ) {
667                 goto done;
668         }
669
670         pull_reg_sz(ctx, &value->data, &result);
671
672         goto done;
673
674 done:
675         talloc_free(mem_ctx);
676         return result;
677 }
678
679 /********************************************************************
680 ********************************************************************/
681
682 const char *svcctl_lookup_dispname(TALLOC_CTX *ctx, const char *name, struct security_token *token )
683 {
684         const char *display_name = NULL;
685
686         display_name = svcctl_get_string_value(ctx, name, "DisplayName", token);
687
688         if (display_name == NULL) {
689                 display_name = talloc_strdup(ctx, name);
690         }
691
692         return display_name;
693 }
694
695 /********************************************************************
696 ********************************************************************/
697
698 const char *svcctl_lookup_description(TALLOC_CTX *ctx, const char *name, struct security_token *token )
699 {
700         const char *description = NULL;
701
702         description = svcctl_get_string_value(ctx, name, "Description", token);
703
704         if (description == NULL) {
705                 description = talloc_strdup(ctx, "Unix Service");
706         }
707
708         return description;
709 }