Changes from APPLIANCE_HEAD:
authorDavid O'Neill <dmo@samba.org>
Wed, 17 Jan 2001 18:47:46 +0000 (18:47 +0000)
committerDavid O'Neill <dmo@samba.org>
Wed, 17 Jan 2001 18:47:46 +0000 (18:47 +0000)
    source/rpc_server/srv_spoolss_nt.c
        - Unrolled construct_notify_jobs_info() loop to only fetch
          printer info_2 structure once rather than num_print_jobs times.
        - convert command to unix codepage.
        - remove lp_remove_service() call as it prevents lp_killservice()
          from working.
        - Modified some DEBUG and DEBUGADD statements.

    source/param/loadparm.c
    source/param/params.c
        - change printer, preload, auto services to FLAG_DOS_STRING,
          reverted earlier changes to szPrintername et al, add comments.

    source/printing/load.c
        - fix bug with lp_auto_services() and strtok()

    source/printing/nt_printing.c
    source/printing/printing.c
        - remove redundant test that used SERVICE(snum)

    source/printing/pcap.c
        - add unix_to_dos() calls, add notes wrt FIXMEs for
          xxx_printer_fn() functions.

    source/web/swat.c
        - added FIXME comment.

    source/smbd/service.c
        - added comment re: dos codepage
(This used to be commit 7b774b72c2857af9519012106714a9e2cb099da3)

source3/param/loadparm.c
source3/param/params.c
source3/printing/load.c
source3/printing/nt_printing.c
source3/printing/pcap.c
source3/printing/printing.c
source3/rpc_server/srv_spoolss_nt.c
source3/smbd/service.c
source3/web/swat.c

