LCOV - code coverage report
Current view: top level - source3/rpc_server/spoolss - srv_spoolss_util.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 103 391 26.3 %
Date: 2024-04-21 15:09:00 Functions: 13 28 46.4 %

          Line data    Source code
       1             : /*
       2             :  *  Unix SMB/CIFS implementation.
       3             :  *
       4             :  *  SPOOLSS RPC Pipe server / winreg client routines
       5             :  *
       6             :  *  Copyright (c) 2010      Andreas Schneider <asn@samba.org>
       7             :  *
       8             :  *  This program is free software; you can redistribute it and/or modify
       9             :  *  it under the terms of the GNU General Public License as published by
      10             :  *  the Free Software Foundation; either version 3 of the License, or
      11             :  *  (at your option) any later version.
      12             :  *
      13             :  *  This program is distributed in the hope that it will be useful,
      14             :  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
      15             :  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      16             :  *  GNU General Public License for more details.
      17             :  *
      18             :  *  You should have received a copy of the GNU General Public License
      19             :  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
      20             :  */
      21             : 
      22             : #include "includes.h"
      23             : #include "rpc_server/rpc_ncacn_np.h"
      24             : #include "../lib/tsocket/tsocket.h"
      25             : #include "../librpc/gen_ndr/ndr_spoolss.h"
      26             : #include "../librpc/gen_ndr/ndr_winreg.h"
      27             : #include "srv_spoolss_util.h"
      28             : #include "rpc_client/cli_winreg_spoolss.h"
      29             : 
      30       30116 : WERROR winreg_printer_binding_handle(TALLOC_CTX *mem_ctx,
      31             :                                      const struct auth_session_info *session_info,
      32             :                                      struct messaging_context *msg_ctx,
      33             :                                      struct dcerpc_binding_handle **winreg_binding_handle)
      34             : {
      35           0 :         struct tsocket_address *local;
      36           0 :         NTSTATUS status;
      37           0 :         int rc;
      38             : 
      39       30116 :         rc = tsocket_address_inet_from_strings(mem_ctx,
      40             :                                                "ip",
      41             :                                                "127.0.0.1",
      42             :                                                0,
      43             :                                                &local);
      44       30116 :         if (rc < 0) {
      45           0 :                 return WERR_NOT_ENOUGH_MEMORY;
      46             :         }
      47             : 
      48       30116 :         status = rpcint_binding_handle(mem_ctx,
      49             :                                        &ndr_table_winreg,
      50             :                                        local,
      51             :                                        NULL,
      52             :                                        session_info,
      53             :                                        msg_ctx,
      54             :                                        winreg_binding_handle);
      55       30116 :         talloc_free(local);
      56       30116 :         if (!NT_STATUS_IS_OK(status)) {
      57           0 :                 DEBUG(0, ("winreg_printer_binding_handle: Could not connect to winreg pipe: %s\n",
      58             :                           nt_errstr(status)));
      59           0 :                 return ntstatus_to_werror(status);
      60             :         }
      61             : 
      62       30116 :         return WERR_OK;
      63             : }
      64             : 
      65          32 : WERROR winreg_delete_printer_key_internal(TALLOC_CTX *mem_ctx,
      66             :                                           const struct auth_session_info *session_info,
      67             :                                           struct messaging_context *msg_ctx,
      68             :                                           const char *printer,
      69             :                                           const char *key)
      70             : {
      71           0 :         WERROR result;
      72           0 :         struct dcerpc_binding_handle *b;
      73           0 :         TALLOC_CTX *tmp_ctx;
      74             : 
      75          32 :         tmp_ctx = talloc_stackframe();
      76          32 :         if (tmp_ctx == NULL) {
      77           0 :                 return WERR_NOT_ENOUGH_MEMORY;
      78             :         }
      79             : 
      80          32 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
      81          32 :         if (!W_ERROR_IS_OK(result)) {
      82           0 :                 talloc_free(tmp_ctx);
      83           0 :                 return result;
      84             :         }
      85             : 
      86          32 :         result = winreg_delete_printer_key(tmp_ctx,
      87             :                                            b,
      88             :                                            printer,
      89             :                                            key);
      90             : 
      91          32 :         talloc_free(tmp_ctx);
      92          32 :         return result;
      93             : }
      94             : 
      95        1368 : WERROR winreg_printer_update_changeid_internal(TALLOC_CTX *mem_ctx,
      96             :                                                const struct auth_session_info *session_info,
      97             :                                                struct messaging_context *msg_ctx,
      98             :                                                const char *printer)
      99             : {
     100           0 :         WERROR result;
     101           0 :         struct dcerpc_binding_handle *b;
     102           0 :         TALLOC_CTX *tmp_ctx;
     103             : 
     104        1368 :         tmp_ctx = talloc_stackframe();
     105        1368 :         if (tmp_ctx == NULL) {
     106           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     107             :         }
     108             : 
     109        1368 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     110        1368 :         if (!W_ERROR_IS_OK(result)) {
     111           0 :                 talloc_free(tmp_ctx);
     112           0 :                 return result;
     113             :         }
     114             : 
     115        1368 :         result = winreg_printer_update_changeid(mem_ctx,
     116             :                                                 b,
     117             :                                                 printer);
     118             : 
     119        1368 :         talloc_free(tmp_ctx);
     120        1368 :         return result;
     121             : }
     122             : 
     123         276 : WERROR winreg_printer_get_changeid_internal(TALLOC_CTX *mem_ctx,
     124             :                                             const struct auth_session_info *session_info,
     125             :                                             struct messaging_context *msg_ctx,
     126             :                                             const char *printer,
     127             :                                             uint32_t *pchangeid)
     128             : {
     129           0 :         WERROR result;
     130           0 :         struct dcerpc_binding_handle *b;
     131           0 :         TALLOC_CTX *tmp_ctx;
     132             : 
     133         276 :         tmp_ctx = talloc_stackframe();
     134         276 :         if (tmp_ctx == NULL) {
     135           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     136             :         }
     137             : 
     138         276 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     139         276 :         if (!W_ERROR_IS_OK(result)) {
     140           0 :                 talloc_free(tmp_ctx);
     141           0 :                 return result;
     142             :         }
     143             : 
     144         276 :         result = winreg_printer_get_changeid(mem_ctx,
     145             :                                              b,
     146             :                                              printer,
     147             :                                              pchangeid);
     148             : 
     149         276 :         talloc_free(tmp_ctx);
     150         276 :         return result;
     151             : }
     152             : 
     153        8066 : WERROR winreg_get_printer_internal(TALLOC_CTX *mem_ctx,
     154             :                                    const struct auth_session_info *session_info,
     155             :                                    struct messaging_context *msg_ctx,
     156             :                                    const char *printer,
     157             :                                    struct spoolss_PrinterInfo2 **pinfo2)
     158             : {
     159           0 :         WERROR result;
     160           0 :         struct dcerpc_binding_handle *b;
     161           0 :         TALLOC_CTX *tmp_ctx;
     162             : 
     163        8066 :         tmp_ctx = talloc_stackframe();
     164        8066 :         if (tmp_ctx == NULL) {
     165           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     166             :         }
     167             : 
     168        8066 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     169        8066 :         if (!W_ERROR_IS_OK(result)) {
     170           0 :                 talloc_free(tmp_ctx);
     171           0 :                 return result;
     172             :         }
     173             : 
     174        8066 :         result = winreg_get_printer(mem_ctx,
     175             :                                     b,
     176             :                                     printer,
     177             :                                     pinfo2);
     178             : 
     179        8066 :         talloc_free(tmp_ctx);
     180        8066 :         return result;
     181             : }
     182             : 
     183         502 : WERROR winreg_create_printer_internal(TALLOC_CTX *mem_ctx,
     184             :                                       const struct auth_session_info *session_info,
     185             :                                       struct messaging_context *msg_ctx,
     186             :                                       const char *sharename)
     187             : {
     188           0 :         WERROR result;
     189           0 :         struct dcerpc_binding_handle *b;
     190           0 :         TALLOC_CTX *tmp_ctx;
     191             : 
     192         502 :         tmp_ctx = talloc_stackframe();
     193         502 :         if (tmp_ctx == NULL) {
     194           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     195             :         }
     196             : 
     197         502 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     198         502 :         if (!W_ERROR_IS_OK(result)) {
     199           0 :                 talloc_free(tmp_ctx);
     200           0 :                 return result;
     201             :         }
     202             : 
     203         502 :         result = winreg_create_printer(mem_ctx,
     204             :                                        b,
     205             :                                        sharename);
     206             : 
     207         502 :         talloc_free(tmp_ctx);
     208         502 :         return result;
     209             : }
     210             : 
     211         312 : WERROR winreg_update_printer_internal(TALLOC_CTX *mem_ctx,
     212             :                                       const struct auth_session_info *session_info,
     213             :                                       struct messaging_context *msg_ctx,
     214             :                                       const char *sharename,
     215             :                                       uint32_t info2_mask,
     216             :                                       struct spoolss_SetPrinterInfo2 *info2,
     217             :                                       struct spoolss_DeviceMode *devmode,
     218             :                                       struct security_descriptor *secdesc)
     219             : {
     220           0 :         WERROR result;
     221           0 :         struct dcerpc_binding_handle *b;
     222           0 :         TALLOC_CTX *tmp_ctx;
     223             : 
     224         312 :         tmp_ctx = talloc_stackframe();
     225         312 :         if (tmp_ctx == NULL) {
     226           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     227             :         }
     228             : 
     229         312 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     230         312 :         if (!W_ERROR_IS_OK(result)) {
     231           0 :                 talloc_free(tmp_ctx);
     232           0 :                 return result;
     233             :         }
     234             : 
     235         312 :         result = winreg_update_printer(mem_ctx,
     236             :                                        b,
     237             :                                        sharename,
     238             :                                        info2_mask,
     239             :                                        info2,
     240             :                                        devmode,
     241             :                                        secdesc);
     242             : 
     243         312 :         talloc_free(tmp_ctx);
     244         312 :         return result;
     245             : }
     246             : 
     247           0 : WERROR winreg_set_printer_dataex_internal(TALLOC_CTX *mem_ctx,
     248             :                                           const struct auth_session_info *session_info,
     249             :                                           struct messaging_context *msg_ctx,
     250             :                                           const char *printer,
     251             :                                           const char *key,
     252             :                                           const char *value,
     253             :                                           enum winreg_Type type,
     254             :                                           uint8_t *data,
     255             :                                           uint32_t data_size)
     256             : {
     257           0 :         WERROR result;
     258           0 :         struct dcerpc_binding_handle *b;
     259           0 :         TALLOC_CTX *tmp_ctx;
     260             : 
     261           0 :         tmp_ctx = talloc_stackframe();
     262           0 :         if (tmp_ctx == NULL) {
     263           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     264             :         }
     265             : 
     266           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     267           0 :         if (!W_ERROR_IS_OK(result)) {
     268           0 :                 talloc_free(tmp_ctx);
     269           0 :                 return result;
     270             :         }
     271             : 
     272           0 :         result = winreg_set_printer_dataex(mem_ctx,
     273             :                                            b,
     274             :                                            printer,
     275             :                                            key,
     276             :                                            value,
     277             :                                            type,
     278             :                                            data,
     279             :                                            data_size);
     280             : 
     281           0 :         talloc_free(tmp_ctx);
     282           0 :         return result;
     283             : }
     284             : 
     285        2856 : WERROR winreg_enum_printer_dataex_internal(TALLOC_CTX *mem_ctx,
     286             :                                            const struct auth_session_info *session_info,
     287             :                                            struct messaging_context *msg_ctx,
     288             :                                            const char *printer,
     289             :                                            const char *key,
     290             :                                            uint32_t *pnum_values,
     291             :                                            struct spoolss_PrinterEnumValues **penum_values)
     292             : {
     293           0 :         WERROR result;
     294           0 :         struct dcerpc_binding_handle *b;
     295           0 :         TALLOC_CTX *tmp_ctx;
     296             : 
     297        2856 :         tmp_ctx = talloc_stackframe();
     298        2856 :         if (tmp_ctx == NULL) {
     299           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     300             :         }
     301             : 
     302        2856 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     303        2856 :         if (!W_ERROR_IS_OK(result)) {
     304           0 :                 talloc_free(tmp_ctx);
     305           0 :                 return result;
     306             :         }
     307             : 
     308        2856 :         result = winreg_enum_printer_dataex(mem_ctx,
     309             :                                             b,
     310             :                                             printer,
     311             :                                             key,
     312             :                                             pnum_values,
     313             :                                             penum_values);
     314             : 
     315        2856 :         talloc_free(tmp_ctx);
     316        2856 :         return result;
     317             : }
     318             : 
     319           0 : WERROR winreg_get_printer_dataex_internal(TALLOC_CTX *mem_ctx,
     320             :                                           const struct auth_session_info *session_info,
     321             :                                           struct messaging_context *msg_ctx,
     322             :                                           const char *printer,
     323             :                                           const char *key,
     324             :                                           const char *value,
     325             :                                           enum winreg_Type *type,
     326             :                                           uint8_t **data,
     327             :                                           uint32_t *data_size)
     328             : {
     329           0 :         WERROR result;
     330           0 :         struct dcerpc_binding_handle *b;
     331           0 :         TALLOC_CTX *tmp_ctx;
     332             : 
     333           0 :         tmp_ctx = talloc_stackframe();
     334           0 :         if (tmp_ctx == NULL) {
     335           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     336             :         }
     337             : 
     338           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     339           0 :         if (!W_ERROR_IS_OK(result)) {
     340           0 :                 talloc_free(tmp_ctx);
     341           0 :                 return result;
     342             :         }
     343             : 
     344           0 :         result = winreg_get_printer_dataex(mem_ctx,
     345             :                                            b,
     346             :                                            printer,
     347             :                                            key,
     348             :                                            value,
     349             :                                            type,
     350             :                                            data,
     351             :                                            data_size);
     352             : 
     353           0 :         talloc_free(tmp_ctx);
     354           0 :         return result;
     355             : }
     356             : 
     357        1368 : WERROR winreg_delete_printer_dataex_internal(TALLOC_CTX *mem_ctx,
     358             :                                              const struct auth_session_info *session_info,
     359             :                                              struct messaging_context *msg_ctx,
     360             :                                              const char *printer,
     361             :                                              const char *key,
     362             :                                              const char *value)
     363             : {
     364           0 :         WERROR result;
     365           0 :         struct dcerpc_binding_handle *b;
     366           0 :         TALLOC_CTX *tmp_ctx;
     367             : 
     368        1368 :         tmp_ctx = talloc_stackframe();
     369        1368 :         if (tmp_ctx == NULL) {
     370           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     371             :         }
     372             : 
     373        1368 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     374        1368 :         if (!W_ERROR_IS_OK(result)) {
     375           0 :                 talloc_free(tmp_ctx);
     376           0 :                 return result;
     377             :         }
     378             : 
     379        1368 :         result = winreg_delete_printer_dataex(mem_ctx,
     380             :                                               b,
     381             :                                               printer,
     382             :                                               key,
     383             :                                               value);
     384             : 
     385        1368 :         talloc_free(tmp_ctx);
     386        1368 :         return result;
     387             : }
     388             : 
     389           0 : WERROR winreg_get_driver_internal(TALLOC_CTX *mem_ctx,
     390             :                                   const struct auth_session_info *session_info,
     391             :                                   struct messaging_context *msg_ctx,
     392             :                                   const char *architecture,
     393             :                                   const char *driver_name,
     394             :                                   uint32_t driver_version,
     395             :                                   struct spoolss_DriverInfo8 **_info8)
     396             : {
     397           0 :         WERROR result;
     398           0 :         struct dcerpc_binding_handle *b;
     399           0 :         TALLOC_CTX *tmp_ctx;
     400             : 
     401           0 :         tmp_ctx = talloc_stackframe();
     402           0 :         if (tmp_ctx == NULL) {
     403           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     404             :         }
     405             : 
     406           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     407           0 :         if (!W_ERROR_IS_OK(result)) {
     408           0 :                 talloc_free(tmp_ctx);
     409           0 :                 return result;
     410             :         }
     411             : 
     412           0 :         result = winreg_get_driver(mem_ctx,
     413             :                                    b,
     414             :                                    architecture,
     415             :                                    driver_name,
     416             :                                    driver_version,
     417             :                                    _info8);
     418             : 
     419           0 :         talloc_free(tmp_ctx);
     420           0 :         return result;
     421             : }
     422             : 
     423           0 : WERROR winreg_get_driver_list_internal(TALLOC_CTX *mem_ctx,
     424             :                                        const struct auth_session_info *session_info,
     425             :                                        struct messaging_context *msg_ctx,
     426             :                                        const char *architecture,
     427             :                                        uint32_t version,
     428             :                                        uint32_t *num_drivers,
     429             :                                        const char ***drivers_p)
     430             : {
     431           0 :         WERROR result;
     432           0 :         struct dcerpc_binding_handle *b;
     433           0 :         TALLOC_CTX *tmp_ctx;
     434             : 
     435           0 :         tmp_ctx = talloc_stackframe();
     436           0 :         if (tmp_ctx == NULL) {
     437           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     438             :         }
     439             : 
     440           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     441           0 :         if (!W_ERROR_IS_OK(result)) {
     442           0 :                 talloc_free(tmp_ctx);
     443           0 :                 return result;
     444             :         }
     445             : 
     446           0 :         result = winreg_get_driver_list(mem_ctx,
     447             :                                         b,
     448             :                                         architecture,
     449             :                                         version,
     450             :                                         num_drivers,
     451             :                                         drivers_p);
     452             : 
     453           0 :         talloc_free(tmp_ctx);
     454           0 :         return result;
     455             : }
     456             : 
     457           0 : WERROR winreg_del_driver_internal(TALLOC_CTX *mem_ctx,
     458             :                                   const struct auth_session_info *session_info,
     459             :                                   struct messaging_context *msg_ctx,
     460             :                                   struct spoolss_DriverInfo8 *info8,
     461             :                                   uint32_t version)
     462             : {
     463           0 :         WERROR result;
     464           0 :         struct dcerpc_binding_handle *b;
     465           0 :         TALLOC_CTX *tmp_ctx;
     466             : 
     467           0 :         tmp_ctx = talloc_stackframe();
     468           0 :         if (tmp_ctx == NULL) {
     469           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     470             :         }
     471             : 
     472           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     473           0 :         if (!W_ERROR_IS_OK(result)) {
     474           0 :                 talloc_free(tmp_ctx);
     475           0 :                 return result;
     476             :         }
     477             : 
     478           0 :         result = winreg_del_driver(mem_ctx,
     479             :                                    b,
     480             :                                    info8,
     481             :                                    version);
     482             : 
     483           0 :         talloc_free(tmp_ctx);
     484           0 :         return result;
     485             : }
     486             : 
     487           0 : WERROR winreg_add_driver_internal(TALLOC_CTX *mem_ctx,
     488             :                                   const struct auth_session_info *session_info,
     489             :                                   struct messaging_context *msg_ctx,
     490             :                                   struct spoolss_AddDriverInfoCtr *r,
     491             :                                   const char **driver_name,
     492             :                                   uint32_t *driver_version)
     493             : {
     494           0 :         WERROR result;
     495           0 :         struct dcerpc_binding_handle *b;
     496           0 :         TALLOC_CTX *tmp_ctx;
     497             : 
     498           0 :         tmp_ctx = talloc_stackframe();
     499           0 :         if (tmp_ctx == NULL) {
     500           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     501             :         }
     502             : 
     503           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     504           0 :         if (!W_ERROR_IS_OK(result)) {
     505           0 :                 talloc_free(tmp_ctx);
     506           0 :                 return result;
     507             :         }
     508             : 
     509           0 :         result = winreg_add_driver(mem_ctx,
     510             :                                    b,
     511             :                                    r,
     512             :                                    driver_name,
     513             :                                    driver_version);
     514             : 
     515           0 :         talloc_free(tmp_ctx);
     516           0 :         return result;
     517             : }
     518             : 
     519           0 : WERROR winreg_get_core_driver_internal(TALLOC_CTX *mem_ctx,
     520             :                                        const struct auth_session_info *session_info,
     521             :                                        struct messaging_context *msg_ctx,
     522             :                                        const char *architecture,
     523             :                                        const struct GUID *core_driver_guid,
     524             :                                        struct spoolss_CorePrinterDriver **core_printer_driver)
     525             : {
     526           0 :         WERROR result;
     527           0 :         struct dcerpc_binding_handle *b;
     528           0 :         TALLOC_CTX *tmp_ctx;
     529             : 
     530           0 :         tmp_ctx = talloc_stackframe();
     531           0 :         if (tmp_ctx == NULL) {
     532           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     533             :         }
     534             : 
     535           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     536           0 :         if (!W_ERROR_IS_OK(result)) {
     537           0 :                 talloc_free(tmp_ctx);
     538           0 :                 return result;
     539             :         }
     540             : 
     541           0 :         result = winreg_get_core_driver(mem_ctx,
     542             :                                         b,
     543             :                                         architecture,
     544             :                                         core_driver_guid,
     545             :                                         core_printer_driver);
     546             : 
     547           0 :         talloc_free(tmp_ctx);
     548           0 :         return result;
     549             : }
     550             : 
     551           0 : WERROR winreg_add_core_driver_internal(TALLOC_CTX *mem_ctx,
     552             :                                        const struct auth_session_info *session_info,
     553             :                                        struct messaging_context *msg_ctx,
     554             :                                        const char *architecture,
     555             :                                        const struct spoolss_CorePrinterDriver *core_printer_driver)
     556             : {
     557           0 :         WERROR result;
     558           0 :         struct dcerpc_binding_handle *b;
     559           0 :         TALLOC_CTX *tmp_ctx;
     560             : 
     561           0 :         tmp_ctx = talloc_stackframe();
     562           0 :         if (tmp_ctx == NULL) {
     563           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     564             :         }
     565             : 
     566           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     567           0 :         if (!W_ERROR_IS_OK(result)) {
     568           0 :                 talloc_free(tmp_ctx);
     569           0 :                 return result;
     570             :         }
     571             : 
     572           0 :         result = winreg_add_core_driver(mem_ctx,
     573             :                                         b,
     574             :                                         architecture,
     575             :                                         core_printer_driver);
     576             : 
     577           0 :         talloc_free(tmp_ctx);
     578           0 :         return result;
     579             : }
     580             : 
     581           0 : WERROR winreg_add_driver_package_internal(TALLOC_CTX *mem_ctx,
     582             :                                           const struct auth_session_info *session_info,
     583             :                                           struct messaging_context *msg_ctx,
     584             :                                           const char *package_id,
     585             :                                           const char *architecture,
     586             :                                           const char *driver_store_path,
     587             :                                           const char *cab_path)
     588             : {
     589           0 :         WERROR result;
     590           0 :         struct dcerpc_binding_handle *b;
     591           0 :         TALLOC_CTX *tmp_ctx;
     592             : 
     593           0 :         tmp_ctx = talloc_stackframe();
     594           0 :         if (tmp_ctx == NULL) {
     595           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     596             :         }
     597             : 
     598           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     599           0 :         if (!W_ERROR_IS_OK(result)) {
     600           0 :                 talloc_free(tmp_ctx);
     601           0 :                 return result;
     602             :         }
     603             : 
     604           0 :         result = winreg_add_driver_package(mem_ctx,
     605             :                                            b,
     606             :                                            package_id,
     607             :                                            architecture,
     608             :                                            driver_store_path,
     609             :                                            cab_path);
     610             : 
     611           0 :         talloc_free(tmp_ctx);
     612           0 :         return result;
     613             : }
     614             : 
     615           0 : WERROR winreg_get_driver_package_internal(TALLOC_CTX *mem_ctx,
     616             :                                           const struct auth_session_info *session_info,
     617             :                                           struct messaging_context *msg_ctx,
     618             :                                           const char *package_id,
     619             :                                           const char *architecture,
     620             :                                           const char **driver_store_path,
     621             :                                           const char **cab_path)
     622             : {
     623           0 :         WERROR result;
     624           0 :         struct dcerpc_binding_handle *b;
     625           0 :         TALLOC_CTX *tmp_ctx;
     626             : 
     627           0 :         tmp_ctx = talloc_stackframe();
     628           0 :         if (tmp_ctx == NULL) {
     629           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     630             :         }
     631             : 
     632           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     633           0 :         if (!W_ERROR_IS_OK(result)) {
     634           0 :                 talloc_free(tmp_ctx);
     635           0 :                 return result;
     636             :         }
     637             : 
     638           0 :         result = winreg_get_driver_package(mem_ctx,
     639             :                                            b,
     640             :                                            package_id,
     641             :                                            architecture,
     642             :                                            driver_store_path,
     643             :                                            cab_path);
     644             : 
     645           0 :         talloc_free(tmp_ctx);
     646           0 :         return result;
     647             : }
     648             : 
     649           0 : WERROR winreg_del_driver_package_internal(TALLOC_CTX *mem_ctx,
     650             :                                           const struct auth_session_info *session_info,
     651             :                                           struct messaging_context *msg_ctx,
     652             :                                           const char *package_id,
     653             :                                           const char *architecture)
     654             : {
     655           0 :         WERROR result;
     656           0 :         struct dcerpc_binding_handle *b;
     657           0 :         TALLOC_CTX *tmp_ctx;
     658             : 
     659           0 :         tmp_ctx = talloc_stackframe();
     660           0 :         if (tmp_ctx == NULL) {
     661           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     662             :         }
     663             : 
     664           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     665           0 :         if (!W_ERROR_IS_OK(result)) {
     666           0 :                 talloc_free(tmp_ctx);
     667           0 :                 return result;
     668             :         }
     669             : 
     670           0 :         result = winreg_del_driver_package(mem_ctx,
     671             :                                            b,
     672             :                                            package_id,
     673             :                                            architecture);
     674             : 
     675           0 :         talloc_free(tmp_ctx);
     676           0 :         return result;
     677             : }
     678             : 
     679           4 : WERROR winreg_get_printer_secdesc_internal(TALLOC_CTX *mem_ctx,
     680             :                                            const struct auth_session_info *session_info,
     681             :                                            struct messaging_context *msg_ctx,
     682             :                                            const char *sharename,
     683             :                                            struct spoolss_security_descriptor **psecdesc)
     684             : {
     685           0 :         WERROR result;
     686           0 :         struct dcerpc_binding_handle *b;
     687           0 :         TALLOC_CTX *tmp_ctx;
     688             : 
     689           4 :         tmp_ctx = talloc_stackframe();
     690           4 :         if (tmp_ctx == NULL) {
     691           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     692             :         }
     693             : 
     694           4 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     695           4 :         if (!W_ERROR_IS_OK(result)) {
     696           0 :                 talloc_free(tmp_ctx);
     697           0 :                 return result;
     698             :         }
     699             : 
     700           4 :         result = winreg_get_printer_secdesc(mem_ctx,
     701             :                                             b,
     702             :                                             sharename,
     703             :                                             psecdesc);
     704             : 
     705           4 :         talloc_free(tmp_ctx);
     706           4 :         return result;
     707             : }
     708             : 
     709           0 : WERROR winreg_set_printer_secdesc_internal(TALLOC_CTX *mem_ctx,
     710             :                                            const struct auth_session_info *session_info,
     711             :                                            struct messaging_context *msg_ctx,
     712             :                                            const char *sharename,
     713             :                                            const struct spoolss_security_descriptor *secdesc)
     714             : {
     715           0 :         WERROR result;
     716           0 :         struct dcerpc_binding_handle *b;
     717           0 :         TALLOC_CTX *tmp_ctx;
     718             : 
     719           0 :         tmp_ctx = talloc_stackframe();
     720           0 :         if (tmp_ctx == NULL) {
     721           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     722             :         }
     723             : 
     724           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     725           0 :         if (!W_ERROR_IS_OK(result)) {
     726           0 :                 talloc_free(tmp_ctx);
     727           0 :                 return result;
     728             :         }
     729             : 
     730           0 :         result = winreg_set_printer_secdesc(mem_ctx,
     731             :                                             b,
     732             :                                             sharename,
     733             :                                             secdesc);
     734             : 
     735           0 :         talloc_free(tmp_ctx);
     736           0 :         return result;
     737             : }
     738             : 
     739         536 : WERROR winreg_printer_enumforms1_internal(TALLOC_CTX *mem_ctx,
     740             :                                           const struct auth_session_info *session_info,
     741             :                                           struct messaging_context *msg_ctx,
     742             :                                           uint32_t *pnum_info,
     743             :                                           union spoolss_FormInfo **pinfo)
     744             : {
     745           0 :         WERROR result;
     746           0 :         struct dcerpc_binding_handle *b;
     747           0 :         TALLOC_CTX *tmp_ctx;
     748             : 
     749         536 :         tmp_ctx = talloc_stackframe();
     750         536 :         if (tmp_ctx == NULL) {
     751           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     752             :         }
     753             : 
     754         536 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     755         536 :         if (!W_ERROR_IS_OK(result)) {
     756           0 :                 talloc_free(tmp_ctx);
     757           0 :                 return result;
     758             :         }
     759             : 
     760         536 :         result = winreg_printer_enumforms1(mem_ctx,
     761             :                                            b,
     762             :                                            pnum_info,
     763             :                                            pinfo);
     764             : 
     765         536 :         talloc_free(tmp_ctx);
     766         536 :         return result;
     767             : }
     768             : 
     769        5040 : WERROR winreg_printer_getform1_internal(TALLOC_CTX *mem_ctx,
     770             :                                         const struct auth_session_info *session_info,
     771             :                                         struct messaging_context *msg_ctx,
     772             :                                         const char *form_name,
     773             :                                         struct spoolss_FormInfo1 *r)
     774             : {
     775           0 :         WERROR result;
     776           0 :         struct dcerpc_binding_handle *b;
     777           0 :         TALLOC_CTX *tmp_ctx;
     778             : 
     779        5040 :         tmp_ctx = talloc_stackframe();
     780        5040 :         if (tmp_ctx == NULL) {
     781           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     782             :         }
     783             : 
     784        5040 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     785        5040 :         if (!W_ERROR_IS_OK(result)) {
     786           0 :                 talloc_free(tmp_ctx);
     787           0 :                 return result;
     788             :         }
     789             : 
     790        5040 :         result = winreg_printer_getform1(mem_ctx,
     791             :                                          b,
     792             :                                          form_name,
     793             :                                          r);
     794             : 
     795        5040 :         talloc_free(tmp_ctx);
     796        5040 :         return result;
     797             : }
     798             : 
     799           0 : WERROR winreg_printer_addform1_internal(TALLOC_CTX *mem_ctx,
     800             :                                         const struct auth_session_info *session_info,
     801             :                                         struct messaging_context *msg_ctx,
     802             :                                         struct spoolss_AddFormInfo1 *form)
     803             : {
     804           0 :         WERROR result;
     805           0 :         struct dcerpc_binding_handle *b;
     806           0 :         TALLOC_CTX *tmp_ctx;
     807             : 
     808           0 :         tmp_ctx = talloc_stackframe();
     809           0 :         if (tmp_ctx == NULL) {
     810           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     811             :         }
     812             : 
     813           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     814           0 :         if (!W_ERROR_IS_OK(result)) {
     815           0 :                 talloc_free(tmp_ctx);
     816           0 :                 return result;
     817             :         }
     818             : 
     819           0 :         result = winreg_printer_addform1(mem_ctx,
     820             :                                          b,
     821             :                                          form);
     822             : 
     823           0 :         talloc_free(tmp_ctx);
     824           0 :         return result;
     825             : }
     826             : 
     827           0 : WERROR winreg_printer_setform1_internal(TALLOC_CTX *mem_ctx,
     828             :                                         const struct auth_session_info *session_info,
     829             :                                         struct messaging_context *msg_ctx,
     830             :                                         const char *form_name,
     831             :                                         struct spoolss_AddFormInfo1 *form)
     832             : {
     833           0 :         WERROR result;
     834           0 :         struct dcerpc_binding_handle *b;
     835           0 :         TALLOC_CTX *tmp_ctx;
     836             : 
     837           0 :         tmp_ctx = talloc_stackframe();
     838           0 :         if (tmp_ctx == NULL) {
     839           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     840             :         }
     841             : 
     842           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     843           0 :         if (!W_ERROR_IS_OK(result)) {
     844           0 :                 talloc_free(tmp_ctx);
     845           0 :                 return result;
     846             :         }
     847             : 
     848           0 :         result = winreg_printer_setform1(mem_ctx,
     849             :                                          b,
     850             :                                          form_name,
     851             :                                          form);
     852             : 
     853           0 :         talloc_free(tmp_ctx);
     854           0 :         return result;
     855             : }
     856             : 
     857           0 : WERROR winreg_printer_deleteform1_internal(TALLOC_CTX *mem_ctx,
     858             :                                            const struct auth_session_info *session_info,
     859             :                                            struct messaging_context *msg_ctx,
     860             :                                            const char *form_name)
     861             : {
     862           0 :         WERROR result;
     863           0 :         struct dcerpc_binding_handle *b;
     864           0 :         TALLOC_CTX *tmp_ctx;
     865             : 
     866           0 :         tmp_ctx = talloc_stackframe();
     867           0 :         if (tmp_ctx == NULL) {
     868           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     869             :         }
     870             : 
     871           0 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     872           0 :         if (!W_ERROR_IS_OK(result)) {
     873           0 :                 talloc_free(tmp_ctx);
     874           0 :                 return result;
     875             :         }
     876             : 
     877           0 :         result = winreg_printer_deleteform1(mem_ctx,
     878             :                                             b,
     879             :                                             form_name);
     880             : 
     881           0 :         talloc_free(tmp_ctx);
     882           0 :         return result;
     883             : }
     884             : 
     885        3384 : WERROR winreg_enum_printer_key_internal(TALLOC_CTX *mem_ctx,
     886             :                                         const struct auth_session_info *session_info,
     887             :                                         struct messaging_context *msg_ctx,
     888             :                                         const char *printer,
     889             :                                         const char *key,
     890             :                                         uint32_t *pnum_subkeys,
     891             :                                         const char ***psubkeys)
     892             : {
     893           0 :         WERROR result;
     894           0 :         struct dcerpc_binding_handle *b;
     895           0 :         TALLOC_CTX *tmp_ctx;
     896             : 
     897        3384 :         tmp_ctx = talloc_stackframe();
     898        3384 :         if (tmp_ctx == NULL) {
     899           0 :                 return WERR_NOT_ENOUGH_MEMORY;
     900             :         }
     901             : 
     902        3384 :         result = winreg_printer_binding_handle(tmp_ctx, session_info, msg_ctx, &b);
     903        3384 :         if (!W_ERROR_IS_OK(result)) {
     904           0 :                 talloc_free(tmp_ctx);
     905           0 :                 return result;
     906             :         }
     907             : 
     908        3384 :         result = winreg_enum_printer_key(mem_ctx,
     909             :                                          b,
     910             :                                          printer,
     911             :                                          key,
     912             :                                          pnum_subkeys,
     913             :                                          psubkeys);
     914             : 
     915        3384 :         talloc_free(tmp_ctx);
     916        3384 :         return result;
     917             : }

Generated by: LCOV version 1.14