Ignore:
Timestamp:
Nov 29, 2012, 1:59:04 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/rpc_server/spoolss/srv_spoolss_nt.c

    r745 r751  
    296296        if (prn_hnd->notify.cli_chan) {
    297297                prn_hnd->notify.cli_chan->active_connections--;
     298                prn_hnd->notify.cli_chan = NULL;
    298299        }
    299300}
     
    20422043};
    20432044
     2045static const int drv_cversion[] = {SPOOLSS_DRIVER_VERSION_9X,
     2046                                   SPOOLSS_DRIVER_VERSION_NT35,
     2047                                   SPOOLSS_DRIVER_VERSION_NT4,
     2048                                   SPOOLSS_DRIVER_VERSION_200X,
     2049                                   -1};
     2050
    20442051static int get_version_id(const char *arch)
    20452052{
     
    20642071
    20652072        struct spoolss_DriverInfo8 *info = NULL;
    2066         struct spoolss_DriverInfo8 *info_win2k = NULL;
    20672073        int                             version;
    20682074        WERROR                          status;
    20692075        struct dcerpc_binding_handle *b;
     2076        TALLOC_CTX *tmp_ctx = NULL;
     2077        int i;
     2078        bool found;
    20702079
    20712080        /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
     
    20892098                return WERR_INVALID_ENVIRONMENT;
    20902099
    2091         status = winreg_printer_binding_handle(p->mem_ctx,
     2100        tmp_ctx = talloc_new(p->mem_ctx);
     2101        if (!tmp_ctx) {
     2102                return WERR_NOMEM;
     2103        }
     2104
     2105        status = winreg_printer_binding_handle(tmp_ctx,
    20922106                                               get_session_info_system(),
    20932107                                               p->msg_ctx,
    20942108                                               &b);
    20952109        if (!W_ERROR_IS_OK(status)) {
    2096                 return status;
    2097         }
    2098 
    2099         status = winreg_get_driver(p->mem_ctx, b,
    2100                                    r->in.architecture, r->in.driver,
    2101                                    version, &info);
    2102         if (!W_ERROR_IS_OK(status)) {
    2103                 /* try for Win2k driver if "Windows NT x86" */
    2104 
    2105                 if ( version == 2 ) {
    2106                         version = 3;
    2107 
    2108                         status = winreg_get_driver(p->mem_ctx, b,
    2109                                                    r->in.architecture,
    2110                                                    r->in.driver,
    2111                                                    version, &info);
    2112                         if (!W_ERROR_IS_OK(status)) {
    2113                                 status = WERR_UNKNOWN_PRINTER_DRIVER;
    2114                                 goto done;
    2115                         }
    2116                 }
    2117                 /* otherwise it was a failure */
    2118                 else {
    2119                         status = WERR_UNKNOWN_PRINTER_DRIVER;
     2110                goto done;
     2111        }
     2112
     2113        for (found = false, i = 0; drv_cversion[i] >= 0; i++) {
     2114                status = winreg_get_driver(tmp_ctx, b,
     2115                                           r->in.architecture, r->in.driver,
     2116                                           drv_cversion[i], &info);
     2117                if (!W_ERROR_IS_OK(status)) {
     2118                        DEBUG(5, ("skipping del of driver with version %d\n",
     2119                                  drv_cversion[i]));
     2120                        continue;
     2121                }
     2122                found = true;
     2123
     2124                if (printer_driver_in_use(tmp_ctx, get_session_info_system(),
     2125                                          p->msg_ctx, info)) {
     2126                        status = WERR_PRINTER_DRIVER_IN_USE;
    21202127                        goto done;
    21212128                }
    21222129
    2123         }
    2124 
    2125         if (printer_driver_in_use(p->mem_ctx,
    2126                                   get_session_info_system(),
    2127                                   p->msg_ctx,
    2128                                   info)) {
     2130                status = winreg_del_driver(tmp_ctx, b, info, drv_cversion[i]);
     2131                if (!W_ERROR_IS_OK(status)) {
     2132                        DEBUG(0, ("failed del of driver with version %d\n",
     2133                                  drv_cversion[i]));
     2134                        goto done;
     2135                }
     2136        }
     2137        if (found == false) {
     2138                DEBUG(0, ("driver %s not found for deletion\n", r->in.driver));
     2139                status = WERR_UNKNOWN_PRINTER_DRIVER;
     2140        } else {
     2141                status = WERR_OK;
     2142        }
     2143
     2144done:
     2145        talloc_free(tmp_ctx);
     2146        return status;
     2147}
     2148
     2149static WERROR spoolss_dpd_version(TALLOC_CTX *mem_ctx,
     2150                                  struct pipes_struct *p,
     2151                                  struct spoolss_DeletePrinterDriverEx *r,
     2152                                  struct dcerpc_binding_handle *b,
     2153                                  struct spoolss_DriverInfo8 *info)
     2154{
     2155        WERROR status;
     2156        bool delete_files;
     2157
     2158        if (printer_driver_in_use(mem_ctx, get_session_info_system(),
     2159                                  p->msg_ctx, info)) {
    21292160                status = WERR_PRINTER_DRIVER_IN_USE;
    21302161                goto done;
    21312162        }
    21322163
    2133         if (version == 2) {
    2134                 status = winreg_get_driver(p->mem_ctx, b,
    2135                                            r->in.architecture,
    2136                                            r->in.driver, 3, &info_win2k);
    2137                 if (W_ERROR_IS_OK(status)) {
    2138                         /* if we get to here, we now have 2 driver info structures to remove */
    2139                         /* remove the Win2k driver first*/
    2140 
    2141                         status = winreg_del_driver(p->mem_ctx, b,
    2142                                                    info_win2k, 3);
    2143                         talloc_free(info_win2k);
    2144 
    2145                         /* this should not have failed---if it did, report to client */
    2146                         if (!W_ERROR_IS_OK(status)) {
    2147                                 goto done;
    2148                         }
    2149                 }
    2150         }
    2151 
    2152         status = winreg_del_driver(p->mem_ctx, b,
    2153                                    info, version);
     2164        /*
     2165         * we have a couple of cases to consider.
     2166         * (1) Are any files in use?  If so and DPD_DELETE_ALL_FILES is set,
     2167         *     then the delete should fail if **any** files overlap with
     2168         *     other drivers
     2169         * (2) If DPD_DELETE_UNUSED_FILES is set, then delete all
     2170         *     non-overlapping files
     2171         * (3) If neither DPD_DELETE_ALL_FILES nor DPD_DELETE_UNUSED_FILES
     2172         *     is set, then do not delete any files
     2173         * Refer to MSDN docs on DeletePrinterDriverEx() for details.
     2174         */
     2175
     2176        delete_files = r->in.delete_flags
     2177                        & (DPD_DELETE_ALL_FILES | DPD_DELETE_UNUSED_FILES);
     2178
     2179        if (delete_files) {
     2180                bool in_use = printer_driver_files_in_use(mem_ctx,
     2181                                                get_session_info_system(),
     2182                                                          p->msg_ctx,
     2183                                                          info);
     2184                if (in_use && (r->in.delete_flags & DPD_DELETE_ALL_FILES)) {
     2185                        status = WERR_PRINTER_DRIVER_IN_USE;
     2186                        goto done;
     2187                }
     2188                /*
     2189                 * printer_driver_files_in_use() has trimmed overlapping files
     2190                 * from info so they are not removed on DPD_DELETE_UNUSED_FILES
     2191                 */
     2192        }
     2193
     2194        status = winreg_del_driver(mem_ctx, b, info, info->version);
     2195        if (!W_ERROR_IS_OK(status)) {
     2196                goto done;
     2197        }
     2198
     2199        /*
     2200         * now delete any associated files if delete_files is
     2201         * true. Even if this part failes, we return succes
     2202         * because the driver doesn not exist any more
     2203         */
     2204        if (delete_files) {
     2205                delete_driver_files(get_session_info_system(), info);
     2206        }
    21542207
    21552208done:
    2156         talloc_free(info);
    2157 
    21582209        return status;
    21592210}
     
    21662217                                      struct spoolss_DeletePrinterDriverEx *r)
    21672218{
    2168         struct spoolss_DriverInfo8      *info = NULL;
    2169         struct spoolss_DriverInfo8      *info_win2k = NULL;
    2170         int                             version;
    2171         bool                            delete_files;
     2219        struct spoolss_DriverInfo8 *info = NULL;
    21722220        WERROR                          status;
    21732221        struct dcerpc_binding_handle *b;
     2222        TALLOC_CTX *tmp_ctx = NULL;
     2223        int i;
     2224        bool found;
    21742225
    21752226        /* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
     
    21882239
    21892240        /* check that we have a valid driver name first */
    2190         if ((version = get_version_id(r->in.architecture)) == -1) {
     2241        if (get_version_id(r->in.architecture) == -1) {
    21912242                /* this is what NT returns */
    21922243                return WERR_INVALID_ENVIRONMENT;
    21932244        }
    21942245
    2195         if (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION)
    2196                 version = r->in.version;
    2197 
    2198         status = winreg_printer_binding_handle(p->mem_ctx,
     2246        tmp_ctx = talloc_new(p->mem_ctx);
     2247        if (!tmp_ctx) {
     2248                return WERR_NOMEM;
     2249        }
     2250
     2251        status = winreg_printer_binding_handle(tmp_ctx,
    21992252                                               get_session_info_system(),
    22002253                                               p->msg_ctx,
    22012254                                               &b);
    22022255        if (!W_ERROR_IS_OK(status)) {
    2203                 return status;
    2204         }
    2205 
    2206         status = winreg_get_driver(p->mem_ctx, b,
    2207                                    r->in.architecture,
    2208                                    r->in.driver,
    2209                                    version,
    2210                                    &info);
    2211         if (!W_ERROR_IS_OK(status)) {
     2256                goto done;
     2257        }
     2258
     2259        for (found = false, i = 0; drv_cversion[i] >= 0; i++) {
     2260                if ((r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION)
     2261                 && (drv_cversion[i] != r->in.version)) {
     2262                        continue;
     2263                }
     2264
     2265                /* check if a driver with this version exists before delete */
     2266                status = winreg_get_driver(tmp_ctx, b,
     2267                                           r->in.architecture, r->in.driver,
     2268                                           drv_cversion[i], &info);
     2269                if (!W_ERROR_IS_OK(status)) {
     2270                        DEBUG(5, ("skipping del of driver with version %d\n",
     2271                                  drv_cversion[i]));
     2272                        continue;
     2273                }
     2274                found = true;
     2275
     2276                status = spoolss_dpd_version(tmp_ctx, p, r, b, info);
     2277                if (!W_ERROR_IS_OK(status)) {
     2278                        DEBUG(0, ("failed to delete driver with version %d\n",
     2279                                  drv_cversion[i]));
     2280                        goto done;
     2281                }
     2282        }
     2283        if (found == false) {
     2284                DEBUG(0, ("driver %s not found for deletion\n", r->in.driver));
    22122285                status = WERR_UNKNOWN_PRINTER_DRIVER;
    2213 
    2214                 /*
    2215                  * if the client asked for a specific version,
    2216                  * or this is something other than Windows NT x86,
    2217                  * then we've failed
    2218                  */
    2219 
    2220                 if ( (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) || (version !=2) )
    2221                         goto done;
    2222 
    2223                 /* try for Win2k driver if "Windows NT x86" */
    2224 
    2225                 version = 3;
    2226                 status = winreg_get_driver(info, b,
    2227                                            r->in.architecture,
    2228                                            r->in.driver,
    2229                                            version, &info);
    2230                 if (!W_ERROR_IS_OK(status)) {
    2231                         status = WERR_UNKNOWN_PRINTER_DRIVER;
    2232                         goto done;
    2233                 }
    2234         }
    2235 
    2236         if (printer_driver_in_use(info,
    2237                                   get_session_info_system(),
    2238                                   p->msg_ctx,
    2239                                   info)) {
    2240                 status = WERR_PRINTER_DRIVER_IN_USE;
    2241                 goto done;
    2242         }
    2243 
    2244         /*
    2245          * we have a couple of cases to consider.
    2246          * (1) Are any files in use?  If so and DPD_DELTE_ALL_FILE is set,
    2247          *     then the delete should fail if **any** files overlap with
    2248          *     other drivers
    2249          * (2) If DPD_DELTE_UNUSED_FILES is sert, then delete all
    2250          *     non-overlapping files
    2251          * (3) If neither DPD_DELTE_ALL_FILE nor DPD_DELTE_ALL_FILES
    2252          *     is set, the do not delete any files
    2253          * Refer to MSDN docs on DeletePrinterDriverEx() for details.
    2254          */
    2255 
    2256         delete_files = r->in.delete_flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES);
    2257 
    2258         /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */
    2259 
    2260         if (delete_files &&
    2261             (r->in.delete_flags & DPD_DELETE_ALL_FILES) &&
    2262             printer_driver_files_in_use(info,
    2263                                         get_session_info_system(),
    2264                                         p->msg_ctx,
    2265                                         info)) {
    2266                 /* no idea of the correct error here */
    2267                 status = WERR_ACCESS_DENIED;
    2268                 goto done;
    2269         }
    2270 
    2271 
    2272         /* also check for W32X86/3 if necessary; maybe we already have? */
    2273 
    2274         if ( (version == 2) && ((r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION)  ) {
    2275                 status = winreg_get_driver(info, b,
    2276                                            r->in.architecture,
    2277                                            r->in.driver, 3, &info_win2k);
    2278                 if (W_ERROR_IS_OK(status)) {
    2279 
    2280                         if (delete_files &&
    2281                             (r->in.delete_flags & DPD_DELETE_ALL_FILES) &&
    2282                             printer_driver_files_in_use(info,
    2283                                                         get_session_info_system(),
    2284                                                         p->msg_ctx,
    2285                                                         info_win2k)) {
    2286                                 /* no idea of the correct error here */
    2287                                 talloc_free(info_win2k);
    2288                                 status = WERR_ACCESS_DENIED;
    2289                                 goto done;
    2290                         }
    2291 
    2292                         /* if we get to here, we now have 2 driver info structures to remove */
    2293                         /* remove the Win2k driver first*/
    2294 
    2295                         status = winreg_del_driver(info, b,
    2296                                                    info_win2k,
    2297                                                    3);
    2298 
    2299                         /* this should not have failed---if it did, report to client */
    2300 
    2301                         if (!W_ERROR_IS_OK(status)) {
    2302                                 goto done;
    2303                         }
    2304 
    2305                         /*
    2306                          * now delete any associated files if delete_files is
    2307                          * true. Even if this part failes, we return succes
    2308                          * because the driver doesn not exist any more
    2309                          */
    2310                         if (delete_files) {
    2311                                 delete_driver_files(get_session_info_system(),
    2312                                                     info_win2k);
    2313                         }
    2314                 }
    2315         }
    2316 
    2317         status = winreg_del_driver(info, b,
    2318                                    info,
    2319                                    version);
    2320         if (!W_ERROR_IS_OK(status)) {
    2321                 goto done;
    2322         }
    2323 
    2324         /*
    2325          * now delete any associated files if delete_files is
    2326          * true. Even if this part failes, we return succes
    2327          * because the driver doesn not exist any more
    2328          */
    2329         if (delete_files) {
    2330                 delete_driver_files(get_session_info_system(), info);
     2286        } else {
     2287                status = WERR_OK;
    23312288        }
    23322289
    23332290done:
    2334         talloc_free(info);
     2291        talloc_free(tmp_ctx);
    23352292        return status;
    23362293}
     
    32633220                                        TALLOC_CTX *mem_ctx)
    32643221{
    3265         SETUP_SPOOLSS_NOTIFY_DATA_INTEGER(data, queue->job);
     3222        SETUP_SPOOLSS_NOTIFY_DATA_INTEGER(data, queue->sysjob);
    32663223}
    32673224
     
    36963653        }
    36973654
     3655        /*
     3656         * When sending a PRINTER_NOTIFY_FIELD_SERVER_NAME we should send the
     3657         * correct servername.
     3658         */
     3659        pinfo2->servername = talloc_strdup(pinfo2, Printer->servername);
     3660        if (pinfo2->servername == NULL) {
     3661                return WERR_NOMEM;
     3662        }
     3663
    36983664        for (i=0; i<option->count; i++) {
    36993665                option_type = option->types[i];
     
    37203686                                                           pinfo2, snum,
    37213687                                                           &option_type,
    3722                                                            queue[j].job,
     3688                                                           queue[j].sysjob,
    37233689                                                           mem_ctx);
    37243690                        }
     
    68186784        t = gmtime(&queue->time);
    68196785
    6820         r->job_id               = queue->job;
     6786        r->job_id               = queue->sysjob;
    68216787
    68226788        r->printer_name         = talloc_strdup(mem_ctx, lp_servicename(snum));
     
    68596825        t = gmtime(&queue->time);
    68606826
    6861         r->job_id               = queue->job;
     6827        r->job_id               = queue->sysjob;
    68626828
    68636829        r->printer_name         = talloc_strdup(mem_ctx, lp_servicename(snum));
     
    69126878                             struct spoolss_PrinterInfo2 *pinfo2)
    69136879{
    6914         r->job_id               = queue->job;
     6880        r->job_id               = queue->sysjob;
    69156881        r->next_job_id          = 0;
    69166882        if (next_queue) {
    6917                 r->next_job_id  = next_queue->job;
     6883                r->next_job_id  = next_queue->sysjob;
    69186884        }
    69196885        r->reserved             = 0;
     
    72247190                break;
    72257191        case SPOOLSS_JOB_CONTROL_PAUSE:
    7226                 if (print_job_pause(session_info, p->msg_ctx,
    7227                                     snum, r->in.job_id, &errcode)) {
    7228                         errcode = WERR_OK;
    7229                 }
     7192                errcode = print_job_pause(session_info, p->msg_ctx,
     7193                                          snum, r->in.job_id);
    72307194                break;
    72317195        case SPOOLSS_JOB_CONTROL_RESTART:
    72327196        case SPOOLSS_JOB_CONTROL_RESUME:
    7233                 if (print_job_resume(session_info, p->msg_ctx,
    7234                                      snum, r->in.job_id, &errcode)) {
    7235                         errcode = WERR_OK;
    7236                 }
     7197                errcode = print_job_resume(session_info, p->msg_ctx,
     7198                                           snum, r->in.job_id);
    72377199                break;
    72387200        case 0:
     
    90639025
    90649026        for (i=0; i<count; i++) {
    9065                 if (queue[i].job == (int)jobid) {
     9027                if (queue[i].sysjob == (int)jobid) {
    90669028                        found = true;
    90679029                        break;
     
    90989060
    90999061        for (i=0; i<count; i++) {
    9100                 if (queue[i].job == (int)jobid) {
     9062                if (queue[i].sysjob == (int)jobid) {
    91019063                        found = true;
    91029064                        break;
     
    91169078         */
    91179079
    9118         devmode = print_job_devmode(lp_const_servicename(snum), jobid);
     9080        devmode = print_job_devmode(mem_ctx, lp_const_servicename(snum), jobid);
    91199081        if (!devmode) {
    91209082                result = spoolss_create_default_devmode(mem_ctx,
Note: See TracChangeset for help on using the changeset viewer.