index 57e8f171898944529cbd4625e7b8704218f1d8f6..7750cb7ac7a3c8a738a6f32b759901a5b5a85b81 100644 (file)
@@ -830,8 +830,8 @@ static struct parm_struct parm_table[] = {
        {"deleteprinter command", P_STRING, P_GLOBAL, &Globals.szDeletePrinterCommand, NULL, NULL, 0},
        {"show add printer wizard", P_BOOL, P_GLOBAL, &Globals.bMsAddPrinterWizard, NULL, NULL, 0},
        
-       {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_PRINT},
-       {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, 0},
+       {"printer name", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_PRINT|FLAG_DOS_STRING},
+       {"printer", P_STRING, P_LOCAL, &sDefault.szPrintername, NULL, NULL, FLAG_DOS_STRING},
        {"printer driver", P_STRING, P_LOCAL, &sDefault.szPrinterDriver, NULL, NULL, FLAG_PRINT},
        {"printer driver file", P_STRING, P_LOCAL, &sDefault.szDriverFile, NULL, NULL, FLAG_PRINT},
        {"printer driver location", P_STRING, P_LOCAL, &sDefault.szPrinterDriverLocation, NULL, NULL, FLAG_PRINT | FLAG_GLOBAL},
@@ -938,8 +938,8 @@ static struct parm_struct parm_table[] = {
        {"smbrun", P_STRING, P_GLOBAL, &Globals.szSmbrun, NULL, NULL, 0},
        
        {"config file", P_STRING, P_GLOBAL, &Globals.szConfigFile, NULL, NULL, FLAG_HIDE},
-       {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, 0},
-       {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, 0},
+       {"preload", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_DOS_STRING},
+       {"auto services", P_STRING, P_GLOBAL, &Globals.szAutoServices, NULL, NULL, FLAG_DOS_STRING},
        {"lock dir", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, 0}, 
        {"lock directory", P_STRING, P_GLOBAL, &Globals.szLockDir, NULL, NULL, 0},
 #ifdef WITH_UTMP
@@ -1270,8 +1270,7 @@ static void init_globals(void)
        Globals.sslCompatibility = False;
 #endif /* WITH_SSL */
 
-/* 
-   these parameters are set to defaults that are more appropriate
+/* these parameters are set to defaults that are more appropriate
    for the increasing samba install base:
 
    as a member of the workgroup, that will possibly become a
@@ -1280,6 +1279,7 @@ static void init_globals(void)
 
    doesn't provide WINS server service by default (wsupp = False),
    and doesn't provide domain master browser services by default, either.
+
 */
 
        Globals.bMsAddPrinterWizard = True;
@@ -1690,7 +1690,7 @@ static void free_service(service * pservice)
 
 /***************************************************************************
 add a new service to the services array initialising it with the given 
-service
+service. name must be in DOS codepage.
 ***************************************************************************/
 static int add_a_service(service * pservice, char *name)
 {
@@ -1739,14 +1739,13 @@ static int add_a_service(service * pservice, char *name)
        if (name)
        {
                string_set(&iSERVICE(i).szService, name);
-               unix_to_dos(iSERVICE(i).szService, True);
        }
        return (i);
 }
 
 /***************************************************************************
 add a new home service, with the specified home directory, defaults coming 
-from service ifrom
+from service ifrom. homename must be in DOS codepage.
 ***************************************************************************/
 BOOL lp_add_home(char *pszHomename, int iDefaultService, char *pszHomedir)
 {
@@ -1775,7 +1774,7 @@ BOOL lp_add_home(char *pszHomename, int iDefaultService, char *pszHomedir)
 }
 
 /***************************************************************************
-add a new service, based on an old one
+add a new service, based on an old one. pszService must be in DOS codepage.
 ***************************************************************************/
 int lp_add_service(char *pszService, int iDefaultService)
 {
@@ -1817,7 +1816,8 @@ static BOOL lp_add_ipc(void)
 
 
 /***************************************************************************
-add a new printer service, with defaults coming from service iFrom
+add a new printer service, with defaults coming from service iFrom.
+printername must be in DOS codepage.
 ***************************************************************************/
 BOOL lp_add_printer(char *pszPrintername, int iDefaultService)
 {
@@ -1834,9 +1834,7 @@ BOOL lp_add_printer(char *pszPrintername, int iDefaultService)
 
        /* the printer name is set to the service name. */
        string_set(&iSERVICE(i).szPrintername, pszPrintername);
-       unix_to_dos(iSERVICE(i).szPrintername, True);
        string_set(&iSERVICE(i).comment, comment);
-       unix_to_dos(iSERVICE(i).comment, True);
        iSERVICE(i).bBrowseable = sDefault.bBrowseable;
        /* Printers cannot be read_only. */
        iSERVICE(i).bRead_only = False;
@@ -2734,7 +2732,7 @@ void init_locals(void)
 /***************************************************************************
 Process a new section (service). At this stage all sections are services.
 Later we'll have special sections that permit server parameters to be set.
-Returns True on success, False on failure.
+Returns True on success, False on failure. SectionName must be in DOS codepage.
 ***************************************************************************/
 static BOOL do_section(char *pszSectionName)
 {
@@ -3037,6 +3035,7 @@ void lp_add_one_printer(char *name, char *comment)
                if ((i = lp_servicenumber(name)) >= 0)
                {
                        string_set(&iSERVICE(i).comment, comment);
+            unix_to_dos(iSERVICE(i).comment, True);
                        iSERVICE(i).autoloaded = True;
                }
        }
@@ -3448,7 +3447,7 @@ void lp_remove_service(int snum)
 }
 
 /*******************************************************************
-copy a service
+copy a service. new_name must be in dos codepage
 ********************************************************************/
 void lp_copy_service(int snum, char *new_name)
 {
index 9cb6412b960a2f5f1159e81018d8257451add758..b359b269d4e380a4a669ca985f263ec641c774b8 100644 (file)
@@ -271,7 +271,7 @@ static BOOL Section( myFILE *InFile, BOOL (*sfunc)(char *) )
           DEBUG(0, ("%s Empty section name in configuration file.\n", func ));
           return( False );
           }
-        if( !sfunc( bufr ) )            /* Got a valid name.  Deal with it. */
+        if( !sfunc( unix_to_dos(bufr,True) ) )            /* Got a valid name.  Deal with it. */
           return( False );
         (void)EatComment( InFile );     /* Finish off the line.             */
         return( True );
index fbf10d22b87f81680410ca936ddcf97ba8c84930..275ffa21edc66b1786faeb86fc4006b6e4f3c47b 100644 (file)
@@ -41,13 +41,16 @@ static void add_auto_printers(void)
 {
        char *p;
        int printers;
-       char *str = lp_auto_services();
+       char *str = strdup(lp_auto_services());
 
        if (!str) return;
 
        printers = lp_servicenumber(PRINTERS_NAME);
 
-       if (printers < 0) return;
+       if (printers < 0) {
+               free(str);
+               return;
+       }
        
        for (p=strtok(str,LIST_SEP);p;p=strtok(NULL,LIST_SEP)) {
                if (lp_servicenumber(p) >= 0) continue;
@@ -56,6 +59,8 @@ static void add_auto_printers(void)
                        lp_add_printer(p,printers);
                }
        }
+
+       free(str);
 }
 
 /***************************************************************************
index 2572a98bdea495315df7d9fa91ddaece0b6511a5..7b84f9516140d21a99b9fc589bcd81bec39350fd 100644 (file)
@@ -3043,9 +3043,6 @@ BOOL print_access_check(struct current_user *user, int snum, int access_type)
 
        pname = PRINTERNAME(snum);
 
-       if (!pname || !*pname)
-               pname = SERVICE(snum);
-
        if (!pname || !*pname) {
                errno = EACCES;
                return False;
index fb2409fd38b659126d097afdb52ce09137386ffc..e9c2e460906f9e5ab2eabd0be15b764daa324082 100644 (file)
@@ -244,7 +244,10 @@ static BOOL ScanQconfig(char *psz,char *pszPrintername)
 Scan printcap file pszPrintcapname for a printer called pszPrintername. 
 Return True if found, else False. Returns False on error, too, after logging 
 the error at level 0. For generality, the printcap name may be passed - if
-passed as NULL, the configuration will be queried for the name.
+passed as NULL, the configuration will be queried for the name. pszPrintername
+must be in DOS codepage.
+The xxx_printername_ok functions need fixing to understand they are being
+given a DOS codepage. FIXME !! JRA.
 ***************************************************************************/
 BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname)
 {
@@ -293,6 +296,8 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname)
       if (*line == '#' || *line == 0)
        continue;
 
+      unix_to_dos(line,True);
+
       /* now we have a real printer line - cut it off at the first : */      
       p = strchr(line,':');
       if (p) *p = 0;
@@ -322,7 +327,9 @@ BOOL pcap_printername_ok(char *pszPrintername, char *pszPrintcapname)
 
 /***************************************************************************
 run a function on each printer name in the printcap file. The function is 
-passed the primary name and the comment (if possible)
+passed the primary name and the comment (if possible). Note the fn() takes
+strings in DOS codepage. This means the xxx_printer_fn() calls must be fixed
+to return DOS codepage. FIXME !! JRA.
 ***************************************************************************/
 void pcap_printer_fn(void (*fn)(char *, char *))
 {
@@ -376,6 +383,8 @@ void pcap_printer_fn(void (*fn)(char *, char *))
       p = strchr(line,':');
       if (p) *p = 0;
       
+      unix_to_dos(line,True);
+
       /* now find the most likely printer name and comment 
        this is pure guesswork, but it's better than nothing */
       *name = 0;
index 3f8c542ec7d57575ad8a0c996a0f34036f07da57..3ce58b5b78b73fd35e1ee4dc7d6af11eea7161e5 100644 (file)
@@ -164,7 +164,6 @@ static int print_run_command(int snum,char *command,
        va_end(ap);
   
        p = PRINTERNAME(snum);
-       if (!p || !*p) p = SERVICE(snum);
   
        pstring_sub(syscmd, "%p", p);
        standard_sub_snum(snum,syscmd);
index 4355e2eb5941e00fe1bae5929a463b4aeb602cd7..0654eea6f4e92ea509e0d649f02bd695a11dae18 100644 (file)
@@ -272,6 +272,7 @@ static BOOL delete_printer_handle(POLICY_HND *hnd)
                /* Printer->dev.handlename equals portname equals sharename */
                slprintf(command, sizeof(command), "%s \"%s\"", cmd,
                                        Printer->dev.handlename);
+               dos_to_unix(command, True);  /* Convert printername to unix-codepage */
                slprintf(tmp_file, sizeof(tmp_file), "%s/smbcmd.%d", path, local_pid);
 
                unlink(tmp_file);
@@ -289,7 +290,6 @@ static BOOL delete_printer_handle(POLICY_HND *hnd)
                kill(0, SIGHUP);
 
                if ( ( i = lp_servicenumber( Printer->dev.handlename ) ) >= 0 ) {
-                       lp_remove_service( i );
                        lp_killservice( i );
                        return True;
                } else
@@ -526,7 +526,8 @@ static BOOL open_printer_hnd(POLICY_HND *hnd, char *name)
                return False;
        }
 
-       DEBUG(5, ("%d printer handles active\n", ubi_dlCount(&Printer_list)));
+       DEBUG(5, ("%d printer handles active\n", 
+                 (int)ubi_dlCount(&Printer_list)));
 
        return True;
 }
@@ -1604,11 +1605,9 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO
        NT_PRINTER_INFO_LEVEL *printer = NULL;
        print_queue_struct *queue=NULL;
        
-       DEBUG(4,("construct_notify_printer_info\n"));
-       
        type=option_type->type;
 
-       DEBUGADD(4,("Notify type: [%s], number of notify info: [%d] on printer: [%s]\n",
+       DEBUG(4,("construct_notify_printer_info: Notify type: [%s], number of notify info: [%d] on printer: [%s]\n",
                (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"),
                option_type->count, lp_servicename(snum)));
        
@@ -1617,7 +1616,7 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO
 
        for(field_num=0; field_num<option_type->count; field_num++) {
                field = option_type->fields[field_num];
-               DEBUGADD(4,("notify [%d]: type [%x], field [%x]\n", field_num, type, field));
+               DEBUG(4,("construct_notify_printer_info: notify [%d]: type [%x], field [%x]\n", field_num, type, field));
 
                if (!search_notify(type, field, &j) )
                        continue;
@@ -1629,8 +1628,8 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO
 
                construct_info_data(current_data, type, field, id);             
 
-               DEBUG(10,("construct_notify_printer_info: calling %s\n",
-                               notify_info_data_table[j].name ));
+               DEBUG(10,("construct_notify_printer_info: calling [%s]  snum=%d  printername=[%s])\n",
+                               notify_info_data_table[j].name, snum, printer->info_2->printername ));
 
                notify_info_data_table[j].fn(snum, current_data, queue, printer);
 
@@ -1646,14 +1645,17 @@ static BOOL construct_notify_printer_info(SPOOL_NOTIFY_INFO *info, int snum, SPO
  * fill a notify_info struct with info asked
  *
  ********************************************************************/
-static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_INFO *info, int snum, SPOOL_NOTIFY_OPTION_TYPE *option_type, uint32 id)
+static BOOL construct_notify_jobs_info(print_queue_struct *queue,
+                                      SPOOL_NOTIFY_INFO *info,
+                                      NT_PRINTER_INFO_LEVEL *printer,
+                                      int snum, SPOOL_NOTIFY_OPTION_TYPE
+                                      *option_type, uint32 id) 
 {
        int field_num,j;
        uint16 type;
        uint16 field;
 
        SPOOL_NOTIFY_INFO_DATA *current_data;
-       NT_PRINTER_INFO_LEVEL *printer = NULL;
        
        DEBUG(4,("construct_notify_jobs_info\n"));
        
@@ -1663,9 +1665,6 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I
                (option_type->type==PRINTER_NOTIFY_TYPE?"PRINTER_NOTIFY_TYPE":"JOB_NOTIFY_TYPE"),
                option_type->count));
 
-       if (get_a_printer(&printer, 2, lp_servicename(snum))!=0)
-               return False;
-       
        for(field_num=0; field_num<option_type->count; field_num++) {
                field = option_type->fields[field_num];
 
@@ -1683,7 +1682,6 @@ static BOOL construct_notify_jobs_info(print_queue_struct *queue, SPOOL_NOTIFY_I
                info->count++;
        }
 
-       free_a_printer(&printer, 2);    
        return True;
 }
 
@@ -1798,18 +1796,35 @@ static uint32 printer_notify_info(POLICY_HND *hnd, SPOOL_NOTIFY_INFO *info)
                
                switch ( option_type->type ) {
                case PRINTER_NOTIFY_TYPE:
-                       if(construct_notify_printer_info(info, snum, option_type, id))
+                       if(construct_notify_printer_info(info, snum,
+                                                        option_type, id))  
                                id--;
                        break;
                        
-               case JOB_NOTIFY_TYPE:
+               case JOB_NOTIFY_TYPE: {
+                       NT_PRINTER_INFO_LEVEL *printer = NULL;
+
                        memset(&status, 0, sizeof(status));     
                        count = print_queue_status(snum, &queue, &status);
-                       for (j=0; j<count; j++)
-                               construct_notify_jobs_info(&queue[j], info, snum, option_type, queue[j].job);
+
+                       if (get_a_printer(&printer, 2, 
+                                         lp_servicename(snum)) != 0)
+                               goto done;
+
+                       for (j=0; j<count; j++) {
+                               construct_notify_jobs_info(&queue[j], info,
+                                                          printer, snum,
+                                                          option_type,
+                                                          queue[j].job); 
+                       }
+
+                       free_a_printer(&printer, 2);
+
+               done:
                        safe_free(queue);
                        break;
                }
+               }
        }
        
        /*
index 4670d601d7e6239713606d923324f9081230cd6b..1db5dc4a5f8d9c266a1a2348aa2e36c7cfec1242 100644 (file)
@@ -80,7 +80,7 @@ BOOL become_service(connection_struct *conn,BOOL do_chdir)
 
 
 /****************************************************************************
-  find a service entry
+  find a service entry. service is always in dos codepage
 ****************************************************************************/
 int find_service(char *service)
 {
index e0936d074191a0533be682cae2223b8162cef6e9..d0a78fb243207e5eda40b2ecbbc6405cf125b146 100644 (file)
@@ -520,7 +520,8 @@ static void globals_page(void)
 }
 
 /****************************************************************************
-  display a shares editing page  
+  display a shares editing page. share is in unix codepage, and must be in
+  dos codepage. FIXME !!! JRA.
 ****************************************************************************/
 static void shares_page(void)
 {
@@ -641,7 +642,7 @@ static BOOL change_password(const char *remote_machine, char *user_name,
        }
 
        if(!initialize_password_db(True)) {
-               printf("Can't initialize passdb!\n<p>");
+               printf("Can't setup password database vectors.\n<p>");
                return False;
        }