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