use winreg_add_driver_package_internal in _winspool_AsyncInstallPrinterDriverFromPackage
authorGünther Deschner <gd@samba.org>
Fri, 20 Jan 2017 16:57:19 +0000 (17:57 +0100)
committerGünther Deschner <gd@samba.org>
Tue, 24 Oct 2023 13:36:30 +0000 (15:36 +0200)
source3/rpc_server/spoolss/srv_iremotewinspool_nt.c

index fe4453d01ecae13fc913be4b95e8d400401faf37..c154a1c93fce393fa6a205821eddd0100fe25ec2 100644 (file)
@@ -1025,6 +1025,30 @@ HRESULT _winspool_AsyncGetRemoteNotifications(struct pipes_struct *p,
  _winspool_AsyncInstallPrinterDriverFromPackage
 ****************************************************************/
 
+static WERROR get_package_id_from_inf_path(TALLOC_CTX *mem_ctx,
+                                          const char *pszInfPath,
+                                          const char **package_id)
+{
+       char *s, *p;
+
+       p = talloc_strdup(mem_ctx, pszInfPath);
+       if (p == NULL) {
+               return WERR_NOT_ENOUGH_MEMORY;
+       }
+
+       s = strrchr(p, '/');
+       if (s == NULL) {
+               return WERR_BAD_PATHNAME;
+       }
+
+       *s = '\0';
+       s++;
+
+       *package_id = s;
+
+       return WERR_OK;
+}
+
 static WERROR create_driver_package_path(TALLOC_CTX *mem_ctx,
                                         const char *pszInfPath,
                                         const char *pszEnvironment,
@@ -1141,6 +1165,7 @@ HRESULT _winspool_AsyncInstallPrinterDriverFromPackage(struct pipes_struct *p,
        struct dcesrv_call_state *dce_call = p->dce_call;
        struct auth_session_info *session_info =
                dcesrv_call_session_info(dce_call);
+       const char *package_id;
 
        ok = winspool_is_privileged_user(session_info);
        if (!ok) {
@@ -1176,6 +1201,25 @@ HRESULT _winspool_AsyncInstallPrinterDriverFromPackage(struct pipes_struct *p,
                return HRESULT_FROM_WERROR(result);
        }
 
+
+       result = get_package_id_from_inf_path(p->mem_ctx,
+                                             r->in.pszInfPath,
+                                             &package_id);
+       if (!W_ERROR_IS_OK(result)) {
+               return HRESULT_FROM_WERROR(result);
+       }
+
+       result = winreg_add_driver_package_internal(p->mem_ctx,
+                                                   get_session_info_system(),
+                                                   p->msg_ctx,
+                                                   package_id,
+                                                   r->in.pszEnvironment,
+                                                   r->in.pszInfPath,
+                                                   cabinet);
+       if (!W_ERROR_IS_OK(result)) {
+               return HRESULT_FROM_WERROR(result);
+       }
+
        result = winreg_add_driver_internal(p->mem_ctx,
                                            get_session_info_system(),
                                            p->msg_ctx,