]> git.pld-linux.org Git - packages/samba.git/blob - samba-printerlocation.patch
- get PATH_MAX definition
[packages/samba.git] / samba-printerlocation.patch
1 diff -ur samba-3.0.25.orig/source/param/loadparm.c samba-3.0.25/source/param/loadparm.c
2 --- samba-3.0.25.orig/source/param/loadparm.c   2007-04-21 03:48:07.000000000 +0200
3 +++ samba-3.0.25/source/param/loadparm.c        2007-05-15 09:06:42.000000000 +0200
4 @@ -359,6 +359,7 @@
5         char *szHideFiles;
6         char *szVetoOplockFiles;
7         char *comment;
8 +       char *location;
9         char *force_user;
10         char *force_group;
11         char **readlist;
12 @@ -500,6 +501,7 @@
13         NULL,                   /* szHideFiles */
14         NULL,                   /* szVetoOplockFiles */
15         NULL,                   /* comment */
16 +       NULL,                   /* location */
17         NULL,                   /* force user */
18         NULL,                   /* force group */
19         NULL,                   /* readlist */
20 @@ -2044,6 +2046,7 @@
21  FN_LOCAL_STRING(lp_magicscript, szMagicScript)
22  FN_LOCAL_STRING(lp_magicoutput, szMagicOutput)
23  FN_LOCAL_STRING(lp_comment, comment)
24 +FN_LOCAL_STRING(lp_location, location)
25  FN_LOCAL_STRING(lp_force_user, force_user)
26  FN_LOCAL_STRING(lp_force_group, force_group)
27  FN_LOCAL_LIST(lp_readlist, readlist)
28 @@ -4114,7 +4117,7 @@
29   Auto-load one printer.
30  ***************************************************************************/
31  
32 -void lp_add_one_printer(char *name, char *comment)
33 +void lp_add_one_printer(char *name, char *comment, char *location)
34  {
35         int printers = lp_servicenumber(PRINTERS_NAME);
36         int i;
37 @@ -4123,6 +4126,7 @@
38                 lp_add_printer(name, printers);
39                 if ((i = lp_servicenumber(name)) >= 0) {
40                         string_set(&ServicePtrs[i]->comment, comment);
41 +                       string_set(&ServicePtrs[i]->location, location);
42                         ServicePtrs[i]->autoloaded = True;
43                 }
44         }
45 diff -ur samba-3.0.25.orig/source/printing/nt_printing.c samba-3.0.25/source/printing/nt_printing.c
46 --- samba-3.0.25.orig/source/printing/nt_printing.c     2007-05-11 00:09:34.000000000 +0200
47 +++ samba-3.0.25/source/printing/nt_printing.c  2007-05-15 13:58:02.000000000 +0200
48 @@ -3291,7 +3291,39 @@
49         }
50  
51         ads_destroy(&ads);
52 -       ads_kdestroy("MEMORY:prtpub_cache");
53 +       return WERR_OK;
54 +}
55 +
56 +WERROR update_published_printer(NT_PRINTER_INFO_LEVEL *printer)
57 +{
58 +       ADS_STATUS ads_rc;
59 +       ADS_STRUCT *ads = NULL;
60 +
61 +       if (!(printer->info_2->attributes & PRINTER_ATTRIBUTE_PUBLISHED))
62 +               return WERR_OK;
63 +               
64 +       ads = ads_init(NULL, NULL, NULL);
65 +       if (!ads) {
66 +               DEBUG(3, ("ads_init() failed\n"));
67 +               return WERR_SERVER_UNAVAILABLE;
68 +       }
69 +       setenv(KRB5_ENV_CCNAME, "MEMORY:prtpub_cache", 1);
70 +       SAFE_FREE(ads->auth.password);
71 +       ads->auth.password = secrets_fetch_machine_password(lp_workgroup(),
72 +               NULL, NULL);
73 +
74 +       /* ads_connect() will find the DC for us */                                         
75 +       ads_rc = ads_connect(ads);
76 +       if (!ADS_ERR_OK(ads_rc)) {
77 +               DEBUG(3, ("ads_connect failed: %s\n", ads_errstr(ads_rc)));
78 +               ads_destroy(&ads);
79 +               ads_kdestroy("MEMORY:prtpub_cache");
80 +               return WERR_ACCESS_DENIED;
81 +       }
82 +
83 +       nt_printer_publish_ads(ads, printer);
84 +
85 +       ads_destroy(&ads);
86         return WERR_OK;
87  }
88  
89 @@ -3769,7 +3801,7 @@
90         fstrcpy(info->printprocessor, "winprint");
91         fstrcpy(info->datatype, "RAW");
92  
93 -#ifdef HAVE_CUPS
94 +#ifdef HAVE_CUPS_BLOAT
95         if ( (enum printing_types)lp_printing(snum) == PRINT_CUPS ) {           
96                 /* Pull the location and comment strings from cups if we don't
97                    already have one */
98 @@ -3873,7 +3905,7 @@
99  
100         fstrcpy(info->printername, printername);
101  
102 -#ifdef HAVE_CUPS
103 +#ifdef HAVE_CUPS_BLOAT
104         if ( (enum printing_types)lp_printing(snum) == PRINT_CUPS ) {           
105                 /* Pull the location and comment strings from cups if we don't
106                    already have one */
107 diff -ur samba-3.0.25.orig/source/printing/pcap.c samba-3.0.25/source/printing/pcap.c
108 --- samba-3.0.25.orig/source/printing/pcap.c    2005-10-18 04:44:57.000000000 +0200
109 +++ samba-3.0.25/source/printing/pcap.c 2007-05-15 09:06:42.000000000 +0200
110 @@ -67,12 +67,13 @@
111  typedef struct pcap_cache {
112         char *name;
113         char *comment;
114 +       char *location;
115         struct pcap_cache *next;
116  } pcap_cache_t;
117  
118  static pcap_cache_t *pcap_cache = NULL;
119  
120 -BOOL pcap_cache_add(const char *name, const char *comment)
121 +BOOL pcap_cache_add(const char *name, const char *comment, const char *location)
122  {
123         pcap_cache_t *p;
124  
125 @@ -81,6 +82,7 @@
126  
127         p->name = SMB_STRDUP(name);
128         p->comment = (comment && *comment) ? SMB_STRDUP(comment) : NULL;
129 +       p->location = (location && *location) ? SMB_STRDUP(location) : NULL;
130  
131         p->next = pcap_cache;
132         pcap_cache = p;
133 @@ -97,6 +99,7 @@
134  
135                 SAFE_FREE(p->name);
136                 SAFE_FREE(p->comment);
137 +               SAFE_FREE(p->location);
138                 SAFE_FREE(p);
139         }
140  }
141 @@ -210,7 +213,7 @@
142                 if (printing == PRINT_LPRNG && *name == '.')
143                         continue;
144  
145 -               if (*name && !pcap_cache_add(name, comment)) {
146 +               if (*name && !pcap_cache_add(name, comment, NULL)) {
147                         x_fclose(pcap_file);
148                         goto done;
149                 }
150 @@ -252,12 +255,12 @@
151  
152  XXX: I'm not sure if this comment still applies.. Anyone?  -Rob
153  ***************************************************************************/
154 -void pcap_printer_fn(void (*fn)(char *, char *))
155 +void pcap_printer_fn(void (*fn)(char *, char *, char *))
156  {
157         pcap_cache_t *p;
158  
159         for (p = pcap_cache; p != NULL; p = p->next)
160 -               fn(p->name, p->comment);
161 +               fn(p->name, p->comment, p->location);
162  
163         return;
164  }
165 diff -ur samba-3.0.25.orig/source/printing/print_aix.c samba-3.0.25/source/printing/print_aix.c
166 --- samba-3.0.25.orig/source/printing/print_aix.c       2005-02-25 18:59:28.000000000 +0100
167 +++ samba-3.0.25/source/printing/print_aix.c    2007-05-15 09:06:42.000000000 +0200
168 @@ -75,7 +75,7 @@
169                                 /* name is found without stanza device  */
170                                 /* probably a good printer ???          */
171                                 iEtat = 0;
172 -                               if (!pcap_cache_add(name, NULL)) {
173 +                               if (!pcap_cache_add(name, NULL, NULL)) {
174                                         safe_free(line);
175                                         x_fclose(pfile);
176                                         return False;
177 @@ -89,7 +89,7 @@
178                         } else if (strstr_m(line, "device")) {
179                                 /* it's a good virtual printer */
180                                 iEtat = 0;
181 -                               if (!pcap_cache_add(name, NULL)) {
182 +                               if (!pcap_cache_add(name, NULL, NULL)) {
183                                         safe_free(line);
184                                         x_fclose(pfile);
185                                         return False;
186 diff -ur samba-3.0.25.orig/source/printing/print_cups.c samba-3.0.25/source/printing/print_cups.c
187 --- samba-3.0.25.orig/source/printing/print_cups.c      2007-04-09 19:30:57.000000000 +0200
188 +++ samba-3.0.25/source/printing/print_cups.c   2007-05-15 09:06:42.000000000 +0200
189 @@ -83,11 +83,13 @@
190         ipp_attribute_t *attr;          /* Current attribute */
191         cups_lang_t     *language = NULL;       /* Default language */
192         char            *name,          /* printer-name attribute */
193 -                       *info;          /* printer-info attribute */
194 +                       *info,          /* printer-info attribute */
195 +                       *location;              /* printer-location attribute */
196         static const char *requested[] =/* Requested attributes */
197                         {
198                           "printer-name",
199                           "printer-info"
200 +                         "printer-location"
201                         };       
202         BOOL ret = False;
203  
204 @@ -161,6 +163,7 @@
205  
206                 name       = NULL;
207                 info       = NULL;
208 +               location   = NULL;
209  
210                 while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) {
211                         if (strcmp(attr->name, "printer-name") == 0 &&
212 @@ -171,6 +174,10 @@
213                             attr->value_tag == IPP_TAG_TEXT)
214                                 info = attr->values[0].string.text;
215  
216 +                               if (strcmp(attr->name, "printer-location") == 0 &&
217 +                                       attr->value_tag == IPP_TAG_TEXT)
218 +                               location = attr->values[0].string.text;
219 +
220                         attr = attr->next;
221                 }
222  
223 @@ -181,7 +188,7 @@
224                 if (name == NULL)
225                         break;
226  
227 -               if (!pcap_cache_add(name, info)) {
228 +               if (!pcap_cache_add(name, info, location)) {
229                         goto out;
230                 }
231         }
232 @@ -241,6 +248,7 @@
233  
234                 name       = NULL;
235                 info       = NULL;
236 +               location   = NULL;
237  
238                 while (attr != NULL && attr->group_tag == IPP_TAG_PRINTER) {
239                         if (strcmp(attr->name, "printer-name") == 0 &&
240 @@ -251,6 +259,10 @@
241                             attr->value_tag == IPP_TAG_TEXT)
242                                 info = attr->values[0].string.text;
243  
244 +                               if (strcmp(attr->name, "printer-location") == 0 &&
245 +                           attr->value_tag == IPP_TAG_TEXT)
246 +                               info = attr->values[0].string.text;
247 +
248                         attr = attr->next;
249                 }
250  
251 @@ -261,7 +273,7 @@
252                 if (name == NULL)
253                         break;
254  
255 -               if (!pcap_cache_add(name, info)) {
256 +               if (!pcap_cache_add(name, info, location)) {
257                         goto out;
258                 }
259         }
260 diff -ur samba-3.0.25.orig/source/printing/print_iprint.c samba-3.0.25/source/printing/print_iprint.c
261 --- samba-3.0.25.orig/source/printing/print_iprint.c    2007-03-01 05:54:09.000000000 +0100
262 +++ samba-3.0.25/source/printing/print_iprint.c 2007-05-15 09:06:42.000000000 +0200
263 @@ -297,7 +297,7 @@
264                 */
265  
266                 if (name != NULL && !secure && smb_enabled) 
267 -                       pcap_cache_add(name, info);
268 +                       pcap_cache_add(name, info, NULL);
269         }
270  
271   out:
272 diff -ur samba-3.0.25.orig/source/printing/print_svid.c samba-3.0.25/source/printing/print_svid.c
273 --- samba-3.0.25.orig/source/printing/print_svid.c      2005-12-02 20:21:45.000000000 +0100
274 +++ samba-3.0.25/source/printing/print_svid.c   2007-05-15 09:06:42.000000000 +0200
275 @@ -111,7 +111,7 @@
276                         *tmp = '\0';
277                 
278                 /* add it to the cache */
279 -               if (!pcap_cache_add(name, NULL)) {
280 +               if (!pcap_cache_add(name, NULL, NULL)) {
281                         file_lines_free(lines);
282                         return False;
283                 }
284 diff -ur samba-3.0.25.orig/source/rpcclient/cmd_spoolss.c samba-3.0.25/source/rpcclient/cmd_spoolss.c
285 --- samba-3.0.25.orig/source/rpcclient/cmd_spoolss.c    2007-05-11 00:09:33.000000000 +0200
286 +++ samba-3.0.25/source/rpcclient/cmd_spoolss.c 2007-05-15 10:38:35.000000000 +0200
287 @@ -476,19 +476,23 @@
288         fstring         printername,
289                         servername,
290                         user,
291 -                       comment;
292 +                       comment,
293 +                   location;
294  
295 -       if (argc == 1 || argc > 3) {
296 -               printf("Usage: %s printername comment\n", argv[0]);
297 +       if (argc == 1 || argc > 4) {
298 +               printf("Usage: %s printername comment [location]\n", argv[0]);
299  
300                 return WERR_OK;
301         }
302  
303         /* Open a printer handle */
304 -       if (argc == 3) {
305 +       if (argc >= 3) {
306                 fstrcpy(comment, argv[2]);
307         }
308 -
309 +       if (argc == 4) {
310 +               fstrcpy(location, argv[3]);
311 +       }
312 +       
313         slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
314         strupper_m(servername);
315         slprintf(printername, sizeof(servername)-1, "%s\\%s", servername, argv[1]);
316 @@ -513,12 +517,15 @@
317  
318         /* Modify the comment. */
319         init_unistr(&ctr.printers_2->comment, comment);
320 +       /* Modify the location. */
321 +       if (argc == 4) 
322 +               init_unistr(&ctr.printers_2->location, location);
323         ctr.printers_2->devmode = NULL;
324         ctr.printers_2->secdesc = NULL;
325  
326         result = rpccli_spoolss_setprinter(cli, mem_ctx, &pol, info_level, &ctr, 0);
327         if (W_ERROR_IS_OK(result))
328 -               printf("Success in setting comment.\n");
329 +               printf("Success in setting comment%s.\n", argc==4?" and location":"");
330  
331   done:
332         if (opened_hnd)
333 diff -ur samba-3.0.25.orig/source/rpc_server/srv_spoolss_nt.c samba-3.0.25/source/rpc_server/srv_spoolss_nt.c
334 --- samba-3.0.25.orig/source/rpc_server/srv_spoolss_nt.c        2007-05-11 00:09:35.000000000 +0200
335 +++ samba-3.0.25/source/rpc_server/srv_spoolss_nt.c     2007-05-15 11:44:07.000000000 +0200
336 @@ -2901,7 +2901,10 @@
337         pstring temp;
338         uint32 len;
339  
340 -       len = rpcstr_push(temp, printer->info_2->location,sizeof(temp)-2, STR_TERMINATE);
341 +       if (*printer->info_2->location == '\0')
342 +               len = rpcstr_push(temp, lp_location(snum), sizeof(temp)-2, STR_TERMINATE);
343 +       else
344 +               len = rpcstr_push(temp, printer->info_2->location,sizeof(temp)-2, STR_TERMINATE);
345  
346         data->notify_data.data.length = len;
347         if (len) {
348 @@ -4204,8 +4207,10 @@
349                 init_unistr(&printer->comment, lp_comment(snum));                       /* comment */   
350         else
351                 init_unistr(&printer->comment, ntprinter->info_2->comment); /* saved comment. */
352 -
353 -       init_unistr(&printer->location, ntprinter->info_2->location);           /* location */  
354 +       if (*ntprinter->info_2->location == '\0')
355 +               init_unistr(&printer->location, lp_location(snum));                     /* location */  
356 +       else
357 +               init_unistr(&printer->location, ntprinter->info_2->location);           /* location */  
358         init_unistr(&printer->sepfile, ntprinter->info_2->sepfile);             /* separator file */
359         init_unistr(&printer->printprocessor, ntprinter->info_2->printprocessor);/* print processor */
360         init_unistr(&printer->datatype, ntprinter->info_2->datatype);           /* datatype */  
361 @@ -6341,6 +6346,13 @@
362         /* Update printer info */
363         result = mod_a_printer(printer, 2);
364  
365 +       /* Update ADS entry */
366 +       if (W_ERROR_IS_OK(result) && lp_security() == SEC_ADS &&
367 +               ( !strequal(printer->info_2->comment, old_printer->info_2->comment)
368 +                 || !strequal(printer->info_2->location, old_printer->info_2->location)
369 +                 || !strequal(printer->info_2->printername, old_printer->info_2->printername))) {
370 +               update_published_printer (printer);
371 +       }
372  done:
373         free_a_printer(&printer, 2);
374         free_a_printer(&old_printer, 2);
This page took 0.087612 seconds and 3 git commands to generate.