s4:kdc: Implement KDC plugin hardware authentication policy
[samba.git] / source3 / rpc_server / svcctl / srv_svcctl_reg.c
index eb0c2bddb6b65e5fa77d15dceb44ce73f1070df1..78f6096eb6a5e74eaacc7948cb75f9d1df1957fa 100644 (file)
@@ -101,7 +101,7 @@ static struct service_display_info common_unix_svcs[] = {
   { "bind",          NULL, "Domain Name Service",      NULL },
   { "httpd",         NULL, "HTTP Server",              NULL },
   { "apache",        NULL, "HTTP Server",              "Provides s highly scalable and flexible web server "
-                                                       "capable of implementing various protocols incluing "
+                                                       "capable of implementing various protocols including "
                                                        "but not limited to HTTP" },
   { "autofs",        NULL, "Automounter",              NULL },
   { "squid",         NULL, "Web Cache Proxy ",         NULL },
@@ -187,7 +187,7 @@ static bool read_init_file(TALLOC_CTX *mem_ctx,
        struct rcinit_file_information *info = NULL;
        char *filepath = NULL;
        char str[1024];
-       XFILE *f = NULL;
+       FILE *f = NULL;
        char *p = NULL;
 
        info = talloc_zero(mem_ctx, struct rcinit_file_information);
@@ -205,13 +205,13 @@ static bool read_init_file(TALLOC_CTX *mem_ctx,
        if (filepath == NULL) {
                return false;
        }
-       f = x_fopen( filepath, O_RDONLY, 0 );
+       f = fopen( filepath, "r" );
        if (f == NULL) {
                DEBUG(0,("read_init_file: failed to open [%s]\n", filepath));
                return false;
        }
 
-       while ((x_fgets(str, sizeof(str) - 1, f)) != NULL) {
+       while ((fgets(str, sizeof(str) - 1, f)) != NULL) {
                /* ignore everything that is not a full line
                   comment starting with a '#' */
 
@@ -224,20 +224,20 @@ static bool read_init_file(TALLOC_CTX *mem_ctx,
                p = strstr(str, "Description:");
                if (p != NULL) {
                        char *desc;
+                       size_t len = strlen(p);
 
-                       p += strlen( "Description:" ) + 1;
-                       if (p == NULL) {
+                       if (len <= 12) {
                                break;
                        }
 
-                       desc = svcctl_cleanup_string(mem_ctx, p);
+                       desc = svcctl_cleanup_string(mem_ctx, p + 12);
                        if (desc != NULL) {
                                info->description = talloc_strdup(info, desc);
                        }
                }
        }
 
-       x_fclose(f);
+       fclose(f);
 
        if (info->description == NULL) {
                info->description = talloc_strdup(info,
@@ -392,10 +392,6 @@ static bool svcctl_add_service(TALLOC_CTX *mem_ctx,
                }
        }
 
-       if (ipath == NULL || dname == NULL || description == NULL) {
-               goto done;
-       }
-
        /* Default to an external service if we haven't found a match */
        if (builtin_svcs[i].servicename == NULL) {
                struct rcinit_file_information *init_info = NULL;
@@ -491,7 +487,7 @@ static bool svcctl_add_service(TALLOC_CTX *mem_ctx,
        ZERO_STRUCT(wkey);
        wkey.name = talloc_asprintf(mem_ctx, "%s\\%s\\Security", key, name);
        if (wkey.name == NULL) {
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
 
@@ -510,12 +506,12 @@ static bool svcctl_add_service(TALLOC_CTX *mem_ctx,
                                         &action,
                                         &result);
        if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0, ("eventlog_init_winreg_keys: Could not create key %s: %s\n",
+               DEBUG(0, ("svcctl_init_winreg_keys: Could not create key %s: %s\n",
                        wkey.name, nt_errstr(status)));
                goto done;
        }
        if (!W_ERROR_IS_OK(result)) {
-               DEBUG(0, ("eventlog_init_winreg_keys: Could not create key %s: %s\n",
+               DEBUG(0, ("svcctl_init_winreg_keys: Could not create key %s: %s\n",
                        wkey.name, win_errstr(result)));
                goto done;
        }
@@ -576,19 +572,6 @@ bool svcctl_init_winreg(struct messaging_context *msg_ctx)
                goto done;
        }
 
-       result = regdb_open();
-       if (!W_ERROR_IS_OK(result)) {
-               DEBUG(10, ("regdb_open failed: %s\n",
-                          win_errstr(result)));
-               goto done;
-       }
-       result = regdb_transaction_start();
-       if (!W_ERROR_IS_OK(result)) {
-               DEBUG(10, ("regdb_transaction_start failed: %s\n",
-                          win_errstr(result)));
-               goto done;
-       }
-
        status = dcerpc_winreg_int_hklm_openkey(tmp_ctx,
                                                get_session_info_system(),
                                                msg_ctx,
@@ -618,12 +601,12 @@ bool svcctl_init_winreg(struct messaging_context *msg_ctx)
                                         &subkeys,
                                         &result);
        if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(0, ("svcctl_init_winreg: Could enum keys at %s - %s\n",
+               DEBUG(0, ("svcctl_init_winreg: Could not enum keys at %s - %s\n",
                          key, nt_errstr(status)));
                goto done;
        }
        if (!W_ERROR_IS_OK(result)) {
-               DEBUG(0, ("svcctl_init_winreg: Could enum keys at %s - %s\n",
+               DEBUG(0, ("svcctl_init_winreg: Could not enum keys at %s - %s\n",
                          key, win_errstr(result)));
                goto done;
        }
@@ -688,20 +671,7 @@ done:
                dcerpc_winreg_CloseKey(h, tmp_ctx, &key_hnd, &result);
        }
 
-       if (ok) {
-               result = regdb_transaction_commit();
-               if (!W_ERROR_IS_OK(result)) {
-                       DEBUG(10, ("regdb_transaction_commit failed: %s\n",
-                                  win_errstr(result)));
-               }
-       } else {
-               result = regdb_transaction_cancel();
-               if (!W_ERROR_IS_OK(result)) {
-                       DEBUG(10, ("regdb_transaction_cancel failed: %s\n",
-                                  win_errstr(result)));
-               }
-       }
-       regdb_close();
+       talloc_free(tmp_ctx);
        return ok;
 }